ó
    °"³jv} ã            
      ó&  • S r SSKJr  SSKrSSKrSSKJrJr  SSK	J
r
JrJrJrJrJr  SSKJrJrJrJrJr  SSKJrJrJr  SSKJr  SS	KJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&  SS
K'J(r(J)r)J*r*J+r+J,r,  SSK-J.r.  SSK/J0r0J1r1  SSK2J3r3J4r4J5r5J6r6  SSK7J8r8J9r9  SSK:J;r;J<r<J=r=J>r>J?r?J@r@  SSKAJBrBJCrC  SSKDJErEJFrFJGrG  SSKHJIrIJJrJ  SSKKJLrLJMrMJNrNJOrOJPrPJQrQJRrRJSrSJTrT  SSKUJVrVJWrWJXrXJYrYJZrZ  SSK[J\r\J]r]J^r^  SSK_J`r`JaraJbrbJcrc  SSKdJereJfrf  SSKgJhrhJiriJjrjJkrkJlrlJmrmJnrnJoroJprp  SSKqJrrrJsrsJtrtJuruJvrvJwrw  SSKxJyryJzrzJ{r{  \Rø                  S:  a  SSK}J~r~  O\~r~\5" SSS9r \5" S SS9r€ \5" S!SS9r� \5" S"SS9r‚ \5" S#SS9rƒ\5" S$\B\\\4   SS%9r„\5" S&SS9r…\5" S'SS9r†\5" S(SS9r‡\5" S)SS9rˆ\" S*S+9 " S, S-\\‚   5      5       r‰\ " S. S/5      5       rŠ\ " S0 S15      5       r‹\" S*S29 " S3 S4\\\€\�\‚4   5      5       rŒ\ " S5 S65      5       r�\ " S7 S8\�5      5       rŽ " S9 S:\\\€\‚4   5      r�\ " S; S<5      5       r�\ " S= S>5      5       r‘\ " S? S@\\\€\‚4   5      5       r’SZSA jr“S[SB jr”\SC 5       r•\" S*S+9 " SD SE\\\€\†\‡4   5      5       r–      S\SF jr—      S]SG jr˜      S]SH jr™      S^SI jrš      S_SJ jr›S`SK jrœSaSL jr�SbSM jržScSN jrŸSOr  \ SP   r¡ \ SQ   r¢\ " SR SS5      5       r£\ " ST SU5      5       r¤      SdSW jr¥\ " SX SV5      5       r¦      SeSY jr§g)faÍ  Builder-based graph API: builder, graph runner, and mermaid rendering.

This module is the canonical home for the builder-based graph API:
[`GraphBuilder`][pydantic_graph.GraphBuilder] for declaratively constructing
executable graphs, [`Graph`][pydantic_graph.Graph] and
[`GraphRun`][pydantic_graph.GraphRun] for executing them, and the mermaid
rendering helpers used by `Graph.render()`. The same public symbols are
re-exported from `pydantic_graph` directly.
é    )ÚannotationsN)ÚCounterÚdefaultdict)ÚAsyncGeneratorÚAsyncIterableÚAsyncIteratorÚCallableÚIterableÚSequence)ÚAbstractContextManagerÚAsyncExitStackÚ	ExitStackÚasynccontextmanagerÚcontextmanager)Ú	dataclassÚfieldÚreplace)ÚNoneType)
ÚTYPE_CHECKINGÚAnyÚGenericÚLiteralÚ	TypeGuardÚcastÚget_argsÚ
get_originÚget_type_hintsÚoverload)ÚBrokenResourceErrorÚCancelScopeÚClosedResourceErrorÚcreate_memory_object_streamÚcreate_task_group)Ú	TaskGroup)ÚMemoryObjectReceiveStreamÚMemoryObjectSendStream)ÚNeverÚTypeAliasTypeÚTypeVarÚassert_never)Ú_utilsÚ
exceptions)ÚUNSETÚAbstractSpanÚUnsetÚget_traceparentÚinfer_obj_nameÚlogfire_span)ÚBaseNodeÚEnd)ÚDecisionÚDecisionBranchÚDecisionBranchBuilder)ÚGraphBuildingErrorÚGraphValidationError)	ÚForkIDÚ	ForkStackÚForkStackItemÚJoinIDÚNodeIDÚ	NodeRunIDÚTaskIDÚgenerate_placeholder_node_idÚreplace_placeholder_id)ÚJoinÚJoinNodeÚ	JoinStateÚReducerContextÚReducerFunction)ÚEndNodeÚForkÚ	StartNode)ÚAnyDestinationNodeÚAnyNodeÚDestinationNodeÚ
SourceNode)Ú
ParentForkÚParentForkFinder)	ÚBroadcastMarkerÚDestinationMarkerÚEdgePathÚEdgePathBuilderÚLabelMarkerÚ	MapMarkerÚPathÚPathBuilderÚTransformMarker)ÚNodeStepÚStepÚStepContextÚStepFunctionÚStepNodeÚStreamFunction)ÚTypeOrTypeExpressionÚget_callable_nameÚunpack_type_expression)é   é   )ÚBaseExceptionGroupÚStateTT)Úinfer_varianceÚDepsTÚInputTÚOutputTÚSourceTÚSourceNodeT)Úboundrg   ÚSourceOutputTÚGraphInputTÚGraphOutputTÚTF©Úinitc                  óD   • \ rS rSr% SrS\S'    S	S jr\S
S j5       rSr	g)Ú	EndMarkerég   zøA marker indicating the end of graph execution with a final value.

EndMarker is used internally to signal that the graph has completed
execution and carries the final output value.

Type Parameters:
    OutputT: The type of the final output value
rj   Ú_valuec                ó   • Xl         g ©N©rw   ©ÚselfÚvalues     ÚY/home/mande/repo/quber/.venv/lib/python3.13/site-packages/pydantic_graph/graph_builder.pyÚ__init__ÚEndMarker.__init__u   s   € à�ó    c                ó   • U R                   $ ry   rz   ©r|   s    r~   r}   ÚEndMarker.valuey   s   € à�{‰{Ðr�   rz   N)r}   rj   )Úreturnrj   )
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__r   Úpropertyr}   Ú__static_attributes__© r�   r~   ru   ru   g   s*   ‡ ñð ƒOØ:ôð óó ór�   ru   c                  ó$   • \ rS rSr% SrS\S'   Srg)ÚErrorMarkeré~   a2  A marker indicating that a graph node raised an exception.

Yielded by the graph iterator instead of raising immediately, allowing the caller
to recover by sending new tasks via `GraphRun.next()` or `GraphRun.override_next()`.
If the caller does not override, the error is re-raised on the next iteration.
ÚBaseExceptionÚerrorrŽ   N©r†   r‡   rˆ   r‰   rŠ   r‹   r�   rŽ   r�   r~   r�   r�   ~   s   ‡ ñð ÓÚ+r�   r�   c                  ó<   • \ rS rSr% SrS\S'    S\S'    S\S'   S	rg
)ÚJoinItemé‹   zÊAn item representing data flowing into a join operation.

JoinItem carries input data from a parallel execution path to a join
node, along with metadata about which execution 'fork' it originated from.
r=   Újoin_idr   Úinputsr;   Ú
fork_stackrŽ   Nr”   rŽ   r�   r~   r–   r–   ‹   s"   ‡ ñð ƒOØ9àƒKØ0àÓÚKr�   r–   ©Úreprc                  óv  ^ • \ rS rSr% SrS\S'    S\S'    S\S'    S	\S
'    S\S'    S\S'    S\S'    S\S'    S\S'    S\S'    S$S jrS%S jrSSSSSS.           S&S jjrSSSSSS.           S&S jjr	\
SSSSSS.           S'S jj5       rSSS.S(S  jjrS)U 4S! jjrS)S" jrS#rU =r$ )*ÚGraphé�   a�  A complete graph definition ready for execution.

The Graph class represents a complete workflow graph with typed inputs,
outputs, state, and dependencies. It contains all nodes, edges, and
metadata needed for execution.

Type Parameters:
    StateT: The type of the graph state
    DepsT: The type of the dependencies
    InputT: The type of the input data
    OutputT: The type of the output data
ú
str | NoneÚnameztype[StateT]Ú
state_typeztype[DepsT]Ú	deps_typeztype[InputT]Ú
input_typeztype[OutputT]Úoutput_typeÚboolÚauto_instrumentúdict[NodeID, AnyNode]Únodesúdict[NodeID, list[Path]]Úedges_by_sourceú dict[JoinID, ParentFork[NodeID]]Úparent_forksúdict[JoinID, set[JoinID]]Úintermediate_join_nodesc                ó`   • U R                   R                  U5      nUc  [        SU S35      eU$ )záGet the parent fork information for a join node.

Args:
    join_id: The ID of the join node

Returns:
    The parent fork information for the join

Raises:
    RuntimeError: If the join ID is not found or has no parent fork
úNode zE is not a join node or did not have a dominating fork (this is a bug))r­   ÚgetÚRuntimeError)r|   r˜   Úresults      r~   Úget_parent_forkÚGraph.get_parent_forkÍ   s9   € ð ×"Ñ"×&Ñ& wÓ/ˆØ‰>Ü  w iÐ/tÐuÓvÐvØˆr�   c                óT   • U R                   R                  5        H
  nX;   d  M
    g   g)a$  Check if a join is 'final' (has no downstream joins with the same parent fork).

A join is non-final if it appears as an intermediate node for another join
with the same parent fork.

Args:
    join_id: The ID of the join node

Returns:
    True if the join is final, False if it's non-final
FT)r¯   Úvalues)r|   r˜   Úintermediate_joinss      r~   Úis_final_joinÚGraph.is_final_joinÞ   s-   € ð #'×">Ñ">×"EÑ"EÖ"GÐØÕ,Ùñ #Hð r�   NT©ÚstateÚdepsr™   ÚspanÚ
infer_namec             ƒ  óÄ  #   • U(       a   U R                   c  [        U SS9nUb  X`l         U R                  XX4SS9 ISh  v•N nSn  UR                  U5      I Sh  v•N nM   N# N! [         aR    [        U[        5      (       d   S5       e[        [        [           U5      R                  s sSSS5      ISh  v•N    $ f = f! , ISh  v•N  (       d  f       g= f7f)aÒ  Execute the graph and return the final output.

This is the main entry point for graph execution. It runs the graph
to completion and returns the final output value.

Args:
    state: The graph state instance
    deps: The dependencies instance
    inputs: The input data for the graph
    span: Optional span for tracing/instrumentation
    infer_name: Whether to infer the graph name from the calling frame.

Returns:
    The final output from the graph execution
Né   ©ÚdepthFr¼   z'Graph run should end with an EndMarker.)
r¡   r1   ÚiterÚnextÚStopAsyncIterationÚ
isinstanceru   r   rj   r}   )	r|   r½   r¾   r™   r¿   rÀ   Úinferred_nameÚ	graph_runÚevents	            r~   ÚrunÚ	Graph.runð   sÎ   é € ö0 ˜$Ÿ)™)Ñ+Ü*¨4°qÑ9ˆMØÑ(Ø)”	à—9‘9 5¸FÐZ_�9×`Ñ`Ðdmð ˆEØðAØ"+§.¡.°Ó"7×7�Eñ ñ añ 8øÜ)ó AÜ% e¬Y×7Ñ7ÐbÐ9bÓbÐ7Ü¤	¬'Ñ 2°EÓ:×@Ñ@Ñ@÷ a×`Ò`ðAú÷ a×`Ö`üs}   ‚=C ¿A#Á C ÁCÁA'ÁA%ÁA'Á!CÁ#C Á%A'Á'ACÂ.CÂ/C Â;B>Â<C ÃCÃCÃCÃCÃCÃC c          
     óš   • U(       a   U R                   c  [        U SS9nUb  X`l         [        R                  " U R	                  XX4SS95      $ )as  Synchronously execute the graph and return the final output.

This is a convenience wrapper around [`run`][pydantic_graph.graph_builder.Graph.run] that runs the coroutine on the
current event loop via `loop.run_until_complete(...)`. As such, it cannot be called from inside async
code or when an event loop is already running.

Args:
    state: The graph state instance
    deps: The dependencies instance
    inputs: The input data for the graph
    span: Optional span for tracing/instrumentation
    infer_name: Whether to infer the graph name from the calling frame.

Returns:
    The final output from the graph execution
rÂ   rÃ   Fr¼   )r¡   r1   r+   Úrun_until_completerÌ   )r|   r½   r¾   r™   r¿   rÀ   rÉ   s          r~   Úrun_syncÚGraph.run_sync  sI   € ö2 ˜$Ÿ)™)Ñ+Ü*¨4°qÑ9ˆMØÑ(Ø)”	Ü×(Ò(¨¯©¸ÐQWÐot¨Ð)uÓvÐvr�   c          	    ó  #   • U(       a   U R                   c  [        U SS9nUb  X`l         [        5        nSnUc9  U R                  (       a'  SU R                    3n	UR	                  [        X�S95      nOUR	                  U5      nUc  SO
[        U5      n
[        [        [        [        4   " U UUUU
S9 ISh  v•N nU7v •  SSS5      ISh  v•N   SSS5        g N" N! , ISh  v•N  (       d  f       N$= f! , (       d  f       g= f7f)aú  Create an iterator for step-by-step graph execution.

This method allows for more fine-grained control over graph execution,
enabling inspection of intermediate states and results.

Args:
    state: The graph state instance
    deps: The dependencies instance
    inputs: The input data for the graph
    span: Optional span for tracing/instrumentation
    infer_name: Whether to infer the graph name from the calling frame.

Yields:
    A GraphRun instance that can be iterated for step-by-step execution
Nrc   rÃ   z
run graph )Úgraph)rÓ   r½   r¾   r™   Útraceparent)r¡   r1   r   r§   Úenter_contextr2   r0   ÚGraphRunrf   rh   rj   )r|   r½   r¾   r™   r¿   rÀ   rÉ   ÚstackÚentered_spanÚ	span_namerÔ   rÊ   s               r~   rÅ   Ú
Graph.iter8  sì   é € ö2 ˜$Ÿ)™)Ñ+Ü*¨4°qÑ9ˆMØÑ(Ø)”	äŒ[˜EØ04ˆLØ‰|Ø×'×'ð #-¨T¯Y©Y¨KÐ 8�IØ#(×#6Ñ#6´|ÀIÑ7ZÓ#[�Løà$×2Ñ2°4Ó8�Ø".Ñ"6™$¼OÈLÓ<YˆKÜ¤¬¬wÐ 6Ò7ØØØØØ'÷ò ð Ø“÷÷ ÷ ˆ[÷÷ ÷ ò ú÷ �[üse   ‚2D
´BC9Â8CÂ9C9Â<CÃC9ÃCÃC9Ã	D
ÃC9ÃC9ÃC6	Ã%C(Ã&C6	Ã2C9Ã9
DÄD
©ÚtitleÚ	directionc               ó\   • [        U R                  U R                  5      R                  XS9$ )zÝRender the graph as a Mermaid diagram string.

Args:
    title: Optional title for the diagram
    direction: Optional direction for the diagram layout

Returns:
    A string containing the Mermaid diagram representation
rÛ   )Úbuild_mermaid_graphr©   r«   Úrender)r|   rÜ   rÝ   s      r~   rà   ÚGraph.renderk  s*   € ô # 4§:¡:¨t×/CÑ/CÓD×KÑKÐRWÐKÐmÐmr�   c                ó@   >• [         TU ]  5       nUS S  SU  SUS    3$ )NéÿÿÿÿÚ
)ÚsuperÚ__repr__)r|   Ú
super_reprÚ	__class__s     €r~   ræ   ÚGraph.__repr__w  s3   ø€ Ü‘WÑ%Ó'ˆ
à˜S˜b�/Ð" " T F¨"¨Z¸©^Ð,<Ð=Ð=r�   c                ó"   • U R                  5       $ )zyReturn a Mermaid diagram representation of the graph.

Returns:
    A string containing the Mermaid diagram of the graph
)rà   rƒ   s    r~   Ú__str__ÚGraph.__str__|  s   € ð �{‰{‹}Ðr�   )r¡   )r˜   r=   r…   zParentFork[NodeID])r˜   r=   r…   r¦   )r½   rf   r¾   rh   r™   ri   r¿   ú+AbstractContextManager[AbstractSpan] | NonerÀ   r¦   r…   rj   )r½   rf   r¾   rh   r™   ri   r¿   rí   rÀ   r¦   r…   z0AsyncGenerator[GraphRun[StateT, DepsT, OutputT]])rÜ   r    rÝ   úStateDiagramDirection | Noner…   Ústr©r…   rï   )r†   r‡   rˆ   r‰   rŠ   r‹   rµ   rº   rÌ   rÐ   r   rÅ   rà   ræ   rë   r�   Ú__classcell__)rè   s   @r~   rž   rž   �   s¦  ø‡ ñð Óð MàÓØ&àÓØ'àÓØ%àÓØ&àÓØ@à Ó Ø5à-Ó-Ø/à2Ó2Ø5à6Ó6ðKô
ô"ð* ØØØ<@Øñ'Að ð'Að ð	'Að
 ð'Að :ð'Að ð'Að 
