+
    2j/                        R t ^ RIHt ^ RIHt ^ RIHtHt ^ RIH	t	H
t
Ht ^RIHt ^RIHt ]'       d   ^ RIHt ^RIHt ^R	IHt  ! R
 R]4      tRR/R R lltR R ltR R ltR R ltR R ltR# )a  Decision-aware look-ahead for :class:`nab_python.provider.Provider`.

Owns ``_look_ahead_ok`` and the pending-block tables that record why a
candidate was rejected.  ``flush_pending_blocks`` turns those into
incompatibilities at the end of ``choose_version``.  A decision or
positive-range rejection becomes a grouped binary incompatibility
(``{candidate range, blocker range}``).  Version-derived terms are
widened onto the listing's gaps, which leaves the selectable versions
they name unchanged.  The blocker term widens further when every
rejection in the group recorded a dependency range: each fired because
the blocker sat outside that range, so every blocker version outside
their union repeats the same rejections.  Groups queued without ranges,
such as the extras block path, keep the narrower term.

A root-requirement or metadata rejection has no blocker to name: nothing
later in the resolve undoes it, so its versions are banned outright.
)annotations)defaultdict)TYPE_CHECKING
NamedTuple)IncompatibilityIncompatibilityCauseTerm)VersionRange)canonicalize_name)Iterable)Version)Providerc                  R    ] tR t^$t$ RtR]R&   R]R&   ]R R l4       tR R	 ltR
t	R# )DepRangeUniona>  The blocker constraints recorded by one pending group.

``union`` accumulates the dependency range each rejected candidate
declared on the blocker; ``covered`` counts the rejections that
contributed one.  Widening needs the whole group, so a flush declines
when ``covered`` falls short of the group's rejection count.
intcoveredr	   unionc                   V ^8  d   QhRR/# )   returnr    )formats   "i/home/user/billing-ledger-validation/.venv/lib/python3.14/site-packages/nab_python/_provider/lookahead.py__annotate__DepRangeUnion.__annotate__1   s     , ,] ,    c                :    V ! ^ \         P                  ! 4       4      # )z0Return an accumulator with nothing recorded yet.)r	   empty)clss   &r   zeroDepRangeUnion.zero0   s     1l((*++r   c                    V ^8  d   QhRRRR/# )r   	dep_ranger	   r   r   r   )r   s   "r   r   r   5   s     G G G Gr   c                ^    \        V P                  ^,           V P                  V,          4      # )zBReturn this accumulator with one more rejection's range folded in.)r   r   r   )selfr"   s   &&r   recordDepRangeUnion.record5   s!    T\\A-tzzI/EFFr   r   N)
__name__
__module____qualname____firstlineno____doc____annotations__classmethodr   r%   __static_attributes__r   r   r   r   r   $   s2     L, ,G Gr   r   check_decisionsTc          
     ,    V ^8  d   QhRRRRRRRRR	R/# )
r   providerr   packagestrversionr   r/   boolr   r   )r   s   "r   r   r   :   sA     K KKK K
 K 
Kr   c                  ^RI Hp V P                  V4      ^,          e   R# W3pWPP                  9  d    V P	                  W4       V P                  P                  V/ 4      pV'       d   V P                  MRpVP                  4        EF  w  r\        V	4      pWP                  9   dR   V P                  V,          pV
P                  V4      '       d(   V P                  WW3,          P                  V4        R# Vf   Kx  VP                  V4      pVe_   W9  dY   WV3pV P                   V,          P                  V4       V P"                  V,          P%                  V
4      V P"                  V&    R# V P&                  P                  V4      pVf   EK  Ve   EK  V
P                  V4      '       g   EK.  WV3pV P(                  V,          P                  V4       V P*                  V,          P%                  V
4      V P*                  V&    R# 	  R#   T dA   pT P
                  \        T4      ,          P                  T\        T4      4        Rp?R# Rp?ii ; i)a  Check candidate compatibility with root reqs and decisions.

With ``check_decisions=False`` only the root-requirement check runs;
used for "subsequent candidate" iterations to avoid per-candidate clause
growth on tight version-locks.  Extras proxies are skipped (the base's
look-ahead is sufficient).

``MetadataError`` (including ``UnsupportedSdistError``) is treated as a
rejection so the resolver moves on; the message is recorded for the
eventual no-versions diagnostic.
)MetadataErrorNTF)r1   r7   split_and_normalize
deps_cacheget_dependenciespending_metadata_blocksr
   
setdefaultr3   getsolution_decisionsitemsroot_requirementsis_disjointpending_root_blocksappendpending_blockspending_decision_dep_rangesr%   solution_rangespending_range_blockspending_range_dep_ranges)r1   r2   r4   r/   r7   	cache_keyexcdeps	decisionsdep_namer"   dep_normalized
root_rangedecided_versiondecision_key	pos_range	range_keys   &&&$             r   look_ahead_okrT   :   s   & )##G,Q/;"I+++	%%g7 ""9b1D/>++DI#zz|*84777!33NCJ$$Z00,,iD&/ 'mmN;O*/O 'I''5<<WE88FMMiX 44\B  !0044^DI%#+)))44$i@	--i8??H55i@GG	R 11)< I  ,L _  	,,->w-GHSSS 		s   H I5IIc               (    V ^8  d   QhRRRRRRRR/# )	r   r1   r   r2   r3   r4   r   r   r	   r   )r   s   "r   r   r      s2     
K 
K
K!$
K/6
K
Kr   c                \    V P                  W4      pVf   \        P                  ! V4      # T# )a
  Return ``version``'s widened neighbor gap, or its singleton without one.