õ'AðX ØØØ<@Øñwð ðwð ð	wð
 ðwð :ðwð ðwð 
õwð> ð ØØØ<@Øñ0 ð ð0 ð ð	0 ð
 ð0 ð :ð0 ð ð0 ð 
:ô0 ó ð0 ðd -1Ð\`÷ 
n÷>÷
ò r�   rž   c                  óH   • \ rS rSr% SrS\S'    S\S'    \" SS9rS	\S
'   Srg)ÚGraphTaskRequesti…  zâA request to run a task representing the execution of a node in the graph.

GraphTaskRequest encapsulates all the information needed to execute a specific
node, including its inputs and the fork context it's executing within.
r>   Únode_idr   r™   Fr›   r;   rš   rŽ   N)	r†   r‡   rˆ   r‰   rŠ   r‹   r   rš   r�   rŽ   r�   r~   ró   ró   …  s-   ‡ ñð ƒOØ(àƒKØ&á! uÑ-€J�	Ó-òr�   ró   c                  óF   • \ rS rSr% Sr\" SS9rS\S'    \S
S j5       r	Sr
g	)Ú	GraphTaskiš  a	  A task representing the execution of a node in the graph.

GraphTask encapsulates all the information needed to execute a specific
node, including its inputs and the fork context it's executing within,
and has a unique ID to identify the task within the graph run.
Fr›   r@   Útask_idc                ó’   • [        U [        5      (       a  U $ [        U R                  U R                  U R                  U" 5       5      $ ry   )rÈ   rö   rô   r™   rš   )ÚrequestÚget_task_ids     r~   Úfrom_requestÚGraphTask.from_request¦  s7   € ô �gœy×)Ñ)ØˆNÜ˜Ÿ™¨'¯.©.¸'×:LÑ:LÉkËmÓ\Ð\r�   rŽ   N)rù   ró   rú   úCallable[[], TaskID]r…   rö   )r†   r‡   rˆ   r‰   rŠ   r   r÷   r‹   Ústaticmethodrû   r�   rŽ   r�   r~   rö   rö   š  s/   ‡ ññ  Ñ'€GˆVÓ'Ø*àó]ó ó]r�   rö   c                  ó
  • \ rS rSrSr          SS jrS rSS jr\S 5       r	\
SS j5       r\
SS j5       rS	S
.SS jjrSS jrSS jr S   SS jjrS S jrS S jr\S!S j5       r\S"S j5       rS#S jrS$S jrSrg)%rÖ   i®  a>  A single execution instance of a graph.

GraphRun manages the execution state for a single run of a graph,
including task scheduling, fork/join coordination, and result tracking.

Type Parameters:
    StateT: The type of the graph state
    DepsT: The type of the dependencies
    OutputT: The type of the output data
c               óˆ  • Xl          X l         X0l         X@l         0 U l         SU l         SU l        SU l        [        [        R                  U R                  5       S5      4n[        [        R                  XFU R                  5       S9U l        [        5       U l        ["        [$        [&        [(        4   " U R                   U R                  U R                  U R                   U R                  U R                  5      U l        U R*                  R-                  U R                  5      U l        XPl        [3        5       U l        g)zëInitialize a graph run.

Args:
    graph: The graph to execute
    state: The graph state instance
    deps: The dependencies instance
    inputs: The input data for the graph
    traceparent: Optional trace parent for instrumentation
Nr   )rô   r™   rš   r÷   )rÓ   r½   r¾   r™   Ú_active_reducersÚ_nextÚ_next_task_idÚ_next_node_run_idr<   rJ   ÚidÚ_get_next_node_run_idrö   Ú_get_next_task_idÚ_first_taskr#   Ú_iterator_task_groupÚ_GraphIteratorrf   rh   rj   Ú_iterator_instanceÚ
iter_graphÚ	_iteratorÚ_GraphRun__traceparentr   Ú_async_exit_stack)r|   rÓ   r½   r¾   r™   rÔ   Úinitial_fork_stacks          r~   r   ÚGraphRun.__init__º  s  € ð$ Œ
Ø'àŒ
Ø'àŒ	Ø(àŒØ%àKMˆÔØ2àTXˆŒ
Ø,àˆÔØ!"ˆÔÜ)6´y·|±|ÀT×E_ÑE_ÓEaÐcdÓ)eÐ(gÐÜ$Ü—L‘L¨ÐX\×XnÑXnÓXpñ
ˆÔô %6Ó$7ˆÔ!Ü"0´¼ÄÐ1GÒ"HØ�J‰JØ�J‰JØ�I‰IØ×%Ñ%Ø×&Ñ&Ø×"Ñ"ó#
ˆÔð ×0Ñ0×;Ñ;¸D×<LÑ<LÓMˆŒà(ÔÜ!/Ó!1ˆÕr�   c              ƒ  ó  #   • U R                   R                  [        5       5        U R                   R                  U R                  5      I S h  v•N   U R                   R                  U R                  5       5      I S h  v•N   U $  N7 N7fry   )r  rÕ   Ú_unwrap_exception_groupsÚenter_async_contextr	  Ú_iterator_contextrƒ   s    r~   Ú
__aenter__ÚGraphRun.__aenter__ò  sn   é € Ø×Ñ×,Ñ,Ô-EÓ-GÔHØ×$Ñ$×8Ñ8¸×9RÑ9RÓS×SÐSØ×$Ñ$×8Ñ8¸×9OÑ9OÓ9QÓR×RÐRØˆñ 	TÙRùs$   ‚AB
ÁBÁ0B
Á?BÂ B
ÂB
c              ƒ  óX   #   • U R                   R                  XU5      I S h  v•N   g  N7fry   )r  Ú	__aexit__)r|   Úexc_typeÚexc_valÚexc_tbs       r~   r  ÚGraphRun.__aexit__ø  s!   é € Ø×$Ñ$×.Ñ.¨xÀ&ÓI×IÓIùs   ‚ *¢(£*c               óÐ  #   •  S 7v •  U R                   R                  R                  5         U R                   R                  R                  5         U R                  R                  5       I S h  v•N   g  N! U R                   R                  R                  5         U R                   R                  R                  5         U R                  R                  5       I S h  v•N    f = f7fry   )r  Úiter_stream_senderÚcloseÚiter_stream_receiverr  Úacloserƒ   s    r~   r  ÚGraphRun._iterator_contextû  sœ   é € ð	*Üà×#Ñ#×6Ñ6×<Ñ<Ô>Ø×#Ñ#×8Ñ8×>Ñ>Ô@Ø—.‘.×'Ñ'Ó)×)Ó)øð ×#Ñ#×6Ñ6×<Ñ<Ô>Ø×#Ñ#×8Ñ8×>Ñ>Ô@Ø—.‘.×'Ñ'Ó)×)Ò)üs5   ‚C&„A6 ‰A%C&Á.A4Á/C&Á6A&C#ÃCÃC#Ã#C&c               ó   • g ry   rŽ   ©r|   Úrequireds     r~   Ú_traceparentÚGraphRun._traceparent  s   € ØGJr�   c                ó   • g ry   rŽ   rƒ   s    r~   r'  r(    s   € Ø#&r�   T)r&  c               ón   • U R                   c  U(       a  [        R                  " S5      eU R                   $ )a
  Get the trace parent for instrumentation.

Args:
    required: Whether to raise an error if no traceparent exists

Returns:
    The traceparent string, or None if not required and not set

Raises:
    GraphRuntimeError: If required is True and no traceparent exists
z&No span was created for this graph run)r  r,   ÚGraphRuntimeErrorr%  s     r~   r'  r(    s0   € ð ×ÑÑ%®(Ü×.Ò.Ð/WÓXÐXØ×!Ñ!Ð!r�   c                ó   • U $ )zIReturn self as an async iterator.

Returns:
    Self for async iteration
rŽ   rƒ   s    r~   Ú	__aiter__ÚGraphRun.__aiter__  s	   € ð ˆr�   c              ƒ  óX  #   • U R                   c#  [        U R                  5      I Sh  v•N U l         O2U R                  R                  U R                   5      I Sh  v•N U l         [	        U R                   [
        5      (       a  U R                   R                  eU R                   $  N} NL7f)zÓGet the next item in the async iteration.

Returns:
    The next execution result from the graph

Raises:
    Exception: If a node raised an error and the caller has not recovered via
        `override_next()`.
N)r  Úanextr  ÚasendrÈ   r�   r“   rƒ   s    r~   Ú	__anext__ÚGraphRun.__anext__   sv   é € ð �:‰:ÑÜ$ T§^¡^Ó4×4ˆD�Jà#Ÿ~™~×3Ñ3°D·J±JÓ?×?ˆDŒJÜ�d—j‘j¤+×.Ñ.ð —*‘*×"Ñ"Ð"Ø�z‰zÐñ 5á?ùs"   ‚&B*¨B&©2B*ÁB(ÁAB*Â(B*Nc              ƒ  ó    #   • U R                   c  [        U 5      I Sh  v•N   Ub  U R                  U5        [        U 5      I Sh  v•N $  N+ N7f)a>  Advance the graph execution by one step.

This method allows for sending a value to the iterator, which is useful
for resuming iteration or overriding intermediate results.

Args:
    value: Optional value to send to the iterator

Returns:
    The next execution result: either an EndMarker, or sequence of GraphTasks
N)r  r0  Ú	_set_nextr{   s     r~   rÆ   ÚGraphRun.next4  sI   é € ð �:‰:Ñô ˜“+×ÐØÑØ�N‰N˜5Ô!Ü˜4“[× Ð ñ ñ !ùs!   ‚AžA
Ÿ&AÁAÁAÁAc                ó&   • U R                  U5        g)añ  Override the next pending step, allowing the graph to continue after an `End` or error.

This is used by hook systems (like `after_node_run` or `on_node_run_error`) to redirect
the graph to a new node when the current step produced an `End` result or raised an error,
or to signal early completion by passing an `EndMarker`.

Must only be called between iterations (not while an iteration is in flight).

Args:
    value: New task requests to execute next, or an `EndMarker` to signal completion.
N)r5  r{   s     r~   Úoverride_nextÚGraphRun.override_nextJ  s   € ð 	�‰�uÕr�   c                ó°   • [        U[        5      (       a  Xl        g U Vs/ s H"  n[        R	                  X R
                  5      PM$     snU l        g s  snf ry   )rÈ   ru   r  rö   rû   r  )r|   r}   Úgtrs      r~   r5  ÚGraphRun._set_nextX  sA   € Ü�eœY×'Ñ'Ø�JáY^Ó_ÒY^ÐRUœ)×0Ñ0°×6LÑ6LÖMÑY^Ñ_ˆD�JùÒ_s   ¡)Ac                óB   • U R                   =(       d    U R                  /$ )zoGet the next task(s) to be executed.

Returns:
    The next execution item, or the initial task if none is set
)r  r  rƒ   s    r~   Ú	next_taskÚGraphRun.next_task^  s   € ð �z‰z×/˜d×.Ñ.Ð/Ð/r�   c                ón   • [        U R                  [        5      (       a  U R                  R                  $ g)zyGet the final output if the graph has completed.

Returns:
    The output value if execution is complete, None otherwise
N)rÈ   r  ru   r}   rƒ   s    r~   ÚoutputÚGraphRun.outputg  s(   € ô �d—j‘j¤)×,Ñ,Ø—:‘:×#Ñ#Ð#Ør�   c                ó`   • [        SU R                   35      nU =R                  S-  sl        U$ ©Nztask:é   )r@   r  ©r|   Únext_ids     r~   r  ÚGraphRun._get_next_task_idr  s0   € Ü˜5 ×!3Ñ!3Ð 4Ð5Ó6ˆØ×Ò˜aÑÕØˆr�   c                ó`   • [        SU R                   35      nU =R                  S-  sl        U$ rD  )r?   r  rF  s     r~   r  ÚGraphRun._get_next_node_run_idw  s0   € Ü˜e D×$:Ñ$:Ð#;Ð<Ó=ˆØ×Ò !Ñ#ÕØˆr�   )Ú__traceparentr  r  r  r  r  r	  r  r  r  r¾   rÓ   r™   r½   )
rÓ   z%Graph[StateT, DepsT, InputT, OutputT]r½   rf   r¾   rh   r™   ri   rÔ   r    )r  r   r  r   r  r   )r&  zLiteral[False]r…   r    rð   )r&  r¦   r…   r    )r…   z7AsyncIterator[EndMarker[OutputT] | Sequence[GraphTask]])r…   ú(EndMarker[OutputT] | Sequence[GraphTask]ry   )r}   z6EndMarker[OutputT] | Sequence[GraphTaskRequest] | Noner…   rL  )r}   z/Sequence[GraphTaskRequest] | EndMarker[OutputT]r…   ÚNone)r…   z6EndMarker[OutputT] | ErrorMarker | Sequence[GraphTask])r…   zOutputT | None)r…   r@   )r…   r?   )r†   r‡   rˆ   r‰   rŠ   r   r  r  r   r  r   r'  r-  r2  rÆ   r8  r5  rŒ   r>  rA  r  r  r�   rŽ   r�   r~   rÖ   rÖ   ®  så   † ñ	ð62à4ð62ð ð	62ð
 ð62ð ð62ð  ô62òpôJð ñ*ó ð*ð ÛJó ØJØÛ&ó Ø&Ø/3÷ "ô ôð* OSð!ØKð!à	1õ!ô,ô`ð ó0ó ð0ð óó ðô÷
r�   rÖ   c                  ó*   • \ rS rSr% S\S'   S\S'   Srg)Ú_GraphTaskAsyncIterablei}  z"AsyncIterable[Sequence[GraphTask]]Úiterabler;   rš   rŽ   N)r†   r‡   rˆ   r‰   r‹   r�   rŽ   r�   r~   rO  rO  }  s   ‡ à0Ó0ØÖr�   rO  c                  óF   • \ rS rSr% S\S'   S\S'   SrS\S'   S	rS
\S'   Srg	)Ú_GraphTaskResultiƒ  rö   Úsourcez/EndMarker[Any] | Sequence[GraphTask] | JoinItemr´   Tr¦   Úsource_is_finishedNzBaseException | Noner“   rŽ   )r†   r‡   rˆ   r‰   r‹   rT  r“   r�   rŽ   r�   r~   rR  rR  ƒ  s$   ‡ àÓØ;Ó;Ø#Ð˜Ó#Ø"&€EÐÖ&r�   rR  c                  ó´  • \ rS rSr% S\S'   S\S'   S\S'   S\S	'   S
\S'   S\S'   \" SS9rS\S'   \" SS9rS\S'   \" SS9rS\S'   \" SS9r	S\S'   \" SS9r
S\S'   S r    S,S jrS-S jrS.S jrS/S jr    S0S jr        S1S  jr      S2S! jrS3S" jr      S4S# jrS5S$ jr        S6S% jrS7S& jr        S8S' jrS9S( jrS:S) jrS*rg+);r
  i‹  z"Graph[StateT, DepsT, Any, OutputT]rÓ   rf   r½   rh   r¾   r$   Ú
task_groupzCallable[[], NodeRunID]Úget_next_node_run_idrý   Úget_next_task_idFrr   zdict[TaskID, CancelScope]Úcancel_scopeszdict[TaskID, GraphTask]Úactive_tasksz)dict[tuple[JoinID, NodeRunID], JoinState]Úactive_reducersz(MemoryObjectSendStream[_GraphTaskResult]r  z+MemoryObjectReceiveStream[_GraphTaskResult]r!  c                óz   • 0 U l         0 U l        0 U l        [        [           " 5       u  U l        U l        SU l        g )NrE  )rY  rZ  r[  r"   rR  r  r!  r  rƒ   s    r~   Ú__post_init__Ú_GraphIterator.__post_init__š  s;   € ØˆÔØˆÔØ!ˆÔÜ=XÔYiÒ=jÓ=lÑ:ˆÔ Ô!:Ø!"ˆÕr�   c           	    óÀ  #   • U R                    IS h  v•N    XR                  UR                  '   U R                  U/5        U R                   IS h  v•N   U R                  (       d  U R
                  (       Ga  U R                    S h  v•N nUR                  b:  [        UR                  5      7v •n[        U[        5      (       a  UR                  eO;[        UR                  [        5      (       a  UR                  nOUR                  7v •n[        U[        5      (       a„  U R                  UR                  R                  5      I S h  v•N   U R                  (       a$  U R                  R                  R!                  5           S S S 5      IS h  v•N   S S S 5      IS h  v•N   g [        U[        5      (       Gao  UnU R"                  R%                  UR&                  5      R(                  nU R+                  UR&                  UR,                  5      u  pgU R"                  R.                  UR&                     n[        U[0        5      (       d
   SU 35       eU R
                  R3                  UR&                  U45      n	U	c5  UR5                  5       n
[7        X§5      =o�R
                  UR&                  U4'   [9        U R:                  U R<                  U	S9nUR?                  X¹R@                  URB                  5      U	l         U	RD                  (       a  U RG                  XV5      I S h  v•N   O8[        U[        5      (       a   eU H  nXÀR                  UR                  '   M     [I        U R                  RK                  5       5      n/ nU RM                  UR                  U5       H�  u  pöU R
                  RO                  Xö45      n	U R"                  R.                  U   n[        U[0        5      (       d
   SU 35       eU RQ                  X‰R@                  U	RR                  5      nURU                  U5        M’     U(       a2  U H  nXÀR                  UR                  '   M     U R                  U5        [        U[V        5      (       a”  [        UR                  [V        5      (       ad  U Vs1 s H  nUR                  iM     nnUR                   H8  nUR                  U;  d  M  U R                  UR                  5      I S h  v•N   M:     U R                  U5        URX                  (       a-  U R                  UR                  R                  5      I S h  v•N   U R                  (       a  GMê    U R
                  (       GaÚ  [I        U R
                  R[                  5       5       GH²  u  u  pön	SnU R"                  R\                  R3                  U[_        5       5      nU R"                  R%                  U5      nU HÑ  nU R
                  R[                  5        H§  u  u  nnnUU:X  d  M  S nS nU	RR                   H+  nUR(                  UR(                  :X  d  M  UR`                  n  O   URR                   H+  nUR(                  UR(                  :X  d  M  UR`                  n  O   U(       d  M”  U(       d  M�  UU:X  d  M¥  Sn  O   U(       d  MÑ    O   U(       a  GM5  U R
                  RO                  Xö45        U R"                  R.                  U   n[        U[0        5      (       d
   SU 35       eU RQ                  X‰R@                  U	RR                  5      nU7v •n[        U[        5      (       aF  U R                  R                  R!                  5           S S S 5      IS h  v•N   S S S 5      IS h  v•N   g [        U[        5      (       a   eU H  nXÀR                  UR                  '   M     U Vs1 s H  nUR                  iM     nnU H8  nUR                  U;  d  M  U R                  UR                  5      I S h  v•N   M:     U R                  U5        GMµ     U R                  (       a  GM÷  U R
                  (       a  GM  S S S 5      IS h  v•N   S S S 5      IS h  v•N   [e        S5      e GNž GNa GN, GNk GN( GN GN™s  snf  GNÆ GNv
 GNb GN4 GN's  snf  NŸ NO! , IS h  v•N  (       d  f       Nd= f! [b         a8    U R                  R                  R!                  5          S S S 5      IS h  v•N    g f = f N ! , IS h  v•N  (       d  f       Nµ= f7f)NzExpected a `Join` but got )r½   r¾   Ú
join_stateFTzpGraph run completed, but no result was produced. This is either a bug in the graph or a bug in the graph runner.)3r  rZ  r÷   Ú_handle_execution_requestr!  r[  r“   r�   rÈ   r´   r–   ru   Ú_finish_taskrS  rV  Úcancel_scopeÚcancelrÓ   rµ   r˜   Úfork_idÚ_resolve_join_fork_runrš   r©   rC   r²   Úinitial_factoryrE   rF   r½   r¾   ÚreduceÚcurrentr™   Úcancelled_sibling_tasksÚ_cancel_sibling_tasksÚlistr¸   Ú_get_completed_fork_runsÚpopÚ_handle_non_fork_edgesÚdownstream_fork_stackÚextendr   rT  Úitemsr¯   ÚsetÚnode_run_idÚGeneratorExitr³   )r|   Ú
first_taskÚtask_resultÚmaybe_overridden_resultr´   Úparent_fork_idÚfork_run_idrp  Ú	join_noder`  ri  ÚcontextÚnew_taskÚtasks_by_id_valuesÚ
join_tasksr˜   Ú	new_tasksÚtÚnew_task_idsÚshould_skipr¹   Újoin_parent_forkÚintermediate_join_idÚother_join_idÚ_Úother_join_stateÚjoin_parent_fork_run_idÚother_parent_fork_run_idÚfsis                                r~   r  Ú_GraphIterator.iter_graph¡  s  é € ð
 ×*×*Ó*ð^à8B×!Ñ! *×"4Ñ"4Ñ5Ø×.Ñ.°
¨|Ô<ð  ×4×4Ó4Ø×+×+¨t×/C×/CÐ/CØ15×1JÒ1J÷ L& +Ø*×0Ñ0Ñ<ô ALÈK×L]ÑL]Ó@^Ò:^Ð 7Ü#-Ð.EÄ{×#SÑ#Sà*5×*;Ñ*;Ð$;ð $Tô ",¨K×,>Ñ,>Ä×!IÑ!IØ:E×:LÑ:LÑ 7à@K×@RÑ@RÒ:RÐ 7Ü)Ð*AÄ9×MÑMð '+×&7Ñ&7¸×8JÑ8J×8RÑ8RÓ&S× SÐ SØ#'×#4×#4à$(§O¡O×$@Ñ$@×$GÑ$GÔ$IØ &÷- 5×4÷ +×*Ð*ô< ",Ð,CÄX×!NÒ!NØ)@ Ø15·±×1KÑ1KÈFÏNÉNÓ1[×1cÑ1c ØEI×E`ÑE`Ø$*§N¡N°F×4EÑ4EóF"Ñ B ð -1¯J©J×,<Ñ,<¸V¿^¹^Ñ,L 	Ü'1°)¼T×'BÑ'BÐ lÐF`ÐajÐ`kÐDlÓ lÐ'BØ-1×-AÑ-A×-EÑ-EÀvÇ~Á~ÐWbÐFcÓ-d 
Ø#-Ñ#5Ø.7×.GÑ.GÓ.I GÜgpØ(/óh&ð %& J×1EÑ1EÀvÇ~Á~ÐWbÐFcÑ1dô +9¸t¿z¹zÐPT×PYÑPYÐfpÑ*q Ø5>×5EÑ5EÀg×OaÑOaÐci×cpÑcpÓ5q 
Ô 2Ø#-×#E×#EØ*.×*DÑ*DÀ^Ó*a×$aÐ$aøä+5Ð6MÌ{×+[Ñ+[Ð [Ð'[Û0G HØJR×$5Ñ$5°h×6FÑ6FÓ$Gñ 1Hô 26°d×6GÑ6G×6NÑ6NÓ6PÓ1QÐ.Ø:<˜Jà8<×8UÑ8UØ +× 2Ñ 2Ð4Fö9Ñ 4 ð .2×-AÑ-A×-EÑ-EÀwÐF\Ó-] 
Ø,0¯J©J×,<Ñ,<¸WÑ,E 	Ü'1°)¼T×'BÑ'BÐ lÐF`ÐajÐ`kÐDlÓ lÐ'BØ,0×,GÑ,GØ$-×/AÑ/AÀ:×CcÑCcó-" 	ð !+× 1Ñ 1°)Ö <ñ9ö  *Û0: HØJR×$5Ñ$5°h×6FÑ6FÓ$Gñ 1;à $× >Ñ >¸zÔ Jä)Ð*AÄ8×LÑLÜ#-¨k×.@Ñ.@Ä(×#KÑ#KÙG^Ó3_ÒG^À!°A·I´IÑG^ LÐ3_Ø-8×-?Ô-?¨Ø+,¯9©9¸LÕ+HØ26×2CÑ2CÀAÇIÁIÓ2N×,NÒ,Nñ .@ð !%× >Ñ >Ð?VÔ Wà*×=×=Ø&*×&7Ñ&7¸×8JÑ8J×8RÑ8RÓ&S× SÐ Sà#'×#4×#4Ò#4à %à×/×/Ð/ô
 GKÈ4×K_ÑK_×KeÑKeÓKg×FhÑ BÑ 6 ¸
à.3 Ø59·Z±Z×5WÑ5W×5[Ñ5[Ð\cÔehÓejÓ5kÐ 2ð 48·:±:×3MÑ3MÈgÓ3VÐ 0ã<NÐ$8àPT×PdÑPd×PjÑPjÖPlÑ(LÑ(:¨¸Ð<LØ+8Ð<PÕ+Pð GKÐ,CØGKÐ,Dà7A×7WÔ7W°Ø36·;±;ÐBR×BZÑBZÕ3ZØNQÏoÉoÐ4KÙ49ñ 8Xð
 8H×7]Ô7]°Ø36·;±;ÐBR×BZÑBZÕ3ZØORÏÉÐ4LÙ49ñ 8^÷ 1HÐ0Gß4LÐ4LØ4KÐOgÕ4gà>B°Ù05ñ/ Qm÷0 (3 {Ù(-ñ7 =Oö: $/Ú$,à $× 4Ñ 4× 8Ñ 8Ø%,Ð$:ô!"ð -1¯J©J×,<Ñ,<¸WÑ,E 	Ü'1°)¼T×'BÑ'BÐ lÐF`ÐajÐ`kÐDlÓ lÐ'BØ,0×,GÑ,GØ$-×/AÑ/AÀ:×CcÑCcó-" 	ð AJº/Ð 7Ü#-Ð.EÄy×#QÑ#Qð %)§O¡O×$@Ñ$@×$GÑ$GÔ$IØ$*÷W 5×4÷ +×*Ð*ôf ,6Ð6MÌ{×+[Ñ+[Ð [Ð'[Û0G HØJR×$5Ñ$5°h×6FÑ6FÓ$Gñ 1HáCZÓ/[ÒCZ¸a°·	´	ÑCZ Ð/[Û)2 Að ()§y¡y¸Õ'DØ.2×.?Ñ.?ÀÇ	Á	Ó.J×(JÒ(Jñ	 *3ð
 !%× >Ñ >Ð?V× WñA Giði ×+×+Ò+¨t×/C×/CÒ/C÷ 5×4÷ +×*ôB Ø~ó
ð 	
òC +ò 5òL&ò  !Tò% 5ò +ò` %bùò4 4`ò -Oò !TòQ 2Kò 5ò +ùòl 0\ñ
 )K÷i 5×4×4Ð4ûôl !ó Ø—‘×,Ñ,×3Ñ3Ô5Ø÷ +×*Ñ*ðzú÷{ +×*×*Ð*üs  ‚e“b1”e—e™:c=Áb4Ác=Á0c#ÂcÂb7
ÂcÂC c#Åb:
Å:c#Æ
c=Æb=Æc=ÆeÆ%c Æ&eÆ+E?c#Ì*c
Ì+Fc#Ò.c
Óc#Ó'c#ÔcÔAc#Õc
Õc#Õ1B6c#Ø++c#Ù7c#Úc#Ú.c#Ú7c#Ú?c#ÛCc#Þc=Þ cÞ!c=Þ%eÞ0cÞ1eÞ6<c#ß2c
àc#à!c#à?cá /c#á2c#âc=âc!âc=âeâ!eâ"eâ4c=â7câ:c#â=c=ã eãc#ãc#ãc#ãc#ãc=ãeãc#ã!c=ã#c:	ã)c,ã*c:	ã6c=ã9eã:c=ã=.d?ä+eä,eä7d:ä8eä>d?ä?eåeåeå
eåeåec              ƒ  ó¢   #   • U R                   R                  US 5      nUb  UR                  5         U R                  R                  US 5        g 7fry   )rY  rn  rd  rZ  )r|   r÷   Úscopes      r~   rb  Ú_GraphIterator._finish_taskK  sB   é € à×"Ñ"×&Ñ& w°Ó5ˆØÑØ�L‰LŒNØ×Ñ×Ñ˜g tÕ,ùs   ‚AAc                ó¤   • U H  nX R                   UR                  '   M     U H)  nU R                  R                  U R                  U5        M+     g ry   )rZ  r÷   rV  Ú
start_soonÚ_run_tracked_task)r|   rù   r}  s      r~   ra  Ú(_GraphIterator._handle_execution_requestR  sD   € ÛˆHØ2:×Ñ˜h×.Ñ.Ó/ñ  ãˆHØ�O‰O×&Ñ& t×'=Ñ'=¸xÖHò  r�   c           
   ƒ  ó*  #   • [        5        nX R                  UR                  '    U R                  U5      I S h  v•N n [        U[        5      (       aD  UR                    S h  v•N nU R
                  R                  [        XS5      5      I S h  v•N   M8  U R
                  R                  [        X5      5      I S h  v•N    S S S 5        g  N”! [         aW  n U R
                  R                  [        U/ US95      I S h  v•N    O! [        [        4 a     Of = f S nAS S S 5        g S nAff = f NÏ N¤
 U R
                  R                  [        U/ 5      5      I S h  v•N    N£ N¨! [        [        4 a     N·f = f! , (       d  f       g = f7f)N)r“   F)r    rY  r÷   Ú	_run_taskr’   r  ÚsendrR  r   r!   rÈ   rO  rP  )r|   Út_rŽ  r´   Úexcr€  s         r~   r’  Ú _GraphIterator._run_tracked_taskX  sW  é € ÜŒ]˜eØ-2×Ñ˜rŸz™zÑ*ð
Ø#Ÿ~™~¨bÓ1×1�ðÜ˜fÔ&=×>Ñ>Ø+1¯?ª?÷ c˜iØ"×5Ñ5×:Ñ:Ô;KÈBÐ[`Ó;aÓb×bÒbð ×1Ñ1×6Ñ6Ô7GÈÓ7SÓT×TÑT÷' ˆ]ñ 2øÜ ó ðØ×1Ñ1×6Ñ6Ô7GÈÈBÐVYÑ7ZÓ[×[Ò[øÜ+Ô-@ÐAó Ùðúã÷ ˆ]ûðúñcÙbð ,;à×1Ñ1×6Ñ6Ô7GÈÈBÓ7OÓP×PÒPáTøÜ'Ô)<Ð=ó ñ ðú÷) �]üsý   ‚F�F§C»C¼CÁ!E,Á"D:Á&D6Á'D:Á*)E,ÂD8Â-E,ÃE*ÃE,ÃFÃ	FÃCÃ
D3Ã'DÄDÄDÄ
D.ÄDÄD.ÄDÄD.Ä!FÄ%	FÄ.D3Ä3FÄ6D:Ä8E,Ä:)E,Å#E&Å$E,Å)FÅ*E,Å,E?Å<FÅ>E?Å?FÆ
FÆFc           	   ƒ  óè  #   • U R                   nU R                  nUR                  nUR                  nUR                  nU R
                  R                  U   n[        U[        [        -  5      (       a  U R                  XuU5      $ [        U[        5      (       aÐ  [        5        nU R
                  R                  (       a2  SUR                   3n	UR                  [!        X—R                  US95        ["        [$        [&        [(        4   " X#US9n
UR+                  U
5      I S h  v•N nS S S 5        [        U[,        5      (       a  U R/                  WU5      $ U R                  UWU5      $ [        U[0        5      (       a  [3        XEU5      $ [        U[4        5      (       a  U R7                  XuU5      $ [        U[8        5      (       a  [;        U5      $ [=        U5        g  Nº! , (       d  f       N¾= f7f)Nz	run node )rô   Únode©r½   r¾   r™   )r½   r¾   rô   r™   rš   rÓ   r©   rÈ   rJ   rI   Ú_handle_edgesr[   r   r§   r  rÕ   r2   r\   rf   rh   r   ÚcallrZ   Ú_handle_noderC   r–   r5   Ú_handle_decisionrH   ru   r*   )r|   Útaskr½   r¾   rô   r™   rš   r›  r×   rÙ   Ústep_contextrA  s               r~   r•  Ú_GraphIterator._run_taskv  s†  é € ð —
‘
ˆØ�y‰yˆà—,‘,ˆØ—‘ˆØ—_‘_ˆ
à�z‰z×Ñ Ñ(ˆä�dœI¬Ñ,×-Ñ-Ø×%Ñ% d°JÓ?Ð?Ü˜œd×#Ñ#Ü” Ø—:‘:×-×-ð #,¨D¯G©G¨9Ð 5�IØ×'Ñ'¬°YÏÉÐVZÑ([Ô\ä*¬6´5¼#Ð+=Ò>ÀUÐ^dÑe�Ø#Ÿy™y¨Ó6×6�÷ ô ˜$¤×)Ñ)Ø×(Ñ(¨°Ó<Ð<à×)Ñ)¨$°¸
ÓCÐCÜ˜œd×#Ñ#Ü˜G¨ZÓ8Ð8Ü˜œh×'Ñ'Ø×(Ñ(¨°zÓBÐBÜ˜œg×&Ñ&Ü˜VÓ$Ð$ä˜Õñ 7÷ •üs2   ‚B#G2Â%A?G!Ä$GÄ%G!Ä)B6G2ÇG!Ç!
G/Ç+G2c                ó´  • UR                    H•  nUR                  nUb	  U" U5      nOU[        UR                  5      nU[        [
        1;   a  SnO-[        U5      [        L a  U[        U5      ;   nO [        X'5      nU(       d  My  U R                  UR                  X#5      s  $    [        SU SU S35      e! [         a  n[        SU S35      UeS nAff = f)NTzDecision branch source z is not a valid type.zNo branch matched inputs z for decision node Ú.)ÚbranchesÚmatchesrb   rS  r   Úobjectr   r   r   rÈ   Ú	TypeErrorr³   Ú_handle_pathÚpath)	r|   Údecisionr™   rš   ÚbranchÚmatch_testerÚinputs_matchÚbranch_sourceÚes	            r~   r   Ú_GraphIterator._handle_decision�  sä   € ð ×'Ô'ˆFØ!Ÿ>™>ˆLØÑ'Ù+¨FÓ3‘ä 6°v·}±}Ó E�à ¤S¬& MÓ1Ø#'‘LÜ Ó.´'Ò9Ø#)¬X°mÓ-DÑ#D‘LðrÜ'1°&Ó'H˜÷ ˆ|Ø×(Ñ(¨¯©°fÓIÒIñ% (ô( Ð6°v°hÐ>QÐRZÐQ[Ð[\Ð]Ó^Ð^øô %ó rÜ*Ð-DÀ]ÀOÐShÐ+iÓjÐpqÐqûðrús   Á2B8Â8
CÃCÃCc                ó,  • [        U[        5      (       a:  [        UR                  R                  UR
                  X R                  5       5      /$ [        U[        5      (       a+  [        UR                  R                  UR
                  U5      $ [        U[        5      (       a;  [        UR                  5      n[        UR                  XU R                  5       5      /$ [        U[        5      (       a  [        UR                  5      $ [!        U5        g ry   )rÈ   r^   rö   Ústepr  r™   rX  rD   r–   Újoinr3   rZ   rè   r4   ru   Údatar*   )r|   Ú	next_noderš   Ú	node_steps       r~   rŸ  Ú_GraphIterator._handle_node¶  sÈ   € ô
 �i¤×*Ñ*Ü˜iŸn™n×/Ñ/°×1AÑ1AÀ:×OdÑOdÓOfÓgÐhÐhÜ˜	¤8×,Ñ,Ü˜IŸN™N×-Ñ-¨y×/?Ñ/?ÀÓLÐLÜ˜	¤8×,Ñ,Ü  ×!4Ñ!4Ó5ˆIÜ˜iŸl™l¨IÀ4×CXÑCXÓCZÓ[Ð\Ð\Ü˜	¤3×'Ñ'Ü˜YŸ^™^Ó,Ð,ä˜Õ#r�   c                ó>  • U R                   R                  U5      R                  n[        USSS2   5       HY  u  pEUR                  U:X  d  M  U R                   R	                  U5      (       a  US[        U5      U-
   nOUnUR                  U4s  $    [        S5      e)zgDetermine which parent fork run a join item belongs to, and the fork stack its output should run under.Nrã   zParent fork run not found)rÓ   rµ   re  Ú	enumeraterº   Úlenrt  r³   )r|   r˜   rš   ry  ÚiÚxrp  s          r~   rf  Ú%_GraphIterator._resolve_join_fork_runÇ  s–   € àŸ™×3Ñ3°GÓ<×DÑDˆÜ˜j©¨2¨Ñ.Ö/‰DˆAØ�y‰y˜NÕ*Ø—:‘:×+Ñ+¨G×4Ñ4ð -7Ð7L¼¸Z»È1Ñ9LÐ,MÑ)ð -7Ð)Ø—}‘}Ð&;Ð;Ò;ñ 0ô Ð6Ó7Ð7r�   c                óF  • / n[        UR                  5       VVs0 s H  u  pEUR                  U_M     nnnU R                  R	                  5        HF  u  pxUR                  U5      n	U	c  M  U R                  X'U5      (       d  M4  UR                  Xx45        MH     U$ s  snnf ry   )r»  rš   rt  r[  Úkeysr²   Ú_is_fork_run_completedÚappend)
r|   r�  rZ  Úcompleted_fork_runsr½  r‹  Úfork_run_indicesr˜   rz  Úfork_run_indexs
             r~   rm  Ú'_GraphIterator._get_completed_fork_runs×  s    € ð
 ?AÐä=FÀqÇ|Á|Ô=TÔUÒ=T±6°1˜CŸO™O¨QÒ.Ñ=TÐÑUØ$(×$8Ñ$8×$=Ñ$=Ö$?Ñ ˆGØ-×1Ñ1°+Ó>ˆNØÑ%Ùð ×*Ñ*¨<À+×NÓNØ#×*Ñ*¨GÐ+AÖBñ %@ð #Ð"ùó Vs   ›Bc                ó:  • UR                   (       d  / $ UR                   S   n[        U[        [        -  5      (       a   S5       e[        U[        5      (       a&  [        UR                  X#U R                  5       5      /$ [        U[        5      (       aJ  UR                  [        U R                  U R                  US95      nU R                  UR                  X#5      $ [        U[        5      (       a  U R                  UR                  X#5      $ [!        U5        g )Nr   z@These markers should be removed from paths during graph buildingrœ  )rr  rÈ   rV   rQ   rR   rö   Údestination_idrX  rY   Ú	transformr\   r½   r¾   rª  Ú	next_pathrU   r*   )r|   r«  r™   rš   Úitems        r~   rª  Ú_GraphIterator._handle_pathê  sÞ   € Ø�z�zØˆIà�z‰z˜!‰}ˆÜ˜d¤I´Ñ$?×@Ñ@ð 	
ØNó	
Ð@ô �dÔ-×.Ñ.Ü˜d×1Ñ1°6Àt×G\ÑG\ÓG^Ó_Ð`Ð`Ü˜œo×.Ñ.Ø—^‘^¤K°d·j±jÀtÇyÁyÐY_Ñ$`ÓaˆFØ×$Ñ$ T§^¡^°VÓHÐHÜ˜œk×*Ñ*Ø×$Ñ$ T§^¡^°VÓHÐHä˜Õr�   c                ót   • [        U[        5      (       a  U R                  XU5      $ U R                  XU5      $ ry   )rÈ   rI   Ú_handle_fork_edgesro  )r|   r›  r™   rš   s       r~   r�  Ú_GraphIterator._handle_edgesü  s7   € ô �dœD×!Ñ!Ø×*Ñ*¨4¸ÓDÐDà×.Ñ.¨t¸ZÓHÐHr�   c                ó®   • U R                   R                  R                  UR                  / 5      n[	        U5      S:X  d   eU R                  US   X#5      $ )NrE  r   )rÓ   r«   r²   r  r¼  rª  )r|   r›  r™   rš   Úedgess        r~   ro  Ú%_GraphIterator._handle_non_fork_edges  sI   € Ø—
‘
×*Ñ*×.Ñ.¨t¯w©w¸Ó;ˆÜ�5‹z˜Q‹ÐˆØ× Ñ   q¡¨6Ó>Ð>r�   c                ó@  ^ ^^^^^• T R                   R                  R                  TR                  / 5      m[	        T5      S:X  d9  [        T[        5      (       a  TR                  (       a   TTR                  45       e/ nT R                  5       mTR                  (       Ga8  TR                  =nb“  T R                   R                  U   n[        U[        5      (       d   eT[        TR                  TS5      4-   nT R                  XW5      u  p‰T R                  R                  XX4[!        UR#                  5       U	5      5        [%        T5      (       aI  ['        T5       H8  u  p«T R)                  TS   UT[        TR                  TU
5      4-   5      nXL-  nM:     U$ [+        T5      (       a  SUUUUUU 4S jjn[-        U" 5       T5      $ [/        ST< 35      e['        T5       H4  u  pïUT R)                  UTT[        TR                  TU5      4-   5      -  nM6     U$ )NrE  r   c                ó¤   >#   • Sn T  S h  v•N nTR                  TS   UT[        TR                  TU 5      4-   5      nU7v •  U S-  n MD   N?
 g 7f)Nr   rE  )rª  r<   r  )	Úthread_indexÚ
input_itemÚ
item_tasksrÒ  rš   r™   r›  rt  r|   s	      €€€€€€r~   Úhandle_async_iterableÚ@_GraphIterator._handle_fork_edges.<locals>.handle_async_iterable*  s`   øé € Ø#$�LÙ,2÷ *˜jØ%)×%6Ñ%6Ø! !™H j°*ÄÈdÏgÉgÐWbÐdpÓ@qÐ?sÑ2só&˜
ð )Ó(Ø$¨Ñ)šñ*©Fùs%   ƒAˆAŒA�A�<AÁAÁAzCannot map non-iterable value: )r…   z"AsyncIterator[Sequence[GraphTask]])rÓ   r«   r²   r  r¼  rÈ   rI   Úis_maprW  Údownstream_join_idr©   rC   r<   rf  r[  Ú
setdefaultrE   rg  Ú_is_any_iterabler»  rª  Ú_is_any_async_iterablerO  r³   )r|   r›  r™   rš   r€  r˜   r{  Úchild_fork_stackrz  rp  rÖ  r×  rØ  rÙ  r½  r«  rÒ  rt  s   ````            @@r~   rÏ  Ú!_GraphIterator._handle_fork_edges	  s  ý€ ð —
‘
×*Ñ*×.Ñ.¨t¯w©w¸Ó;ˆÜ�5‹z˜Q‹¤:¨d´D×#9Ñ#9À$Ç+Ç+ð 	
ØØ�G‰GðQ
ó 	
ÐNð
 &(ˆ	Ø×/Ñ/Ó1ˆØ�;�;ˆ;ð  ×2Ñ2Ð2�Ñ?Ø ŸJ™J×,Ñ,¨WÑ5�	Ü! )¬T×2Ñ2Ð2Ð2Ø#-´¸t¿w¹wÈÐUVÓ1WÐ0YÑ#YÐ Ø59×5PÑ5PÐQXÓ5kÑ2�Ø×$Ñ$×/Ñ/ØÐ*¬I°i×6OÑ6OÓ6QÐShÓ,iôô
   ×'Ñ'Ü09¸&Ö0AÑ,�LØ!%×!2Ñ!2Ø˜a™ *¨j¼MÈ$Ï'É'ÐS^Ð`lÓ<mÐ;oÑ.oó"�Jð Ñ+’Iñ	 1Bð. Ðô% (¨×/Ñ/÷*ô *ô /Ñ/DÓ/FÈ
ÓSÐSô #Ð%DÀVÁJÐ#OÓPÐPä$ UÖ+‘�Ø˜T×.Ñ.¨t°V¸ZÌ=ÐY]×Y`ÑY`ÐbmÐopÓKqÐJsÑ=sÓtÑt’	ñ ,àÐr�   c                ó  • U R                   R                  U5      nU HZ  nX5R                   Vs1 s H  ofR                  iM     sn;   a.  UR                  UR
                  ;   d  UR                  U:X  a    gMZ  M\     gs  snf )NFT)rÓ   rµ   rš   rt  rô   Úintermediate_nodes)r|   Útasksr˜   rz  Úparent_forkr�  r¾  s          r~   rÂ  Ú%_GraphIterator._is_fork_run_completed<  st   € ð —j‘j×0Ñ0°Ó9ˆÛˆAØ·l²lÓC²l°Ÿ}œ}±lÑCÓCØ—9‘9 × >Ñ >Ó>À!Ç)Á)ÈwÓBVÙ ñ CWñ ñ ð ùò Ds   ¯A=c              ƒ  óL  #   • [         [           " 5       nU R                  R                  5        HL  u  pEUR                   H7  nUR
                  U:X  a$  UR                  U:X  a  UR                  U5          MH  M9     MN     U H  nU R                  U5      I S h  v•N   M     g  N	7fry   )	rs  r@   rZ  rr  rš   re  rt  Úaddrb  )r|   ry  rt  Útask_ids_to_cancelr÷   r�  rÌ  s          r~   rk  Ú$_GraphIterator._cancel_sibling_tasksH  sŠ   é € Ü ¤š[›]ÐØ×+Ñ+×1Ñ1Ö3‰JˆGØŸœ�Ø—<‘< >Ó1°d×6FÑ6FÈ+Ó6UØ&×*Ñ*¨7Ô3Úáó %ñ 4ó *ˆGØ×#Ñ# GÓ,×,Ò,ò *Ù,ùs   ‚BB$ÂB"Â
B$)r  r[  rZ  rY  r!  r  N)rv  rö   r…   z~AsyncGenerator[EndMarker[OutputT] | ErrorMarker | Sequence[GraphTask], EndMarker[OutputT] | ErrorMarker | Sequence[GraphTask]])r÷   r@   r…   rM  )rù   úSequence[GraphTask]r…   rM  )r—  rö   )r¡  rö   r…   zMEndMarker[OutputT] | Sequence[GraphTask] | _GraphTaskAsyncIterable | JoinItem)r¬  zDecision[StateT, DepsT, Any]r™   r   rš   r;   r…   rë  )r·  z'BaseNode[StateT, DepsT, Any] | End[Any]rš   r;   r…   z3Sequence[GraphTask] | JoinItem | EndMarker[OutputT])r˜   r=   rš   r;   r…   ztuple[NodeRunID, ForkStack])r�  rö   rZ  úIterable[GraphTask]r…   zlist[tuple[JoinID, NodeRunID]])r«  rW   r™   r   rš   r;   r…   rë  )r›  rL   r™   r   rš   r;   r…   ú-Sequence[GraphTask] | _GraphTaskAsyncIterable)r›  rL   r™   r   rš   r;   r…   rë  )r›  zFork[Any, Any]r™   r   rš   r;   r…   rí  )rä  rì  r˜   r=   rz  r?   r…   r¦   )ry  r:   rt  r?   )r†   r‡   rˆ   r‰   r‹   r   rY  rZ  r[  r  r!  r]  r  rb  ra  r’  r•  r   rŸ  rf  rm  rª  r�  ro  rÏ  rÂ  rk  r�   rŽ   r�   r~   r
  r
  ‹  s•  ‡ à-Ó-ØƒMØ
ƒKØÓØ1Ó1Ø*Ó*á/4¸%Ñ/@€MÐ,Ó@Ù,1°uÑ,=€LÐ)Ó=ÙAFÈEÑAR€OÐ>ÓRÙCHÈeÑCTÐÐ@ÓTÙHMÐSXÑHYÐÐEÓYò#ðh
Ø#ðh
ð
ôh
ôT-ôIôð<%àð%ð 
Wô%ðN_Ø4ð_Ø>Að_ØOXð_à	ô_ð2$à:ð$ð ð$ð 
=ô	$ô"8ð #àð#ð *ð#ð 
(ô	#ô&ð$IØðIØ%(ðIØ6?ðIà	6ôIô?ð
1Ø"ð1Ø,/ð1Ø=Fð1à	6ô1ôf
÷
-r�   r
  c                ó"   • [        U [        5      $ ry   )rÈ   r
   ©r¾  s    r~   rÞ  rÞ  U  s   € Ü�aœÓ"Ð"r�   c                ó"   • [        U [        5      $ ry   )rÈ   r   rï  s    r~   rß  rß  Y  s   € Ü�aœÓ'Ð'r�   c               #  ó¤   #   • [         (       a  S v •  g  S v •  g ! [         a*  n U R                  S   nUR                  c  S Ul        UeS n A ff = f7f)Nr   )r   re   r,   Ú	__cause__)r±  Ú	exceptions     r~   r  r  ]  sL   é € ÷
 ‚}Üð	ÜøÜ!ó 	ØŸ™ Q™ˆIØ×"Ñ"Ñ*à&*�	Ô#ØˆOûð	üs$   ‚A” ˜A™
A£%AÁAÁAc                  óÊ  • \ rS rSr% SrS\S'    S\S'    S\S'    S	\S
'    S\S'    S\S'    S\S'    S\S'    S\S'    \" S\\\	\
4   \
4S9r\" S\\\	\4   \4S9rS\\\\SS.           S<S jjr\S=S j5       r\S>S j5       r\SSS.     S?S jj5       r\SSS.       S@S  jj5       r SASSS.       SBS! jjjr\SSS.     SCS" jj5       r\SSS.       SDS# jj5       r\ SASSS.       SES$ jjj5       r SASSS.       SES% jjjr\SSS&S'.           SFS( jj5       r\SSS&S'.           SGS) jj5       r\\SSS&S*.             SHS+ jjrSIS, jrSS-.SJS. jjrSSSSS/.             SKS0 jjrSLS1 jrSSS2.SMS3 jjrSS4.     SNS5 jjrSS4.     SOS6 jjr    SPS7 jr SQS8 jr!      SRS9 jr"SSSTS: jjr#S;r$g)UÚGraphBuilderir  a«  A builder for constructing executable graph definitions.

GraphBuilder provides a fluent interface for defining nodes, edges, and
routing in a graph workflow. It supports typed state, dependencies, and
input/output validation.

Type Parameters:
    StateT: The type of the graph state
    DepsT: The type of the dependencies
    GraphInputT: The type of the graph input data
    GraphOutputT: The type of the graph output data
r    r¡   úTypeOrTypeExpression[StateT]r¢   úTypeOrTypeExpression[DepsT]r£   ú!TypeOrTypeExpression[GraphInputT]r¤   ú"TypeOrTypeExpression[GraphOutputT]r¥   r¦   r§   r¨   Ú_nodesrª   Ú_edges_by_sourceÚintÚ_decision_indexÚSource)Útype_paramsÚDestinationNT)r¡   r¢   r£   r¤   r¥   r§   c               óì   • Xl         X l        X0l        X@l        XPl        X`l        0 U l        [        [        5      U l	        SU l
        [        [           " 5       U l        [        [           " 5       U l        g)a·  Initialize a graph builder.

Args:
    name: Optional name for the graph, if not provided the name will be inferred from the calling frame on the first call to a graph method.
    state_type: The type of the graph state
    deps_type: The type of the dependencies
    input_type: The type of the graph input data
    output_type: The type of the graph output data
    auto_instrument: Whether to automatically create instrumentation spans
rE  N)r¡   r¢   r£   r¤   r¥   r§   rú  r   rl  rû  rý  rJ   ro   Ú_start_noderH   rp   Ú	_end_node)r|   r¡   r¢   r£   r¤   r¥   r§   s          r~   r   ÚGraphBuilder.__init__Ÿ  s_   € ð( Œ	à$ŒØ"ŒØ$ŒØ&Ôà.ÔàˆŒÜ +¬DÓ 1ˆÔØ ˆÔä$¤[Ò1Ó3ˆÔÜ ¤Ò.Ó0ˆ�r�   c                ó   • U R                   $ )zeGet the start node for the graph.

Returns:
    The start node that receives the initial graph input
)r  rƒ   s    r~   Ú
start_nodeÚGraphBuilder.start_nodeÄ  s   € ð ×ÑÐr�   c                ó   • U R                   $ )z`Get the end node for the graph.

Returns:
    The end node that produces the final graph output
)r  rƒ   s    r~   Úend_nodeÚGraphBuilder.end_nodeÍ  s   € ð �~‰~Ðr�   )rô   Úlabelc               ó   • g ry   rŽ   ©r|   rô   r  s      r~   r´  ÚGraphBuilder.stepÖ  s	   € ð jmr�   c               ó   • g ry   rŽ   ©r|   rž  rô   r  s       r~   r´  r  Ý  s   € ð 03r�   c               ó²   ^ ^^• Uc      SUUU 4S jjnU$ T=(       d    [        U5      m[        [        [        [        [
        4   " [        T5      UTS9nU$ )aD  Create a step from a step function.

This method can be used as a decorator or called directly to create
a step node from an async function.

Args:
    call: The step function to wrap
    node_id: Optional ID for the node
    label: Optional human-readable label

Returns:
    Either a Step instance or a decorator function
c                ó&   >• TR                  U TTS9$ ©N©rž  rô   r  )r´  ©Úfuncr  rô   r|   s    €€€r~   Ú	decoratorÚ$GraphBuilder.step.<locals>.decoratorþ  s   ø€ ð —y‘y d°GÀ5�yÐIÐIr�   )r  rž  r  )r  ú,StepFunction[StateT, DepsT, InputT, OutputT]r…   ú$Step[StateT, DepsT, InputT, OutputT])ra   r[   rf   rh   ri   rj   r>   )r|   rž  rô   r  r  r´  s   ` ``  r~   r´  r  å  sf   ú€ ð. ‰<ðJØBðJà5÷Jñ Jð
 Ðà×4Ô.¨tÓ4ˆä”FœE¤6¬7Ð2Ò3´v¸g³ÈTÐY^Ñ_ˆàˆr�   c               ó   • g ry   rŽ   r  s      r~   ÚstreamÚGraphBuilder.stream  s   € ð r�   c               ó   • g ry   rŽ   r  s       r~   r  r    s   € ð ?Br�   c               ó   • g ry   rŽ   r  s       r~   r  r    s   € ð r�   c               óŠ   ^ ^^^• Tc      SUUU 4S jjnU$ SU4S jjnT=(       d    [        T5      mT R                  UTTS9$ )ah  Create a step from an async iterator (which functions like a "stream").

This method can be used as a decorator or called directly to create
a step node from an async function.

Args:
    call: The step function to wrap
    node_id: Optional ID for the node
    label: Optional human-readable label

Returns:
    Either a Step instance or a decorator function
c                ó&   >• TR                  U TTS9$ r  )r  r  s    €€€r~   r  Ú&GraphBuilder.stream.<locals>.decoratorF  s   ø€ ð —{‘{¨°gÀU�{ÐKÐKr�   c              “  ó   >#   • T" U 5      $ 7fry   rŽ   )Úctxrž  s    €r~   ÚwrapperÚ$GraphBuilder.stream.<locals>.wrapperN  s   øé € Ù˜“9Ðùs   ƒ	r  )r  ú.StreamFunction[StateT, DepsT, InputT, OutputT]r…   ú3Step[StateT, DepsT, InputT, AsyncIterable[OutputT]])r$  z"StepContext[StateT, DepsT, InputT])ra   r´  )r|   rž  rô   r  r  r%  s   ````  r~   r  r  *  s\   û€ ð4 ‰<ðLØDðLàD÷Lñ Lð
 Ð÷	ð ×4Ô.¨tÓ4ˆà�y‰y˜g¨w¸eˆyÐDÐDr�   Úfarthest)rô   ry  Úpreferred_parent_forkc               ó   • g ry   rŽ   )r|   ÚreducerÚinitialrô   ry  r*  s         r~   rµ  ÚGraphBuilder.joinU  ó   € ð 03r�   c               ó   • g ry   rŽ   )r|   r,  rg  rô   ry  r*  s         r~   rµ  r.  _  r/  r�   )r-  rg  rô   ry  r*  c               ó  ^• U[         L a  U4S jn[        [        [        [        [
        4   " [        [        U=(       d    [        [        U5      5      5      5      U[        [        / [
        4   U5      Ub  [        U5      US9$ S US9$ )Nc                 ó   >• T $ ry   rŽ   )r-  s   €r~   Ú<lambda>Ú#GraphBuilder.join.<locals>.<lambda>u  s   ø€ ¡gr�   )r  r,  rg  ry  r*  )r-   rC   rf   rh   ri   rj   r=   r>   rA   ra   r   r	   r:   )r|   r,  r-  rg  rô   ry  r*  s     `    r~   rµ  r.  j  s†   ø€ ð œeÒ#Ü-ˆOä”FœE¤6¬7Ð2Ò3Ü”f˜W×`Ô(DÔEVÐW^ÓE_Ó(`ÓaÓbØÜ ¤¨"¬g¨+Ñ!6¸ÓHØ5CÑ5Oœ6 .Ó1Ø"7ñ
ð 	
ð VZØ"7ñ
ð 	
r�   c                óÚ  ^ ^	^
^^• SU
U 4S jjm
SU	U
UUU 4S jjm	[         [           " 5       m/ mU H†  nUR                   HF  nT R                  U5        T R                  UR
                     R                  UR                  5        MH     UR                   H  nT	" U5        M     T
" UR                  5        Mˆ     T Hš  n[        U[        5      (       a  [        U[        5      (       a  M/  [        R                  " [        R                  " 5       5      n[!        UR"                  USS9n US   nT R%                  XX5      nUb  T R'                  U5        Mš  Mœ     g! [(         a     M¬  f = f)	zÍAdd one or more edge paths to the graph.

This method processes edge paths and automatically creates any necessary
fork nodes for broadcasts and maps.

Args:
    *edges: The edge paths to add to the graph
c                óö  >• U R                    Hè  n[        U[        5      (       ad  [        [        [        4   " UR
                  SSS9nTR                  U5        UR                   H  nT" [        / UR                   QS95        M      M|  [        U[        5      (       a@  [        [        [        4   " UR
                  SUR                  S9nTR                  U5        MÑ  [        U[        5      (       d  Mè  Mê     g)zRProcess a path and create necessary fork nodes.

Args:
    p: The path to process
FN©r  rÛ  rÜ  ©rr  T)rr  rÈ   rQ   rI   r   re  Ú_insert_nodeÚpathsrW   rV   rÜ  rR   )ÚprÌ  Únew_noder«  rª  r|   s       €€r~   rª  Ú&GraphBuilder.add.<locals>._handle_pathŠ  s¹   ø€ ð Ÿœ�Ü˜d¤O×4Ñ4Ü#¤C¬ Hš~°·±ÀeÐ`dÑe�HØ×%Ñ% hÔ/Ø $§
¤
˜Ù$¤T°°$·*±*°Ñ%>Ö?ó !+ä ¤i×0Ñ0Ü#¤C¬ Hš~°·±ÀdÐ_c×_vÑ_vÑw�HØ×%Ñ% hÖ/Ü Ô&7×8Ó8Ùò  r�   c                óJ  >• [        U 5      T;   a  g TR                  [        U 5      5        TR                  U 5        TR                  U 5        [	        U [
        5      (       aA  U R                   H0  nT" UR                  5        UR                   H  nT" U5        M     M2     g g ry   )	r  rè  rÃ  r9  rÈ   r5   r¦  r«  Údestinations)Údr­  Úd2Ú_handle_destination_noderª  Údestination_idsr?  r|   s      €€€€€r~   rB  Ú2GraphBuilder.add.<locals>._handle_destination_nodeœ  s„   ø€ Ü�!‹u˜Ó'Øà×Ñ¤ 1£Ô&Ø×Ñ Ô"Ø×Ñ˜aÔ Ü˜!œX×&Ñ&ØŸjœj�FÙ  §¡Ô-Ø$×1Ô1˜Ù0°Ö4ó 2ò )ð 'r�   T©ÚlocalnsÚinclude_extrasr…   N)r;  rW   )r@  rK   )rs  rü  Úsourcesr9  rû  r  rÃ  r«  r?  rÈ   r[   rZ   r+   Úget_parent_namespaceÚinspectÚcurrentframer   rž  Ú_edge_from_return_hintrè  ÚKeyError)r|   rÒ  ÚedgeÚsource_nodeÚdestination_nodeÚdestinationÚparent_namespaceÚ
type_hintsÚreturn_hintrB  rª  rC  r?  s   `        @@@@r~   rè  ÚGraphBuilder.add€  s;  ü€ ÷	ð 	÷$	5ó 	5ô œcš(›*ˆØ13ˆÛˆDØ#Ÿ|œ|�Ø×!Ñ! +Ô.Ø×%Ñ% k§n¡nÑ5×<Ñ<¸T¿Y¹YÖGñ  ,ð %)×$5Ô$5Ð Ù(Ð)9Ö:ñ %6á˜Ÿ™Ö#ñ ó (ˆKÜ˜k¬4×0Ñ0´J¸{ÌH×4UÑ4UÙÜ%×:Ò:¼7×;OÒ;OÓ;QÓRÐÜ'¨×(8Ñ(8ÐBRÐcgÑhˆJð#Ø(¨Ñ2�ð ×2Ñ2°;ÓL�ØÑ#Ø—H‘H˜T–Nñ $ò (øô ó Úðús   Ä+EÅ
E*Å)E*)r  c               óŽ   • U R                  U5      nUb  UR                  U5      nU R                  UR                  U5      5        g)z•Add a simple edge between two nodes.

Args:
    source: The source node
    destination: The destination node
    label: Optional label for the edge
N)Ú	edge_fromr  rè  Úto)r|   rS  rQ  r  Úbuilders        r~   Úadd_edgeÚGraphBuilder.add_edgeÂ  s;   € ð —.‘. Ó(ˆØÑØ—m‘m EÓ*ˆGØ�‰�—‘˜KÓ(Õ)r�   )Úpre_map_labelÚpost_map_labelre  rÜ  c               óÔ   • U R                  U5      nUb  UR                  U5      nUR                  XVS9nUb  UR                  U5      nU R                  UR	                  U5      5        g)a0  Add an edge that maps iterable data across parallel paths.

Args:
    source: The source node that produces iterable data
    map_to: The destination node that receives individual items
    pre_map_label: Optional label before the map operation
    post_map_label: Optional label after the map operation
    fork_id: Optional ID for the fork node produced for this map operation
    downstream_join_id: Optional ID of a join node that will always be downstream of this map.
        Specifying this ensures correct handling if you try to map an empty iterable.
N)re  rÜ  )rW  r  Úmaprè  rX  )r|   rS  Úmap_tor\  r]  re  rÜ  rY  s           r~   Úadd_mapping_edgeÚGraphBuilder.add_mapping_edgeÏ  s_   € ð* —.‘. Ó(ˆØÑ$Ø—m‘m MÓ2ˆGØ—+‘+ g�+ÐUˆØÑ%Ø—m‘m NÓ3ˆGØ�‰�—‘˜FÓ#Õ$r�   c                óJ   • [         [        [        [        4   " U[	        / S9S9$ )zÍCreate an edge path builder starting from the given source nodes.

Args:
    *sources: The source nodes to start the edge path from

Returns:
    An EdgePathBuilder for constructing the complete edge path
©Úworking_items)rH  Úpath_builder)rT   rf   rh   rn   rX   )r|   rH  s     r~   rW  ÚGraphBuilder.edge_fromî  s'   € ô œv¤u¬mÐ;Ò<Ø¬+ÀBÑ*Gñ
ð 	
r�   )Únoterô   c               óN   • [        [        U=(       d    [        S5      5      / US9$ )zÔCreate a new decision node.

Args:
    note: Optional note to describe the decision logic
    node_id: Optional ID for the node produced for this decision logic

Returns:
    A new Decision node with no branches
r¬  ©r  r¦  rh  )r5   r>   rA   )r|   rh  rô   s      r~   r¬  ÚGraphBuilder.decisionû  s%   € ô œ6 '×"UÔ-IÈ*Ó-UÓVÐacÐjnÑoÐor�   )r§  c               ó²   • [        [        S5      5      n[        [        [        [
        4   " U/ SS9n[        [        [        [        4   " / S9n[        XAX%S9$ )zÓCreate a decision branch matcher.

Args:
    source: The type or type expression to match against
    matches: Optional custom matching function

Returns:
    A DecisionBranchBuilder for constructing the branch
Úmatch_decisionNrj  rd  )r¬  rS  r§  rf  )	r>   rA   r5   rf   rh   r'   rX   rk   r7   )r|   rS  r§  rô   r¬  Únew_path_builders         r~   ÚmatchÚGraphBuilder.match  sT   € ô" Ô5Ð6FÓGÓHˆÜœF¤E¬5Ð0Ò1°WÀrÐPTÑUˆÜ&¤v¬u´gÐ'=Ò>ÈRÑPÐÜ$¨hÈwÑvÐvr�   c               óh   • [        U5      n[        [        UR                  5      /S9n[	        XXC/S9$ )a7  Create a decision branch for `BaseNode` subclasses.

This is similar to `match()` but specifically designed for matching against `BaseNode` types.

Args:
    source: The `BaseNode` subclass to match against
    matches: Optional custom matching function

Returns:
    A `DecisionBranch` for the `BaseNode` type
r8  )rS  r§  r«  r?  )rZ   rW   rR   r  r6   )r|   rS  r§  r›  r«  s        r~   Ú
match_nodeÚGraphBuilder.match_node  s5   € ô" ˜ÓˆÜÔ,¨T¯W©WÓ5Ð6Ñ7ˆÜ VÀ4ÐV\Ñ]Ð]r�   c                ób  • [         R                  " [        R                  " 5       5      n[	        UR
                  USS9n US   n[        U5      nU R                  Xd5      nU(       d  [        R                  " SU S35      eU$ ! [         a   n[        R                  " SU S35      UeSnAff = f)aŠ  Create an edge path from a `BaseNode` class.

This method integrates a `BaseNode` subclass into the builder graph by
analyzing its `run` return type hints and creating appropriate edges.

Args:
    node_type: The `BaseNode` subclass to integrate

Returns:
    An `EdgePath` representing the node and its connections

Raises:
    GraphSetupError: If the node type is missing required type hints
TrE  r…   r±   z2 is missing a return type hint on its `run` methodN)r+   rI  rJ  rK  r   rÌ   rM  r,   ÚGraphSetupErrorrZ   rL  )r|   Ú	node_typerR  rS  rT  r±  r›  rN  s           r~   r›  ÚGraphBuilder.node2  sµ   € ô$ "×6Ò6´w×7KÒ7KÓ7MÓNÐÜ# I§M¡MÐ;KÐ\`Ñaˆ
ð	Ø$ XÑ.ˆKô ˜	Ó"ˆà×*Ñ*¨4Ó=ˆÞÜ×,Ò,¨u°Y°KÐ?qÐ-rÓsÐsàˆøô ó 	Ü×,Ò,Ø˜	�{Ð"TÐUóàðûð	ús   Á B Â
B.ÂB)Â)B.c                óT  • U R                   R                  UR                  5      nUc  XR                   UR                  '   g[        U[        5      (       a/  [        U[        5      (       a  UR
                  UR
                  L a  gX!La  [        SUR                  < SU SU 35      eg)zªInsert a node into the graph, checking for ID conflicts.

Args:
    node: The node to insert

Raises:
    ValueError: If a different node with the same ID already exists
Nz%All nodes must have unique node IDs. z was the ID for z and )rú  r²   r  rÈ   rZ   rv  r8   )r|   r›  Úexistings      r~   r9  ÚGraphBuilder._insert_nodeV  s˜   € ð —;‘;—?‘? 4§7¡7Ó+ˆØÑØ#'�K‰K˜Ÿ™Ò Ü˜¤(×+Ñ+´
¸4Ä×0JÑ0JÈx×OaÑOaÐei×esÑesÒOsØØÒ!Ü$Ø7¸¿¹±{ÐBRÐS[ÐR\Ð\aÐbfÐagÐhóð ð "r�   c                óø  • / n[         R                  " U5      nU GH²  n[         R                  " U5      u  pV[        U5      =(       d    UnU[        L a  UR                  U R                  5        MV  U[        L a  [        R                  " SU S35      eU[        L ak  [        [        [        [        [        [        4   S-  [!        S U 5       S5      5      nUc  [        R                  " SU S35      eUR                  U5        Mí  U["        L al  [        [$        [        [        [        [        4   S-  [!        S U 5       S5      5      n	U	c  [        R                  " SU S35      eUR                  U	5        GMb  [&        R(                  " U5      (       d  GM€  [+        U[        5      (       d  GM˜  UR                  [-        U5      5        GMµ     [/        U5      [/        U5      :  a  gU R1                  U5      n
[/        U5      S:X  a  U
R3                  US	   5      $ U R5                  5       nU H6  nUR7                  U R9                  [:        5      R3                  U5      5      nM8     U
R3                  U5      $ )
aŽ  Create edges from a return type hint.

This method analyzes return type hints from step functions or node methods
to automatically create appropriate edges in the graph.

Args:
    node: The source node
    return_hint: The return type hint to analyze

Returns:
    An EdgePath if edges can be inferred, None otherwise

Raises:
    GraphSetupError: If the return type hint is invalid or incomplete
r±   zŠ return type hint includes a plain `BaseNode`. Edge inference requires each possible returned `BaseNode` subclass to be listed explicitly.Nc              3  óT   #   • U  H  n[        U[        5      (       d  M  Uv •  M      g 7fry   )rÈ   r[   ©Ú.0Úas     r~   Ú	<genexpr>Ú6GraphBuilder._edge_from_return_hint.<locals>.<genexpr>Š  ó   é € ÐH¢[ ´J¸qÄ$×4GŸ!™!¢[ùó   ‚(Ÿ	(z³ return type hint includes a `StepNode` without a `Step` annotation. When returning `my_step.as_node()`, use `Annotated[StepNode[StateT, DepsT], my_step]` as the return type hint.c              3  óT   #   • U  H  n[        U[        5      (       d  M  Uv •  M      g 7fry   )rÈ   rC   r}  s     r~   r€  r�  •  r‚  rƒ  z³ return type hint includes a `JoinNode` without a `Join` annotation. When returning `my_join.as_node()`, use `Annotated[JoinNode[StateT, DepsT], my_join]` as the return type hint.rE  r   )r+   Úget_union_argsÚunpack_annotatedr   r4   rÃ  r	  r3   r,   ru  r^   r   r[   rf   rh   r   rÆ   rD   rC   rJ  ÚisclassÚ
issubclassrZ   r¼  rW  rX  r¬  r­  ro  r   )r|   r›  rT  r?  Ú
union_argsÚreturn_typer   Úreturn_type_originr´  rµ  rN  r¬  rQ  s                r~   rL  Ú#GraphBuilder._edge_from_return_hinti  s9  € ð$ 24ˆÜ×*Ò*¨;Ó7ˆ
Ü%ˆKÜ'-×'>Ò'>¸{Ó'KÑ$ˆKÜ!+¨KÓ!8×!G¸KÐØ!¤SÒ(Ø×#Ñ# D§M¡MÖ2Ø#¤xÒ/Ü ×0Ò0Ø˜D˜6ð "rð róð ð $¤xÒ/ÜÜœ¤¬¬SÐ0Ñ1°DÑ8ÜÑH¡[ÓHÈ$ÓOó�ð ‘<Ü$×4Ò4Ø ˜vð &Ið Ióð ð ×#Ñ# DÖ)Ø#¤xÒ/ÜÜœ¤¬¬SÐ0Ñ1°DÑ8ÜÑH¡[ÓHÈ$ÓOó�ð ‘<Ü$×4Ò4Ø ˜vð &Ið Ióð ð ×#Ñ# D×)Ü—’Ð!3×4Ô4¼ÐDVÔX`×9aÔ9aØ×#Ñ#¤H¨[Ó$9×:ñC &ôF ˆ|Óœs :›Ó.àà�~‰~˜dÓ#ˆÜˆ|Ó Ó!Ø—7‘7˜<¨™?Ó+Ð+à—}‘}“ˆHÛ+�à#Ÿ?™?¨4¯:©:´hÓ+?×+BÑ+BÀ;Ó+OÓP’ñ  ,ð —7‘7˜8Ó$Ð$r�   c                óä  • U R                   nU R                  n[        X#5      u  p#[        X#5      u  p#[	        X#5      u  p#U(       a  [        X#5        [        X#5      n[        X$5      n[        [        [        [        [        4   " U R                  [        U R                  5      [        U R                   5      [        U R"                  5      [        U R$                  5      UUUUU R&                  S9
$ )a  Build the final executable graph from the accumulated nodes and edges.

This method performs validation, normalization, and analysis of the graph
structure to create a complete, executable graph instance.

Args:
    validate_graph_structure: whether to perform validation of the graph structure
        See the docstring of _validate_graph_structure below for more details.

Returns:
    A complete Graph instance ready for execution

Raises:
    ValueError: If the graph structure is invalid (e.g., join without parent fork)
)
r¡   r¢   r£   r¤   r¥   r©   r«   r­   r¯   r§   )rú  rû  Ú_replace_placeholder_node_idsÚ_flatten_pathsÚ_normalize_forksÚ_validate_graph_structureÚ_collect_dominating_forksÚ _compute_intermediate_join_nodesrž   rf   rh   ro   rp   r¡   rb   r¢   r£   r¤   r¥   r§   )r|   Úvalidate_graph_structurer©   r«   r­   r¯   s         r~   ÚbuildÚGraphBuilder.build¯  sÈ   € ð  —‘ˆØ×/Ñ/ˆä!>¸uÓ!VÑˆÜ!/°Ó!GÑˆÜ!1°%Ó!IÑˆÞ#Ü% eÔ=Ü0°ÓHˆÜ"BÀ5Ó"WÐä”VœU¤K´Ð=Ò>Ø—‘Ü-¨d¯o©oÓ>Ü,¨T¯^©^Ó<Ü-¨d¯o©oÓ>Ü.¨t×/?Ñ/?Ó@ØØ+Ø%Ø$;Ø ×0Ñ0ñ
ð 	
r�   )rý  rû  r  rú  r  r§   r£   r¤   r¡   r¥   r¢   )r¡   r    r¢   rö  r£   r÷  r¤   rø  r¥   rù  r§   r¦   )r…   zStartNode[GraphInputT])r…   zEndNode[GraphOutputT])rô   r    r  r    r…   z^Callable[[StepFunction[StateT, DepsT, InputT, OutputT]], Step[StateT, DepsT, InputT, OutputT]])rž  r  rô   r    r  r    r…   r  ry   )rž  z3StepFunction[StateT, DepsT, InputT, OutputT] | Nonerô   r    r  r    r…   z…Step[StateT, DepsT, InputT, OutputT] | Callable[[StepFunction[StateT, DepsT, InputT, OutputT]], Step[StateT, DepsT, InputT, OutputT]])rô   r    r  r    r…   zoCallable[[StreamFunction[StateT, DepsT, InputT, OutputT]], Step[StateT, DepsT, InputT, AsyncIterable[OutputT]]])rž  r'  rô   r    r  r    r…   r(  )rž  z5StreamFunction[StateT, DepsT, InputT, OutputT] | Nonerô   r    r  r    r…   z¥Step[StateT, DepsT, InputT, AsyncIterable[OutputT]] | Callable[[StreamFunction[StateT, DepsT, InputT, OutputT]], Step[StateT, DepsT, InputT, AsyncIterable[OutputT]]])r,  ú/ReducerFunction[StateT, DepsT, InputT, OutputT]r-  rj   rô   r    ry  r    r*  úLiteral['farthest', 'closest']r…   ú$Join[StateT, DepsT, InputT, OutputT])r,  r—  rg  zCallable[[], OutputT]rô   r    ry  r    r*  r˜  r…   r™  )r,  r—  r-  zOutputT | Unsetrg  zCallable[[], OutputT] | Unsetrô   r    ry  r    r*  r˜  r…   r™  )rÒ  úEdgePath[StateT, DepsT]r…   rM  )rS  z	Source[T]rQ  úDestination[T]r  r    r…   rM  )rS  zSource[Iterable[T]]r`  r›  r\  r    r]  r    re  zForkID | NonerÜ  zJoinID | Noner…   rM  )rH  zSource[SourceOutputT]r…   z-EdgePathBuilder[StateT, DepsT, SourceOutputT])rh  r    rô   r    r…   zDecision[StateT, DepsT, Never])rS  zTypeOrTypeExpression[SourceT]r§  úCallable[[Any], bool] | Noner…   z=DecisionBranchBuilder[StateT, DepsT, SourceT, SourceT, Never])rS  ztype[SourceNodeT]r§  rœ  r…   zDecisionBranch[SourceNodeT])rv  z+type[BaseNode[StateT, DepsT, GraphOutputT]]r…   rš  )r›  rL   r…   rM  )r›  zSourceNode[StateT, DepsT, Any]rT  zTypeOrTypeExpression[Any]r…   zEdgePath[StateT, DepsT] | None)T)r”  r¦   r…   z/Graph[StateT, DepsT, GraphInputT, GraphOutputT])%r†   r‡   rˆ   r‰   rŠ   r‹   r(   rN   rf   rh   rj   rþ  rM   ri   r   r   r   rŒ   r  r	  r   r´  r  rµ  r-   rè  rZ  ra  rW  r¬  ro  rr  r›  r9  rL  r•  r�   rŽ   r�   r~   rõ  rõ  r  s  ‡ ñð Óð Mà,Ó,Ø&à*Ó*Ø'à1Ó1Ø+à3Ó3Ø,àÓØ@à!Ó!Ø2à.Ó.Ø4àÓØ:á˜8 Z°¸¸wÐ0FÑ%GÐV]ÐU_Ñ`€FÙ ¨¸vÀuÈfÐ?TÑ/UÐdjÐclÑm€Kð
  Ø3;Ø19Ø8@Ø:BØ $ñ"1ð ð"1ð 1ð	"1ð
 /ð"1ð 6ð"1ð 8ð"1ð õ"1ðJ ó ó ð ð óó ðð ð #Ø ñ	mð ðmð ð	mð
 
hômó ðmð ð
 #Ø ñ3à:ð3ð ð	3ð
 ð3ð 
.ô3ó ð3ð EIð$ð #Ø ñ$àAð$ð ð	$ð
 ð$ð	iö$ðL ð #Ø ñ	ð ðð ð	ð

ôó ðð ð
 #Ø ñBà<ðBð ð	Bð
 ðBð 
=ôBó ðBð ð GKðð #Ø ñàCðð ð	ð
 ðð	
õó ðð GKð)Eð #Ø ñ)EàCð)Eð ð	)Eð
 ð)Eð	
ö)EðV ð #Ø%)Ø@Jñ3à@ð3ð ð	3ð
 ð3ð #ð3ð  >ð3ð 
.ô3ó ð3ð ð #Ø%)Ø@Jñ3à@ð3ð /ð	3ð
 ð3ð #ð3ð  >ð3ð 
.ô3ó ð3ð $)Ø9>Ø"Ø%)Ø@Jñ
à@ð
ð !ð	
ð
 7ð
ð ð
ð #ð
ð  >ð
ð 
.õ
ô,@#ðD _c÷ *ð$ %)Ø%)Ø!%Ø,0ñ%à#ð%ð ð%ð
 "ð%ð #ð%ð ð%ð *ð%ð 
õ%ô>
ð .2È÷ 
pð  15ñ	wà-ðwð .ð	wð
 
Gõwð4 15ñ	^à!ð^ð .ð	^ð
 
%õ^ð*!à>ð!ð 
!ô!ôHð&C%Ø2ðC%ØAZðC%à	'ôC%÷L&
ñ &
r�   rõ  c                ó´  ^• Sn[        5       mS
U4S jjnUR                  5        H  nU H  nU" U5        M     M     U R                  5        H?  n[        U[        5      (       d  M  UR                   H  nU" UR
                  5        M     MA     UR                  [        R                  / 5      nU(       d  [        SU-   5      e[        R                  T;  a  [        SU-   5      e/ n	U R                  5        H‡  u  p¦[        U[        5      (       a  M  X¡;   =(       a    [        X   5      S:„  n[        U[        5      (       a!  U=(       d    [        UR                  5      S:„  nU(       a  Mv  U	R                  U
5        M‰     U	(       a  [        SU	 S3U-   5      e[        R                  1n[        R                  /nU(       GaZ  UR                  5       nUR                  U/ 5       Hu  nUR                   Hb  n[        U[        5      (       d  M  UR                   U;  d  M,  UR#                  UR                   5        UR                  UR                   5        Md     Mw     U R                  U5      n[        U[        5      (       a�  UR                   H  nUR
                  R                   Hb  n[        U[        5      (       d  M  UR                   U;  d  M,  UR#                  UR                   5        UR                  UR                   5        Md     M�     U(       a  GMZ  U  V
s/ s H  oªU;  d  M
  U
PM     nn
U(       a  [        SU S3U-   5      eg	s  sn
f )a£  Validate the graph structure for common issues.

This function raises an error if any of the following criteria are not met:
1. There are edges from the start node
2. There are edges to the end node
3. No non-End node is a dead end (no outgoing edges)
4. The end node is reachable from the start node
5. All nodes are reachable from the start node

Note 1: Under some circumstances it may be reasonable to build a graph that violates one or more of
the above conditions. We may eventually add support for more granular control over validation,
but today, if you want to build a graph that violates any of these assumptions you need to pass
`validate_graph_structure=False` to the call to `GraphBuilder.build`.

Note 2: Some of the earlier items in the above list are redundant with the later items.
I've included the earlier items in the list as a reminder to ourselves if/when we add more granular validation
because you might want to check the earlier items but not the later items, as described in Note 1.

Args:
    nodes: The nodes in the graph
    edges_by_source: The edges by source node

Raises:
    GraphBuildingError: If any of the aforementioned structural issues are found.
z… If this is intentional, you can suppress this error by passing `validate_graph_structure=False` to the call to `GraphBuilder.build`.c                ó�   >• U R                    H5  n[        U[        5      (       d  M  TR                  UR                  5        M7     g ry   )rr  rÈ   rR   rè  rÉ  )r«  rÌ  Úall_destinationss     €r~   Ú_collect_destinations_from_pathÚB_validate_graph_structure.<locals>._collect_destinations_from_pathú  s3   ø€ Ø—J”JˆDÜ˜$Ô 1×2Ó2Ø ×$Ñ$ T×%8Ñ%8Ö9ò r�   z+The graph has no edges from the start node.z'The graph has no edges to the end node.r   z,The following nodes have no outgoing edges: r¥  z;The following nodes are not reachable from the start node: N)r«  rW   r…   rM  )rs  r¸   rÈ   r5   r¦  r«  r²   rJ   r  r9   rH   rr  r¼  rÃ  rn  rR   rÉ  rè  )r©   r«   Úhow_to_suppressr   r:  r«  r›  r­  Ústart_edgesÚdead_end_nodesrô   Ú	has_edgesÚ	reachableÚto_visitÚ
current_idrÌ  Úcurrent_nodeÚunreachable_nodesrŸ  s                     @r~   r‘  r‘  Ø  sË  ø€ ð: ^€Oô %(£EÐ÷:ð
 !×'Ñ'Ö)ˆÛˆDÙ+¨DÖ1ó ñ *ð
 —‘–ˆÜ�dœH×%Ó%ØŸ-œ-�Ù/°·±Ö<ó (ñ ð "×%Ñ%¤i§l¡l°BÓ7€KÞÜ"Ð#PÐSbÑ#bÓcÐcô ‡z�zÐ)Ó)Ü"Ð#LÈÑ#^Ó_Ð_ð $&€NØŸ™ž‰ˆä�dœG×$Ñ$Ùð Ñ.×T´3°Ñ7OÓ3PÐSTÑ3Tˆ	ô �dœH×%Ñ%Ø!×;¤S¨¯©Ó%7¸!Ñ%;ˆIçˆyØ×!Ñ! 'Ö*ñ 'ö Ü"Ð%QÐR`ÐQaÐabÐ#cÐfuÑ#uÓvÐvô (Ÿl™l˜^€IÜ—‘ˆ~€Hç
Ø—\‘\“^ˆ
ð $×'Ñ'¨
°BÖ7ˆDØŸ
œ
�Ü˜dÔ$5×6Ó6Ø×*Ñ*°)Õ;Ø!Ÿ™ d×&9Ñ&9Ô:Ø Ÿ™¨×(;Ñ(;Ö<ó	 #ñ 8ð —y‘y Ó,ˆÜ�l¤H×-Ñ-Ø&×/Ô/�Ø"ŸK™K×-Ô-�DÜ! $Ô(9×:Ó:Ø×.Ñ.°iÕ?Ø%ŸM™M¨$×*=Ñ*=Ô>Ø$ŸO™O¨D×,?Ñ,?Ö@ó	 .ñ 0÷ ‰(ñ* 16ÓR² WÈ	Ñ9QŸ±ÐÐRÞÜ"ØIÐJ[ÐI\Ð\]Ð^ÐapÑpó
ð 	
ð ùò Ss   Ì&	MÌ3Mc                óP  ^ • T R                  5       n[        [        5      n/ nSU 4S jjnUR                  5        HX  n[	        U[
        5      (       d  M  UR                   H.  nU" UR                  5      u  p‰X‡l        UR                  U	5        M0     MZ     UR                  5        H   u  p«U H  nUR                  X¬45        M     M"     U(       aI  UR                  5       u  p¬U" U5      u  p‰X:   R                  U5        UR                  U	5        U(       a  MI  U[        U5      4$ )Nc                ó”  >• [        U R                  5       GH%  u  p[        U[        5      (       a|  UR                  T;   d   S5       e[        [        U R                  S U 5      [        UR                  5      /-   5      n[        U R                  US-   S  5      nX2R                  U4/4s  $ [        U[        5      (       d  M®  UR                  T;   d   S5       e[        [        U R                  S U 5      [        UR                  5      /-   5      nX2R                   Vs/ s H  oRR                  U4PM     sn4s  $    U / 4$ s  snf )Nz?This should have been added to the node during GraphBuilder.addrE  )
r»  rr  rÈ   rV   re  rW   rl  rR   rQ   r:  )r«  r½  rÌ  ÚupstreamÚ
downstreamr;  r©   s         €r~   Ú_split_at_first_forkÚ,_flatten_paths.<locals>._split_at_first_forkN  s  ø€ Ü  §¡×,‰GˆAÜ˜$¤	×*Ñ*Ø—|‘| uÓ,ÐoÐ.oÓoÐ,Ü¤ T§Z¡Z°° ^Ó 4Ô8IÈ$Ï,É,Ó8WÐ7XÑ XÓY�Ü! $§*¡*¨Q°©U¨WÐ"5Ó6�
Ø§<¡<°Ð"<Ð!=Ð=Ò=ä˜$¤×0Ó0Ø—|‘| uÓ,ÐoÐ.oÓoÐ,Ü¤ T§Z¡Z°° ^Ó 4Ô8IÈ$Ï,É,Ó8WÐ7XÑ XÓY�Ø¿ZºZÓ!HºZ¸§<¡<°Ó"3¹ZÑ!HÐHÒHñ -ð �Rˆxˆùò "Is   Ä"E)r«  rW   r…   z&tuple[Path, list[tuple[NodeID, Path]]])Úcopyr   rl  r¸   rÈ   r5   r¦  r«  rq  rr  rÃ  rn  Údict)r©   rÒ  Ú	new_nodesÚ	new_edgesÚpaths_to_handler¯  r›  r­  r­  ÚdownstreamsÚ	source_idÚedges_from_sourcer«  s   `            r~   r�  r�  F  s  ø€ ð —
‘
“€IÜ*5´dÓ*;€Ià13€O÷ð × Ñ Ö"ˆÜ�dœH×%Ó%ØŸ-œ-�Ù(<¸V¿[¹[Ó(IÑ%�Ø&”Ø×&Ñ& {Ö3ó (ñ #ð ).¯©®Ñ$ˆ	Û%ˆDØ×"Ñ" IÐ#4Ö5ó &ñ )6ö Ø)×-Ñ-Ó/‰ˆ	Ù 4°TÓ :ÑˆØÑ×#Ñ# HÔ-Ø×Ñ˜{Ô+÷	 ˆ/ð ”d˜9“oÐ%Ð%r�   c           	     óö  • U R                  5       n0 n/ nUR                  5        HÏ  u  pVUR                  U5        X   n[        U[        5      (       a  UR
                  (       d  XcU'   MF  [        U5      S:X  a  XcU'   M[  [        [        [        4   " [        [        UR                   S35      5      SSS9nX‚UR                  '   [        [        UR                  5      /S9/X5'   XcUR                  '   MÑ     X#4$ )an  Normalize the graph structure so only broadcast forks have multiple outgoing edges.

This function ensures that any node with multiple outgoing edges is converted
to use an explicit broadcast fork, simplifying the graph execution model.

Args:
    nodes: The nodes in the graph
    edges: The edges by source node

Returns:
    A tuple of normalized nodes and edges
rE  Ú_broadcast_forkFNr7  r8  )r±  rr  rq  rÈ   rI   rÛ  r¼  r   r:   r>   r  rW   rR   )	r©   rÒ  r³  r´  rµ  r·  r¸  r›  Únew_forks	            r~   r�  r�  p  sç   € ð —
‘
“€IØ*,€Ià"$€Oà(-¯©®Ñ$ˆ	Ø×ÑÐ0Ô1àÑˆÜ�dœD×!Ñ!¨$¯+¯+Ø#4�iÑ ÙÜÐ Ó! QÓ&Ø#4�iÑ ÙÜœœS˜’>¤V¬F°d·g±g°Y¸oÐ3NÓ,OÓ%PÐY^ÐswÑxˆØ!)�(—+‘+ÑÜ $Ô,=¸h¿k¹kÓ,JÐ+KÑ LÐMˆ	ÑØ!2�(—+‘+Óñ )6ð ÐÐr�   c                óp  ^• [        U 5      n[        R                  1n[        [        5      m[        U5      nU H¬  nUnU R                  U5      n[        U[        5      (       a  UR                  UR                  5        SU4S jjn[        U[        5      (       a(  UR                   H  n	U" U	R                  U5        M     M‹  UR                  U/ 5       H  n
U" X¥5        M     M®     [        UUUTS9nU R                  5        Vs/ s H  n[        U[        5      (       d  M  UPM     nn0 nU H|  nUR                  UR                  UR                   UR"                  S:H  S9nUc6  [%        X5      R'                  5       n[)        SU SUR                  < S35      eXýUR                  '   M~     U$ s  snf )	aÕ  Find the dominating fork for each join node in the graph.

This function analyzes the graph structure to find the parent fork that
dominates each join node, which is necessary for proper synchronization
during graph execution.

Args:
    graph_nodes: All nodes in the graph
    graph_edges_by_source: Edges organized by source node

Returns:
    A mapping from join IDs to their parent fork information

Raises:
    ValueError: If any join node lacks a dominating fork
c                ó–   >• U R                    H8  n[        U[        5      (       d  M  TU   R                  UR                  5          g   g)z‹Process a path and collect edges and fork information.

Args:
    path: The path to process
    last_source_id: The current source node ID
N)rr  rÈ   rR   rÃ  rÉ  )r«  Úlast_source_idrÌ  rÒ  s      €r~   rª  Ú/_collect_dominating_forks.<locals>._handle_pathµ  s?   ø€ ð Ÿ
œ
�ô ˜dÔ$5×6Ó6Ø˜.Ñ)×0Ñ0°×1DÑ1DÔEáò #r�   )r©   Ú	start_idsÚfork_idsrÒ  Úclosest)ry  Úprefer_closestaÈ  A node in the graph is missing a dominating fork.

For every Join J in the graph, there must be a Fork F between the StartNode and J satisfying:
* Every path from the StartNode to J passes through F
* There are no cycles in the graph including J that don't pass through F.
In this case, F is called a "dominating fork" for J.

This is used to determine when all tasks upstream of this Join are complete and we can proceed with execution.

Mermaid diagram:
z

Join z4 in this graph has no dominating fork in this graph.)r«  rW   r¾  r>   )rs  rJ   r  r   rl  r²   rÈ   rI   rè  r5   r¦  r«  rP   r¸   rC   Úfind_parent_forkry  r*  rß   rà   r8   )Úgraph_nodesÚgraph_edges_by_sourcer©   rÀ  rÁ  r·  Úworking_source_idr›  rª  r­  r«  ÚfinderÚjoinsÚdominating_forksrµ  Údominating_forkÚrendered_mermaid_graphrÒ  s                    @r~   r’  r’  –  sª  ø€ ô& �Ó€EÜ'Ÿl™l˜^€IÜ(3´DÓ(9€Eä 	›N€HÛˆ	Ø%ÐØ�‰˜yÓ)ˆä�dœD×!Ñ!Ø�L‰L˜Ÿ™Ô!÷	ô �dœH×%Ñ%ØŸ-œ-�Ù˜VŸ[™[Ð*;Ö<ó (ð .×1Ñ1°)¸RÖ@�Ù˜TÖ-ó Añ5 ô: ØØØØñ	€Fð *×0Ñ0Ô2ÓMÒ2�d´jÀÄt×6L�TÑ2€EÐMØ9;ÐÛˆØ ×1Ñ1Ø�G‰G D×$7Ñ$7È×HbÑHbÐfoÑHoð 2ð 
ˆð Ñ"Ü%8¸Ó%\×%cÑ%cÓ%eÐ"Ü$ð 
*ð Ð ð à
‡g�g�[ÐDð&Hó Ið Ið %4˜Ÿ™Ó!ñ' ð* Ðùò/ Ns   ÄF3Ä%F3c                ó  • 0 nUR                  5        Hp  u  p4[        [           " 5       nUR                   HE  nU R	                  U5      n[        U[        5      (       d  M+  UR                  [        U5      5        MG     XRU'   Mr     U$ )a;  Compute which joins have other joins as intermediate nodes.

A join J1 is an intermediate node of join J2 if J1 appears in J2's intermediate_nodes
(as computed relative to J2's parent fork).

This information is used to determine:
1. Which joins are "final" (have no other joins in their intermediate_nodes)
2. When selecting which reducer to proceed with when there are no active tasks

Args:
    nodes: All nodes in the graph
    parent_forks: Parent fork information for each join

Returns:
    A mapping from each join to the set of joins that are intermediate to it
)rr  rs  r=   rã  r²   rÈ   rC   rè  )r©   r­   r¯   r˜   rå  r¹   Úintermediate_node_idÚintermediate_nodes           r~   r“  r“  ì  s‚   € ð& :<Ðà ,× 2Ñ 2Ö 4ÑˆÜ ¤š[›]ÐØ$/×$BÔ$BÐ à %§	¡	Ð*>Ó ?ÐÜÐ+¬T×2Ó2à"×&Ñ&¤vÐ.BÓ'CÖDñ %Cð ,> Ó(ñ !5ð #Ð"r�   c                ó\  • [        U 5      nU R                  5        VVs0 s H   u  p4UR                  X35      [        XB5      _M"     nnnUR                  5        VVVs0 s H1  u  pgUR                  Xf5      U Vs/ s H  n[	        X‚5      PM     sn_M3     n	nnnXY4$ s  snnf s  snf s  snnnf ry   )Ú$_build_placeholder_node_id_remappingrr  r²   Ú_update_node_with_id_remappingÚ_update_path_with_id_remapping)
r©   r«   Únode_id_remappingr¡   r›  Úreplaced_nodesrS  r:  r;  Úreplaced_edges_by_sources
             r~   rŽ  rŽ    s¾   € Ü<¸UÓCÐð  Ÿ+™+œ-ôâ'‰JˆDð 	×Ñ˜dÓ)Ô+IÈ$Ó+bÒbÙ'ð ñ ð -×2Ñ2Ô4õ â4‰MˆFð 	×Ñ˜fÓ-ÑnsÓ/tÒnsÐijÔ0NÈqÖ0dÑnsÑ/tÒtÙ4ð ò  ð Ð3Ð3ùóùò
 0uùô s   Ÿ'BÁB'Á9B"ÂB'Â"B'c                óÊ   • [         [           " 5       n0 nU R                  5        H:  n[        U5      nXC:X  a  M  X   S-   =X'   n[	        US:”  a  U SU 3OU5      X#'   M<     U$ )aW  The determinism of the generated remapping here is dependent on the determinism of the ordering of the `nodes` dict.

Note: If we want to generate more interesting names, we could try to make use of information about the edges
into/out of the relevant nodes. I'm not sure if there's a good use case for that though so I didn't bother for now.
rE  r‡  )r   rï   rÁ  rB   r>   )r©   ÚcounterÚ	remappingrô   Úreplaced_node_idÚcounts         r~   rÑ  rÑ    sx   € ô ”cŠl‹n€GØ&(€IØ—:‘:–<ˆÜ1°'Ó:ÐØÓ&ÙØ,3Ñ,EÈÑ,IÐIˆÑ! EÜ#ÀUÈQÃYÐ'7Ð&8¸¸%¸Ñ$AÐTdÓeˆ	Óñ  ð Ðr�   c           
     ó>  • [        U [        5      (       a-  UR                  U R                  U R                  5      U l        U $ [        U [        5      (       a6  [        UR                  U R                  U R                  5      5      U l        U $ [        U [        5      (       aw  [        UR                  U R                  U R                  5      5      U l        U R                  b4  [        UR                  U R                  U R                  5      5      U l        U $ [        U [        5      (       ai  UR                  U R                  U R                  5      U l        U R                   Vs/ s H!  n[        U[        UR                  U5      S9PM#     snU l
        U $ s  snf )N)r«  )rÈ   r[   r²   r  rC   r=   rI   r:   rÜ  r5   r¦  r   rÓ  r«  )r›  rÔ  r­  s      r~   rÒ  rÒ  ,  sH  € ô
 �$œ×ÑØ#×'Ñ'¨¯©°·±Ó9ˆŒð €Kô 
�Dœ$×	Ñ	ÜÐ*×.Ñ.¨t¯w©w¸¿¹Ó@ÓAˆŒð €Kô 
�Dœ$×	Ñ	ÜÐ*×.Ñ.¨t¯w©w¸¿¹Ó@ÓAˆŒØ×"Ñ"Ñ.Ü&,Ð->×-BÑ-BÀ4×CZÑCZÐ\`×\sÑ\sÓ-tÓ&uˆDÔ#ð €Kô 
�Dœ(×	#Ñ	#Ø#×'Ñ'¨¯©°·±Ó9ˆŒð Ÿ-š-ó
â'�ô �FÔ!?ÀÇÁÐM^Ó!_Ô`Ù'ñ
ˆŒð €Kùò	
s   Å((Fc                óž  • U R                    GH6  n[        U[        5      (       ad  UR                  nUb  [	        UR                  X35      5      Ul        [        UR                  UR                  UR                  5      5      Ul        M}  [        U[        5      (       aa  [        UR                  UR                  UR                  5      5      Ul        UR                   Vs/ s H  n[        XA5      PM     snUl	        Mó  [        U[        5      (       d  GM  UR                  UR                  UR                  5      Ul        GM9     U $ s  snf ry   )rr  rÈ   rV   rÜ  r=   r²   r:   re  rQ   r:  rÓ  rR   rÉ  )r«  rÔ  rÌ  rÜ  r;  s        r~   rÓ  rÓ  B  sý   € ð —
•
ˆÜ�dœI×&Ñ&Ø!%×!8Ñ!8ÐØ!Ñ-Ü*0Ð1B×1FÑ1FÐGYÓ1nÓ*o�Ô'Ü!Ð"3×"7Ñ"7¸¿¹ÀdÇlÁlÓ"SÓTˆDŽLÜ˜œo×.Ñ.Ü!Ð"3×"7Ñ"7¸¿¹ÀdÇlÁlÓ"SÓTˆDŒLØX\×XbÒXbÓcÒXbÐSTÔ8¸ÖNÑXbÑcˆDŽJÜ˜Ô/×0Ô0Ø"3×"7Ñ"7¸×8KÑ8KÈT×M`ÑM`Ó"aˆD×ñ ð €Kùò ds   Ã!E
zfill:#fdff32)ÚTBÚLRÚRLÚBT)Ú	broadcastr_  rµ  ÚstartÚendr´  r¬  c                  óB   • \ rS rSr% SrS\S'   S\S'   S\S'   S\S	'   S
rg)ÚMermaidNodeie  zA mermaid node.rï   r  ÚNodeKindÚkindr    r  rh  rŽ   Nr”   rŽ   r�   r~   ræ  ræ  e  s   ‡ áàƒGØ
ƒNØÓØ
Ör�   ræ  c                  ó8   • \ rS rSr% SrS\S'   S\S'   S\S'   Srg	)
ÚMermaidEdgeio  zA mermaid edge.rï   Ústart_idÚend_idr    r  rŽ   Nr”   rŽ   r�   r~   rê  rê  o  s   ‡ áàƒMØƒKØÖr�   rê  ÚMermaidGraphc           	     óò  ^• / n[        [        5      mSU4S jjnU R                  5        Hë  u  pESnSn[        U[        5      (       a  SnO®[        U[
        5      (       a  SnO–[        U[        5      (       a  SnUR                  nOr[        U[        5      (       a  SnOZ[        U[        5      (       a  UR                  (       a  SOSnO/[        U[        5      (       a  S	nUR                  nO[        U5        [        UWXgS
9n	UR                  U	5        Mí     UR                  5        H  u  p«U H  nU" XÊ5        M     M     U R!                  5        HJ  n[        U[        5      (       d  M  UR"                   H   nU" UR$                  UR&                  5        M"     ML     [)        U Vs/ s H  nTR+                  UR&                  / 5      PM!     sn[        [,           " 5       5      n[/        X.5      $ s  snf )zBuild a mermaid graph.c                ó:  >• S nU R                    Hˆ  n[        U[        [        -  5      (       a   S5       e[        U[        5      (       a  UR
                  nMI  [        U[        5      (       d  M`  TU   R                  [        XR                  U5      5        MŠ     g )Nz-These should be removed during Graph building)
rr  rÈ   rV   rQ   rU   r  rR   rÃ  rê  rÉ  )r«  r¾  Úworking_labelrÌ  r«   s       €r~   Ú_collect_edgesÚ+build_mermaid_graph.<locals>._collect_edges  sy   ø€ Ø$(ˆØ—J”JˆDÜ! $¬	´OÑ(C×DÑDÐuÐFuÓuÐDÜ˜$¤×,Ñ,Ø $§
¡
’Ü˜DÔ"3×4Ó4Ø Ñ/×6Ñ6´{À>×SfÑSfÐhuÓ7vÖwò r�   Nrã  rä  r´  rµ  r_  râ  r¬  )r  rè  r  rh  )r«  rW   r¾  r>   r…   rM  )r   rl  rr  rÈ   rJ   rH   r[   r  rC   rI   rÛ  r5   rh  r*   ræ  rÃ  r¸   r¦  r«  r  Úsumr²   rê  rí  )rÅ  rÆ  r©   rñ  rô   r›  r  rh  rè  rO  ÚkÚvr«  r­  rÒ  r«   s                  @r~   rß   rß   x  sš  ø€ ð  "€EÜ4?ÄÓ4E€O÷xð %×*Ñ*Ö,‰ˆà ˆØˆÜ�dœI×&Ñ&Ø‰DÜ˜œg×&Ñ&Ø‰DÜ˜œd×#Ñ#ØˆDØ—J‘J‰EÜ˜œd×#Ñ#Ø‰DÜ˜œd×#Ñ#Ø ŸKŸK‘5¨[‰DÜ˜œh×'Ñ'ØˆDØ—9‘9‰Dä˜Ôä! W°4¸uÑPˆØ�‰�[Ö!ñ- -ð0 &×+Ñ+Ö-‰ˆÛˆDÙ˜4Ö#ó ñ .ð ×"Ñ"Ö$ˆÜ�dœH×%Ó%ØŸ-œ-�Ù˜vŸ{™{¨D¯G©GÖ4ó (ñ %ô  #ÑQVÓ#WÒQVÈ O×$7Ñ$7¸¿¹ÀÖ$DÑQVÑ#WÔY]Ô^iÒYjÓYlÓm€EÜ˜Ó%Ð%ùò $Xs   Æ+&G4c                  óh   • \ rS rSr% SrS\S'   S\S'   SrS\S	'   SrS
\S'      S     SS jjrSr	g)rí  i®  zA mermaid graph.úlist[MermaidNode]r©   úlist[MermaidEdge]rÒ  Nr    rÜ   rî   rÝ   c                óü  • / nU(       a  SSU 3S/nUR                  S5        Ub  UR                  SU 35        [        U R                  U R                  5      u  pVU GHU  n/ nUR                  S:X  d  UR                  S:X  a  GOUR                  S:X  aD  SUR
                   3n	UR                  (       a  U	S	UR                   3-  n	UR                  U	5        OÈUR                  S
:X  a  SUR
                   S3/nO¦UR                  S:X  d  UR                  S:X  a  SUR
                   S3/nOtUR                  S:X  aO  SUR
                   S3/nUR                  (       a,  UR                  SUR
                   SUR                   S35        O[        UR                  5        UR                  U5        GMX     UR                  S5        U Hž  n
U
R                  [        R
                  :X  a  SOU
R                  nU
R                  [        R
                  :X  a  SOU
R                  nSU SU 3nU
R                  (       a  U(       a  US	U
R                   3-  nUR                  U5        M      SR                  U5      $ )Nz---ztitle: zstateDiagram-v2z  direction rã  rä  r´  z  z: rµ  z  state z	 <<join>>râ  r_  z	 <<fork>>r¬  z <<choice>>z  note right of z
    z
  end noteÚ z[*]z --> rä   )rÃ  Ú_topological_sortr©   rÒ  rè  r  r  rh  r*   rq  rë  rJ   rì  rH   rµ  )r|   rÝ   rÜ   Úedge_labelsÚlinesr©   rÒ  r›  Ú
node_linesÚlinerN  Úrender_start_idÚrender_end_idÚ	edge_lines                 r~   rà   ÚMermaidGraph.render¸  s  € ð ˆÞØ˜g e WÐ-¨uÐ5ˆEØ�‰Ð&Ô'ØÑ Ø�L‰L˜<¨	 {Ð3Ô4ä(¨¯©°T·Z±ZÓ@‰ˆÜˆDà$&ˆJØ�y‰y˜GÓ# t§y¡y°EÓ'9ÙØ—‘˜fÓ$Ø˜DŸG™G˜9�~�Ø—:—:Ø˜b §¡ Ð-Ñ-�DØ×!Ñ! $Õ'Ø—‘˜fÓ$Ø (¨¯©¨	°Ð;Ð<‘
Ø—‘˜kÓ)¨T¯Y©Y¸%Ó-?Ø (¨¯©¨	°Ð;Ð<‘
Ø—‘˜jÓ(Ø (¨¯©¨	°Ð=Ð>�
Ø—9—9Ø×%Ñ%Ð(8¸¿¹¸	ÀÈÏ	É	À{ÐR^Ð&_Ô`øä˜TŸY™YÔ'Ø�L‰L˜×$ñ) ð, 	�‰�RÔãˆDà'+§}¡}¼	¿¹Ó'D™eÈ$Ï-É-ˆOØ%)§[¡[´G·J±JÓ%>™EÀDÇKÁKˆMØ˜_Ð-¨U°=°/ÐBˆIØ�z�zžkØ˜r $§*¡* Ð.Ñ.�	Ø�L‰L˜Ö#ñ ð �y‰y˜ÓÐr�   rŽ   )NNT)rÝ   rî   rÜ   r    rü  r¦   )
r†   r‡   rˆ   r‰   rŠ   r‹   rÜ   rÝ   rà   r�   rŽ   r�   r~   rí  rí  ®  sW   ‡ áàÓØÓà€Eˆ:ÓØ.2€IÐ+Ó2ð 37Ø Ø ð	/ à/ð/ ð ð/ ð ÷	/ ð / r�   c                ó¶  ^
• [        [        5      nU H*  nX#R                     R                  UR                  5        M,     0 m
[
        R                  S4/nST
[
        R                  '   U(       aL  UR                  S5      u  pVX%    H(  nUT
;  d  M  US-   T
U'   UR                  XvS-   45        M*     U(       a  ML  [        U U
4S jS9n[        UU
4S jS9n	X‰4$ )zÏSort nodes and edges in a logical topological order.

Uses BFS from the start node to assign depths, then sorts:
- Nodes by their distance from start
- Edges by the distance of their source and target nodes
r   rE  c                óf   >• TR                  U R                  [        S5      5      U R                  4$ ©NÚinf)r²   r  Úfloat)ÚnÚdepthss    €r~   r3  Ú#_topological_sort.<locals>.<lambda>	  s$   ø€ °·
±
¸1¿4¹4ÄÀuÃÓ0NÐPQ×PTÑPTÑ/Ur�   )Úkeyc                óÄ   >• TR                  U R                  [        S5      5      TR                  U R                  [        S5      5      U R                  U R                  4$ r  )r²   rë  r  rì  )r±  r
  s    €r~   r3  r  	  sB   ø€ Ø�J‰J�q—z‘z¤5¨£<Ó0Ø�J‰J�q—x‘x¤ u£Ó.Ø�J‰JØ�H‰Hñ	
r�   )	r   rl  rë  rÃ  rì  rJ   r  rn  Úsorted)r©   rÒ  Ú	adjacencyrN  Úqueuerô   rÄ   rG  Úsorted_nodesÚsorted_edgesr
  s             @r~   rû  rû  ê  sÔ   ø€ ô '2´$Ó&7€IÛˆØ—-‘-Ñ ×'Ñ'¨¯©Ö4ñ ð  €FÜ%.§\¡\°1Ð$5Ð#6€EØ€FŒ9�<‰<Ñæ
ØŸ™ 1›‰ˆØ Ô)ˆGØ˜fÕ$Ø"'¨!¡)��w‘Ø—‘˜g¨q¡yÐ1Ö2ñ *÷ ˆ%ô ˜%Ô%UÑV€Lô Øô
ñ€Lð Ð%Ð%r�   )r¾  r   r…   zTypeGuard[Iterable[Any]])r¾  r   r…   zTypeGuard[AsyncIterable[Any]])r©   r¨   r«   rª   r…   rM  )r©   r¨   rÒ  rª   r…   z6tuple[dict[NodeID, AnyNode], dict[NodeID, list[Path]]])rÅ  r¨   rÆ  rª   r…   r¬   )r©   r¨   r­   r¬   r…   r®   )r©   r¨   r«   rª   )r©   r¨   r…   údict[NodeID, NodeID])r›  rL   rÔ  r  r…   rL   )r«  rW   rÔ  r  r…   rW   )rÅ  r¨   rÆ  rª   r…   rí  )r©   r÷  rÒ  rø  r…   z+tuple[list[MermaidNode], list[MermaidEdge]])¨rŠ   Ú
__future__r   Ú_annotationsrJ  ÚsysÚcollectionsr   r   Úcollections.abcr   r   r   r	   r
   r   Ú
contextlibr   r   r   r   r   Údataclassesr   r   r   Útypesr   Útypingr   r   r   r   r   r   r   r   r   r   Úanyior   r    r!   r"   r#   Ú	anyio.abcr$   Úanyio.streams.memoryr%   r&   Útyping_extensionsr'   r(   r)   r*   Úpydantic_graphr+   r,   Úpydantic_graph._utilsr-   r.   r/   r0   r1   r2   Úpydantic_graph.basenoder3   r4   Úpydantic_graph.decisionr5   r6   r7   Úpydantic_graph.exceptionsr8   r9   Úpydantic_graph.id_typesr:   r;   r<   r=   r>   r?   r@   rA   rB   Úpydantic_graph.joinrC   rD   rE   rF   rG   Úpydantic_graph.noderH   rI   rJ   Úpydantic_graph.node_typesrK   rL   rM   rN   Úpydantic_graph.parent_forksrO   rP   Úpydantic_graph.pathsrQ   rR   rS   rT   rU   rV   rW   rX   rY   Úpydantic_graph.steprZ   r[   r\   r]   r^   r_   Úpydantic_graph.utilr`   ra   rb   Úversion_infoÚexceptiongroupre   rf   rh   ri   rj   rk   rl   rn   ro   rp   rq   ru   r�   r–   rž   ró   rö   rÖ   rO  rR  r
  rÞ  rß  r  rõ  r‘  r�  r�  r’  r“  rŽ  rÑ  rÒ  rÓ  ÚDEFAULT_HIGHLIGHT_CSSÚStateDiagramDirectionrç  ræ  rê  rß   rí  rû  rŽ   r�   r~   Ú<module>r2     sH  ðñõ 3ã Û 
ß ,ß f× fß mÕ mß 1Ñ 1Ý ÷÷ ÷ ÷ xÕ wÝ ß Rß IÓ Iç -ß k× kß 1ß SÑ Sß N÷
÷ 
õ 
÷ [Õ Zß 8Ñ 8ß ^Ó ^ß D÷
÷ 
õ 
÷ d× cß _Ñ _à×Ñ�gÓÞGà+Ðñ
 
�¨$Ñ	/€Ø $á�¨Ñ-€Ø +á	�¨$Ñ	/€Ø %á
�)¨DÑ
1€Ø &á
�)¨DÑ
1€Ù�m¨8°C¸¸c°MÑ+BÐSWÑX€Ù˜¸Ñ=€Ù�m°DÑ9€Ù�~°dÑ;€ÙˆC Ñ%€ñ �Ñô�˜Ñ ó ó ðð, ÷	,ð 	,ó ð	,ð ÷Lð Ló ðLñ" �ÑôdˆG�F˜E 6¨7Ð2Ñ3ó dó ðdðN ÷ð ó ðð( ô]Ð ó ]ó ð]ô&Lˆw�v˜u gÐ-Ñ.ô Lð^ ÷ð ó ðð
 ÷'ð 'ó ð'ð ôF-�W˜V U¨GÐ3Ñ4ó F-ó ðF-ôR#ô(ð ñó ðñ( �Ñôb	
�7˜6 5¨+°|ÐCÑDó b	
ó ðb	
ðJk
Ø ðk
à-ðk
ð 
ôk
ð\'&Ø ð'&Ø)Að'&à;ô'&ðT# Ø ð# Ø)Að# à;ô# ðLSØ&ðSØ?WðSà%ôSðl#Ø ð#Ø0Pð#àô#ôD
4ôô"ô,ð& 'Ð Ø 4ð  Ð 6Ñ7Ð ðð ÐQÑR€ð ÷ð ó ðð ÷ð ó ðð3&Ø&ð3&Ø?Wð3&àô3&ðl ÷8 ð 8 ó ð8 ðv*&Øð*&Ø%6ð*&à0õ*&r�   