Look-ahead needs the gap rather than a ``widen_decision`` span: the gap
contains ``version`` and no other listed version, so unions and merge
keys name exactly the versions the scan rejected.
)widen_decision_gapr	   	singleton)r1   r2   r4   wideneds   &&& r   _widen_or_singletonrZ      s.     ))';G.5o<!!'*J7Jr   c               (    V ^8  d   QhRRRRRRRR/# )	r   r1   r   r2   r3   versionszIterable[Version]r   r	   r   )r   s   "r   r   r      s,      !$0Ar   c                h    \         P                  ! 4       pV F  pV\        WV4      ,          pK  	  V# )zDReturn the widened union of one group's rejected candidate versions.)r	   r   rZ   )r1   r2   r\   r   r4   s   &&&  r   _candidate_unionr^      s3      E+HwGG Lr   c               $    V ^8  d   QhRRRRRR/# )r   accumulatedr   
rejectionsr   r   zVersionRange | Noner   )r   s   "r   r   r      s$     * **,/**r   c                \    V P                   V8w  d   R# V P                  P                  4       # )a\  Return the blocker range every rejection in the group rules out.

Each rejection recorded the candidate's dependency range on the blocker
and fired because the blocker sat outside it, so a blocker version
outside all of them reproduces the whole group and the complement of
the union is the largest sound term.  Returns ``None`` when a rejection
contributed no range, leaving the group on its narrower term.

Dependency ranges never admit arbitrary strings and
:meth:`VersionRange.complement` drops the pre-release opt-in region, so
the complement opens no admission the rejections did not already have.
N)r   r   
complement)r`   ra   s   &&r   _membership_widenedrd      s*     j(''))r   c                    V ^8  d   QhRRRR/# )r   r1   r   r   Noner   )r   s   "r   r   r      s     m9 m98 m9 m9r   c                d   V P                   P                  4        F  w  w  pppp\        WV4      p\        V P                  WV3,          \        V4      4      pVe.   \        P                  ! V4      P                  V4      '       d   TM\        WV4      pV P                  P                  \        \        WRR7      \        W'RR7      .\        P                  R7      4       K  	  \!        \"        4      V n         \!        \$        P&                  4      V n        V P(                  P                  4        F  w  w  pppp\        WV4      p\        V P*                  WV3,          \        V4      4      pVe   W,
          P,                  '       d   TMTpV P                  P                  \        \        WRR7      \        W'RR7      .\        P                  R7      4       K  	  \!        \"        4      V n        \!        \$        P&                  4      V n        \!        \        P.                  4      p	V P0                  P                  4        F%  w  vrpW;;,          \        WV4      ,          uu&   K'  	  V P2                  P                  4        F#  w  rW;;,          \        WV4      ,          uu&   K%  	  V	P                  4        FE  w  rV P                  P                  \        \        WRR7      .\        P4                  R7      4       KG  	  \!        \"        4      V n        \!        \6        4      V n        R# )a  Convert queued rejections into incompatibilities.

For each ``(candidate_pkg, blocker_pkg, blocker_key)`` group we add
``{candidate_pkg in {v1,v2,...}, blocker_pkg in R}``, with each candidate
version widened through ``widen_decision_gap``: a version's open neighbor
gap holds no other listed version, so adjacent gaps coalesce without
changing which versions the clause names.  ``R`` is the membership widening
when the group recorded a range for every rejection and that widening still
covers the blocker, otherwise the decided version's gap for decision-keyed
groups and the captured positive range for range-keyed ones.  Sound across
backjumps because the blocker term goes UNDETERMINED when the supporting
decision is reverted, so the candidate range can be reconsidered.

Root-requirement and metadata rejections have no such blocker: neither a
root requirement nor unreadable metadata changes over the resolve, so each
package's rejected versions go out as one single-term ``NO_VERSIONS``
clause naming just those versions.  The resolver's own fallback bans the
whole asked range, including the pre-releases the PEP 440 buffer kept out
of the scan.
NT)positive)cause)rD   r?   r^   rd   rE   lenr	   rX   	is_subsetrZ   pending_clausesrC   r   r   r   
DEPENDENCYr   listr   r   rG   rH   is_emptyr   rB   r;   NO_VERSIONSdict)r1   candidate_pkgblocker_pkgblocker_versionr\   range_union
membershipblocker_termblocker_rangeunusable_rejecteds   &           r   flush_pending_blocksr|      s   4 **002		 	&xI )00_= M	

 %&&7AA*MM  %XOL	 	 	  ''dCTB +55	
' 38 *$/H+6}7I7I+JH( 00668		 	&xI )--]; M	

 %=+E*O*O*O  	
 	  ''dCTB +55	
! 92 %0$5H!(3M4F4F(GH% 0;<;M;M/NH)1)E)E)K)K)M%X#3HX#VV *N $,#C#C#I#I#K#3HX#VV $L $,>>#3  ''m=>*66	
 $4 $/t#4H '24'8H$r   N)r+   
__future__r   collectionsr   typingr   r   nab_resolver.typesr   r   r   _vendor.packaging.rangesr	   _vendor.packaging.utilsr
   collections.abcr   _vendor.packaging.versionr   r1   r   r   rT   rZ   r^   rd   r|   r   r   r   <module>r      sc   $ # # , J J 3 7(3#GJ G,K
 !K\
K*(m9r   