From 7457f9103fb624b5cc58322a35731433283e9482 Mon Sep 17 00:00:00 2001 From: Jason Robert Date: Thu, 21 May 2026 15:04:08 -0400 Subject: [PATCH 1/5] feat(engine): add `type: terminate` step (#219) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a terminal step type that ends the workflow with an explicit `status` (`success` | `failed`) and a Jinja2-rendered `reason`, distinguishable from the default `$end` path in the CLI exit code, JSONL event log, and web dashboard. Behaviour - `status: success`: workflow returns normally, CLI exits 0, dashboard ✅, `workflow_completed { termination_reason, terminated_by, is_explicit: true }`. - `status: failed`: raises `WorkflowTerminated`, CLI exits 1 (and still prints the rendered output JSON to stdout), dashboard ❌, dedicated engine handler emits `workflow_failed { error_type: 'WorkflowTerminated', is_explicit: true, output, termination_reason, terminated_by }` and intentionally does NOT save an on-failure checkpoint (explicit termination is not resumable). - Optional `output_template: dict[str, str]` replaces the workflow-level `output:` for that termination path (same shape as workflow output). - Sub-workflow boundary: failed terminate inside a child sub-workflow is downgraded to `ExecutionError` so the parent treats it as a normal sub-workflow failure (parent's own `workflow_failed` does not inherit `is_explicit: true`). Schema / validator - Adds `terminate` to `AgentDef.type` Literal plus `status`, `reason`, and `output_template` fields, all forbidden on every other step type. - Rejects `routes`, `tools`, `output`, `prompt`, `model`, etc. on terminate steps so authoring mistakes fail fast. - Forbids terminate inside parallel-group members and for_each inline agents (those contexts wrap/swallow exceptions and would mask the explicit signal). - Treats terminate as a sink (peer of `$end`) in path enumeration; output coverage analysis skips terminate paths that supply their own `output_template`. - Validates Jinja2 templates inside `reason` and `output_template` values. Tests / docs - 8 engine tests, 2 sub-workflow tests, 20 schema tests, 9 validator tests, 3 CLI integration tests, 4 exception tests; full suite (2824 tests) passes. - `examples/terminate.yaml` demonstrates success + failure paths. - `AGENTS.md` documents the new step type. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- AGENTS.md | 1 + examples/terminate.yaml | 122 +++++++++++ src/conductor/cli/app.py | 15 ++ src/conductor/cli/run.py | 9 + src/conductor/config/schema.py | 156 ++++++++++++- src/conductor/config/validator.py | 86 +++++++- src/conductor/engine/workflow.py | 188 +++++++++++++++- src/conductor/exceptions.py | 49 +++++ tests/test_cli/test_run.py | 125 +++++++++++ tests/test_config/test_schema.py | 155 +++++++++++++ tests/test_config/test_validator.py | 251 +++++++++++++++++++++ tests/test_engine/test_subworkflow.py | 167 ++++++++++++++ tests/test_engine/test_workflow.py | 303 ++++++++++++++++++++++++++ tests/test_exceptions.py | 57 +++++ 14 files changed, 1670 insertions(+), 14 deletions(-) create mode 100644 examples/terminate.yaml diff --git a/AGENTS.md b/AGENTS.md index 4f1005d9..945a07a6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -134,6 +134,7 @@ make validate-examples # validate all examples - **Tool resolution**: `null` = all workflow tools, `[]` = none, `[list]` = subset - **Set step typing**: `output_type` defaults to `auto` (safe YAML parse with `_to_json_safe` normalisation — `datetime`/`date`/`time` → ISO 8601, non-string dict keys and other non-JSON-safe values raise `ExecutionError`). Explicit `string`/`number`/`integer`/`boolean`/`list`/`dict` only valid on single `value:`. `WorkflowContext.store` accepts any JSON-safe value (scalars/lists from `set` steps in addition to the dicts produced by LLM / script / gate / parallel-group outputs); `_add_agent_input` returns the scalar verbatim for `step.output` and raises a clear `KeyError` for `step.output.field` shorthand on non-dict outputs. - **Reasoning effort**: `runtime.default_reasoning_effort` sets a workflow-wide default; per-agent `reasoning.effort` overrides it. Allowed values: `low`, `medium`, `high`, `xhigh`. Each provider translates the unified value to its native API (Copilot: `reasoning_effort` on the session, validated against the model's `supported_reasoning_efforts`; Claude: extended thinking with budget mapping low=2048, medium=8192, high=16384, xhigh=32768 tokens, with `temperature` coerced to 1.0 and `max_tokens` bumped to fit the budget). See `examples/reasoning-effort.yaml`. +- **Terminate steps** (`type: terminate`): explicit terminal step with `status` (`success` | `failed`), Jinja2 `reason`, and optional `output_template` (a `dict[str, str]` that replaces `workflow.output:` when set). Reaching a terminate step ends the workflow immediately (no routes evaluated after). `success` → CLI exit 0, dashboard ✅, `workflow_completed { termination_reason, terminated_by, is_explicit: true }`. `failed` → CLI exit 1, dashboard ❌, raises `WorkflowTerminated`, emits `workflow_failed { error_type: "WorkflowTerminated", is_explicit: true }`, and **does not** save an on-failure checkpoint. Terminate steps cannot have `routes`, `tools`, `output`, `prompt`, `model`, etc.; cannot be used as parallel-group members or as a for_each inline agent. Inside a sub-workflow, a `status: failed` terminate is downgraded to `ExecutionError` at the parent boundary so the parent sees a normal sub-workflow failure (parent's own `workflow_failed` does NOT inherit `is_explicit: true`). See `examples/terminate.yaml`. ### Debugging `--web-bg` failures diff --git a/examples/terminate.yaml b/examples/terminate.yaml new file mode 100644 index 00000000..ddb5bf95 --- /dev/null +++ b/examples/terminate.yaml @@ -0,0 +1,122 @@ +# Terminate Step Example +# +# This example demonstrates `type: terminate` steps, which end the workflow +# with an explicit status (success/failed) and a structured reason. Reaching +# a terminate step ends the workflow immediately: +# +# - status: success → CLI exit code 0, dashboard ✅, +# emits `workflow_completed` with +# `termination_reason`, `terminated_by`, +# and `is_explicit: true`. +# - status: failed → CLI exit code 1, dashboard ❌, +# emits `workflow_failed` with the same metadata +# plus `error_type: WorkflowTerminated`. +# No checkpoint is saved (explicit termination +# is not resumable). +# +# A terminate step's optional `output_template:` replaces the workflow-level +# `output:` mapping for that termination path. When omitted, the workflow's +# `output:` is rendered as on any normal `$end` path. +# +# Usage: +# conductor run examples/terminate.yaml --input document_state=stale +# conductor run examples/terminate.yaml --input document_state=current +# conductor run examples/terminate.yaml --input document_state=unsafe + +workflow: + name: terminate-demo + description: Demonstrates type=terminate with success and failure paths + version: "1.0.0" + entry_point: precheck + + input: + document_state: + type: string + description: Simulated state of an upstream document. One of `current`, `stale`, or `unsafe`. + default: stale + + runtime: + provider: copilot + + limits: + max_iterations: 10 + +agents: + - name: precheck + type: script + description: Classify the upstream document state and route accordingly + command: bash + args: + - "-c" + - | + state="{{ workflow.input.document_state }}" + case "$state" in + current) + echo '{"action":"noop","reason":"Document already up to date; no edits needed."}' + ;; + stale) + echo '{"action":"refresh","reason":"Document is stale; running refresh pipeline."}' + ;; + *) + echo '{"action":"abort","reason":"Document state \"'"$state"'\" is not safe to process."}' + ;; + esac + output: + action: + type: string + description: One of `noop`, `refresh`, or `abort`. + reason: + type: string + description: Human-readable explanation of the chosen action. + routes: + - when: "action == 'noop'" + to: noop_exit + - when: "action == 'abort'" + to: abort_unsafe + - to: refresh + + # Success termination — workflow completes cleanly with status=success. + # The CLI exits 0 and the dashboard shows ✅. + - name: noop_exit + type: terminate + description: No work needed; document already current + status: success + reason: "{{ precheck.output.reason }}" + output_template: + result: "no-op" + reason: "{{ precheck.output.reason }}" + + # Failure termination — workflow ends with status=failed. The CLI exits 1 + # and the dashboard shows ❌. Downstream tooling (CI, notifications) can + # distinguish this from a generic exception via `is_explicit: true` in the + # `workflow_failed` event. + - name: abort_unsafe + type: terminate + description: Refuse to run downstream steps on unsafe input + status: failed + reason: "{{ precheck.output.reason }}" + output_template: + result: "aborted" + stage: "precheck" + reason: "{{ precheck.output.reason }}" + + # Normal path — runs the "real" pipeline and lets the workflow-level + # `output:` mapping render the final result. + - name: refresh + model: claude-haiku-4.5 + description: Refresh the stale document (simulated) + prompt: | + The upstream document needs to be refreshed. + + Reason: {{ precheck.output.reason }} + + Briefly summarize, in one sentence, what a refresh pipeline would do + for a stale document. Reply with JSON: {"summary": "..."}. + output: + summary: + type: string + routes: + - to: $end + +output: + result: "{{ refresh.output.summary | default('') }}" diff --git a/src/conductor/cli/app.py b/src/conductor/cli/app.py index 93f5bc60..d0be5024 100644 --- a/src/conductor/cli/app.py +++ b/src/conductor/cli/app.py @@ -469,6 +469,15 @@ def run( output_console.print_json(json.dumps(result)) except Exception as e: + from conductor.exceptions import WorkflowTerminated + + if isinstance(e, WorkflowTerminated): + # Explicit `type: terminate` with `status: failed`. Print the + # rendered final output so downstream tooling can read it, surface + # the reason as a user-facing message, then exit non-zero. + output_console.print_json(json.dumps(e.output)) + console.print(f"[red]Workflow terminated[/red] at '{e.terminated_by}': {e.reason}") + raise typer.Exit(code=1) from None print_error(e) raise typer.Exit(code=1) from None @@ -877,6 +886,12 @@ def resume( output_console.print_json(json.dumps(result)) except Exception as e: + from conductor.exceptions import WorkflowTerminated + + if isinstance(e, WorkflowTerminated): + output_console.print_json(json.dumps(e.output)) + console.print(f"[red]Workflow terminated[/red] at '{e.terminated_by}': {e.reason}") + raise typer.Exit(code=1) from None print_error(e) raise typer.Exit(code=1) from None diff --git a/src/conductor/cli/run.py b/src/conductor/cli/run.py index 930938b5..b0e30fba 100644 --- a/src/conductor/cli/run.py +++ b/src/conductor/cli/run.py @@ -24,6 +24,7 @@ from conductor.config.loader import load_config from conductor.engine.workflow import ExecutionPlan, WorkflowEngine +from conductor.exceptions import WorkflowTerminated from conductor.mcp_auth import resolve_mcp_server_auth from conductor.providers.registry import ProviderRegistry @@ -1343,6 +1344,10 @@ async def run_workflow_async( _verbose_console.print("[dim]Press Esc to interrupt and provide guidance[/dim]") result = await _run_with_stop_signal(engine, inputs, dashboard) + except WorkflowTerminated: + # Explicit `type: terminate status: failed` — no resume hint + # because this is an intentional, non-resumable outcome. + raise except BaseException: _print_resume_instructions(engine) raise @@ -1910,6 +1915,10 @@ async def resume_workflow_async( _verbose_console.print("[dim]Press Esc to interrupt and provide guidance[/dim]") result = await _resume_with_stop_signal(engine, cp.current_agent, dashboard) + except WorkflowTerminated: + # Explicit `type: terminate status: failed` — no resume hint + # because this is an intentional, non-resumable outcome. + raise except BaseException: _print_resume_instructions(engine) raise diff --git a/src/conductor/config/schema.py b/src/conductor/config/schema.py index 79e658ca..effc1638 100644 --- a/src/conductor/config/schema.py +++ b/src/conductor/config/schema.py @@ -463,7 +463,9 @@ class AgentDef(BaseModel): description: str | None = None """Human-readable description of agent's purpose.""" - type: Literal["agent", "human_gate", "script", "set", "wait", "workflow"] | None = None + type: ( + Literal["agent", "human_gate", "script", "set", "terminate", "wait", "workflow"] | None + ) = None """Agent type. Defaults to 'agent' if not specified.""" provider: Literal["copilot", "claude"] | None = None @@ -740,6 +742,55 @@ class AgentDef(BaseModel): effort: high """ + status: Literal["success", "failed"] | None = None + """Outcome status for ``type: terminate`` steps. + + ``success`` ends the workflow cleanly (exit code 0, dashboard ✅, + ``workflow_completed`` event with ``is_explicit: true``). ``failed`` + ends the workflow as an explicit error (non-zero exit code, dashboard + ❌, ``workflow_failed`` event with ``is_explicit: true``). Required + for ``type: terminate``; forbidden on all other step types. + + Example YAML:: + + type: terminate + status: failed + reason: "Upstream service returned unprocessable data" + """ + + reason: str | None = None + """Termination reason for ``type: terminate`` steps (Jinja2-rendered). + + Surfaced in the ``workflow_completed`` / ``workflow_failed`` event as + ``termination_reason`` and stored in the step's context entry. Required + for ``type: terminate``; forbidden on all other step types. + + Supports Jinja2 templating against accumulated context. + + Example YAML:: + + reason: "{{ precheck.output.reason }}" + """ + + output_template: dict[str, str] | None = None + """Optional final-output mapping for ``type: terminate`` steps. + + When present, *replaces* the workflow-level ``output:`` mapping for + this termination path. Each value is a Jinja2 expression evaluated + against the accumulated context (including the terminate step's own + ``status`` / ``reason``). When omitted, the workflow-level ``output:`` + mapping is rendered as usual. + + Forbidden on all step types other than ``terminate``. + + Example YAML:: + + output_template: + aborted: "true" + stage: precheck + reason: "{{ precheck.output.reason }}" + """ + @field_validator("timeout") @classmethod def validate_timeout(cls, v: int | None) -> int | None: @@ -765,6 +816,23 @@ def reject_bool_duration(cls, v: Any) -> Any: @model_validator(mode="after") def validate_agent_type(self) -> AgentDef: """Ensure agent has required fields for its type.""" + # Fields exclusive to ``type: terminate`` — reject if set on any + # other type. This is enforced before the per-type branches so the + # error message clearly names the conflict. + # + # NOTE: ``reason`` is intentionally NOT in this list because it is + # shared with ``type: wait`` (which uses it as an optional dashboard + # label, vs. terminate's required Jinja2-rendered message). The wait + # PR's cross-rejection block at the end of this method enforces + # "not allowed on anything except wait OR terminate" for ``reason``. + if self.type != "terminate": + for field_name in ("status", "output_template"): + if getattr(self, field_name) is not None: + raise ValueError( + f"'{self.type or 'agent'}' agents cannot have '{field_name}' " + "(only 'terminate' agents support this field)" + ) + if self.type == "human_gate": if not self.options: raise ValueError("human_gate agents require 'options'") @@ -965,8 +1033,81 @@ def validate_agent_type(self) -> AgentDef: raise ValueError("set agents cannot have 'timeout_seconds'") if self.duration is not None: raise ValueError("set agents cannot have 'duration' (only 'wait' agents do)") - if self.reason is not None: - raise ValueError("set agents cannot have 'reason' (only 'wait' agents do)") + elif self.type == "terminate": + # Required fields + if self.status is None: + raise ValueError( + "terminate agents require 'status' (must be 'success' or 'failed')" + ) + if not self.reason or not self.reason.strip(): + raise ValueError("terminate agents require a non-empty 'reason'") + # Routing and per-step machinery are meaningless on a terminal + # step — the engine ends the workflow as soon as it dispatches. + if self.routes: + raise ValueError( + "terminate agents cannot have 'routes' " + "(reaching a terminate step ends the workflow immediately)" + ) + if self.tools is not None: + raise ValueError("terminate agents cannot have 'tools'") + if self.output is not None: + raise ValueError( + "terminate agents cannot have 'output' " + "(use 'output_template' to override the workflow's final output)" + ) + if self.prompt: + raise ValueError("terminate agents cannot have 'prompt'") + if self.model: + raise ValueError("terminate agents cannot have 'model'") + if self.provider: + raise ValueError("terminate agents cannot have 'provider'") + if self.system_prompt: + raise ValueError("terminate agents cannot have 'system_prompt'") + if self.command: + raise ValueError("terminate agents cannot have 'command'") + if self.args: + raise ValueError("terminate agents cannot have 'args'") + if self.env: + raise ValueError("terminate agents cannot have 'env'") + if self.working_dir: + raise ValueError("terminate agents cannot have 'working_dir'") + if self.timeout is not None: + raise ValueError("terminate agents cannot have 'timeout'") + if self.timeout_seconds is not None: + raise ValueError("terminate agents cannot have 'timeout_seconds'") + if self.max_session_seconds is not None: + raise ValueError("terminate agents cannot have 'max_session_seconds'") + if self.max_agent_iterations is not None: + raise ValueError("terminate agents cannot have 'max_agent_iterations'") + if self.max_depth is not None: + raise ValueError("terminate agents cannot have 'max_depth'") + if self.retry is not None: + raise ValueError("terminate agents cannot have 'retry'") + if self.dialog is not None: + raise ValueError("terminate agents cannot have 'dialog'") + if self.reasoning is not None: + raise ValueError("terminate agents cannot have 'reasoning'") + if self.workflow: + raise ValueError("terminate agents cannot have 'workflow'") + if self.input_mapping is not None: + raise ValueError("terminate agents cannot have 'input_mapping'") + if self.options: + raise ValueError("terminate agents cannot have 'options'") + # Cross-rejection with sibling step types: terminate has its own + # `reason` so we do NOT reject it (the `if self.type not in ...` + # block at the bottom of this method handles the + # other-type-rejection for `reason`). But these are exclusive to + # other step types and must not leak in. + if self.value is not None: + raise ValueError("terminate agents cannot have 'value' (only 'set' agents do)") + if self.values is not None: + raise ValueError("terminate agents cannot have 'values' (only 'set' agents do)") + if self.output_type is not None: + raise ValueError( + "terminate agents cannot have 'output_type' (only 'set' agents do)" + ) + if self.duration is not None: + raise ValueError("terminate agents cannot have 'duration' (only 'wait' agents do)") else: # Regular agent or human_gate — input_mapping is not valid if self.input_mapping is not None: @@ -997,17 +1138,20 @@ def validate_agent_type(self) -> AgentDef: if self.type == "workflow" and self.reasoning is not None: raise ValueError("workflow agents cannot have 'reasoning'") - # Wait-only fields are forbidden on every other type. + # Wait-only fields are forbidden on every other type. ``reason`` is + # shared with ``type: terminate`` (which has its own required-non- + # empty semantics enforced earlier), so it is rejected on every + # non-wait, non-terminate type with a message naming both owners. if self.type != "wait": if self.duration is not None: raise ValueError( f"'{self.type or 'agent'}' agents cannot have 'duration' " "(only wait agents support duration)" ) - if self.reason is not None: + if self.type != "terminate" and self.reason is not None: raise ValueError( f"'{self.type or 'agent'}' agents cannot have 'reason' " - "(only wait agents support reason)" + "(only 'terminate' and 'wait' agents support this field)" ) return self diff --git a/src/conductor/config/validator.py b/src/conductor/config/validator.py index 1f88e625..04b0f7ea 100644 --- a/src/conductor/config/validator.py +++ b/src/conductor/config/validator.py @@ -204,7 +204,7 @@ def validate_workflow_config( parallel_errors = _validate_parallel_groups(config) errors.extend(parallel_errors) - # Validate for_each groups: reject script and wait steps as inline agents + # Validate for_each groups: reject step types that can't be used inline for for_each_group in config.for_each: if for_each_group.agent.type == "script": errors.append( @@ -216,6 +216,12 @@ def validate_workflow_config( f"For-each group '{for_each_group.name}' uses a wait step as its " "inline agent. Wait steps cannot be used in for_each groups." ) + if for_each_group.agent.type == "terminate": + errors.append( + f"For-each group '{for_each_group.name}' uses a terminate step as its " + "inline agent. Terminate steps cannot run inside a for_each iteration; " + "route to a terminate step from the for_each group's routes instead." + ) # Validate sub-workflow references (local paths and registry refs). # Skipped when workflow_path is not provided — relative paths cannot be @@ -512,6 +518,14 @@ def _validate_parallel_groups(config: WorkflowConfig) -> list[str]: "Workflow steps cannot be used in parallel groups." ) + # Validate no terminate steps in parallel groups + if agent.type == "terminate": + errors.append( + f"Agent '{agent_name}' in parallel group '{pg.name}' is a terminate step. " + "Terminate steps cannot run inside a parallel branch; route to a " + "terminate step from the parallel group's routes instead." + ) + # PE-6.2: Validate parallel group route targets for_each_names = {fe.name for fe in config.for_each} all_names = agent_names | parallel_names | for_each_names @@ -569,6 +583,15 @@ def _validate_parallel_groups(config: WorkflowConfig) -> list[str]: return errors +def _terminate_agent_names(config: WorkflowConfig) -> set[str]: + """Names of agents whose ``type`` is ``terminate``. + + Terminate steps end the workflow when reached and behave like ``$end`` for + path-enumeration purposes (no outbound edges, sink in the routing graph). + """ + return {agent.name for agent in config.agents if agent.type == "terminate"} + + def _build_routing_graph(config: WorkflowConfig) -> dict[str, list[tuple[str, bool]]]: """Build adjacency list from workflow config for path analysis. @@ -580,6 +603,10 @@ def _build_routing_graph(config: WorkflowConfig) -> dict[str, list[tuple[str, bo """ graph: dict[str, list[tuple[str, bool]]] = {} for agent in config.agents: + # Terminate steps end the workflow; treat them as sinks with no edges. + if agent.type == "terminate": + graph[agent.name] = [] + continue edges: list[tuple[str, bool]] = [] if agent.routes: for route in agent.routes: @@ -599,13 +626,17 @@ def _enumerate_paths_to_end( start: str, graph: dict[str, list[tuple[str, bool]]], max_depth: int = 50, + terminal_nodes: frozenset[str] = frozenset(), ) -> list[list[str]]: - """Enumerate paths from start to $end via DFS, up to _MAX_ENUMERATED_PATHS. + """Enumerate paths from start to a terminal node via DFS. Args: start: Entry point node name. graph: Adjacency list from _build_routing_graph. max_depth: Maximum path depth (prevents infinite exploration). + terminal_nodes: Set of node names that terminate the workflow in + addition to the implicit ``$end`` sentinel (e.g., ``type: terminate`` + steps). Returns: List of paths (up to _MAX_ENUMERATED_PATHS), where each path is a list @@ -621,6 +652,11 @@ def dfs(current: str, path: list[str], visited: set[str]) -> None: if current == "$end": paths.append(list(path)) return + if current in terminal_nodes: + # Terminal node (e.g., terminate step) — record it as part of the + # path so callers can inspect the terminating step. + paths.append(list(path) + [current]) + return if current not in graph or current in visited: return visited.add(current) @@ -882,7 +918,11 @@ def _validate_output_path_coverage(config: WorkflowConfig) -> list[str]: """Validate that output template references are reachable on all paths. Emits warnings (not errors) for output template references to agents/groups - that don't appear on every possible execution path from entry_point to $end. + that don't appear on every possible execution path from entry_point to a + terminal node (``$end`` or a ``type: terminate`` step). Paths that end on a + terminate step whose ``output_template`` is set are excluded from coverage + because that step supplies its own final output dict and bypasses the + workflow-level ``output:``. Args: config: The WorkflowConfig to validate. @@ -896,7 +936,25 @@ def _validate_output_path_coverage(config: WorkflowConfig) -> list[str]: graph = _build_routing_graph(config) node_count = len(config.agents) + len(config.parallel) + len(config.for_each) max_depth = max(config.workflow.limits.max_iterations, node_count) - paths = _enumerate_paths_to_end(config.workflow.entry_point, graph, max_depth) + terminate_names = _terminate_agent_names(config) + paths = _enumerate_paths_to_end( + config.workflow.entry_point, + graph, + max_depth, + terminal_nodes=frozenset(terminate_names), + ) + + if not paths: + return [] + + # Drop paths that terminate via a `type: terminate` step whose + # `output_template` overrides the workflow-level `output:`. Those paths do + # not consume the workflow `output:` mapping and would produce spurious + # "not reached" warnings. + overriding_terminators = { + a.name for a in config.agents if a.type == "terminate" and a.output_template is not None + } + paths = [p for p in paths if not p or p[-1] not in overriding_terminators] if not paths: return [] @@ -912,7 +970,11 @@ def _validate_output_path_coverage(config: WorkflowConfig) -> list[str]: # Pick the shortest example path for the warning message missing_paths.sort(key=len) example = missing_paths[0] - path_str = " \u2192 ".join(example + ["$end"]) + # If the path ended on a terminate step, show that explicitly; + # otherwise append the implicit "$end" marker. + tail = "$end" if not example or example[-1] not in terminate_names else "" + display = example + ([tail] if tail else []) + path_str = " \u2192 ".join(display) warnings.append( f"Output template references '{ref}' which may not run on all paths. " f"Example path where it is skipped: {path_str}. " @@ -963,6 +1025,20 @@ def _collect_template_strings( for key, expr in input_mapping.items(): templates.append((f"agent '{agent.name}' input_mapping.{key}", expr)) + # Terminate steps: validate `reason` and `output_template` like other + # Jinja2-rendered fields so bad refs fail at validate-time, not runtime. + # `getattr` matches the duck-typed-agent path used by + # `TestInputMappingTemplateCollection` (mirrors the `input_mapping` + # forward-compatibility shim above). + if getattr(agent, "type", None) == "terminate": + reason = getattr(agent, "reason", None) + if reason: + templates.append((f"agent '{agent.name}' reason", reason)) + output_template: dict[str, str] | None = getattr(agent, "output_template", None) + if output_template: + for key, expr in output_template.items(): + templates.append((f"agent '{agent.name}' output_template.{key}", expr)) + return templates diff --git a/src/conductor/engine/workflow.py b/src/conductor/engine/workflow.py index 8bf9b08d..f0e97887 100644 --- a/src/conductor/engine/workflow.py +++ b/src/conductor/engine/workflow.py @@ -33,6 +33,7 @@ InterruptError, MaxIterationsError, ValidationError, + WorkflowTerminated, ) from conductor.exceptions import ( TimeoutError as ConductorTimeoutError, @@ -1264,7 +1265,7 @@ async def _execute_subworkflow( instructions_preamble=child_preamble, ) - return await child_engine.run(sub_inputs) + return await self._run_child_engine(child_engine, sub_inputs, agent) async def _execute_subworkflow_with_inputs( self, @@ -1376,10 +1377,54 @@ async def _execute_subworkflow_with_inputs( child_engine = WorkflowEngine(**child_engine_kwargs) - output = await child_engine.run(sub_inputs) + output = await self._run_child_engine(child_engine, sub_inputs, agent) usage = child_engine.usage_tracker.get_summary() return output, usage + async def _run_child_engine( + self, + child_engine: WorkflowEngine, + sub_inputs: dict[str, Any], + agent: AgentDef, + ) -> dict[str, Any]: + """Run a child sub-workflow engine and convert child-level termination. + + A ``WorkflowTerminated`` raised by a child sub-workflow (i.e. a + ``type: terminate`` step with ``status: failed`` inside the child) + must NOT propagate as ``WorkflowTerminated`` to the parent — the + parent did not explicitly terminate, the child did. The parent + should see this as a normal sub-workflow failure so its own + ``subworkflow_failed`` event fires and the parent's outer error + handling treats it like any other ``ExecutionError``. + + Successful terminations inside a child propagate normally: the + child returns its rendered output dict and the parent continues. + + Args: + child_engine: Already-constructed child :class:`WorkflowEngine`. + sub_inputs: Inputs to pass to ``child_engine.run()``. + agent: The parent's ``type: workflow`` agent definition (used + for diagnostic messages). + + Returns: + The child workflow's final output dict. + """ + try: + return await child_engine.run(sub_inputs) + except WorkflowTerminated as exc: + raise ExecutionError( + f"Sub-workflow '{agent.workflow}' (agent '{agent.name}') " + f"terminated explicitly: {exc.reason}", + suggestion=( + "The sub-workflow ended with `type: terminate` and " + "`status: failed`. To surface the termination details to " + "the parent's routes, change the terminate step to " + "`status: success` and put the reason/status in its " + "`output_template:`." + ), + agent_name=agent.name, + ) from exc + async def _get_provider_for_agent(self, agent: AgentDef) -> AgentProvider | None: """Resolve the provider that will (or did) execute ``agent``. @@ -2286,6 +2331,97 @@ async def _execute_loop(self, current_agent_name: str) -> dict[str, Any]: # Trim context if max_tokens is configured self._trim_context_if_needed() + # Handle terminate steps — explicit workflow exit with a + # structured reason and status. Reached via a normal + # route from any upstream agent/group; the engine ends + # the workflow immediately (no routes evaluated after). + if agent.type == "terminate": + terminate_elapsed = _time.time() - _workflow_start + agent_context = self.context.build_for_agent( + agent.name, + agent.input, + mode=self.config.workflow.context.mode, + agent_type=agent.type, + ) + # Render the reason against context first so the + # rendered value is available to output_template + # and to the workflow-level output: fallback. + rendered_reason = self.renderer.render( + agent.reason or "", agent_context + ) + # Store the terminate step's own context entry + # BEFORE building the final output so workflow.output + # templates can reference {{ .reason }} / + # {{ .status }} if desired. + self.context.store( + agent.name, + { + "status": agent.status, + "reason": rendered_reason, + "terminated_by": agent.name, + }, + ) + self.limits.record_execution(agent.name) + self.limits.check_timeout() + + # Build the final output: prefer output_template + # when set (replaces workflow-level output:); + # otherwise fall back to the workflow's output: + # mapping rendered as usual. + output = self._build_terminate_output(agent) + + termination_meta = { + "termination_reason": rendered_reason, + "terminated_by": agent.name, + "is_explicit": True, + "status": agent.status, + } + + if agent.status == "success": + self._emit( + "agent_completed", + { + "agent_name": agent.name, + "elapsed": _time.time() + - _workflow_start + - terminate_elapsed, + "agent_type": "terminate", + **termination_meta, + }, + ) + self._emit( + "workflow_completed", + { + "elapsed": _time.time() - _workflow_start, + "output": output, + **termination_meta, + }, + ) + self._execute_hook("on_complete", result=output) + return output + + # status == "failed" — raise an explicit termination + # exception. The dedicated handler below emits + # workflow_failed with is_explicit=True and skips + # the on-failure checkpoint save. + self._emit( + "agent_failed", + { + "agent_name": agent.name, + "elapsed": _time.time() - _workflow_start - terminate_elapsed, + "agent_type": "terminate", + "error_type": "WorkflowTerminated", + "message": rendered_reason, + **termination_meta, + }, + ) + raise WorkflowTerminated( + rendered_reason, + output=output, + reason=rendered_reason, + terminated_by=agent.name, + ) + # Handle human gates if agent.type == "human_gate": # Build context for the gate prompt @@ -2932,8 +3068,27 @@ async def _execute_loop(self, current_agent_name: str) -> dict[str, Any]: except KeyboardInterrupt: self._save_checkpoint_on_failure(KeyboardInterrupt("Workflow interrupted by user")) raise - except ConductorError as e: + except WorkflowTerminated as e: + # Explicit `type: terminate` with `status: failed`. The workflow + # ended intentionally — emit `workflow_failed` with rich termination + # metadata so the CLI/dashboard/JSONL can distinguish it from an + # unexpected failure. Skip the on-failure checkpoint: an explicit + # termination is not a resumable transient failure. fail_data: dict[str, Any] = { + "error_type": "WorkflowTerminated", + "message": e.reason, + "agent_name": e.terminated_by, + "termination_reason": e.reason, + "terminated_by": e.terminated_by, + "status": e.status, + "is_explicit": True, + "output": e.output, + } + self._emit("workflow_failed", fail_data) + self._execute_hook("on_error", error=e) + raise + except ConductorError as e: + fail_data = { "error_type": type(e).__name__, "message": str(e), "agent_name": self._current_agent_name, @@ -4663,6 +4818,33 @@ def _build_final_output( return result + def _build_terminate_output(self, agent: AgentDef) -> dict[str, Any]: + """Build the final output for a ``type: terminate`` step. + + When ``agent.output_template`` is set, render its entries against the + accumulated context and use them as the final workflow output + (replacing the workflow-level ``output:`` mapping). Otherwise, fall + back to ``_build_final_output(None)`` so the workflow-level ``output:`` + is rendered as on any other terminal path. + + Args: + agent: The terminate-step agent definition. + + Returns: + Dict with rendered output values, ready for the + ``workflow_completed`` / ``workflow_failed`` event payload and + stdout JSON. + """ + if agent.output_template is None: + return self._build_final_output(None) + + ctx = self.context.get_for_template() + result: dict[str, Any] = {} + for key, template in agent.output_template.items(): + rendered = self.renderer.render(template, ctx) + result[key] = self._maybe_parse_json(rendered) + return result + @staticmethod def _maybe_parse_json(value: str) -> Any: """Attempt to parse a string as JSON. diff --git a/src/conductor/exceptions.py b/src/conductor/exceptions.py index d3bac88c..c8830c99 100644 --- a/src/conductor/exceptions.py +++ b/src/conductor/exceptions.py @@ -512,6 +512,55 @@ def __init__( super().__init__(message, suggestion, file_path, line_number) +class WorkflowTerminated(ExecutionError): + """Raised when a ``type: terminate`` step ends the workflow with ``status: failed``. + + This is an *explicit* termination signal — not an unexpected failure. It carries + the rendered output, reason, and the name of the terminate step that fired so + the CLI, event consumers, and dashboard can distinguish it from generic errors. + + The engine emits ``workflow_failed`` with ``is_explicit: True`` for this path + and intentionally skips checkpoint creation: an explicit termination is not a + resumable failure. + + Attributes: + output: The rendered final output dict (from ``output_template`` if + provided, else the workflow-level ``output:`` mapping). + reason: The rendered termination reason (Jinja2-resolved against context). + terminated_by: The ``name`` of the terminate step that fired. + status: Always ``"failed"`` (success terminations return normally and do + not raise). + """ + + def __init__( + self, + message: str, + *, + output: dict, + reason: str, + terminated_by: str, + status: str = "failed", + suggestion: str | None = None, + ) -> None: + """Initialize a WorkflowTerminated exception. + + Args: + message: The error message describing the termination (typically the + rendered ``reason``). + output: The rendered final output dict for the workflow. + reason: The rendered termination reason. + terminated_by: Name of the terminate step that fired. + status: Always ``"failed"`` — kept as a parameter for forward + compatibility if non-binary statuses are ever added. + suggestion: Optional advice for resolving the termination. + """ + self.output = output + self.reason = reason + self.terminated_by = terminated_by + self.status = status + super().__init__(message, suggestion=suggestion, agent_name=terminated_by) + + class InterruptError(ExecutionError): """Raised when the user stops a workflow via the interrupt menu. diff --git a/tests/test_cli/test_run.py b/tests/test_cli/test_run.py index 7a22789c..f5a2fdc6 100644 --- a/tests/test_cli/test_run.py +++ b/tests/test_cli/test_run.py @@ -980,3 +980,128 @@ def test_build_plan_detects_loop(self, tmp_path: Path) -> None: # agent1 should be marked as a loop target agent1_step = next(s for s in plan.steps if s.agent_name == "agent1") assert agent1_step.is_loop_target is True + + +class TestRunCommandTerminate: + """CLI integration tests for ``type: terminate`` steps (issue #219). + + The CLI must: + - Exit with code 0 and print the rendered output JSON when a workflow ends + via ``terminate status: success``. + - Exit with non-zero code AND still print the rendered output JSON when a + workflow ends via ``terminate status: failed``, plus a user-facing + message naming the step that fired and the rendered reason. + + These tests patch ``run_workflow_async`` so we exercise only the + exit-code / stdout / stderr wiring; engine semantics are covered in + ``tests/test_engine/test_workflow.py::TestWorkflowEngineTerminate``. + """ + + def test_run_success_terminate_exits_zero_and_prints_output(self, tmp_path: Path) -> None: + """Success-terminate: behaves like any clean workflow exit (code 0).""" + workflow_file = tmp_path / "wf.yaml" + workflow_file.write_text("""\ +workflow: + name: t + entry_point: bye +agents: + - name: bye + type: terminate + status: success + reason: "all done" + output_template: + result: "no-op" +output: {} +""") + # `run` (not the engine) only sees `run_workflow_async`'s return; + # success-terminate returns the rendered output dict normally. + with patch("conductor.cli.run.run_workflow_async") as mock_run: + mock_run.return_value = {"result": "no-op"} + + result = runner.invoke(app, ["run", str(workflow_file)]) + + assert result.exit_code == 0, result.output + # Output JSON should be present (Rich's `print_json` colors it; check + # the structural pieces are there rather than parsing). + assert '"result"' in result.output + assert '"no-op"' in result.output + + def test_run_failed_terminate_exits_nonzero_and_prints_output_and_reason( + self, tmp_path: Path + ) -> None: + """Failed-terminate: exits non-zero, prints rendered output AND reason. + + Downstream tooling (CI scripts, dashboards) reads the JSON from stdout + regardless of exit code; humans read the reason from stderr. Both + must be present. + """ + from conductor.exceptions import WorkflowTerminated + + workflow_file = tmp_path / "wf.yaml" + workflow_file.write_text("""\ +workflow: + name: t + entry_point: bye +agents: + - name: bye + type: terminate + status: failed + reason: "unsafe input" + output_template: + aborted: "true" +output: {} +""") + with patch("conductor.cli.run.run_workflow_async") as mock_run: + mock_run.side_effect = WorkflowTerminated( + "unsafe input", + output={"aborted": True, "reason": "unsafe input"}, + reason="unsafe input", + terminated_by="bye", + ) + + result = runner.invoke(app, ["run", str(workflow_file)]) + + assert result.exit_code == 1, result.output + # Rendered output JSON is on stdout for tooling. + assert '"aborted"' in result.output + # Reason + step name on stderr (Rich routes the warning through the + # error console). CliRunner mixes stdout/stderr so look in `output`. + assert "unsafe input" in result.output + assert "bye" in result.output + + def test_run_failed_terminate_does_not_print_generic_error_panel(self, tmp_path: Path) -> None: + """The dedicated handler must short-circuit `print_error`. + + Without this, the user would see the standard exception panel + ("ExecutionError: ...") instead of the explicit termination message, + making the terminate feature indistinguishable from a generic crash. + """ + from conductor.exceptions import WorkflowTerminated + + workflow_file = tmp_path / "wf.yaml" + workflow_file.write_text("""\ +workflow: + name: t + entry_point: bye +agents: + - name: bye + type: terminate + status: failed + reason: "halt" +output: {} +""") + with patch("conductor.cli.run.run_workflow_async") as mock_run: + mock_run.side_effect = WorkflowTerminated( + "halt", + output={}, + reason="halt", + terminated_by="bye", + ) + + result = runner.invoke(app, ["run", str(workflow_file)]) + + assert result.exit_code == 1, result.output + # The standard error panel formats as "Error: WorkflowTerminated" + # via print_error -> format_error. The dedicated handler should + # NOT produce that — instead, a single-line red message. + assert "Error: WorkflowTerminated" not in result.output diff --git a/tests/test_config/test_schema.py b/tests/test_config/test_schema.py index bba49941..68be5e2c 100644 --- a/tests/test_config/test_schema.py +++ b/tests/test_config/test_schema.py @@ -1522,3 +1522,158 @@ def test_routedef_typo_when_rejected(self) -> None: assert any(err["type"] == "extra_forbidden" and "whn" in err["loc"] for err in errors), ( f"Expected extra_forbidden error for 'whn', got: {errors}" ) + + +class TestTerminateAgent: + """Tests for ``type: terminate`` step schema validation (issue #219). + + Terminate steps are terminal nodes that end the workflow with an explicit + ``status`` and ``reason``. The schema must: + + - Accept ``status`` (``success`` | ``failed``), ``reason``, and optional + ``output_template`` only when ``type == "terminate"``. + - Reject those fields on any other step type (avoids silent misuse on a + regular agent). + - Reject every field that doesn't make sense for a terminal step (routes, + tools, output, prompt, model, provider, etc.) so authoring errors fail + fast. + """ + + def test_valid_terminate_success(self) -> None: + a = AgentDef(name="ok", type="terminate", status="success", reason="done") + assert a.type == "terminate" + assert a.status == "success" + assert a.reason == "done" + assert a.output_template is None + + def test_valid_terminate_failed_with_output_template(self) -> None: + a = AgentDef( + name="abort", + type="terminate", + status="failed", + reason="Refusing to run on unsafe input", + output_template={"result": "aborted", "reason": "{{ precheck.output.reason }}"}, + ) + assert a.status == "failed" + assert a.output_template == { + "result": "aborted", + "reason": "{{ precheck.output.reason }}", + } + + def test_missing_status_rejected(self) -> None: + with pytest.raises(ValidationError) as exc_info: + AgentDef(name="x", type="terminate", reason="needed") + assert "status" in str(exc_info.value).lower() + + def test_missing_reason_rejected(self) -> None: + with pytest.raises(ValidationError) as exc_info: + AgentDef(name="x", type="terminate", status="success") + assert "reason" in str(exc_info.value).lower() + + def test_empty_reason_rejected(self) -> None: + with pytest.raises(ValidationError) as exc_info: + AgentDef(name="x", type="terminate", status="success", reason=" ") + assert "reason" in str(exc_info.value).lower() + + def test_invalid_status_rejected(self) -> None: + with pytest.raises(ValidationError): + AgentDef(name="x", type="terminate", status="maybe", reason="x") + + def test_routes_rejected_on_terminate(self) -> None: + """Terminate ends the workflow; outbound routes would be unreachable.""" + with pytest.raises(ValidationError) as exc_info: + AgentDef( + name="x", + type="terminate", + status="success", + reason="r", + routes=[RouteDef(to="$end")], + ) + assert "routes" in str(exc_info.value).lower() + + def test_tools_rejected_on_terminate(self) -> None: + with pytest.raises(ValidationError) as exc_info: + AgentDef(name="x", type="terminate", status="success", reason="r", tools=["foo"]) + assert "tools" in str(exc_info.value).lower() + + def test_output_rejected_on_terminate(self) -> None: + """`output:` is for agent schemas; terminate uses `output_template:` instead.""" + with pytest.raises(ValidationError) as exc_info: + AgentDef( + name="x", + type="terminate", + status="success", + reason="r", + output={"k": OutputField(type="string")}, + ) + assert "output" in str(exc_info.value).lower() + + def test_prompt_rejected_on_terminate(self) -> None: + with pytest.raises(ValidationError) as exc_info: + AgentDef(name="x", type="terminate", status="success", reason="r", prompt="hi") + assert "prompt" in str(exc_info.value).lower() + + def test_model_rejected_on_terminate(self) -> None: + with pytest.raises(ValidationError) as exc_info: + AgentDef(name="x", type="terminate", status="success", reason="r", model="claude") + assert "model" in str(exc_info.value).lower() + + def test_command_rejected_on_terminate(self) -> None: + with pytest.raises(ValidationError) as exc_info: + AgentDef(name="x", type="terminate", status="success", reason="r", command="echo") + assert "command" in str(exc_info.value).lower() + + def test_workflow_rejected_on_terminate(self) -> None: + with pytest.raises(ValidationError) as exc_info: + AgentDef( + name="x", + type="terminate", + status="success", + reason="r", + workflow="./sub.yaml", + ) + assert "workflow" in str(exc_info.value).lower() + + @pytest.mark.parametrize("forbidden_field", ["status", "reason", "output_template"]) + def test_terminate_fields_rejected_on_regular_agent(self, forbidden_field: str) -> None: + """`status`, `reason`, `output_template` only make sense on `type: terminate`. + + Without this guard, an author who forgot to add `type: terminate` would + silently get a regular agent that ignores these fields entirely — a + subtle bug that breaks the workflow without any error surfaced. + """ + payload: dict[str, object] = {"name": "a"} + if forbidden_field == "output_template": + payload[forbidden_field] = {"k": "{{ a.output }}"} + else: + payload[forbidden_field] = "success" if forbidden_field == "status" else "r" + with pytest.raises(ValidationError) as exc_info: + AgentDef.model_validate(payload) + assert forbidden_field in str(exc_info.value) + + @pytest.mark.parametrize("step_type", ["script", "workflow", "human_gate"]) + def test_terminate_fields_rejected_on_other_step_types(self, step_type: str) -> None: + """The terminate-only-fields guard must trip for every non-terminate type.""" + payload: dict[str, object] = {"name": "a", "type": step_type} + if step_type == "script": + payload["command"] = "echo" + elif step_type == "workflow": + payload["workflow"] = "./sub.yaml" + elif step_type == "human_gate": + payload["prompt"] = "Pick" + payload["options"] = [GateOption(value="x", label="X", route="$end")] + payload["status"] = "success" + with pytest.raises(ValidationError) as exc_info: + AgentDef.model_validate(payload) + assert "status" in str(exc_info.value) + + def test_input_allowed_on_terminate(self) -> None: + """Terminate steps may declare context inputs to drive Jinja rendering.""" + a = AgentDef( + name="x", + type="terminate", + status="success", + reason="{{ precheck.output.reason }}", + input=["precheck.output"], + ) + assert a.input == ["precheck.output"] diff --git a/tests/test_config/test_validator.py b/tests/test_config/test_validator.py index 07c2d3c1..255eeae6 100644 --- a/tests/test_config/test_validator.py +++ b/tests/test_config/test_validator.py @@ -2636,3 +2636,254 @@ def fake_fetch_github(entry, workflow_path, sha_arg, dest_dir): # Confirm the sibling was actually auto-fetched into the shared SHA root. sibling = official_sha_root / "document-review" / "workflow.yaml" assert sibling.exists() + + +class TestTerminateValidation: + """Cross-field validation for ``type: terminate`` steps (issue #219). + + The schema layer alone cannot catch every misuse — terminate steps + interact with the wider workflow in several ways the validator must guard: + + - Routes from regular agents are allowed to target a terminate step, + because that is the point of the feature. + - Terminate cannot be used as a parallel-group member or as a for_each + inline agent — those execution contexts swallow exceptions or assume + the inline step is a normal agent. + - When a terminate step provides its own ``output_template``, the + workflow-level ``output:`` coverage analysis must NOT flag missing + refs against that path (the path skips ``workflow.output`` entirely). + - Jinja2 templates inside ``reason`` and ``output_template`` must be + validated like every other template (no stale agent refs). + """ + + def test_routes_can_target_terminate(self) -> None: + config = WorkflowConfig( + workflow=WorkflowDef(name="t", entry_point="precheck"), + agents=[ + AgentDef( + name="precheck", + model="gpt-4", + prompt="check", + routes=[RouteDef(to="abort"), RouteDef(to="$end")], + ), + AgentDef( + name="abort", + type="terminate", + status="failed", + reason="nope", + ), + ], + ) + validate_workflow_config(config) # must not raise + + def test_terminate_can_be_entry_point(self) -> None: + """Unusual but valid — workflow ends immediately on the first step.""" + config = WorkflowConfig( + workflow=WorkflowDef(name="t", entry_point="goodbye"), + agents=[ + AgentDef( + name="goodbye", + type="terminate", + status="success", + reason="nothing to do", + ), + ], + ) + validate_workflow_config(config) # must not raise + + def test_terminate_rejected_inside_parallel_group(self) -> None: + """Parallel branches run inside `asyncio.gather(return_exceptions=True)`; + an explicit termination from one branch would be wrapped/swallowed + rather than ending the workflow as intended.""" + config = WorkflowConfig( + workflow=WorkflowDef(name="t", entry_point="group"), + agents=[ + AgentDef(name="a", model="gpt-4", prompt="x"), + AgentDef( + name="b", + type="terminate", + status="failed", + reason="nope", + ), + ], + parallel=[ + ParallelGroup(name="group", agents=["a", "b"], routes=[RouteDef(to="$end")]), + ], + ) + with pytest.raises(ConfigurationError, match="terminate step"): + validate_workflow_config(config) + + def test_terminate_rejected_as_for_each_inline_agent(self) -> None: + # ``as`` is a Python keyword; construct via dict so the validation + # alias resolves to ``as_`` correctly. + for_each = ForEachDef.model_validate( + { + "name": "loop", + "type": "for_each", + "source": "workflow.input.items", + "as": "item", + "agent": AgentDef( + name="bail", + type="terminate", + status="failed", + reason="r", + ), + "routes": [RouteDef(to="$end")], + } + ) + config = WorkflowConfig( + workflow=WorkflowDef( + name="t", + entry_point="finder", + input={"items": InputDef(type="array")}, + ), + agents=[ + AgentDef( + name="finder", + model="gpt-4", + prompt="x", + routes=[RouteDef(to="loop")], + ), + ], + for_each=[for_each], + ) + with pytest.raises(ConfigurationError, match="terminate step"): + validate_workflow_config(config) + + def test_output_template_skips_workflow_output_coverage(self) -> None: + """Paths ending in terminate-with-output_template bypass workflow.output. + + Without the path-coverage carve-out, the validator would warn that + ``writer`` is "not reached on all paths" — true, but irrelevant: the + terminate path doesn't use ``workflow.output`` at all. + """ + config = WorkflowConfig( + workflow=WorkflowDef(name="t", entry_point="check"), + agents=[ + AgentDef( + name="check", + model="gpt-4", + prompt="x", + routes=[RouteDef(to="bail"), RouteDef(to="writer")], + ), + AgentDef( + name="bail", + type="terminate", + status="failed", + reason="nope", + output_template={"result": "aborted"}, + ), + AgentDef( + name="writer", + model="gpt-4", + prompt="x", + routes=[RouteDef(to="$end")], + ), + ], + output={"result": "{{ writer.output.result }}"}, + ) + warnings = validate_workflow_config(config) + # Only the writer path consumes workflow.output; the bail-path + # supplies its own output_template and is excluded from coverage. + assert not any("writer" in w and "not run on all paths" in w for w in warnings), ( + f"unexpected coverage warning: {warnings!r}" + ) + + def test_output_template_with_fallback_still_warns(self) -> None: + """A terminate path WITHOUT `output_template` falls back to workflow.output — + it should be analyzed for coverage like any normal terminal path.""" + config = WorkflowConfig( + workflow=WorkflowDef(name="t", entry_point="check"), + agents=[ + AgentDef( + name="check", + model="gpt-4", + prompt="x", + routes=[RouteDef(to="bail"), RouteDef(to="writer")], + ), + AgentDef( + name="bail", + type="terminate", + status="failed", + reason="nope", + ), + AgentDef( + name="writer", + model="gpt-4", + prompt="x", + routes=[RouteDef(to="$end")], + ), + ], + output={"result": "{{ writer.output.result }}"}, + ) + warnings = validate_workflow_config(config) + assert any("writer" in w and "not run on all paths" in w for w in warnings), ( + f"expected coverage warning for terminate fallback path; got: {warnings!r}" + ) + + def test_reason_template_validated(self) -> None: + """Bad refs in ``reason`` must fail validation, not surprise at runtime.""" + config = WorkflowConfig( + workflow=WorkflowDef(name="t", entry_point="check"), + agents=[ + AgentDef( + name="check", + model="gpt-4", + prompt="x", + routes=[RouteDef(to="bail"), RouteDef(to="$end")], + ), + AgentDef( + name="bail", + type="terminate", + status="failed", + reason="{{ ghost.output.value }}", + ), + ], + ) + with pytest.raises(ConfigurationError, match=r"ghost"): + validate_workflow_config(config) + + def test_output_template_template_validated(self) -> None: + """Bad refs in ``output_template`` values must fail validation too.""" + config = WorkflowConfig( + workflow=WorkflowDef(name="t", entry_point="check"), + agents=[ + AgentDef( + name="check", + model="gpt-4", + prompt="x", + routes=[RouteDef(to="bail"), RouteDef(to="$end")], + ), + AgentDef( + name="bail", + type="terminate", + status="failed", + reason="halt", + output_template={"r": "{{ ghost.output.value }}"}, + ), + ], + ) + with pytest.raises(ConfigurationError, match=r"ghost"): + validate_workflow_config(config) + + def test_unknown_route_target_message_unchanged_for_terminate(self) -> None: + """Routes to an undefined name still error — terminate doesn't bypass this. + + The schema-level route-target check runs on every WorkflowConfig, so + the unknown target surfaces as a Pydantic ValidationError at + construction time (not via :func:`validate_workflow_config`). + """ + from pydantic import ValidationError as PydanticValidationError + + with pytest.raises(PydanticValidationError, match=r"unknown agent"): + WorkflowConfig( + workflow=WorkflowDef(name="t", entry_point="check"), + agents=[ + AgentDef( + name="check", + model="gpt-4", + prompt="x", + routes=[RouteDef(to="not_defined")], + ), + ], + ) diff --git a/tests/test_engine/test_subworkflow.py b/tests/test_engine/test_subworkflow.py index 4edf2d8f..0dd01e71 100644 --- a/tests/test_engine/test_subworkflow.py +++ b/tests/test_engine/test_subworkflow.py @@ -2130,3 +2130,170 @@ def mock_handler(agent, prompt, context): assert sibling.exists() # And its sentinel was written. assert (meta_dir / "document-review.complete").exists() + + +class TestSubWorkflowTerminate: + """Sub-workflow terminate semantics (issue #219). + + A ``type: terminate`` step inside a child sub-workflow MUST stay scoped to + that child. From the parent's perspective: + + - ``status: success`` → child returns its rendered output cleanly; the + parent continues with its next routes as if a normal `$end` had been + reached inside the child. + - ``status: failed`` → child raises ``WorkflowTerminated``; the parent's + ``_run_child_engine`` converts that to a normal ``ExecutionError`` so + the parent treats it like any other sub-workflow failure (parent + ``subworkflow_failed`` event fires; parent's outer ``workflow_failed`` + does NOT carry ``is_explicit: true``). + + Without this conversion, a child terminate would bubble all the way out + and the parent's `workflow_failed` would falsely attribute the explicit + termination to the parent (whose author never opted in). + """ + + @pytest.mark.asyncio + async def test_child_success_terminate_returns_output(self, tmp_workflow_dir: Path) -> None: + """A child `terminate status: success` returns its output_template to the parent.""" + _write_yaml( + tmp_workflow_dir / "sub.yaml", + """\ + workflow: + name: sub + entry_point: bye + runtime: + provider: copilot + limits: + max_iterations: 5 + agents: + - name: bye + type: terminate + status: success + reason: "Document is already current." + output_template: + result: "no-op" + reason: "{{ bye.output.reason }}" + """, + ) + parent_path = tmp_workflow_dir / "parent.yaml" + parent_path.write_text("dummy", encoding="utf-8") + + config = WorkflowConfig( + workflow=WorkflowDef( + name="parent", + entry_point="research", + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=10), + ), + agents=[ + AgentDef( + name="research", + type="workflow", + workflow="sub.yaml", + routes=[RouteDef(to="$end")], + ), + ], + output={ + "child_result": "{{ research.output.result }}", + "child_reason": "{{ research.output.reason }}", + }, + ) + + engine = WorkflowEngine(config, CopilotProvider(), workflow_path=parent_path) + result = await engine.run({}) + assert result == { + "child_result": "no-op", + "child_reason": "Document is already current.", + } + + @pytest.mark.asyncio + async def test_child_failed_terminate_surfaces_as_execution_error( + self, tmp_workflow_dir: Path + ) -> None: + """Failed-terminate in a child must propagate as ExecutionError to the parent. + + The parent's outer handler treats it like any other sub-workflow + failure (parent's workflow_failed has NO ``is_explicit: true``). This + protects parent authors from accidentally inheriting child-only + termination semantics. + """ + from conductor.events import WorkflowEvent, WorkflowEventEmitter + + _write_yaml( + tmp_workflow_dir / "sub.yaml", + """\ + workflow: + name: sub + entry_point: abort + runtime: + provider: copilot + limits: + max_iterations: 5 + agents: + - name: abort + type: terminate + status: failed + reason: "Child refused to run." + """, + ) + parent_path = tmp_workflow_dir / "parent.yaml" + parent_path.write_text("dummy", encoding="utf-8") + + config = WorkflowConfig( + workflow=WorkflowDef( + name="parent", + entry_point="research", + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=10), + ), + agents=[ + AgentDef( + name="research", + type="workflow", + workflow="sub.yaml", + routes=[RouteDef(to="$end")], + ), + ], + output={}, + ) + + events: list[WorkflowEvent] = [] + emitter = WorkflowEventEmitter() + emitter.subscribe(events.append) + + engine = WorkflowEngine( + config, CopilotProvider(), workflow_path=parent_path, event_emitter=emitter + ) + + with pytest.raises(ExecutionError) as excinfo: + await engine.run({}) + + # The parent sees a sub-workflow failure, not its own explicit termination. + assert "Child refused to run." in str(excinfo.value) + assert "research" in str(excinfo.value) + + # subworkflow_failed must fire so the dashboard shows the child as failed. + assert any(e.type == "subworkflow_failed" for e in events), ( + f"expected subworkflow_failed; got {[e.type for e in events]}" + ) + + # The parent's OWN `workflow_failed` must NOT inherit is_explicit. + # Child engines share the parent's emitter and emit their own + # `workflow_failed` with `subworkflow_path` set; we filter those out + # to look only at parent-level events (no subworkflow_path). + outer = [ + e for e in events if e.type == "workflow_failed" and not e.data.get("subworkflow_path") + ] + assert outer, "expected parent's workflow_failed event" + assert all(not e.data.get("is_explicit") for e in outer), ( + f"parent must not inherit is_explicit from child terminate; got: " + f"{[e.data for e in outer]}" + ) + # Parent's error_type should be ExecutionError — child's termination + # is downgraded at the boundary so the parent treats it normally. + assert all(e.data.get("error_type") == "ExecutionError" for e in outer), ( + f"parent error_type should be ExecutionError; got: " + f"{[e.data.get('error_type') for e in outer]}" + ) diff --git a/tests/test_engine/test_workflow.py b/tests/test_engine/test_workflow.py index 5eb62703..291b195d 100644 --- a/tests/test_engine/test_workflow.py +++ b/tests/test_engine/test_workflow.py @@ -2727,3 +2727,306 @@ def mock_handler(agent, prompt, context): system = started[0].data["system"] assert "bg_stderr_log" not in system assert "bg_stdout_log" not in system + + +class TestWorkflowEngineTerminate: + """Engine-level tests for ``type: terminate`` steps (issue #219). + + These tests drive the engine through real terminate dispatch (success and + failure), verify the correct event payloads, and confirm + ``WorkflowTerminated`` semantics: explicit termination must surface as a + non-resumable failure with rich metadata, distinguishable from a generic + exception. Tests use a stub provider via ``CopilotProvider(mock_handler=…)`` + only for the upstream agent; the terminate dispatch branch needs no + provider call. + """ + + @staticmethod + def _config_with_terminate( + status: str, + *, + output_template: dict[str, str] | None = None, + reason: str = "Document already up to date; no edits needed.", + also_workflow_output: bool = True, + ) -> WorkflowConfig: + """Build a small workflow whose entry agent unconditionally routes to a terminate step. + + The entry agent is a real provider-backed agent so the dispatch path + exercises every event the dashboard listens for (agent_started / + agent_completed) before reaching the terminate branch. + """ + agents: list[AgentDef] = [ + AgentDef( + name="upstream", + model="gpt-4", + prompt="x", + output={"value": OutputField(type="string")}, + routes=[RouteDef(to="finish")], + ), + AgentDef( + name="finish", + type="terminate", + status=status, # type: ignore[arg-type] + reason=reason, + output_template=output_template, + ), + ] + return WorkflowConfig( + workflow=WorkflowDef( + name="terminate-test", + entry_point="upstream", + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=10), + ), + agents=agents, + output={"result": "{{ upstream.output.value }}"} if also_workflow_output else {}, + ) + + @pytest.mark.asyncio + async def test_success_terminate_returns_output_template(self) -> None: + """`status: success` returns the rendered output_template cleanly. + + The workflow-level ``output:`` mapping is REPLACED by the terminate + step's ``output_template`` (not merged). This contract lets callers + use a terminate step as an early-exit short-circuit that emits a + differently-shaped final payload from the normal `$end` path. + """ + from conductor.events import WorkflowEvent, WorkflowEventEmitter + + config = self._config_with_terminate( + "success", + output_template={ + "result": "no-op", + "reason": "{{ finish.output.reason }}", + }, + ) + provider = CopilotProvider(mock_handler=lambda *_a, **_kw: {"value": "upstream-value"}) + events: list[WorkflowEvent] = [] + emitter = WorkflowEventEmitter() + emitter.subscribe(events.append) + + engine = WorkflowEngine(config, provider, event_emitter=emitter) + result = await engine.run({}) + + assert result == { + "result": "no-op", + "reason": "Document already up to date; no edits needed.", + } + completed = [e for e in events if e.type == "workflow_completed"] + assert len(completed) == 1 + data = completed[0].data + assert data["is_explicit"] is True + assert data["termination_reason"] == "Document already up to date; no edits needed." + assert data["terminated_by"] == "finish" + assert data["status"] == "success" + + @pytest.mark.asyncio + async def test_success_terminate_without_output_template_falls_back(self) -> None: + """Without ``output_template`` the workflow-level ``output:`` is rendered. + + This is the behaviour-preserving default: existing workflows that route + to a terminate step without supplying ``output_template`` still produce + the same final-output shape as a normal `$end` path. + """ + config = self._config_with_terminate("success", output_template=None) + provider = CopilotProvider(mock_handler=lambda *_a, **_kw: {"value": "v"}) + + engine = WorkflowEngine(config, provider) + result = await engine.run({}) + + assert result == {"result": "v"} + + @pytest.mark.asyncio + async def test_failed_terminate_raises_workflow_terminated(self) -> None: + """`status: failed` raises ``WorkflowTerminated`` with structured fields. + + The CLI / dashboard rely on these attributes (``output``, ``reason``, + ``terminated_by``) to render the explicit termination distinctly from a + generic exception. The reason is the *rendered* string, not the + template. + """ + from conductor.exceptions import WorkflowTerminated + + config = self._config_with_terminate( + "failed", + reason="upstream said {{ upstream.output.value }}", + output_template={"aborted": "true", "msg": "{{ upstream.output.value }}"}, + ) + provider = CopilotProvider(mock_handler=lambda *_a, **_kw: {"value": "stop now"}) + + engine = WorkflowEngine(config, provider) + with pytest.raises(WorkflowTerminated) as excinfo: + await engine.run({}) + + err = excinfo.value + assert err.terminated_by == "finish" + assert err.reason == "upstream said stop now" + assert err.output == {"aborted": True, "msg": "stop now"} + assert err.status == "failed" + + @pytest.mark.asyncio + async def test_failed_terminate_emits_workflow_failed_with_explicit_flag(self) -> None: + """`status: failed` emits a `workflow_failed` event with `is_explicit: true`. + + Downstream tooling (CI, notifications, dashboards) distinguishes an + intentional termination from a generic crash by reading this flag. + Without it, every terminate would look indistinguishable from an + unhandled exception. + """ + from conductor.events import WorkflowEvent, WorkflowEventEmitter + from conductor.exceptions import WorkflowTerminated + + config = self._config_with_terminate("failed", reason="halt") + provider = CopilotProvider(mock_handler=lambda *_a, **_kw: {"value": "v"}) + + events: list[WorkflowEvent] = [] + emitter = WorkflowEventEmitter() + emitter.subscribe(events.append) + + engine = WorkflowEngine(config, provider, event_emitter=emitter) + with pytest.raises(WorkflowTerminated): + await engine.run({}) + + failed = [e for e in events if e.type == "workflow_failed"] + assert len(failed) == 1 + data = failed[0].data + assert data["is_explicit"] is True + assert data["error_type"] == "WorkflowTerminated" + assert data["terminated_by"] == "finish" + assert data["termination_reason"] == "halt" + assert data["status"] == "failed" + # The agent-lifecycle event for a failed terminate is `agent_failed` + # (not `agent_completed`) so dashboard counters stay accurate. + agent_lifecycle = [e for e in events if e.type in ("agent_completed", "agent_failed")] + terminate_lifecycle = [e for e in agent_lifecycle if e.data.get("agent_name") == "finish"] + assert terminate_lifecycle and terminate_lifecycle[0].type == "agent_failed", ( + f"terminate with status=failed must emit agent_failed; " + f"got: {[e.type for e in terminate_lifecycle]}" + ) + + @pytest.mark.asyncio + async def test_failed_terminate_does_not_save_checkpoint(self, tmp_path) -> None: + """Explicit termination is intentional; no on-failure checkpoint is saved. + + Without this carve-out, every terminate-failed run would leave a + checkpoint behind for the next ``conductor resume`` to pick up — but + terminating with `status: failed` is the author saying "this run is + complete and the outcome is failure," not "please resume this later." + """ + from conductor.exceptions import WorkflowTerminated + + config = self._config_with_terminate("failed", reason="halt") + provider = CopilotProvider(mock_handler=lambda *_a, **_kw: {"value": "v"}) + + wf_file = tmp_path / "wf.yaml" + wf_file.write_text("name: t\n") + engine = WorkflowEngine(config, provider, workflow_path=wf_file) + + with pytest.raises(WorkflowTerminated): + await engine.run({}) + + # No checkpoint files should exist for this workflow run. + from conductor.engine.checkpoint import CheckpointManager + + checkpoints = CheckpointManager.list_checkpoints(workflow_path=wf_file) + assert not checkpoints, f"failed-terminate must not save a checkpoint; got: {checkpoints!r}" + + @pytest.mark.asyncio + async def test_terminate_step_stored_in_context(self) -> None: + """The terminate step records its own context entry before output renders. + + Order matters: workflow-level ``output:`` templates can reference + ``{{ .reason }}`` only if the entry is stored BEFORE the + final output is rendered. + """ + config = WorkflowConfig( + workflow=WorkflowDef( + name="t", + entry_point="upstream", + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=10), + ), + agents=[ + AgentDef( + name="upstream", + model="gpt-4", + prompt="x", + output={"value": OutputField(type="string")}, + routes=[RouteDef(to="finish")], + ), + AgentDef( + name="finish", + type="terminate", + status="success", + reason="all done", + ), + ], + # Reference the terminate step's stored entry from workflow.output + # to assert ordering. + output={ + "reason": "{{ finish.output.reason }}", + "by": "{{ finish.output.terminated_by }}", + }, + ) + provider = CopilotProvider(mock_handler=lambda *_a, **_kw: {"value": "v"}) + + engine = WorkflowEngine(config, provider) + result = await engine.run({}) + + assert result == {"reason": "all done", "by": "finish"} + + @pytest.mark.asyncio + async def test_reason_rendered_against_context(self) -> None: + """``reason`` is a Jinja2 template; refs resolve against accumulated context.""" + from conductor.exceptions import WorkflowTerminated + + config = self._config_with_terminate( + "failed", + reason="value was {{ upstream.output.value }}", + ) + provider = CopilotProvider(mock_handler=lambda *_a, **_kw: {"value": "unsafe-input"}) + engine = WorkflowEngine(config, provider) + with pytest.raises(WorkflowTerminated) as excinfo: + await engine.run({}) + assert excinfo.value.reason == "value was unsafe-input" + + @pytest.mark.asyncio + async def test_terminate_with_input_declared(self) -> None: + """A terminate step may declare ``input:`` refs for template rendering. + + Mirrors the contract for other step types: declaring an input forces + the engine to materialize that ref in the agent's context. + """ + config = WorkflowConfig( + workflow=WorkflowDef( + name="t", + entry_point="upstream", + runtime=RuntimeConfig(provider="copilot"), + # explicit mode requires inputs to be declared + context=ContextConfig(mode="explicit"), + limits=LimitsConfig(max_iterations=10), + ), + agents=[ + AgentDef( + name="upstream", + model="gpt-4", + prompt="x", + output={"value": OutputField(type="string")}, + routes=[RouteDef(to="finish")], + ), + AgentDef( + name="finish", + type="terminate", + status="success", + reason="ok", + input=["upstream.output"], + output_template={"echo": "{{ upstream.output.value }}"}, + ), + ], + ) + provider = CopilotProvider(mock_handler=lambda *_a, **_kw: {"value": "VAL"}) + engine = WorkflowEngine(config, provider) + result = await engine.run({}) + assert result == {"echo": "VAL"} diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index 3b74e9b4..94a88d46 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -11,6 +11,7 @@ TemplateError, TimeoutError, ValidationError, + WorkflowTerminated, ) @@ -374,3 +375,59 @@ def test_suggestion_when_exhausted(self) -> None: """Test suggestion when all attempts exhausted.""" error = RetryableError("Failed", attempt=3, max_attempts=3) assert "exhausted" in error.suggestion + + +class TestWorkflowTerminated: + """Tests for the WorkflowTerminated exception (issue #219). + + ``WorkflowTerminated`` is the explicit-termination signal raised by the + engine when a ``type: terminate`` step fires with ``status: failed``. It + must carry enough structured data for the CLI to print the rendered + output, for the dashboard to render a distinct end-state, and for the + engine's outer handler to skip the on-failure checkpoint. + """ + + def test_basic_construction(self) -> None: + """Required fields are populated and accessible on the instance.""" + error = WorkflowTerminated( + "halt", + output={"result": "aborted"}, + reason="halt", + terminated_by="abort_unsafe", + ) + assert isinstance(error, ConductorError) + assert isinstance(error, ExecutionError) + assert error.output == {"result": "aborted"} + assert error.reason == "halt" + assert error.terminated_by == "abort_unsafe" + assert error.status == "failed" + # Carries the agent_name from ExecutionError contract so existing + # error-rendering paths can identify the offending step. + assert error.agent_name == "abort_unsafe" + + def test_message_is_preserved(self) -> None: + """The message argument is used as the exception's `str()` payload.""" + error = WorkflowTerminated( + "human-readable reason", + output={}, + reason="human-readable reason", + terminated_by="abort", + ) + assert "human-readable reason" in str(error) + + def test_suggestion_passthrough(self) -> None: + """Optional suggestion is rendered through the base formatter.""" + error = WorkflowTerminated( + "halt", + output={}, + reason="halt", + terminated_by="abort", + suggestion="Adjust upstream config", + ) + assert error.suggestion == "Adjust upstream config" + assert "Adjust upstream config" in str(error) + + def test_status_defaults_to_failed(self) -> None: + """``status`` defaults to ``failed`` — success terminations return cleanly.""" + error = WorkflowTerminated("halt", output={}, reason="halt", terminated_by="abort") + assert error.status == "failed" From f32cd0590217bba4ec5cb833666e0cf80d88fc05 Mon Sep 17 00:00:00 2001 From: Jason Robert Date: Thu, 21 May 2026 15:38:21 -0400 Subject: [PATCH 2/5] refactor(terminate): apply PR-review polish (#219) Follow-up to the initial `type: terminate` implementation, addressing findings from a comprehensive PR review (code, tests, comments, silent-failure, type-design, dead-code). Critical fixes -------------- - `_run_child_engine` now raises a dedicated `SubworkflowTerminatedError` (subclass of `ExecutionError`) carrying the child's rendered `terminated_output` / `terminated_reason` / `terminated_by`. Previously the child's structured `output_template` dict was silently dropped at the parent boundary. - CLI `run` / `resume` handlers now wrap `json.dumps(e.output)` with `default=str` plus a try/except so a future non-serialisable `output_template` value cannot crash the CLI and lose the termination reason; suggestions are now surfaced alongside the reason. Type-design polish ------------------ - Drop the dead `status` parameter on `WorkflowTerminated` (always "failed" in practice); expose `status` as a property. - Make `terminated_by` a property over `agent_name` so the two fields cannot drift apart. - Tighten `output: dict` to `dict[str, Any]`. Engine safety ------------- - Reorder `check_timeout()` before `record_execution()` in the terminate branch so a workflow at `max_iterations` cannot mask explicit termination behind `MaxIterationsError`. - Wrap `_build_terminate_output()` so a template error emits `agent_failed` for the terminate step before re-raising (prevents "stuck agent" state in the dashboard / JSONL log). - Update terminate-branch comment to acknowledge that terminate may be the workflow's `entry_point`. CLI / validator hygiene ----------------------- - Promote the `WorkflowTerminated` import to module scope in `cli/app.py`. - Reframe `except WorkflowTerminated: raise` comments in `cli/run.py` as defense-in-depth (the existing checkpoint-path guard makes them redundant in practice, but the explicit catch protects against future drift in either layer). - Replace `getattr(agent, "type", None) == "terminate"` in `_collect_template_strings` with an `isinstance(agent, AgentDef)` check so a future field-rename surfaces loudly instead of silently skipping template validation. Docs ---- - Document the implicit JSON coercion of rendered `output_template` values in the schema docstring (`"true"` -> True, etc.). Tests (15 new) -------------- - CLI: split stdout/stderr assertions, add `resume` failed-terminate parity test. - Engine: terminate as entry_point, terminate routed from parallel group, terminate routed from for_each group, `on_complete` hook firing, `on_error` hook firing, `agent_failed`-before-`workflow_failed` event ordering. - Sub-workflow: child `output` preservation across boundary, failed-terminate inside for_each-of-workflow (`_with_inputs` path). - Schema: cross-product (status / reason / output_template) x (script / workflow / human_gate) rejection coverage. - All 2839 tests pass; lint clean; typecheck clean (modulo pre-existing dialog_evaluator warning). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/conductor/cli/app.py | 51 +++-- src/conductor/cli/run.py | 20 +- src/conductor/config/schema.py | 11 +- src/conductor/config/validator.py | 24 +- src/conductor/engine/workflow.py | 65 +++++- src/conductor/exceptions.py | 105 +++++++-- tests/test_cli/test_run.py | 92 ++++++-- tests/test_config/test_schema.py | 26 ++- tests/test_engine/test_subworkflow.py | 221 +++++++++++++++++- tests/test_engine/test_workflow.py | 315 ++++++++++++++++++++++++++ 10 files changed, 851 insertions(+), 79 deletions(-) diff --git a/src/conductor/cli/app.py b/src/conductor/cli/app.py index d0be5024..f67d0943 100644 --- a/src/conductor/cli/app.py +++ b/src/conductor/cli/app.py @@ -18,6 +18,7 @@ from rich.text import Text from conductor import __version__ +from conductor.exceptions import WorkflowTerminated logger = logging.getLogger(__name__) @@ -468,16 +469,28 @@ def run( # Output as JSON to stdout output_console.print_json(json.dumps(result)) + except WorkflowTerminated as e: + # Explicit `type: terminate` with `status: failed`. Print the + # rendered final output so downstream tooling can read it, surface + # the reason (and optional suggestion) as a user-facing message, + # then exit non-zero. `default=str` keeps the JSON dump robust + # against any output value that isn't directly JSON-serialisable — + # today everything goes through `_maybe_parse_json` so it round- + # trips, but a future custom Jinja filter or output_template + # transform could produce a non-trivial Python object that would + # otherwise crash the CLI here and lose the termination message. + try: + output_console.print_json(json.dumps(e.output, default=str)) + except (TypeError, ValueError) as json_exc: + logger.exception("Failed to serialise terminate output") + console.print( + f"[yellow]Warning:[/yellow] could not serialise terminate output: {json_exc}" + ) + console.print(f"[red]Workflow terminated[/red] at '{e.terminated_by}': {e.reason}") + if e.suggestion: + console.print(f"[dim]Suggestion: {e.suggestion}[/dim]") + raise typer.Exit(code=1) from None except Exception as e: - from conductor.exceptions import WorkflowTerminated - - if isinstance(e, WorkflowTerminated): - # Explicit `type: terminate` with `status: failed`. Print the - # rendered final output so downstream tooling can read it, surface - # the reason as a user-facing message, then exit non-zero. - output_console.print_json(json.dumps(e.output)) - console.print(f"[red]Workflow terminated[/red] at '{e.terminated_by}': {e.reason}") - raise typer.Exit(code=1) from None print_error(e) raise typer.Exit(code=1) from None @@ -885,13 +898,21 @@ def resume( # Output as JSON to stdout output_console.print_json(json.dumps(result)) + except WorkflowTerminated as e: + # Mirror of the `run` handler — see commentary there for the + # `default=str` and `try/except` rationale. + try: + output_console.print_json(json.dumps(e.output, default=str)) + except (TypeError, ValueError) as json_exc: + logger.exception("Failed to serialise terminate output") + console.print( + f"[yellow]Warning:[/yellow] could not serialise terminate output: {json_exc}" + ) + console.print(f"[red]Workflow terminated[/red] at '{e.terminated_by}': {e.reason}") + if e.suggestion: + console.print(f"[dim]Suggestion: {e.suggestion}[/dim]") + raise typer.Exit(code=1) from None except Exception as e: - from conductor.exceptions import WorkflowTerminated - - if isinstance(e, WorkflowTerminated): - output_console.print_json(json.dumps(e.output)) - console.print(f"[red]Workflow terminated[/red] at '{e.terminated_by}': {e.reason}") - raise typer.Exit(code=1) from None print_error(e) raise typer.Exit(code=1) from None diff --git a/src/conductor/cli/run.py b/src/conductor/cli/run.py index b0e30fba..cb51a1b8 100644 --- a/src/conductor/cli/run.py +++ b/src/conductor/cli/run.py @@ -1345,8 +1345,15 @@ async def run_workflow_async( result = await _run_with_stop_signal(engine, inputs, dashboard) except WorkflowTerminated: - # Explicit `type: terminate status: failed` — no resume hint - # because this is an intentional, non-resumable outcome. + # Defense-in-depth: `_print_resume_instructions` already early- + # returns when no checkpoint was saved, and the engine skips + # the on-failure checkpoint save for `WorkflowTerminated` — + # so the hint wouldn't print today regardless. Catching the + # exception explicitly here makes the intent ("never resume an + # explicit termination") visible at the CLI layer, so a future + # refactor of either `_print_resume_instructions` or the + # engine's checkpoint policy cannot accidentally start + # surfacing a misleading "resume?" hint for intentional exits. raise except BaseException: _print_resume_instructions(engine) @@ -1916,8 +1923,13 @@ async def resume_workflow_async( result = await _resume_with_stop_signal(engine, cp.current_agent, dashboard) except WorkflowTerminated: - # Explicit `type: terminate status: failed` — no resume hint - # because this is an intentional, non-resumable outcome. + # Defense-in-depth: see the matching arm in + # `run_workflow_async` for the full rationale. In short, + # `_print_resume_instructions` is already a no-op when no + # checkpoint was saved (which is the case for an explicit + # termination), but pinning that contract at the CLI layer + # protects against future drift in either the helper or the + # engine's checkpoint policy. raise except BaseException: _print_resume_instructions(engine) diff --git a/src/conductor/config/schema.py b/src/conductor/config/schema.py index effc1638..81b200c5 100644 --- a/src/conductor/config/schema.py +++ b/src/conductor/config/schema.py @@ -781,12 +781,21 @@ class AgentDef(BaseModel): ``status`` / ``reason``). When omitted, the workflow-level ``output:`` mapping is rendered as usual. + Each rendered value is then passed through the engine's JSON-coercion + helper before being placed in the final output dict: literal strings + ``"true"`` / ``"false"`` become Python booleans, numeric strings become + ``int`` / ``float``, and strings that parse as JSON objects/arrays are + deserialised. This matches the behaviour of workflow-level ``output:`` + and route output transforms, but it means the example below produces + ``{"aborted": True, "stage": "precheck", ...}`` — not all-string values. + Quote with backslashes if you genuinely want the literal text ``"true"``. + Forbidden on all step types other than ``terminate``. Example YAML:: output_template: - aborted: "true" + aborted: "true" # rendered to Python True stage: precheck reason: "{{ precheck.output.reason }}" """ diff --git a/src/conductor/config/validator.py b/src/conductor/config/validator.py index 04b0f7ea..e807068a 100644 --- a/src/conductor/config/validator.py +++ b/src/conductor/config/validator.py @@ -1027,16 +1027,20 @@ def _collect_template_strings( # Terminate steps: validate `reason` and `output_template` like other # Jinja2-rendered fields so bad refs fail at validate-time, not runtime. - # `getattr` matches the duck-typed-agent path used by - # `TestInputMappingTemplateCollection` (mirrors the `input_mapping` - # forward-compatibility shim above). - if getattr(agent, "type", None) == "terminate": - reason = getattr(agent, "reason", None) - if reason: - templates.append((f"agent '{agent.name}' reason", reason)) - output_template: dict[str, str] | None = getattr(agent, "output_template", None) - if output_template: - for key, expr in output_template.items(): + # Use a runtime-imported `AgentDef` isinstance check (NOT `getattr`) so a + # future rename of `AgentDef.type` / `.reason` / `.output_template` + # surfaces as an `AttributeError` here instead of silently skipping + # template validation. Duck-typed agent objects (the only callers using + # `SimpleNamespace`-style stubs are forward-compat tests like + # `TestInputMappingTemplateCollection`) never set `type="terminate"`, so + # they don't enter this branch and don't need the `getattr` fallback. + from conductor.config.schema import AgentDef as _AgentDef + + if isinstance(agent, _AgentDef) and agent.type == "terminate": + if agent.reason is not None: + templates.append((f"agent '{agent.name}' reason", agent.reason)) + if agent.output_template: + for key, expr in agent.output_template.items(): templates.append((f"agent '{agent.name}' output_template.{key}", expr)) return templates diff --git a/src/conductor/engine/workflow.py b/src/conductor/engine/workflow.py index f0e97887..f0f798c3 100644 --- a/src/conductor/engine/workflow.py +++ b/src/conductor/engine/workflow.py @@ -32,6 +32,7 @@ ExecutionError, InterruptError, MaxIterationsError, + SubworkflowTerminatedError, ValidationError, WorkflowTerminated, ) @@ -1397,6 +1398,17 @@ async def _run_child_engine( ``subworkflow_failed`` event fires and the parent's outer error handling treats it like any other ``ExecutionError``. + The child's rendered output dict (from ``output_template:`` or the + child workflow's ``output:`` mapping) is preserved on the raised + :class:`ExecutionError` as the ``terminated_output`` attribute so + debuggers, on_error hooks, and CLI surfaces can inspect what the + child intended to emit. The child's reason is also embedded in the + exception message for human-readable diagnostics. We deliberately do + NOT merge ``terminated_output`` into the parent's context — that + would let parent routes accidentally branch on a child's + "i was failing" payload (use ``status: success`` + ``output_template`` + for that pattern). + Successful terminations inside a child propagate normally: the child returns its rendered output dict and the parent continues. @@ -1412,7 +1424,14 @@ async def _run_child_engine( try: return await child_engine.run(sub_inputs) except WorkflowTerminated as exc: - raise ExecutionError( + # Convert to SubworkflowTerminatedError so the parent's outer + # handler treats this as a normal sub-workflow failure (parent's + # own `workflow_failed` does NOT carry `is_explicit: true`). The + # child's rendered output / reason / terminate-step name are + # preserved as structured attributes on the wrapper so on_error + # hooks, debugging surfaces, and the CLI can inspect them without + # walking ``__cause__``. + raise SubworkflowTerminatedError( f"Sub-workflow '{agent.workflow}' (agent '{agent.name}') " f"terminated explicitly: {exc.reason}", suggestion=( @@ -1423,6 +1442,9 @@ async def _run_child_engine( "`output_template:`." ), agent_name=agent.name, + terminated_output=exc.output, + terminated_reason=exc.reason, + terminated_by=exc.terminated_by, ) from exc async def _get_provider_for_agent(self, agent: AgentDef) -> AgentProvider | None: @@ -2333,8 +2355,11 @@ async def _execute_loop(self, current_agent_name: str) -> dict[str, Any]: # Handle terminate steps — explicit workflow exit with a # structured reason and status. Reached via a normal - # route from any upstream agent/group; the engine ends - # the workflow immediately (no routes evaluated after). + # route from any upstream agent/group, OR as the + # workflow's `entry_point` (a workflow whose first step + # is a terminate ends immediately on dispatch). The + # engine ends the workflow on this branch — no routes + # evaluated after. if agent.type == "terminate": terminate_elapsed = _time.time() - _workflow_start agent_context = self.context.build_for_agent( @@ -2351,8 +2376,8 @@ async def _execute_loop(self, current_agent_name: str) -> dict[str, Any]: ) # Store the terminate step's own context entry # BEFORE building the final output so workflow.output - # templates can reference {{ .reason }} / - # {{ .status }} if desired. + # templates can reference {{ .output.reason }} + # / {{ .output.status }} if desired. self.context.store( agent.name, { @@ -2361,14 +2386,38 @@ async def _execute_loop(self, current_agent_name: str) -> dict[str, Any]: "terminated_by": agent.name, }, ) - self.limits.record_execution(agent.name) + # check_timeout before record_execution so a + # workflow that has exhausted its iteration budget + # exactly at this terminate step cannot mask the + # user's explicit termination behind a + # MaxIterationsError from record_execution. self.limits.check_timeout() + self.limits.record_execution(agent.name) # Build the final output: prefer output_template # when set (replaces workflow-level output:); # otherwise fall back to the workflow's output: - # mapping rendered as usual. - output = self._build_terminate_output(agent) + # mapping rendered as usual. A template error here + # must surface through `agent_failed` so the + # dashboard / JSONL log records a resolved + # lifecycle for the terminate step rather than + # leaving it visually "in flight". + try: + output = self._build_terminate_output(agent) + except Exception as exc: + self._emit( + "agent_failed", + { + "agent_name": agent.name, + "elapsed": _time.time() + - _workflow_start + - terminate_elapsed, + "agent_type": "terminate", + "error_type": type(exc).__name__, + "message": str(exc), + }, + ) + raise termination_meta = { "termination_reason": rendered_reason, diff --git a/src/conductor/exceptions.py b/src/conductor/exceptions.py index c8830c99..f8b83076 100644 --- a/src/conductor/exceptions.py +++ b/src/conductor/exceptions.py @@ -7,6 +7,8 @@ from __future__ import annotations +from typing import Any + class ConductorError(Exception): """Base exception for all Conductor errors. @@ -519,27 +521,31 @@ class WorkflowTerminated(ExecutionError): the rendered output, reason, and the name of the terminate step that fired so the CLI, event consumers, and dashboard can distinguish it from generic errors. - The engine emits ``workflow_failed`` with ``is_explicit: True`` for this path - and intentionally skips checkpoint creation: an explicit termination is not a - resumable failure. + The engine's top-level ``except WorkflowTerminated`` handler emits + ``workflow_failed`` with ``is_explicit: True`` for this exception and + intentionally skips checkpoint creation. The skip is a property of the + handler, not of the type — a future refactor that moves checkpointing into + a nested handler would need to preserve that contract. Attributes: output: The rendered final output dict (from ``output_template`` if provided, else the workflow-level ``output:`` mapping). reason: The rendered termination reason (Jinja2-resolved against context). - terminated_by: The ``name`` of the terminate step that fired. - status: Always ``"failed"`` (success terminations return normally and do - not raise). + terminated_by: Alias for ``agent_name`` — the ``name`` of the terminate + step that fired. Exposed as a property over ``agent_name`` so the + two cannot drift apart. + status: Always the string ``"failed"``. Successful terminations return + from :meth:`WorkflowEngine.run` cleanly and do not raise, so this + exception only ever represents the failed-termination branch. """ def __init__( self, message: str, *, - output: dict, + output: dict[str, Any], reason: str, terminated_by: str, - status: str = "failed", suggestion: str | None = None, ) -> None: """Initialize a WorkflowTerminated exception. @@ -549,17 +555,90 @@ def __init__( rendered ``reason``). output: The rendered final output dict for the workflow. reason: The rendered termination reason. - terminated_by: Name of the terminate step that fired. - status: Always ``"failed"`` — kept as a parameter for forward - compatibility if non-binary statuses are ever added. + terminated_by: Name of the terminate step that fired. Stored on the + base class as ``agent_name``; exposed here via the + :attr:`terminated_by` property so both names point at the same + underlying value. suggestion: Optional advice for resolving the termination. """ self.output = output self.reason = reason - self.terminated_by = terminated_by - self.status = status super().__init__(message, suggestion=suggestion, agent_name=terminated_by) + @property + def terminated_by(self) -> str: + """Name of the terminate step that fired (alias for ``agent_name``).""" + # Stored on the base class to keep one source of truth — both `agent_name` + # (used by generic ConductorError consumers) and `terminated_by` (used by + # terminate-specific code paths) MUST agree. A property guarantees that. + return self.agent_name or "" + + @property + def status(self) -> str: + """Always ``"failed"``; success terminations return without raising. + + Kept as an attribute (rather than a constant) so call sites that want + to log or serialise the termination status have a single API regardless + of whether the engine introduces additional non-binary statuses in the + future. Today the value is invariantly ``"failed"``. + """ + return "failed" + + +class SubworkflowTerminatedError(ExecutionError): + """Wraps a child sub-workflow's :class:`WorkflowTerminated` at the parent boundary. + + When a child sub-workflow ends with ``type: terminate, status: failed``, + its :class:`WorkflowTerminated` is converted to this error before + propagating to the parent. The conversion serves two goals: + + 1. The parent's outer exception handler treats this as a normal + sub-workflow failure (parent ``workflow_failed`` does not inherit + ``is_explicit: true``) because the parent author did not opt into + explicit termination — the child did. + 2. The structured payload the child built (its rendered ``output_template`` + dict, the rendered reason, the terminate step's name) is preserved on + the wrapper so on_error hooks, debugging surfaces, and the CLI can + inspect it without walking ``__cause__``. + + Attributes: + terminated_output: The child's rendered final-output dict (from the + child's ``output_template:`` or its ``output:`` mapping). + terminated_reason: The child's rendered termination reason. + terminated_by: The ``name`` of the terminate step inside the child + workflow that fired. (Distinct from ``agent_name``, which is the + parent's ``type: workflow`` agent that invoked the child.) + """ + + def __init__( + self, + message: str, + *, + terminated_output: dict[str, Any], + terminated_reason: str, + terminated_by: str, + suggestion: str | None = None, + agent_name: str | None = None, + ) -> None: + """Initialize a SubworkflowTerminatedError. + + Args: + message: Human-readable description of the boundary downgrade. + terminated_output: The child's rendered final-output dict. + terminated_reason: The child's rendered termination reason. + terminated_by: Name of the terminate step inside the child + workflow that fired. + suggestion: Optional advice for resolving the failure. + agent_name: Name of the parent's ``type: workflow`` agent that + invoked the child (set on the base class so generic + ``ExecutionError`` consumers see the parent's agent name, + not the child's). + """ + self.terminated_output = terminated_output + self.terminated_reason = terminated_reason + self.terminated_by = terminated_by + super().__init__(message, suggestion=suggestion, agent_name=agent_name) + class InterruptError(ExecutionError): """Raised when the user stops a workflow via the interrupt menu. diff --git a/tests/test_cli/test_run.py b/tests/test_cli/test_run.py index f5a2fdc6..d174d83d 100644 --- a/tests/test_cli/test_run.py +++ b/tests/test_cli/test_run.py @@ -992,9 +992,15 @@ class TestRunCommandTerminate: workflow ends via ``terminate status: failed``, plus a user-facing message naming the step that fired and the rendered reason. - These tests patch ``run_workflow_async`` so we exercise only the - exit-code / stdout / stderr wiring; engine semantics are covered in + These tests patch ``run_workflow_async`` (or ``resume_workflow_async``) + so we exercise only the exit-code / stdout / stderr wiring; engine + semantics are covered in ``tests/test_engine/test_workflow.py::TestWorkflowEngineTerminate``. + + ``CliRunner`` in Click 8+ exposes separate ``result.stdout`` / + ``result.stderr`` attributes, so we can assert "JSON on stdout, banner + on stderr" precisely. A regression that flipped the streams would + pass any test that asserts only on ``result.output`` (the merged form). """ def test_run_success_terminate_exits_zero_and_prints_output(self, tmp_path: Path) -> None: @@ -1020,11 +1026,10 @@ def test_run_success_terminate_exits_zero_and_prints_output(self, tmp_path: Path result = runner.invoke(app, ["run", str(workflow_file)]) - assert result.exit_code == 0, result.output - # Output JSON should be present (Rich's `print_json` colors it; check - # the structural pieces are there rather than parsing). - assert '"result"' in result.output - assert '"no-op"' in result.output + assert result.exit_code == 0, (result.stdout, result.stderr) + # JSON must be on stdout where downstream tooling reads it. + assert '"result"' in result.stdout + assert '"no-op"' in result.stdout def test_run_failed_terminate_exits_nonzero_and_prints_output_and_reason( self, tmp_path: Path @@ -1033,7 +1038,8 @@ def test_run_failed_terminate_exits_nonzero_and_prints_output_and_reason( Downstream tooling (CI scripts, dashboards) reads the JSON from stdout regardless of exit code; humans read the reason from stderr. Both - must be present. + streams must be exercised separately so a regression flipping them + cannot pass silently. """ from conductor.exceptions import WorkflowTerminated @@ -1061,13 +1067,13 @@ def test_run_failed_terminate_exits_nonzero_and_prints_output_and_reason( result = runner.invoke(app, ["run", str(workflow_file)]) - assert result.exit_code == 1, result.output - # Rendered output JSON is on stdout for tooling. - assert '"aborted"' in result.output - # Reason + step name on stderr (Rich routes the warning through the - # error console). CliRunner mixes stdout/stderr so look in `output`. - assert "unsafe input" in result.output - assert "bye" in result.output + assert result.exit_code == 1, (result.stdout, result.stderr) + # JSON on stdout (for `conductor run ... | jq` style consumers). + assert '"aborted"' in result.stdout + # Human-readable reason + step name on stderr (Rich's error console + # is wired to stderr in app.py). + assert "unsafe input" in result.stderr + assert "bye" in result.stderr def test_run_failed_terminate_does_not_print_generic_error_panel(self, tmp_path: Path) -> None: """The dedicated handler must short-circuit `print_error`. @@ -1075,6 +1081,10 @@ def test_run_failed_terminate_does_not_print_generic_error_panel(self, tmp_path: Without this, the user would see the standard exception panel ("ExecutionError: ...") instead of the explicit termination message, making the terminate feature indistinguishable from a generic crash. + Positive assertion (terminate banner is present) AND negative + assertion (generic panel is absent) — both are required because the + generic panel's format string could change without breaking either + assertion alone. """ from conductor.exceptions import WorkflowTerminated @@ -1100,8 +1110,50 @@ def test_run_failed_terminate_does_not_print_generic_error_panel(self, tmp_path: result = runner.invoke(app, ["run", str(workflow_file)]) - assert result.exit_code == 1, result.output - # The standard error panel formats as "Error: WorkflowTerminated" - # via print_error -> format_error. The dedicated handler should - # NOT produce that — instead, a single-line red message. - assert "Error: WorkflowTerminated" not in result.output + assert result.exit_code == 1, (result.stdout, result.stderr) + # Dedicated terminate banner — must be present. + assert "Workflow terminated" in result.stderr + # Generic error panel must NOT be present. + assert "Error: WorkflowTerminated" not in result.stderr + + def test_resume_failed_terminate_exits_nonzero_and_prints_output(self, tmp_path: Path) -> None: + """`resume` mirrors `run`'s WorkflowTerminated handling. + + Without parity coverage on the `resume` command, a refactor that drops + the handler from `app.py:resume` would ship silently — and users who + resume a workflow that ends on `type: terminate, status: failed` + would see a generic exception panel instead of structured output + + reason. + """ + from conductor.exceptions import WorkflowTerminated + + workflow_file = tmp_path / "wf.yaml" + workflow_file.write_text("""\ +workflow: + name: t + entry_point: bye +agents: + - name: bye + type: terminate + status: failed + reason: "resume terminated" +output: {} +""") + # Patch `resume_workflow_async` itself — `conductor resume` calls it + # inside an `asyncio.run` wrapper inside the try/except we are + # exercising. The exception propagates out and the app.py:resume + # handler kicks in. + with patch("conductor.cli.run.resume_workflow_async") as mock_resume: + mock_resume.side_effect = WorkflowTerminated( + "resume terminated", + output={"on_resume": "stopped"}, + reason="resume terminated", + terminated_by="bye", + ) + result = runner.invoke(app, ["resume", str(workflow_file)]) + + assert result.exit_code == 1, (result.stdout, result.stderr) + assert '"on_resume"' in result.stdout + assert "Workflow terminated" in result.stderr + assert "resume terminated" in result.stderr + assert "bye" in result.stderr diff --git a/tests/test_config/test_schema.py b/tests/test_config/test_schema.py index 68be5e2c..640c58f2 100644 --- a/tests/test_config/test_schema.py +++ b/tests/test_config/test_schema.py @@ -1652,8 +1652,26 @@ def test_terminate_fields_rejected_on_regular_agent(self, forbidden_field: str) assert forbidden_field in str(exc_info.value) @pytest.mark.parametrize("step_type", ["script", "workflow", "human_gate"]) - def test_terminate_fields_rejected_on_other_step_types(self, step_type: str) -> None: - """The terminate-only-fields guard must trip for every non-terminate type.""" + @pytest.mark.parametrize( + "forbidden_field,field_value", + [ + ("status", "success"), + ("reason", "halt"), + ("output_template", {"k": "{{ a.output }}"}), + ], + ) + def test_terminate_fields_rejected_on_other_step_types( + self, step_type: str, forbidden_field: str, field_value: object + ) -> None: + """The terminate-only-fields guard must trip for every non-terminate type + and every terminate-exclusive field — not just `status`. + + Earlier iteration of this test only varied ``step_type`` and asserted on + ``status``. A bug in ``validate_agent_type`` that, say, rejected only + ``status`` on ``script`` agents but silently accepted ``reason`` and + ``output_template`` would have slipped through. Cross-product the + parametrisation so every (step_type, terminate-field) pair is exercised. + """ payload: dict[str, object] = {"name": "a", "type": step_type} if step_type == "script": payload["command"] = "echo" @@ -1662,10 +1680,10 @@ def test_terminate_fields_rejected_on_other_step_types(self, step_type: str) -> elif step_type == "human_gate": payload["prompt"] = "Pick" payload["options"] = [GateOption(value="x", label="X", route="$end")] - payload["status"] = "success" + payload[forbidden_field] = field_value with pytest.raises(ValidationError) as exc_info: AgentDef.model_validate(payload) - assert "status" in str(exc_info.value) + assert forbidden_field in str(exc_info.value) def test_input_allowed_on_terminate(self) -> None: """Terminate steps may declare context inputs to drive Jinja rendering.""" diff --git a/tests/test_engine/test_subworkflow.py b/tests/test_engine/test_subworkflow.py index 0dd01e71..dbeb498c 100644 --- a/tests/test_engine/test_subworkflow.py +++ b/tests/test_engine/test_subworkflow.py @@ -22,7 +22,9 @@ from conductor.config.schema import ( AgentDef, ContextConfig, + InputDef, LimitsConfig, + OutputField, RouteDef, RuntimeConfig, WorkflowConfig, @@ -2274,6 +2276,28 @@ async def test_child_failed_terminate_surfaces_as_execution_error( assert "Child refused to run." in str(excinfo.value) assert "research" in str(excinfo.value) + # The downgrade must produce a plain ExecutionError, NOT pass through + # a WorkflowTerminated subtype. Without this assertion the existing + # `pytest.raises(ExecutionError)` would pass even if the boundary + # conversion silently leaked a child's WorkflowTerminated (which IS + # an ExecutionError subclass) to the parent. + from conductor.exceptions import WorkflowTerminated + + assert not isinstance(excinfo.value, WorkflowTerminated), ( + "boundary downgrade must convert WorkflowTerminated to plain ExecutionError" + ) + + # The child's rendered output must be preserved as an attribute on + # the downgraded error so on_error hooks and debugging surfaces can + # inspect what the child intended to emit (see issue #219 PR review: + # "child sub-workflow's `output` dict is silently discarded"). + assert hasattr(excinfo.value, "terminated_output"), ( + "downgraded ExecutionError must carry `terminated_output` attribute" + ) + assert excinfo.value.terminated_output == {} + assert excinfo.value.terminated_reason == "Child refused to run." + assert excinfo.value.terminated_by == "abort" + # subworkflow_failed must fire so the dashboard shows the child as failed. assert any(e.type == "subworkflow_failed" for e in events), ( f"expected subworkflow_failed; got {[e.type for e in events]}" @@ -2291,9 +2315,198 @@ async def test_child_failed_terminate_surfaces_as_execution_error( f"parent must not inherit is_explicit from child terminate; got: " f"{[e.data for e in outer]}" ) - # Parent's error_type should be ExecutionError — child's termination - # is downgraded at the boundary so the parent treats it normally. - assert all(e.data.get("error_type") == "ExecutionError" for e in outer), ( - f"parent error_type should be ExecutionError; got: " + # Parent's error_type should be SubworkflowTerminatedError — child's + # termination is downgraded at the boundary so the parent treats it + # normally. SubworkflowTerminatedError IS-A ExecutionError so the + # outer ConductorError handler picks it up via the same code path as + # any other sub-workflow failure, but the distinct class name makes + # the cause visible to event consumers. + assert all( + e.data.get("error_type") == "SubworkflowTerminatedError" for e in outer + ), ( + f"parent error_type should be SubworkflowTerminatedError; got: " f"{[e.data.get('error_type') for e in outer]}" ) + + @pytest.mark.asyncio + async def test_child_failed_terminate_preserves_output_dict( + self, tmp_workflow_dir: Path + ) -> None: + """The child's rendered `output_template` is preserved across the boundary. + + The boundary downgrade in `_run_child_engine` attaches the child's + rendered output to the converted ExecutionError as + `terminated_output`. Without this, parent debugging surfaces lose + every structured field the child author put in `output_template:` + — defeating the point of having `output_template` on a failed + terminate at all. + """ + from conductor.exceptions import WorkflowTerminated + + _write_yaml( + tmp_workflow_dir / "sub.yaml", + """\ + workflow: + name: sub + entry_point: abort + runtime: + provider: copilot + limits: + max_iterations: 5 + agents: + - name: abort + type: terminate + status: failed + reason: "structured failure" + output_template: + error_code: "E_UPSTREAM" + retry_after: "60" + """, + ) + parent_path = tmp_workflow_dir / "parent.yaml" + parent_path.write_text("dummy", encoding="utf-8") + + config = WorkflowConfig( + workflow=WorkflowDef( + name="parent", + entry_point="research", + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=10), + ), + agents=[ + AgentDef( + name="research", + type="workflow", + workflow="sub.yaml", + routes=[RouteDef(to="$end")], + ), + ], + output={}, + ) + engine = WorkflowEngine(config, CopilotProvider(), workflow_path=parent_path) + + with pytest.raises(ExecutionError) as excinfo: + await engine.run({}) + + # Verify each structured field the child author set survives. + assert excinfo.value.terminated_output == { + "error_code": "E_UPSTREAM", + # `_maybe_parse_json` coerces "60" to int 60 — same shape as the + # child engine would have returned to the parent on success. + "retry_after": 60, + } + assert excinfo.value.terminated_reason == "structured failure" + # The original WorkflowTerminated is preserved on __cause__ for any + # consumer that wants the full chain. + assert isinstance(excinfo.value.__cause__, WorkflowTerminated) + assert excinfo.value.__cause__.output == { + "error_code": "E_UPSTREAM", + "retry_after": 60, + } + + @pytest.mark.asyncio + async def test_failed_terminate_in_for_each_workflow_iteration( + self, tmp_workflow_dir: Path + ) -> None: + """The for_each-of-workflow path (`_execute_subworkflow_with_inputs`) downgrades too. + + The original PR routed both sub-workflow execution helpers through + `_run_child_engine`, but the original test suite only exercised the + sequential `_execute_subworkflow` path. This test drives the + per-iteration `_execute_subworkflow_with_inputs` path with a + failed-terminate child to verify the boundary downgrade applies + there too. + """ + from conductor.exceptions import WorkflowTerminated + + _write_yaml( + tmp_workflow_dir / "sub.yaml", + """\ + workflow: + name: sub + entry_point: bail + input: + item: + type: string + required: true + runtime: + provider: copilot + limits: + max_iterations: 5 + agents: + - name: bail + type: terminate + status: failed + reason: "iteration {{ workflow.input.item }} failed" + output_template: + failed_item: "{{ workflow.input.item }}" + """, + ) + parent_path = tmp_workflow_dir / "parent.yaml" + parent_path.write_text("dummy", encoding="utf-8") + + # for_each over a list of inputs, each iteration runs the sub-workflow. + # The first iteration's failed-terminate is what we expect to bubble + # up (fail_fast is the default). + from conductor.config.schema import ForEachDef + + config = WorkflowConfig( + workflow=WorkflowDef( + name="parent", + entry_point="finder", + input={"items": InputDef(type="array", default=["x", "y"])}, + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=20), + ), + agents=[ + AgentDef( + name="finder", + model="gpt-4", + prompt="x", + output={"items": OutputField(type="array")}, + routes=[RouteDef(to="loop")], + ), + ], + for_each=[ + ForEachDef.model_validate( + { + "name": "loop", + "type": "for_each", + "source": "finder.output.items", + "as": "item", + "agent": AgentDef( + name="child", + type="workflow", + workflow="sub.yaml", + input_mapping={"item": "{{ item }}"}, + ), + "failure_mode": "fail_fast", + "routes": [RouteDef(to="$end")], + } + ), + ], + output={}, + ) + + provider = CopilotProvider(mock_handler=lambda *_a, **_kw: {"items": ["x", "y"]}) + engine = WorkflowEngine(config, provider, workflow_path=parent_path) + + # The first iteration's failed-terminate must downgrade to + # ExecutionError (NOT propagate as WorkflowTerminated through the + # for_each gather). The downgraded error must carry the child's + # rendered output_template. + with pytest.raises(ExecutionError) as excinfo: + await engine.run({}) + + assert not isinstance(excinfo.value, WorkflowTerminated), ( + "for_each-of-workflow boundary must downgrade child WorkflowTerminated" + ) + # `terminated_output` may or may not be present depending on whether + # for_each wraps the ExecutionError further; assert at minimum that + # the reason text from the failed iteration is in the error chain. + message = str(excinfo.value) + assert "iteration x failed" in message or "iteration y failed" in message, ( + f"expected child reason in error chain; got: {message}" + ) diff --git a/tests/test_engine/test_workflow.py b/tests/test_engine/test_workflow.py index 291b195d..6f8b51ea 100644 --- a/tests/test_engine/test_workflow.py +++ b/tests/test_engine/test_workflow.py @@ -17,6 +17,7 @@ AgentDef, ContextConfig, GateOption, + HooksConfig, InputDef, LimitsConfig, OutputField, @@ -3030,3 +3031,317 @@ async def test_terminate_with_input_declared(self) -> None: engine = WorkflowEngine(config, provider) result = await engine.run({}) assert result == {"echo": "VAL"} + + +class TestWorkflowEngineTerminateAdditionalScenarios: + """Additional terminate-step engine coverage (issue #219). + + The base class above covers single-agent → terminate sequences. These + tests exercise the corners surfaced during PR review: + + - Terminate as the workflow entry point (the dispatch path runs without + any upstream context). + - Terminate as a route target from a parallel group's routes and from a + for_each group's routes (the main routing loop must dispatch to the + terminate branch after the group completes). + - Lifecycle hooks (``on_complete`` for success, ``on_error`` for failed) + fire with the right arguments. + """ + + @pytest.mark.asyncio + async def test_terminate_as_entry_point(self) -> None: + """Workflow whose `entry_point` IS a terminate step ends immediately. + + Schema validation allows this; this test pins the engine actually + dispatches it correctly when there is no upstream agent context to + accumulate before the terminate branch runs. + """ + from conductor.events import WorkflowEvent, WorkflowEventEmitter + + config = WorkflowConfig( + workflow=WorkflowDef( + name="entry-terminate", + entry_point="bye", + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=5), + ), + agents=[ + AgentDef( + name="bye", + type="terminate", + status="success", + reason="nothing to do", + output_template={"result": "no-op"}, + ), + ], + output={}, + ) + events: list[WorkflowEvent] = [] + emitter = WorkflowEventEmitter() + emitter.subscribe(events.append) + engine = WorkflowEngine(config, CopilotProvider(), event_emitter=emitter) + + result = await engine.run({}) + + assert result == {"result": "no-op"} + completed = [e for e in events if e.type == "workflow_completed"] + assert len(completed) == 1 + assert completed[0].data["terminated_by"] == "bye" + + @pytest.mark.asyncio + async def test_terminate_routed_from_parallel_group(self) -> None: + """A parallel-group route may target a terminate step. + + The main routing loop dispatches the terminate step after the group + completes; without this coverage a refactor of the parallel-group + post-execution dispatch could silently break that hop. + """ + from conductor.events import WorkflowEvent, WorkflowEventEmitter + + config = WorkflowConfig( + workflow=WorkflowDef( + name="par-terminate", + entry_point="group", + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=10), + ), + agents=[ + AgentDef( + name="a", + model="gpt-4", + prompt="a", + output={"x": OutputField(type="string")}, + ), + AgentDef( + name="b", + model="gpt-4", + prompt="b", + output={"y": OutputField(type="string")}, + ), + AgentDef( + name="finish", + type="terminate", + status="success", + reason="parallel branches done", + output_template={"result": "from-parallel"}, + ), + ], + parallel=[ + ParallelGroup( + name="group", + agents=["a", "b"], + routes=[RouteDef(to="finish")], + ), + ], + output={}, + ) + + provider = CopilotProvider( + mock_handler=lambda agent, *_a, **_kw: {"x": "ax"} if agent.name == "a" else {"y": "by"} + ) + events: list[WorkflowEvent] = [] + emitter = WorkflowEventEmitter() + emitter.subscribe(events.append) + + engine = WorkflowEngine(config, provider, event_emitter=emitter) + result = await engine.run({}) + + assert result == {"result": "from-parallel"} + # Verify the dispatch hop: a `route_taken` event must show + # group → finish, and the terminate completion must follow. + route_events = [ + e for e in events if e.type == "route_taken" and e.data.get("from_agent") == "group" + ] + assert route_events, f"expected route_taken from group; got {[e.type for e in events]}" + assert route_events[0].data["to_agent"] == "finish" + + @pytest.mark.asyncio + async def test_terminate_routed_from_for_each_group(self) -> None: + """A for_each-group route may target a terminate step.""" + from conductor.config.schema import ForEachDef + + config = WorkflowConfig( + workflow=WorkflowDef( + name="fe-terminate", + entry_point="finder", + input={"items": InputDef(type="array", default=["a", "b"])}, + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=20), + ), + agents=[ + AgentDef( + name="finder", + model="gpt-4", + prompt="x", + output={"items": OutputField(type="array")}, + routes=[RouteDef(to="loop")], + ), + AgentDef( + name="finish", + type="terminate", + status="success", + reason="for_each done", + output_template={"result": "from-for-each"}, + ), + ], + for_each=[ + ForEachDef.model_validate( + { + "name": "loop", + "type": "for_each", + "source": "finder.output.items", + "as": "item", + "agent": AgentDef( + name="worker", + model="gpt-4", + prompt="process {{ item }}", + output={"r": OutputField(type="string")}, + ), + "routes": [RouteDef(to="finish")], + } + ), + ], + output={}, + ) + + def mock_handler(agent, *_a, **_kw): + if agent.name == "finder": + return {"items": ["a", "b"]} + return {"r": "ok"} + + provider = CopilotProvider(mock_handler=mock_handler) + engine = WorkflowEngine(config, provider) + result = await engine.run({}) + assert result == {"result": "from-for-each"} + + @pytest.mark.asyncio + async def test_on_complete_hook_fires_for_success_terminate(self) -> None: + """`on_complete` hook must fire when a terminate step ends with success. + + Hooks are a public extension point; a refactor that dropped the + `_execute_hook("on_complete", ...)` call from the success-terminate + branch would silently regress every workflow that relies on the + hook for completion notifications. + """ + from unittest.mock import patch as _patch + + config = WorkflowConfig( + workflow=WorkflowDef( + name="hook-success", + entry_point="bye", + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=5), + hooks=HooksConfig(on_complete="completed: {{ result }}"), + ), + agents=[ + AgentDef( + name="bye", + type="terminate", + status="success", + reason="all done", + output_template={"r": "ok"}, + ), + ], + output={}, + ) + engine = WorkflowEngine(config, CopilotProvider()) + with _patch.object(engine, "_execute_hook", wraps=engine._execute_hook) as spy: + result = await engine.run({}) + assert result == {"r": "ok"} + completion_calls = [ + call for call in spy.call_args_list if call.args and call.args[0] == "on_complete" + ] + assert len(completion_calls) == 1, ( + f"on_complete must fire exactly once; got: {spy.call_args_list}" + ) + # The hook must receive the rendered output dict, not a raw template. + assert completion_calls[0].kwargs.get("result") == {"r": "ok"} + + @pytest.mark.asyncio + async def test_on_error_hook_fires_for_failed_terminate(self) -> None: + """`on_error` hook must fire when a terminate step ends with failed. + + The hook receives the `WorkflowTerminated` exception so authors can + notify on the structured `reason`/`terminated_by` rather than a + generic error message. + """ + from unittest.mock import patch as _patch + + from conductor.exceptions import WorkflowTerminated + + config = WorkflowConfig( + workflow=WorkflowDef( + name="hook-error", + entry_point="abort", + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=5), + hooks=HooksConfig(on_error="failed: {{ error.message }}"), + ), + agents=[ + AgentDef( + name="abort", + type="terminate", + status="failed", + reason="halt", + ), + ], + output={}, + ) + engine = WorkflowEngine(config, CopilotProvider()) + with ( + _patch.object(engine, "_execute_hook", wraps=engine._execute_hook) as spy, + pytest.raises(WorkflowTerminated), + ): + await engine.run({}) + error_calls = [ + call for call in spy.call_args_list if call.args and call.args[0] == "on_error" + ] + assert len(error_calls) == 1, f"on_error must fire exactly once; got: {spy.call_args_list}" + passed_error = error_calls[0].kwargs.get("error") + assert isinstance(passed_error, WorkflowTerminated) + assert passed_error.reason == "halt" + assert passed_error.terminated_by == "abort" + + @pytest.mark.asyncio + async def test_lifecycle_event_ordering_failed_terminate(self) -> None: + """`agent_failed` must fire BEFORE `workflow_failed` for failed terminate. + + The dashboard's failure-counter UI relies on this ordering. Without + the ordering assertion, a refactor that reversed the emits (or + dropped `agent_failed`) would visually decouple agent and workflow + failure states in the dashboard. + """ + from conductor.events import WorkflowEvent, WorkflowEventEmitter + from conductor.exceptions import WorkflowTerminated + + config = WorkflowConfig( + workflow=WorkflowDef( + name="order-test", + entry_point="abort", + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=5), + ), + agents=[ + AgentDef(name="abort", type="terminate", status="failed", reason="halt"), + ], + output={}, + ) + events: list[WorkflowEvent] = [] + emitter = WorkflowEventEmitter() + emitter.subscribe(events.append) + engine = WorkflowEngine(config, CopilotProvider(), event_emitter=emitter) + with pytest.raises(WorkflowTerminated): + await engine.run({}) + + types_in_order = [e.type for e in events] + af_index = types_in_order.index("agent_failed") + wf_index = types_in_order.index("workflow_failed") + assert af_index < wf_index, ( + f"agent_failed must precede workflow_failed; got order: {types_in_order}" + ) From 43f5aff9a363076bf2cac4a09611ece64afd9fb4 Mon Sep 17 00:00:00 2001 From: Jason Robert Date: Thu, 21 May 2026 15:50:07 -0400 Subject: [PATCH 3/5] docs(terminate): document type: terminate across user-facing docs (#219) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Comprehensive documentation pass for the new `type: terminate` step. User-facing surfaces updated ---------------------------- - README.md: added Terminate steps to the features list and to the Examples table. - docs/workflow-syntax.md: new "Terminate Steps" section with example, behaviour table (status × CLI exit / dashboard / event / resumability), output-template rendering rules including JSON coercion, restrictions list, and sub-workflow boundary semantics. Updated the `type:` enum comment in the agent example. - docs/configuration.md: added `terminate` to the list of agent types where `reasoning.effort` is rejected (it doesn't call a model). - examples/README.md: added Explicit Termination section with all three paths (success, failed, normal) and `is_explicit: true` hint for CI / observability consumers. Conductor skill (AI-author-facing) updated ------------------------------------------ - plugins/conductor/skills/conductor/SKILL.md: added `type: terminate` row to the Key Concepts table. - plugins/conductor/skills/conductor/references/yaml-schema.md: added `terminate` to the type enum, added Terminate-only fields block, and added the full restrictions paragraph naming WorkflowTerminated / SubworkflowTerminatedError boundary semantics. - plugins/conductor/skills/conductor/references/authoring.md: new "Terminate Steps (`type: terminate`)" section with motivation (multiple legitimate end states beyond $end), full example, semantics, restrictions, and the parent-branching guidance (use `status: success` + `output_template:` if the parent needs to route on a child's outcome). Internal docs / inline updated ------------------------------ - AGENTS.md: expanded the existing one-liner bullet to mention `SubworkflowTerminatedError`, the JSON coercion behaviour, the hook firing contract, and pointers to the new docs. - CHANGELOG.md: Unreleased entry describing the feature in full detail (event payload, sub-workflow downgrade, schema rejection matrix, restrictions, link to issue #219). - src/conductor/config/schema.py: expanded `AgentDef` class docstring to enumerate all five step kinds and point at the per-type validator and the cross-cutting structural rules in validator.py. - tests/test_engine/test_subworkflow.py: ruff format tidy. Validation ---------- - make lint clean, make typecheck clean (modulo pre-existing dialog_evaluator warning), 1295 targeted tests pass, example workflow validates and runs both paths correctly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- AGENTS.md | 2 +- CHANGELOG.md | 31 +++++++++++ README.md | 5 ++ docs/configuration.md | 5 ++ docs/workflow-syntax.md | 54 ++++++++++++++++++- examples/README.md | 24 +++++++++ plugins/conductor/skills/conductor/SKILL.md | 1 + .../skills/conductor/references/authoring.md | 41 +++++++++++++- .../conductor/references/yaml-schema.md | 11 +++- src/conductor/config/schema.py | 31 ++++++++++- tests/test_engine/test_subworkflow.py | 4 +- 11 files changed, 201 insertions(+), 8 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 945a07a6..d14187e6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -134,7 +134,7 @@ make validate-examples # validate all examples - **Tool resolution**: `null` = all workflow tools, `[]` = none, `[list]` = subset - **Set step typing**: `output_type` defaults to `auto` (safe YAML parse with `_to_json_safe` normalisation — `datetime`/`date`/`time` → ISO 8601, non-string dict keys and other non-JSON-safe values raise `ExecutionError`). Explicit `string`/`number`/`integer`/`boolean`/`list`/`dict` only valid on single `value:`. `WorkflowContext.store` accepts any JSON-safe value (scalars/lists from `set` steps in addition to the dicts produced by LLM / script / gate / parallel-group outputs); `_add_agent_input` returns the scalar verbatim for `step.output` and raises a clear `KeyError` for `step.output.field` shorthand on non-dict outputs. - **Reasoning effort**: `runtime.default_reasoning_effort` sets a workflow-wide default; per-agent `reasoning.effort` overrides it. Allowed values: `low`, `medium`, `high`, `xhigh`. Each provider translates the unified value to its native API (Copilot: `reasoning_effort` on the session, validated against the model's `supported_reasoning_efforts`; Claude: extended thinking with budget mapping low=2048, medium=8192, high=16384, xhigh=32768 tokens, with `temperature` coerced to 1.0 and `max_tokens` bumped to fit the budget). See `examples/reasoning-effort.yaml`. -- **Terminate steps** (`type: terminate`): explicit terminal step with `status` (`success` | `failed`), Jinja2 `reason`, and optional `output_template` (a `dict[str, str]` that replaces `workflow.output:` when set). Reaching a terminate step ends the workflow immediately (no routes evaluated after). `success` → CLI exit 0, dashboard ✅, `workflow_completed { termination_reason, terminated_by, is_explicit: true }`. `failed` → CLI exit 1, dashboard ❌, raises `WorkflowTerminated`, emits `workflow_failed { error_type: "WorkflowTerminated", is_explicit: true }`, and **does not** save an on-failure checkpoint. Terminate steps cannot have `routes`, `tools`, `output`, `prompt`, `model`, etc.; cannot be used as parallel-group members or as a for_each inline agent. Inside a sub-workflow, a `status: failed` terminate is downgraded to `ExecutionError` at the parent boundary so the parent sees a normal sub-workflow failure (parent's own `workflow_failed` does NOT inherit `is_explicit: true`). See `examples/terminate.yaml`. +- **Terminate steps** (`type: terminate`): explicit terminal step with `status` (`success` | `failed`), Jinja2 `reason`, and optional `output_template` (a `dict[str, str]` that replaces `workflow.output:` when set; each value is rendered then passed through `_maybe_parse_json` so `"true"` becomes `True`, `"42"` becomes `42`, JSON literals are parsed). Reaching a terminate step ends the workflow immediately (no routes evaluated after). `success` → CLI exit 0, dashboard ✅, `workflow_completed { termination_reason, terminated_by, is_explicit: true, status }`; runs `on_complete` hook. `failed` → CLI exit 1 (with rendered output JSON still printed to stdout for downstream tooling), dashboard ❌, raises `WorkflowTerminated` (subclass of `ExecutionError`), emits `workflow_failed { error_type: "WorkflowTerminated", is_explicit: true, status, output }`, runs `on_error` hook, and **does not** save an on-failure checkpoint (explicit terminations are intentionally non-resumable). Terminate steps cannot have `routes`, `tools`, `output`, `prompt`, `model`, etc.; cannot be used as parallel-group members or as a for_each inline agent (route to one from those groups' `routes:` instead). Inside a sub-workflow, a `status: failed` terminate is downgraded at the parent boundary to `SubworkflowTerminatedError` (also a subclass of `ExecutionError`) preserving the child's rendered `terminated_output` / `terminated_reason` / `terminated_by` as structured attributes — the parent treats it as a normal sub-workflow failure (its own `workflow_failed` does NOT inherit `is_explicit: true`). For more detail see `examples/terminate.yaml`, `docs/workflow-syntax.md` (Terminate Steps section), and `plugins/conductor/skills/conductor/references/authoring.md`. ### Debugging `--web-bg` failures diff --git a/CHANGELOG.md b/CHANGELOG.md index 487a98a7..9b6f97df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/microsoft/conductor/compare/v0.1.17...HEAD) ### Added +<<<<<<< HEAD - New `type: wait` workflow step that pauses execution for a parsed duration via in-process `asyncio.sleep`. Cross-platform — no shell `sleep` dependency. Use for rate-limit cooldowns, polling intervals, @@ -34,6 +35,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 route loop-back ([#224](https://github.com/microsoft/conductor/pull/224), closes [#218](https://github.com/microsoft/conductor/issues/218)). +======= +- New `type: terminate` workflow step that explicitly ends the workflow with + a structured `status` (`success` | `failed`) and Jinja2-rendered `reason`, + plus an optional `output_template` (`dict[str, str]`) that replaces the + workflow-level `output:` mapping for that termination path. Reaching a + terminate step ends the workflow immediately (no routes evaluated after). + `status: success` returns the rendered output cleanly (CLI exit 0, + dashboard ✅, emits `workflow_completed { termination_reason, terminated_by, + is_explicit: true, status: "success" }`); `status: failed` raises a new + `WorkflowTerminated` exception (`ExecutionError` subclass), gives the CLI a + non-zero exit code while still printing the rendered output JSON to stdout + for downstream tooling, and intentionally **skips** the on-failure + checkpoint save because explicit termination is not a resumable transient + failure. Inside a sub-workflow, a failed terminate is downgraded at the + parent boundary to a new `SubworkflowTerminatedError` (also an + `ExecutionError`) preserving the child's rendered `terminated_output` / + `terminated_reason` / `terminated_by` as structured attributes, so the + parent treats it as a normal sub-workflow failure (its own + `workflow_failed` does NOT inherit `is_explicit: true`) while debugging + surfaces can still inspect what the child intended to emit. Schema + validation rejects `routes`, `tools`, `output`, `prompt`, `model`, + `provider`, and the other agent-only fields on terminate steps, and + conversely rejects `status` / `reason` / `output_template` on every other + step type so authors who forget `type: terminate` get a clear error + instead of silently dropped fields. Terminate cannot be used as a + parallel-group member or as a `for_each` inline agent — route to one + from those groups' `routes:` instead. The example workflow lives at + `examples/terminate.yaml` + ([#219](https://github.com/microsoft/conductor/issues/219)). +>>>>>>> e04312b (docs(terminate): document type: terminate across user-facing docs (#219)) ## [0.1.17](https://github.com/microsoft/conductor/compare/v0.1.16...v0.1.17) - 2026-05-21 diff --git a/README.md b/README.md index a2bb08cc..3893bb91 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Conductor makes multi-agent workflows — code review pipelines, research-then-s - **Sub-workflow composition** - Reusable sub-workflows with templated `input_mapping`, usable inside `for_each` groups for dynamic fan-out - **Script steps** - Run shell commands and route on exit code or parsed JSON stdout - **Set steps** - Bind one or more Jinja2-evaluated values into the context (no LLM, no subprocess) for derived flags, computed defaults, and constants reused by many later prompts +- **Terminate steps** - Explicit terminal step with `status` (`success`/`failed`) and structured `reason` — distinguishable from the default `$end` path in CLI exit codes, dashboard state, and event logs - **Dialog mode** - Agents can pause for multi-turn conversation when uncertain - **Reasoning effort** - Unified `reasoning.effort` (low/medium/high/xhigh) per agent or workflow-wide, translated to each provider's native API - **Workspace instructions** - Auto-discover and inject `AGENTS.md` / `CLAUDE.md` / `.github/copilot-instructions.md` into every agent's prompt @@ -302,8 +303,12 @@ See the [`examples/`](./examples/) directory for complete workflows: | [design-review.yaml](./examples/design-review.yaml) | Human gate with loop pattern | | [script-step.yaml](./examples/script-step.yaml) | Script step with exit_code routing | | [set-step.yaml](./examples/set-step.yaml) | Set step deriving named values + boolean-routed branching | +<<<<<<< HEAD | [wait-step.yaml](./examples/wait-step.yaml) | Wait step + script for a polling loop-back pattern | | [wait-smoke.yaml](./examples/wait-smoke.yaml) | Minimal wait-only smoke test (no provider required) | +======= +| [terminate.yaml](./examples/terminate.yaml) | Explicit `type: terminate` with success and failure paths | +>>>>>>> e04312b (docs(terminate): document type: terminate across user-facing docs (#219)) **More examples and running instructions:** [examples/README.md](./examples/README.md) diff --git a/docs/configuration.md b/docs/configuration.md index 4a0cecab..1e789470 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -159,8 +159,13 @@ agents: Per-agent overrides always win over the workflow-wide default. The `reasoning.effort` field is **only** valid on standard `agent`-type agents; it +<<<<<<< HEAD is rejected on `script`, `human_gate`, `workflow`, and `wait` agents (which do not call a model). +======= +is rejected on `script`, `human_gate`, `workflow`, and `terminate` agents +(none of which call a model). +>>>>>>> e04312b (docs(terminate): document type: terminate across user-facing docs (#219)) ### Per-provider translation diff --git a/docs/workflow-syntax.md b/docs/workflow-syntax.md index dac716c4..21945b9c 100644 --- a/docs/workflow-syntax.md +++ b/docs/workflow-syntax.md @@ -75,7 +75,7 @@ Agents are defined in the `agents` list. Each agent represents a unit of work. agents: - name: string # Required: Unique agent identifier description: string # Optional: Purpose description - type: agent # agent | human_gate | script | workflow | wait (default: agent) + type: agent # agent | human_gate | script | workflow | wait | terminate (default: agent) model: string # Optional: Model identifier (e.g., 'claude-sonnet-4.5') prompt: | # Required for type=agent: Agent instructions @@ -522,6 +522,58 @@ parallel: **Restrictions** — workflow steps cannot have `prompt`, `model`, `provider`, `tools`, `system_prompt`, `command`, or `options`. +### Terminate Steps + +Terminate steps end the workflow with an explicit `status` (`success` or `failed`) and a structured `reason`. Reaching a terminate step ends execution immediately — no routes are evaluated after — and produces a CLI exit code, dashboard state, and event payload that downstream tooling can distinguish from a generic crash. + +```yaml +agents: + - name: precheck + type: script + command: bash + args: ["-c", "echo '{\"action\":\"abort\",\"reason\":\"unsafe input\"}'"] + output: + action: { type: string } + reason: { type: string } + routes: + - when: "action == 'abort'" + to: abort_unsafe + - when: "action == 'noop'" + to: noop_exit + - to: main_pipeline + + # Soft success — workflow ends cleanly, exit 0, dashboard ✅. + - name: noop_exit + type: terminate + status: success + reason: "Document already up to date; no edits needed." + + # Hard failure with reason — workflow ends, exit 1, dashboard ❌. + - name: abort_unsafe + type: terminate + status: failed + reason: "{{ precheck.output.reason }}" + output_template: # optional; replaces workflow.output + aborted: "true" # rendered then JSON-coerced to True + stage: precheck + reason: "{{ precheck.output.reason }}" +``` + +**Behaviour** + +| `status` | CLI exit code | Dashboard | Event | Resumable? | +|----------|---------------|-----------|-------|------------| +| `success` | `0` | ✅ | `workflow_completed { termination_reason, terminated_by, is_explicit: true, status: "success" }` | n/a (clean exit) | +| `failed` | `1` | ❌ | `workflow_failed { error_type: "WorkflowTerminated", termination_reason, terminated_by, is_explicit: true, status: "failed", output }` | **No** — explicit terminations skip the on-failure checkpoint | + +**Final output** — when `output_template:` is set, it *replaces* the workflow-level `output:` mapping for this termination path. Each rendered value is passed through the same JSON-coercion helper used elsewhere in the engine, so `"true"` becomes `True`, `"42"` becomes `42`, and JSON literals are parsed. When `output_template:` is omitted, the workflow-level `output:` is rendered as on any other terminal path. + +**Restrictions** — terminate steps cannot have `routes`, `tools`, `output`, `prompt`, `model`, `provider`, `system_prompt`, `command`, `args`, `env`, `working_dir`, `timeout`, `timeout_seconds`, `max_session_seconds`, `max_agent_iterations`, `max_depth`, `retry`, `dialog`, `reasoning`, `workflow`, `input_mapping`, or `options`. They cannot appear as members of a parallel group or as a `for_each` inline agent — route to them from those groups' `routes:` instead. + +**Sub-workflow boundary** — a `status: failed` terminate inside a sub-workflow is downgraded to a `SubworkflowTerminatedError` (subclass of `ExecutionError`) at the parent boundary so the parent treats it as a normal sub-workflow failure (its own `workflow_failed` does NOT inherit `is_explicit: true`). The child's rendered output, reason, and terminate step name are preserved on the wrapper as `terminated_output`, `terminated_reason`, and `terminated_by` for `on_error` hooks and debugging surfaces. A `status: success` terminate inside a sub-workflow returns its rendered output cleanly and the parent continues with its next routes. + +See [`examples/terminate.yaml`](../examples/terminate.yaml) for a complete worked example with all three paths. + ### Dialog Mode Dialog mode allows agents to conditionally pause after execution and enter a free-form conversation with the user. An LLM evaluator examines the agent's output against user-defined criteria and decides whether to initiate a dialog. diff --git a/examples/README.md b/examples/README.md index 767ce630..158960c2 100644 --- a/examples/README.md +++ b/examples/README.md @@ -94,6 +94,30 @@ conductor run examples/design-review.yaml --input requirement="Build a REST API" conductor run examples/design-review.yaml --input requirement="Build a REST API" --skip-gates ``` +## Explicit Termination + +### terminate.yaml + +A workflow with multiple legitimate end states beyond "the last agent finished," using `type: terminate` steps to surface each outcome distinctly. Demonstrates: + +- `status: success` — early-exit when there's nothing to do (CLI exit 0, dashboard ✅) +- `status: failed` — refuse-to-run on unsafe input (CLI exit 1, dashboard ❌, emits `workflow_failed` with `is_explicit: true` and `error_type: WorkflowTerminated`) +- Pass-through normal pipeline for the "do the work" path +- Optional `output_template:` that replaces the workflow-level `output:` for a termination path + +```bash +# Success path — soft no-op, exit 0 +conductor run examples/terminate.yaml --input document_state=current + +# Failure path — hard refusal, exit 1 with structured reason +conductor run examples/terminate.yaml --input document_state=unsafe + +# Normal pipeline (no terminate hit) +conductor run examples/terminate.yaml --input document_state=stale +``` + +CI / dashboard / notification tooling can read `is_explicit: true` from the JSONL event log to distinguish an intentional termination from a generic crash. + ## Reasoning Effort ### reasoning-effort.yaml diff --git a/plugins/conductor/skills/conductor/SKILL.md b/plugins/conductor/skills/conductor/SKILL.md index 5185f128..0aa2f07d 100644 --- a/plugins/conductor/skills/conductor/SKILL.md +++ b/plugins/conductor/skills/conductor/SKILL.md @@ -102,6 +102,7 @@ For runtime config, context modes, limits, and cost tracking, see [references/au | `type: set` | Pure-context step that evaluates Jinja2 expressions and binds typed values (no LLM, no subprocess); supports single `value:` and multi `values:` | | `type: wait` | Pause via `asyncio.sleep` (cross-platform); duration accepts `Ns/Nm/Nh/Nms` or Jinja2; composes with route loop-backs for polling | | `type: workflow` | Sub-workflow agent — runs another YAML file as a black box (supports `input_mapping`, `max_depth`) | +| `type: terminate` | Explicit terminal step with `status` (`success`/`failed`), Jinja `reason`, optional `output_template` — controls CLI exit code, dashboard state, and emits `is_explicit: true` in `workflow_completed`/`workflow_failed` | | `parallel` | Static parallel groups (fixed agent list) | | `for_each` | Dynamic parallel groups (runtime-determined array; supports `type: workflow` agents) | | `human_gate` | Pauses for user decision with options (Markdown + auto-linkified paths/URLs) | diff --git a/plugins/conductor/skills/conductor/references/authoring.md b/plugins/conductor/skills/conductor/references/authoring.md index 0df873a7..2c619598 100644 --- a/plugins/conductor/skills/conductor/references/authoring.md +++ b/plugins/conductor/skills/conductor/references/authoring.md @@ -67,7 +67,7 @@ workflow: ```yaml agents: - name: my_agent # Required: unique identifier - type: agent # agent (default), human_gate, script, workflow, or wait + type: agent # agent (default), human_gate, script, workflow, wait, or terminate description: What it does model: gpt-5.2 # Override workflow default provider: claude # Optional: per-agent provider override @@ -452,6 +452,45 @@ for_each: **Restrictions** — workflow steps cannot have `prompt`, `model`, `provider`, `tools`, `system_prompt`, `command`, `options`, `retry`, `reasoning`, `dialog`, `max_session_seconds`, `max_agent_iterations`, or `timeout_seconds`. +## Terminate Steps (`type: terminate`) + +End the workflow with an explicit, structured outcome — distinguishable from a generic crash in CLI exit codes, dashboard state, and event logs. Real workflows have multiple legitimate end states beyond "the last agent finished": early success ("the document is already up to date"), soft abort ("no matching issues found"), hard failure with reason ("upstream service returned unprocessable data"), pre-condition not met ("this PR is from a fork"). With only `$end`, all of these collapse into "workflow completed" downstream. Terminate steps surface the distinction. + +```yaml +agents: + - name: precheck + prompt: "Is the input safe to process? Return JSON: {safe: bool, reason: string}" + output: + safe: { type: boolean } + reason: { type: string } + routes: + - when: "not precheck.output.safe" + to: abort_unsafe + - to: main_pipeline + + - name: abort_unsafe + type: terminate + status: failed # success | failed (required) + reason: "{{ precheck.output.reason }}" # required; Jinja2-templated + output_template: # optional; replaces workflow-level output: + aborted: "true" # rendered then JSON-coerced ("true" -> True) + stage: precheck + reason: "{{ precheck.output.reason }}" +``` + +**Semantics:** + +- Reaching a terminate step ends the workflow immediately — no routes evaluated after. +- `status: success` → engine returns the rendered output, CLI exits `0`, dashboard ✅, emits `workflow_completed { termination_reason, terminated_by, is_explicit: true, status: "success" }`. Runs the `on_complete` hook. +- `status: failed` → engine raises `WorkflowTerminated` (subclass of `ExecutionError`), CLI exits `1` (and still prints the rendered output JSON to stdout for downstream tooling), dashboard ❌, emits `workflow_failed { error_type: "WorkflowTerminated", termination_reason, terminated_by, is_explicit: true, status: "failed", output }`. Runs the `on_error` hook. **Intentionally not resumable** — the engine skips the on-failure checkpoint because the author explicitly chose this outcome. +- `output_template:` is a `dict[str, str]` where each value is a Jinja2 expression. The rendered values are passed through the engine's JSON-coercion helper, so `"true"` becomes `True`, `"42"` becomes `42`, and JSON literals (`'{"k":"v"}'`) are parsed. When omitted, the workflow-level `output:` mapping is rendered as on any other terminal path. +- **Sub-workflow boundary** — a `status: failed` terminate inside a child sub-workflow is downgraded to `SubworkflowTerminatedError` (also an `ExecutionError`) at the parent boundary. The parent treats it as a normal sub-workflow failure (its own `workflow_failed` does NOT inherit `is_explicit: true`). The child's rendered output, reason, and terminate-step name are preserved as `terminated_output` / `terminated_reason` / `terminated_by` attributes on the wrapper for `on_error` hooks and debugging surfaces. A `status: success` child terminate returns its rendered output cleanly and the parent continues with its next routes. +- **Branching on a child's termination** — if the parent's routes need to react to a child's outcome, the child should use `status: success` plus an `output_template:` carrying the relevant fields. Failed terminate is an error from the parent's perspective; parent `routes:` are only evaluated after successful steps. + +**Restrictions** — terminate steps cannot have `routes`, `tools`, `output`, `prompt`, `model`, `provider`, `system_prompt`, `command`, `args`, `env`, `working_dir`, `timeout`, `timeout_seconds`, `max_session_seconds`, `max_agent_iterations`, `max_depth`, `retry`, `dialog`, `reasoning`, `workflow`, `input_mapping`, or `options`. Cannot appear as a parallel-group member or as a `for_each` inline agent — route to them from those groups' `routes:` instead. Conversely, regular agents cannot have `status`, `reason`, or `output_template` — those fields are rejected at schema validation to catch authors who forgot to add `type: terminate`. + +See `examples/terminate.yaml` for a complete example demonstrating success, failure, and pass-through paths. + ## Dialog Mode Dialog mode lets an agent conditionally pause after execution and enter a free-form conversation with the user. A lightweight evaluator LLM call inspects the agent's output against `trigger_prompt` and decides whether to engage. Both Copilot and Claude providers are supported, and the dashboard provides dedicated UI (`DialogDetail`, `DialogEngagementPrompt`, `DialogOverlay`). diff --git a/plugins/conductor/skills/conductor/references/yaml-schema.md b/plugins/conductor/skills/conductor/references/yaml-schema.md index 0d615583..9c976fbc 100644 --- a/plugins/conductor/skills/conductor/references/yaml-schema.md +++ b/plugins/conductor/skills/conductor/references/yaml-schema.md @@ -103,7 +103,7 @@ agents: name: string # Unique agent identifier # Optional fields - type: string # "agent" (default), "human_gate", "script", "workflow", or "wait" + type: string # "agent" (default), "human_gate", "script", "workflow", "wait", or "terminate" description: string # What this agent does model: string # Override default_model provider: string # Per-agent provider override ("copilot" or "claude") @@ -184,6 +184,13 @@ agents: : string output_type: string # auto|string|number|integer|boolean|list|dict # (single value: only; per-key typing on values: not supported) + + # Terminate-only fields (type: terminate) + status: string # Required: "success" or "failed" + reason: string # Required: Jinja2-templated termination reason + output_template: # Optional: replaces workflow-level output: for this path + : string # Each value Jinja2-templated, then JSON-coerced + # ("true" -> True, "42" -> 42, JSON literals parsed) ``` **Script agent restrictions:** Cannot have `prompt`, `provider`, `model`, `tools`, `output`, `system_prompt`, `options`, `retry`, `reasoning`, `dialog`, `max_session_seconds`, `max_agent_iterations`, `timeout_seconds` (use `timeout`), `input_mapping`, or `max_depth`. Output is always `{stdout, stderr, exit_code}`. If `stdout` is valid JSON, its top-level keys are auto-merged into the output dict. @@ -192,6 +199,8 @@ agents: **Workflow agent restrictions (`type: workflow`):** Cannot have `prompt`, `model`, `provider`, `tools`, `system_prompt`, `command`, `options`, `retry`, `reasoning`, `dialog`, `max_session_seconds`, `max_agent_iterations`, or `timeout_seconds`. Requires `workflow:` path. Supports `input_mapping` and `max_depth`. Allowed inside `for_each` groups for dynamic fan-out. +**Terminate agent restrictions (`type: terminate`):** Requires `status` (`success` | `failed`) and a non-empty `reason`. Cannot have `routes`, `tools`, `output`, `prompt`, `model`, `provider`, `system_prompt`, `command`, `args`, `env`, `working_dir`, `timeout`, `timeout_seconds`, `max_session_seconds`, `max_agent_iterations`, `max_depth`, `retry`, `dialog`, `reasoning`, `workflow`, `input_mapping`, or `options`. Cannot be used as a parallel-group member or as a `for_each` inline agent — route to a terminate step from those groups' `routes:` instead. Reaching a terminate step ends the workflow immediately (no routes evaluated after) and produces a distinguishable event payload: `workflow_completed` (for `success`) or `workflow_failed` (for `failed`) with `termination_reason`, `terminated_by`, `is_explicit: true`, and `status`. `status: failed` raises `WorkflowTerminated` (an `ExecutionError` subclass), gives the CLI a non-zero exit code, and is intentionally NOT resumable (no on-failure checkpoint saved). Inside a sub-workflow, a `status: failed` terminate is downgraded at the parent boundary to `SubworkflowTerminatedError` (also an `ExecutionError`), preserving the child's rendered `terminated_output`/`terminated_reason`/`terminated_by` as attributes on the wrapper. + **Reasoning effort:** `reasoning.effort` (and `runtime.default_reasoning_effort`) accepts `low`, `medium`, `high`, or `xhigh`. Per-agent value overrides the runtime default. Each provider translates the unified value to its native API: - **Copilot**: forwards `reasoning_effort` to the session. Validated against the model's advertised `supported_reasoning_efforts` (when available); raises `ValidationError` for unsupported combinations. diff --git a/src/conductor/config/schema.py b/src/conductor/config/schema.py index 81b200c5..f7be6c48 100644 --- a/src/conductor/config/schema.py +++ b/src/conductor/config/schema.py @@ -453,7 +453,36 @@ class ReasoningConfig(BaseModel): class AgentDef(BaseModel): - """Definition for a single agent in the workflow.""" + """Definition for a single agent in the workflow. + + A single Pydantic model covers all step kinds. The ``type`` field + discriminates between them: + + - ``agent`` (default): LLM-backed agent. Requires ``prompt``; supports + ``model``, ``provider``, ``tools``, ``output``, ``reasoning``, ``retry``, + ``dialog``, and ``timeout_seconds``. + - ``human_gate``: Pause for user decision. Requires ``prompt`` and + ``options``. + - ``script``: Shell command step. Requires ``command``; supports + ``args``, ``env``, ``working_dir``, ``timeout``. Output is always + ``{stdout, stderr, exit_code}`` with parsed-JSON keys merged on top + when ``stdout`` is valid JSON. + - ``workflow``: Sub-workflow black-box step. Requires ``workflow:`` + (path or registry reference); supports ``input_mapping`` and + ``max_depth``. + - ``terminate``: Explicit terminal step. Requires ``status`` (``success`` + | ``failed``) and ``reason``; supports optional ``output_template``. + Reaching one ends the workflow immediately (no routes evaluated + after) and surfaces in the CLI exit code / dashboard / event log as + a distinct, intentional outcome — distinguishable from a generic + crash via ``is_explicit: true`` on the emitted lifecycle event. + + Per-type field forbidden-lists are enforced in + :meth:`validate_agent_type`. Cross-cutting structural rules (e.g., + terminate steps cannot appear as parallel-group members or as a + for_each inline agent) are enforced in + :func:`conductor.config.validator.validate_workflow_config`. + """ model_config = ConfigDict(extra="forbid") diff --git a/tests/test_engine/test_subworkflow.py b/tests/test_engine/test_subworkflow.py index dbeb498c..2a215ed4 100644 --- a/tests/test_engine/test_subworkflow.py +++ b/tests/test_engine/test_subworkflow.py @@ -2321,9 +2321,7 @@ async def test_child_failed_terminate_surfaces_as_execution_error( # outer ConductorError handler picks it up via the same code path as # any other sub-workflow failure, but the distinct class name makes # the cause visible to event consumers. - assert all( - e.data.get("error_type") == "SubworkflowTerminatedError" for e in outer - ), ( + assert all(e.data.get("error_type") == "SubworkflowTerminatedError" for e in outer), ( f"parent error_type should be SubworkflowTerminatedError; got: " f"{[e.data.get('error_type') for e in outer]}" ) From 767311fbd4fc37a2d10ca915dbbb594c999e5828 Mon Sep 17 00:00:00 2001 From: Jason Robert Date: Thu, 21 May 2026 16:53:01 -0400 Subject: [PATCH 4/5] feat(web): render type: terminate steps distinctly in dashboard (#219) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes the last remaining acceptance criterion from the original issue: "Dashboard shows terminate steps distinctly (e.g. red/green pill with reason text)". Engine and CLI already emitted all the metadata needed; this commit teaches the frontend how to consume it. Graph node ---------- - New `TerminateNode` component (Octagon icon, status-themed border, body shows "terminate · success" / "terminate · failed" sub-label plus the rendered reason). Distinct from AgentNode (Bot icon), ScriptNode (Terminal icon), WorkflowNode, and GateNode so terminate steps are immediately identifiable in the DAG. - `NodeType` extended with `'terminate'` and `graph-layout.ts` maps that to `terminateNode` (was silently falling through to `agentNode`). - `WorkflowGraph.tsx` registers `terminateNode` in its `nodeTypes` map. Tooltip ------- - `NodeTooltip` gained optional `reason` and `terminationStatus` fields. When set, the tooltip shows a green/red "Termination" capsule row plus a "Reason:" section with the rendered text — so hovering a terminate node surfaces the full context without having to open the agent detail panel. Workflow-level banners ---------------------- - New `workflowTermination` state on the store, populated from the `is_explicit` / `termination_reason` / `terminated_by` / `status` fields on the root `workflow_completed` and `workflow_failed` events. Reset across all replay / load paths. - `WorkflowSuccessBanner` renders "Workflow Terminated" with the rendered reason and `terminated_by` line when the workflow ended via `type: terminate status: success`. Otherwise it keeps the existing "Completed" rendering verbatim. - `WorkflowErrorBanner` renders "Workflow Terminated" (instead of "Workflow Failed") for an explicit-failed termination, plus the `terminated_by` line. Generic failures keep the existing banner. Node-level event handlers ------------------------- - `agent_completed` and `agent_failed` handlers now capture `termination_reason` / `terminated_by` / `status` from the event when the engine attached them, storing the values on `NodeData` so `TerminateNode` and `NodeTooltip` can render them. Non-terminate agents are unaffected (the fields are simply absent from their event payloads). Build artifacts --------------- Includes the rebuilt `src/conductor/web/static/assets/index-*.{css,js}` and updated `index.html` — these are tracked in git (see commit dc29c2c for the convention) so the dashboard bundle ships with the Python package. Validation ---------- - npm run build (tsc -b && vite build): clean. - make lint, make typecheck (modulo pre-existing dialog warning): clean. - 92 web tests still pass. This closes acceptance criterion #6 for issue #219. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../src/components/graph/NodeTooltip.tsx | 40 +++++ .../src/components/graph/TerminateNode.tsx | 114 ++++++++++++++ .../src/components/graph/WorkflowGraph.tsx | 2 + .../src/components/graph/graph-layout.ts | 1 + .../src/components/layout/ErrorBanner.tsx | 46 +++++- .../web/frontend/src/lib/constants.ts | 2 +- .../web/frontend/src/stores/workflow-store.ts | 82 +++++++++- .../web/frontend/tsconfig.tsbuildinfo | 2 +- .../{index-hDSiT313.js => index-B3D3Mvad.js} | 145 +++++++++--------- ...{index-CQX53z_g.css => index-CjrhFxh5.css} | 2 +- src/conductor/web/static/index.html | 4 +- 11 files changed, 356 insertions(+), 84 deletions(-) create mode 100644 src/conductor/web/frontend/src/components/graph/TerminateNode.tsx rename src/conductor/web/static/assets/{index-hDSiT313.js => index-B3D3Mvad.js} (75%) rename src/conductor/web/static/assets/{index-CQX53z_g.css => index-CjrhFxh5.css} (63%) diff --git a/src/conductor/web/frontend/src/components/graph/NodeTooltip.tsx b/src/conductor/web/frontend/src/components/graph/NodeTooltip.tsx index da74594f..3bf96090 100644 --- a/src/conductor/web/frontend/src/components/graph/NodeTooltip.tsx +++ b/src/conductor/web/frontend/src/components/graph/NodeTooltip.tsx @@ -15,6 +15,10 @@ interface TooltipData { errorMessage?: string | null; iteration?: number | null; selectedOption?: string | null; + // Terminate-step metadata (issue #219). Populated for `type: terminate` + // nodes; rendered as a distinct section below the details grid when set. + reason?: string | null; + terminationStatus?: 'success' | 'failed' | null; } interface NodeTooltipProps { @@ -115,8 +119,44 @@ export function NodeTooltip({ data, children }: NodeTooltipProps) { {data.selectedOption} )} + {data.terminationStatus && ( + <> + Termination + + {data.terminationStatus} + + + )} + {/* Termination reason (issue #219) — shown for `type: terminate` + steps so the rendered reason is visible without opening the + node detail panel. */} + {data.reason && ( + <> +
+
+ Reason: + {data.reason.slice(0, 160)} + {data.reason.length > 160 ? '...' : ''} +
+ + )} + {/* Error message */} {data.errorMessage && ( <> diff --git a/src/conductor/web/frontend/src/components/graph/TerminateNode.tsx b/src/conductor/web/frontend/src/components/graph/TerminateNode.tsx new file mode 100644 index 00000000..b1df1e77 --- /dev/null +++ b/src/conductor/web/frontend/src/components/graph/TerminateNode.tsx @@ -0,0 +1,114 @@ +import { memo } from 'react'; +import { Handle, Position, type NodeProps } from '@xyflow/react'; +import { Octagon } from 'lucide-react'; +import { cn } from '@/lib/utils'; +import { NODE_STATUS_HEX } from '@/lib/constants'; +import { useViewedNodes } from '@/hooks/use-viewed-context'; +import { NodeTooltip } from './NodeTooltip'; +import type { GraphNodeData } from './graph-layout'; +import type { NodeStatus } from '@/lib/constants'; + +/** + * Renders a `type: terminate` step distinctly from regular agent / script / + * gate / workflow nodes (issue #219). Terminate steps are intentional + * end-of-workflow signals, not model invocations or shell commands, so the + * visual deliberately avoids the agent/script affordances: + * + * - Octagon icon (universal "stop" semantic) instead of bot/terminal/etc. + * - Body shows the rendered termination `reason` once the step fires (it is + * captured on the node from the `agent_completed` / `agent_failed` event + * payload's `termination_reason` field). + * - Pending → grey, success → green, failed → red. Status comes from the + * shared `NODE_STATUS_HEX` map so the visual is consistent with every + * other node type's status semantics. + * + * The error/success banners at the workflow level (see ErrorBanner.tsx) are + * responsible for the workflow-wide red/green message — this node is just + * about identifying the terminate step in the DAG graph. + */ +export const TerminateNode = memo(function TerminateNode({ data, id, selected }: NodeProps) { + const nodeData = data as unknown as GraphNodeData; + const viewedNodes = useViewedNodes(); + const storeStatus = viewedNodes[id]?.status; + const status = (storeStatus || nodeData.status || 'pending') as NodeStatus; + const borderColor = NODE_STATUS_HEX[status] || NODE_STATUS_HEX.pending; + + const nd = viewedNodes[id]; + const reason = nd?.termination_reason; + const terminationStatus = nd?.termination_status; + const errorMessage = nd?.error_message; + const errorType = nd?.error_type; + + // Body shows the rendered termination reason. Until the step fires we only + // have the static type to display ("terminate"). On failure paths, prefer + // `termination_reason` (set explicitly by the engine) and fall back to + // `error_message` (set by the generic `agent_failed` handler) so we never + // show an empty banner. + const bodyText = reason || errorMessage; + const bodyClassName = + status === 'failed' + ? 'text-red-400' + : status === 'completed' + ? 'text-green-400' + : 'text-[var(--text-muted)]'; + + return ( + <> + + +
+
+ +
+
+ + {nodeData.label} + + + terminate{terminationStatus ? ` · ${terminationStatus}` : ''} + + {bodyText && ( + + {bodyText.length > 50 ? bodyText.slice(0, 47) + '...' : bodyText} + + )} +
+
+
+ {/* Terminate is a sink — no outbound handle. Keeping a hidden source + handle would let stray edges attach in the layout; omit it entirely + so dagre treats this node as terminal. */} + + ); +}); diff --git a/src/conductor/web/frontend/src/components/graph/WorkflowGraph.tsx b/src/conductor/web/frontend/src/components/graph/WorkflowGraph.tsx index cc9515a5..226d0c72 100644 --- a/src/conductor/web/frontend/src/components/graph/WorkflowGraph.tsx +++ b/src/conductor/web/frontend/src/components/graph/WorkflowGraph.tsx @@ -26,6 +26,7 @@ import { GateNode } from './GateNode'; import { GroupNode } from './GroupNode'; import { WorkflowNode } from './WorkflowNode'; import { WaitNode } from './WaitNode'; +import { TerminateNode } from './TerminateNode'; import { EndNode } from './EndNode'; import { StartNode } from './StartNode'; import { IngressNode } from './IngressNode'; @@ -44,6 +45,7 @@ const nodeTypes: NodeTypes = { groupNode: GroupNode, workflowNode: WorkflowNode, waitNode: WaitNode, + terminateNode: TerminateNode, endNode: EndNode, startNode: StartNode, ingressNode: IngressNode, diff --git a/src/conductor/web/frontend/src/components/graph/graph-layout.ts b/src/conductor/web/frontend/src/components/graph/graph-layout.ts index 7bde599e..604bed5a 100644 --- a/src/conductor/web/frontend/src/components/graph/graph-layout.ts +++ b/src/conductor/web/frontend/src/components/graph/graph-layout.ts @@ -121,6 +121,7 @@ export function buildGraphElements( else if (nodeType === 'human_gate') flowNodeType = 'gateNode'; else if (nodeType === 'workflow') flowNodeType = 'workflowNode'; else if (nodeType === 'wait') flowNodeType = 'waitNode'; + else if (nodeType === 'terminate') flowNodeType = 'terminateNode'; flowNodes.push({ id: a.name, diff --git a/src/conductor/web/frontend/src/components/layout/ErrorBanner.tsx b/src/conductor/web/frontend/src/components/layout/ErrorBanner.tsx index fe425183..ce4a63c7 100644 --- a/src/conductor/web/frontend/src/components/layout/ErrorBanner.tsx +++ b/src/conductor/web/frontend/src/components/layout/ErrorBanner.tsx @@ -8,11 +8,20 @@ export function WorkflowErrorBanner() { const workflowStatus = useWorkflowStore((s) => s.workflowStatus); const workflowFailure = useWorkflowStore((s) => s.workflowFailure); const workflowFailedAgent = useWorkflowStore((s) => s.workflowFailedAgent); + const workflowTermination = useWorkflowStore((s) => s.workflowTermination); const selectNode = useWorkflowStore((s) => s.selectNode); if (workflowStatus !== 'failed' || !workflowFailure) return null; - const errorText = workflowFailure.message || workflowFailure.error_type || 'Unknown error'; + // Issue #219: explicit `type: terminate status: failed` deserves a distinct + // banner — it is an intentional outcome, not a crash. Use the rendered + // termination_reason rather than the generic message and mention the step + // that fired so CI/dashboard consumers can tell them apart at a glance. + const isExplicit = workflowTermination?.is_explicit && workflowTermination.status === 'failed'; + const errorText = isExplicit + ? workflowTermination!.termination_reason || workflowFailure.message || 'Workflow terminated' + : workflowFailure.message || workflowFailure.error_type || 'Unknown error'; + const titleText = isExplicit ? 'Workflow Terminated' : 'Workflow Failed'; const isTimeout = workflowFailure.error_type === 'TimeoutError'; return ( @@ -26,8 +35,13 @@ export function WorkflowErrorBanner() { >
- Workflow Failed + {titleText} {errorText} + {isExplicit && workflowTermination?.terminated_by && ( + + Terminated by: {workflowTermination.terminated_by} + + )} {isTimeout && workflowFailure.current_agent && ( Timed out on agent: {workflowFailure.current_agent} @@ -56,6 +70,7 @@ export function WorkflowErrorBanner() { export function WorkflowSuccessBanner() { const [dismissed, setDismissed] = useState(false); const workflowStatus = useWorkflowStore((s) => s.workflowStatus); + const workflowTermination = useWorkflowStore((s) => s.workflowTermination); const totalCost = useWorkflowStore((s) => s.totalCost); const totalTokens = useWorkflowStore((s) => s.totalTokens); const agentsCompleted = useWorkflowStore((s) => s.agentsCompleted); @@ -64,18 +79,39 @@ export function WorkflowSuccessBanner() { if (workflowStatus !== 'completed' || dismissed) return null; + // Issue #219: when the workflow ended via `type: terminate status: success`, + // surface the structured reason and terminate step name so the success + // banner clearly distinguishes "early exit by author intent" from "the last + // agent finished and routed to $end". + const isExplicit = + workflowTermination?.is_explicit && workflowTermination.status === 'success'; + return (
- Completed -
+
+ + {isExplicit ? 'Workflow Terminated' : 'Completed'} + + {isExplicit && workflowTermination?.termination_reason && ( + + {workflowTermination.termination_reason} + + )} + {isExplicit && workflowTermination?.terminated_by && ( + + Terminated by: {workflowTermination.terminated_by} + + )} +
+
{elapsed} {agentsTotal > 0 && ( {agentsCompleted}/{agentsTotal} agents diff --git a/src/conductor/web/frontend/src/lib/constants.ts b/src/conductor/web/frontend/src/lib/constants.ts index 28dd21c6..bc55b3a2 100644 --- a/src/conductor/web/frontend/src/lib/constants.ts +++ b/src/conductor/web/frontend/src/lib/constants.ts @@ -1,5 +1,5 @@ export type NodeStatus = 'pending' | 'running' | 'completed' | 'failed' | 'paused' | 'idle' | 'waiting'; -export type NodeType = 'agent' | 'script' | 'set' | 'human_gate' | 'parallel_group' | 'for_each_group' | 'workflow' | 'wait' | 'start' | 'end' | 'ingress' | 'egress'; +export type NodeType = 'agent' | 'script' | 'set' | 'human_gate' | 'parallel_group' | 'for_each_group' | 'workflow' | 'wait' | 'terminate' | 'start' | 'end' | 'ingress' | 'egress'; export const NODE_STATUS_HEX: Record = { pending: '#6b7280', diff --git a/src/conductor/web/frontend/src/stores/workflow-store.ts b/src/conductor/web/frontend/src/stores/workflow-store.ts index 730620bd..6beac8b7 100644 --- a/src/conductor/web/frontend/src/stores/workflow-store.ts +++ b/src/conductor/web/frontend/src/stores/workflow-store.ts @@ -142,6 +142,10 @@ export interface NodeData { dialog_messages?: Array<{ role: 'user' | 'agent'; content: string }>; dialog_active?: boolean; dialog_awaiting_response?: boolean; + // Terminate-specific (type: terminate steps; see issue #219) + termination_status?: 'success' | 'failed'; + termination_reason?: string; + terminated_by?: string; } export interface GroupProgress { @@ -254,12 +258,23 @@ interface WorkflowState { workflowName: string; workflowStatus: WorkflowStatus; workflowStartTime: number | null; - workflowFailure: { error_type?: string; message?: string; elapsed_seconds?: number; timeout_seconds?: number; current_agent?: string; checkpoint_path?: string } | null; + workflowFailure: { error_type?: string; message?: string; elapsed_seconds?: number; timeout_seconds?: number; current_agent?: string; checkpoint_path?: string; termination_reason?: string; terminated_by?: string; is_explicit?: boolean; status?: string } | null; workflowFailedAgent: string | null; workflowYaml: string | null; conductorVersion: string | null; entryPoint: string | null; + // Explicit-termination metadata, populated for both success and failure + // terminations (see issue #219). When present, the WorkflowSuccessBanner / + // WorkflowErrorBanner can show the structured reason and terminate step + // name in addition to the generic completion / failure banners. + workflowTermination: { + is_explicit: boolean; + status: 'success' | 'failed'; + termination_reason?: string; + terminated_by?: string; + } | null; + // Graph structure agents: WorkflowAgent[]; routes: RouteEdge[]; @@ -518,6 +533,7 @@ export const useWorkflowStore = create((set, get) => ({ workflowStartTime: null, workflowFailure: null, workflowFailedAgent: null, + workflowTermination: null, workflowYaml: null, conductorVersion: null, entryPoint: null, @@ -656,6 +672,7 @@ export const useWorkflowStore = create((set, get) => ({ activityLog: [], workflowOutput: null, workflowFailedAgent: null, + workflowTermination: null, activeDialog: null, dialogEngaged: false, wfDepth: 0, @@ -705,6 +722,7 @@ export const useWorkflowStore = create((set, get) => ({ activityLog: [], workflowOutput: null, workflowFailedAgent: null, + workflowTermination: null, activeDialog: null, dialogEngaged: false, wfDepth: 0, @@ -741,6 +759,7 @@ export const useWorkflowStore = create((set, get) => ({ activityLog: [], workflowOutput: null, workflowFailedAgent: null, + workflowTermination: null, workflowStatus: 'pending', workflowStartTime: null, workflowName: '', @@ -1110,6 +1129,15 @@ const eventHandlers: Record; + if (extra.terminated_by) { + nd.termination_status = (extra.status as 'success' | 'failed' | undefined) ?? 'success'; + nd.termination_reason = extra.termination_reason as string | undefined; + nd.terminated_by = extra.terminated_by as string; + } replaceNode(t.nodes, data.agent_name); }, @@ -1126,6 +1154,16 @@ const eventHandlers: Record; + if (extra.terminated_by) { + nd.termination_status = (extra.status as 'success' | 'failed' | undefined) ?? 'failed'; + nd.termination_reason = extra.termination_reason as string | undefined; + nd.terminated_by = extra.terminated_by as string; + } replaceNode(t.nodes, data.agent_name); }, @@ -1475,13 +1513,27 @@ const eventHandlers: Record { state.wfDepth = Math.max(0, state.wfDepth - 1); - const data = _data as { agent_name?: string; error_type?: string; message?: string; elapsed_seconds?: number; timeout_seconds?: number; current_agent?: string; subworkflow_path?: string[] }; + const data = _data as { agent_name?: string; error_type?: string; message?: string; elapsed_seconds?: number; timeout_seconds?: number; current_agent?: string; subworkflow_path?: string[]; is_explicit?: boolean; termination_reason?: string; terminated_by?: string; status?: string }; if (state.wfDepth === 0) { // Root workflow failed state.workflowStatus = 'failed'; @@ -1532,7 +1584,29 @@ const eventHandlers: Recordt in e?FE(e,t,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Py;function QE(){if(Py)return yo;Py=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(l,a,o){var s=null;if(o!==void 0&&(s=""+o),a.key!==void 0&&(s=""+a.key),"key"in a){o={};for(var c in a)c!=="key"&&(o[c]=a[c])}else o=a;return a=o.ref,{$$typeof:e,type:l,key:s,ref:a!==void 0?a:null,props:o}}return yo.Fragment=t,yo.jsx=n,yo.jsxs=n,yo}var Gy;function ZE(){return Gy||(Gy=1,oh.exports=QE()),oh.exports}var y=ZE(),sh={exports:{}},ze={};/** + */var Py;function QE(){if(Py)return yo;Py=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(l,a,o){var s=null;if(o!==void 0&&(s=""+o),a.key!==void 0&&(s=""+a.key),"key"in a){o={};for(var c in a)c!=="key"&&(o[c]=a[c])}else o=a;return a=o.ref,{$$typeof:e,type:l,key:s,ref:a!==void 0?a:null,props:o}}return yo.Fragment=t,yo.jsx=n,yo.jsxs=n,yo}var Gy;function ZE(){return Gy||(Gy=1,oh.exports=QE()),oh.exports}var y=ZE(),sh={exports:{}},Me={};/** * @license React * react.production.js * @@ -14,7 +14,7 @@ var FE=Object.defineProperty;var YE=(e,t,n)=>t in e?FE(e,t,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Fy;function KE(){if(Fy)return ze;Fy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),s=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),g=Symbol.iterator;function b($){return $===null||typeof $!="object"?null:($=g&&$[g]||$["@@iterator"],typeof $=="function"?$:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,S={};function _($,Y,C){this.props=$,this.context=Y,this.refs=S,this.updater=C||w}_.prototype.isReactComponent={},_.prototype.setState=function($,Y){if(typeof $!="object"&&typeof $!="function"&&$!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,$,Y,"setState")},_.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function N(){}N.prototype=_.prototype;function k($,Y,C){this.props=$,this.context=Y,this.refs=S,this.updater=C||w}var T=k.prototype=new N;T.constructor=k,E(T,_.prototype),T.isPureReactComponent=!0;var M=Array.isArray;function A(){}var L={H:null,A:null,T:null,S:null},R=Object.prototype.hasOwnProperty;function V($,Y,C){var P=C.ref;return{$$typeof:e,type:$,key:Y,ref:P!==void 0?P:null,props:C}}function H($,Y){return V($.type,Y,$.props)}function B($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function U($){var Y={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(C){return Y[C]})}var ee=/\/+/g;function q($,Y){return typeof $=="object"&&$!==null&&$.key!=null?U(""+$.key):Y.toString(36)}function F($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(A,A):($.status="pending",$.then(function(Y){$.status==="pending"&&($.status="fulfilled",$.value=Y)},function(Y){$.status==="pending"&&($.status="rejected",$.reason=Y)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function z($,Y,C,P,X){var J=typeof $;(J==="undefined"||J==="boolean")&&($=null);var ne=!1;if($===null)ne=!0;else switch(J){case"bigint":case"string":case"number":ne=!0;break;case"object":switch($.$$typeof){case e:case t:ne=!0;break;case m:return ne=$._init,z(ne($._payload),Y,C,P,X)}}if(ne)return X=X($),ne=P===""?"."+q($,0):P,M(X)?(C="",ne!=null&&(C=ne.replace(ee,"$&/")+"/"),z(X,Y,C,"",function(xe){return xe})):X!=null&&(B(X)&&(X=H(X,C+(X.key==null||$&&$.key===X.key?"":(""+X.key).replace(ee,"$&/")+"/")+ne)),Y.push(X)),1;ne=0;var re=P===""?".":P+":";if(M($))for(var ue=0;ue<$.length;ue++)P=$[ue],J=re+q(P,ue),ne+=z(P,Y,C,J,X);else if(ue=b($),typeof ue=="function")for($=ue.call($),ue=0;!(P=$.next()).done;)P=P.value,J=re+q(P,ue++),ne+=z(P,Y,C,J,X);else if(J==="object"){if(typeof $.then=="function")return z(F($),Y,C,P,X);throw Y=String($),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return ne}function G($,Y,C){if($==null)return $;var P=[],X=0;return z($,P,"","",function(J){return Y.call(C,J,X++)}),P}function Q($){if($._status===-1){var Y=$._result;Y=Y(),Y.then(function(C){($._status===0||$._status===-1)&&($._status=1,$._result=C)},function(C){($._status===0||$._status===-1)&&($._status=2,$._result=C)}),$._status===-1&&($._status=0,$._result=Y)}if($._status===1)return $._result.default;throw $._result}var K=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},D={map:G,forEach:function($,Y,C){G($,function(){Y.apply(this,arguments)},C)},count:function($){var Y=0;return G($,function(){Y++}),Y},toArray:function($){return G($,function(Y){return Y})||[]},only:function($){if(!B($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return ze.Activity=p,ze.Children=D,ze.Component=_,ze.Fragment=n,ze.Profiler=a,ze.PureComponent=k,ze.StrictMode=l,ze.Suspense=h,ze.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=L,ze.__COMPILER_RUNTIME={__proto__:null,c:function($){return L.H.useMemoCache($)}},ze.cache=function($){return function(){return $.apply(null,arguments)}},ze.cacheSignal=function(){return null},ze.cloneElement=function($,Y,C){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var P=E({},$.props),X=$.key;if(Y!=null)for(J in Y.key!==void 0&&(X=""+Y.key),Y)!R.call(Y,J)||J==="key"||J==="__self"||J==="__source"||J==="ref"&&Y.ref===void 0||(P[J]=Y[J]);var J=arguments.length-2;if(J===1)P.children=C;else if(1t in e?FE(e,t,{enumerable:!0,config * LICENSE file in the root directory of this source tree. */var Jy;function nN(){if(Jy)return vo;Jy=1;var e=eN(),t=Jo(),n=pw();function l(r){var i="https://react.dev/errors/"+r;if(1D||(r.current=K[D],K[D]=null,D--)}function C(r,i){D++,K[D]=r.current,r.current=i}var P=$(null),X=$(null),J=$(null),ne=$(null);function re(r,i){switch(C(J,i),C(X,r),C(P,null),i.nodeType){case 9:case 11:r=(r=i.documentElement)&&(r=r.namespaceURI)?hy(r):0;break;default:if(r=i.tagName,i=i.namespaceURI)i=hy(i),r=py(i,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}Y(P),C(P,r)}function ue(){Y(P),Y(X),Y(J)}function xe(r){r.memoizedState!==null&&C(ne,r);var i=P.current,u=py(i,r.type);i!==u&&(C(X,r),C(P,u))}function be(r){X.current===r&&(Y(P),Y(X)),ne.current===r&&(Y(ne),po._currentValue=Q)}var ye,pe;function Se(r){if(ye===void 0)try{throw Error()}catch(u){var i=u.stack.trim().match(/\n( *(at )?)/);ye=i&&i[1]||"",pe=-1)":-1x||Z[d]!==le[x]){var fe=` -`+Z[d].replace(" at new "," at ");return r.displayName&&fe.includes("")&&(fe=fe.replace("",r.displayName)),fe}while(1<=d&&0<=x);break}}}finally{Oe=!1,Error.prepareStackTrace=u}return(u=r?r.displayName||r.name:"")?Se(u):""}function ft(r,i){switch(r.tag){case 26:case 27:case 5:return Se(r.type);case 16:return Se("Lazy");case 13:return r.child!==i&&i!==null?Se("Suspense Fallback"):Se("Suspense");case 19:return Se("SuspenseList");case 0:case 15:return je(r.type,!1);case 11:return je(r.type.render,!1);case 1:return je(r.type,!0);case 31:return Se("Activity");default:return""}}function rt(r){try{var i="",u=null;do i+=ft(r,u),u=r,r=r.return;while(r);return i}catch(d){return` +`+Z[d].replace(" at new "," at ");return r.displayName&&fe.includes("")&&(fe=fe.replace("",r.displayName)),fe}while(1<=d&&0<=x);break}}}finally{Oe=!1,Error.prepareStackTrace=u}return(u=r?r.displayName||r.name:"")?Se(u):""}function ft(r,i){switch(r.tag){case 26:case 27:case 5:return Se(r.type);case 16:return Se("Lazy");case 13:return r.child!==i&&i!==null?Se("Suspense Fallback"):Se("Suspense");case 19:return Se("SuspenseList");case 0:case 15:return Te(r.type,!1);case 11:return Te(r.type.render,!1);case 1:return Te(r.type,!0);case 31:return Se("Activity");default:return""}}function rt(r){try{var i="",u=null;do i+=ft(r,u),u=r,r=r.return;while(r);return i}catch(d){return` Error generating stack: `+d.message+` -`+d.stack}}var Dt=Object.prototype.hasOwnProperty,Pt=e.unstable_scheduleCallback,Bt=e.unstable_cancelCallback,kn=e.unstable_shouldYield,Rn=e.unstable_requestPaint,Rt=e.unstable_now,qr=e.unstable_getCurrentPriorityLevel,ce=e.unstable_ImmediatePriority,ge=e.unstable_UserBlockingPriority,Ne=e.unstable_NormalPriority,Ie=e.unstable_LowPriority,Xe=e.unstable_IdlePriority,Zt=e.log,On=e.unstable_setDisableYieldValue,It=null,wt=null;function Gt(r){if(typeof Zt=="function"&&On(r),wt&&typeof wt.setStrictMode=="function")try{wt.setStrictMode(It,r)}catch{}}var et=Math.clz32?Math.clz32:Xc,Zn=Math.log,fn=Math.LN2;function Xc(r){return r>>>=0,r===0?32:31-(Zn(r)/fn|0)|0}var fl=256,dl=262144,hl=4194304;function ur(r){var i=r&42;if(i!==0)return i;switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return r&261888;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function pl(r,i,u){var d=r.pendingLanes;if(d===0)return 0;var x=0,v=r.suspendedLanes,j=r.pingedLanes;r=r.warmLanes;var O=d&134217727;return O!==0?(d=O&~v,d!==0?x=ur(d):(j&=O,j!==0?x=ur(j):u||(u=O&~r,u!==0&&(x=ur(u))))):(O=d&~v,O!==0?x=ur(O):j!==0?x=ur(j):u||(u=d&~r,u!==0&&(x=ur(u)))),x===0?0:i!==0&&i!==x&&(i&v)===0&&(v=x&-x,u=i&-i,v>=u||v===32&&(u&4194048)!==0)?i:x}function ki(r,i){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&i)===0}function Qc(r,i){switch(r){case 1:case 2:case 4:case 8:case 64:return i+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function cs(){var r=hl;return hl<<=1,(hl&62914560)===0&&(hl=4194304),r}function ka(r){for(var i=[],u=0;31>u;u++)i.push(r);return i}function Ei(r,i){r.pendingLanes|=i,i!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function Zc(r,i,u,d,x,v){var j=r.pendingLanes;r.pendingLanes=u,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=u,r.entangledLanes&=u,r.errorRecoveryDisabledLanes&=u,r.shellSuspendCounter=0;var O=r.entanglements,Z=r.expirationTimes,le=r.hiddenUpdates;for(u=j&~u;0"u")return null;try{return r.activeElement||r.body}catch{return r.body}}var tf=/[\n"\\]/g;function en(r){return r.replace(tf,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function ji(r,i,u,d,x,v,j,O){r.name="",j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?r.type=j:r.removeAttribute("type"),i!=null?j==="number"?(i===0&&r.value===""||r.value!=i)&&(r.value=""+Wt(i)):r.value!==""+Wt(i)&&(r.value=""+Wt(i)):j!=="submit"&&j!=="reset"||r.removeAttribute("value"),i!=null?Ta(r,j,Wt(i)):u!=null?Ta(r,j,Wt(u)):d!=null&&r.removeAttribute("value"),x==null&&v!=null&&(r.defaultChecked=!!v),x!=null&&(r.checked=x&&typeof x!="function"&&typeof x!="symbol"),O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?r.name=""+Wt(O):r.removeAttribute("name")}function Ss(r,i,u,d,x,v,j,O){if(v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(r.type=v),i!=null||u!=null){if(!(v!=="submit"&&v!=="reset"||i!=null)){Fr(r);return}u=u!=null?""+Wt(u):"",i=i!=null?""+Wt(i):u,O||i===r.value||(r.value=i),r.defaultValue=i}d=d??x,d=typeof d!="function"&&typeof d!="symbol"&&!!d,r.checked=O?r.checked:!!d,r.defaultChecked=!!d,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(r.name=j),Fr(r)}function Ta(r,i,u){i==="number"&&Ci(r.ownerDocument)===r||r.defaultValue===""+u||(r.defaultValue=""+u)}function dr(r,i,u,d){if(r=r.options,i){i={};for(var x=0;x"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),of=!1;if(pr)try{var za={};Object.defineProperty(za,"passive",{get:function(){of=!0}}),window.addEventListener("test",za,za),window.removeEventListener("test",za,za)}catch{of=!1}var Yr=null,sf=null,Es=null;function pg(){if(Es)return Es;var r,i=sf,u=i.length,d,x="value"in Yr?Yr.value:Yr.textContent,v=x.length;for(r=0;r=Ra),bg=" ",wg=!1;function _g(r,i){switch(r){case"keyup":return p2.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sg(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var wl=!1;function g2(r,i){switch(r){case"compositionend":return Sg(i);case"keypress":return i.which!==32?null:(wg=!0,bg);case"textInput":return r=i.data,r===bg&&wg?null:r;default:return null}}function x2(r,i){if(wl)return r==="compositionend"||!hf&&_g(r,i)?(r=pg(),Es=sf=Yr=null,wl=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1=i)return{node:u,offset:i-r};r=d}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=zg(u)}}function Dg(r,i){return r&&i?r===i?!0:r&&r.nodeType===3?!1:i&&i.nodeType===3?Dg(r,i.parentNode):"contains"in r?r.contains(i):r.compareDocumentPosition?!!(r.compareDocumentPosition(i)&16):!1:!1}function Rg(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var i=Ci(r.document);i instanceof r.HTMLIFrameElement;){try{var u=typeof i.contentWindow.location.href=="string"}catch{u=!1}if(u)r=i.contentWindow;else break;i=Ci(r.document)}return i}function gf(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i&&(i==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||i==="textarea"||r.contentEditable==="true")}var E2=pr&&"documentMode"in document&&11>=document.documentMode,_l=null,xf=null,Ba=null,yf=!1;function Og(r,i,u){var d=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;yf||_l==null||_l!==Ci(d)||(d=_l,"selectionStart"in d&&gf(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),Ba&&Ha(Ba,d)||(Ba=d,d=yu(xf,"onSelect"),0>=j,x-=j,Jn=1<<32-et(i)+x|u<Le?(Ge=_e,_e=null):Ge=_e.sibling;var Ke=ae(te,_e,ie[Le],de);if(Ke===null){_e===null&&(_e=Ge);break}r&&_e&&Ke.alternate===null&&i(te,_e),W=v(Ke,W,Le),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke,_e=Ge}if(Le===ie.length)return u(te,_e),Fe&&gr(te,Le),ke;if(_e===null){for(;LeLe?(Ge=_e,_e=null):Ge=_e.sibling;var mi=ae(te,_e,Ke.value,de);if(mi===null){_e===null&&(_e=Ge);break}r&&_e&&mi.alternate===null&&i(te,_e),W=v(mi,W,Le),Ze===null?ke=mi:Ze.sibling=mi,Ze=mi,_e=Ge}if(Ke.done)return u(te,_e),Fe&&gr(te,Le),ke;if(_e===null){for(;!Ke.done;Le++,Ke=ie.next())Ke=he(te,Ke.value,de),Ke!==null&&(W=v(Ke,W,Le),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke);return Fe&&gr(te,Le),ke}for(_e=d(_e);!Ke.done;Le++,Ke=ie.next())Ke=oe(_e,te,Le,Ke.value,de),Ke!==null&&(r&&Ke.alternate!==null&&_e.delete(Ke.key===null?Le:Ke.key),W=v(Ke,W,Le),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke);return r&&_e.forEach(function(GE){return i(te,GE)}),Fe&&gr(te,Le),ke}function at(te,W,ie,de){if(typeof ie=="object"&&ie!==null&&ie.type===E&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case b:e:{for(var ke=ie.key;W!==null;){if(W.key===ke){if(ke=ie.type,ke===E){if(W.tag===7){u(te,W.sibling),de=x(W,ie.props.children),de.return=te,te=de;break e}}else if(W.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===R&&Bi(ke)===W.type){u(te,W.sibling),de=x(W,ie.props),Pa(de,ie),de.return=te,te=de;break e}u(te,W);break}else i(te,W);W=W.sibling}ie.type===E?(de=Di(ie.props.children,te.mode,de,ie.key),de.return=te,te=de):(de=Os(ie.type,ie.key,ie.props,null,te.mode,de),Pa(de,ie),de.return=te,te=de)}return j(te);case w:e:{for(ke=ie.key;W!==null;){if(W.key===ke)if(W.tag===4&&W.stateNode.containerInfo===ie.containerInfo&&W.stateNode.implementation===ie.implementation){u(te,W.sibling),de=x(W,ie.children||[]),de.return=te,te=de;break e}else{u(te,W);break}else i(te,W);W=W.sibling}de=Ef(ie,te.mode,de),de.return=te,te=de}return j(te);case R:return ie=Bi(ie),at(te,W,ie,de)}if(F(ie))return we(te,W,ie,de);if(U(ie)){if(ke=U(ie),typeof ke!="function")throw Error(l(150));return ie=ke.call(ie),Ce(te,W,ie,de)}if(typeof ie.then=="function")return at(te,W,Us(ie),de);if(ie.$$typeof===k)return at(te,W,Bs(te,ie),de);Vs(te,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint"?(ie=""+ie,W!==null&&W.tag===6?(u(te,W.sibling),de=x(W,ie),de.return=te,te=de):(u(te,W),de=kf(ie,te.mode,de),de.return=te,te=de),j(te)):u(te,W)}return function(te,W,ie,de){try{Va=0;var ke=at(te,W,ie,de);return Dl=null,ke}catch(_e){if(_e===Ml||_e===qs)throw _e;var Ze=hn(29,_e,null,te.mode);return Ze.lanes=de,Ze.return=te,Ze}finally{}}}var qi=ix(!0),lx=ix(!1),Jr=!1;function Hf(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Bf(r,i){r=r.updateQueue,i.updateQueue===r&&(i.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function Wr(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function ei(r,i,u){var d=r.updateQueue;if(d===null)return null;if(d=d.shared,(Je&2)!==0){var x=d.pending;return x===null?i.next=i:(i.next=x.next,x.next=i),d.pending=i,i=Rs(r),Ug(r,null,u),i}return Ds(r,d,i,u),Rs(r)}function Ga(r,i,u){if(i=i.updateQueue,i!==null&&(i=i.shared,(u&4194048)!==0)){var d=i.lanes;d&=r.pendingLanes,u|=d,i.lanes=u,ds(r,u)}}function If(r,i){var u=r.updateQueue,d=r.alternate;if(d!==null&&(d=d.updateQueue,u===d)){var x=null,v=null;if(u=u.firstBaseUpdate,u!==null){do{var j={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};v===null?x=v=j:v=v.next=j,u=u.next}while(u!==null);v===null?x=v=i:v=v.next=i}else x=v=i;u={baseState:d.baseState,firstBaseUpdate:x,lastBaseUpdate:v,shared:d.shared,callbacks:d.callbacks},r.updateQueue=u;return}r=u.lastBaseUpdate,r===null?u.firstBaseUpdate=i:r.next=i,u.lastBaseUpdate=i}var qf=!1;function Fa(){if(qf){var r=zl;if(r!==null)throw r}}function Ya(r,i,u,d){qf=!1;var x=r.updateQueue;Jr=!1;var v=x.firstBaseUpdate,j=x.lastBaseUpdate,O=x.shared.pending;if(O!==null){x.shared.pending=null;var Z=O,le=Z.next;Z.next=null,j===null?v=le:j.next=le,j=Z;var fe=r.alternate;fe!==null&&(fe=fe.updateQueue,O=fe.lastBaseUpdate,O!==j&&(O===null?fe.firstBaseUpdate=le:O.next=le,fe.lastBaseUpdate=Z))}if(v!==null){var he=x.baseState;j=0,fe=le=Z=null,O=v;do{var ae=O.lane&-536870913,oe=ae!==O.lane;if(oe?(Pe&ae)===ae:(d&ae)===ae){ae!==0&&ae===Al&&(qf=!0),fe!==null&&(fe=fe.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var we=r,Ce=O;ae=i;var at=u;switch(Ce.tag){case 1:if(we=Ce.payload,typeof we=="function"){he=we.call(at,he,ae);break e}he=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=Ce.payload,ae=typeof we=="function"?we.call(at,he,ae):we,ae==null)break e;he=p({},he,ae);break e;case 2:Jr=!0}}ae=O.callback,ae!==null&&(r.flags|=64,oe&&(r.flags|=8192),oe=x.callbacks,oe===null?x.callbacks=[ae]:oe.push(ae))}else oe={lane:ae,tag:O.tag,payload:O.payload,callback:O.callback,next:null},fe===null?(le=fe=oe,Z=he):fe=fe.next=oe,j|=ae;if(O=O.next,O===null){if(O=x.shared.pending,O===null)break;oe=O,O=oe.next,oe.next=null,x.lastBaseUpdate=oe,x.shared.pending=null}}while(!0);fe===null&&(Z=he),x.baseState=Z,x.firstBaseUpdate=le,x.lastBaseUpdate=fe,v===null&&(x.shared.lanes=0),li|=j,r.lanes=j,r.memoizedState=he}}function ax(r,i){if(typeof r!="function")throw Error(l(191,r));r.call(i)}function ox(r,i){var u=r.callbacks;if(u!==null)for(r.callbacks=null,r=0;rv?v:8;var j=z.T,O={};z.T=O,ld(r,!1,i,u);try{var Z=x(),le=z.S;if(le!==null&&le(O,Z),Z!==null&&typeof Z=="object"&&typeof Z.then=="function"){var fe=R2(Z,d);Za(r,i,fe,yn(r))}else Za(r,i,d,yn(r))}catch(he){Za(r,i,{then:function(){},status:"rejected",reason:he},yn())}finally{G.p=v,j!==null&&O.types!==null&&(j.types=O.types),z.T=j}}function q2(){}function rd(r,i,u,d){if(r.tag!==5)throw Error(l(476));var x=Ix(r).queue;Bx(r,x,i,Q,u===null?q2:function(){return qx(r),u(d)})}function Ix(r){var i=r.memoizedState;if(i!==null)return i;i={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:br,lastRenderedState:Q},next:null};var u={};return i.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:br,lastRenderedState:u},next:null},r.memoizedState=i,r=r.alternate,r!==null&&(r.memoizedState=i),i}function qx(r){var i=Ix(r);i.next===null&&(i=r.alternate.memoizedState),Za(r,i.next.queue,{},yn())}function id(){return $t(po)}function $x(){return St().memoizedState}function Ux(){return St().memoizedState}function $2(r){for(var i=r.return;i!==null;){switch(i.tag){case 24:case 3:var u=yn();r=Wr(u);var d=ei(i,r,u);d!==null&&(on(d,i,u),Ga(d,i,u)),i={cache:Df()},r.payload=i;return}i=i.return}}function U2(r,i,u){var d=yn();u={lane:d,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Ws(r)?Px(i,u):(u=_f(r,i,u,d),u!==null&&(on(u,r,d),Gx(u,i,d)))}function Vx(r,i,u){var d=yn();Za(r,i,u,d)}function Za(r,i,u,d){var x={lane:d,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(Ws(r))Px(i,x);else{var v=r.alternate;if(r.lanes===0&&(v===null||v.lanes===0)&&(v=i.lastRenderedReducer,v!==null))try{var j=i.lastRenderedState,O=v(j,u);if(x.hasEagerState=!0,x.eagerState=O,dn(O,j))return Ds(r,i,x,0),st===null&&Ms(),!1}catch{}finally{}if(u=_f(r,i,x,d),u!==null)return on(u,r,d),Gx(u,i,d),!0}return!1}function ld(r,i,u,d){if(d={lane:2,revertLane:Hd(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Ws(r)){if(i)throw Error(l(479))}else i=_f(r,u,d,2),i!==null&&on(i,r,2)}function Ws(r){var i=r.alternate;return r===Re||i!==null&&i===Re}function Px(r,i){Ol=Fs=!0;var u=r.pending;u===null?i.next=i:(i.next=u.next,u.next=i),r.pending=i}function Gx(r,i,u){if((u&4194048)!==0){var d=i.lanes;d&=r.pendingLanes,u|=d,i.lanes=u,ds(r,u)}}var Ka={readContext:$t,use:Qs,useCallback:xt,useContext:xt,useEffect:xt,useImperativeHandle:xt,useLayoutEffect:xt,useInsertionEffect:xt,useMemo:xt,useReducer:xt,useRef:xt,useState:xt,useDebugValue:xt,useDeferredValue:xt,useTransition:xt,useSyncExternalStore:xt,useId:xt,useHostTransitionStatus:xt,useFormState:xt,useActionState:xt,useOptimistic:xt,useMemoCache:xt,useCacheRefresh:xt};Ka.useEffectEvent=xt;var Fx={readContext:$t,use:Qs,useCallback:function(r,i){return Kt().memoizedState=[r,i===void 0?null:i],r},useContext:$t,useEffect:Tx,useImperativeHandle:function(r,i,u){u=u!=null?u.concat([r]):null,Ks(4194308,4,Dx.bind(null,i,r),u)},useLayoutEffect:function(r,i){return Ks(4194308,4,r,i)},useInsertionEffect:function(r,i){Ks(4,2,r,i)},useMemo:function(r,i){var u=Kt();i=i===void 0?null:i;var d=r();if($i){Gt(!0);try{r()}finally{Gt(!1)}}return u.memoizedState=[d,i],d},useReducer:function(r,i,u){var d=Kt();if(u!==void 0){var x=u(i);if($i){Gt(!0);try{u(i)}finally{Gt(!1)}}}else x=i;return d.memoizedState=d.baseState=x,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:x},d.queue=r,r=r.dispatch=U2.bind(null,Re,r),[d.memoizedState,r]},useRef:function(r){var i=Kt();return r={current:r},i.memoizedState=r},useState:function(r){r=Jf(r);var i=r.queue,u=Vx.bind(null,Re,i);return i.dispatch=u,[r.memoizedState,u]},useDebugValue:td,useDeferredValue:function(r,i){var u=Kt();return nd(u,r,i)},useTransition:function(){var r=Jf(!1);return r=Bx.bind(null,Re,r.queue,!0,!1),Kt().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,i,u){var d=Re,x=Kt();if(Fe){if(u===void 0)throw Error(l(407));u=u()}else{if(u=i(),st===null)throw Error(l(349));(Pe&127)!==0||hx(d,i,u)}x.memoizedState=u;var v={value:u,getSnapshot:i};return x.queue=v,Tx(mx.bind(null,d,v,r),[r]),d.flags|=2048,Hl(9,{destroy:void 0},px.bind(null,d,v,u,i),null),u},useId:function(){var r=Kt(),i=st.identifierPrefix;if(Fe){var u=Wn,d=Jn;u=(d&~(1<<32-et(d)-1)).toString(32)+u,i="_"+i+"R_"+u,u=Ys++,0<\/script>",v=v.removeChild(v.firstChild);break;case"select":v=typeof d.is=="string"?j.createElement("select",{is:d.is}):j.createElement("select"),d.multiple?v.multiple=!0:d.size&&(v.size=d.size);break;default:v=typeof d.is=="string"?j.createElement(x,{is:d.is}):j.createElement(x)}}v[Ot]=i,v[Ft]=d;e:for(j=i.child;j!==null;){if(j.tag===5||j.tag===6)v.appendChild(j.stateNode);else if(j.tag!==4&&j.tag!==27&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===i)break e;for(;j.sibling===null;){if(j.return===null||j.return===i)break e;j=j.return}j.sibling.return=j.return,j=j.sibling}i.stateNode=v;e:switch(Vt(v,x,d),x){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&_r(i)}}return ht(i),vd(i,i.type,r===null?null:r.memoizedProps,i.pendingProps,u),null;case 6:if(r&&i.stateNode!=null)r.memoizedProps!==d&&_r(i);else{if(typeof d!="string"&&i.stateNode===null)throw Error(l(166));if(r=J.current,jl(i)){if(r=i.stateNode,u=i.memoizedProps,d=null,x=qt,x!==null)switch(x.tag){case 27:case 5:d=x.memoizedProps}r[Ot]=i,r=!!(r.nodeValue===u||d!==null&&d.suppressHydrationWarning===!0||fy(r.nodeValue,u)),r||Zr(i,!0)}else r=vu(r).createTextNode(d),r[Ot]=i,i.stateNode=r}return ht(i),null;case 31:if(u=i.memoizedState,r===null||r.memoizedState!==null){if(d=jl(i),u!==null){if(r===null){if(!d)throw Error(l(318));if(r=i.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(l(557));r[Ot]=i}else Ri(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;ht(i),r=!1}else u=Tf(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=u),r=!0;if(!r)return i.flags&256?(mn(i),i):(mn(i),null);if((i.flags&128)!==0)throw Error(l(558))}return ht(i),null;case 13:if(d=i.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(x=jl(i),d!==null&&d.dehydrated!==null){if(r===null){if(!x)throw Error(l(318));if(x=i.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(l(317));x[Ot]=i}else Ri(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;ht(i),x=!1}else x=Tf(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=x),x=!0;if(!x)return i.flags&256?(mn(i),i):(mn(i),null)}return mn(i),(i.flags&128)!==0?(i.lanes=u,i):(u=d!==null,r=r!==null&&r.memoizedState!==null,u&&(d=i.child,x=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(x=d.alternate.memoizedState.cachePool.pool),v=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(v=d.memoizedState.cachePool.pool),v!==x&&(d.flags|=2048)),u!==r&&u&&(i.child.flags|=8192),iu(i,i.updateQueue),ht(i),null);case 4:return ue(),r===null&&$d(i.stateNode.containerInfo),ht(i),null;case 10:return yr(i.type),ht(i),null;case 19:if(Y(_t),d=i.memoizedState,d===null)return ht(i),null;if(x=(i.flags&128)!==0,v=d.rendering,v===null)if(x)Wa(d,!1);else{if(yt!==0||r!==null&&(r.flags&128)!==0)for(r=i.child;r!==null;){if(v=Gs(r),v!==null){for(i.flags|=128,Wa(d,!1),r=v.updateQueue,i.updateQueue=r,iu(i,r),i.subtreeFlags=0,r=u,u=i.child;u!==null;)Vg(u,r),u=u.sibling;return C(_t,_t.current&1|2),Fe&&gr(i,d.treeForkCount),i.child}r=r.sibling}d.tail!==null&&Rt()>uu&&(i.flags|=128,x=!0,Wa(d,!1),i.lanes=4194304)}else{if(!x)if(r=Gs(v),r!==null){if(i.flags|=128,x=!0,r=r.updateQueue,i.updateQueue=r,iu(i,r),Wa(d,!0),d.tail===null&&d.tailMode==="hidden"&&!v.alternate&&!Fe)return ht(i),null}else 2*Rt()-d.renderingStartTime>uu&&u!==536870912&&(i.flags|=128,x=!0,Wa(d,!1),i.lanes=4194304);d.isBackwards?(v.sibling=i.child,i.child=v):(r=d.last,r!==null?r.sibling=v:i.child=v,d.last=v)}return d.tail!==null?(r=d.tail,d.rendering=r,d.tail=r.sibling,d.renderingStartTime=Rt(),r.sibling=null,u=_t.current,C(_t,x?u&1|2:u&1),Fe&&gr(i,d.treeForkCount),r):(ht(i),null);case 22:case 23:return mn(i),Uf(),d=i.memoizedState!==null,r!==null?r.memoizedState!==null!==d&&(i.flags|=8192):d&&(i.flags|=8192),d?(u&536870912)!==0&&(i.flags&128)===0&&(ht(i),i.subtreeFlags&6&&(i.flags|=8192)):ht(i),u=i.updateQueue,u!==null&&iu(i,u.retryQueue),u=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),d=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(d=i.memoizedState.cachePool.pool),d!==u&&(i.flags|=2048),r!==null&&Y(Hi),null;case 24:return u=null,r!==null&&(u=r.memoizedState.cache),i.memoizedState.cache!==u&&(i.flags|=2048),yr(Et),ht(i),null;case 25:return null;case 30:return null}throw Error(l(156,i.tag))}function Y2(r,i){switch(Cf(i),i.tag){case 1:return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 3:return yr(Et),ue(),r=i.flags,(r&65536)!==0&&(r&128)===0?(i.flags=r&-65537|128,i):null;case 26:case 27:case 5:return be(i),null;case 31:if(i.memoizedState!==null){if(mn(i),i.alternate===null)throw Error(l(340));Ri()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 13:if(mn(i),r=i.memoizedState,r!==null&&r.dehydrated!==null){if(i.alternate===null)throw Error(l(340));Ri()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 19:return Y(_t),null;case 4:return ue(),null;case 10:return yr(i.type),null;case 22:case 23:return mn(i),Uf(),r!==null&&Y(Hi),r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 24:return yr(Et),null;case 25:return null;default:return null}}function g0(r,i){switch(Cf(i),i.tag){case 3:yr(Et),ue();break;case 26:case 27:case 5:be(i);break;case 4:ue();break;case 31:i.memoizedState!==null&&mn(i);break;case 13:mn(i);break;case 19:Y(_t);break;case 10:yr(i.type);break;case 22:case 23:mn(i),Uf(),r!==null&&Y(Hi);break;case 24:yr(Et)}}function eo(r,i){try{var u=i.updateQueue,d=u!==null?u.lastEffect:null;if(d!==null){var x=d.next;u=x;do{if((u.tag&r)===r){d=void 0;var v=u.create,j=u.inst;d=v(),j.destroy=d}u=u.next}while(u!==x)}}catch(O){nt(i,i.return,O)}}function ri(r,i,u){try{var d=i.updateQueue,x=d!==null?d.lastEffect:null;if(x!==null){var v=x.next;d=v;do{if((d.tag&r)===r){var j=d.inst,O=j.destroy;if(O!==void 0){j.destroy=void 0,x=i;var Z=u,le=O;try{le()}catch(fe){nt(x,Z,fe)}}}d=d.next}while(d!==v)}}catch(fe){nt(i,i.return,fe)}}function x0(r){var i=r.updateQueue;if(i!==null){var u=r.stateNode;try{ox(i,u)}catch(d){nt(r,r.return,d)}}}function y0(r,i,u){u.props=Ui(r.type,r.memoizedProps),u.state=r.memoizedState;try{u.componentWillUnmount()}catch(d){nt(r,i,d)}}function to(r,i){try{var u=r.ref;if(u!==null){switch(r.tag){case 26:case 27:case 5:var d=r.stateNode;break;case 30:d=r.stateNode;break;default:d=r.stateNode}typeof u=="function"?r.refCleanup=u(d):u.current=d}}catch(x){nt(r,i,x)}}function er(r,i){var u=r.ref,d=r.refCleanup;if(u!==null)if(typeof d=="function")try{d()}catch(x){nt(r,i,x)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(x){nt(r,i,x)}else u.current=null}function v0(r){var i=r.type,u=r.memoizedProps,d=r.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":u.autoFocus&&d.focus();break e;case"img":u.src?d.src=u.src:u.srcSet&&(d.srcset=u.srcSet)}}catch(x){nt(r,r.return,x)}}function bd(r,i,u){try{var d=r.stateNode;mE(d,r.type,u,i),d[Ft]=i}catch(x){nt(r,r.return,x)}}function b0(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&ci(r.type)||r.tag===4}function wd(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||b0(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.tag===27&&ci(r.type)||r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function _d(r,i,u){var d=r.tag;if(d===5||d===6)r=r.stateNode,i?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(r,i):(i=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,i.appendChild(r),u=u._reactRootContainer,u!=null||i.onclick!==null||(i.onclick=hr));else if(d!==4&&(d===27&&ci(r.type)&&(u=r.stateNode,i=null),r=r.child,r!==null))for(_d(r,i,u),r=r.sibling;r!==null;)_d(r,i,u),r=r.sibling}function lu(r,i,u){var d=r.tag;if(d===5||d===6)r=r.stateNode,i?u.insertBefore(r,i):u.appendChild(r);else if(d!==4&&(d===27&&ci(r.type)&&(u=r.stateNode),r=r.child,r!==null))for(lu(r,i,u),r=r.sibling;r!==null;)lu(r,i,u),r=r.sibling}function w0(r){var i=r.stateNode,u=r.memoizedProps;try{for(var d=r.type,x=i.attributes;x.length;)i.removeAttributeNode(x[0]);Vt(i,d,u),i[Ot]=r,i[Ft]=u}catch(v){nt(r,r.return,v)}}var Sr=!1,jt=!1,Sd=!1,_0=typeof WeakSet=="function"?WeakSet:Set,Ht=null;function X2(r,i){if(r=r.containerInfo,Pd=Nu,r=Rg(r),gf(r)){if("selectionStart"in r)var u={start:r.selectionStart,end:r.selectionEnd};else e:{u=(u=r.ownerDocument)&&u.defaultView||window;var d=u.getSelection&&u.getSelection();if(d&&d.rangeCount!==0){u=d.anchorNode;var x=d.anchorOffset,v=d.focusNode;d=d.focusOffset;try{u.nodeType,v.nodeType}catch{u=null;break e}var j=0,O=-1,Z=-1,le=0,fe=0,he=r,ae=null;t:for(;;){for(var oe;he!==u||x!==0&&he.nodeType!==3||(O=j+x),he!==v||d!==0&&he.nodeType!==3||(Z=j+d),he.nodeType===3&&(j+=he.nodeValue.length),(oe=he.firstChild)!==null;)ae=he,he=oe;for(;;){if(he===r)break t;if(ae===u&&++le===x&&(O=j),ae===v&&++fe===d&&(Z=j),(oe=he.nextSibling)!==null)break;he=ae,ae=he.parentNode}he=oe}u=O===-1||Z===-1?null:{start:O,end:Z}}else u=null}u=u||{start:0,end:0}}else u=null;for(Gd={focusedElem:r,selectionRange:u},Nu=!1,Ht=i;Ht!==null;)if(i=Ht,r=i.child,(i.subtreeFlags&1028)!==0&&r!==null)r.return=i,Ht=r;else for(;Ht!==null;){switch(i=Ht,v=i.alternate,r=i.flags,i.tag){case 0:if((r&4)!==0&&(r=i.updateQueue,r=r!==null?r.events:null,r!==null))for(u=0;u title"))),Vt(v,d,u),v[Ot]=r,kt(v),d=v;break e;case"link":var j=jy("link","href",x).get(d+(u.href||""));if(j){for(var O=0;Oat&&(j=at,at=Ce,Ce=j);var te=Mg(O,Ce),W=Mg(O,at);if(te&&W&&(oe.rangeCount!==1||oe.anchorNode!==te.node||oe.anchorOffset!==te.offset||oe.focusNode!==W.node||oe.focusOffset!==W.offset)){var ie=he.createRange();ie.setStart(te.node,te.offset),oe.removeAllRanges(),Ce>at?(oe.addRange(ie),oe.extend(W.node,W.offset)):(ie.setEnd(W.node,W.offset),oe.addRange(ie))}}}}for(he=[],oe=O;oe=oe.parentNode;)oe.nodeType===1&&he.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;Ou?32:u,z.T=null,u=Ad,Ad=null;var v=oi,j=jr;if(Lt=0,Ul=oi=null,jr=0,(Je&6)!==0)throw Error(l(331));var O=Je;if(Je|=4,D0(v.current),A0(v,v.current,j,u),Je=O,oo(0,!1),wt&&typeof wt.onPostCommitFiberRoot=="function")try{wt.onPostCommitFiberRoot(It,v)}catch{}return!0}finally{G.p=x,z.T=d,K0(r,i)}}function W0(r,i,u){i=Nn(u,i),i=ud(r.stateNode,i,2),r=ei(r,i,2),r!==null&&(Ei(r,2),tr(r))}function nt(r,i,u){if(r.tag===3)W0(r,r,u);else for(;i!==null;){if(i.tag===3){W0(i,r,u);break}else if(i.tag===1){var d=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(ai===null||!ai.has(d))){r=Nn(u,r),u=e0(2),d=ei(i,u,2),d!==null&&(t0(u,d,i,r),Ei(d,2),tr(d));break}}i=i.return}}function Rd(r,i,u){var d=r.pingCache;if(d===null){d=r.pingCache=new K2;var x=new Set;d.set(i,x)}else x=d.get(i),x===void 0&&(x=new Set,d.set(i,x));x.has(u)||(Nd=!0,x.add(u),r=nE.bind(null,r,i,u),i.then(r,r))}function nE(r,i,u){var d=r.pingCache;d!==null&&d.delete(i),r.pingedLanes|=r.suspendedLanes&u,r.warmLanes&=~u,st===r&&(Pe&u)===u&&(yt===4||yt===3&&(Pe&62914560)===Pe&&300>Rt()-su?(Je&2)===0&&Vl(r,0):Cd|=u,$l===Pe&&($l=0)),tr(r)}function ey(r,i){i===0&&(i=cs()),r=Mi(r,i),r!==null&&(Ei(r,i),tr(r))}function rE(r){var i=r.memoizedState,u=0;i!==null&&(u=i.retryLane),ey(r,u)}function iE(r,i){var u=0;switch(r.tag){case 31:case 13:var d=r.stateNode,x=r.memoizedState;x!==null&&(u=x.retryLane);break;case 19:d=r.stateNode;break;case 22:d=r.stateNode._retryCache;break;default:throw Error(l(314))}d!==null&&d.delete(i),ey(r,u)}function lE(r,i){return Pt(r,i)}var mu=null,Gl=null,Od=!1,gu=!1,Ld=!1,ui=0;function tr(r){r!==Gl&&r.next===null&&(Gl===null?mu=Gl=r:Gl=Gl.next=r),gu=!0,Od||(Od=!0,oE())}function oo(r,i){if(!Ld&&gu){Ld=!0;do for(var u=!1,d=mu;d!==null;){if(r!==0){var x=d.pendingLanes;if(x===0)var v=0;else{var j=d.suspendedLanes,O=d.pingedLanes;v=(1<<31-et(42|r)+1)-1,v&=x&~(j&~O),v=v&201326741?v&201326741|1:v?v|2:0}v!==0&&(u=!0,iy(d,v))}else v=Pe,v=pl(d,d===st?v:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(v&3)===0||ki(d,v)||(u=!0,iy(d,v));d=d.next}while(u);Ld=!1}}function aE(){ty()}function ty(){gu=Od=!1;var r=0;ui!==0&&xE()&&(r=ui);for(var i=Rt(),u=null,d=mu;d!==null;){var x=d.next,v=ny(d,i);v===0?(d.next=null,u===null?mu=x:u.next=x,x===null&&(Gl=u)):(u=d,(r!==0||(v&3)!==0)&&(gu=!0)),d=x}Lt!==0&&Lt!==5||oo(r),ui!==0&&(ui=0)}function ny(r,i){for(var u=r.suspendedLanes,d=r.pingedLanes,x=r.expirationTimes,v=r.pendingLanes&-62914561;0O)break;var fe=Z.transferSize,he=Z.initiatorType;fe&&dy(he)&&(Z=Z.responseEnd,j+=fe*(Z"u"?null:document;function ky(r,i,u){var d=Fl;if(d&&typeof i=="string"&&i){var x=en(i);x='link[rel="'+r+'"][href="'+x+'"]',typeof u=="string"&&(x+='[crossorigin="'+u+'"]'),Sy.has(x)||(Sy.add(x),r={rel:r,crossOrigin:u,href:i},d.querySelector(x)===null&&(i=d.createElement("link"),Vt(i,"link",r),kt(i),d.head.appendChild(i)))}}function NE(r){Tr.D(r),ky("dns-prefetch",r,null)}function CE(r,i){Tr.C(r,i),ky("preconnect",r,i)}function jE(r,i,u){Tr.L(r,i,u);var d=Fl;if(d&&r&&i){var x='link[rel="preload"][as="'+en(i)+'"]';i==="image"&&u&&u.imageSrcSet?(x+='[imagesrcset="'+en(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(x+='[imagesizes="'+en(u.imageSizes)+'"]')):x+='[href="'+en(r)+'"]';var v=x;switch(i){case"style":v=Yl(r);break;case"script":v=Xl(r)}Mn.has(v)||(r=p({rel:"preload",href:i==="image"&&u&&u.imageSrcSet?void 0:r,as:i},u),Mn.set(v,r),d.querySelector(x)!==null||i==="style"&&d.querySelector(fo(v))||i==="script"&&d.querySelector(ho(v))||(i=d.createElement("link"),Vt(i,"link",r),kt(i),d.head.appendChild(i)))}}function TE(r,i){Tr.m(r,i);var u=Fl;if(u&&r){var d=i&&typeof i.as=="string"?i.as:"script",x='link[rel="modulepreload"][as="'+en(d)+'"][href="'+en(r)+'"]',v=x;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":v=Xl(r)}if(!Mn.has(v)&&(r=p({rel:"modulepreload",href:r},i),Mn.set(v,r),u.querySelector(x)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(ho(v)))return}d=u.createElement("link"),Vt(d,"link",r),kt(d),u.head.appendChild(d)}}}function AE(r,i,u){Tr.S(r,i,u);var d=Fl;if(d&&r){var x=Pr(d).hoistableStyles,v=Yl(r);i=i||"default";var j=x.get(v);if(!j){var O={loading:0,preload:null};if(j=d.querySelector(fo(v)))O.loading=5;else{r=p({rel:"stylesheet",href:r,"data-precedence":i},u),(u=Mn.get(v))&&Jd(r,u);var Z=j=d.createElement("link");kt(Z),Vt(Z,"link",r),Z._p=new Promise(function(le,fe){Z.onload=le,Z.onerror=fe}),Z.addEventListener("load",function(){O.loading|=1}),Z.addEventListener("error",function(){O.loading|=2}),O.loading|=4,wu(j,i,d)}j={type:"stylesheet",instance:j,count:1,state:O},x.set(v,j)}}}function zE(r,i){Tr.X(r,i);var u=Fl;if(u&&r){var d=Pr(u).hoistableScripts,x=Xl(r),v=d.get(x);v||(v=u.querySelector(ho(x)),v||(r=p({src:r,async:!0},i),(i=Mn.get(x))&&Wd(r,i),v=u.createElement("script"),kt(v),Vt(v,"link",r),u.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},d.set(x,v))}}function ME(r,i){Tr.M(r,i);var u=Fl;if(u&&r){var d=Pr(u).hoistableScripts,x=Xl(r),v=d.get(x);v||(v=u.querySelector(ho(x)),v||(r=p({src:r,async:!0,type:"module"},i),(i=Mn.get(x))&&Wd(r,i),v=u.createElement("script"),kt(v),Vt(v,"link",r),u.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},d.set(x,v))}}function Ey(r,i,u,d){var x=(x=J.current)?bu(x):null;if(!x)throw Error(l(446));switch(r){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(i=Yl(u.href),u=Pr(x).hoistableStyles,d=u.get(i),d||(d={type:"style",instance:null,count:0,state:null},u.set(i,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){r=Yl(u.href);var v=Pr(x).hoistableStyles,j=v.get(r);if(j||(x=x.ownerDocument||x,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},v.set(r,j),(v=x.querySelector(fo(r)))&&!v._p&&(j.instance=v,j.state.loading=5),Mn.has(r)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},Mn.set(r,u),v||DE(x,r,u,j.state))),i&&d===null)throw Error(l(528,""));return j}if(i&&d!==null)throw Error(l(529,""));return null;case"script":return i=u.async,u=u.src,typeof u=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=Xl(u),u=Pr(x).hoistableScripts,d=u.get(i),d||(d={type:"script",instance:null,count:0,state:null},u.set(i,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,r))}}function Yl(r){return'href="'+en(r)+'"'}function fo(r){return'link[rel="stylesheet"]['+r+"]"}function Ny(r){return p({},r,{"data-precedence":r.precedence,precedence:null})}function DE(r,i,u,d){r.querySelector('link[rel="preload"][as="style"]['+i+"]")?d.loading=1:(i=r.createElement("link"),d.preload=i,i.addEventListener("load",function(){return d.loading|=1}),i.addEventListener("error",function(){return d.loading|=2}),Vt(i,"link",u),kt(i),r.head.appendChild(i))}function Xl(r){return'[src="'+en(r)+'"]'}function ho(r){return"script[async]"+r}function Cy(r,i,u){if(i.count++,i.instance===null)switch(i.type){case"style":var d=r.querySelector('style[data-href~="'+en(u.href)+'"]');if(d)return i.instance=d,kt(d),d;var x=p({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return d=(r.ownerDocument||r).createElement("style"),kt(d),Vt(d,"style",x),wu(d,u.precedence,r),i.instance=d;case"stylesheet":x=Yl(u.href);var v=r.querySelector(fo(x));if(v)return i.state.loading|=4,i.instance=v,kt(v),v;d=Ny(u),(x=Mn.get(x))&&Jd(d,x),v=(r.ownerDocument||r).createElement("link"),kt(v);var j=v;return j._p=new Promise(function(O,Z){j.onload=O,j.onerror=Z}),Vt(v,"link",d),i.state.loading|=4,wu(v,u.precedence,r),i.instance=v;case"script":return v=Xl(u.src),(x=r.querySelector(ho(v)))?(i.instance=x,kt(x),x):(d=u,(x=Mn.get(v))&&(d=p({},u),Wd(d,x)),r=r.ownerDocument||r,x=r.createElement("script"),kt(x),Vt(x,"link",d),r.head.appendChild(x),i.instance=x);case"void":return null;default:throw Error(l(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(d=i.instance,i.state.loading|=4,wu(d,u.precedence,r));return i.instance}function wu(r,i,u){for(var d=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),x=d.length?d[d.length-1]:null,v=x,j=0;j title"):null)}function RE(r,i,u){if(u===1||i.itemProp!=null)return!1;switch(r){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;switch(i.rel){case"stylesheet":return r=i.disabled,typeof i.precedence=="string"&&r==null;default:return!0}case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function Ay(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function OE(r,i,u,d){if(u.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var x=Yl(d.href),v=i.querySelector(fo(x));if(v){i=v._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(r.count++,r=Su.bind(r),i.then(r,r)),u.state.loading|=4,u.instance=v,kt(v);return}v=i.ownerDocument||i,d=Ny(d),(x=Mn.get(x))&&Jd(d,x),v=v.createElement("link"),kt(v);var j=v;j._p=new Promise(function(O,Z){j.onload=O,j.onerror=Z}),Vt(v,"link",d),u.instance=v}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(u,i),(i=u.state.preload)&&(u.state.loading&3)===0&&(r.count++,u=Su.bind(r),i.addEventListener("load",u),i.addEventListener("error",u))}}var eh=0;function LE(r,i){return r.stylesheets&&r.count===0&&Eu(r,r.stylesheets),0eh?50:800)+i);return r.unsuspend=u,function(){r.unsuspend=null,clearTimeout(d),clearTimeout(x)}}:null}function Su(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Eu(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var ku=null;function Eu(r,i){r.stylesheets=null,r.unsuspend!==null&&(r.count++,ku=new Map,i.forEach(HE,r),ku=null,Su.call(r))}function HE(r,i){if(!(i.state.loading&4)){var u=ku.get(r);if(u)var d=u.get(null);else{u=new Map,ku.set(r,u);for(var x=r.querySelectorAll("link[data-precedence],style[data-precedence]"),v=0;v"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),uh.exports=nN(),uh.exports}var iN=rN();/** +`+d.stack}}var Dt=Object.prototype.hasOwnProperty,Pt=e.unstable_scheduleCallback,Bt=e.unstable_cancelCallback,kn=e.unstable_shouldYield,On=e.unstable_requestPaint,Rt=e.unstable_now,qr=e.unstable_getCurrentPriorityLevel,ce=e.unstable_ImmediatePriority,ge=e.unstable_UserBlockingPriority,Ne=e.unstable_NormalPriority,qe=e.unstable_LowPriority,Xe=e.unstable_IdlePriority,Zt=e.log,Ln=e.unstable_setDisableYieldValue,It=null,wt=null;function Gt(r){if(typeof Zt=="function"&&Ln(r),wt&&typeof wt.setStrictMode=="function")try{wt.setStrictMode(It,r)}catch{}}var et=Math.clz32?Math.clz32:Xc,Zn=Math.log,fn=Math.LN2;function Xc(r){return r>>>=0,r===0?32:31-(Zn(r)/fn|0)|0}var dl=256,hl=262144,pl=4194304;function ur(r){var i=r&42;if(i!==0)return i;switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return r&261888;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function ml(r,i,u){var d=r.pendingLanes;if(d===0)return 0;var x=0,v=r.suspendedLanes,j=r.pingedLanes;r=r.warmLanes;var O=d&134217727;return O!==0?(d=O&~v,d!==0?x=ur(d):(j&=O,j!==0?x=ur(j):u||(u=O&~r,u!==0&&(x=ur(u))))):(O=d&~v,O!==0?x=ur(O):j!==0?x=ur(j):u||(u=d&~r,u!==0&&(x=ur(u)))),x===0?0:i!==0&&i!==x&&(i&v)===0&&(v=x&-x,u=i&-i,v>=u||v===32&&(u&4194048)!==0)?i:x}function ki(r,i){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&i)===0}function Qc(r,i){switch(r){case 1:case 2:case 4:case 8:case 64:return i+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function cs(){var r=pl;return pl<<=1,(pl&62914560)===0&&(pl=4194304),r}function ka(r){for(var i=[],u=0;31>u;u++)i.push(r);return i}function Ei(r,i){r.pendingLanes|=i,i!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function Zc(r,i,u,d,x,v){var j=r.pendingLanes;r.pendingLanes=u,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=u,r.entangledLanes&=u,r.errorRecoveryDisabledLanes&=u,r.shellSuspendCounter=0;var O=r.entanglements,Z=r.expirationTimes,le=r.hiddenUpdates;for(u=j&~u;0"u")return null;try{return r.activeElement||r.body}catch{return r.body}}var tf=/[\n"\\]/g;function en(r){return r.replace(tf,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function ji(r,i,u,d,x,v,j,O){r.name="",j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?r.type=j:r.removeAttribute("type"),i!=null?j==="number"?(i===0&&r.value===""||r.value!=i)&&(r.value=""+Wt(i)):r.value!==""+Wt(i)&&(r.value=""+Wt(i)):j!=="submit"&&j!=="reset"||r.removeAttribute("value"),i!=null?Ta(r,j,Wt(i)):u!=null?Ta(r,j,Wt(u)):d!=null&&r.removeAttribute("value"),x==null&&v!=null&&(r.defaultChecked=!!v),x!=null&&(r.checked=x&&typeof x!="function"&&typeof x!="symbol"),O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?r.name=""+Wt(O):r.removeAttribute("name")}function Ss(r,i,u,d,x,v,j,O){if(v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(r.type=v),i!=null||u!=null){if(!(v!=="submit"&&v!=="reset"||i!=null)){Fr(r);return}u=u!=null?""+Wt(u):"",i=i!=null?""+Wt(i):u,O||i===r.value||(r.value=i),r.defaultValue=i}d=d??x,d=typeof d!="function"&&typeof d!="symbol"&&!!d,r.checked=O?r.checked:!!d,r.defaultChecked=!!d,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(r.name=j),Fr(r)}function Ta(r,i,u){i==="number"&&Ci(r.ownerDocument)===r||r.defaultValue===""+u||(r.defaultValue=""+u)}function dr(r,i,u,d){if(r=r.options,i){i={};for(var x=0;x"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),of=!1;if(pr)try{var za={};Object.defineProperty(za,"passive",{get:function(){of=!0}}),window.addEventListener("test",za,za),window.removeEventListener("test",za,za)}catch{of=!1}var Yr=null,sf=null,Es=null;function pg(){if(Es)return Es;var r,i=sf,u=i.length,d,x="value"in Yr?Yr.value:Yr.textContent,v=x.length;for(r=0;r=Ra),bg=" ",wg=!1;function _g(r,i){switch(r){case"keyup":return p2.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sg(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var _l=!1;function g2(r,i){switch(r){case"compositionend":return Sg(i);case"keypress":return i.which!==32?null:(wg=!0,bg);case"textInput":return r=i.data,r===bg&&wg?null:r;default:return null}}function x2(r,i){if(_l)return r==="compositionend"||!hf&&_g(r,i)?(r=pg(),Es=sf=Yr=null,_l=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1=i)return{node:u,offset:i-r};r=d}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=zg(u)}}function Dg(r,i){return r&&i?r===i?!0:r&&r.nodeType===3?!1:i&&i.nodeType===3?Dg(r,i.parentNode):"contains"in r?r.contains(i):r.compareDocumentPosition?!!(r.compareDocumentPosition(i)&16):!1:!1}function Rg(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var i=Ci(r.document);i instanceof r.HTMLIFrameElement;){try{var u=typeof i.contentWindow.location.href=="string"}catch{u=!1}if(u)r=i.contentWindow;else break;i=Ci(r.document)}return i}function gf(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i&&(i==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||i==="textarea"||r.contentEditable==="true")}var E2=pr&&"documentMode"in document&&11>=document.documentMode,Sl=null,xf=null,Ba=null,yf=!1;function Og(r,i,u){var d=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;yf||Sl==null||Sl!==Ci(d)||(d=Sl,"selectionStart"in d&&gf(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),Ba&&Ha(Ba,d)||(Ba=d,d=yu(xf,"onSelect"),0>=j,x-=j,Jn=1<<32-et(i)+x|u<Le?(Ge=_e,_e=null):Ge=_e.sibling;var Ke=ae(te,_e,ie[Le],de);if(Ke===null){_e===null&&(_e=Ge);break}r&&_e&&Ke.alternate===null&&i(te,_e),W=v(Ke,W,Le),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke,_e=Ge}if(Le===ie.length)return u(te,_e),Fe&&gr(te,Le),ke;if(_e===null){for(;LeLe?(Ge=_e,_e=null):Ge=_e.sibling;var mi=ae(te,_e,Ke.value,de);if(mi===null){_e===null&&(_e=Ge);break}r&&_e&&mi.alternate===null&&i(te,_e),W=v(mi,W,Le),Ze===null?ke=mi:Ze.sibling=mi,Ze=mi,_e=Ge}if(Ke.done)return u(te,_e),Fe&&gr(te,Le),ke;if(_e===null){for(;!Ke.done;Le++,Ke=ie.next())Ke=he(te,Ke.value,de),Ke!==null&&(W=v(Ke,W,Le),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke);return Fe&&gr(te,Le),ke}for(_e=d(_e);!Ke.done;Le++,Ke=ie.next())Ke=oe(_e,te,Le,Ke.value,de),Ke!==null&&(r&&Ke.alternate!==null&&_e.delete(Ke.key===null?Le:Ke.key),W=v(Ke,W,Le),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke);return r&&_e.forEach(function(GE){return i(te,GE)}),Fe&&gr(te,Le),ke}function at(te,W,ie,de){if(typeof ie=="object"&&ie!==null&&ie.type===E&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case b:e:{for(var ke=ie.key;W!==null;){if(W.key===ke){if(ke=ie.type,ke===E){if(W.tag===7){u(te,W.sibling),de=x(W,ie.props.children),de.return=te,te=de;break e}}else if(W.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===R&&Bi(ke)===W.type){u(te,W.sibling),de=x(W,ie.props),Pa(de,ie),de.return=te,te=de;break e}u(te,W);break}else i(te,W);W=W.sibling}ie.type===E?(de=Di(ie.props.children,te.mode,de,ie.key),de.return=te,te=de):(de=Os(ie.type,ie.key,ie.props,null,te.mode,de),Pa(de,ie),de.return=te,te=de)}return j(te);case w:e:{for(ke=ie.key;W!==null;){if(W.key===ke)if(W.tag===4&&W.stateNode.containerInfo===ie.containerInfo&&W.stateNode.implementation===ie.implementation){u(te,W.sibling),de=x(W,ie.children||[]),de.return=te,te=de;break e}else{u(te,W);break}else i(te,W);W=W.sibling}de=Ef(ie,te.mode,de),de.return=te,te=de}return j(te);case R:return ie=Bi(ie),at(te,W,ie,de)}if(F(ie))return we(te,W,ie,de);if(U(ie)){if(ke=U(ie),typeof ke!="function")throw Error(l(150));return ie=ke.call(ie),Ce(te,W,ie,de)}if(typeof ie.then=="function")return at(te,W,Us(ie),de);if(ie.$$typeof===k)return at(te,W,Bs(te,ie),de);Vs(te,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint"?(ie=""+ie,W!==null&&W.tag===6?(u(te,W.sibling),de=x(W,ie),de.return=te,te=de):(u(te,W),de=kf(ie,te.mode,de),de.return=te,te=de),j(te)):u(te,W)}return function(te,W,ie,de){try{Va=0;var ke=at(te,W,ie,de);return Rl=null,ke}catch(_e){if(_e===Dl||_e===qs)throw _e;var Ze=hn(29,_e,null,te.mode);return Ze.lanes=de,Ze.return=te,Ze}finally{}}}var qi=ix(!0),lx=ix(!1),Jr=!1;function Hf(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Bf(r,i){r=r.updateQueue,i.updateQueue===r&&(i.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function Wr(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function ei(r,i,u){var d=r.updateQueue;if(d===null)return null;if(d=d.shared,(Je&2)!==0){var x=d.pending;return x===null?i.next=i:(i.next=x.next,x.next=i),d.pending=i,i=Rs(r),Ug(r,null,u),i}return Ds(r,d,i,u),Rs(r)}function Ga(r,i,u){if(i=i.updateQueue,i!==null&&(i=i.shared,(u&4194048)!==0)){var d=i.lanes;d&=r.pendingLanes,u|=d,i.lanes=u,ds(r,u)}}function If(r,i){var u=r.updateQueue,d=r.alternate;if(d!==null&&(d=d.updateQueue,u===d)){var x=null,v=null;if(u=u.firstBaseUpdate,u!==null){do{var j={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};v===null?x=v=j:v=v.next=j,u=u.next}while(u!==null);v===null?x=v=i:v=v.next=i}else x=v=i;u={baseState:d.baseState,firstBaseUpdate:x,lastBaseUpdate:v,shared:d.shared,callbacks:d.callbacks},r.updateQueue=u;return}r=u.lastBaseUpdate,r===null?u.firstBaseUpdate=i:r.next=i,u.lastBaseUpdate=i}var qf=!1;function Fa(){if(qf){var r=Ml;if(r!==null)throw r}}function Ya(r,i,u,d){qf=!1;var x=r.updateQueue;Jr=!1;var v=x.firstBaseUpdate,j=x.lastBaseUpdate,O=x.shared.pending;if(O!==null){x.shared.pending=null;var Z=O,le=Z.next;Z.next=null,j===null?v=le:j.next=le,j=Z;var fe=r.alternate;fe!==null&&(fe=fe.updateQueue,O=fe.lastBaseUpdate,O!==j&&(O===null?fe.firstBaseUpdate=le:O.next=le,fe.lastBaseUpdate=Z))}if(v!==null){var he=x.baseState;j=0,fe=le=Z=null,O=v;do{var ae=O.lane&-536870913,oe=ae!==O.lane;if(oe?(Pe&ae)===ae:(d&ae)===ae){ae!==0&&ae===zl&&(qf=!0),fe!==null&&(fe=fe.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var we=r,Ce=O;ae=i;var at=u;switch(Ce.tag){case 1:if(we=Ce.payload,typeof we=="function"){he=we.call(at,he,ae);break e}he=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=Ce.payload,ae=typeof we=="function"?we.call(at,he,ae):we,ae==null)break e;he=p({},he,ae);break e;case 2:Jr=!0}}ae=O.callback,ae!==null&&(r.flags|=64,oe&&(r.flags|=8192),oe=x.callbacks,oe===null?x.callbacks=[ae]:oe.push(ae))}else oe={lane:ae,tag:O.tag,payload:O.payload,callback:O.callback,next:null},fe===null?(le=fe=oe,Z=he):fe=fe.next=oe,j|=ae;if(O=O.next,O===null){if(O=x.shared.pending,O===null)break;oe=O,O=oe.next,oe.next=null,x.lastBaseUpdate=oe,x.shared.pending=null}}while(!0);fe===null&&(Z=he),x.baseState=Z,x.firstBaseUpdate=le,x.lastBaseUpdate=fe,v===null&&(x.shared.lanes=0),li|=j,r.lanes=j,r.memoizedState=he}}function ax(r,i){if(typeof r!="function")throw Error(l(191,r));r.call(i)}function ox(r,i){var u=r.callbacks;if(u!==null)for(r.callbacks=null,r=0;rv?v:8;var j=z.T,O={};z.T=O,ld(r,!1,i,u);try{var Z=x(),le=z.S;if(le!==null&&le(O,Z),Z!==null&&typeof Z=="object"&&typeof Z.then=="function"){var fe=R2(Z,d);Za(r,i,fe,yn(r))}else Za(r,i,d,yn(r))}catch(he){Za(r,i,{then:function(){},status:"rejected",reason:he},yn())}finally{G.p=v,j!==null&&O.types!==null&&(j.types=O.types),z.T=j}}function q2(){}function rd(r,i,u,d){if(r.tag!==5)throw Error(l(476));var x=Ix(r).queue;Bx(r,x,i,Q,u===null?q2:function(){return qx(r),u(d)})}function Ix(r){var i=r.memoizedState;if(i!==null)return i;i={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:br,lastRenderedState:Q},next:null};var u={};return i.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:br,lastRenderedState:u},next:null},r.memoizedState=i,r=r.alternate,r!==null&&(r.memoizedState=i),i}function qx(r){var i=Ix(r);i.next===null&&(i=r.alternate.memoizedState),Za(r,i.next.queue,{},yn())}function id(){return $t(po)}function $x(){return St().memoizedState}function Ux(){return St().memoizedState}function $2(r){for(var i=r.return;i!==null;){switch(i.tag){case 24:case 3:var u=yn();r=Wr(u);var d=ei(i,r,u);d!==null&&(on(d,i,u),Ga(d,i,u)),i={cache:Df()},r.payload=i;return}i=i.return}}function U2(r,i,u){var d=yn();u={lane:d,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Ws(r)?Px(i,u):(u=_f(r,i,u,d),u!==null&&(on(u,r,d),Gx(u,i,d)))}function Vx(r,i,u){var d=yn();Za(r,i,u,d)}function Za(r,i,u,d){var x={lane:d,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(Ws(r))Px(i,x);else{var v=r.alternate;if(r.lanes===0&&(v===null||v.lanes===0)&&(v=i.lastRenderedReducer,v!==null))try{var j=i.lastRenderedState,O=v(j,u);if(x.hasEagerState=!0,x.eagerState=O,dn(O,j))return Ds(r,i,x,0),st===null&&Ms(),!1}catch{}finally{}if(u=_f(r,i,x,d),u!==null)return on(u,r,d),Gx(u,i,d),!0}return!1}function ld(r,i,u,d){if(d={lane:2,revertLane:Hd(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Ws(r)){if(i)throw Error(l(479))}else i=_f(r,u,d,2),i!==null&&on(i,r,2)}function Ws(r){var i=r.alternate;return r===Re||i!==null&&i===Re}function Px(r,i){Ll=Fs=!0;var u=r.pending;u===null?i.next=i:(i.next=u.next,u.next=i),r.pending=i}function Gx(r,i,u){if((u&4194048)!==0){var d=i.lanes;d&=r.pendingLanes,u|=d,i.lanes=u,ds(r,u)}}var Ka={readContext:$t,use:Qs,useCallback:yt,useContext:yt,useEffect:yt,useImperativeHandle:yt,useLayoutEffect:yt,useInsertionEffect:yt,useMemo:yt,useReducer:yt,useRef:yt,useState:yt,useDebugValue:yt,useDeferredValue:yt,useTransition:yt,useSyncExternalStore:yt,useId:yt,useHostTransitionStatus:yt,useFormState:yt,useActionState:yt,useOptimistic:yt,useMemoCache:yt,useCacheRefresh:yt};Ka.useEffectEvent=yt;var Fx={readContext:$t,use:Qs,useCallback:function(r,i){return Kt().memoizedState=[r,i===void 0?null:i],r},useContext:$t,useEffect:Tx,useImperativeHandle:function(r,i,u){u=u!=null?u.concat([r]):null,Ks(4194308,4,Dx.bind(null,i,r),u)},useLayoutEffect:function(r,i){return Ks(4194308,4,r,i)},useInsertionEffect:function(r,i){Ks(4,2,r,i)},useMemo:function(r,i){var u=Kt();i=i===void 0?null:i;var d=r();if($i){Gt(!0);try{r()}finally{Gt(!1)}}return u.memoizedState=[d,i],d},useReducer:function(r,i,u){var d=Kt();if(u!==void 0){var x=u(i);if($i){Gt(!0);try{u(i)}finally{Gt(!1)}}}else x=i;return d.memoizedState=d.baseState=x,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:x},d.queue=r,r=r.dispatch=U2.bind(null,Re,r),[d.memoizedState,r]},useRef:function(r){var i=Kt();return r={current:r},i.memoizedState=r},useState:function(r){r=Jf(r);var i=r.queue,u=Vx.bind(null,Re,i);return i.dispatch=u,[r.memoizedState,u]},useDebugValue:td,useDeferredValue:function(r,i){var u=Kt();return nd(u,r,i)},useTransition:function(){var r=Jf(!1);return r=Bx.bind(null,Re,r.queue,!0,!1),Kt().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,i,u){var d=Re,x=Kt();if(Fe){if(u===void 0)throw Error(l(407));u=u()}else{if(u=i(),st===null)throw Error(l(349));(Pe&127)!==0||hx(d,i,u)}x.memoizedState=u;var v={value:u,getSnapshot:i};return x.queue=v,Tx(mx.bind(null,d,v,r),[r]),d.flags|=2048,Bl(9,{destroy:void 0},px.bind(null,d,v,u,i),null),u},useId:function(){var r=Kt(),i=st.identifierPrefix;if(Fe){var u=Wn,d=Jn;u=(d&~(1<<32-et(d)-1)).toString(32)+u,i="_"+i+"R_"+u,u=Ys++,0<\/script>",v=v.removeChild(v.firstChild);break;case"select":v=typeof d.is=="string"?j.createElement("select",{is:d.is}):j.createElement("select"),d.multiple?v.multiple=!0:d.size&&(v.size=d.size);break;default:v=typeof d.is=="string"?j.createElement(x,{is:d.is}):j.createElement(x)}}v[Ot]=i,v[Ft]=d;e:for(j=i.child;j!==null;){if(j.tag===5||j.tag===6)v.appendChild(j.stateNode);else if(j.tag!==4&&j.tag!==27&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===i)break e;for(;j.sibling===null;){if(j.return===null||j.return===i)break e;j=j.return}j.sibling.return=j.return,j=j.sibling}i.stateNode=v;e:switch(Vt(v,x,d),x){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&_r(i)}}return ht(i),vd(i,i.type,r===null?null:r.memoizedProps,i.pendingProps,u),null;case 6:if(r&&i.stateNode!=null)r.memoizedProps!==d&&_r(i);else{if(typeof d!="string"&&i.stateNode===null)throw Error(l(166));if(r=J.current,Tl(i)){if(r=i.stateNode,u=i.memoizedProps,d=null,x=qt,x!==null)switch(x.tag){case 27:case 5:d=x.memoizedProps}r[Ot]=i,r=!!(r.nodeValue===u||d!==null&&d.suppressHydrationWarning===!0||fy(r.nodeValue,u)),r||Zr(i,!0)}else r=vu(r).createTextNode(d),r[Ot]=i,i.stateNode=r}return ht(i),null;case 31:if(u=i.memoizedState,r===null||r.memoizedState!==null){if(d=Tl(i),u!==null){if(r===null){if(!d)throw Error(l(318));if(r=i.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(l(557));r[Ot]=i}else Ri(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;ht(i),r=!1}else u=Tf(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=u),r=!0;if(!r)return i.flags&256?(mn(i),i):(mn(i),null);if((i.flags&128)!==0)throw Error(l(558))}return ht(i),null;case 13:if(d=i.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(x=Tl(i),d!==null&&d.dehydrated!==null){if(r===null){if(!x)throw Error(l(318));if(x=i.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(l(317));x[Ot]=i}else Ri(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;ht(i),x=!1}else x=Tf(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=x),x=!0;if(!x)return i.flags&256?(mn(i),i):(mn(i),null)}return mn(i),(i.flags&128)!==0?(i.lanes=u,i):(u=d!==null,r=r!==null&&r.memoizedState!==null,u&&(d=i.child,x=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(x=d.alternate.memoizedState.cachePool.pool),v=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(v=d.memoizedState.cachePool.pool),v!==x&&(d.flags|=2048)),u!==r&&u&&(i.child.flags|=8192),iu(i,i.updateQueue),ht(i),null);case 4:return ue(),r===null&&$d(i.stateNode.containerInfo),ht(i),null;case 10:return yr(i.type),ht(i),null;case 19:if(Y(_t),d=i.memoizedState,d===null)return ht(i),null;if(x=(i.flags&128)!==0,v=d.rendering,v===null)if(x)Wa(d,!1);else{if(vt!==0||r!==null&&(r.flags&128)!==0)for(r=i.child;r!==null;){if(v=Gs(r),v!==null){for(i.flags|=128,Wa(d,!1),r=v.updateQueue,i.updateQueue=r,iu(i,r),i.subtreeFlags=0,r=u,u=i.child;u!==null;)Vg(u,r),u=u.sibling;return C(_t,_t.current&1|2),Fe&&gr(i,d.treeForkCount),i.child}r=r.sibling}d.tail!==null&&Rt()>uu&&(i.flags|=128,x=!0,Wa(d,!1),i.lanes=4194304)}else{if(!x)if(r=Gs(v),r!==null){if(i.flags|=128,x=!0,r=r.updateQueue,i.updateQueue=r,iu(i,r),Wa(d,!0),d.tail===null&&d.tailMode==="hidden"&&!v.alternate&&!Fe)return ht(i),null}else 2*Rt()-d.renderingStartTime>uu&&u!==536870912&&(i.flags|=128,x=!0,Wa(d,!1),i.lanes=4194304);d.isBackwards?(v.sibling=i.child,i.child=v):(r=d.last,r!==null?r.sibling=v:i.child=v,d.last=v)}return d.tail!==null?(r=d.tail,d.rendering=r,d.tail=r.sibling,d.renderingStartTime=Rt(),r.sibling=null,u=_t.current,C(_t,x?u&1|2:u&1),Fe&&gr(i,d.treeForkCount),r):(ht(i),null);case 22:case 23:return mn(i),Uf(),d=i.memoizedState!==null,r!==null?r.memoizedState!==null!==d&&(i.flags|=8192):d&&(i.flags|=8192),d?(u&536870912)!==0&&(i.flags&128)===0&&(ht(i),i.subtreeFlags&6&&(i.flags|=8192)):ht(i),u=i.updateQueue,u!==null&&iu(i,u.retryQueue),u=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),d=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(d=i.memoizedState.cachePool.pool),d!==u&&(i.flags|=2048),r!==null&&Y(Hi),null;case 24:return u=null,r!==null&&(u=r.memoizedState.cache),i.memoizedState.cache!==u&&(i.flags|=2048),yr(Et),ht(i),null;case 25:return null;case 30:return null}throw Error(l(156,i.tag))}function Y2(r,i){switch(Cf(i),i.tag){case 1:return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 3:return yr(Et),ue(),r=i.flags,(r&65536)!==0&&(r&128)===0?(i.flags=r&-65537|128,i):null;case 26:case 27:case 5:return be(i),null;case 31:if(i.memoizedState!==null){if(mn(i),i.alternate===null)throw Error(l(340));Ri()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 13:if(mn(i),r=i.memoizedState,r!==null&&r.dehydrated!==null){if(i.alternate===null)throw Error(l(340));Ri()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 19:return Y(_t),null;case 4:return ue(),null;case 10:return yr(i.type),null;case 22:case 23:return mn(i),Uf(),r!==null&&Y(Hi),r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 24:return yr(Et),null;case 25:return null;default:return null}}function g0(r,i){switch(Cf(i),i.tag){case 3:yr(Et),ue();break;case 26:case 27:case 5:be(i);break;case 4:ue();break;case 31:i.memoizedState!==null&&mn(i);break;case 13:mn(i);break;case 19:Y(_t);break;case 10:yr(i.type);break;case 22:case 23:mn(i),Uf(),r!==null&&Y(Hi);break;case 24:yr(Et)}}function eo(r,i){try{var u=i.updateQueue,d=u!==null?u.lastEffect:null;if(d!==null){var x=d.next;u=x;do{if((u.tag&r)===r){d=void 0;var v=u.create,j=u.inst;d=v(),j.destroy=d}u=u.next}while(u!==x)}}catch(O){nt(i,i.return,O)}}function ri(r,i,u){try{var d=i.updateQueue,x=d!==null?d.lastEffect:null;if(x!==null){var v=x.next;d=v;do{if((d.tag&r)===r){var j=d.inst,O=j.destroy;if(O!==void 0){j.destroy=void 0,x=i;var Z=u,le=O;try{le()}catch(fe){nt(x,Z,fe)}}}d=d.next}while(d!==v)}}catch(fe){nt(i,i.return,fe)}}function x0(r){var i=r.updateQueue;if(i!==null){var u=r.stateNode;try{ox(i,u)}catch(d){nt(r,r.return,d)}}}function y0(r,i,u){u.props=Ui(r.type,r.memoizedProps),u.state=r.memoizedState;try{u.componentWillUnmount()}catch(d){nt(r,i,d)}}function to(r,i){try{var u=r.ref;if(u!==null){switch(r.tag){case 26:case 27:case 5:var d=r.stateNode;break;case 30:d=r.stateNode;break;default:d=r.stateNode}typeof u=="function"?r.refCleanup=u(d):u.current=d}}catch(x){nt(r,i,x)}}function er(r,i){var u=r.ref,d=r.refCleanup;if(u!==null)if(typeof d=="function")try{d()}catch(x){nt(r,i,x)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(x){nt(r,i,x)}else u.current=null}function v0(r){var i=r.type,u=r.memoizedProps,d=r.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":u.autoFocus&&d.focus();break e;case"img":u.src?d.src=u.src:u.srcSet&&(d.srcset=u.srcSet)}}catch(x){nt(r,r.return,x)}}function bd(r,i,u){try{var d=r.stateNode;mE(d,r.type,u,i),d[Ft]=i}catch(x){nt(r,r.return,x)}}function b0(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&ci(r.type)||r.tag===4}function wd(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||b0(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.tag===27&&ci(r.type)||r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function _d(r,i,u){var d=r.tag;if(d===5||d===6)r=r.stateNode,i?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(r,i):(i=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,i.appendChild(r),u=u._reactRootContainer,u!=null||i.onclick!==null||(i.onclick=hr));else if(d!==4&&(d===27&&ci(r.type)&&(u=r.stateNode,i=null),r=r.child,r!==null))for(_d(r,i,u),r=r.sibling;r!==null;)_d(r,i,u),r=r.sibling}function lu(r,i,u){var d=r.tag;if(d===5||d===6)r=r.stateNode,i?u.insertBefore(r,i):u.appendChild(r);else if(d!==4&&(d===27&&ci(r.type)&&(u=r.stateNode),r=r.child,r!==null))for(lu(r,i,u),r=r.sibling;r!==null;)lu(r,i,u),r=r.sibling}function w0(r){var i=r.stateNode,u=r.memoizedProps;try{for(var d=r.type,x=i.attributes;x.length;)i.removeAttributeNode(x[0]);Vt(i,d,u),i[Ot]=r,i[Ft]=u}catch(v){nt(r,r.return,v)}}var Sr=!1,jt=!1,Sd=!1,_0=typeof WeakSet=="function"?WeakSet:Set,Ht=null;function X2(r,i){if(r=r.containerInfo,Pd=Nu,r=Rg(r),gf(r)){if("selectionStart"in r)var u={start:r.selectionStart,end:r.selectionEnd};else e:{u=(u=r.ownerDocument)&&u.defaultView||window;var d=u.getSelection&&u.getSelection();if(d&&d.rangeCount!==0){u=d.anchorNode;var x=d.anchorOffset,v=d.focusNode;d=d.focusOffset;try{u.nodeType,v.nodeType}catch{u=null;break e}var j=0,O=-1,Z=-1,le=0,fe=0,he=r,ae=null;t:for(;;){for(var oe;he!==u||x!==0&&he.nodeType!==3||(O=j+x),he!==v||d!==0&&he.nodeType!==3||(Z=j+d),he.nodeType===3&&(j+=he.nodeValue.length),(oe=he.firstChild)!==null;)ae=he,he=oe;for(;;){if(he===r)break t;if(ae===u&&++le===x&&(O=j),ae===v&&++fe===d&&(Z=j),(oe=he.nextSibling)!==null)break;he=ae,ae=he.parentNode}he=oe}u=O===-1||Z===-1?null:{start:O,end:Z}}else u=null}u=u||{start:0,end:0}}else u=null;for(Gd={focusedElem:r,selectionRange:u},Nu=!1,Ht=i;Ht!==null;)if(i=Ht,r=i.child,(i.subtreeFlags&1028)!==0&&r!==null)r.return=i,Ht=r;else for(;Ht!==null;){switch(i=Ht,v=i.alternate,r=i.flags,i.tag){case 0:if((r&4)!==0&&(r=i.updateQueue,r=r!==null?r.events:null,r!==null))for(u=0;u title"))),Vt(v,d,u),v[Ot]=r,kt(v),d=v;break e;case"link":var j=jy("link","href",x).get(d+(u.href||""));if(j){for(var O=0;Oat&&(j=at,at=Ce,Ce=j);var te=Mg(O,Ce),W=Mg(O,at);if(te&&W&&(oe.rangeCount!==1||oe.anchorNode!==te.node||oe.anchorOffset!==te.offset||oe.focusNode!==W.node||oe.focusOffset!==W.offset)){var ie=he.createRange();ie.setStart(te.node,te.offset),oe.removeAllRanges(),Ce>at?(oe.addRange(ie),oe.extend(W.node,W.offset)):(ie.setEnd(W.node,W.offset),oe.addRange(ie))}}}}for(he=[],oe=O;oe=oe.parentNode;)oe.nodeType===1&&he.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;Ou?32:u,z.T=null,u=Ad,Ad=null;var v=oi,j=jr;if(Lt=0,Vl=oi=null,jr=0,(Je&6)!==0)throw Error(l(331));var O=Je;if(Je|=4,D0(v.current),A0(v,v.current,j,u),Je=O,oo(0,!1),wt&&typeof wt.onPostCommitFiberRoot=="function")try{wt.onPostCommitFiberRoot(It,v)}catch{}return!0}finally{G.p=x,z.T=d,K0(r,i)}}function W0(r,i,u){i=Nn(u,i),i=ud(r.stateNode,i,2),r=ei(r,i,2),r!==null&&(Ei(r,2),tr(r))}function nt(r,i,u){if(r.tag===3)W0(r,r,u);else for(;i!==null;){if(i.tag===3){W0(i,r,u);break}else if(i.tag===1){var d=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(ai===null||!ai.has(d))){r=Nn(u,r),u=e0(2),d=ei(i,u,2),d!==null&&(t0(u,d,i,r),Ei(d,2),tr(d));break}}i=i.return}}function Rd(r,i,u){var d=r.pingCache;if(d===null){d=r.pingCache=new K2;var x=new Set;d.set(i,x)}else x=d.get(i),x===void 0&&(x=new Set,d.set(i,x));x.has(u)||(Nd=!0,x.add(u),r=nE.bind(null,r,i,u),i.then(r,r))}function nE(r,i,u){var d=r.pingCache;d!==null&&d.delete(i),r.pingedLanes|=r.suspendedLanes&u,r.warmLanes&=~u,st===r&&(Pe&u)===u&&(vt===4||vt===3&&(Pe&62914560)===Pe&&300>Rt()-su?(Je&2)===0&&Pl(r,0):Cd|=u,Ul===Pe&&(Ul=0)),tr(r)}function ey(r,i){i===0&&(i=cs()),r=Mi(r,i),r!==null&&(Ei(r,i),tr(r))}function rE(r){var i=r.memoizedState,u=0;i!==null&&(u=i.retryLane),ey(r,u)}function iE(r,i){var u=0;switch(r.tag){case 31:case 13:var d=r.stateNode,x=r.memoizedState;x!==null&&(u=x.retryLane);break;case 19:d=r.stateNode;break;case 22:d=r.stateNode._retryCache;break;default:throw Error(l(314))}d!==null&&d.delete(i),ey(r,u)}function lE(r,i){return Pt(r,i)}var mu=null,Fl=null,Od=!1,gu=!1,Ld=!1,ui=0;function tr(r){r!==Fl&&r.next===null&&(Fl===null?mu=Fl=r:Fl=Fl.next=r),gu=!0,Od||(Od=!0,oE())}function oo(r,i){if(!Ld&&gu){Ld=!0;do for(var u=!1,d=mu;d!==null;){if(r!==0){var x=d.pendingLanes;if(x===0)var v=0;else{var j=d.suspendedLanes,O=d.pingedLanes;v=(1<<31-et(42|r)+1)-1,v&=x&~(j&~O),v=v&201326741?v&201326741|1:v?v|2:0}v!==0&&(u=!0,iy(d,v))}else v=Pe,v=ml(d,d===st?v:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(v&3)===0||ki(d,v)||(u=!0,iy(d,v));d=d.next}while(u);Ld=!1}}function aE(){ty()}function ty(){gu=Od=!1;var r=0;ui!==0&&xE()&&(r=ui);for(var i=Rt(),u=null,d=mu;d!==null;){var x=d.next,v=ny(d,i);v===0?(d.next=null,u===null?mu=x:u.next=x,x===null&&(Fl=u)):(u=d,(r!==0||(v&3)!==0)&&(gu=!0)),d=x}Lt!==0&&Lt!==5||oo(r),ui!==0&&(ui=0)}function ny(r,i){for(var u=r.suspendedLanes,d=r.pingedLanes,x=r.expirationTimes,v=r.pendingLanes&-62914561;0O)break;var fe=Z.transferSize,he=Z.initiatorType;fe&&dy(he)&&(Z=Z.responseEnd,j+=fe*(Z"u"?null:document;function ky(r,i,u){var d=Yl;if(d&&typeof i=="string"&&i){var x=en(i);x='link[rel="'+r+'"][href="'+x+'"]',typeof u=="string"&&(x+='[crossorigin="'+u+'"]'),Sy.has(x)||(Sy.add(x),r={rel:r,crossOrigin:u,href:i},d.querySelector(x)===null&&(i=d.createElement("link"),Vt(i,"link",r),kt(i),d.head.appendChild(i)))}}function NE(r){Tr.D(r),ky("dns-prefetch",r,null)}function CE(r,i){Tr.C(r,i),ky("preconnect",r,i)}function jE(r,i,u){Tr.L(r,i,u);var d=Yl;if(d&&r&&i){var x='link[rel="preload"][as="'+en(i)+'"]';i==="image"&&u&&u.imageSrcSet?(x+='[imagesrcset="'+en(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(x+='[imagesizes="'+en(u.imageSizes)+'"]')):x+='[href="'+en(r)+'"]';var v=x;switch(i){case"style":v=Xl(r);break;case"script":v=Ql(r)}Mn.has(v)||(r=p({rel:"preload",href:i==="image"&&u&&u.imageSrcSet?void 0:r,as:i},u),Mn.set(v,r),d.querySelector(x)!==null||i==="style"&&d.querySelector(fo(v))||i==="script"&&d.querySelector(ho(v))||(i=d.createElement("link"),Vt(i,"link",r),kt(i),d.head.appendChild(i)))}}function TE(r,i){Tr.m(r,i);var u=Yl;if(u&&r){var d=i&&typeof i.as=="string"?i.as:"script",x='link[rel="modulepreload"][as="'+en(d)+'"][href="'+en(r)+'"]',v=x;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":v=Ql(r)}if(!Mn.has(v)&&(r=p({rel:"modulepreload",href:r},i),Mn.set(v,r),u.querySelector(x)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(ho(v)))return}d=u.createElement("link"),Vt(d,"link",r),kt(d),u.head.appendChild(d)}}}function AE(r,i,u){Tr.S(r,i,u);var d=Yl;if(d&&r){var x=Pr(d).hoistableStyles,v=Xl(r);i=i||"default";var j=x.get(v);if(!j){var O={loading:0,preload:null};if(j=d.querySelector(fo(v)))O.loading=5;else{r=p({rel:"stylesheet",href:r,"data-precedence":i},u),(u=Mn.get(v))&&Jd(r,u);var Z=j=d.createElement("link");kt(Z),Vt(Z,"link",r),Z._p=new Promise(function(le,fe){Z.onload=le,Z.onerror=fe}),Z.addEventListener("load",function(){O.loading|=1}),Z.addEventListener("error",function(){O.loading|=2}),O.loading|=4,wu(j,i,d)}j={type:"stylesheet",instance:j,count:1,state:O},x.set(v,j)}}}function zE(r,i){Tr.X(r,i);var u=Yl;if(u&&r){var d=Pr(u).hoistableScripts,x=Ql(r),v=d.get(x);v||(v=u.querySelector(ho(x)),v||(r=p({src:r,async:!0},i),(i=Mn.get(x))&&Wd(r,i),v=u.createElement("script"),kt(v),Vt(v,"link",r),u.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},d.set(x,v))}}function ME(r,i){Tr.M(r,i);var u=Yl;if(u&&r){var d=Pr(u).hoistableScripts,x=Ql(r),v=d.get(x);v||(v=u.querySelector(ho(x)),v||(r=p({src:r,async:!0,type:"module"},i),(i=Mn.get(x))&&Wd(r,i),v=u.createElement("script"),kt(v),Vt(v,"link",r),u.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},d.set(x,v))}}function Ey(r,i,u,d){var x=(x=J.current)?bu(x):null;if(!x)throw Error(l(446));switch(r){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(i=Xl(u.href),u=Pr(x).hoistableStyles,d=u.get(i),d||(d={type:"style",instance:null,count:0,state:null},u.set(i,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){r=Xl(u.href);var v=Pr(x).hoistableStyles,j=v.get(r);if(j||(x=x.ownerDocument||x,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},v.set(r,j),(v=x.querySelector(fo(r)))&&!v._p&&(j.instance=v,j.state.loading=5),Mn.has(r)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},Mn.set(r,u),v||DE(x,r,u,j.state))),i&&d===null)throw Error(l(528,""));return j}if(i&&d!==null)throw Error(l(529,""));return null;case"script":return i=u.async,u=u.src,typeof u=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=Ql(u),u=Pr(x).hoistableScripts,d=u.get(i),d||(d={type:"script",instance:null,count:0,state:null},u.set(i,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,r))}}function Xl(r){return'href="'+en(r)+'"'}function fo(r){return'link[rel="stylesheet"]['+r+"]"}function Ny(r){return p({},r,{"data-precedence":r.precedence,precedence:null})}function DE(r,i,u,d){r.querySelector('link[rel="preload"][as="style"]['+i+"]")?d.loading=1:(i=r.createElement("link"),d.preload=i,i.addEventListener("load",function(){return d.loading|=1}),i.addEventListener("error",function(){return d.loading|=2}),Vt(i,"link",u),kt(i),r.head.appendChild(i))}function Ql(r){return'[src="'+en(r)+'"]'}function ho(r){return"script[async]"+r}function Cy(r,i,u){if(i.count++,i.instance===null)switch(i.type){case"style":var d=r.querySelector('style[data-href~="'+en(u.href)+'"]');if(d)return i.instance=d,kt(d),d;var x=p({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return d=(r.ownerDocument||r).createElement("style"),kt(d),Vt(d,"style",x),wu(d,u.precedence,r),i.instance=d;case"stylesheet":x=Xl(u.href);var v=r.querySelector(fo(x));if(v)return i.state.loading|=4,i.instance=v,kt(v),v;d=Ny(u),(x=Mn.get(x))&&Jd(d,x),v=(r.ownerDocument||r).createElement("link"),kt(v);var j=v;return j._p=new Promise(function(O,Z){j.onload=O,j.onerror=Z}),Vt(v,"link",d),i.state.loading|=4,wu(v,u.precedence,r),i.instance=v;case"script":return v=Ql(u.src),(x=r.querySelector(ho(v)))?(i.instance=x,kt(x),x):(d=u,(x=Mn.get(v))&&(d=p({},u),Wd(d,x)),r=r.ownerDocument||r,x=r.createElement("script"),kt(x),Vt(x,"link",d),r.head.appendChild(x),i.instance=x);case"void":return null;default:throw Error(l(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(d=i.instance,i.state.loading|=4,wu(d,u.precedence,r));return i.instance}function wu(r,i,u){for(var d=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),x=d.length?d[d.length-1]:null,v=x,j=0;j title"):null)}function RE(r,i,u){if(u===1||i.itemProp!=null)return!1;switch(r){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;switch(i.rel){case"stylesheet":return r=i.disabled,typeof i.precedence=="string"&&r==null;default:return!0}case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function Ay(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function OE(r,i,u,d){if(u.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var x=Xl(d.href),v=i.querySelector(fo(x));if(v){i=v._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(r.count++,r=Su.bind(r),i.then(r,r)),u.state.loading|=4,u.instance=v,kt(v);return}v=i.ownerDocument||i,d=Ny(d),(x=Mn.get(x))&&Jd(d,x),v=v.createElement("link"),kt(v);var j=v;j._p=new Promise(function(O,Z){j.onload=O,j.onerror=Z}),Vt(v,"link",d),u.instance=v}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(u,i),(i=u.state.preload)&&(u.state.loading&3)===0&&(r.count++,u=Su.bind(r),i.addEventListener("load",u),i.addEventListener("error",u))}}var eh=0;function LE(r,i){return r.stylesheets&&r.count===0&&Eu(r,r.stylesheets),0eh?50:800)+i);return r.unsuspend=u,function(){r.unsuspend=null,clearTimeout(d),clearTimeout(x)}}:null}function Su(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Eu(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var ku=null;function Eu(r,i){r.stylesheets=null,r.unsuspend!==null&&(r.count++,ku=new Map,i.forEach(HE,r),ku=null,Su.call(r))}function HE(r,i){if(!(i.state.loading&4)){var u=ku.get(r);if(u)var d=u.get(null);else{u=new Map,ku.set(r,u);for(var x=r.querySelectorAll("link[data-precedence],style[data-precedence]"),v=0;v"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),uh.exports=nN(),uh.exports}var iN=rN();/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. @@ -66,203 +66,208 @@ Error generating stack: `+d.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const qe=(e,t)=>{const n=I.forwardRef(({className:l,...a},o)=>I.createElement(oN,{ref:o,iconNode:t,className:mw(`lucide-${lN(e)}`,l),...a}));return n.displayName=`${e}`,n};/** + */const Ie=(e,t)=>{const n=I.forwardRef(({className:l,...a},o)=>I.createElement(oN,{ref:o,iconNode:t,className:mw(`lucide-${lN(e)}`,l),...a}));return n.displayName=`${e}`,n};/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const gw=qe("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/** + */const gw=Ie("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const sN=qe("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/** + */const sN=Ie("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const uN=qe("ArrowUpFromLine",[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** + */const uN=Ie("ArrowUpFromLine",[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const cN=qe("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + */const cN=Ie("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Ki=qe("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + */const Ki=Ie("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ol=qe("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + */const ol=Ie("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Lr=qe("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + */const Lr=Ie("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const fN=qe("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** + */const fN=Ie("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const dN=qe("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** + */const dN=Ie("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const hN=qe("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);/** + */const hN=Ie("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const xw=qe("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + */const xw=Ie("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const yw=qe("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + */const yw=Ie("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const vw=qe("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + */const vw=Ie("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const pN=qe("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + */const pN=Ie("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const mN=qe("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + */const mN=Ie("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const gN=qe("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/** + */const gN=Ie("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const xN=qe("FileOutput",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]]);/** + */const xN=Ie("FileOutput",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const bw=qe("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** + */const bw=Ie("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const yN=qe("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** + */const yN=Ie("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ww=qe("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/** + */const ww=Ie("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const kc=qe("Layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);/** + */const kc=Ie("Layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const da=qe("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + */const ha=Ie("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const vN=qe("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/** + */const vN=Ie("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ym=qe("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/** + */const ym=Ie("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const bN=qe("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/** + */const bN=Ie("Octagon",[["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Ec=qe("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** + */const wN=Ie("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const wN=qe("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/** + */const Ec=Ie("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const _N=qe("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + */const _N=Ie("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const _w=qe("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** + */const SN=Ie("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const SN=qe("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** + */const _w=Ie("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ev=qe("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/** + */const kN=Ie("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Sw=qe("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + */const ev=Ie("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const kN=qe("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/** + */const Sw=Ie("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const lc=qe("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** + */const EN=Ie("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const EN=qe("Variable",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]);/** + */const lc=Ie("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const NN=qe("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** + */const NN=Ie("Variable",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const CN=qe("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** + */const CN=Ie("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const sl=qe("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + */const jN=Ie("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const jN=qe("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),tv=e=>{let t;const n=new Set,l=(f,m)=>{const p=typeof f=="function"?f(t):f;if(!Object.is(p,t)){const g=t;t=m??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(b=>b(t,g))}},a=()=>t,c={setState:l,getState:a,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f))},h=t=e(l,a,c);return c},TN=(e=>e?tv(e):tv),AN=e=>e;function zN(e,t=AN){const n=ra.useSyncExternalStore(e.subscribe,ra.useCallback(()=>t(e.getState()),[e,t]),ra.useCallback(()=>t(e.getInitialState()),[e,t]));return ra.useDebugValue(n),n}const nv=e=>{const t=TN(e),n=l=>zN(t,l);return Object.assign(n,t),n},MN=(e=>e?nv(e):nv);function Me(e,t,n="agent"){return e[t]||(e[t]={name:t,status:"pending",type:n,activity:[]}),e[t].activity||(e[t].activity=[]),e[t]}function Du(e,t,n){Me(e,t).activity.push(n)}function Te(e,t){e[t]&&(e[t]={...e[t]})}function bo(e,t,n,l){const a=e[t];if(!(a!=null&&a.for_each_items))return;const o=a.for_each_items.find(s=>s.key===n);o&&o.activity.push(l)}function DN(e,t,n,l){return{parentAgent:e,iteration:t,slotKey:l??e,workflowFile:n,workflowName:"",status:"pending",agents:[],routes:[],parallelGroups:[],forEachGroups:[],nodes:{},groupProgress:{},highlightedEdges:[],entryPoint:null,children:[],agentsCompleted:0,agentsTotal:0,totalCost:0,totalTokens:0,eventLog:[],activityLog:[],workflowOutput:null,workflowFailure:null}}function nr(e,t){if(t.length===0)return null;let n=e[t[0]];for(let l=1;l=0;c--)if(l[c].slotKey===o){s=c;break}if(s===-1)return null;n.push(s),a=l[s],l=a.children}return{indexPath:n,ctx:a}}function RN(e,t){for(let n=e.length-1;n>=0;n--){const l=e[n];if(l.slotKey===t)return{ctx:l,index:n}}return null}const se=MN((e,t)=>({workflowName:"",workflowStatus:"pending",workflowStartTime:null,workflowFailure:null,workflowFailedAgent:null,workflowYaml:null,conductorVersion:null,entryPoint:null,agents:[],routes:[],parallelGroups:[],forEachGroups:[],nodes:{},groupProgress:{},highlightedEdges:[],agentsCompleted:0,agentsTotal:0,totalCost:0,totalTokens:0,selectedNode:null,wsStatus:"connecting",eventLog:[],activityLog:[],workflowOutput:null,lastEventTime:null,isPaused:!1,iterationLimitGate:null,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[],replayMode:!1,replayEvents:[],replayPosition:0,replayTotalEvents:0,replayPlaying:!1,replaySpeed:1,_wsSend:null,setWsSend:n=>{e({_wsSend:n})},sendGateResponse:(n,l,a)=>{const o=se.getState()._wsSend;o&&o({type:"gate_response",agent_name:n,selected_value:l,additional_input:a||{}})},activeDialog:null,dialogEngaged:!1,engageDialog:()=>{e({dialogEngaged:!0})},sendDialogMessage:(n,l,a)=>{const o=se.getState()._wsSend;o&&o({type:"dialog_message",agent_name:n,dialog_id:l,content:a})},sendDialogDecline:(n,l)=>{const a=se.getState()._wsSend;a&&a({type:"dialog_decline",agent_name:n,dialog_id:l})},sendIterationLimitResponse:(n,l,a)=>{const o=se.getState()._wsSend;if(!o)return;const s=Math.max(0,Math.floor(Number(a)||0)),c="agent_name"in n?{agent_name:n.agent_name}:{group_name:n.group_name};o({type:"iteration_limit_response",gate_id:l,...c,additional_iterations:s})},processEvent:n=>{const l=Ru[n.type];e(a=>{const o={...a,nodes:{...a.nodes},groupProgress:{...a.groupProgress},eventLog:[...a.eventLog],activityLog:[...a.activityLog],lastEventTime:n.timestamp};l&&l(o,n.data,n.timestamp);const s=Ou(n);s&&o.eventLog.push(s);const c=Lu(n);return c&&o.activityLog.push(c),o})},replayState:n=>{e(l=>{const a={...l,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[]};for(const o of n){const s=Ru[o.type];s&&s(a,o.data,o.timestamp);const c=Ou(o);c&&a.eventLog.push(c);const h=Lu(o);h&&a.activityLog.push(h),a.lastEventTime=o.timestamp}return a})},selectNode:n=>{e({selectedNode:n})},setReplayMode:n=>{e(l=>{const a={...l,replayMode:!0,replayEvents:n,replayTotalEvents:n.length,replayPosition:n.length,replayPlaying:!1,replaySpeed:1,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[]};for(const o of n){const s=Ru[o.type];s&&s(a,o.data,o.timestamp);const c=Ou(o);c&&a.eventLog.push(c);const h=Lu(o);h&&a.activityLog.push(h),a.lastEventTime=o.timestamp}return a})},setReplayPosition:n=>{e(l=>{const a=l.replayEvents.slice(0,n),o={...l,replayPosition:n,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,workflowStatus:"pending",workflowStartTime:null,workflowName:"",workflowFailure:null,entryPoint:null,agents:[],routes:[],parallelGroups:[],forEachGroups:[],isPaused:!1,iterationLimitGate:null,lastEventTime:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[]};for(const s of a){const c=Ru[s.type];c&&c(o,s.data,s.timestamp);const h=Ou(s);h&&o.eventLog.push(h);const f=Lu(s);f&&o.activityLog.push(f),o.lastEventTime=s.timestamp}return o})},setReplayPlaying:n=>{e({replayPlaying:n})},setReplaySpeed:n=>{e({replaySpeed:n})},setWsStatus:n=>{e({wsStatus:n})},setEdgeHighlight:(n,l,a)=>{e(o=>({highlightedEdges:[...o.highlightedEdges.filter(s=>!(s.from===n&&s.to===l)),{from:n,to:l,state:a}]}))},clearEdgeHighlight:(n,l)=>{e(a=>({highlightedEdges:a.highlightedEdges.filter(o=>!(o.from===n&&o.to===l))}))},navigateToContext:n=>{e({viewContextPath:n,selectedNode:null})},navigateUp:()=>{e(n=>({viewContextPath:n.viewContextPath.slice(0,-1),selectedNode:null}))},navigateIntoSubworkflow:n=>{const l=t(),a=l.viewContextPath;let o;if(a.length===0)o=l.subworkflowContexts;else{const c=nr(l.subworkflowContexts,a);if(!c)return;o=c.children}const s=RN(o,n);s&&e({viewContextPath:[...a,s.index],selectedNode:null})},getViewedContext:()=>{const n=t();if(n.viewContextPath.length===0)return{workflowName:n.workflowName,agents:n.agents,routes:n.routes,parallelGroups:n.parallelGroups,forEachGroups:n.forEachGroups,nodes:n.nodes,groupProgress:n.groupProgress,highlightedEdges:n.highlightedEdges,entryPoint:n.entryPoint,subworkflowContexts:n.subworkflowContexts};const l=nr(n.subworkflowContexts,n.viewContextPath);return l?{workflowName:l.workflowName,agents:l.agents,routes:l.routes,parallelGroups:l.parallelGroups,forEachGroups:l.forEachGroups,nodes:l.nodes,groupProgress:l.groupProgress,highlightedEdges:l.highlightedEdges,entryPoint:l.entryPoint,subworkflowContexts:l.children}:{workflowName:n.workflowName,agents:n.agents,routes:n.routes,parallelGroups:n.parallelGroups,forEachGroups:n.forEachGroups,nodes:n.nodes,groupProgress:n.groupProgress,highlightedEdges:n.highlightedEdges,entryPoint:n.entryPoint,subworkflowContexts:n.subworkflowContexts}},getBreadcrumbs:()=>{const n=t(),l=[{label:n.workflowName||"Root",path:[]}];let a=n.subworkflowContexts;for(let o=0;o0&&(n=((a=Yi(e.subworkflowContexts,l))==null?void 0:a.ctx)??null),n){const o=n;return{nodes:o.nodes,groupProgress:o.groupProgress,routes:o.routes,highlightedEdges:o.highlightedEdges,addCost:s=>{o.totalCost+=s,e.totalCost+=s},addTokens:s=>{o.totalTokens+=s,e.totalTokens+=s},incrCompleted:()=>{o.agentsCompleted++,e.agentsCompleted++}}}return{nodes:e.nodes,groupProgress:e.groupProgress,routes:e.routes,highlightedEdges:e.highlightedEdges,addCost:o=>{e.totalCost+=o},addTokens:o=>{e.totalTokens+=o},incrCompleted:()=>{e.agentsCompleted++}}}const Ru={workflow_started:(e,t,n)=>{var a;const l=t;if(e.wfDepth===0){e.workflowStatus="running",e.workflowStartTime=n??Date.now()/1e3,e.workflowName=l.name||"",e.workflowYaml=t.yaml_source??null,e.conductorVersion=t.version??null,e.entryPoint=l.entry_point||null,e.agents=l.agents||[],e.routes=l.routes||[],e.parallelGroups=l.parallel_groups||[],e.forEachGroups=l.for_each_groups||[],Me(e.nodes,"$start","start"),e.nodes.$start.status="running",Te(e.nodes,"$start");const o=new Set,s=new Set;for(const c of e.parallelGroups){for(const h of c.agents)o.add(h);s.add(c.name),Me(e.nodes,c.name,"parallel_group"),e.groupProgress[c.name]={total:c.agents.length,completed:0,failed:0};for(const h of c.agents)Me(e.nodes,h,"agent")}for(const c of e.forEachGroups)s.add(c.name),Me(e.nodes,c.name,"for_each_group"),e.groupProgress[c.name]={total:0,completed:0,failed:0};for(const c of e.agents)if(!s.has(c.name)&&!o.has(c.name)){const h=c.type||"agent";Me(e.nodes,c.name,h),c.model&&(e.nodes[c.name].model=c.model),c.reasoning_effort&&(e.nodes[c.name].reasoning_effort=c.reasoning_effort),s.add(c.name)}e.agentsTotal=s.size}else{const o=t.subworkflow_path,s=Array.isArray(o)&&o.length>0?((a=Yi(e.subworkflowContexts,o))==null?void 0:a.ctx)??null:nr(e.subworkflowContexts,e.activeContextPath);if(s){s.workflowName=l.name||"",s.status="running",s.entryPoint=l.entry_point||null,s.agents=l.agents||[],s.routes=l.routes||[],s.parallelGroups=l.parallel_groups||[],s.forEachGroups=l.for_each_groups||[],Me(s.nodes,"$start","start"),s.nodes.$start.status="running";const c=new Set,h=new Set;for(const f of s.parallelGroups){for(const m of f.agents)c.add(m);h.add(f.name),Me(s.nodes,f.name,"parallel_group"),s.groupProgress[f.name]={total:f.agents.length,completed:0,failed:0};for(const m of f.agents)Me(s.nodes,m,"agent")}for(const f of s.forEachGroups)h.add(f.name),Me(s.nodes,f.name,"for_each_group"),s.groupProgress[f.name]={total:0,completed:0,failed:0};for(const f of s.agents)if(!h.has(f.name)&&!c.has(f.name)){const m=f.type||"agent";Me(s.nodes,f.name,m),f.model&&(s.nodes[f.name].model=f.model),f.reasoning_effort&&(s.nodes[f.name].reasoning_effort=f.reasoning_effort),h.add(f.name)}s.agentsTotal=h.size}}e.wfDepth++},agent_started:(e,t,n)=>{const l=t,a=We(e,t),o=Me(a.nodes,l.agent_name);o.iteration!=null&&(o.output!=null||o.error_type!=null)&&(o.iterationHistory||(o.iterationHistory=[]),o.iterationHistory.push({iteration:o.iteration,prompt:o.prompt,output:o.output,elapsed:o.elapsed,model:o.model,reasoning_effort:o.reasoning_effort,tokens:o.tokens,input_tokens:o.input_tokens,output_tokens:o.output_tokens,cost_usd:o.cost_usd,activity:o.activity,error_type:o.error_type,error_message:o.error_message})),o.status="running",o.iteration=l.iteration,o.startedAt=n??Date.now()/1e3,o.activity=[],l.context_window_max!=null&&(o.context_window_max=l.context_window_max),o.prompt=void 0,o.output=void 0,o.error_type=void 0,o.error_message=void 0,Te(a.nodes,l.agent_name)},agent_completed:(e,t)=>{const n=t,l=We(e,t),a=Me(l.nodes,n.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=n.elapsed,a.model=n.model,a.tokens=n.tokens,a.input_tokens=n.input_tokens,a.output_tokens=n.output_tokens,a.cost_usd=n.cost_usd,a.output=n.output,a.output_keys=n.output_keys,a.context_window_used=n.context_window_used,a.context_window_max=n.context_window_max,n.context_window_used!=null&&n.context_window_max!=null&&n.context_window_max>0&&(a.context_pct=Math.round(n.context_window_used/n.context_window_max*100)),n.cost_usd&&l.addCost(n.cost_usd),n.tokens&&l.addTokens(n.tokens),Te(l.nodes,n.agent_name)},agent_failed:(e,t)=>{const n=t,l=We(e,t),a=Me(l.nodes,n.agent_name);a.status="failed",a.elapsed=n.elapsed,a.error_type=n.error_type,a.error_message=n.message;for(const o of l.routes)o.to===n.agent_name&&l.highlightedEdges.push({from:o.from,to:o.to,state:"failed"});Te(l.nodes,n.agent_name)},agent_prompt_rendered:(e,t)=>{var s;const n=t,l=t.item_key,a=We(e,t),o=Me(a.nodes,n.agent_name);if(o.prompt=n.rendered_prompt,o.context_keys=n.context_keys,l){bo(a.nodes,n.agent_name,l,{type:"prompt",icon:"📝",label:"prompt",text:"Prompt rendered",detail:((s=n.rendered_prompt)==null?void 0:s.slice(0,500))||null});const c=a.nodes[n.agent_name];if(c!=null&&c.for_each_items){const h=c.for_each_items.find(f=>f.key===l);h&&(h.prompt=n.rendered_prompt)}}Te(a.nodes,n.agent_name)},agent_reasoning:(e,t)=>{const n=t,l=t.item_key,a=We(e,t),o={type:"reasoning",icon:"💭",label:"thinking",text:n.content};Du(a.nodes,n.agent_name,o),l&&bo(a.nodes,n.agent_name,l,o),Te(a.nodes,n.agent_name)},agent_tool_start:(e,t)=>{const n=t,l=t.item_key,a=We(e,t),o={type:"tool-start",icon:"🔧",label:"tool",text:n.tool_name,detail:n.arguments||null};Du(a.nodes,n.agent_name,o),l&&bo(a.nodes,n.agent_name,l,o),Te(a.nodes,n.agent_name)},agent_tool_complete:(e,t)=>{const n=t,l=t.item_key,a=We(e,t),o={type:"tool-complete",icon:"✓",label:"result",text:n.tool_name||"done",detail:n.result||null};Du(a.nodes,n.agent_name,o),l&&bo(a.nodes,n.agent_name,l,o),Te(a.nodes,n.agent_name)},agent_turn_start:(e,t)=>{const n=t,l=t.item_key,a=We(e,t),o={type:"turn",icon:"⏳",label:"turn",text:`Turn ${n.turn??"?"}`};Du(a.nodes,n.agent_name,o),l&&bo(a.nodes,n.agent_name,l,o),Te(a.nodes,n.agent_name)},agent_message:(e,t)=>{const n=t,l=We(e,t),a=Me(l.nodes,n.agent_name);a.latest_message=n.content,Te(l.nodes,n.agent_name)},script_started:(e,t,n)=>{const l=t,a=We(e,t),o=Me(a.nodes,l.agent_name);o.status="running",o.startedAt=n??Date.now()/1e3,Te(a.nodes,l.agent_name)},script_completed:(e,t)=>{const n=t,l=We(e,t),a=Me(l.nodes,n.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=n.elapsed,a.stdout=n.stdout,a.stderr=n.stderr,a.exit_code=n.exit_code,Te(l.nodes,n.agent_name)},script_failed:(e,t)=>{const n=t,l=We(e,t),a=Me(l.nodes,n.agent_name);a.status="failed",a.elapsed=n.elapsed,a.error_type=n.error_type,a.error_message=n.message,Te(l.nodes,n.agent_name)},wait_started:(e,t,n)=>{const l=t,a=We(e,t),o=Me(a.nodes,l.agent_name);o.status="running",o.startedAt=n??Date.now()/1e3,o.duration_seconds=l.duration_seconds??null,o.reason=l.reason??null,o.iteration=l.iteration,Te(a.nodes,l.agent_name)},wait_completed:(e,t)=>{const n=t,l=We(e,t),a=Me(l.nodes,n.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=n.elapsed,a.waited_seconds=n.waited_seconds,a.requested_seconds=n.requested_seconds,a.reason=n.reason??null,a.interrupted=n.interrupted,Te(l.nodes,n.agent_name)},wait_failed:(e,t)=>{const n=t,l=We(e,t),a=Me(l.nodes,n.agent_name);a.status="failed",a.elapsed=n.elapsed,a.error_type=n.error_type,a.error_message=n.message,Te(l.nodes,n.agent_name)},set_started:(e,t,n)=>{const l=t,a=We(e,t),o=Me(a.nodes,l.agent_name);o.status="running",o.startedAt=n??Date.now()/1e3,Te(a.nodes,l.agent_name)},set_completed:(e,t)=>{const n=t,l=We(e,t),a=Me(l.nodes,n.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=n.elapsed,a.set_output_type=n.output_type,a.set_output_keys=n.output_keys,a.set_value_repr=n.value_repr,Te(l.nodes,n.agent_name)},set_failed:(e,t)=>{const n=t,l=We(e,t),a=Me(l.nodes,n.agent_name);a.status="failed",a.elapsed=n.elapsed,a.error_type=n.error_type,a.error_message=n.message,Te(l.nodes,n.agent_name)},gate_presented:(e,t)=>{const n=t,l=We(e,t),a=Me(l.nodes,n.agent_name);a.status="waiting",a.options=n.options,a.option_details=n.option_details,a.prompt=n.prompt,Te(l.nodes,n.agent_name)},gate_resolved:(e,t)=>{const n=t,l=We(e,t),a=Me(l.nodes,n.agent_name);a.status="completed",l.incrCompleted(),a.selected_option=n.selected_option,a.route=n.route,a.additional_input=n.additional_input,Te(l.nodes,n.agent_name)},route_taken:(e,t)=>{const n=t;We(e,t).highlightedEdges.push({from:n.from_agent,to:n.to_agent,state:"taken"})},parallel_started:(e,t)=>{const n=t,l=We(e,t),a=Me(l.nodes,n.group_name,"parallel_group");a.status="running",l.groupProgress[n.group_name]&&(l.groupProgress[n.group_name].total=n.agents.length,l.groupProgress[n.group_name].completed=0,l.groupProgress[n.group_name].failed=0),Te(l.nodes,n.group_name)},parallel_agent_completed:(e,t)=>{const n=t,l=We(e,t);l.groupProgress[n.group_name]&&l.groupProgress[n.group_name].completed++;const a=Me(l.nodes,n.agent_name);a.status="completed",a.elapsed=n.elapsed,a.model=n.model,a.tokens=n.tokens,a.cost_usd=n.cost_usd,a.context_window_used=n.context_window_used,a.context_window_max=n.context_window_max,n.context_window_used!=null&&n.context_window_max!=null&&n.context_window_max>0&&(a.context_pct=Math.round(n.context_window_used/n.context_window_max*100)),n.cost_usd&&l.addCost(n.cost_usd),n.tokens&&l.addTokens(n.tokens),Te(l.nodes,n.agent_name),Te(l.nodes,n.group_name)},parallel_agent_failed:(e,t)=>{const n=t,l=We(e,t);l.groupProgress[n.group_name]&&l.groupProgress[n.group_name].failed++;const a=Me(l.nodes,n.agent_name);a.status="failed",a.elapsed=n.elapsed,a.error_type=n.error_type,a.error_message=n.message,Te(l.nodes,n.agent_name),Te(l.nodes,n.group_name)},parallel_completed:(e,t)=>{const n=t,l=We(e,t);l.incrCompleted();const a=Me(l.nodes,n.group_name,"parallel_group");a.status=n.failure_count===0?"completed":"failed",Te(l.nodes,n.group_name)},for_each_started:(e,t)=>{const n=t,l=We(e,t),a=Me(l.nodes,n.group_name,"for_each_group");a.status="running",a.for_each_items=[],l.groupProgress[n.group_name]&&(l.groupProgress[n.group_name].total=n.item_count,l.groupProgress[n.group_name].completed=0,l.groupProgress[n.group_name].failed=0),Te(l.nodes,n.group_name)},for_each_item_started:(e,t)=>{const n=t,l=We(e,t),a=Me(l.nodes,n.group_name,"for_each_group");a.for_each_items||(a.for_each_items=[]),a.for_each_items.push({key:n.item_key??String(n.index),index:n.index,status:"running",activity:[]}),Te(l.nodes,n.group_name)},for_each_item_completed:(e,t)=>{const n=t,l=We(e,t);l.groupProgress[n.group_name]&&l.groupProgress[n.group_name].completed++;const a=Me(l.nodes,n.group_name,"for_each_group");if(a.for_each_items){const o=n.item_key??String(n.index),s=a.for_each_items.find(c=>c.key===o);s&&(s.status="completed",s.elapsed=n.elapsed,s.tokens=n.tokens,s.cost_usd=n.cost_usd,s.output=n.output)}Te(l.nodes,n.group_name)},for_each_item_failed:(e,t)=>{const n=t,l=We(e,t);l.groupProgress[n.group_name]&&l.groupProgress[n.group_name].failed++;const a=Me(l.nodes,n.group_name,"for_each_group");if(a.for_each_items){const o=n.item_key??String(n.index),s=a.for_each_items.find(c=>c.key===o);s&&(s.status="failed",s.elapsed=n.elapsed,s.error_type=n.error_type,s.error_message=n.message)}Te(l.nodes,n.group_name)},for_each_completed:(e,t)=>{const n=t,l=We(e,t);l.incrCompleted();const a=Me(l.nodes,n.group_name,"for_each_group");a.status=(n.failure_count??0)===0?"completed":"failed",a.elapsed=n.elapsed,a.success_count=n.success_count,a.failure_count=n.failure_count,Te(l.nodes,n.group_name)},workflow_completed:(e,t)=>{var n;if(e.wfDepth=Math.max(0,e.wfDepth-1),e.wfDepth===0){const l=t;e.workflowStatus="completed",e.isPaused=!1,e.iterationLimitGate=null,e.workflowOutput=l.output??null,e.nodes.$end&&(e.nodes.$end.status="completed",Te(e.nodes,"$end")),e.nodes.$start&&(e.nodes.$start.status="completed",Te(e.nodes,"$start")),e.highlightedEdges=[]}else{const l=t,a=l.subworkflow_path?(n=Yi(e.subworkflowContexts,l.subworkflow_path))==null?void 0:n.ctx:nr(e.subworkflowContexts,e.activeContextPath);a&&(a.status="completed",a.workflowOutput=l.output??null,a.nodes.$end&&(a.nodes.$end.status="completed"),a.nodes.$start&&(a.nodes.$start.status="completed"),a.highlightedEdges=[])}},workflow_failed:(e,t)=>{var l;e.wfDepth=Math.max(0,e.wfDepth-1);const n=t;if(e.wfDepth===0){if(e.workflowStatus="failed",e.isPaused=!1,e.iterationLimitGate=null,e.workflowFailedAgent=n.agent_name||null,n.agent_name&&e.nodes[n.agent_name]){e.nodes[n.agent_name].status="failed",Te(e.nodes,n.agent_name);for(const a of e.routes)a.to===n.agent_name&&e.highlightedEdges.push({from:a.from,to:a.to,state:"failed"})}e.workflowFailure={error_type:n.error_type,message:n.message,elapsed_seconds:n.elapsed_seconds,timeout_seconds:n.timeout_seconds,current_agent:n.current_agent},e.nodes.$start&&(e.nodes.$start.status="completed",Te(e.nodes,"$start"))}else{const a=n.subworkflow_path?(l=Yi(e.subworkflowContexts,n.subworkflow_path))==null?void 0:l.ctx:nr(e.subworkflowContexts,e.activeContextPath);a&&(a.status="failed",a.workflowFailure={error_type:n.error_type,message:n.message})}},subworkflow_started:(e,t)=>{const n=t,l=n.slot_key??(n.item_key!=null?`${n.agent_name}[${n.item_key}]`:n.agent_name),a=DN(n.agent_name,n.iteration??1,n.workflow,l);let o;if(n.parent_path!==void 0){const c=Yi(e.subworkflowContexts,n.parent_path);if(!c)return;o=c.indexPath}else o=e.activeContextPath;let s;if(o.length===0)e.subworkflowContexts.push(a),s=[e.subworkflowContexts.length-1];else{const c=nr(e.subworkflowContexts,o);if(!c)return;c.children.push(a),s=[...o,c.children.length-1]}if(e.activeContextPath=s,o.length===0){const c=e.nodes[n.agent_name];c&&(c.status="running",Te(e.nodes,n.agent_name))}else{const c=nr(e.subworkflowContexts,o);if(c){const h=c.nodes[n.agent_name];h&&(h.status="running",Te(c.nodes,n.agent_name))}}},subworkflow_completed:(e,t)=>{var o;const n=t;let l;if(n.parent_path!==void 0){const s=Yi(e.subworkflowContexts,n.parent_path);if(!s)return;l=s.indexPath}else l=e.activeContextPath;const a=l.length===0?e.nodes:(o=nr(e.subworkflowContexts,l))==null?void 0:o.nodes;if(a){const s=a[n.agent_name];if(s){if(n.item_key==null)if(s.status="completed",s.elapsed=n.elapsed,l.length===0)e.agentsCompleted++;else{const c=nr(e.subworkflowContexts,l);c&&c.agentsCompleted++}Te(a,n.agent_name)}}e.activeContextPath=l},subworkflow_failed:(e,t)=>{var o;const n=t;let l;if(n.parent_path!==void 0){const s=Yi(e.subworkflowContexts,n.parent_path);if(!s)return;l=s.indexPath}else l=e.activeContextPath;const a=l.length===0?e.nodes:(o=nr(e.subworkflowContexts,l))==null?void 0:o.nodes;if(a){const s=a[n.agent_name];s&&n.item_key==null&&(s.status="failed",s.elapsed=n.elapsed,s.error_type=n.error_type,s.error_message=n.message,Te(a,n.agent_name))}e.activeContextPath=l},checkpoint_saved:(e,t)=>{const n=t;n.path&&e.workflowFailure&&(e.workflowFailure={...e.workflowFailure,checkpoint_path:n.path})},agent_paused:(e,t)=>{const n=t,l=Me(e.nodes,n.agent_name);l.status="waiting",l.activity.push({type:"agent_paused",icon:"⏸",label:"Paused",text:"Agent paused — click Resume to re-execute"}),Te(e.nodes,n.agent_name),e.isPaused=!0},agent_resumed:(e,t)=>{const n=t,l=Me(e.nodes,n.agent_name);l.status="running",l.activity.push({type:"agent_resumed",icon:"▶",label:"Resumed",text:"Agent resumed — re-executing"}),Te(e.nodes,n.agent_name),e.isPaused=!1},iteration_limit_reached:(e,t)=>{const n=t;e.iterationLimitGate=n;const l=n.agent_name??n.group_name;l?(Me(e.nodes,l).activity.push({type:"iteration_limit_reached",icon:"⚠",label:"Iteration limit",text:`Reached ${n.current_iteration}/${n.max_iterations} iterations — ${n.skip_gates?"auto-stopping (--skip-gates)":"awaiting decision"}`}),Te(e.nodes,l)):typeof console<"u"&&console.warn("[workflow-store] iteration_limit_reached event missing both agent_name and group_name",n)},iteration_limit_resolved:(e,t)=>{const n=t;e.iterationLimitGate=null;const l=n.agent_name??n.group_name;l?(Me(e.nodes,l).activity.push({type:"iteration_limit_resolved",icon:n.continue_execution?"▶":"■",label:"Iteration limit",text:n.aborted?"Gate aborted unexpectedly — stopping workflow":n.continue_execution?`Continuing with ${n.additional_iterations} more iteration(s)`:"Stopping workflow"}),Te(e.nodes,l)):typeof console<"u"&&console.warn("[workflow-store] iteration_limit_resolved event missing both agent_name and group_name",n)},dialog_started:(e,t)=>{const n=t,l=Me(e.nodes,n.agent_name);l.dialog_id=n.dialog_id,l.dialog_messages=[],l.dialog_active=!0,l.dialog_awaiting_response=!1,e.activeDialog={agentName:n.agent_name,dialogId:n.dialog_id},e.dialogEngaged=!1,Te(e.nodes,n.agent_name)},dialog_message:(e,t)=>{const n=t,l=Me(e.nodes,n.agent_name);l.dialog_messages||(l.dialog_messages=[]),l.dialog_messages.push({role:n.role,content:n.content}),n.role==="user"?l.dialog_awaiting_response=!0:n.role==="agent"&&(l.dialog_awaiting_response=!1),Te(e.nodes,n.agent_name)},dialog_completed:(e,t)=>{const n=t,l=Me(e.nodes,n.agent_name);l.dialog_active=!1,l.dialog_awaiting_response=!1,e.activeDialog=null,e.dialogEngaged=!1,Te(e.nodes,n.agent_name)}};function Ou(e){var l,a;const t=e.timestamp,n=e.data;switch(e.type){case"workflow_started":return{timestamp:t,level:"info",source:"workflow",message:`Workflow "${n.name||""}" started`};case"agent_started":return{timestamp:t,level:"info",source:String(n.agent_name),message:`Agent started${n.iteration!=null?` (iteration ${n.iteration})`:""}`};case"agent_completed":return{timestamp:t,level:"success",source:String(n.agent_name),message:`Agent completed${n.elapsed!=null?` in ${zr(n.elapsed)}`:""}${n.tokens!=null?` · ${n.tokens.toLocaleString()} tokens`:""}${n.cost_usd!=null?` · $${n.cost_usd.toFixed(4)}`:""}`};case"agent_failed":return{timestamp:t,level:"error",source:String(n.agent_name),message:`Agent failed: ${n.message||n.error_type||"unknown error"}`};case"script_started":return{timestamp:t,level:"info",source:String(n.agent_name),message:"Script started"};case"script_completed":return{timestamp:t,level:"success",source:String(n.agent_name),message:`Script completed (exit ${n.exit_code??"?"})${n.elapsed!=null?` in ${zr(n.elapsed)}`:""}`};case"script_failed":return{timestamp:t,level:"error",source:String(n.agent_name),message:`Script failed: ${n.message||n.error_type||"unknown error"}`};case"wait_started":{const o=n.duration_seconds,s=n.reason,c=typeof o=="number"?zr(o):"?";return{timestamp:t,level:"info",source:String(n.agent_name),message:`Waiting ${c}${s?` — ${s}`:""}`}}case"wait_completed":{const o=n.waited_seconds,s=n.interrupted;return{timestamp:t,level:"success",source:String(n.agent_name),message:`Wait completed${o!=null?` (${zr(o)})`:""}${s?" — interrupted":""}`}}case"wait_failed":return{timestamp:t,level:"error",source:String(n.agent_name),message:`Wait failed: ${n.message||n.error_type||"unknown error"}`};case"set_started":return{timestamp:t,level:"info",source:String(n.agent_name),message:"Set started"};case"set_completed":{const o=n.output_keys??[],s=o.length>0?` · ${o.join(", ")}`:"";return{timestamp:t,level:"success",source:String(n.agent_name),message:`Set completed${s}${n.elapsed!=null?` in ${zr(n.elapsed)}`:""}`}}case"set_failed":return{timestamp:t,level:"error",source:String(n.agent_name),message:`Set failed: ${n.message||n.error_type||"unknown error"}`};case"gate_presented":return{timestamp:t,level:"warning",source:String(n.agent_name),message:"Waiting for human input…"};case"gate_resolved":return{timestamp:t,level:"success",source:String(n.agent_name),message:`Gate resolved → ${n.selected_option||"continue"}`};case"route_taken":return{timestamp:t,level:"debug",source:"router",message:`${n.from_agent} → ${n.to_agent}`};case"parallel_started":return{timestamp:t,level:"info",source:String(n.group_name),message:`Parallel group started (${((l=n.agents)==null?void 0:l.length)||"?"} agents)`};case"parallel_completed":return{timestamp:t,level:n.failure_count===0?"success":"error",source:String(n.group_name),message:`Parallel group completed${n.failure_count>0?` with ${n.failure_count} failure(s)`:""}`};case"for_each_started":return{timestamp:t,level:"info",source:String(n.group_name),message:`For-each started (${n.item_count} items)`};case"for_each_completed":return{timestamp:t,level:(n.failure_count??0)===0?"success":"error",source:String(n.group_name),message:`For-each completed · ${n.success_count} succeeded${n.failure_count>0?` · ${n.failure_count} failed`:""}`};case"workflow_completed":return{timestamp:t,level:"success",source:"workflow",message:`Workflow completed${n.elapsed!=null?` in ${zr(n.elapsed)}`:""}`};case"workflow_failed":return{timestamp:t,level:"error",source:"workflow",message:`Workflow failed: ${n.message||n.error_type||"unknown error"}`};case"checkpoint_saved":return{timestamp:t,level:"info",source:"workflow",message:`Checkpoint saved: ${((a=n.path)==null?void 0:a.split("/").pop())||"unknown"}`};case"agent_paused":return{timestamp:t,level:"warning",source:String(n.agent_name),message:"Agent paused — waiting for resume"};case"agent_resumed":return{timestamp:t,level:"info",source:String(n.agent_name),message:"Agent resumed — re-executing"};case"iteration_limit_reached":{const o=n.agent_name??n.group_name??"workflow",s=n.skip_gates?" — auto-stopping (--skip-gates)":" — awaiting decision";return{timestamp:t,level:"warning",source:String(o),message:`Iteration limit reached (${n.current_iteration}/${n.max_iterations})${s}`}}case"iteration_limit_resolved":{const o=n.agent_name??n.group_name??"workflow",s=!!n.continue_execution,c=n.additional_iterations??0;return{timestamp:t,level:s?"info":"warning",source:String(o),message:s?`Iteration limit resolved — continuing with ${c} more`:"Iteration limit resolved — stopping workflow"}}case"dialog_started":return{timestamp:t,level:"warning",source:String(n.agent_name),message:"Dialog started — waiting for user…"};case"dialog_completed":return{timestamp:t,level:"success",source:String(n.agent_name),message:`Dialog completed (${n.turn_count||0} messages)`};default:return null}}function zr(e){if(e<1)return`${(e*1e3).toFixed(0)}ms`;if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=(e%60).toFixed(0);return`${t}m ${n}s`}function Lu(e){const t=e.timestamp,n=e.data;switch(e.type){case"agent_started":return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Agent started${n.iteration!=null?` (iteration ${n.iteration})`:""}`};case"agent_prompt_rendered":return{timestamp:t,source:String(n.agent_name),type:"prompt",message:"Prompt rendered",detail:Zl(String(n.rendered_prompt||""),500)};case"agent_reasoning":return{timestamp:t,source:String(n.agent_name),type:"reasoning",message:String(n.content||"")};case"agent_tool_start":return{timestamp:t,source:String(n.agent_name),type:"tool-start",message:`→ ${n.tool_name}`,detail:n.arguments?Zl(String(n.arguments),300):null};case"agent_tool_complete":return{timestamp:t,source:String(n.agent_name),type:"tool-complete",message:`← ${n.tool_name||"done"}`,detail:n.result?Zl(String(n.result),300):null};case"agent_turn_start":return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Turn ${n.turn??"?"}`};case"agent_message":return{timestamp:t,source:String(n.agent_name),type:"message",message:Zl(String(n.content||""),500)};case"agent_completed":return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Completed${n.elapsed!=null?` in ${zr(n.elapsed)}`:""}${n.tokens!=null?` · ${n.tokens.toLocaleString()} tokens`:""}`};case"agent_failed":return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Failed: ${n.message||n.error_type||"unknown"}`};case"script_started":return{timestamp:t,source:String(n.agent_name),type:"turn",message:"Script started"};case"script_completed":return{timestamp:t,source:String(n.agent_name),type:"tool-complete",message:`Script completed (exit ${n.exit_code??"?"})`,detail:n.stdout?Zl(String(n.stdout),300):null};case"script_failed":return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Script failed: ${n.message||n.error_type||"unknown"}`};case"wait_started":{const l=n.duration_seconds,a=n.reason,o=typeof l=="number"?zr(l):"?";return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Waiting ${o}${a?` — ${a}`:""}`}}case"wait_completed":{const l=n.waited_seconds,a=n.interrupted;return{timestamp:t,source:String(n.agent_name),type:"tool-complete",message:`Wait completed${l!=null?` (${zr(l)})`:""}${a?" — interrupted":""}`}}case"wait_failed":return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Wait failed: ${n.message||n.error_type||"unknown"}`};case"set_started":return{timestamp:t,source:String(n.agent_name),type:"turn",message:"Set started"};case"set_completed":{const l=n.output_keys??[],a=l.length>0?` (${l.join(", ")})`:"";return{timestamp:t,source:String(n.agent_name),type:"tool-complete",message:`Set completed${a}`,detail:n.value_repr?Zl(String(n.value_repr),300):null}}case"set_failed":return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Set failed: ${n.message||n.error_type||"unknown"}`};default:return null}}function Zl(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function rv(e){const t=e.match(/^(\s*)/);return t?t[1].length:0}function ON(e){const t=new Map;for(let n=0;na)o=s;else break}o>n&&t.set(n,o)}return t}function LN(e){if(/^\s*#/.test(e))return y.jsx("span",{className:"text-emerald-500/70",children:e});const t=e.match(/^(\s*)(- )?([a-zA-Z_][\w.-]*)(:\s*)(.*)/);if(t){const[,l,a,o,s,c]=t;return y.jsxs("span",{children:[l,a??"",y.jsx("span",{className:"text-sky-400",children:o}),y.jsx("span",{className:"text-[var(--text-muted)]",children:s}),iv(c??"")]})}const n=e.match(/^(\s*)(- )(.*)/);if(n){const[,l,a,o]=n;return y.jsxs("span",{children:[l,y.jsx("span",{className:"text-[var(--text-muted)]",children:a}),iv(o??"")]})}return y.jsx("span",{children:e})}function iv(e){if(!e)return"";const t=e.indexOf(" #"),n=t>=0?e.slice(0,t):e,l=t>=0?e.slice(t):"";let a=n;return/^(true|false|null|yes|no)$/i.test(n.trim())?a=y.jsx("span",{className:"text-amber-400",children:n}):/^\d+(\.\d+)?$/.test(n.trim())?a=y.jsx("span",{className:"text-amber-400",children:n}):/^["'].*["']$/.test(n.trim())?a=y.jsx("span",{className:"text-green-400",children:n}):(n.includes("|")||n.includes(">"))&&(a=y.jsx("span",{className:"text-[var(--text-secondary)]",children:n})),y.jsxs(y.Fragment,{children:[a,l&&y.jsx("span",{className:"text-emerald-500/70",children:l})]})}function HN({yaml:e,onClose:t}){const[n,l]=I.useState(new Set);I.useEffect(()=>{const h=f=>{f.key==="Escape"&&t()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t]);const a=I.useMemo(()=>e.split(` -`),[e]),o=I.useMemo(()=>ON(a),[a]),s=I.useCallback(h=>{l(f=>{const m=new Set(f);return m.has(h)?m.delete(h):m.add(h),m})},[]),c=I.useMemo(()=>{const h=[];let f=-1;for(let m=0;my.jsxs("div",{className:"flex",children:[y.jsx("span",{className:"inline-flex items-center justify-center flex-shrink-0",style:{width:"1.25rem"},children:m?y.jsx("button",{onClick:()=>s(h),className:"text-[var(--text-muted)] hover:text-[var(--text)] p-0 leading-none",style:{background:"none",border:"none",cursor:"pointer"},children:p?y.jsx(Lr,{className:"w-3 h-3"}):y.jsx(ol,{className:"w-3 h-3"})}):null}),y.jsxs("span",{className:"flex-1",children:[LN(f),p&&y.jsx("span",{className:"text-[var(--text-muted)] text-[11px] ml-2 px-1.5 py-0.5 rounded bg-[var(--surface-hover)] cursor-pointer",onClick:()=>s(h),children:"···"})]})]},h))})})]})]})}function BN(){const e=se(_=>_.workflowName),t=se(_=>_.workflowStatus),n=se(_=>_.isPaused),l=se(_=>_.workflowYaml),a=se(_=>_.conductorVersion),[o,s]=I.useState(!1),[c,h]=I.useState(!1),[f,m]=I.useState(!1),[p,g]=I.useState(!1),b=t==="running"||t==="pending";I.useEffect(()=>{n||(s(!1),h(!1),m(!1))},[n]);const w=async()=>{s(!0);try{await fetch("/api/stop",{method:"POST"})}catch(_){console.error("Failed to stop agent:",_),s(!1)}},E=async()=>{h(!0);try{await fetch("/api/resume",{method:"POST"})}catch(_){console.error("Failed to resume agent:",_),h(!1)}},S=async()=>{m(!0);try{await fetch("/api/kill",{method:"POST"})}catch(_){console.error("Failed to kill workflow:",_),m(!1)}};return y.jsxs("header",{className:"flex items-center justify-between px-4 py-2 bg-[var(--surface)] border-b border-[var(--border)] flex-shrink-0",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(gw,{className:"w-4 h-4 text-[var(--running)]"}),y.jsx("h1",{className:"text-sm font-semibold text-[var(--text)]",children:"Conductor"}),e&&y.jsxs("span",{className:"text-sm text-[var(--text-muted)] font-normal",children:["— ",e]})]}),y.jsxs("div",{className:"flex items-center gap-3",children:[n?y.jsxs(y.Fragment,{children:[y.jsxs("button",{onClick:E,disabled:c,className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded + */const sl=Ie("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const TN=Ie("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),tv=e=>{let t;const n=new Set,l=(f,m)=>{const p=typeof f=="function"?f(t):f;if(!Object.is(p,t)){const g=t;t=m??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(b=>b(t,g))}},a=()=>t,c={setState:l,getState:a,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f))},h=t=e(l,a,c);return c},AN=(e=>e?tv(e):tv),zN=e=>e;function MN(e,t=zN){const n=ia.useSyncExternalStore(e.subscribe,ia.useCallback(()=>t(e.getState()),[e,t]),ia.useCallback(()=>t(e.getInitialState()),[e,t]));return ia.useDebugValue(n),n}const nv=e=>{const t=AN(e),n=l=>MN(t,l);return Object.assign(n,t),n},DN=(e=>e?nv(e):nv);function De(e,t,n="agent"){return e[t]||(e[t]={name:t,status:"pending",type:n,activity:[]}),e[t].activity||(e[t].activity=[]),e[t]}function Du(e,t,n){De(e,t).activity.push(n)}function Ae(e,t){e[t]&&(e[t]={...e[t]})}function bo(e,t,n,l){const a=e[t];if(!(a!=null&&a.for_each_items))return;const o=a.for_each_items.find(s=>s.key===n);o&&o.activity.push(l)}function RN(e,t,n,l){return{parentAgent:e,iteration:t,slotKey:l??e,workflowFile:n,workflowName:"",status:"pending",agents:[],routes:[],parallelGroups:[],forEachGroups:[],nodes:{},groupProgress:{},highlightedEdges:[],entryPoint:null,children:[],agentsCompleted:0,agentsTotal:0,totalCost:0,totalTokens:0,eventLog:[],activityLog:[],workflowOutput:null,workflowFailure:null}}function nr(e,t){if(t.length===0)return null;let n=e[t[0]];for(let l=1;l=0;c--)if(l[c].slotKey===o){s=c;break}if(s===-1)return null;n.push(s),a=l[s],l=a.children}return{indexPath:n,ctx:a}}function ON(e,t){for(let n=e.length-1;n>=0;n--){const l=e[n];if(l.slotKey===t)return{ctx:l,index:n}}return null}const se=DN((e,t)=>({workflowName:"",workflowStatus:"pending",workflowStartTime:null,workflowFailure:null,workflowFailedAgent:null,workflowTermination:null,workflowYaml:null,conductorVersion:null,entryPoint:null,agents:[],routes:[],parallelGroups:[],forEachGroups:[],nodes:{},groupProgress:{},highlightedEdges:[],agentsCompleted:0,agentsTotal:0,totalCost:0,totalTokens:0,selectedNode:null,wsStatus:"connecting",eventLog:[],activityLog:[],workflowOutput:null,lastEventTime:null,isPaused:!1,iterationLimitGate:null,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[],replayMode:!1,replayEvents:[],replayPosition:0,replayTotalEvents:0,replayPlaying:!1,replaySpeed:1,_wsSend:null,setWsSend:n=>{e({_wsSend:n})},sendGateResponse:(n,l,a)=>{const o=se.getState()._wsSend;o&&o({type:"gate_response",agent_name:n,selected_value:l,additional_input:a||{}})},activeDialog:null,dialogEngaged:!1,engageDialog:()=>{e({dialogEngaged:!0})},sendDialogMessage:(n,l,a)=>{const o=se.getState()._wsSend;o&&o({type:"dialog_message",agent_name:n,dialog_id:l,content:a})},sendDialogDecline:(n,l)=>{const a=se.getState()._wsSend;a&&a({type:"dialog_decline",agent_name:n,dialog_id:l})},sendIterationLimitResponse:(n,l,a)=>{const o=se.getState()._wsSend;if(!o)return;const s=Math.max(0,Math.floor(Number(a)||0)),c="agent_name"in n?{agent_name:n.agent_name}:{group_name:n.group_name};o({type:"iteration_limit_response",gate_id:l,...c,additional_iterations:s})},processEvent:n=>{const l=Ru[n.type];e(a=>{const o={...a,nodes:{...a.nodes},groupProgress:{...a.groupProgress},eventLog:[...a.eventLog],activityLog:[...a.activityLog],lastEventTime:n.timestamp};l&&l(o,n.data,n.timestamp);const s=Ou(n);s&&o.eventLog.push(s);const c=Lu(n);return c&&o.activityLog.push(c),o})},replayState:n=>{e(l=>{const a={...l,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,workflowTermination:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[]};for(const o of n){const s=Ru[o.type];s&&s(a,o.data,o.timestamp);const c=Ou(o);c&&a.eventLog.push(c);const h=Lu(o);h&&a.activityLog.push(h),a.lastEventTime=o.timestamp}return a})},selectNode:n=>{e({selectedNode:n})},setReplayMode:n=>{e(l=>{const a={...l,replayMode:!0,replayEvents:n,replayTotalEvents:n.length,replayPosition:n.length,replayPlaying:!1,replaySpeed:1,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,workflowTermination:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[]};for(const o of n){const s=Ru[o.type];s&&s(a,o.data,o.timestamp);const c=Ou(o);c&&a.eventLog.push(c);const h=Lu(o);h&&a.activityLog.push(h),a.lastEventTime=o.timestamp}return a})},setReplayPosition:n=>{e(l=>{const a=l.replayEvents.slice(0,n),o={...l,replayPosition:n,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,workflowTermination:null,workflowStatus:"pending",workflowStartTime:null,workflowName:"",workflowFailure:null,entryPoint:null,agents:[],routes:[],parallelGroups:[],forEachGroups:[],isPaused:!1,iterationLimitGate:null,lastEventTime:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[]};for(const s of a){const c=Ru[s.type];c&&c(o,s.data,s.timestamp);const h=Ou(s);h&&o.eventLog.push(h);const f=Lu(s);f&&o.activityLog.push(f),o.lastEventTime=s.timestamp}return o})},setReplayPlaying:n=>{e({replayPlaying:n})},setReplaySpeed:n=>{e({replaySpeed:n})},setWsStatus:n=>{e({wsStatus:n})},setEdgeHighlight:(n,l,a)=>{e(o=>({highlightedEdges:[...o.highlightedEdges.filter(s=>!(s.from===n&&s.to===l)),{from:n,to:l,state:a}]}))},clearEdgeHighlight:(n,l)=>{e(a=>({highlightedEdges:a.highlightedEdges.filter(o=>!(o.from===n&&o.to===l))}))},navigateToContext:n=>{e({viewContextPath:n,selectedNode:null})},navigateUp:()=>{e(n=>({viewContextPath:n.viewContextPath.slice(0,-1),selectedNode:null}))},navigateIntoSubworkflow:n=>{const l=t(),a=l.viewContextPath;let o;if(a.length===0)o=l.subworkflowContexts;else{const c=nr(l.subworkflowContexts,a);if(!c)return;o=c.children}const s=ON(o,n);s&&e({viewContextPath:[...a,s.index],selectedNode:null})},getViewedContext:()=>{const n=t();if(n.viewContextPath.length===0)return{workflowName:n.workflowName,agents:n.agents,routes:n.routes,parallelGroups:n.parallelGroups,forEachGroups:n.forEachGroups,nodes:n.nodes,groupProgress:n.groupProgress,highlightedEdges:n.highlightedEdges,entryPoint:n.entryPoint,subworkflowContexts:n.subworkflowContexts};const l=nr(n.subworkflowContexts,n.viewContextPath);return l?{workflowName:l.workflowName,agents:l.agents,routes:l.routes,parallelGroups:l.parallelGroups,forEachGroups:l.forEachGroups,nodes:l.nodes,groupProgress:l.groupProgress,highlightedEdges:l.highlightedEdges,entryPoint:l.entryPoint,subworkflowContexts:l.children}:{workflowName:n.workflowName,agents:n.agents,routes:n.routes,parallelGroups:n.parallelGroups,forEachGroups:n.forEachGroups,nodes:n.nodes,groupProgress:n.groupProgress,highlightedEdges:n.highlightedEdges,entryPoint:n.entryPoint,subworkflowContexts:n.subworkflowContexts}},getBreadcrumbs:()=>{const n=t(),l=[{label:n.workflowName||"Root",path:[]}];let a=n.subworkflowContexts;for(let o=0;o0&&(n=((a=Yi(e.subworkflowContexts,l))==null?void 0:a.ctx)??null),n){const o=n;return{nodes:o.nodes,groupProgress:o.groupProgress,routes:o.routes,highlightedEdges:o.highlightedEdges,addCost:s=>{o.totalCost+=s,e.totalCost+=s},addTokens:s=>{o.totalTokens+=s,e.totalTokens+=s},incrCompleted:()=>{o.agentsCompleted++,e.agentsCompleted++}}}return{nodes:e.nodes,groupProgress:e.groupProgress,routes:e.routes,highlightedEdges:e.highlightedEdges,addCost:o=>{e.totalCost+=o},addTokens:o=>{e.totalTokens+=o},incrCompleted:()=>{e.agentsCompleted++}}}const Ru={workflow_started:(e,t,n)=>{var a;const l=t;if(e.wfDepth===0){e.workflowStatus="running",e.workflowStartTime=n??Date.now()/1e3,e.workflowName=l.name||"",e.workflowYaml=t.yaml_source??null,e.conductorVersion=t.version??null,e.entryPoint=l.entry_point||null,e.agents=l.agents||[],e.routes=l.routes||[],e.parallelGroups=l.parallel_groups||[],e.forEachGroups=l.for_each_groups||[],De(e.nodes,"$start","start"),e.nodes.$start.status="running",Ae(e.nodes,"$start");const o=new Set,s=new Set;for(const c of e.parallelGroups){for(const h of c.agents)o.add(h);s.add(c.name),De(e.nodes,c.name,"parallel_group"),e.groupProgress[c.name]={total:c.agents.length,completed:0,failed:0};for(const h of c.agents)De(e.nodes,h,"agent")}for(const c of e.forEachGroups)s.add(c.name),De(e.nodes,c.name,"for_each_group"),e.groupProgress[c.name]={total:0,completed:0,failed:0};for(const c of e.agents)if(!s.has(c.name)&&!o.has(c.name)){const h=c.type||"agent";De(e.nodes,c.name,h),c.model&&(e.nodes[c.name].model=c.model),c.reasoning_effort&&(e.nodes[c.name].reasoning_effort=c.reasoning_effort),s.add(c.name)}e.agentsTotal=s.size}else{const o=t.subworkflow_path,s=Array.isArray(o)&&o.length>0?((a=Yi(e.subworkflowContexts,o))==null?void 0:a.ctx)??null:nr(e.subworkflowContexts,e.activeContextPath);if(s){s.workflowName=l.name||"",s.status="running",s.entryPoint=l.entry_point||null,s.agents=l.agents||[],s.routes=l.routes||[],s.parallelGroups=l.parallel_groups||[],s.forEachGroups=l.for_each_groups||[],De(s.nodes,"$start","start"),s.nodes.$start.status="running";const c=new Set,h=new Set;for(const f of s.parallelGroups){for(const m of f.agents)c.add(m);h.add(f.name),De(s.nodes,f.name,"parallel_group"),s.groupProgress[f.name]={total:f.agents.length,completed:0,failed:0};for(const m of f.agents)De(s.nodes,m,"agent")}for(const f of s.forEachGroups)h.add(f.name),De(s.nodes,f.name,"for_each_group"),s.groupProgress[f.name]={total:0,completed:0,failed:0};for(const f of s.agents)if(!h.has(f.name)&&!c.has(f.name)){const m=f.type||"agent";De(s.nodes,f.name,m),f.model&&(s.nodes[f.name].model=f.model),f.reasoning_effort&&(s.nodes[f.name].reasoning_effort=f.reasoning_effort),h.add(f.name)}s.agentsTotal=h.size}}e.wfDepth++},agent_started:(e,t,n)=>{const l=t,a=We(e,t),o=De(a.nodes,l.agent_name);o.iteration!=null&&(o.output!=null||o.error_type!=null)&&(o.iterationHistory||(o.iterationHistory=[]),o.iterationHistory.push({iteration:o.iteration,prompt:o.prompt,output:o.output,elapsed:o.elapsed,model:o.model,reasoning_effort:o.reasoning_effort,tokens:o.tokens,input_tokens:o.input_tokens,output_tokens:o.output_tokens,cost_usd:o.cost_usd,activity:o.activity,error_type:o.error_type,error_message:o.error_message})),o.status="running",o.iteration=l.iteration,o.startedAt=n??Date.now()/1e3,o.activity=[],l.context_window_max!=null&&(o.context_window_max=l.context_window_max),o.prompt=void 0,o.output=void 0,o.error_type=void 0,o.error_message=void 0,Ae(a.nodes,l.agent_name)},agent_completed:(e,t)=>{const n=t,l=We(e,t),a=De(l.nodes,n.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=n.elapsed,a.model=n.model,a.tokens=n.tokens,a.input_tokens=n.input_tokens,a.output_tokens=n.output_tokens,a.cost_usd=n.cost_usd,a.output=n.output,a.output_keys=n.output_keys,a.context_window_used=n.context_window_used,a.context_window_max=n.context_window_max,n.context_window_used!=null&&n.context_window_max!=null&&n.context_window_max>0&&(a.context_pct=Math.round(n.context_window_used/n.context_window_max*100)),n.cost_usd&&l.addCost(n.cost_usd),n.tokens&&l.addTokens(n.tokens);const o=t;o.terminated_by&&(a.termination_status=o.status??"success",a.termination_reason=o.termination_reason,a.terminated_by=o.terminated_by),Ae(l.nodes,n.agent_name)},agent_failed:(e,t)=>{const n=t,l=We(e,t),a=De(l.nodes,n.agent_name);a.status="failed",a.elapsed=n.elapsed,a.error_type=n.error_type,a.error_message=n.message;for(const s of l.routes)s.to===n.agent_name&&l.highlightedEdges.push({from:s.from,to:s.to,state:"failed"});const o=t;o.terminated_by&&(a.termination_status=o.status??"failed",a.termination_reason=o.termination_reason,a.terminated_by=o.terminated_by),Ae(l.nodes,n.agent_name)},agent_prompt_rendered:(e,t)=>{var s;const n=t,l=t.item_key,a=We(e,t),o=De(a.nodes,n.agent_name);if(o.prompt=n.rendered_prompt,o.context_keys=n.context_keys,l){bo(a.nodes,n.agent_name,l,{type:"prompt",icon:"📝",label:"prompt",text:"Prompt rendered",detail:((s=n.rendered_prompt)==null?void 0:s.slice(0,500))||null});const c=a.nodes[n.agent_name];if(c!=null&&c.for_each_items){const h=c.for_each_items.find(f=>f.key===l);h&&(h.prompt=n.rendered_prompt)}}Ae(a.nodes,n.agent_name)},agent_reasoning:(e,t)=>{const n=t,l=t.item_key,a=We(e,t),o={type:"reasoning",icon:"💭",label:"thinking",text:n.content};Du(a.nodes,n.agent_name,o),l&&bo(a.nodes,n.agent_name,l,o),Ae(a.nodes,n.agent_name)},agent_tool_start:(e,t)=>{const n=t,l=t.item_key,a=We(e,t),o={type:"tool-start",icon:"🔧",label:"tool",text:n.tool_name,detail:n.arguments||null};Du(a.nodes,n.agent_name,o),l&&bo(a.nodes,n.agent_name,l,o),Ae(a.nodes,n.agent_name)},agent_tool_complete:(e,t)=>{const n=t,l=t.item_key,a=We(e,t),o={type:"tool-complete",icon:"✓",label:"result",text:n.tool_name||"done",detail:n.result||null};Du(a.nodes,n.agent_name,o),l&&bo(a.nodes,n.agent_name,l,o),Ae(a.nodes,n.agent_name)},agent_turn_start:(e,t)=>{const n=t,l=t.item_key,a=We(e,t),o={type:"turn",icon:"⏳",label:"turn",text:`Turn ${n.turn??"?"}`};Du(a.nodes,n.agent_name,o),l&&bo(a.nodes,n.agent_name,l,o),Ae(a.nodes,n.agent_name)},agent_message:(e,t)=>{const n=t,l=We(e,t),a=De(l.nodes,n.agent_name);a.latest_message=n.content,Ae(l.nodes,n.agent_name)},script_started:(e,t,n)=>{const l=t,a=We(e,t),o=De(a.nodes,l.agent_name);o.status="running",o.startedAt=n??Date.now()/1e3,Ae(a.nodes,l.agent_name)},script_completed:(e,t)=>{const n=t,l=We(e,t),a=De(l.nodes,n.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=n.elapsed,a.stdout=n.stdout,a.stderr=n.stderr,a.exit_code=n.exit_code,Ae(l.nodes,n.agent_name)},script_failed:(e,t)=>{const n=t,l=We(e,t),a=De(l.nodes,n.agent_name);a.status="failed",a.elapsed=n.elapsed,a.error_type=n.error_type,a.error_message=n.message,Ae(l.nodes,n.agent_name)},wait_started:(e,t,n)=>{const l=t,a=We(e,t),o=De(a.nodes,l.agent_name);o.status="running",o.startedAt=n??Date.now()/1e3,o.duration_seconds=l.duration_seconds??null,o.reason=l.reason??null,o.iteration=l.iteration,Ae(a.nodes,l.agent_name)},wait_completed:(e,t)=>{const n=t,l=We(e,t),a=De(l.nodes,n.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=n.elapsed,a.waited_seconds=n.waited_seconds,a.requested_seconds=n.requested_seconds,a.reason=n.reason??null,a.interrupted=n.interrupted,Ae(l.nodes,n.agent_name)},wait_failed:(e,t)=>{const n=t,l=We(e,t),a=De(l.nodes,n.agent_name);a.status="failed",a.elapsed=n.elapsed,a.error_type=n.error_type,a.error_message=n.message,Ae(l.nodes,n.agent_name)},set_started:(e,t,n)=>{const l=t,a=We(e,t),o=De(a.nodes,l.agent_name);o.status="running",o.startedAt=n??Date.now()/1e3,Ae(a.nodes,l.agent_name)},set_completed:(e,t)=>{const n=t,l=We(e,t),a=De(l.nodes,n.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=n.elapsed,a.set_output_type=n.output_type,a.set_output_keys=n.output_keys,a.set_value_repr=n.value_repr,Ae(l.nodes,n.agent_name)},set_failed:(e,t)=>{const n=t,l=We(e,t),a=De(l.nodes,n.agent_name);a.status="failed",a.elapsed=n.elapsed,a.error_type=n.error_type,a.error_message=n.message,Ae(l.nodes,n.agent_name)},gate_presented:(e,t)=>{const n=t,l=We(e,t),a=De(l.nodes,n.agent_name);a.status="waiting",a.options=n.options,a.option_details=n.option_details,a.prompt=n.prompt,Ae(l.nodes,n.agent_name)},gate_resolved:(e,t)=>{const n=t,l=We(e,t),a=De(l.nodes,n.agent_name);a.status="completed",l.incrCompleted(),a.selected_option=n.selected_option,a.route=n.route,a.additional_input=n.additional_input,Ae(l.nodes,n.agent_name)},route_taken:(e,t)=>{const n=t;We(e,t).highlightedEdges.push({from:n.from_agent,to:n.to_agent,state:"taken"})},parallel_started:(e,t)=>{const n=t,l=We(e,t),a=De(l.nodes,n.group_name,"parallel_group");a.status="running",l.groupProgress[n.group_name]&&(l.groupProgress[n.group_name].total=n.agents.length,l.groupProgress[n.group_name].completed=0,l.groupProgress[n.group_name].failed=0),Ae(l.nodes,n.group_name)},parallel_agent_completed:(e,t)=>{const n=t,l=We(e,t);l.groupProgress[n.group_name]&&l.groupProgress[n.group_name].completed++;const a=De(l.nodes,n.agent_name);a.status="completed",a.elapsed=n.elapsed,a.model=n.model,a.tokens=n.tokens,a.cost_usd=n.cost_usd,a.context_window_used=n.context_window_used,a.context_window_max=n.context_window_max,n.context_window_used!=null&&n.context_window_max!=null&&n.context_window_max>0&&(a.context_pct=Math.round(n.context_window_used/n.context_window_max*100)),n.cost_usd&&l.addCost(n.cost_usd),n.tokens&&l.addTokens(n.tokens),Ae(l.nodes,n.agent_name),Ae(l.nodes,n.group_name)},parallel_agent_failed:(e,t)=>{const n=t,l=We(e,t);l.groupProgress[n.group_name]&&l.groupProgress[n.group_name].failed++;const a=De(l.nodes,n.agent_name);a.status="failed",a.elapsed=n.elapsed,a.error_type=n.error_type,a.error_message=n.message,Ae(l.nodes,n.agent_name),Ae(l.nodes,n.group_name)},parallel_completed:(e,t)=>{const n=t,l=We(e,t);l.incrCompleted();const a=De(l.nodes,n.group_name,"parallel_group");a.status=n.failure_count===0?"completed":"failed",Ae(l.nodes,n.group_name)},for_each_started:(e,t)=>{const n=t,l=We(e,t),a=De(l.nodes,n.group_name,"for_each_group");a.status="running",a.for_each_items=[],l.groupProgress[n.group_name]&&(l.groupProgress[n.group_name].total=n.item_count,l.groupProgress[n.group_name].completed=0,l.groupProgress[n.group_name].failed=0),Ae(l.nodes,n.group_name)},for_each_item_started:(e,t)=>{const n=t,l=We(e,t),a=De(l.nodes,n.group_name,"for_each_group");a.for_each_items||(a.for_each_items=[]),a.for_each_items.push({key:n.item_key??String(n.index),index:n.index,status:"running",activity:[]}),Ae(l.nodes,n.group_name)},for_each_item_completed:(e,t)=>{const n=t,l=We(e,t);l.groupProgress[n.group_name]&&l.groupProgress[n.group_name].completed++;const a=De(l.nodes,n.group_name,"for_each_group");if(a.for_each_items){const o=n.item_key??String(n.index),s=a.for_each_items.find(c=>c.key===o);s&&(s.status="completed",s.elapsed=n.elapsed,s.tokens=n.tokens,s.cost_usd=n.cost_usd,s.output=n.output)}Ae(l.nodes,n.group_name)},for_each_item_failed:(e,t)=>{const n=t,l=We(e,t);l.groupProgress[n.group_name]&&l.groupProgress[n.group_name].failed++;const a=De(l.nodes,n.group_name,"for_each_group");if(a.for_each_items){const o=n.item_key??String(n.index),s=a.for_each_items.find(c=>c.key===o);s&&(s.status="failed",s.elapsed=n.elapsed,s.error_type=n.error_type,s.error_message=n.message)}Ae(l.nodes,n.group_name)},for_each_completed:(e,t)=>{const n=t,l=We(e,t);l.incrCompleted();const a=De(l.nodes,n.group_name,"for_each_group");a.status=(n.failure_count??0)===0?"completed":"failed",a.elapsed=n.elapsed,a.success_count=n.success_count,a.failure_count=n.failure_count,Ae(l.nodes,n.group_name)},workflow_completed:(e,t)=>{var n;if(e.wfDepth=Math.max(0,e.wfDepth-1),e.wfDepth===0){const l=t;e.workflowStatus="completed",e.isPaused=!1,e.iterationLimitGate=null,e.workflowOutput=l.output??null,l.is_explicit?e.workflowTermination={is_explicit:!0,status:l.status??"success",termination_reason:l.termination_reason,terminated_by:l.terminated_by}:e.workflowTermination=null,e.nodes.$end&&(e.nodes.$end.status="completed",Ae(e.nodes,"$end")),e.nodes.$start&&(e.nodes.$start.status="completed",Ae(e.nodes,"$start")),e.highlightedEdges=[]}else{const l=t,a=l.subworkflow_path?(n=Yi(e.subworkflowContexts,l.subworkflow_path))==null?void 0:n.ctx:nr(e.subworkflowContexts,e.activeContextPath);a&&(a.status="completed",a.workflowOutput=l.output??null,a.nodes.$end&&(a.nodes.$end.status="completed"),a.nodes.$start&&(a.nodes.$start.status="completed"),a.highlightedEdges=[])}},workflow_failed:(e,t)=>{var l;e.wfDepth=Math.max(0,e.wfDepth-1);const n=t;if(e.wfDepth===0){if(e.workflowStatus="failed",e.isPaused=!1,e.iterationLimitGate=null,e.workflowFailedAgent=n.agent_name||null,n.agent_name&&e.nodes[n.agent_name]){e.nodes[n.agent_name].status="failed",Ae(e.nodes,n.agent_name);for(const a of e.routes)a.to===n.agent_name&&e.highlightedEdges.push({from:a.from,to:a.to,state:"failed"})}e.workflowFailure={error_type:n.error_type,message:n.message,elapsed_seconds:n.elapsed_seconds,timeout_seconds:n.timeout_seconds,current_agent:n.current_agent,termination_reason:n.termination_reason,terminated_by:n.terminated_by,is_explicit:n.is_explicit,status:n.status},n.is_explicit?e.workflowTermination={is_explicit:!0,status:n.status??"failed",termination_reason:n.termination_reason,terminated_by:n.terminated_by}:e.workflowTermination=null,e.nodes.$start&&(e.nodes.$start.status="completed",Ae(e.nodes,"$start"))}else{const a=n.subworkflow_path?(l=Yi(e.subworkflowContexts,n.subworkflow_path))==null?void 0:l.ctx:nr(e.subworkflowContexts,e.activeContextPath);a&&(a.status="failed",a.workflowFailure={error_type:n.error_type,message:n.message})}},subworkflow_started:(e,t)=>{const n=t,l=n.slot_key??(n.item_key!=null?`${n.agent_name}[${n.item_key}]`:n.agent_name),a=RN(n.agent_name,n.iteration??1,n.workflow,l);let o;if(n.parent_path!==void 0){const c=Yi(e.subworkflowContexts,n.parent_path);if(!c)return;o=c.indexPath}else o=e.activeContextPath;let s;if(o.length===0)e.subworkflowContexts.push(a),s=[e.subworkflowContexts.length-1];else{const c=nr(e.subworkflowContexts,o);if(!c)return;c.children.push(a),s=[...o,c.children.length-1]}if(e.activeContextPath=s,o.length===0){const c=e.nodes[n.agent_name];c&&(c.status="running",Ae(e.nodes,n.agent_name))}else{const c=nr(e.subworkflowContexts,o);if(c){const h=c.nodes[n.agent_name];h&&(h.status="running",Ae(c.nodes,n.agent_name))}}},subworkflow_completed:(e,t)=>{var o;const n=t;let l;if(n.parent_path!==void 0){const s=Yi(e.subworkflowContexts,n.parent_path);if(!s)return;l=s.indexPath}else l=e.activeContextPath;const a=l.length===0?e.nodes:(o=nr(e.subworkflowContexts,l))==null?void 0:o.nodes;if(a){const s=a[n.agent_name];if(s){if(n.item_key==null)if(s.status="completed",s.elapsed=n.elapsed,l.length===0)e.agentsCompleted++;else{const c=nr(e.subworkflowContexts,l);c&&c.agentsCompleted++}Ae(a,n.agent_name)}}e.activeContextPath=l},subworkflow_failed:(e,t)=>{var o;const n=t;let l;if(n.parent_path!==void 0){const s=Yi(e.subworkflowContexts,n.parent_path);if(!s)return;l=s.indexPath}else l=e.activeContextPath;const a=l.length===0?e.nodes:(o=nr(e.subworkflowContexts,l))==null?void 0:o.nodes;if(a){const s=a[n.agent_name];s&&n.item_key==null&&(s.status="failed",s.elapsed=n.elapsed,s.error_type=n.error_type,s.error_message=n.message,Ae(a,n.agent_name))}e.activeContextPath=l},checkpoint_saved:(e,t)=>{const n=t;n.path&&e.workflowFailure&&(e.workflowFailure={...e.workflowFailure,checkpoint_path:n.path})},agent_paused:(e,t)=>{const n=t,l=De(e.nodes,n.agent_name);l.status="waiting",l.activity.push({type:"agent_paused",icon:"⏸",label:"Paused",text:"Agent paused — click Resume to re-execute"}),Ae(e.nodes,n.agent_name),e.isPaused=!0},agent_resumed:(e,t)=>{const n=t,l=De(e.nodes,n.agent_name);l.status="running",l.activity.push({type:"agent_resumed",icon:"▶",label:"Resumed",text:"Agent resumed — re-executing"}),Ae(e.nodes,n.agent_name),e.isPaused=!1},iteration_limit_reached:(e,t)=>{const n=t;e.iterationLimitGate=n;const l=n.agent_name??n.group_name;l?(De(e.nodes,l).activity.push({type:"iteration_limit_reached",icon:"⚠",label:"Iteration limit",text:`Reached ${n.current_iteration}/${n.max_iterations} iterations — ${n.skip_gates?"auto-stopping (--skip-gates)":"awaiting decision"}`}),Ae(e.nodes,l)):typeof console<"u"&&console.warn("[workflow-store] iteration_limit_reached event missing both agent_name and group_name",n)},iteration_limit_resolved:(e,t)=>{const n=t;e.iterationLimitGate=null;const l=n.agent_name??n.group_name;l?(De(e.nodes,l).activity.push({type:"iteration_limit_resolved",icon:n.continue_execution?"▶":"■",label:"Iteration limit",text:n.aborted?"Gate aborted unexpectedly — stopping workflow":n.continue_execution?`Continuing with ${n.additional_iterations} more iteration(s)`:"Stopping workflow"}),Ae(e.nodes,l)):typeof console<"u"&&console.warn("[workflow-store] iteration_limit_resolved event missing both agent_name and group_name",n)},dialog_started:(e,t)=>{const n=t,l=De(e.nodes,n.agent_name);l.dialog_id=n.dialog_id,l.dialog_messages=[],l.dialog_active=!0,l.dialog_awaiting_response=!1,e.activeDialog={agentName:n.agent_name,dialogId:n.dialog_id},e.dialogEngaged=!1,Ae(e.nodes,n.agent_name)},dialog_message:(e,t)=>{const n=t,l=De(e.nodes,n.agent_name);l.dialog_messages||(l.dialog_messages=[]),l.dialog_messages.push({role:n.role,content:n.content}),n.role==="user"?l.dialog_awaiting_response=!0:n.role==="agent"&&(l.dialog_awaiting_response=!1),Ae(e.nodes,n.agent_name)},dialog_completed:(e,t)=>{const n=t,l=De(e.nodes,n.agent_name);l.dialog_active=!1,l.dialog_awaiting_response=!1,e.activeDialog=null,e.dialogEngaged=!1,Ae(e.nodes,n.agent_name)}};function Ou(e){var l,a;const t=e.timestamp,n=e.data;switch(e.type){case"workflow_started":return{timestamp:t,level:"info",source:"workflow",message:`Workflow "${n.name||""}" started`};case"agent_started":return{timestamp:t,level:"info",source:String(n.agent_name),message:`Agent started${n.iteration!=null?` (iteration ${n.iteration})`:""}`};case"agent_completed":return{timestamp:t,level:"success",source:String(n.agent_name),message:`Agent completed${n.elapsed!=null?` in ${zr(n.elapsed)}`:""}${n.tokens!=null?` · ${n.tokens.toLocaleString()} tokens`:""}${n.cost_usd!=null?` · $${n.cost_usd.toFixed(4)}`:""}`};case"agent_failed":return{timestamp:t,level:"error",source:String(n.agent_name),message:`Agent failed: ${n.message||n.error_type||"unknown error"}`};case"script_started":return{timestamp:t,level:"info",source:String(n.agent_name),message:"Script started"};case"script_completed":return{timestamp:t,level:"success",source:String(n.agent_name),message:`Script completed (exit ${n.exit_code??"?"})${n.elapsed!=null?` in ${zr(n.elapsed)}`:""}`};case"script_failed":return{timestamp:t,level:"error",source:String(n.agent_name),message:`Script failed: ${n.message||n.error_type||"unknown error"}`};case"wait_started":{const o=n.duration_seconds,s=n.reason,c=typeof o=="number"?zr(o):"?";return{timestamp:t,level:"info",source:String(n.agent_name),message:`Waiting ${c}${s?` — ${s}`:""}`}}case"wait_completed":{const o=n.waited_seconds,s=n.interrupted;return{timestamp:t,level:"success",source:String(n.agent_name),message:`Wait completed${o!=null?` (${zr(o)})`:""}${s?" — interrupted":""}`}}case"wait_failed":return{timestamp:t,level:"error",source:String(n.agent_name),message:`Wait failed: ${n.message||n.error_type||"unknown error"}`};case"set_started":return{timestamp:t,level:"info",source:String(n.agent_name),message:"Set started"};case"set_completed":{const o=n.output_keys??[],s=o.length>0?` · ${o.join(", ")}`:"";return{timestamp:t,level:"success",source:String(n.agent_name),message:`Set completed${s}${n.elapsed!=null?` in ${zr(n.elapsed)}`:""}`}}case"set_failed":return{timestamp:t,level:"error",source:String(n.agent_name),message:`Set failed: ${n.message||n.error_type||"unknown error"}`};case"gate_presented":return{timestamp:t,level:"warning",source:String(n.agent_name),message:"Waiting for human input…"};case"gate_resolved":return{timestamp:t,level:"success",source:String(n.agent_name),message:`Gate resolved → ${n.selected_option||"continue"}`};case"route_taken":return{timestamp:t,level:"debug",source:"router",message:`${n.from_agent} → ${n.to_agent}`};case"parallel_started":return{timestamp:t,level:"info",source:String(n.group_name),message:`Parallel group started (${((l=n.agents)==null?void 0:l.length)||"?"} agents)`};case"parallel_completed":return{timestamp:t,level:n.failure_count===0?"success":"error",source:String(n.group_name),message:`Parallel group completed${n.failure_count>0?` with ${n.failure_count} failure(s)`:""}`};case"for_each_started":return{timestamp:t,level:"info",source:String(n.group_name),message:`For-each started (${n.item_count} items)`};case"for_each_completed":return{timestamp:t,level:(n.failure_count??0)===0?"success":"error",source:String(n.group_name),message:`For-each completed · ${n.success_count} succeeded${n.failure_count>0?` · ${n.failure_count} failed`:""}`};case"workflow_completed":return{timestamp:t,level:"success",source:"workflow",message:`Workflow completed${n.elapsed!=null?` in ${zr(n.elapsed)}`:""}`};case"workflow_failed":return{timestamp:t,level:"error",source:"workflow",message:`Workflow failed: ${n.message||n.error_type||"unknown error"}`};case"checkpoint_saved":return{timestamp:t,level:"info",source:"workflow",message:`Checkpoint saved: ${((a=n.path)==null?void 0:a.split("/").pop())||"unknown"}`};case"agent_paused":return{timestamp:t,level:"warning",source:String(n.agent_name),message:"Agent paused — waiting for resume"};case"agent_resumed":return{timestamp:t,level:"info",source:String(n.agent_name),message:"Agent resumed — re-executing"};case"iteration_limit_reached":{const o=n.agent_name??n.group_name??"workflow",s=n.skip_gates?" — auto-stopping (--skip-gates)":" — awaiting decision";return{timestamp:t,level:"warning",source:String(o),message:`Iteration limit reached (${n.current_iteration}/${n.max_iterations})${s}`}}case"iteration_limit_resolved":{const o=n.agent_name??n.group_name??"workflow",s=!!n.continue_execution,c=n.additional_iterations??0;return{timestamp:t,level:s?"info":"warning",source:String(o),message:s?`Iteration limit resolved — continuing with ${c} more`:"Iteration limit resolved — stopping workflow"}}case"dialog_started":return{timestamp:t,level:"warning",source:String(n.agent_name),message:"Dialog started — waiting for user…"};case"dialog_completed":return{timestamp:t,level:"success",source:String(n.agent_name),message:`Dialog completed (${n.turn_count||0} messages)`};default:return null}}function zr(e){if(e<1)return`${(e*1e3).toFixed(0)}ms`;if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=(e%60).toFixed(0);return`${t}m ${n}s`}function Lu(e){const t=e.timestamp,n=e.data;switch(e.type){case"agent_started":return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Agent started${n.iteration!=null?` (iteration ${n.iteration})`:""}`};case"agent_prompt_rendered":return{timestamp:t,source:String(n.agent_name),type:"prompt",message:"Prompt rendered",detail:Kl(String(n.rendered_prompt||""),500)};case"agent_reasoning":return{timestamp:t,source:String(n.agent_name),type:"reasoning",message:String(n.content||"")};case"agent_tool_start":return{timestamp:t,source:String(n.agent_name),type:"tool-start",message:`→ ${n.tool_name}`,detail:n.arguments?Kl(String(n.arguments),300):null};case"agent_tool_complete":return{timestamp:t,source:String(n.agent_name),type:"tool-complete",message:`← ${n.tool_name||"done"}`,detail:n.result?Kl(String(n.result),300):null};case"agent_turn_start":return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Turn ${n.turn??"?"}`};case"agent_message":return{timestamp:t,source:String(n.agent_name),type:"message",message:Kl(String(n.content||""),500)};case"agent_completed":return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Completed${n.elapsed!=null?` in ${zr(n.elapsed)}`:""}${n.tokens!=null?` · ${n.tokens.toLocaleString()} tokens`:""}`};case"agent_failed":return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Failed: ${n.message||n.error_type||"unknown"}`};case"script_started":return{timestamp:t,source:String(n.agent_name),type:"turn",message:"Script started"};case"script_completed":return{timestamp:t,source:String(n.agent_name),type:"tool-complete",message:`Script completed (exit ${n.exit_code??"?"})`,detail:n.stdout?Kl(String(n.stdout),300):null};case"script_failed":return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Script failed: ${n.message||n.error_type||"unknown"}`};case"wait_started":{const l=n.duration_seconds,a=n.reason,o=typeof l=="number"?zr(l):"?";return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Waiting ${o}${a?` — ${a}`:""}`}}case"wait_completed":{const l=n.waited_seconds,a=n.interrupted;return{timestamp:t,source:String(n.agent_name),type:"tool-complete",message:`Wait completed${l!=null?` (${zr(l)})`:""}${a?" — interrupted":""}`}}case"wait_failed":return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Wait failed: ${n.message||n.error_type||"unknown"}`};case"set_started":return{timestamp:t,source:String(n.agent_name),type:"turn",message:"Set started"};case"set_completed":{const l=n.output_keys??[],a=l.length>0?` (${l.join(", ")})`:"";return{timestamp:t,source:String(n.agent_name),type:"tool-complete",message:`Set completed${a}`,detail:n.value_repr?Kl(String(n.value_repr),300):null}}case"set_failed":return{timestamp:t,source:String(n.agent_name),type:"turn",message:`Set failed: ${n.message||n.error_type||"unknown"}`};default:return null}}function Kl(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function rv(e){const t=e.match(/^(\s*)/);return t?t[1].length:0}function LN(e){const t=new Map;for(let n=0;na)o=s;else break}o>n&&t.set(n,o)}return t}function HN(e){if(/^\s*#/.test(e))return y.jsx("span",{className:"text-emerald-500/70",children:e});const t=e.match(/^(\s*)(- )?([a-zA-Z_][\w.-]*)(:\s*)(.*)/);if(t){const[,l,a,o,s,c]=t;return y.jsxs("span",{children:[l,a??"",y.jsx("span",{className:"text-sky-400",children:o}),y.jsx("span",{className:"text-[var(--text-muted)]",children:s}),iv(c??"")]})}const n=e.match(/^(\s*)(- )(.*)/);if(n){const[,l,a,o]=n;return y.jsxs("span",{children:[l,y.jsx("span",{className:"text-[var(--text-muted)]",children:a}),iv(o??"")]})}return y.jsx("span",{children:e})}function iv(e){if(!e)return"";const t=e.indexOf(" #"),n=t>=0?e.slice(0,t):e,l=t>=0?e.slice(t):"";let a=n;return/^(true|false|null|yes|no)$/i.test(n.trim())?a=y.jsx("span",{className:"text-amber-400",children:n}):/^\d+(\.\d+)?$/.test(n.trim())?a=y.jsx("span",{className:"text-amber-400",children:n}):/^["'].*["']$/.test(n.trim())?a=y.jsx("span",{className:"text-green-400",children:n}):(n.includes("|")||n.includes(">"))&&(a=y.jsx("span",{className:"text-[var(--text-secondary)]",children:n})),y.jsxs(y.Fragment,{children:[a,l&&y.jsx("span",{className:"text-emerald-500/70",children:l})]})}function BN({yaml:e,onClose:t}){const[n,l]=I.useState(new Set);I.useEffect(()=>{const h=f=>{f.key==="Escape"&&t()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t]);const a=I.useMemo(()=>e.split(` +`),[e]),o=I.useMemo(()=>LN(a),[a]),s=I.useCallback(h=>{l(f=>{const m=new Set(f);return m.has(h)?m.delete(h):m.add(h),m})},[]),c=I.useMemo(()=>{const h=[];let f=-1;for(let m=0;my.jsxs("div",{className:"flex",children:[y.jsx("span",{className:"inline-flex items-center justify-center flex-shrink-0",style:{width:"1.25rem"},children:m?y.jsx("button",{onClick:()=>s(h),className:"text-[var(--text-muted)] hover:text-[var(--text)] p-0 leading-none",style:{background:"none",border:"none",cursor:"pointer"},children:p?y.jsx(Lr,{className:"w-3 h-3"}):y.jsx(ol,{className:"w-3 h-3"})}):null}),y.jsxs("span",{className:"flex-1",children:[HN(f),p&&y.jsx("span",{className:"text-[var(--text-muted)] text-[11px] ml-2 px-1.5 py-0.5 rounded bg-[var(--surface-hover)] cursor-pointer",onClick:()=>s(h),children:"···"})]})]},h))})})]})]})}function IN(){const e=se(_=>_.workflowName),t=se(_=>_.workflowStatus),n=se(_=>_.isPaused),l=se(_=>_.workflowYaml),a=se(_=>_.conductorVersion),[o,s]=I.useState(!1),[c,h]=I.useState(!1),[f,m]=I.useState(!1),[p,g]=I.useState(!1),b=t==="running"||t==="pending";I.useEffect(()=>{n||(s(!1),h(!1),m(!1))},[n]);const w=async()=>{s(!0);try{await fetch("/api/stop",{method:"POST"})}catch(_){console.error("Failed to stop agent:",_),s(!1)}},E=async()=>{h(!0);try{await fetch("/api/resume",{method:"POST"})}catch(_){console.error("Failed to resume agent:",_),h(!1)}},S=async()=>{m(!0);try{await fetch("/api/kill",{method:"POST"})}catch(_){console.error("Failed to kill workflow:",_),m(!1)}};return y.jsxs("header",{className:"flex items-center justify-between px-4 py-2 bg-[var(--surface)] border-b border-[var(--border)] flex-shrink-0",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(gw,{className:"w-4 h-4 text-[var(--running)]"}),y.jsx("h1",{className:"text-sm font-semibold text-[var(--text)]",children:"Conductor"}),e&&y.jsxs("span",{className:"text-sm text-[var(--text-muted)] font-normal",children:["— ",e]})]}),y.jsxs("div",{className:"flex items-center gap-3",children:[n?y.jsxs(y.Fragment,{children:[y.jsxs("button",{onClick:E,disabled:c,className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 hover:bg-emerald-500/20 hover:border-emerald-500/30 disabled:opacity-50 disabled:cursor-not-allowed @@ -280,7 +285,7 @@ Error generating stack: `+d.message+` transition-colors`,title:"View workflow YAML configuration",children:[y.jsx(gN,{className:"w-3 h-3"}),"YAML"]}),y.jsxs("a",{href:"/api/logs",download:"conductor-logs.json",className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded bg-[var(--surface-hover)] text-[var(--text-secondary)] border border-[var(--border)] hover:text-[var(--text)] hover:bg-[var(--surface)] - transition-colors`,title:"Download full event log as JSON",children:[y.jsx(pN,{className:"w-3 h-3"}),"Logs"]}),y.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["v",a??"—"]})]}),p&&l&&y.jsx(HN,{yaml:l,onClose:()=>g(!1)})]})}function IN(){const e=se(o=>o.getBreadcrumbs),t=se(o=>o.navigateToContext),n=se(o=>o.viewContextPath);if(se(o=>o.subworkflowContexts).length===0&&n.length===0)return null;const a=e();return y.jsxs("div",{className:"flex items-center gap-1 px-4 py-1.5 bg-[var(--surface)] border-b border-[var(--border)] text-xs flex-shrink-0",children:[y.jsx(kc,{className:"w-3 h-3 text-[var(--text-muted)] mr-1"}),a.map((o,s)=>{const c=s===a.length-1,h=JSON.stringify(o.path)===JSON.stringify(n);return y.jsxs("span",{className:"flex items-center gap-1",children:[s>0&&y.jsx(Lr,{className:"w-3 h-3 text-[var(--text-muted)]"}),c?y.jsx("span",{className:"font-semibold text-[var(--text)]",children:o.label}):y.jsx("button",{onClick:()=>t(o.path),className:`hover:text-[var(--running)] transition-colors ${h?"text-[var(--text)] font-medium":"text-[var(--text-muted)]"}`,children:o.label})]},s)})]})}function Ae(...e){return e.filter(Boolean).join(" ")}function ot(e){if(e==null)return"";if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=(e%60).toFixed(0);return`${t}m ${n}s`}function Pn(e){return e==null?"":e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:`${e}`}function wi(e){return e==null?"":`$${e.toFixed(4)}`}function kw(e){return e==null?"":typeof e=="string"?e:JSON.stringify(e,null,2)}function qN(e,t){if(t<=0)return`${e.toLocaleString()} tokens (limit unknown)`;const n=a=>a.toLocaleString(),l=(e/t*100).toFixed(1);return`${n(e)} / ${n(t)} (${l}%)`}function Ew(){const e=se(c=>c.workflowStatus),t=se(c=>c.workflowStartTime),n=se(c=>c.replayMode),l=se(c=>c.lastEventTime),[a,o]=I.useState("—"),s=I.useRef(null);return I.useEffect(()=>{if(t!=null){if(n){s.current&&(clearInterval(s.current),s.current=null),o(ot((l??t)-t));return}if(e==="running"){const c=()=>{const h=Date.now()/1e3-t;o(ot(h))};return c(),s.current=setInterval(c,500),()=>{s.current&&clearInterval(s.current)}}else(e==="completed"||e==="failed")&&s.current&&(clearInterval(s.current),s.current=null)}},[e,t,n,l]),a}function $N(){const e=se(_=>_.workflowStatus),t=se(_=>_.agentsCompleted),n=se(_=>_.agentsTotal),l=se(_=>_.totalCost),a=se(_=>_.totalTokens),o=se(_=>_.wsStatus),s=se(_=>_.workflowFailure),c=se(_=>_.lastEventTime),h=se(_=>_.iterationLimitGate),f=Ew(),[m,p]=I.useState(null);I.useEffect(()=>{if(e!=="running"||c==null){p(null);return}const _=()=>{p(Math.floor(Date.now()/1e3-c))};_();const N=setInterval(_,1e3);return()=>clearInterval(N)},[e,c]);const g=e==="failed",b=(()=>{if(h&&e==="running"){const _=h.agent_name??h.group_name??"workflow",N=h.skip_gates?" — auto-stopping":" — awaiting decision";return`Iteration limit reached: ${_} ${h.current_iteration}/${h.max_iterations}${N}`}switch(e){case"pending":return"Waiting for workflow…";case"running":return"Running";case"completed":return"Completed";case"failed":{if(!s)return"Failed";const _=s.error_type||"";return _==="MaxIterationsError"?"Failed: exceeded maximum iterations":_==="TimeoutError"?"Failed: workflow timed out":s.message?`Failed: ${s.message.length>60?s.message.slice(0,57)+"...":s.message}`:`Failed: ${_}`}}})(),w=h!=null&&e==="running",E=w?"bg-[var(--waiting)] animate-pulse":{pending:"bg-[var(--pending)]",running:"bg-[var(--running)] animate-pulse",completed:"bg-[var(--completed)]",failed:"bg-[var(--failed)]"}[e],S=(()=>{switch(o){case"connected":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--completed)]",children:[y.jsx(CN,{className:"w-3 h-3"}),y.jsx("span",{children:"Connected"})]});case"disconnected":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--failed)]",children:[y.jsx(NN,{className:"w-3 h-3"}),y.jsx("span",{children:"Disconnected"})]});case"reconnecting":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--waiting)]",children:[y.jsx(da,{className:"w-3 h-3 animate-spin"}),y.jsx("span",{children:"Reconnecting\\u2026"})]});case"connecting":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--text-muted)]",children:[y.jsx(da,{className:"w-3 h-3 animate-spin"}),y.jsx("span",{children:"Connecting\\u2026"})]})}})();return y.jsxs("footer",{className:Ae("flex items-center gap-4 px-4 py-1.5 border-t text-xs flex-shrink-0 transition-colors duration-300",g?"bg-red-950/50 border-red-500/30":w?"bg-amber-950/30 border-amber-500/30":"bg-[var(--surface)] border-[var(--border)]"),children:[y.jsx("span",{className:Ae("w-2 h-2 rounded-full flex-shrink-0",E)}),y.jsx("span",{className:Ae(g?"text-red-300":w?"text-amber-200":"text-[var(--text)]"),children:b}),n>0&&y.jsxs("span",{className:Ae(g?"text-red-400/60":"text-[var(--text-muted)]"),children:[t,"/",n," agents"]}),e!=="pending"&&y.jsx("span",{className:Ae("font-mono",g?"text-red-400/60":"text-[var(--text-muted)]"),children:f}),a>0&&y.jsxs("span",{className:Ae("flex items-center gap-1",g?"text-red-400/60":"text-[var(--text-muted)]"),title:"Total tokens used",children:[y.jsx(ww,{className:"w-3 h-3"}),y.jsx("span",{className:"font-mono",children:a.toLocaleString()})]}),l>0&&y.jsxs("span",{className:Ae("flex items-center gap-1",g?"text-red-400/60":"text-[var(--text-muted)]"),title:"Total cost",children:[y.jsx(yw,{className:"w-3 h-3"}),y.jsxs("span",{className:"font-mono",children:["$",l.toFixed(4)]})]}),m!=null&&m>=5&&y.jsxs("span",{className:Ae("flex items-center gap-1 font-mono",m>=60?"text-amber-400":"text-[var(--text-muted)]"),title:"Time since last event from the provider",children:[y.jsx(xw,{className:"w-3 h-3"}),y.jsx("span",{children:m>=60?`${Math.floor(m/60)}m ${m%60}s idle`:`${m}s idle`})]}),y.jsx("span",{className:"flex-1"}),S]})}const UN=[1,5,10,20,50];function VN(e,t){if(t===0||e.length===0)return"+0.0s";const n=e[0].timestamp,a=e[Math.min(t,e.length)-1].timestamp-n;if(a<60)return`+${a.toFixed(1)}s`;const o=Math.floor(a/60),s=a%60;return`+${o}m${s.toFixed(0)}s`}function PN(){const e=se(p=>p.replayPosition),t=se(p=>p.replayTotalEvents),n=se(p=>p.replayPlaying),l=se(p=>p.replaySpeed),a=se(p=>p.replayEvents),o=se(p=>p.setReplayPosition),s=se(p=>p.setReplayPlaying),c=se(p=>p.setReplaySpeed),h=p=>{const g=parseInt(p.target.value,10);o(g),n&&s(!1)},f=()=>{!n&&e>=t&&o(0),s(!n)},m=t>0?e/t*100:0;return y.jsxs("footer",{className:"flex items-center gap-3 px-4 py-1.5 border-t bg-[var(--surface)] border-[var(--border)] text-xs flex-shrink-0",children:[y.jsx("button",{onClick:f,className:"flex items-center justify-center w-6 h-6 rounded hover:bg-[var(--surface-hover)] text-[var(--text-secondary)] hover:text-[var(--text)] transition-colors",title:n?"Pause":"Play",children:n?y.jsx(bN,{className:"w-3.5 h-3.5"}):y.jsx(Ec,{className:"w-3.5 h-3.5"})}),y.jsxs("div",{className:"flex-1 relative flex items-center",children:[y.jsx("input",{type:"range",min:0,max:t,value:e,onChange:h,className:"w-full h-1 appearance-none rounded-full cursor-pointer",style:{background:`linear-gradient(to right, var(--accent) 0%, var(--accent) ${m}%, var(--border) ${m}%, var(--border) 100%)`,WebkitAppearance:"none"}}),y.jsx("style",{children:` + transition-colors`,title:"Download full event log as JSON",children:[y.jsx(pN,{className:"w-3 h-3"}),"Logs"]}),y.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["v",a??"—"]})]}),p&&l&&y.jsx(BN,{yaml:l,onClose:()=>g(!1)})]})}function qN(){const e=se(o=>o.getBreadcrumbs),t=se(o=>o.navigateToContext),n=se(o=>o.viewContextPath);if(se(o=>o.subworkflowContexts).length===0&&n.length===0)return null;const a=e();return y.jsxs("div",{className:"flex items-center gap-1 px-4 py-1.5 bg-[var(--surface)] border-b border-[var(--border)] text-xs flex-shrink-0",children:[y.jsx(kc,{className:"w-3 h-3 text-[var(--text-muted)] mr-1"}),a.map((o,s)=>{const c=s===a.length-1,h=JSON.stringify(o.path)===JSON.stringify(n);return y.jsxs("span",{className:"flex items-center gap-1",children:[s>0&&y.jsx(Lr,{className:"w-3 h-3 text-[var(--text-muted)]"}),c?y.jsx("span",{className:"font-semibold text-[var(--text)]",children:o.label}):y.jsx("button",{onClick:()=>t(o.path),className:`hover:text-[var(--running)] transition-colors ${h?"text-[var(--text)] font-medium":"text-[var(--text-muted)]"}`,children:o.label})]},s)})]})}function je(...e){return e.filter(Boolean).join(" ")}function ot(e){if(e==null)return"";if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=(e%60).toFixed(0);return`${t}m ${n}s`}function Gn(e){return e==null?"":e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:`${e}`}function wi(e){return e==null?"":`$${e.toFixed(4)}`}function kw(e){return e==null?"":typeof e=="string"?e:JSON.stringify(e,null,2)}function $N(e,t){if(t<=0)return`${e.toLocaleString()} tokens (limit unknown)`;const n=a=>a.toLocaleString(),l=(e/t*100).toFixed(1);return`${n(e)} / ${n(t)} (${l}%)`}function Ew(){const e=se(c=>c.workflowStatus),t=se(c=>c.workflowStartTime),n=se(c=>c.replayMode),l=se(c=>c.lastEventTime),[a,o]=I.useState("—"),s=I.useRef(null);return I.useEffect(()=>{if(t!=null){if(n){s.current&&(clearInterval(s.current),s.current=null),o(ot((l??t)-t));return}if(e==="running"){const c=()=>{const h=Date.now()/1e3-t;o(ot(h))};return c(),s.current=setInterval(c,500),()=>{s.current&&clearInterval(s.current)}}else(e==="completed"||e==="failed")&&s.current&&(clearInterval(s.current),s.current=null)}},[e,t,n,l]),a}function UN(){const e=se(_=>_.workflowStatus),t=se(_=>_.agentsCompleted),n=se(_=>_.agentsTotal),l=se(_=>_.totalCost),a=se(_=>_.totalTokens),o=se(_=>_.wsStatus),s=se(_=>_.workflowFailure),c=se(_=>_.lastEventTime),h=se(_=>_.iterationLimitGate),f=Ew(),[m,p]=I.useState(null);I.useEffect(()=>{if(e!=="running"||c==null){p(null);return}const _=()=>{p(Math.floor(Date.now()/1e3-c))};_();const N=setInterval(_,1e3);return()=>clearInterval(N)},[e,c]);const g=e==="failed",b=(()=>{if(h&&e==="running"){const _=h.agent_name??h.group_name??"workflow",N=h.skip_gates?" — auto-stopping":" — awaiting decision";return`Iteration limit reached: ${_} ${h.current_iteration}/${h.max_iterations}${N}`}switch(e){case"pending":return"Waiting for workflow…";case"running":return"Running";case"completed":return"Completed";case"failed":{if(!s)return"Failed";const _=s.error_type||"";return _==="MaxIterationsError"?"Failed: exceeded maximum iterations":_==="TimeoutError"?"Failed: workflow timed out":s.message?`Failed: ${s.message.length>60?s.message.slice(0,57)+"...":s.message}`:`Failed: ${_}`}}})(),w=h!=null&&e==="running",E=w?"bg-[var(--waiting)] animate-pulse":{pending:"bg-[var(--pending)]",running:"bg-[var(--running)] animate-pulse",completed:"bg-[var(--completed)]",failed:"bg-[var(--failed)]"}[e],S=(()=>{switch(o){case"connected":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--completed)]",children:[y.jsx(jN,{className:"w-3 h-3"}),y.jsx("span",{children:"Connected"})]});case"disconnected":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--failed)]",children:[y.jsx(CN,{className:"w-3 h-3"}),y.jsx("span",{children:"Disconnected"})]});case"reconnecting":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--waiting)]",children:[y.jsx(ha,{className:"w-3 h-3 animate-spin"}),y.jsx("span",{children:"Reconnecting\\u2026"})]});case"connecting":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--text-muted)]",children:[y.jsx(ha,{className:"w-3 h-3 animate-spin"}),y.jsx("span",{children:"Connecting\\u2026"})]})}})();return y.jsxs("footer",{className:je("flex items-center gap-4 px-4 py-1.5 border-t text-xs flex-shrink-0 transition-colors duration-300",g?"bg-red-950/50 border-red-500/30":w?"bg-amber-950/30 border-amber-500/30":"bg-[var(--surface)] border-[var(--border)]"),children:[y.jsx("span",{className:je("w-2 h-2 rounded-full flex-shrink-0",E)}),y.jsx("span",{className:je(g?"text-red-300":w?"text-amber-200":"text-[var(--text)]"),children:b}),n>0&&y.jsxs("span",{className:je(g?"text-red-400/60":"text-[var(--text-muted)]"),children:[t,"/",n," agents"]}),e!=="pending"&&y.jsx("span",{className:je("font-mono",g?"text-red-400/60":"text-[var(--text-muted)]"),children:f}),a>0&&y.jsxs("span",{className:je("flex items-center gap-1",g?"text-red-400/60":"text-[var(--text-muted)]"),title:"Total tokens used",children:[y.jsx(ww,{className:"w-3 h-3"}),y.jsx("span",{className:"font-mono",children:a.toLocaleString()})]}),l>0&&y.jsxs("span",{className:je("flex items-center gap-1",g?"text-red-400/60":"text-[var(--text-muted)]"),title:"Total cost",children:[y.jsx(yw,{className:"w-3 h-3"}),y.jsxs("span",{className:"font-mono",children:["$",l.toFixed(4)]})]}),m!=null&&m>=5&&y.jsxs("span",{className:je("flex items-center gap-1 font-mono",m>=60?"text-amber-400":"text-[var(--text-muted)]"),title:"Time since last event from the provider",children:[y.jsx(xw,{className:"w-3 h-3"}),y.jsx("span",{children:m>=60?`${Math.floor(m/60)}m ${m%60}s idle`:`${m}s idle`})]}),y.jsx("span",{className:"flex-1"}),S]})}const VN=[1,5,10,20,50];function PN(e,t){if(t===0||e.length===0)return"+0.0s";const n=e[0].timestamp,a=e[Math.min(t,e.length)-1].timestamp-n;if(a<60)return`+${a.toFixed(1)}s`;const o=Math.floor(a/60),s=a%60;return`+${o}m${s.toFixed(0)}s`}function GN(){const e=se(p=>p.replayPosition),t=se(p=>p.replayTotalEvents),n=se(p=>p.replayPlaying),l=se(p=>p.replaySpeed),a=se(p=>p.replayEvents),o=se(p=>p.setReplayPosition),s=se(p=>p.setReplayPlaying),c=se(p=>p.setReplaySpeed),h=p=>{const g=parseInt(p.target.value,10);o(g),n&&s(!1)},f=()=>{!n&&e>=t&&o(0),s(!n)},m=t>0?e/t*100:0;return y.jsxs("footer",{className:"flex items-center gap-3 px-4 py-1.5 border-t bg-[var(--surface)] border-[var(--border)] text-xs flex-shrink-0",children:[y.jsx("button",{onClick:f,className:"flex items-center justify-center w-6 h-6 rounded hover:bg-[var(--surface-hover)] text-[var(--text-secondary)] hover:text-[var(--text)] transition-colors",title:n?"Pause":"Play",children:n?y.jsx(wN,{className:"w-3.5 h-3.5"}):y.jsx(Ec,{className:"w-3.5 h-3.5"})}),y.jsxs("div",{className:"flex-1 relative flex items-center",children:[y.jsx("input",{type:"range",min:0,max:t,value:e,onChange:h,className:"w-full h-1 appearance-none rounded-full cursor-pointer",style:{background:`linear-gradient(to right, var(--accent) 0%, var(--accent) ${m}%, var(--border) ${m}%, var(--border) 100%)`,WebkitAppearance:"none"}}),y.jsx("style",{children:` footer input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; @@ -300,7 +305,7 @@ Error generating stack: `+d.message+` cursor: pointer; box-shadow: 0 0 4px rgba(99, 102, 241, 0.4); } - `})]}),y.jsx("span",{className:"text-[var(--text-muted)] font-mono whitespace-nowrap",children:VN(a,e)}),y.jsxs("span",{className:"text-[var(--text-muted)] font-mono whitespace-nowrap",children:["Event ",e,"/",t]}),y.jsx("div",{className:"flex items-center gap-0.5",children:UN.map(p=>y.jsxs("button",{onClick:()=>c(p),className:Ae("px-1.5 py-0.5 rounded text-xs font-mono transition-colors",l===p?"bg-[var(--accent)] text-white":"text-[var(--text-muted)] hover:text-[var(--text-secondary)] hover:bg-[var(--surface-hover)]"),children:[p,"×"]},p))})]})}const Nc=I.createContext(null);Nc.displayName="PanelGroupContext";const vt={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},vm=10,Ji=I.useLayoutEffect,lv=JE.useId,GN=typeof lv=="function"?lv:()=>null;let FN=0;function bm(e=null){const t=GN(),n=I.useRef(e||t||null);return n.current===null&&(n.current=""+FN++),e??n.current}function Nw({children:e,className:t="",collapsedSize:n,collapsible:l,defaultSize:a,forwardedRef:o,id:s,maxSize:c,minSize:h,onCollapse:f,onExpand:m,onResize:p,order:g,style:b,tagName:w="div",...E}){const S=I.useContext(Nc);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:_,expandPanel:N,getPanelSize:k,getPanelStyle:T,groupId:M,isPanelCollapsed:A,reevaluatePanelConstraints:L,registerPanel:R,resizePanel:V,unregisterPanel:H}=S,B=bm(s),U=I.useRef({callbacks:{onCollapse:f,onExpand:m,onResize:p},constraints:{collapsedSize:n,collapsible:l,defaultSize:a,maxSize:c,minSize:h},id:B,idIsFromProps:s!==void 0,order:g});I.useRef({didLogMissingDefaultSizeWarning:!1}),Ji(()=>{const{callbacks:q,constraints:F}=U.current,z={...F};U.current.id=B,U.current.idIsFromProps=s!==void 0,U.current.order=g,q.onCollapse=f,q.onExpand=m,q.onResize=p,F.collapsedSize=n,F.collapsible=l,F.defaultSize=a,F.maxSize=c,F.minSize=h,(z.collapsedSize!==F.collapsedSize||z.collapsible!==F.collapsible||z.maxSize!==F.maxSize||z.minSize!==F.minSize)&&L(U.current,z)}),Ji(()=>{const q=U.current;return R(q),()=>{H(q)}},[g,B,R,H]),I.useImperativeHandle(o,()=>({collapse:()=>{_(U.current)},expand:q=>{N(U.current,q)},getId(){return B},getSize(){return k(U.current)},isCollapsed(){return A(U.current)},isExpanded(){return!A(U.current)},resize:q=>{V(U.current,q)}}),[_,N,k,A,B,V]);const ee=T(U.current,a);return I.createElement(w,{...E,children:e,className:t,id:B,style:{...ee,...b},[vt.groupId]:M,[vt.panel]:"",[vt.panelCollapsible]:l||void 0,[vt.panelId]:B,[vt.panelSize]:parseFloat(""+ee.flexGrow).toFixed(1)})}const Co=I.forwardRef((e,t)=>I.createElement(Nw,{...e,forwardedRef:t}));Nw.displayName="Panel";Co.displayName="forwardRef(Panel)";let Vp=null,Ku=-1,vi=null;function YN(e,t){if(t){const n=(t&zw)!==0,l=(t&Mw)!==0,a=(t&Dw)!==0,o=(t&Rw)!==0;if(n)return a?"se-resize":o?"ne-resize":"e-resize";if(l)return a?"sw-resize":o?"nw-resize":"w-resize";if(a)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function XN(){vi!==null&&(document.head.removeChild(vi),Vp=null,vi=null,Ku=-1)}function hh(e,t){var n,l;const a=YN(e,t);if(Vp!==a){if(Vp=a,vi===null&&(vi=document.createElement("style"),document.head.appendChild(vi)),Ku>=0){var o;(o=vi.sheet)===null||o===void 0||o.removeRule(Ku)}Ku=(n=(l=vi.sheet)===null||l===void 0?void 0:l.insertRule(`*{cursor: ${a} !important;}`))!==null&&n!==void 0?n:-1}}function Cw(e){return e.type==="keydown"}function jw(e){return e.type.startsWith("pointer")}function Tw(e){return e.type.startsWith("mouse")}function Cc(e){if(jw(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Tw(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function QN(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function ZN(e,t,n){return e.xt.x&&e.yt.y}function KN(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:sv(e),b:sv(t)};let l;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),l=e;Be(l,"Stacking order can only be calculated for elements with a common ancestor");const a={a:ov(av(n.a)),b:ov(av(n.b))};if(a.a===a.b){const o=l.childNodes,s={a:n.a.at(-1),b:n.b.at(-1)};let c=o.length;for(;c--;){const h=o[c];if(h===s.a)return 1;if(h===s.b)return-1}}return Math.sign(a.a-a.b)}const JN=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function WN(e){var t;const n=getComputedStyle((t=Aw(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function eC(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||WN(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||JN.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function av(e){let t=e.length;for(;t--;){const n=e[t];if(Be(n,"Missing node"),eC(n))return n}return null}function ov(e){return e&&Number(getComputedStyle(e).zIndex)||0}function sv(e){const t=[];for(;e;)t.push(e),e=Aw(e);return t}function Aw(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const zw=1,Mw=2,Dw=4,Rw=8,tC=QN()==="coarse";let Gn=[],sa=!1,Qi=new Map,jc=new Map;const Bo=new Set;function nC(e,t,n,l,a){var o;const{ownerDocument:s}=t,c={direction:n,element:t,hitAreaMargins:l,setResizeHandlerState:a},h=(o=Qi.get(s))!==null&&o!==void 0?o:0;return Qi.set(s,h+1),Bo.add(c),ac(),function(){var m;jc.delete(e),Bo.delete(c);const p=(m=Qi.get(s))!==null&&m!==void 0?m:1;if(Qi.set(s,p-1),ac(),p===1&&Qi.delete(s),Gn.includes(c)){const g=Gn.indexOf(c);g>=0&&Gn.splice(g,1),_m(),a("up",!0,null)}}}function rC(e){const{target:t}=e,{x:n,y:l}=Cc(e);sa=!0,wm({target:t,x:n,y:l}),ac(),Gn.length>0&&(oc("down",e),e.preventDefault(),Ow(t)||e.stopImmediatePropagation())}function ph(e){const{x:t,y:n}=Cc(e);if(sa&&e.buttons===0&&(sa=!1,oc("up",e)),!sa){const{target:l}=e;wm({target:l,x:t,y:n})}oc("move",e),_m(),Gn.length>0&&e.preventDefault()}function mh(e){const{target:t}=e,{x:n,y:l}=Cc(e);jc.clear(),sa=!1,Gn.length>0&&(e.preventDefault(),Ow(t)||e.stopImmediatePropagation()),oc("up",e),wm({target:t,x:n,y:l}),_m(),ac()}function Ow(e){let t=e;for(;t;){if(t.hasAttribute(vt.resizeHandle))return!0;t=t.parentElement}return!1}function wm({target:e,x:t,y:n}){Gn.splice(0);let l=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(l=e),Bo.forEach(a=>{const{element:o,hitAreaMargins:s}=a,c=o.getBoundingClientRect(),{bottom:h,left:f,right:m,top:p}=c,g=tC?s.coarse:s.fine;if(t>=f-g&&t<=m+g&&n>=p-g&&n<=h+g){if(l!==null&&document.contains(l)&&o!==l&&!o.contains(l)&&!l.contains(o)&&KN(l,o)>0){let w=l,E=!1;for(;w&&!w.contains(o);){if(ZN(w.getBoundingClientRect(),c)){E=!0;break}w=w.parentElement}if(E)return}Gn.push(a)}})}function gh(e,t){jc.set(e,t)}function _m(){let e=!1,t=!1;Gn.forEach(l=>{const{direction:a}=l;a==="horizontal"?e=!0:t=!0});let n=0;jc.forEach(l=>{n|=l}),e&&t?hh("intersection",n):e?hh("horizontal",n):t?hh("vertical",n):XN()}let xh=new AbortController;function ac(){xh.abort(),xh=new AbortController;const e={capture:!0,signal:xh.signal};Bo.size&&(sa?(Gn.length>0&&Qi.forEach((t,n)=>{const{body:l}=n;t>0&&(l.addEventListener("contextmenu",mh,e),l.addEventListener("pointerleave",ph,e),l.addEventListener("pointermove",ph,e))}),window.addEventListener("pointerup",mh,e),window.addEventListener("pointercancel",mh,e)):Qi.forEach((t,n)=>{const{body:l}=n;t>0&&(l.addEventListener("pointerdown",rC,e),l.addEventListener("pointermove",ph,e))}))}function oc(e,t){Bo.forEach(n=>{const{setResizeHandlerState:l}=n,a=Gn.includes(n);l(e,a,t)})}function iC(){const[e,t]=I.useState(0);return I.useCallback(()=>t(n=>n+1),[])}function Be(e,t){if(!e)throw console.error(t),Error(t)}function tl(e,t,n=vm){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Mr(e,t,n=vm){return tl(e,t,n)===0}function bn(e,t,n){return tl(e,t,n)===0}function lC(e,t,n){if(e.length!==t.length)return!1;for(let l=0;l0&&(e=e<0?0-_:_)}}}{const p=e<0?c:h,g=n[p];Be(g,`No panel constraints found for index ${p}`);const{collapsedSize:b=0,collapsible:w,minSize:E=0}=g;if(w){const S=t[p];if(Be(S!=null,`Previous layout not found for panel index ${p}`),bn(S,E)){const _=S-b;tl(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}}{const p=e<0?1:-1;let g=e<0?h:c,b=0;for(;;){const E=t[g];Be(E!=null,`Previous layout not found for panel index ${g}`);const _=ia({panelConstraints:n,panelIndex:g,size:100})-E;if(b+=_,g+=p,g<0||g>=n.length)break}const w=Math.min(Math.abs(e),Math.abs(b));e=e<0?0-w:w}{let g=e<0?c:h;for(;g>=0&&g=0))break;e<0?g--:g++}}if(lC(a,s))return a;{const p=e<0?h:c,g=t[p];Be(g!=null,`Previous layout not found for panel index ${p}`);const b=g+f,w=ia({panelConstraints:n,panelIndex:p,size:b});if(s[p]=w,!bn(w,b)){let E=b-w,_=e<0?h:c;for(;_>=0&&_0?_--:_++}}}const m=s.reduce((p,g)=>g+p,0);return bn(m,100)?s:a}function aC({layout:e,panelsArray:t,pivotIndices:n}){let l=0,a=100,o=0,s=0;const c=n[0];Be(c!=null,"No pivot index found"),t.forEach((p,g)=>{const{constraints:b}=p,{maxSize:w=100,minSize:E=0}=b;g===c?(l=E,a=w):(o+=E,s+=w)});const h=Math.min(a,100-o),f=Math.max(l,100-s),m=e[c];return{valueMax:h,valueMin:f,valueNow:m}}function Io(e,t=document){return Array.from(t.querySelectorAll(`[${vt.resizeHandleId}][data-panel-group-id="${e}"]`))}function Lw(e,t,n=document){const a=Io(e,n).findIndex(o=>o.getAttribute(vt.resizeHandleId)===t);return a??null}function Hw(e,t,n){const l=Lw(e,t,n);return l!=null?[l,l+1]:[-1,-1]}function Bw(e,t=document){var n;if(t instanceof HTMLElement&&(t==null||(n=t.dataset)===null||n===void 0?void 0:n.panelGroupId)==e)return t;const l=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return l||null}function Tc(e,t=document){const n=t.querySelector(`[${vt.resizeHandleId}="${e}"]`);return n||null}function oC(e,t,n,l=document){var a,o,s,c;const h=Tc(t,l),f=Io(e,l),m=h?f.indexOf(h):-1,p=(a=(o=n[m])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null,g=(s=(c=n[m+1])===null||c===void 0?void 0:c.id)!==null&&s!==void 0?s:null;return[p,g]}function sC({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:l,panelDataArray:a,panelGroupElement:o,setLayout:s}){I.useRef({didWarnAboutMissingResizeHandle:!1}),Ji(()=>{if(!o)return;const c=Io(n,o);for(let h=0;h{c.forEach((h,f)=>{h.removeAttribute("aria-controls"),h.removeAttribute("aria-valuemax"),h.removeAttribute("aria-valuemin"),h.removeAttribute("aria-valuenow")})}},[n,l,a,o]),I.useEffect(()=>{if(!o)return;const c=t.current;Be(c,"Eager values not found");const{panelDataArray:h}=c,f=Bw(n,o);Be(f!=null,`No group found for id "${n}"`);const m=Io(n,o);Be(m,`No resize handles found for group id "${n}"`);const p=m.map(g=>{const b=g.getAttribute(vt.resizeHandleId);Be(b,"Resize handle element has no handle id attribute");const[w,E]=oC(n,b,h,o);if(w==null||E==null)return()=>{};const S=_=>{if(!_.defaultPrevented)switch(_.key){case"Enter":{_.preventDefault();const N=h.findIndex(k=>k.id===w);if(N>=0){const k=h[N];Be(k,`No panel data found for index ${N}`);const T=l[N],{collapsedSize:M=0,collapsible:A,minSize:L=0}=k.constraints;if(T!=null&&A){const R=jo({delta:bn(T,M)?L-M:M-T,initialLayout:l,panelConstraints:h.map(V=>V.constraints),pivotIndices:Hw(n,b,o),prevLayout:l,trigger:"keyboard"});l!==R&&s(R)}}break}}};return g.addEventListener("keydown",S),()=>{g.removeEventListener("keydown",S)}});return()=>{p.forEach(g=>g())}},[o,e,t,n,l,a,s])}function uv(e,t){if(e.length!==t.length)return!1;for(let n=0;no.constraints);let l=0,a=100;for(let o=0;o{const o=e[a];Be(o,`Panel data not found for index ${a}`);const{callbacks:s,constraints:c,id:h}=o,{collapsedSize:f=0,collapsible:m}=c,p=n[h];if(p==null||l!==p){n[h]=l;const{onCollapse:g,onExpand:b,onResize:w}=s;w&&w(l,p),m&&(g||b)&&(b&&(p==null||Mr(p,f))&&!Mr(l,f)&&b(),g&&(p==null||!Mr(p,f))&&Mr(l,f)&&g())}})}function Hu(e,t){if(e.length!==t.length)return!1;for(let n=0;n{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...a)},t)}}function cv(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function qw(e){return`react-resizable-panels:${e}`}function $w(e){return e.map(t=>{const{constraints:n,id:l,idIsFromProps:a,order:o}=t;return a?l:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function Uw(e,t){try{const n=qw(e),l=t.getItem(n);if(l){const a=JSON.parse(l);if(typeof a=="object"&&a!=null)return a}}catch{}return null}function pC(e,t,n){var l,a;const o=(l=Uw(e,n))!==null&&l!==void 0?l:{},s=$w(t);return(a=o[s])!==null&&a!==void 0?a:null}function mC(e,t,n,l,a){var o;const s=qw(e),c=$w(t),h=(o=Uw(e,a))!==null&&o!==void 0?o:{};h[c]={expandToSizes:Object.fromEntries(n.entries()),layout:l};try{a.setItem(s,JSON.stringify(h))}catch(f){console.error(f)}}function fv({layout:e,panelConstraints:t}){const n=[...e],l=n.reduce((o,s)=>o+s,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!bn(l,100)&&n.length>0)for(let o=0;o(cv(To),To.getItem(e)),setItem:(e,t)=>{cv(To),To.setItem(e,t)}},dv={};function Vw({autoSaveId:e=null,children:t,className:n="",direction:l,forwardedRef:a,id:o=null,onLayout:s=null,keyboardResizeBy:c=null,storage:h=To,style:f,tagName:m="div",...p}){const g=bm(o),b=I.useRef(null),[w,E]=I.useState(null),[S,_]=I.useState([]),N=iC(),k=I.useRef({}),T=I.useRef(new Map),M=I.useRef(0),A=I.useRef({autoSaveId:e,direction:l,dragState:w,id:g,keyboardResizeBy:c,onLayout:s,storage:h}),L=I.useRef({layout:S,panelDataArray:[],panelDataArrayChanged:!1});I.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),I.useImperativeHandle(a,()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:C}=L.current;return C},setLayout:C=>{const{onLayout:P}=A.current,{layout:X,panelDataArray:J}=L.current,ne=fv({layout:C,panelConstraints:J.map(re=>re.constraints)});uv(X,ne)||(_(ne),L.current.layout=ne,P&&P(ne),Kl(J,ne,k.current))}}),[]),Ji(()=>{A.current.autoSaveId=e,A.current.direction=l,A.current.dragState=w,A.current.id=g,A.current.onLayout=s,A.current.storage=h}),sC({committedValuesRef:A,eagerValuesRef:L,groupId:g,layout:S,panelDataArray:L.current.panelDataArray,setLayout:_,panelGroupElement:b.current}),I.useEffect(()=>{const{panelDataArray:C}=L.current;if(e){if(S.length===0||S.length!==C.length)return;let P=dv[e];P==null&&(P=hC(mC,gC),dv[e]=P);const X=[...C],J=new Map(T.current);P(e,X,J,S,h)}},[e,S,h]),I.useEffect(()=>{});const R=I.useCallback(C=>{const{onLayout:P}=A.current,{layout:X,panelDataArray:J}=L.current;if(C.constraints.collapsible){const ne=J.map(be=>be.constraints),{collapsedSize:re=0,panelSize:ue,pivotIndices:xe}=Gi(J,C,X);if(Be(ue!=null,`Panel size not found for panel "${C.id}"`),!Mr(ue,re)){T.current.set(C.id,ue);const ye=ta(J,C)===J.length-1?ue-re:re-ue,pe=jo({delta:ye,initialLayout:X,panelConstraints:ne,pivotIndices:xe,prevLayout:X,trigger:"imperative-api"});Hu(X,pe)||(_(pe),L.current.layout=pe,P&&P(pe),Kl(J,pe,k.current))}}},[]),V=I.useCallback((C,P)=>{const{onLayout:X}=A.current,{layout:J,panelDataArray:ne}=L.current;if(C.constraints.collapsible){const re=ne.map(Se=>Se.constraints),{collapsedSize:ue=0,panelSize:xe=0,minSize:be=0,pivotIndices:ye}=Gi(ne,C,J),pe=P??be;if(Mr(xe,ue)){const Se=T.current.get(C.id),Oe=Se!=null&&Se>=pe?Se:pe,ft=ta(ne,C)===ne.length-1?xe-Oe:Oe-xe,rt=jo({delta:ft,initialLayout:J,panelConstraints:re,pivotIndices:ye,prevLayout:J,trigger:"imperative-api"});Hu(J,rt)||(_(rt),L.current.layout=rt,X&&X(rt),Kl(ne,rt,k.current))}}},[]),H=I.useCallback(C=>{const{layout:P,panelDataArray:X}=L.current,{panelSize:J}=Gi(X,C,P);return Be(J!=null,`Panel size not found for panel "${C.id}"`),J},[]),B=I.useCallback((C,P)=>{const{panelDataArray:X}=L.current,J=ta(X,C);return dC({defaultSize:P,dragState:w,layout:S,panelData:X,panelIndex:J})},[w,S]),U=I.useCallback(C=>{const{layout:P,panelDataArray:X}=L.current,{collapsedSize:J=0,collapsible:ne,panelSize:re}=Gi(X,C,P);return Be(re!=null,`Panel size not found for panel "${C.id}"`),ne===!0&&Mr(re,J)},[]),ee=I.useCallback(C=>{const{layout:P,panelDataArray:X}=L.current,{collapsedSize:J=0,collapsible:ne,panelSize:re}=Gi(X,C,P);return Be(re!=null,`Panel size not found for panel "${C.id}"`),!ne||tl(re,J)>0},[]),q=I.useCallback(C=>{const{panelDataArray:P}=L.current;P.push(C),P.sort((X,J)=>{const ne=X.order,re=J.order;return ne==null&&re==null?0:ne==null?-1:re==null?1:ne-re}),L.current.panelDataArrayChanged=!0,N()},[N]);Ji(()=>{if(L.current.panelDataArrayChanged){L.current.panelDataArrayChanged=!1;const{autoSaveId:C,onLayout:P,storage:X}=A.current,{layout:J,panelDataArray:ne}=L.current;let re=null;if(C){const xe=pC(C,ne,X);xe&&(T.current=new Map(Object.entries(xe.expandToSizes)),re=xe.layout)}re==null&&(re=fC({panelDataArray:ne}));const ue=fv({layout:re,panelConstraints:ne.map(xe=>xe.constraints)});uv(J,ue)||(_(ue),L.current.layout=ue,P&&P(ue),Kl(ne,ue,k.current))}}),Ji(()=>{const C=L.current;return()=>{C.layout=[]}},[]);const F=I.useCallback(C=>{let P=!1;const X=b.current;return X&&window.getComputedStyle(X,null).getPropertyValue("direction")==="rtl"&&(P=!0),function(ne){ne.preventDefault();const re=b.current;if(!re)return()=>null;const{direction:ue,dragState:xe,id:be,keyboardResizeBy:ye,onLayout:pe}=A.current,{layout:Se,panelDataArray:Oe}=L.current,{initialLayout:je}=xe??{},ft=Hw(be,C,re);let rt=cC(ne,C,ue,xe,ye,re);const Dt=ue==="horizontal";Dt&&P&&(rt=-rt);const Pt=Oe.map(Rn=>Rn.constraints),Bt=jo({delta:rt,initialLayout:je??Se,panelConstraints:Pt,pivotIndices:ft,prevLayout:Se,trigger:Cw(ne)?"keyboard":"mouse-or-touch"}),kn=!Hu(Se,Bt);(jw(ne)||Tw(ne))&&M.current!=rt&&(M.current=rt,!kn&&rt!==0?Dt?gh(C,rt<0?zw:Mw):gh(C,rt<0?Dw:Rw):gh(C,0)),kn&&(_(Bt),L.current.layout=Bt,pe&&pe(Bt),Kl(Oe,Bt,k.current))}},[]),z=I.useCallback((C,P)=>{const{onLayout:X}=A.current,{layout:J,panelDataArray:ne}=L.current,re=ne.map(Se=>Se.constraints),{panelSize:ue,pivotIndices:xe}=Gi(ne,C,J);Be(ue!=null,`Panel size not found for panel "${C.id}"`);const ye=ta(ne,C)===ne.length-1?ue-P:P-ue,pe=jo({delta:ye,initialLayout:J,panelConstraints:re,pivotIndices:xe,prevLayout:J,trigger:"imperative-api"});Hu(J,pe)||(_(pe),L.current.layout=pe,X&&X(pe),Kl(ne,pe,k.current))},[]),G=I.useCallback((C,P)=>{const{layout:X,panelDataArray:J}=L.current,{collapsedSize:ne=0,collapsible:re}=P,{collapsedSize:ue=0,collapsible:xe,maxSize:be=100,minSize:ye=0}=C.constraints,{panelSize:pe}=Gi(J,C,X);pe!=null&&(re&&xe&&Mr(pe,ne)?Mr(ne,ue)||z(C,ue):pebe&&z(C,be))},[z]),Q=I.useCallback((C,P)=>{const{direction:X}=A.current,{layout:J}=L.current;if(!b.current)return;const ne=Tc(C,b.current);Be(ne,`Drag handle element not found for id "${C}"`);const re=Iw(X,P);E({dragHandleId:C,dragHandleRect:ne.getBoundingClientRect(),initialCursorPosition:re,initialLayout:J})},[]),K=I.useCallback(()=>{E(null)},[]),D=I.useCallback(C=>{const{panelDataArray:P}=L.current,X=ta(P,C);X>=0&&(P.splice(X,1),delete k.current[C.id],L.current.panelDataArrayChanged=!0,N())},[N]),$=I.useMemo(()=>({collapsePanel:R,direction:l,dragState:w,expandPanel:V,getPanelSize:H,getPanelStyle:B,groupId:g,isPanelCollapsed:U,isPanelExpanded:ee,reevaluatePanelConstraints:G,registerPanel:q,registerResizeHandle:F,resizePanel:z,startDragging:Q,stopDragging:K,unregisterPanel:D,panelGroupElement:b.current}),[R,w,l,V,H,B,g,U,ee,G,q,F,z,Q,K,D]),Y={display:"flex",flexDirection:l==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return I.createElement(Nc.Provider,{value:$},I.createElement(m,{...p,children:t,className:n,id:o,ref:b,style:{...Y,...f},[vt.group]:"",[vt.groupDirection]:l,[vt.groupId]:g}))}const Pp=I.forwardRef((e,t)=>I.createElement(Vw,{...e,forwardedRef:t}));Vw.displayName="PanelGroup";Pp.displayName="forwardRef(PanelGroup)";function ta(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Gi(e,t,n){const l=ta(e,t),o=l===e.length-1?[l-1,l]:[l,l+1],s=n[l];return{...t.constraints,panelSize:s,pivotIndices:o}}function xC({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:l}){I.useEffect(()=>{if(e||n==null||l==null)return;const a=Tc(t,l);if(a==null)return;const o=s=>{if(!s.defaultPrevented)switch(s.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{s.preventDefault(),n(s);break}case"F6":{s.preventDefault();const c=a.getAttribute(vt.groupId);Be(c,`No group element found for id "${c}"`);const h=Io(c,l),f=Lw(c,t,l);Be(f!==null,`No resize element found for id "${t}"`);const m=s.shiftKey?f>0?f-1:h.length-1:f+1{a.removeEventListener("keydown",o)}},[l,e,t,n])}function Gp({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:l,id:a,onBlur:o,onClick:s,onDragging:c,onFocus:h,onPointerDown:f,onPointerUp:m,style:p={},tabIndex:g=0,tagName:b="div",...w}){var E,S;const _=I.useRef(null),N=I.useRef({onClick:s,onDragging:c,onPointerDown:f,onPointerUp:m});I.useEffect(()=>{N.current.onClick=s,N.current.onDragging=c,N.current.onPointerDown=f,N.current.onPointerUp=m});const k=I.useContext(Nc);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:T,groupId:M,registerResizeHandle:A,startDragging:L,stopDragging:R,panelGroupElement:V}=k,H=bm(a),[B,U]=I.useState("inactive"),[ee,q]=I.useState(!1),[F,z]=I.useState(null),G=I.useRef({state:B});Ji(()=>{G.current.state=B}),I.useEffect(()=>{if(n)z(null);else{const $=A(H);z(()=>$)}},[n,H,A]);const Q=(E=l==null?void 0:l.coarse)!==null&&E!==void 0?E:15,K=(S=l==null?void 0:l.fine)!==null&&S!==void 0?S:5;I.useEffect(()=>{if(n||F==null)return;const $=_.current;Be($,"Element ref not attached");let Y=!1;return nC(H,$,T,{coarse:Q,fine:K},(P,X,J)=>{if(!X){U("inactive");return}switch(P){case"down":{U("drag"),Y=!1,Be(J,'Expected event to be defined for "down" action'),L(H,J);const{onDragging:ne,onPointerDown:re}=N.current;ne==null||ne(!0),re==null||re();break}case"move":{const{state:ne}=G.current;Y=!0,ne!=="drag"&&U("hover"),Be(J,'Expected event to be defined for "move" action'),F(J);break}case"up":{U("hover"),R();const{onClick:ne,onDragging:re,onPointerUp:ue}=N.current;re==null||re(!1),ue==null||ue(),Y||ne==null||ne();break}}})},[Q,T,n,K,A,H,F,L,R]),xC({disabled:n,handleId:H,resizeHandler:F,panelGroupElement:V});const D={touchAction:"none",userSelect:"none"};return I.createElement(b,{...w,children:e,className:t,id:a,onBlur:()=>{q(!1),o==null||o()},onFocus:()=>{q(!0),h==null||h()},ref:_,role:"separator",style:{...D,...p},tabIndex:g,[vt.groupDirection]:T,[vt.groupId]:M,[vt.resizeHandle]:"",[vt.resizeHandleActive]:B==="drag"?"pointer":ee?"keyboard":void 0,[vt.resizeHandleEnabled]:!n,[vt.resizeHandleId]:H,[vt.resizeHandleState]:B})}Gp.displayName="PanelResizeHandle";function Mt(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,l;n{}};function Ac(){for(var e=0,t=arguments.length,n={},l;e=0&&(l=n.slice(a+1),n=n.slice(0,a)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:l}})}Ju.prototype=Ac.prototype={constructor:Ju,on:function(e,t){var n=this._,l=vC(e+"",n),a,o=-1,s=l.length;if(arguments.length<2){for(;++o0)for(var n=new Array(a),l=0,a,o;l=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),pv.hasOwnProperty(t)?{space:pv[t],local:e}:e}function wC(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Fp&&t.documentElement.namespaceURI===Fp?t.createElement(e):t.createElementNS(n,e)}}function _C(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Pw(e){var t=zc(e);return(t.local?_C:wC)(t)}function SC(){}function Sm(e){return e==null?SC:function(){return this.querySelector(e)}}function kC(e){typeof e!="function"&&(e=Sm(e));for(var t=this._groups,n=t.length,l=new Array(n),a=0;a=k&&(k=N+1);!(M=S[k])&&++k=0;)(s=l[a])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function QC(e){e||(e=ZC);function t(p,g){return p&&g?e(p.__data__,g.__data__):!p-!g}for(var n=this._groups,l=n.length,a=new Array(l),o=0;ot?1:e>=t?0:NaN}function KC(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function JC(){return Array.from(this)}function WC(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?c3:typeof t=="function"?d3:f3)(e,t,n??"")):ha(this.node(),e)}function ha(e,t){return e.style.getPropertyValue(t)||Qw(e).getComputedStyle(e,null).getPropertyValue(t)}function p3(e){return function(){delete this[e]}}function m3(e,t){return function(){this[e]=t}}function g3(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function x3(e,t){return arguments.length>1?this.each((t==null?p3:typeof t=="function"?g3:m3)(e,t)):this.node()[e]}function Zw(e){return e.trim().split(/^|\s+/)}function km(e){return e.classList||new Kw(e)}function Kw(e){this._node=e,this._names=Zw(e.getAttribute("class")||"")}Kw.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Jw(e,t){for(var n=km(e),l=-1,a=t.length;++l=0&&(n=t.slice(l+1),t=t.slice(0,l)),{type:t,name:n}})}function G3(e){return function(){var t=this.__on;if(t){for(var n=0,l=-1,a=t.length,o;n()=>e;function Yp(e,{sourceEvent:t,subject:n,target:l,identifier:a,active:o,x:s,y:c,dx:h,dy:f,dispatch:m}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:l,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:h,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:m}})}Yp.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function tj(e){return!e.ctrlKey&&!e.button}function nj(){return this.parentNode}function rj(e,t){return t??{x:e.x,y:e.y}}function ij(){return navigator.maxTouchPoints||"ontouchstart"in this}function i_(){var e=tj,t=nj,n=rj,l=ij,a={},o=Ac("start","drag","end"),s=0,c,h,f,m,p=0;function g(T){T.on("mousedown.drag",b).filter(l).on("touchstart.drag",S).on("touchmove.drag",_,ej).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(T,M){if(!(m||!e.call(this,T,M))){var A=k(this,t.call(this,T,M),T,M,"mouse");A&&(wn(T.view).on("mousemove.drag",w,qo).on("mouseup.drag",E,qo),n_(T.view),yh(T),f=!1,c=T.clientX,h=T.clientY,A("start",T))}}function w(T){if(ua(T),!f){var M=T.clientX-c,A=T.clientY-h;f=M*M+A*A>p}a.mouse("drag",T)}function E(T){wn(T.view).on("mousemove.drag mouseup.drag",null),r_(T.view,f),ua(T),a.mouse("end",T)}function S(T,M){if(e.call(this,T,M)){var A=T.changedTouches,L=t.call(this,T,M),R=A.length,V,H;for(V=0;V>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Iu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Iu(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=aj.exec(e))?new un(t[1],t[2],t[3],1):(t=oj.exec(e))?new un(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=sj.exec(e))?Iu(t[1],t[2],t[3],t[4]):(t=uj.exec(e))?Iu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=cj.exec(e))?wv(t[1],t[2]/100,t[3]/100,1):(t=fj.exec(e))?wv(t[1],t[2]/100,t[3]/100,t[4]):mv.hasOwnProperty(e)?yv(mv[e]):e==="transparent"?new un(NaN,NaN,NaN,0):null}function yv(e){return new un(e>>16&255,e>>8&255,e&255,1)}function Iu(e,t,n,l){return l<=0&&(e=t=n=NaN),new un(e,t,n,l)}function pj(e){return e instanceof es||(e=nl(e)),e?(e=e.rgb(),new un(e.r,e.g,e.b,e.opacity)):new un}function Xp(e,t,n,l){return arguments.length===1?pj(e):new un(e,t,n,l??1)}function un(e,t,n,l){this.r=+e,this.g=+t,this.b=+n,this.opacity=+l}Em(un,Xp,l_(es,{brighter(e){return e=e==null?uc:Math.pow(uc,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?$o:Math.pow($o,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new un(Wi(this.r),Wi(this.g),Wi(this.b),cc(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:vv,formatHex:vv,formatHex8:mj,formatRgb:bv,toString:bv}));function vv(){return`#${Zi(this.r)}${Zi(this.g)}${Zi(this.b)}`}function mj(){return`#${Zi(this.r)}${Zi(this.g)}${Zi(this.b)}${Zi((isNaN(this.opacity)?1:this.opacity)*255)}`}function bv(){const e=cc(this.opacity);return`${e===1?"rgb(":"rgba("}${Wi(this.r)}, ${Wi(this.g)}, ${Wi(this.b)}${e===1?")":`, ${e})`}`}function cc(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Wi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Zi(e){return e=Wi(e),(e<16?"0":"")+e.toString(16)}function wv(e,t,n,l){return l<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new $n(e,t,n,l)}function a_(e){if(e instanceof $n)return new $n(e.h,e.s,e.l,e.opacity);if(e instanceof es||(e=nl(e)),!e)return new $n;if(e instanceof $n)return e;e=e.rgb();var t=e.r/255,n=e.g/255,l=e.b/255,a=Math.min(t,n,l),o=Math.max(t,n,l),s=NaN,c=o-a,h=(o+a)/2;return c?(t===o?s=(n-l)/c+(n0&&h<1?0:s,new $n(s,c,h,e.opacity)}function gj(e,t,n,l){return arguments.length===1?a_(e):new $n(e,t,n,l??1)}function $n(e,t,n,l){this.h=+e,this.s=+t,this.l=+n,this.opacity=+l}Em($n,gj,l_(es,{brighter(e){return e=e==null?uc:Math.pow(uc,e),new $n(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?$o:Math.pow($o,e),new $n(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,l=n+(n<.5?n:1-n)*t,a=2*n-l;return new un(vh(e>=240?e-240:e+120,a,l),vh(e,a,l),vh(e<120?e+240:e-120,a,l),this.opacity)},clamp(){return new $n(_v(this.h),qu(this.s),qu(this.l),cc(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=cc(this.opacity);return`${e===1?"hsl(":"hsla("}${_v(this.h)}, ${qu(this.s)*100}%, ${qu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _v(e){return e=(e||0)%360,e<0?e+360:e}function qu(e){return Math.max(0,Math.min(1,e||0))}function vh(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Nm=e=>()=>e;function xj(e,t){return function(n){return e+n*t}}function yj(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(l){return Math.pow(e+l*t,n)}}function vj(e){return(e=+e)==1?o_:function(t,n){return n-t?yj(t,n,e):Nm(isNaN(t)?n:t)}}function o_(e,t){var n=t-e;return n?xj(e,n):Nm(isNaN(e)?t:e)}const fc=(function e(t){var n=vj(t);function l(a,o){var s=n((a=Xp(a)).r,(o=Xp(o)).r),c=n(a.g,o.g),h=n(a.b,o.b),f=o_(a.opacity,o.opacity);return function(m){return a.r=s(m),a.g=c(m),a.b=h(m),a.opacity=f(m),a+""}}return l.gamma=e,l})(1);function bj(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,l=t.slice(),a;return function(o){for(a=0;an&&(o=t.slice(n,o),c[s]?c[s]+=o:c[++s]=o),(l=l[0])===(a=a[0])?c[s]?c[s]+=a:c[++s]=a:(c[++s]=null,h.push({i:s,x:ir(l,a)})),n=bh.lastIndex;return n180?m+=360:m-f>180&&(f+=360),g.push({i:p.push(a(p)+"rotate(",null,l)-2,x:ir(f,m)})):m&&p.push(a(p)+"rotate("+m+l)}function c(f,m,p,g){f!==m?g.push({i:p.push(a(p)+"skewX(",null,l)-2,x:ir(f,m)}):m&&p.push(a(p)+"skewX("+m+l)}function h(f,m,p,g,b,w){if(f!==p||m!==g){var E=b.push(a(b)+"scale(",null,",",null,")");w.push({i:E-4,x:ir(f,p)},{i:E-2,x:ir(m,g)})}else(p!==1||g!==1)&&b.push(a(b)+"scale("+p+","+g+")")}return function(f,m){var p=[],g=[];return f=e(f),m=e(m),o(f.translateX,f.translateY,m.translateX,m.translateY,p,g),s(f.rotate,m.rotate,p,g),c(f.skewX,m.skewX,p,g),h(f.scaleX,f.scaleY,m.scaleX,m.scaleY,p,g),f=m=null,function(b){for(var w=-1,E=g.length,S;++w=0&&e._call.call(void 0,t),e=e._next;--pa}function Ev(){rl=(hc=Vo.now())+Mc,pa=Ao=0;try{Oj()}finally{pa=0,Hj(),rl=0}}function Lj(){var e=Vo.now(),t=e-hc;t>f_&&(Mc-=t,hc=e)}function Hj(){for(var e,t=dc,n,l=1/0;t;)t._call?(l>t._time&&(l=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:dc=n);zo=e,Kp(l)}function Kp(e){if(!pa){Ao&&(Ao=clearTimeout(Ao));var t=e-rl;t>24?(e<1/0&&(Ao=setTimeout(Ev,e-Vo.now()-Mc)),wo&&(wo=clearInterval(wo))):(wo||(hc=Vo.now(),wo=setInterval(Lj,f_)),pa=1,d_(Ev))}}function Nv(e,t,n){var l=new pc;return t=t==null?0:+t,l.restart(a=>{l.stop(),e(a+t)},t,n),l}var Bj=Ac("start","end","cancel","interrupt"),Ij=[],p_=0,Cv=1,Jp=2,ec=3,jv=4,Wp=5,tc=6;function Dc(e,t,n,l,a,o){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;qj(e,n,{name:t,index:l,group:a,on:Bj,tween:Ij,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:p_})}function jm(e,t){var n=Xn(e,t);if(n.state>p_)throw new Error("too late; already scheduled");return n}function or(e,t){var n=Xn(e,t);if(n.state>ec)throw new Error("too late; already running");return n}function Xn(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function qj(e,t,n){var l=e.__transition,a;l[t]=n,n.timer=h_(o,0,n.time);function o(f){n.state=Cv,n.timer.restart(s,n.delay,n.time),n.delay<=f&&s(f-n.delay)}function s(f){var m,p,g,b;if(n.state!==Cv)return h();for(m in l)if(b=l[m],b.name===n.name){if(b.state===ec)return Nv(s);b.state===jv?(b.state=tc,b.timer.stop(),b.on.call("interrupt",e,e.__data__,b.index,b.group),delete l[m]):+mJp&&l.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function gT(e,t,n){var l,a,o=mT(t)?jm:or;return function(){var s=o(this,e),c=s.on;c!==l&&(a=(l=c).copy()).on(t,n),s.on=a}}function xT(e,t){var n=this._id;return arguments.length<2?Xn(this.node(),n).on.on(e):this.each(gT(n,e,t))}function yT(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function vT(){return this.on("end.remove",yT(this._id))}function bT(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Sm(e));for(var l=this._groups,a=l.length,o=new Array(a),s=0;s()=>e;function GT(e,{sourceEvent:t,target:n,transform:l,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:a}})}function Dr(e,t,n){this.k=e,this.x=t,this.y=n}Dr.prototype={constructor:Dr,scale:function(e){return e===1?this:new Dr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Dr(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Rc=new Dr(1,0,0);y_.prototype=Dr.prototype;function y_(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Rc;return e.__zoom}function wh(e){e.stopImmediatePropagation()}function _o(e){e.preventDefault(),e.stopImmediatePropagation()}function FT(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function YT(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Tv(){return this.__zoom||Rc}function XT(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function QT(){return navigator.maxTouchPoints||"ontouchstart"in this}function ZT(e,t,n){var l=e.invertX(t[0][0])-n[0][0],a=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(a>l?(l+a)/2:Math.min(0,l)||Math.max(0,a),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}function v_(){var e=FT,t=YT,n=ZT,l=XT,a=QT,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],c=250,h=Wu,f=Ac("start","zoom","end"),m,p,g,b=500,w=150,E=0,S=10;function _(q){q.property("__zoom",Tv).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",V).on("dblclick.zoom",H).filter(a).on("touchstart.zoom",B).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",ee).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(q,F,z,G){var Q=q.selection?q.selection():q;Q.property("__zoom",Tv),q!==Q?M(q,F,z,G):Q.interrupt().each(function(){A(this,arguments).event(G).start().zoom(null,typeof F=="function"?F.apply(this,arguments):F).end()})},_.scaleBy=function(q,F,z,G){_.scaleTo(q,function(){var Q=this.__zoom.k,K=typeof F=="function"?F.apply(this,arguments):F;return Q*K},z,G)},_.scaleTo=function(q,F,z,G){_.transform(q,function(){var Q=t.apply(this,arguments),K=this.__zoom,D=z==null?T(Q):typeof z=="function"?z.apply(this,arguments):z,$=K.invert(D),Y=typeof F=="function"?F.apply(this,arguments):F;return n(k(N(K,Y),D,$),Q,s)},z,G)},_.translateBy=function(q,F,z,G){_.transform(q,function(){return n(this.__zoom.translate(typeof F=="function"?F.apply(this,arguments):F,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),s)},null,G)},_.translateTo=function(q,F,z,G,Q){_.transform(q,function(){var K=t.apply(this,arguments),D=this.__zoom,$=G==null?T(K):typeof G=="function"?G.apply(this,arguments):G;return n(Rc.translate($[0],$[1]).scale(D.k).translate(typeof F=="function"?-F.apply(this,arguments):-F,typeof z=="function"?-z.apply(this,arguments):-z),K,s)},G,Q)};function N(q,F){return F=Math.max(o[0],Math.min(o[1],F)),F===q.k?q:new Dr(F,q.x,q.y)}function k(q,F,z){var G=F[0]-z[0]*q.k,Q=F[1]-z[1]*q.k;return G===q.x&&Q===q.y?q:new Dr(q.k,G,Q)}function T(q){return[(+q[0][0]+ +q[1][0])/2,(+q[0][1]+ +q[1][1])/2]}function M(q,F,z,G){q.on("start.zoom",function(){A(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(G).end()}).tween("zoom",function(){var Q=this,K=arguments,D=A(Q,K).event(G),$=t.apply(Q,K),Y=z==null?T($):typeof z=="function"?z.apply(Q,K):z,C=Math.max($[1][0]-$[0][0],$[1][1]-$[0][1]),P=Q.__zoom,X=typeof F=="function"?F.apply(Q,K):F,J=h(P.invert(Y).concat(C/P.k),X.invert(Y).concat(C/X.k));return function(ne){if(ne===1)ne=X;else{var re=J(ne),ue=C/re[2];ne=new Dr(ue,Y[0]-re[0]*ue,Y[1]-re[1]*ue)}D.zoom(null,ne)}})}function A(q,F,z){return!z&&q.__zooming||new L(q,F)}function L(q,F){this.that=q,this.args=F,this.active=0,this.sourceEvent=null,this.extent=t.apply(q,F),this.taps=0}L.prototype={event:function(q){return q&&(this.sourceEvent=q),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(q,F){return this.mouse&&q!=="mouse"&&(this.mouse[1]=F.invert(this.mouse[0])),this.touch0&&q!=="touch"&&(this.touch0[1]=F.invert(this.touch0[0])),this.touch1&&q!=="touch"&&(this.touch1[1]=F.invert(this.touch1[0])),this.that.__zoom=F,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(q){var F=wn(this.that).datum();f.call(q,this.that,new GT(q,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:f}),F)}};function R(q,...F){if(!e.apply(this,arguments))return;var z=A(this,F).event(q),G=this.__zoom,Q=Math.max(o[0],Math.min(o[1],G.k*Math.pow(2,l.apply(this,arguments)))),K=qn(q);if(z.wheel)(z.mouse[0][0]!==K[0]||z.mouse[0][1]!==K[1])&&(z.mouse[1]=G.invert(z.mouse[0]=K)),clearTimeout(z.wheel);else{if(G.k===Q)return;z.mouse=[K,G.invert(K)],nc(this),z.start()}_o(q),z.wheel=setTimeout(D,w),z.zoom("mouse",n(k(N(G,Q),z.mouse[0],z.mouse[1]),z.extent,s));function D(){z.wheel=null,z.end()}}function V(q,...F){if(g||!e.apply(this,arguments))return;var z=q.currentTarget,G=A(this,F,!0).event(q),Q=wn(q.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",C,!0),K=qn(q,z),D=q.clientX,$=q.clientY;n_(q.view),wh(q),G.mouse=[K,this.__zoom.invert(K)],nc(this),G.start();function Y(P){if(_o(P),!G.moved){var X=P.clientX-D,J=P.clientY-$;G.moved=X*X+J*J>E}G.event(P).zoom("mouse",n(k(G.that.__zoom,G.mouse[0]=qn(P,z),G.mouse[1]),G.extent,s))}function C(P){Q.on("mousemove.zoom mouseup.zoom",null),r_(P.view,G.moved),_o(P),G.event(P).end()}}function H(q,...F){if(e.apply(this,arguments)){var z=this.__zoom,G=qn(q.changedTouches?q.changedTouches[0]:q,this),Q=z.invert(G),K=z.k*(q.shiftKey?.5:2),D=n(k(N(z,K),G,Q),t.apply(this,F),s);_o(q),c>0?wn(this).transition().duration(c).call(M,D,G,q):wn(this).call(_.transform,D,G,q)}}function B(q,...F){if(e.apply(this,arguments)){var z=q.touches,G=z.length,Q=A(this,F,q.changedTouches.length===G).event(q),K,D,$,Y;for(wh(q),D=0;D"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:l})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:l}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Po=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],b_=["Enter"," ","Escape"],w_={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var ma;(function(e){e.Strict="strict",e.Loose="loose"})(ma||(ma={}));var el;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(el||(el={}));var Go;(function(e){e.Partial="partial",e.Full="full"})(Go||(Go={}));const __={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var bi;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(bi||(bi={}));var mc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(mc||(mc={}));var ve;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ve||(ve={}));const Av={[ve.Left]:ve.Right,[ve.Right]:ve.Left,[ve.Top]:ve.Bottom,[ve.Bottom]:ve.Top};function S_(e){return e===null?null:e?"valid":"invalid"}const k_=e=>"id"in e&&"source"in e&&"target"in e,KT=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Am=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),ts=(e,t=[0,0])=>{const{width:n,height:l}=Hr(e),a=e.origin??t,o=n*a[0],s=l*a[1];return{x:e.position.x-o,y:e.position.y-s}},JT=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((l,a)=>{const o=typeof a=="string";let s=!t.nodeLookup&&!o?a:void 0;t.nodeLookup&&(s=o?t.nodeLookup.get(a):Am(a)?a:t.nodeLookup.get(a.id));const c=s?gc(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Oc(l,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Lc(n)},ns=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},l=!1;return e.forEach(a=>{(t.filter===void 0||t.filter(a))&&(n=Oc(n,gc(a)),l=!0)}),l?Lc(n):{x:0,y:0,width:0,height:0}},zm=(e,t,[n,l,a]=[0,0,1],o=!1,s=!1)=>{const c={...is(t,[n,l,a]),width:t.width/a,height:t.height/a},h=[];for(const f of e.values()){const{measured:m,selectable:p=!0,hidden:g=!1}=f;if(s&&!p||g)continue;const b=m.width??f.width??f.initialWidth??null,w=m.height??f.height??f.initialHeight??null,E=Fo(c,xa(f)),S=(b??0)*(w??0),_=o&&E>0;(!f.internals.handleBounds||_||E>=S||f.dragging)&&h.push(f)}return h},WT=(e,t)=>{const n=new Set;return e.forEach(l=>{n.add(l.id)}),t.filter(l=>n.has(l.source)||n.has(l.target))};function eA(e,t){const n=new Map,l=t!=null&&t.nodes?new Set(t.nodes.map(a=>a.id)):null;return e.forEach(a=>{a.measured.width&&a.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!a.hidden)&&(!l||l.has(a.id))&&n.set(a.id,a)}),n}async function tA({nodes:e,width:t,height:n,panZoom:l,minZoom:a,maxZoom:o},s){if(e.size===0)return Promise.resolve(!0);const c=eA(e,s),h=ns(c),f=Mm(h,t,n,(s==null?void 0:s.minZoom)??a,(s==null?void 0:s.maxZoom)??o,(s==null?void 0:s.padding)??.1);return await l.setViewport(f,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function E_({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:l=[0,0],nodeExtent:a,onError:o}){const s=n.get(e),c=s.parentId?n.get(s.parentId):void 0,{x:h,y:f}=c?c.internals.positionAbsolute:{x:0,y:0},m=s.origin??l;let p=s.extent||a;if(s.extent==="parent"&&!s.expandParent)if(!c)o==null||o("005",ar.error005());else{const b=c.measured.width,w=c.measured.height;b&&w&&(p=[[h,f],[h+b,f+w]])}else c&&ya(s.extent)&&(p=[[s.extent[0][0]+h,s.extent[0][1]+f],[s.extent[1][0]+h,s.extent[1][1]+f]]);const g=ya(p)?il(t,p,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(o==null||o("015",ar.error015())),{position:{x:g.x-h+(s.measured.width??0)*m[0],y:g.y-f+(s.measured.height??0)*m[1]},positionAbsolute:g}}async function nA({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:l,onBeforeDelete:a}){const o=new Set(e.map(g=>g.id)),s=[];for(const g of n){if(g.deletable===!1)continue;const b=o.has(g.id),w=!b&&g.parentId&&s.find(E=>E.id===g.parentId);(b||w)&&s.push(g)}const c=new Set(t.map(g=>g.id)),h=l.filter(g=>g.deletable!==!1),m=WT(s,h);for(const g of h)c.has(g.id)&&!m.find(w=>w.id===g.id)&&m.push(g);if(!a)return{edges:m,nodes:s};const p=await a({nodes:s,edges:m});return typeof p=="boolean"?p?{edges:m,nodes:s}:{edges:[],nodes:[]}:p}const ga=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),il=(e={x:0,y:0},t,n)=>({x:ga(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:ga(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function N_(e,t,n){const{width:l,height:a}=Hr(n),{x:o,y:s}=n.internals.positionAbsolute;return il(e,[[o,s],[o+l,s+a]],t)}const zv=(e,t,n)=>en?-ga(Math.abs(e-n),1,t)/t:0,C_=(e,t,n=15,l=40)=>{const a=zv(e.x,l,t.width-l)*n,o=zv(e.y,l,t.height-l)*n;return[a,o]},Oc=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),em=({x:e,y:t,width:n,height:l})=>({x:e,y:t,x2:e+n,y2:t+l}),Lc=({x:e,y:t,x2:n,y2:l})=>({x:e,y:t,width:n-e,height:l-t}),xa=(e,t=[0,0])=>{var a,o;const{x:n,y:l}=Am(e)?e.internals.positionAbsolute:ts(e,t);return{x:n,y:l,width:((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},gc=(e,t=[0,0])=>{var a,o;const{x:n,y:l}=Am(e)?e.internals.positionAbsolute:ts(e,t);return{x:n,y:l,x2:n+(((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0),y2:l+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},j_=(e,t)=>Lc(Oc(em(e),em(t))),Fo=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),l=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*l)},Mv=e=>Un(e.width)&&Un(e.height)&&Un(e.x)&&Un(e.y),Un=e=>!isNaN(e)&&isFinite(e),rA=(e,t)=>{},rs=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),is=({x:e,y:t},[n,l,a],o=!1,s=[1,1])=>{const c={x:(e-n)/a,y:(t-l)/a};return o?rs(c,s):c},xc=({x:e,y:t},[n,l,a])=>({x:e*a+n,y:t*a+l});function Jl(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function iA(e,t,n){if(typeof e=="string"||typeof e=="number"){const l=Jl(e,n),a=Jl(e,t);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof e=="object"){const l=Jl(e.top??e.y??0,n),a=Jl(e.bottom??e.y??0,n),o=Jl(e.left??e.x??0,t),s=Jl(e.right??e.x??0,t);return{top:l,right:s,bottom:a,left:o,x:o+s,y:l+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function lA(e,t,n,l,a,o){const{x:s,y:c}=xc(e,[t,n,l]),{x:h,y:f}=xc({x:e.x+e.width,y:e.y+e.height},[t,n,l]),m=a-h,p=o-f;return{left:Math.floor(s),top:Math.floor(c),right:Math.floor(m),bottom:Math.floor(p)}}const Mm=(e,t,n,l,a,o)=>{const s=iA(o,t,n),c=(t-s.x)/e.width,h=(n-s.y)/e.height,f=Math.min(c,h),m=ga(f,l,a),p=e.x+e.width/2,g=e.y+e.height/2,b=t/2-p*m,w=n/2-g*m,E=lA(e,b,w,m,t,n),S={left:Math.min(E.left-s.left,0),top:Math.min(E.top-s.top,0),right:Math.min(E.right-s.right,0),bottom:Math.min(E.bottom-s.bottom,0)};return{x:b-S.left+S.right,y:w-S.top+S.bottom,zoom:m}},Yo=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function ya(e){return e!=null&&e!=="parent"}function Hr(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function T_(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function A_(e,t={width:0,height:0},n,l,a){const o={...e},s=l.get(n);if(s){const c=s.origin||a;o.x+=s.internals.positionAbsolute.x-(t.width??0)*c[0],o.y+=s.internals.positionAbsolute.y-(t.height??0)*c[1]}return o}function Dv(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function aA(){let e,t;return{promise:new Promise((l,a)=>{e=l,t=a}),resolve:e,reject:t}}function oA(e){return{...w_,...e||{}}}function Ro(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:l,containerBounds:a}){const{x:o,y:s}=Vn(e),c=is({x:o-((a==null?void 0:a.left)??0),y:s-((a==null?void 0:a.top)??0)},l),{x:h,y:f}=n?rs(c,t):c;return{xSnapped:h,ySnapped:f,...c}}const Dm=e=>({width:e.offsetWidth,height:e.offsetHeight}),z_=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},sA=["INPUT","SELECT","TEXTAREA"];function M_(e){var l,a;const t=((a=(l=e.composedPath)==null?void 0:l.call(e))==null?void 0:a[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:sA.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const D_=e=>"clientX"in e,Vn=(e,t)=>{var o,s;const n=D_(e),l=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,a=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:l-((t==null?void 0:t.left)??0),y:a-((t==null?void 0:t.top)??0)}},Rv=(e,t,n,l,a)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(s=>{const c=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:a,position:s.getAttribute("data-handlepos"),x:(c.left-n.left)/l,y:(c.top-n.top)/l,...Dm(s)}})};function R_({sourceX:e,sourceY:t,targetX:n,targetY:l,sourceControlX:a,sourceControlY:o,targetControlX:s,targetControlY:c}){const h=e*.125+a*.375+s*.375+n*.125,f=t*.125+o*.375+c*.375+l*.125,m=Math.abs(h-e),p=Math.abs(f-t);return[h,f,m,p]}function Vu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Ov({pos:e,x1:t,y1:n,x2:l,y2:a,c:o}){switch(e){case ve.Left:return[t-Vu(t-l,o),n];case ve.Right:return[t+Vu(l-t,o),n];case ve.Top:return[t,n-Vu(n-a,o)];case ve.Bottom:return[t,n+Vu(a-n,o)]}}function Rm({sourceX:e,sourceY:t,sourcePosition:n=ve.Bottom,targetX:l,targetY:a,targetPosition:o=ve.Top,curvature:s=.25}){const[c,h]=Ov({pos:n,x1:e,y1:t,x2:l,y2:a,c:s}),[f,m]=Ov({pos:o,x1:l,y1:a,x2:e,y2:t,c:s}),[p,g,b,w]=R_({sourceX:e,sourceY:t,targetX:l,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:f,targetControlY:m});return[`M${e},${t} C${c},${h} ${f},${m} ${l},${a}`,p,g,b,w]}function O_({sourceX:e,sourceY:t,targetX:n,targetY:l}){const a=Math.abs(n-e)/2,o=n0}const fA=({source:e,sourceHandle:t,target:n,targetHandle:l})=>`xy-edge__${e}${t||""}-${n}${l||""}`,dA=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),hA=(e,t,n={})=>{if(!e.source||!e.target)return t;const l=n.getEdgeId||fA;let a;return k_(e)?a={...e}:a={...e,id:l(e)},dA(a,t)?t:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,t.concat(a))};function L_({sourceX:e,sourceY:t,targetX:n,targetY:l}){const[a,o,s,c]=O_({sourceX:e,sourceY:t,targetX:n,targetY:l});return[`M ${e},${t}L ${n},${l}`,a,o,s,c]}const Lv={[ve.Left]:{x:-1,y:0},[ve.Right]:{x:1,y:0},[ve.Top]:{x:0,y:-1},[ve.Bottom]:{x:0,y:1}},pA=({source:e,sourcePosition:t=ve.Bottom,target:n})=>t===ve.Left||t===ve.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function mA({source:e,sourcePosition:t=ve.Bottom,target:n,targetPosition:l=ve.Top,center:a,offset:o,stepPosition:s}){const c=Lv[t],h=Lv[l],f={x:e.x+c.x*o,y:e.y+c.y*o},m={x:n.x+h.x*o,y:n.y+h.y*o},p=pA({source:f,sourcePosition:t,target:m}),g=p.x!==0?"x":"y",b=p[g];let w=[],E,S;const _={x:0,y:0},N={x:0,y:0},[,,k,T]=O_({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[g]*h[g]===-1){g==="x"?(E=a.x??f.x+(m.x-f.x)*s,S=a.y??(f.y+m.y)/2):(E=a.x??(f.x+m.x)/2,S=a.y??f.y+(m.y-f.y)*s);const A=[{x:E,y:f.y},{x:E,y:m.y}],L=[{x:f.x,y:S},{x:m.x,y:S}];c[g]===b?w=g==="x"?A:L:w=g==="x"?L:A}else{const A=[{x:f.x,y:m.y}],L=[{x:m.x,y:f.y}];if(g==="x"?w=c.x===b?L:A:w=c.y===b?A:L,t===l){const U=Math.abs(e[g]-n[g]);if(U<=o){const ee=Math.min(o-1,o-U);c[g]===b?_[g]=(f[g]>e[g]?-1:1)*ee:N[g]=(m[g]>n[g]?-1:1)*ee}}if(t!==l){const U=g==="x"?"y":"x",ee=c[g]===h[U],q=f[U]>m[U],F=f[U]=B?(E=(R.x+V.x)/2,S=w[0].y):(E=w[0].x,S=(R.y+V.y)/2)}return[[e,{x:f.x+_.x,y:f.y+_.y},...w,{x:m.x+N.x,y:m.y+N.y},n],E,S,k,T]}function gA(e,t,n,l){const a=Math.min(Hv(e,t)/2,Hv(t,n)/2,l),{x:o,y:s}=t;if(e.x===o&&o===n.x||e.y===s&&s===n.y)return`L${o} ${s}`;if(e.y===s){const f=e.x{let T="";return k>0&&kn.id===t):e[0])||null}function nm(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(l=>`${l}=${e[l]}`).join("&")}`:""}function yA(e,{id:t,defaultColor:n,defaultMarkerStart:l,defaultMarkerEnd:a}){const o=new Set;return e.reduce((s,c)=>([c.markerStart||l,c.markerEnd||a].forEach(h=>{if(h&&typeof h=="object"){const f=nm(h,t);o.has(f)||(s.push({id:f,color:h.color||n,...h}),o.add(f))}}),s),[]).sort((s,c)=>s.id.localeCompare(c.id))}const H_=1e3,vA=10,Om={nodeOrigin:[0,0],nodeExtent:Po,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},bA={...Om,checkEquality:!0};function Lm(e,t){const n={...e};for(const l in t)t[l]!==void 0&&(n[l]=t[l]);return n}function wA(e,t,n){const l=Lm(Om,n);for(const a of e.values())if(a.parentId)Bm(a,e,t,l);else{const o=ts(a,l.nodeOrigin),s=ya(a.extent)?a.extent:l.nodeExtent,c=il(o,s,Hr(a));a.internals.positionAbsolute=c}}function _A(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],l=[];for(const a of e.handles){const o={id:a.id,width:a.width??1,height:a.height??1,nodeId:e.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?n.push(o):a.type==="target"&&l.push(o)}return{source:n,target:l}}function Hm(e){return e==="manual"}function rm(e,t,n,l={}){var f,m;const a=Lm(bA,l),o={i:0},s=new Map(t),c=a!=null&&a.elevateNodesOnSelect&&!Hm(a.zIndexMode)?H_:0;let h=e.length>0;t.clear(),n.clear();for(const p of e){let g=s.get(p.id);if(a.checkEquality&&p===(g==null?void 0:g.internals.userNode))t.set(p.id,g);else{const b=ts(p,a.nodeOrigin),w=ya(p.extent)?p.extent:a.nodeExtent,E=il(b,w,Hr(p));g={...a.defaults,...p,measured:{width:(f=p.measured)==null?void 0:f.width,height:(m=p.measured)==null?void 0:m.height},internals:{positionAbsolute:E,handleBounds:_A(p,g),z:B_(p,c,a.zIndexMode),userNode:p}},t.set(p.id,g)}(g.measured===void 0||g.measured.width===void 0||g.measured.height===void 0)&&!g.hidden&&(h=!1),p.parentId&&Bm(g,t,n,l,o)}return h}function SA(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Bm(e,t,n,l,a){const{elevateNodesOnSelect:o,nodeOrigin:s,nodeExtent:c,zIndexMode:h}=Lm(Om,l),f=e.parentId,m=t.get(f);if(!m){console.warn(`Parent node ${f} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}SA(e,n),a&&!m.parentId&&m.internals.rootParentIndex===void 0&&h==="auto"&&(m.internals.rootParentIndex=++a.i,m.internals.z=m.internals.z+a.i*vA),a&&m.internals.rootParentIndex!==void 0&&(a.i=m.internals.rootParentIndex);const p=o&&!Hm(h)?H_:0,{x:g,y:b,z:w}=kA(e,m,s,c,p,h),{positionAbsolute:E}=e.internals,S=g!==E.x||b!==E.y;(S||w!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:S?{x:g,y:b}:E,z:w}})}function B_(e,t,n){const l=Un(e.zIndex)?e.zIndex:0;return Hm(n)?l:l+(e.selected?t:0)}function kA(e,t,n,l,a,o){const{x:s,y:c}=t.internals.positionAbsolute,h=Hr(e),f=ts(e,n),m=ya(e.extent)?il(f,e.extent,h):f;let p=il({x:s+m.x,y:c+m.y},l,h);e.extent==="parent"&&(p=N_(p,h,t));const g=B_(e,a,o),b=t.internals.z??0;return{x:p.x,y:p.y,z:b>=g?b+1:g}}function Im(e,t,n,l=[0,0]){var s;const a=[],o=new Map;for(const c of e){const h=t.get(c.parentId);if(!h)continue;const f=((s=o.get(c.parentId))==null?void 0:s.expandedRect)??xa(h),m=j_(f,c.rect);o.set(c.parentId,{expandedRect:m,parent:h})}return o.size>0&&o.forEach(({expandedRect:c,parent:h},f)=>{var k;const m=h.internals.positionAbsolute,p=Hr(h),g=h.origin??l,b=c.x0||w>0||_||N)&&(a.push({id:f,type:"position",position:{x:h.position.x-b+_,y:h.position.y-w+N}}),(k=n.get(f))==null||k.forEach(T=>{e.some(M=>M.id===T.id)||a.push({id:T.id,type:"position",position:{x:T.position.x+b,y:T.position.y+w}})})),(p.width0){const b=Im(g,t,n,a);f.push(...b)}return{changes:f,updatedInternals:h}}async function NA({delta:e,panZoom:t,transform:n,translateExtent:l,width:a,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[a,o]],l),c=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(c)}function $v(e,t,n,l,a,o){let s=a;const c=l.get(s)||new Map;l.set(s,c.set(n,t)),s=`${a}-${e}`;const h=l.get(s)||new Map;if(l.set(s,h.set(n,t)),o){s=`${a}-${e}-${o}`;const f=l.get(s)||new Map;l.set(s,f.set(n,t))}}function I_(e,t,n){e.clear(),t.clear();for(const l of n){const{source:a,target:o,sourceHandle:s=null,targetHandle:c=null}=l,h={edgeId:l.id,source:a,target:o,sourceHandle:s,targetHandle:c},f=`${a}-${s}--${o}-${c}`,m=`${o}-${c}--${a}-${s}`;$v("source",h,m,e,a,s),$v("target",h,f,e,o,c),t.set(l.id,l)}}function q_(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:q_(n,t):!1}function Uv(e,t,n){var a;let l=e;do{if((a=l==null?void 0:l.matches)!=null&&a.call(l,t))return!0;if(l===n)return!1;l=l==null?void 0:l.parentElement}while(l);return!1}function CA(e,t,n,l){const a=new Map;for(const[o,s]of e)if((s.selected||s.id===l)&&(!s.parentId||!q_(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const c=e.get(o);c&&a.set(o,{id:o,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return a}function _h({nodeId:e,dragItems:t,nodeLookup:n,dragging:l=!0}){var s,c,h;const a=[];for(const[f,m]of t){const p=(s=n.get(f))==null?void 0:s.internals.userNode;p&&a.push({...p,position:m.position,dragging:l})}if(!e)return[a[0],a];const o=(c=n.get(e))==null?void 0:c.internals.userNode;return[o?{...o,position:((h=t.get(e))==null?void 0:h.position)||o.position,dragging:l}:a[0],a]}function jA({dragItems:e,snapGrid:t,x:n,y:l}){const a=e.values().next().value;if(!a)return null;const o={x:n-a.distance.x,y:l-a.distance.y},s=rs(o,t);return{x:s.x-o.x,y:s.y-o.y}}function TA({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:l,onDragStop:a}){let o={x:null,y:null},s=0,c=new Map,h=!1,f={x:0,y:0},m=null,p=!1,g=null,b=!1,w=!1,E=null;function S({noDragClassName:N,handleSelector:k,domNode:T,isSelectable:M,nodeId:A,nodeClickDistance:L=0}){g=wn(T);function R({x:U,y:ee}){const{nodeLookup:q,nodeExtent:F,snapGrid:z,snapToGrid:G,nodeOrigin:Q,onNodeDrag:K,onSelectionDrag:D,onError:$,updateNodePositions:Y}=t();o={x:U,y:ee};let C=!1;const P=c.size>1,X=P&&F?em(ns(c)):null,J=P&&G?jA({dragItems:c,snapGrid:z,x:U,y:ee}):null;for(const[ne,re]of c){if(!q.has(ne))continue;let ue={x:U-re.distance.x,y:ee-re.distance.y};G&&(ue=J?{x:Math.round(ue.x+J.x),y:Math.round(ue.y+J.y)}:rs(ue,z));let xe=null;if(P&&F&&!re.extent&&X){const{positionAbsolute:pe}=re.internals,Se=pe.x-X.x+F[0][0],Oe=pe.x+re.measured.width-X.x2+F[1][0],je=pe.y-X.y+F[0][1],ft=pe.y+re.measured.height-X.y2+F[1][1];xe=[[Se,je],[Oe,ft]]}const{position:be,positionAbsolute:ye}=E_({nodeId:ne,nextPosition:ue,nodeLookup:q,nodeExtent:xe||F,nodeOrigin:Q,onError:$});C=C||re.position.x!==be.x||re.position.y!==be.y,re.position=be,re.internals.positionAbsolute=ye}if(w=w||C,!!C&&(Y(c,!0),E&&(l||K||!A&&D))){const[ne,re]=_h({nodeId:A,dragItems:c,nodeLookup:q});l==null||l(E,c,ne,re),K==null||K(E,ne,re),A||D==null||D(E,re)}}async function V(){if(!m)return;const{transform:U,panBy:ee,autoPanSpeed:q,autoPanOnNodeDrag:F}=t();if(!F){h=!1,cancelAnimationFrame(s);return}const[z,G]=C_(f,m,q);(z!==0||G!==0)&&(o.x=(o.x??0)-z/U[2],o.y=(o.y??0)-G/U[2],await ee({x:z,y:G})&&R(o)),s=requestAnimationFrame(V)}function H(U){var P;const{nodeLookup:ee,multiSelectionActive:q,nodesDraggable:F,transform:z,snapGrid:G,snapToGrid:Q,selectNodesOnDrag:K,onNodeDragStart:D,onSelectionDragStart:$,unselectNodesAndEdges:Y}=t();p=!0,(!K||!M)&&!q&&A&&((P=ee.get(A))!=null&&P.selected||Y()),M&&K&&A&&(e==null||e(A));const C=Ro(U.sourceEvent,{transform:z,snapGrid:G,snapToGrid:Q,containerBounds:m});if(o=C,c=CA(ee,F,C,A),c.size>0&&(n||D||!A&&$)){const[X,J]=_h({nodeId:A,dragItems:c,nodeLookup:ee});n==null||n(U.sourceEvent,c,X,J),D==null||D(U.sourceEvent,X,J),A||$==null||$(U.sourceEvent,J)}}const B=i_().clickDistance(L).on("start",U=>{const{domNode:ee,nodeDragThreshold:q,transform:F,snapGrid:z,snapToGrid:G}=t();m=(ee==null?void 0:ee.getBoundingClientRect())||null,b=!1,w=!1,E=U.sourceEvent,q===0&&H(U),o=Ro(U.sourceEvent,{transform:F,snapGrid:z,snapToGrid:G,containerBounds:m}),f=Vn(U.sourceEvent,m)}).on("drag",U=>{const{autoPanOnNodeDrag:ee,transform:q,snapGrid:F,snapToGrid:z,nodeDragThreshold:G,nodeLookup:Q}=t(),K=Ro(U.sourceEvent,{transform:q,snapGrid:F,snapToGrid:z,containerBounds:m});if(E=U.sourceEvent,(U.sourceEvent.type==="touchmove"&&U.sourceEvent.touches.length>1||A&&!Q.has(A))&&(b=!0),!b){if(!h&&ee&&p&&(h=!0,V()),!p){const D=Vn(U.sourceEvent,m),$=D.x-f.x,Y=D.y-f.y;Math.sqrt($*$+Y*Y)>G&&H(U)}(o.x!==K.xSnapped||o.y!==K.ySnapped)&&c&&p&&(f=Vn(U.sourceEvent,m),R(K))}}).on("end",U=>{if(!(!p||b)&&(h=!1,p=!1,cancelAnimationFrame(s),c.size>0)){const{nodeLookup:ee,updateNodePositions:q,onNodeDragStop:F,onSelectionDragStop:z}=t();if(w&&(q(c,!1),w=!1),a||F||!A&&z){const[G,Q]=_h({nodeId:A,dragItems:c,nodeLookup:ee,dragging:!1});a==null||a(U.sourceEvent,c,G,Q),F==null||F(U.sourceEvent,G,Q),A||z==null||z(U.sourceEvent,Q)}}}).filter(U=>{const ee=U.target;return!U.button&&(!N||!Uv(ee,`.${N}`,T))&&(!k||Uv(ee,k,T))});g.call(B)}function _(){g==null||g.on(".drag",null)}return{update:S,destroy:_}}function AA(e,t,n){const l=[],a={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())Fo(a,xa(o))>0&&l.push(o);return l}const zA=250;function MA(e,t,n,l){var c,h;let a=[],o=1/0;const s=AA(e,n,t+zA);for(const f of s){const m=[...((c=f.internals.handleBounds)==null?void 0:c.source)??[],...((h=f.internals.handleBounds)==null?void 0:h.target)??[]];for(const p of m){if(l.nodeId===p.nodeId&&l.type===p.type&&l.id===p.id)continue;const{x:g,y:b}=ll(f,p,p.position,!0),w=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(b-e.y,2));w>t||(w1){const f=l.type==="source"?"target":"source";return a.find(m=>m.type===f)??a[0]}return a[0]}function $_(e,t,n,l,a,o=!1){var f,m,p;const s=l.get(e);if(!s)return null;const c=a==="strict"?(f=s.internals.handleBounds)==null?void 0:f[t]:[...((m=s.internals.handleBounds)==null?void 0:m.source)??[],...((p=s.internals.handleBounds)==null?void 0:p.target)??[]],h=(n?c==null?void 0:c.find(g=>g.id===n):c==null?void 0:c[0])??null;return h&&o?{...h,...ll(s,h,h.position,!0)}:h}function U_(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function DA(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const V_=()=>!0;function RA(e,{connectionMode:t,connectionRadius:n,handleId:l,nodeId:a,edgeUpdaterType:o,isTarget:s,domNode:c,nodeLookup:h,lib:f,autoPanOnConnect:m,flowId:p,panBy:g,cancelConnection:b,onConnectStart:w,onConnect:E,onConnectEnd:S,isValidConnection:_=V_,onReconnectEnd:N,updateConnection:k,getTransform:T,getFromHandle:M,autoPanSpeed:A,dragThreshold:L=1,handleDomNode:R}){const V=z_(e.target);let H=0,B;const{x:U,y:ee}=Vn(e),q=U_(o,R),F=c==null?void 0:c.getBoundingClientRect();let z=!1;if(!F||!q)return;const G=$_(a,q,l,h,t);if(!G)return;let Q=Vn(e,F),K=!1,D=null,$=!1,Y=null;function C(){if(!m||!F)return;const[be,ye]=C_(Q,F,A);g({x:be,y:ye}),H=requestAnimationFrame(C)}const P={...G,nodeId:a,type:q,position:G.position},X=h.get(a);let ne={inProgress:!0,isValid:null,from:ll(X,P,ve.Left,!0),fromHandle:P,fromPosition:P.position,fromNode:X,to:Q,toHandle:null,toPosition:Av[P.position],toNode:null,pointer:Q};function re(){z=!0,k(ne),w==null||w(e,{nodeId:a,handleId:l,handleType:q})}L===0&&re();function ue(be){if(!z){const{x:ft,y:rt}=Vn(be),Dt=ft-U,Pt=rt-ee;if(!(Dt*Dt+Pt*Pt>L*L))return;re()}if(!M()||!P){xe(be);return}const ye=T();Q=Vn(be,F),B=MA(is(Q,ye,!1,[1,1]),n,h,P),K||(C(),K=!0);const pe=P_(be,{handle:B,connectionMode:t,fromNodeId:a,fromHandleId:l,fromType:s?"target":"source",isValidConnection:_,doc:V,lib:f,flowId:p,nodeLookup:h});Y=pe.handleDomNode,D=pe.connection,$=DA(!!B,pe.isValid);const Se=h.get(a),Oe=Se?ll(Se,P,ve.Left,!0):ne.from,je={...ne,from:Oe,isValid:$,to:pe.toHandle&&$?xc({x:pe.toHandle.x,y:pe.toHandle.y},ye):Q,toHandle:pe.toHandle,toPosition:$&&pe.toHandle?pe.toHandle.position:Av[P.position],toNode:pe.toHandle?h.get(pe.toHandle.nodeId):null,pointer:Q};k(je),ne=je}function xe(be){if(!("touches"in be&&be.touches.length>0)){if(z){(B||Y)&&D&&$&&(E==null||E(D));const{inProgress:ye,...pe}=ne,Se={...pe,toPosition:ne.toHandle?ne.toPosition:null};S==null||S(be,Se),o&&(N==null||N(be,Se))}b(),cancelAnimationFrame(H),K=!1,$=!1,D=null,Y=null,V.removeEventListener("mousemove",ue),V.removeEventListener("mouseup",xe),V.removeEventListener("touchmove",ue),V.removeEventListener("touchend",xe)}}V.addEventListener("mousemove",ue),V.addEventListener("mouseup",xe),V.addEventListener("touchmove",ue),V.addEventListener("touchend",xe)}function P_(e,{handle:t,connectionMode:n,fromNodeId:l,fromHandleId:a,fromType:o,doc:s,lib:c,flowId:h,isValidConnection:f=V_,nodeLookup:m}){const p=o==="target",g=t?s.querySelector(`.${c}-flow__handle[data-id="${h}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:b,y:w}=Vn(e),E=s.elementFromPoint(b,w),S=E!=null&&E.classList.contains(`${c}-flow__handle`)?E:g,_={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const N=U_(void 0,S),k=S.getAttribute("data-nodeid"),T=S.getAttribute("data-handleid"),M=S.classList.contains("connectable"),A=S.classList.contains("connectableend");if(!k||!N)return _;const L={source:p?k:l,sourceHandle:p?T:a,target:p?l:k,targetHandle:p?a:T};_.connection=L;const V=M&&A&&(n===ma.Strict?p&&N==="source"||!p&&N==="target":k!==l||T!==a);_.isValid=V&&f(L),_.toHandle=$_(k,N,T,m,n,!0)}return _}const im={onPointerDown:RA,isValid:P_};function OA({domNode:e,panZoom:t,getTransform:n,getViewScale:l}){const a=wn(e);function o({translateExtent:c,width:h,height:f,zoomStep:m=1,pannable:p=!0,zoomable:g=!0,inversePan:b=!1}){const w=k=>{if(k.sourceEvent.type!=="wheel"||!t)return;const T=n(),M=k.sourceEvent.ctrlKey&&Yo()?10:1,A=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*m,L=T[2]*Math.pow(2,A*M);t.scaleTo(L)};let E=[0,0];const S=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(E=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},_=k=>{const T=n();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!t)return;const M=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],A=[M[0]-E[0],M[1]-E[1]];E=M;const L=l()*Math.max(T[2],Math.log(T[2]))*(b?-1:1),R={x:T[0]-A[0]*L,y:T[1]-A[1]*L},V=[[0,0],[h,f]];t.setViewportConstrained({x:R.x,y:R.y,zoom:T[2]},V,c)},N=v_().on("start",S).on("zoom",p?_:null).on("zoom.wheel",g?w:null);a.call(N,{})}function s(){a.on("zoom",null)}return{update:o,destroy:s,pointer:qn}}const Hc=e=>({x:e.x,y:e.y,zoom:e.k}),Sh=({x:e,y:t,zoom:n})=>Rc.translate(e,t).scale(n),la=(e,t)=>e.target.closest(`.${t}`),G_=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),LA=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,kh=(e,t=0,n=LA,l=()=>{})=>{const a=typeof t=="number"&&t>0;return a||l(),a?e.transition().duration(t).ease(n).on("end",l):e},F_=e=>{const t=e.ctrlKey&&Yo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function HA({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:o,zoomOnPinch:s,onPanZoomStart:c,onPanZoom:h,onPanZoomEnd:f}){return m=>{if(la(m,t))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(m.ctrlKey&&s){const S=qn(m),_=F_(m),N=p*Math.pow(2,_);l.scaleTo(n,N,S,m);return}const g=m.deltaMode===1?20:1;let b=a===el.Vertical?0:m.deltaX*g,w=a===el.Horizontal?0:m.deltaY*g;!Yo()&&m.shiftKey&&a!==el.Vertical&&(b=m.deltaY*g,w=0),l.translateBy(n,-(b/p)*o,-(w/p)*o,{internal:!0});const E=Hc(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(h==null||h(m,E),e.panScrollTimeout=setTimeout(()=>{f==null||f(m,E),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c==null||c(m,E))}}function BA({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(l,a){const o=l.type==="wheel",s=!t&&o&&!l.ctrlKey,c=la(l,e);if(l.ctrlKey&&o&&c&&l.preventDefault(),s||c)return null;l.preventDefault(),n.call(this,l,a)}}function IA({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return l=>{var o,s,c;if((o=l.sourceEvent)!=null&&o.internal)return;const a=Hc(l.transform);e.mouseButton=((s=l.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=a,((c=l.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),n&&(n==null||n(l.sourceEvent,a))}}function qA({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:l,onPanZoom:a}){return o=>{var s,c;e.usedRightMouseButton=!!(n&&G_(t,e.mouseButton??0)),(s=o.sourceEvent)!=null&&s.sync||l([o.transform.x,o.transform.y,o.transform.k]),a&&!((c=o.sourceEvent)!=null&&c.internal)&&(a==null||a(o.sourceEvent,Hc(o.transform)))}}function $A({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:l,onPanZoomEnd:a,onPaneContextMenu:o}){return s=>{var c;if(!((c=s.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,o&&G_(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&o(s.sourceEvent),e.usedRightMouseButton=!1,l(!1),a)){const h=Hc(s.transform);e.prevViewport=h,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{a==null||a(s.sourceEvent,h)},n?150:0)}}}function UA({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:l,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:c,noPanClassName:h,lib:f,connectionInProgress:m}){return p=>{var S;const g=e||t,b=n&&p.ctrlKey,w=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(la(p,`${f}-flow__node`)||la(p,`${f}-flow__edge`)))return!0;if(!l&&!g&&!a&&!o&&!n||s||m&&!w||la(p,c)&&w||la(p,h)&&(!w||a&&w&&!e)||!n&&p.ctrlKey&&w)return!1;if(!n&&p.type==="touchstart"&&((S=p.touches)==null?void 0:S.length)>1)return p.preventDefault(),!1;if(!g&&!a&&!b&&w||!l&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(l)&&!l.includes(p.button)&&p.type==="mousedown")return!1;const E=Array.isArray(l)&&l.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||w)&&E}}function VA({domNode:e,minZoom:t,maxZoom:n,translateExtent:l,viewport:a,onPanZoom:o,onPanZoomStart:s,onPanZoomEnd:c,onDraggingChange:h}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=e.getBoundingClientRect(),p=v_().scaleExtent([t,n]).translateExtent(l),g=wn(e).call(p);N({x:a.x,y:a.y,zoom:ga(a.zoom,t,n)},[[0,0],[m.width,m.height]],l);const b=g.on("wheel.zoom"),w=g.on("dblclick.zoom");p.wheelDelta(F_);function E(B,U){return g?new Promise(ee=>{p==null||p.interpolate((U==null?void 0:U.interpolate)==="linear"?Do:Wu).transform(kh(g,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function S({noWheelClassName:B,noPanClassName:U,onPaneContextMenu:ee,userSelectionActive:q,panOnScroll:F,panOnDrag:z,panOnScrollMode:G,panOnScrollSpeed:Q,preventScrolling:K,zoomOnPinch:D,zoomOnScroll:$,zoomOnDoubleClick:Y,zoomActivationKeyPressed:C,lib:P,onTransformChange:X,connectionInProgress:J,paneClickDistance:ne,selectionOnDrag:re}){q&&!f.isZoomingOrPanning&&_();const ue=F&&!C&&!q;p.clickDistance(re?1/0:!Un(ne)||ne<0?0:ne);const xe=ue?HA({zoomPanValues:f,noWheelClassName:B,d3Selection:g,d3Zoom:p,panOnScrollMode:G,panOnScrollSpeed:Q,zoomOnPinch:D,onPanZoomStart:s,onPanZoom:o,onPanZoomEnd:c}):BA({noWheelClassName:B,preventScrolling:K,d3ZoomHandler:b});if(g.on("wheel.zoom",xe,{passive:!1}),!q){const ye=IA({zoomPanValues:f,onDraggingChange:h,onPanZoomStart:s});p.on("start",ye);const pe=qA({zoomPanValues:f,panOnDrag:z,onPaneContextMenu:!!ee,onPanZoom:o,onTransformChange:X});p.on("zoom",pe);const Se=$A({zoomPanValues:f,panOnDrag:z,panOnScroll:F,onPaneContextMenu:ee,onPanZoomEnd:c,onDraggingChange:h});p.on("end",Se)}const be=UA({zoomActivationKeyPressed:C,panOnDrag:z,zoomOnScroll:$,panOnScroll:F,zoomOnDoubleClick:Y,zoomOnPinch:D,userSelectionActive:q,noPanClassName:U,noWheelClassName:B,lib:P,connectionInProgress:J});p.filter(be),Y?g.on("dblclick.zoom",w):g.on("dblclick.zoom",null)}function _(){p.on("zoom",null)}async function N(B,U,ee){const q=Sh(B),F=p==null?void 0:p.constrain()(q,U,ee);return F&&await E(F),new Promise(z=>z(F))}async function k(B,U){const ee=Sh(B);return await E(ee,U),new Promise(q=>q(ee))}function T(B){if(g){const U=Sh(B),ee=g.property("__zoom");(ee.k!==B.zoom||ee.x!==B.x||ee.y!==B.y)&&(p==null||p.transform(g,U,null,{sync:!0}))}}function M(){const B=g?y_(g.node()):{x:0,y:0,k:1};return{x:B.x,y:B.y,zoom:B.k}}function A(B,U){return g?new Promise(ee=>{p==null||p.interpolate((U==null?void 0:U.interpolate)==="linear"?Do:Wu).scaleTo(kh(g,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function L(B,U){return g?new Promise(ee=>{p==null||p.interpolate((U==null?void 0:U.interpolate)==="linear"?Do:Wu).scaleBy(kh(g,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function R(B){p==null||p.scaleExtent(B)}function V(B){p==null||p.translateExtent(B)}function H(B){const U=!Un(B)||B<0?0:B;p==null||p.clickDistance(U)}return{update:S,destroy:_,setViewport:k,setViewportConstrained:N,getViewport:M,scaleTo:A,scaleBy:L,setScaleExtent:R,setTranslateExtent:V,syncViewport:T,setClickDistance:H}}var va;(function(e){e.Line="line",e.Handle="handle"})(va||(va={}));function PA({width:e,prevWidth:t,height:n,prevHeight:l,affectsX:a,affectsY:o}){const s=e-t,c=n-l,h=[s>0?1:s<0?-1:0,c>0?1:c<0?-1:0];return s&&a&&(h[0]=h[0]*-1),c&&o&&(h[1]=h[1]*-1),h}function Vv(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),l=e.includes("left"),a=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:l,affectsY:a}}function gi(e,t){return Math.max(0,t-e)}function xi(e,t){return Math.max(0,e-t)}function Pu(e,t,n){return Math.max(0,t-e,e-n)}function Pv(e,t){return e?!t:t}function GA(e,t,n,l,a,o,s,c){let{affectsX:h,affectsY:f}=t;const{isHorizontal:m,isVertical:p}=t,g=m&&p,{xSnapped:b,ySnapped:w}=n,{minWidth:E,maxWidth:S,minHeight:_,maxHeight:N}=l,{x:k,y:T,width:M,height:A,aspectRatio:L}=e;let R=Math.floor(m?b-e.pointerX:0),V=Math.floor(p?w-e.pointerY:0);const H=M+(h?-R:R),B=A+(f?-V:V),U=-o[0]*M,ee=-o[1]*A;let q=Pu(H,E,S),F=Pu(B,_,N);if(s){let Q=0,K=0;h&&R<0?Q=gi(k+R+U,s[0][0]):!h&&R>0&&(Q=xi(k+H+U,s[1][0])),f&&V<0?K=gi(T+V+ee,s[0][1]):!f&&V>0&&(K=xi(T+B+ee,s[1][1])),q=Math.max(q,Q),F=Math.max(F,K)}if(c){let Q=0,K=0;h&&R>0?Q=xi(k+R,c[0][0]):!h&&R<0&&(Q=gi(k+H,c[1][0])),f&&V>0?K=xi(T+V,c[0][1]):!f&&V<0&&(K=gi(T+B,c[1][1])),q=Math.max(q,Q),F=Math.max(F,K)}if(a){if(m){const Q=Pu(H/L,_,N)*L;if(q=Math.max(q,Q),s){let K=0;!h&&!f||h&&!f&&g?K=xi(T+ee+H/L,s[1][1])*L:K=gi(T+ee+(h?R:-R)/L,s[0][1])*L,q=Math.max(q,K)}if(c){let K=0;!h&&!f||h&&!f&&g?K=gi(T+H/L,c[1][1])*L:K=xi(T+(h?R:-R)/L,c[0][1])*L,q=Math.max(q,K)}}if(p){const Q=Pu(B*L,E,S)/L;if(F=Math.max(F,Q),s){let K=0;!h&&!f||f&&!h&&g?K=xi(k+B*L+U,s[1][0])/L:K=gi(k+(f?V:-V)*L+U,s[0][0])/L,F=Math.max(F,K)}if(c){let K=0;!h&&!f||f&&!h&&g?K=gi(k+B*L,c[1][0])/L:K=xi(k+(f?V:-V)*L,c[0][0])/L,F=Math.max(F,K)}}}V=V+(V<0?F:-F),R=R+(R<0?q:-q),a&&(g?H>B*L?V=(Pv(h,f)?-R:R)/L:R=(Pv(h,f)?-V:V)*L:m?(V=R/L,f=h):(R=V*L,h=f));const z=h?k+R:k,G=f?T+V:T;return{width:M+(h?-R:R),height:A+(f?-V:V),x:o[0]*R*(h?-1:1)+z,y:o[1]*V*(f?-1:1)+G}}const Y_={width:0,height:0,x:0,y:0},FA={...Y_,pointerX:0,pointerY:0,aspectRatio:1};function YA(e){return[[0,0],[e.measured.width,e.measured.height]]}function XA(e,t,n){const l=t.position.x+e.position.x,a=t.position.y+e.position.y,o=e.measured.width??0,s=e.measured.height??0,c=n[0]*o,h=n[1]*s;return[[l-c,a-h],[l+o-c,a+s-h]]}function QA({domNode:e,nodeId:t,getStoreItems:n,onChange:l,onEnd:a}){const o=wn(e);let s={controlDirection:Vv("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:f,boundaries:m,keepAspectRatio:p,resizeDirection:g,onResizeStart:b,onResize:w,onResizeEnd:E,shouldResize:S}){let _={...Y_},N={...FA};s={boundaries:m,resizeDirection:g,keepAspectRatio:p,controlDirection:Vv(f)};let k,T=null,M=[],A,L,R,V=!1;const H=i_().on("start",B=>{const{nodeLookup:U,transform:ee,snapGrid:q,snapToGrid:F,nodeOrigin:z,paneDomNode:G}=n();if(k=U.get(t),!k)return;T=(G==null?void 0:G.getBoundingClientRect())??null;const{xSnapped:Q,ySnapped:K}=Ro(B.sourceEvent,{transform:ee,snapGrid:q,snapToGrid:F,containerBounds:T});_={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},N={..._,pointerX:Q,pointerY:K,aspectRatio:_.width/_.height},A=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(A=U.get(k.parentId),L=A&&k.extent==="parent"?YA(A):void 0),M=[],R=void 0;for(const[D,$]of U)if($.parentId===t&&(M.push({id:D,position:{...$.position},extent:$.extent}),$.extent==="parent"||$.expandParent)){const Y=XA($,k,$.origin??z);R?R=[[Math.min(Y[0][0],R[0][0]),Math.min(Y[0][1],R[0][1])],[Math.max(Y[1][0],R[1][0]),Math.max(Y[1][1],R[1][1])]]:R=Y}b==null||b(B,{..._})}).on("drag",B=>{const{transform:U,snapGrid:ee,snapToGrid:q,nodeOrigin:F}=n(),z=Ro(B.sourceEvent,{transform:U,snapGrid:ee,snapToGrid:q,containerBounds:T}),G=[];if(!k)return;const{x:Q,y:K,width:D,height:$}=_,Y={},C=k.origin??F,{width:P,height:X,x:J,y:ne}=GA(N,s.controlDirection,z,s.boundaries,s.keepAspectRatio,C,L,R),re=P!==D,ue=X!==$,xe=J!==Q&&re,be=ne!==K&&ue;if(!xe&&!be&&!re&&!ue)return;if((xe||be||C[0]===1||C[1]===1)&&(Y.x=xe?J:_.x,Y.y=be?ne:_.y,_.x=Y.x,_.y=Y.y,M.length>0)){const Oe=J-Q,je=ne-K;for(const ft of M)ft.position={x:ft.position.x-Oe+C[0]*(P-D),y:ft.position.y-je+C[1]*(X-$)},G.push(ft)}if((re||ue)&&(Y.width=re&&(!s.resizeDirection||s.resizeDirection==="horizontal")?P:_.width,Y.height=ue&&(!s.resizeDirection||s.resizeDirection==="vertical")?X:_.height,_.width=Y.width,_.height=Y.height),A&&k.expandParent){const Oe=C[0]*(Y.width??0);Y.x&&Y.x{V&&(E==null||E(B,{..._}),a==null||a({..._}),V=!1)});o.call(H)}function h(){o.on(".drag",null)}return{update:c,destroy:h}}var Eh={exports:{}},Nh={},Ch={exports:{}},jh={};/** + `})]}),y.jsx("span",{className:"text-[var(--text-muted)] font-mono whitespace-nowrap",children:PN(a,e)}),y.jsxs("span",{className:"text-[var(--text-muted)] font-mono whitespace-nowrap",children:["Event ",e,"/",t]}),y.jsx("div",{className:"flex items-center gap-0.5",children:VN.map(p=>y.jsxs("button",{onClick:()=>c(p),className:je("px-1.5 py-0.5 rounded text-xs font-mono transition-colors",l===p?"bg-[var(--accent)] text-white":"text-[var(--text-muted)] hover:text-[var(--text-secondary)] hover:bg-[var(--surface-hover)]"),children:[p,"×"]},p))})]})}const Nc=I.createContext(null);Nc.displayName="PanelGroupContext";const bt={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},vm=10,Ji=I.useLayoutEffect,lv=JE.useId,FN=typeof lv=="function"?lv:()=>null;let YN=0;function bm(e=null){const t=FN(),n=I.useRef(e||t||null);return n.current===null&&(n.current=""+YN++),e??n.current}function Nw({children:e,className:t="",collapsedSize:n,collapsible:l,defaultSize:a,forwardedRef:o,id:s,maxSize:c,minSize:h,onCollapse:f,onExpand:m,onResize:p,order:g,style:b,tagName:w="div",...E}){const S=I.useContext(Nc);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:_,expandPanel:N,getPanelSize:k,getPanelStyle:T,groupId:M,isPanelCollapsed:A,reevaluatePanelConstraints:L,registerPanel:R,resizePanel:V,unregisterPanel:H}=S,B=bm(s),U=I.useRef({callbacks:{onCollapse:f,onExpand:m,onResize:p},constraints:{collapsedSize:n,collapsible:l,defaultSize:a,maxSize:c,minSize:h},id:B,idIsFromProps:s!==void 0,order:g});I.useRef({didLogMissingDefaultSizeWarning:!1}),Ji(()=>{const{callbacks:q,constraints:F}=U.current,z={...F};U.current.id=B,U.current.idIsFromProps=s!==void 0,U.current.order=g,q.onCollapse=f,q.onExpand=m,q.onResize=p,F.collapsedSize=n,F.collapsible=l,F.defaultSize=a,F.maxSize=c,F.minSize=h,(z.collapsedSize!==F.collapsedSize||z.collapsible!==F.collapsible||z.maxSize!==F.maxSize||z.minSize!==F.minSize)&&L(U.current,z)}),Ji(()=>{const q=U.current;return R(q),()=>{H(q)}},[g,B,R,H]),I.useImperativeHandle(o,()=>({collapse:()=>{_(U.current)},expand:q=>{N(U.current,q)},getId(){return B},getSize(){return k(U.current)},isCollapsed(){return A(U.current)},isExpanded(){return!A(U.current)},resize:q=>{V(U.current,q)}}),[_,N,k,A,B,V]);const ee=T(U.current,a);return I.createElement(w,{...E,children:e,className:t,id:B,style:{...ee,...b},[bt.groupId]:M,[bt.panel]:"",[bt.panelCollapsible]:l||void 0,[bt.panelId]:B,[bt.panelSize]:parseFloat(""+ee.flexGrow).toFixed(1)})}const Co=I.forwardRef((e,t)=>I.createElement(Nw,{...e,forwardedRef:t}));Nw.displayName="Panel";Co.displayName="forwardRef(Panel)";let Vp=null,Ku=-1,vi=null;function XN(e,t){if(t){const n=(t&zw)!==0,l=(t&Mw)!==0,a=(t&Dw)!==0,o=(t&Rw)!==0;if(n)return a?"se-resize":o?"ne-resize":"e-resize";if(l)return a?"sw-resize":o?"nw-resize":"w-resize";if(a)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function QN(){vi!==null&&(document.head.removeChild(vi),Vp=null,vi=null,Ku=-1)}function hh(e,t){var n,l;const a=XN(e,t);if(Vp!==a){if(Vp=a,vi===null&&(vi=document.createElement("style"),document.head.appendChild(vi)),Ku>=0){var o;(o=vi.sheet)===null||o===void 0||o.removeRule(Ku)}Ku=(n=(l=vi.sheet)===null||l===void 0?void 0:l.insertRule(`*{cursor: ${a} !important;}`))!==null&&n!==void 0?n:-1}}function Cw(e){return e.type==="keydown"}function jw(e){return e.type.startsWith("pointer")}function Tw(e){return e.type.startsWith("mouse")}function Cc(e){if(jw(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Tw(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function ZN(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function KN(e,t,n){return e.xt.x&&e.yt.y}function JN(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:sv(e),b:sv(t)};let l;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),l=e;Be(l,"Stacking order can only be calculated for elements with a common ancestor");const a={a:ov(av(n.a)),b:ov(av(n.b))};if(a.a===a.b){const o=l.childNodes,s={a:n.a.at(-1),b:n.b.at(-1)};let c=o.length;for(;c--;){const h=o[c];if(h===s.a)return 1;if(h===s.b)return-1}}return Math.sign(a.a-a.b)}const WN=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function eC(e){var t;const n=getComputedStyle((t=Aw(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function tC(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||eC(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||WN.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function av(e){let t=e.length;for(;t--;){const n=e[t];if(Be(n,"Missing node"),tC(n))return n}return null}function ov(e){return e&&Number(getComputedStyle(e).zIndex)||0}function sv(e){const t=[];for(;e;)t.push(e),e=Aw(e);return t}function Aw(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const zw=1,Mw=2,Dw=4,Rw=8,nC=ZN()==="coarse";let Fn=[],ua=!1,Qi=new Map,jc=new Map;const Bo=new Set;function rC(e,t,n,l,a){var o;const{ownerDocument:s}=t,c={direction:n,element:t,hitAreaMargins:l,setResizeHandlerState:a},h=(o=Qi.get(s))!==null&&o!==void 0?o:0;return Qi.set(s,h+1),Bo.add(c),ac(),function(){var m;jc.delete(e),Bo.delete(c);const p=(m=Qi.get(s))!==null&&m!==void 0?m:1;if(Qi.set(s,p-1),ac(),p===1&&Qi.delete(s),Fn.includes(c)){const g=Fn.indexOf(c);g>=0&&Fn.splice(g,1),_m(),a("up",!0,null)}}}function iC(e){const{target:t}=e,{x:n,y:l}=Cc(e);ua=!0,wm({target:t,x:n,y:l}),ac(),Fn.length>0&&(oc("down",e),e.preventDefault(),Ow(t)||e.stopImmediatePropagation())}function ph(e){const{x:t,y:n}=Cc(e);if(ua&&e.buttons===0&&(ua=!1,oc("up",e)),!ua){const{target:l}=e;wm({target:l,x:t,y:n})}oc("move",e),_m(),Fn.length>0&&e.preventDefault()}function mh(e){const{target:t}=e,{x:n,y:l}=Cc(e);jc.clear(),ua=!1,Fn.length>0&&(e.preventDefault(),Ow(t)||e.stopImmediatePropagation()),oc("up",e),wm({target:t,x:n,y:l}),_m(),ac()}function Ow(e){let t=e;for(;t;){if(t.hasAttribute(bt.resizeHandle))return!0;t=t.parentElement}return!1}function wm({target:e,x:t,y:n}){Fn.splice(0);let l=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(l=e),Bo.forEach(a=>{const{element:o,hitAreaMargins:s}=a,c=o.getBoundingClientRect(),{bottom:h,left:f,right:m,top:p}=c,g=nC?s.coarse:s.fine;if(t>=f-g&&t<=m+g&&n>=p-g&&n<=h+g){if(l!==null&&document.contains(l)&&o!==l&&!o.contains(l)&&!l.contains(o)&&JN(l,o)>0){let w=l,E=!1;for(;w&&!w.contains(o);){if(KN(w.getBoundingClientRect(),c)){E=!0;break}w=w.parentElement}if(E)return}Fn.push(a)}})}function gh(e,t){jc.set(e,t)}function _m(){let e=!1,t=!1;Fn.forEach(l=>{const{direction:a}=l;a==="horizontal"?e=!0:t=!0});let n=0;jc.forEach(l=>{n|=l}),e&&t?hh("intersection",n):e?hh("horizontal",n):t?hh("vertical",n):QN()}let xh=new AbortController;function ac(){xh.abort(),xh=new AbortController;const e={capture:!0,signal:xh.signal};Bo.size&&(ua?(Fn.length>0&&Qi.forEach((t,n)=>{const{body:l}=n;t>0&&(l.addEventListener("contextmenu",mh,e),l.addEventListener("pointerleave",ph,e),l.addEventListener("pointermove",ph,e))}),window.addEventListener("pointerup",mh,e),window.addEventListener("pointercancel",mh,e)):Qi.forEach((t,n)=>{const{body:l}=n;t>0&&(l.addEventListener("pointerdown",iC,e),l.addEventListener("pointermove",ph,e))}))}function oc(e,t){Bo.forEach(n=>{const{setResizeHandlerState:l}=n,a=Fn.includes(n);l(e,a,t)})}function lC(){const[e,t]=I.useState(0);return I.useCallback(()=>t(n=>n+1),[])}function Be(e,t){if(!e)throw console.error(t),Error(t)}function tl(e,t,n=vm){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Mr(e,t,n=vm){return tl(e,t,n)===0}function bn(e,t,n){return tl(e,t,n)===0}function aC(e,t,n){if(e.length!==t.length)return!1;for(let l=0;l0&&(e=e<0?0-_:_)}}}{const p=e<0?c:h,g=n[p];Be(g,`No panel constraints found for index ${p}`);const{collapsedSize:b=0,collapsible:w,minSize:E=0}=g;if(w){const S=t[p];if(Be(S!=null,`Previous layout not found for panel index ${p}`),bn(S,E)){const _=S-b;tl(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}}{const p=e<0?1:-1;let g=e<0?h:c,b=0;for(;;){const E=t[g];Be(E!=null,`Previous layout not found for panel index ${g}`);const _=la({panelConstraints:n,panelIndex:g,size:100})-E;if(b+=_,g+=p,g<0||g>=n.length)break}const w=Math.min(Math.abs(e),Math.abs(b));e=e<0?0-w:w}{let g=e<0?c:h;for(;g>=0&&g=0))break;e<0?g--:g++}}if(aC(a,s))return a;{const p=e<0?h:c,g=t[p];Be(g!=null,`Previous layout not found for panel index ${p}`);const b=g+f,w=la({panelConstraints:n,panelIndex:p,size:b});if(s[p]=w,!bn(w,b)){let E=b-w,_=e<0?h:c;for(;_>=0&&_0?_--:_++}}}const m=s.reduce((p,g)=>g+p,0);return bn(m,100)?s:a}function oC({layout:e,panelsArray:t,pivotIndices:n}){let l=0,a=100,o=0,s=0;const c=n[0];Be(c!=null,"No pivot index found"),t.forEach((p,g)=>{const{constraints:b}=p,{maxSize:w=100,minSize:E=0}=b;g===c?(l=E,a=w):(o+=E,s+=w)});const h=Math.min(a,100-o),f=Math.max(l,100-s),m=e[c];return{valueMax:h,valueMin:f,valueNow:m}}function Io(e,t=document){return Array.from(t.querySelectorAll(`[${bt.resizeHandleId}][data-panel-group-id="${e}"]`))}function Lw(e,t,n=document){const a=Io(e,n).findIndex(o=>o.getAttribute(bt.resizeHandleId)===t);return a??null}function Hw(e,t,n){const l=Lw(e,t,n);return l!=null?[l,l+1]:[-1,-1]}function Bw(e,t=document){var n;if(t instanceof HTMLElement&&(t==null||(n=t.dataset)===null||n===void 0?void 0:n.panelGroupId)==e)return t;const l=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return l||null}function Tc(e,t=document){const n=t.querySelector(`[${bt.resizeHandleId}="${e}"]`);return n||null}function sC(e,t,n,l=document){var a,o,s,c;const h=Tc(t,l),f=Io(e,l),m=h?f.indexOf(h):-1,p=(a=(o=n[m])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null,g=(s=(c=n[m+1])===null||c===void 0?void 0:c.id)!==null&&s!==void 0?s:null;return[p,g]}function uC({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:l,panelDataArray:a,panelGroupElement:o,setLayout:s}){I.useRef({didWarnAboutMissingResizeHandle:!1}),Ji(()=>{if(!o)return;const c=Io(n,o);for(let h=0;h{c.forEach((h,f)=>{h.removeAttribute("aria-controls"),h.removeAttribute("aria-valuemax"),h.removeAttribute("aria-valuemin"),h.removeAttribute("aria-valuenow")})}},[n,l,a,o]),I.useEffect(()=>{if(!o)return;const c=t.current;Be(c,"Eager values not found");const{panelDataArray:h}=c,f=Bw(n,o);Be(f!=null,`No group found for id "${n}"`);const m=Io(n,o);Be(m,`No resize handles found for group id "${n}"`);const p=m.map(g=>{const b=g.getAttribute(bt.resizeHandleId);Be(b,"Resize handle element has no handle id attribute");const[w,E]=sC(n,b,h,o);if(w==null||E==null)return()=>{};const S=_=>{if(!_.defaultPrevented)switch(_.key){case"Enter":{_.preventDefault();const N=h.findIndex(k=>k.id===w);if(N>=0){const k=h[N];Be(k,`No panel data found for index ${N}`);const T=l[N],{collapsedSize:M=0,collapsible:A,minSize:L=0}=k.constraints;if(T!=null&&A){const R=jo({delta:bn(T,M)?L-M:M-T,initialLayout:l,panelConstraints:h.map(V=>V.constraints),pivotIndices:Hw(n,b,o),prevLayout:l,trigger:"keyboard"});l!==R&&s(R)}}break}}};return g.addEventListener("keydown",S),()=>{g.removeEventListener("keydown",S)}});return()=>{p.forEach(g=>g())}},[o,e,t,n,l,a,s])}function uv(e,t){if(e.length!==t.length)return!1;for(let n=0;no.constraints);let l=0,a=100;for(let o=0;o{const o=e[a];Be(o,`Panel data not found for index ${a}`);const{callbacks:s,constraints:c,id:h}=o,{collapsedSize:f=0,collapsible:m}=c,p=n[h];if(p==null||l!==p){n[h]=l;const{onCollapse:g,onExpand:b,onResize:w}=s;w&&w(l,p),m&&(g||b)&&(b&&(p==null||Mr(p,f))&&!Mr(l,f)&&b(),g&&(p==null||!Mr(p,f))&&Mr(l,f)&&g())}})}function Hu(e,t){if(e.length!==t.length)return!1;for(let n=0;n{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...a)},t)}}function cv(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function qw(e){return`react-resizable-panels:${e}`}function $w(e){return e.map(t=>{const{constraints:n,id:l,idIsFromProps:a,order:o}=t;return a?l:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function Uw(e,t){try{const n=qw(e),l=t.getItem(n);if(l){const a=JSON.parse(l);if(typeof a=="object"&&a!=null)return a}}catch{}return null}function mC(e,t,n){var l,a;const o=(l=Uw(e,n))!==null&&l!==void 0?l:{},s=$w(t);return(a=o[s])!==null&&a!==void 0?a:null}function gC(e,t,n,l,a){var o;const s=qw(e),c=$w(t),h=(o=Uw(e,a))!==null&&o!==void 0?o:{};h[c]={expandToSizes:Object.fromEntries(n.entries()),layout:l};try{a.setItem(s,JSON.stringify(h))}catch(f){console.error(f)}}function fv({layout:e,panelConstraints:t}){const n=[...e],l=n.reduce((o,s)=>o+s,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!bn(l,100)&&n.length>0)for(let o=0;o(cv(To),To.getItem(e)),setItem:(e,t)=>{cv(To),To.setItem(e,t)}},dv={};function Vw({autoSaveId:e=null,children:t,className:n="",direction:l,forwardedRef:a,id:o=null,onLayout:s=null,keyboardResizeBy:c=null,storage:h=To,style:f,tagName:m="div",...p}){const g=bm(o),b=I.useRef(null),[w,E]=I.useState(null),[S,_]=I.useState([]),N=lC(),k=I.useRef({}),T=I.useRef(new Map),M=I.useRef(0),A=I.useRef({autoSaveId:e,direction:l,dragState:w,id:g,keyboardResizeBy:c,onLayout:s,storage:h}),L=I.useRef({layout:S,panelDataArray:[],panelDataArrayChanged:!1});I.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),I.useImperativeHandle(a,()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:C}=L.current;return C},setLayout:C=>{const{onLayout:P}=A.current,{layout:X,panelDataArray:J}=L.current,ne=fv({layout:C,panelConstraints:J.map(re=>re.constraints)});uv(X,ne)||(_(ne),L.current.layout=ne,P&&P(ne),Jl(J,ne,k.current))}}),[]),Ji(()=>{A.current.autoSaveId=e,A.current.direction=l,A.current.dragState=w,A.current.id=g,A.current.onLayout=s,A.current.storage=h}),uC({committedValuesRef:A,eagerValuesRef:L,groupId:g,layout:S,panelDataArray:L.current.panelDataArray,setLayout:_,panelGroupElement:b.current}),I.useEffect(()=>{const{panelDataArray:C}=L.current;if(e){if(S.length===0||S.length!==C.length)return;let P=dv[e];P==null&&(P=pC(gC,xC),dv[e]=P);const X=[...C],J=new Map(T.current);P(e,X,J,S,h)}},[e,S,h]),I.useEffect(()=>{});const R=I.useCallback(C=>{const{onLayout:P}=A.current,{layout:X,panelDataArray:J}=L.current;if(C.constraints.collapsible){const ne=J.map(be=>be.constraints),{collapsedSize:re=0,panelSize:ue,pivotIndices:xe}=Gi(J,C,X);if(Be(ue!=null,`Panel size not found for panel "${C.id}"`),!Mr(ue,re)){T.current.set(C.id,ue);const ye=na(J,C)===J.length-1?ue-re:re-ue,pe=jo({delta:ye,initialLayout:X,panelConstraints:ne,pivotIndices:xe,prevLayout:X,trigger:"imperative-api"});Hu(X,pe)||(_(pe),L.current.layout=pe,P&&P(pe),Jl(J,pe,k.current))}}},[]),V=I.useCallback((C,P)=>{const{onLayout:X}=A.current,{layout:J,panelDataArray:ne}=L.current;if(C.constraints.collapsible){const re=ne.map(Se=>Se.constraints),{collapsedSize:ue=0,panelSize:xe=0,minSize:be=0,pivotIndices:ye}=Gi(ne,C,J),pe=P??be;if(Mr(xe,ue)){const Se=T.current.get(C.id),Oe=Se!=null&&Se>=pe?Se:pe,ft=na(ne,C)===ne.length-1?xe-Oe:Oe-xe,rt=jo({delta:ft,initialLayout:J,panelConstraints:re,pivotIndices:ye,prevLayout:J,trigger:"imperative-api"});Hu(J,rt)||(_(rt),L.current.layout=rt,X&&X(rt),Jl(ne,rt,k.current))}}},[]),H=I.useCallback(C=>{const{layout:P,panelDataArray:X}=L.current,{panelSize:J}=Gi(X,C,P);return Be(J!=null,`Panel size not found for panel "${C.id}"`),J},[]),B=I.useCallback((C,P)=>{const{panelDataArray:X}=L.current,J=na(X,C);return hC({defaultSize:P,dragState:w,layout:S,panelData:X,panelIndex:J})},[w,S]),U=I.useCallback(C=>{const{layout:P,panelDataArray:X}=L.current,{collapsedSize:J=0,collapsible:ne,panelSize:re}=Gi(X,C,P);return Be(re!=null,`Panel size not found for panel "${C.id}"`),ne===!0&&Mr(re,J)},[]),ee=I.useCallback(C=>{const{layout:P,panelDataArray:X}=L.current,{collapsedSize:J=0,collapsible:ne,panelSize:re}=Gi(X,C,P);return Be(re!=null,`Panel size not found for panel "${C.id}"`),!ne||tl(re,J)>0},[]),q=I.useCallback(C=>{const{panelDataArray:P}=L.current;P.push(C),P.sort((X,J)=>{const ne=X.order,re=J.order;return ne==null&&re==null?0:ne==null?-1:re==null?1:ne-re}),L.current.panelDataArrayChanged=!0,N()},[N]);Ji(()=>{if(L.current.panelDataArrayChanged){L.current.panelDataArrayChanged=!1;const{autoSaveId:C,onLayout:P,storage:X}=A.current,{layout:J,panelDataArray:ne}=L.current;let re=null;if(C){const xe=mC(C,ne,X);xe&&(T.current=new Map(Object.entries(xe.expandToSizes)),re=xe.layout)}re==null&&(re=dC({panelDataArray:ne}));const ue=fv({layout:re,panelConstraints:ne.map(xe=>xe.constraints)});uv(J,ue)||(_(ue),L.current.layout=ue,P&&P(ue),Jl(ne,ue,k.current))}}),Ji(()=>{const C=L.current;return()=>{C.layout=[]}},[]);const F=I.useCallback(C=>{let P=!1;const X=b.current;return X&&window.getComputedStyle(X,null).getPropertyValue("direction")==="rtl"&&(P=!0),function(ne){ne.preventDefault();const re=b.current;if(!re)return()=>null;const{direction:ue,dragState:xe,id:be,keyboardResizeBy:ye,onLayout:pe}=A.current,{layout:Se,panelDataArray:Oe}=L.current,{initialLayout:Te}=xe??{},ft=Hw(be,C,re);let rt=fC(ne,C,ue,xe,ye,re);const Dt=ue==="horizontal";Dt&&P&&(rt=-rt);const Pt=Oe.map(On=>On.constraints),Bt=jo({delta:rt,initialLayout:Te??Se,panelConstraints:Pt,pivotIndices:ft,prevLayout:Se,trigger:Cw(ne)?"keyboard":"mouse-or-touch"}),kn=!Hu(Se,Bt);(jw(ne)||Tw(ne))&&M.current!=rt&&(M.current=rt,!kn&&rt!==0?Dt?gh(C,rt<0?zw:Mw):gh(C,rt<0?Dw:Rw):gh(C,0)),kn&&(_(Bt),L.current.layout=Bt,pe&&pe(Bt),Jl(Oe,Bt,k.current))}},[]),z=I.useCallback((C,P)=>{const{onLayout:X}=A.current,{layout:J,panelDataArray:ne}=L.current,re=ne.map(Se=>Se.constraints),{panelSize:ue,pivotIndices:xe}=Gi(ne,C,J);Be(ue!=null,`Panel size not found for panel "${C.id}"`);const ye=na(ne,C)===ne.length-1?ue-P:P-ue,pe=jo({delta:ye,initialLayout:J,panelConstraints:re,pivotIndices:xe,prevLayout:J,trigger:"imperative-api"});Hu(J,pe)||(_(pe),L.current.layout=pe,X&&X(pe),Jl(ne,pe,k.current))},[]),G=I.useCallback((C,P)=>{const{layout:X,panelDataArray:J}=L.current,{collapsedSize:ne=0,collapsible:re}=P,{collapsedSize:ue=0,collapsible:xe,maxSize:be=100,minSize:ye=0}=C.constraints,{panelSize:pe}=Gi(J,C,X);pe!=null&&(re&&xe&&Mr(pe,ne)?Mr(ne,ue)||z(C,ue):pebe&&z(C,be))},[z]),Q=I.useCallback((C,P)=>{const{direction:X}=A.current,{layout:J}=L.current;if(!b.current)return;const ne=Tc(C,b.current);Be(ne,`Drag handle element not found for id "${C}"`);const re=Iw(X,P);E({dragHandleId:C,dragHandleRect:ne.getBoundingClientRect(),initialCursorPosition:re,initialLayout:J})},[]),K=I.useCallback(()=>{E(null)},[]),D=I.useCallback(C=>{const{panelDataArray:P}=L.current,X=na(P,C);X>=0&&(P.splice(X,1),delete k.current[C.id],L.current.panelDataArrayChanged=!0,N())},[N]),$=I.useMemo(()=>({collapsePanel:R,direction:l,dragState:w,expandPanel:V,getPanelSize:H,getPanelStyle:B,groupId:g,isPanelCollapsed:U,isPanelExpanded:ee,reevaluatePanelConstraints:G,registerPanel:q,registerResizeHandle:F,resizePanel:z,startDragging:Q,stopDragging:K,unregisterPanel:D,panelGroupElement:b.current}),[R,w,l,V,H,B,g,U,ee,G,q,F,z,Q,K,D]),Y={display:"flex",flexDirection:l==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return I.createElement(Nc.Provider,{value:$},I.createElement(m,{...p,children:t,className:n,id:o,ref:b,style:{...Y,...f},[bt.group]:"",[bt.groupDirection]:l,[bt.groupId]:g}))}const Pp=I.forwardRef((e,t)=>I.createElement(Vw,{...e,forwardedRef:t}));Vw.displayName="PanelGroup";Pp.displayName="forwardRef(PanelGroup)";function na(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Gi(e,t,n){const l=na(e,t),o=l===e.length-1?[l-1,l]:[l,l+1],s=n[l];return{...t.constraints,panelSize:s,pivotIndices:o}}function yC({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:l}){I.useEffect(()=>{if(e||n==null||l==null)return;const a=Tc(t,l);if(a==null)return;const o=s=>{if(!s.defaultPrevented)switch(s.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{s.preventDefault(),n(s);break}case"F6":{s.preventDefault();const c=a.getAttribute(bt.groupId);Be(c,`No group element found for id "${c}"`);const h=Io(c,l),f=Lw(c,t,l);Be(f!==null,`No resize element found for id "${t}"`);const m=s.shiftKey?f>0?f-1:h.length-1:f+1{a.removeEventListener("keydown",o)}},[l,e,t,n])}function Gp({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:l,id:a,onBlur:o,onClick:s,onDragging:c,onFocus:h,onPointerDown:f,onPointerUp:m,style:p={},tabIndex:g=0,tagName:b="div",...w}){var E,S;const _=I.useRef(null),N=I.useRef({onClick:s,onDragging:c,onPointerDown:f,onPointerUp:m});I.useEffect(()=>{N.current.onClick=s,N.current.onDragging=c,N.current.onPointerDown=f,N.current.onPointerUp=m});const k=I.useContext(Nc);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:T,groupId:M,registerResizeHandle:A,startDragging:L,stopDragging:R,panelGroupElement:V}=k,H=bm(a),[B,U]=I.useState("inactive"),[ee,q]=I.useState(!1),[F,z]=I.useState(null),G=I.useRef({state:B});Ji(()=>{G.current.state=B}),I.useEffect(()=>{if(n)z(null);else{const $=A(H);z(()=>$)}},[n,H,A]);const Q=(E=l==null?void 0:l.coarse)!==null&&E!==void 0?E:15,K=(S=l==null?void 0:l.fine)!==null&&S!==void 0?S:5;I.useEffect(()=>{if(n||F==null)return;const $=_.current;Be($,"Element ref not attached");let Y=!1;return rC(H,$,T,{coarse:Q,fine:K},(P,X,J)=>{if(!X){U("inactive");return}switch(P){case"down":{U("drag"),Y=!1,Be(J,'Expected event to be defined for "down" action'),L(H,J);const{onDragging:ne,onPointerDown:re}=N.current;ne==null||ne(!0),re==null||re();break}case"move":{const{state:ne}=G.current;Y=!0,ne!=="drag"&&U("hover"),Be(J,'Expected event to be defined for "move" action'),F(J);break}case"up":{U("hover"),R();const{onClick:ne,onDragging:re,onPointerUp:ue}=N.current;re==null||re(!1),ue==null||ue(),Y||ne==null||ne();break}}})},[Q,T,n,K,A,H,F,L,R]),yC({disabled:n,handleId:H,resizeHandler:F,panelGroupElement:V});const D={touchAction:"none",userSelect:"none"};return I.createElement(b,{...w,children:e,className:t,id:a,onBlur:()=>{q(!1),o==null||o()},onFocus:()=>{q(!0),h==null||h()},ref:_,role:"separator",style:{...D,...p},tabIndex:g,[bt.groupDirection]:T,[bt.groupId]:M,[bt.resizeHandle]:"",[bt.resizeHandleActive]:B==="drag"?"pointer":ee?"keyboard":void 0,[bt.resizeHandleEnabled]:!n,[bt.resizeHandleId]:H,[bt.resizeHandleState]:B})}Gp.displayName="PanelResizeHandle";function Mt(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,l;n{}};function Ac(){for(var e=0,t=arguments.length,n={},l;e=0&&(l=n.slice(a+1),n=n.slice(0,a)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:l}})}Ju.prototype=Ac.prototype={constructor:Ju,on:function(e,t){var n=this._,l=bC(e+"",n),a,o=-1,s=l.length;if(arguments.length<2){for(;++o0)for(var n=new Array(a),l=0,a,o;l=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),pv.hasOwnProperty(t)?{space:pv[t],local:e}:e}function _C(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Fp&&t.documentElement.namespaceURI===Fp?t.createElement(e):t.createElementNS(n,e)}}function SC(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Pw(e){var t=zc(e);return(t.local?SC:_C)(t)}function kC(){}function Sm(e){return e==null?kC:function(){return this.querySelector(e)}}function EC(e){typeof e!="function"&&(e=Sm(e));for(var t=this._groups,n=t.length,l=new Array(n),a=0;a=k&&(k=N+1);!(M=S[k])&&++k=0;)(s=l[a])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function ZC(e){e||(e=KC);function t(p,g){return p&&g?e(p.__data__,g.__data__):!p-!g}for(var n=this._groups,l=n.length,a=new Array(l),o=0;ot?1:e>=t?0:NaN}function JC(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function WC(){return Array.from(this)}function ej(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?fj:typeof t=="function"?hj:dj)(e,t,n??"")):pa(this.node(),e)}function pa(e,t){return e.style.getPropertyValue(t)||Qw(e).getComputedStyle(e,null).getPropertyValue(t)}function mj(e){return function(){delete this[e]}}function gj(e,t){return function(){this[e]=t}}function xj(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function yj(e,t){return arguments.length>1?this.each((t==null?mj:typeof t=="function"?xj:gj)(e,t)):this.node()[e]}function Zw(e){return e.trim().split(/^|\s+/)}function km(e){return e.classList||new Kw(e)}function Kw(e){this._node=e,this._names=Zw(e.getAttribute("class")||"")}Kw.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Jw(e,t){for(var n=km(e),l=-1,a=t.length;++l=0&&(n=t.slice(l+1),t=t.slice(0,l)),{type:t,name:n}})}function Fj(e){return function(){var t=this.__on;if(t){for(var n=0,l=-1,a=t.length,o;n()=>e;function Yp(e,{sourceEvent:t,subject:n,target:l,identifier:a,active:o,x:s,y:c,dx:h,dy:f,dispatch:m}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:l,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:h,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:m}})}Yp.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function n3(e){return!e.ctrlKey&&!e.button}function r3(){return this.parentNode}function i3(e,t){return t??{x:e.x,y:e.y}}function l3(){return navigator.maxTouchPoints||"ontouchstart"in this}function i_(){var e=n3,t=r3,n=i3,l=l3,a={},o=Ac("start","drag","end"),s=0,c,h,f,m,p=0;function g(T){T.on("mousedown.drag",b).filter(l).on("touchstart.drag",S).on("touchmove.drag",_,t3).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(T,M){if(!(m||!e.call(this,T,M))){var A=k(this,t.call(this,T,M),T,M,"mouse");A&&(wn(T.view).on("mousemove.drag",w,qo).on("mouseup.drag",E,qo),n_(T.view),yh(T),f=!1,c=T.clientX,h=T.clientY,A("start",T))}}function w(T){if(ca(T),!f){var M=T.clientX-c,A=T.clientY-h;f=M*M+A*A>p}a.mouse("drag",T)}function E(T){wn(T.view).on("mousemove.drag mouseup.drag",null),r_(T.view,f),ca(T),a.mouse("end",T)}function S(T,M){if(e.call(this,T,M)){var A=T.changedTouches,L=t.call(this,T,M),R=A.length,V,H;for(V=0;V>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Iu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Iu(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=o3.exec(e))?new un(t[1],t[2],t[3],1):(t=s3.exec(e))?new un(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=u3.exec(e))?Iu(t[1],t[2],t[3],t[4]):(t=c3.exec(e))?Iu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=f3.exec(e))?wv(t[1],t[2]/100,t[3]/100,1):(t=d3.exec(e))?wv(t[1],t[2]/100,t[3]/100,t[4]):mv.hasOwnProperty(e)?yv(mv[e]):e==="transparent"?new un(NaN,NaN,NaN,0):null}function yv(e){return new un(e>>16&255,e>>8&255,e&255,1)}function Iu(e,t,n,l){return l<=0&&(e=t=n=NaN),new un(e,t,n,l)}function m3(e){return e instanceof es||(e=nl(e)),e?(e=e.rgb(),new un(e.r,e.g,e.b,e.opacity)):new un}function Xp(e,t,n,l){return arguments.length===1?m3(e):new un(e,t,n,l??1)}function un(e,t,n,l){this.r=+e,this.g=+t,this.b=+n,this.opacity=+l}Em(un,Xp,l_(es,{brighter(e){return e=e==null?uc:Math.pow(uc,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?$o:Math.pow($o,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new un(Wi(this.r),Wi(this.g),Wi(this.b),cc(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:vv,formatHex:vv,formatHex8:g3,formatRgb:bv,toString:bv}));function vv(){return`#${Zi(this.r)}${Zi(this.g)}${Zi(this.b)}`}function g3(){return`#${Zi(this.r)}${Zi(this.g)}${Zi(this.b)}${Zi((isNaN(this.opacity)?1:this.opacity)*255)}`}function bv(){const e=cc(this.opacity);return`${e===1?"rgb(":"rgba("}${Wi(this.r)}, ${Wi(this.g)}, ${Wi(this.b)}${e===1?")":`, ${e})`}`}function cc(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Wi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Zi(e){return e=Wi(e),(e<16?"0":"")+e.toString(16)}function wv(e,t,n,l){return l<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Un(e,t,n,l)}function a_(e){if(e instanceof Un)return new Un(e.h,e.s,e.l,e.opacity);if(e instanceof es||(e=nl(e)),!e)return new Un;if(e instanceof Un)return e;e=e.rgb();var t=e.r/255,n=e.g/255,l=e.b/255,a=Math.min(t,n,l),o=Math.max(t,n,l),s=NaN,c=o-a,h=(o+a)/2;return c?(t===o?s=(n-l)/c+(n0&&h<1?0:s,new Un(s,c,h,e.opacity)}function x3(e,t,n,l){return arguments.length===1?a_(e):new Un(e,t,n,l??1)}function Un(e,t,n,l){this.h=+e,this.s=+t,this.l=+n,this.opacity=+l}Em(Un,x3,l_(es,{brighter(e){return e=e==null?uc:Math.pow(uc,e),new Un(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?$o:Math.pow($o,e),new Un(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,l=n+(n<.5?n:1-n)*t,a=2*n-l;return new un(vh(e>=240?e-240:e+120,a,l),vh(e,a,l),vh(e<120?e+240:e-120,a,l),this.opacity)},clamp(){return new Un(_v(this.h),qu(this.s),qu(this.l),cc(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=cc(this.opacity);return`${e===1?"hsl(":"hsla("}${_v(this.h)}, ${qu(this.s)*100}%, ${qu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _v(e){return e=(e||0)%360,e<0?e+360:e}function qu(e){return Math.max(0,Math.min(1,e||0))}function vh(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Nm=e=>()=>e;function y3(e,t){return function(n){return e+n*t}}function v3(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(l){return Math.pow(e+l*t,n)}}function b3(e){return(e=+e)==1?o_:function(t,n){return n-t?v3(t,n,e):Nm(isNaN(t)?n:t)}}function o_(e,t){var n=t-e;return n?y3(e,n):Nm(isNaN(e)?t:e)}const fc=(function e(t){var n=b3(t);function l(a,o){var s=n((a=Xp(a)).r,(o=Xp(o)).r),c=n(a.g,o.g),h=n(a.b,o.b),f=o_(a.opacity,o.opacity);return function(m){return a.r=s(m),a.g=c(m),a.b=h(m),a.opacity=f(m),a+""}}return l.gamma=e,l})(1);function w3(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,l=t.slice(),a;return function(o){for(a=0;an&&(o=t.slice(n,o),c[s]?c[s]+=o:c[++s]=o),(l=l[0])===(a=a[0])?c[s]?c[s]+=a:c[++s]=a:(c[++s]=null,h.push({i:s,x:ir(l,a)})),n=bh.lastIndex;return n180?m+=360:m-f>180&&(f+=360),g.push({i:p.push(a(p)+"rotate(",null,l)-2,x:ir(f,m)})):m&&p.push(a(p)+"rotate("+m+l)}function c(f,m,p,g){f!==m?g.push({i:p.push(a(p)+"skewX(",null,l)-2,x:ir(f,m)}):m&&p.push(a(p)+"skewX("+m+l)}function h(f,m,p,g,b,w){if(f!==p||m!==g){var E=b.push(a(b)+"scale(",null,",",null,")");w.push({i:E-4,x:ir(f,p)},{i:E-2,x:ir(m,g)})}else(p!==1||g!==1)&&b.push(a(b)+"scale("+p+","+g+")")}return function(f,m){var p=[],g=[];return f=e(f),m=e(m),o(f.translateX,f.translateY,m.translateX,m.translateY,p,g),s(f.rotate,m.rotate,p,g),c(f.skewX,m.skewX,p,g),h(f.scaleX,f.scaleY,m.scaleX,m.scaleY,p,g),f=m=null,function(b){for(var w=-1,E=g.length,S;++w=0&&e._call.call(void 0,t),e=e._next;--ma}function Ev(){rl=(hc=Vo.now())+Mc,ma=Ao=0;try{L3()}finally{ma=0,B3(),rl=0}}function H3(){var e=Vo.now(),t=e-hc;t>f_&&(Mc-=t,hc=e)}function B3(){for(var e,t=dc,n,l=1/0;t;)t._call?(l>t._time&&(l=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:dc=n);zo=e,Kp(l)}function Kp(e){if(!ma){Ao&&(Ao=clearTimeout(Ao));var t=e-rl;t>24?(e<1/0&&(Ao=setTimeout(Ev,e-Vo.now()-Mc)),wo&&(wo=clearInterval(wo))):(wo||(hc=Vo.now(),wo=setInterval(H3,f_)),ma=1,d_(Ev))}}function Nv(e,t,n){var l=new pc;return t=t==null?0:+t,l.restart(a=>{l.stop(),e(a+t)},t,n),l}var I3=Ac("start","end","cancel","interrupt"),q3=[],p_=0,Cv=1,Jp=2,ec=3,jv=4,Wp=5,tc=6;function Dc(e,t,n,l,a,o){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;$3(e,n,{name:t,index:l,group:a,on:I3,tween:q3,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:p_})}function jm(e,t){var n=Qn(e,t);if(n.state>p_)throw new Error("too late; already scheduled");return n}function or(e,t){var n=Qn(e,t);if(n.state>ec)throw new Error("too late; already running");return n}function Qn(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function $3(e,t,n){var l=e.__transition,a;l[t]=n,n.timer=h_(o,0,n.time);function o(f){n.state=Cv,n.timer.restart(s,n.delay,n.time),n.delay<=f&&s(f-n.delay)}function s(f){var m,p,g,b;if(n.state!==Cv)return h();for(m in l)if(b=l[m],b.name===n.name){if(b.state===ec)return Nv(s);b.state===jv?(b.state=tc,b.timer.stop(),b.on.call("interrupt",e,e.__data__,b.index,b.group),delete l[m]):+mJp&&l.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function xT(e,t,n){var l,a,o=gT(t)?jm:or;return function(){var s=o(this,e),c=s.on;c!==l&&(a=(l=c).copy()).on(t,n),s.on=a}}function yT(e,t){var n=this._id;return arguments.length<2?Qn(this.node(),n).on.on(e):this.each(xT(n,e,t))}function vT(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function bT(){return this.on("end.remove",vT(this._id))}function wT(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Sm(e));for(var l=this._groups,a=l.length,o=new Array(a),s=0;s()=>e;function FT(e,{sourceEvent:t,target:n,transform:l,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:a}})}function Dr(e,t,n){this.k=e,this.x=t,this.y=n}Dr.prototype={constructor:Dr,scale:function(e){return e===1?this:new Dr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Dr(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Rc=new Dr(1,0,0);y_.prototype=Dr.prototype;function y_(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Rc;return e.__zoom}function wh(e){e.stopImmediatePropagation()}function _o(e){e.preventDefault(),e.stopImmediatePropagation()}function YT(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function XT(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Tv(){return this.__zoom||Rc}function QT(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ZT(){return navigator.maxTouchPoints||"ontouchstart"in this}function KT(e,t,n){var l=e.invertX(t[0][0])-n[0][0],a=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(a>l?(l+a)/2:Math.min(0,l)||Math.max(0,a),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}function v_(){var e=YT,t=XT,n=KT,l=QT,a=ZT,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],c=250,h=Wu,f=Ac("start","zoom","end"),m,p,g,b=500,w=150,E=0,S=10;function _(q){q.property("__zoom",Tv).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",V).on("dblclick.zoom",H).filter(a).on("touchstart.zoom",B).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",ee).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(q,F,z,G){var Q=q.selection?q.selection():q;Q.property("__zoom",Tv),q!==Q?M(q,F,z,G):Q.interrupt().each(function(){A(this,arguments).event(G).start().zoom(null,typeof F=="function"?F.apply(this,arguments):F).end()})},_.scaleBy=function(q,F,z,G){_.scaleTo(q,function(){var Q=this.__zoom.k,K=typeof F=="function"?F.apply(this,arguments):F;return Q*K},z,G)},_.scaleTo=function(q,F,z,G){_.transform(q,function(){var Q=t.apply(this,arguments),K=this.__zoom,D=z==null?T(Q):typeof z=="function"?z.apply(this,arguments):z,$=K.invert(D),Y=typeof F=="function"?F.apply(this,arguments):F;return n(k(N(K,Y),D,$),Q,s)},z,G)},_.translateBy=function(q,F,z,G){_.transform(q,function(){return n(this.__zoom.translate(typeof F=="function"?F.apply(this,arguments):F,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),s)},null,G)},_.translateTo=function(q,F,z,G,Q){_.transform(q,function(){var K=t.apply(this,arguments),D=this.__zoom,$=G==null?T(K):typeof G=="function"?G.apply(this,arguments):G;return n(Rc.translate($[0],$[1]).scale(D.k).translate(typeof F=="function"?-F.apply(this,arguments):-F,typeof z=="function"?-z.apply(this,arguments):-z),K,s)},G,Q)};function N(q,F){return F=Math.max(o[0],Math.min(o[1],F)),F===q.k?q:new Dr(F,q.x,q.y)}function k(q,F,z){var G=F[0]-z[0]*q.k,Q=F[1]-z[1]*q.k;return G===q.x&&Q===q.y?q:new Dr(q.k,G,Q)}function T(q){return[(+q[0][0]+ +q[1][0])/2,(+q[0][1]+ +q[1][1])/2]}function M(q,F,z,G){q.on("start.zoom",function(){A(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(G).end()}).tween("zoom",function(){var Q=this,K=arguments,D=A(Q,K).event(G),$=t.apply(Q,K),Y=z==null?T($):typeof z=="function"?z.apply(Q,K):z,C=Math.max($[1][0]-$[0][0],$[1][1]-$[0][1]),P=Q.__zoom,X=typeof F=="function"?F.apply(Q,K):F,J=h(P.invert(Y).concat(C/P.k),X.invert(Y).concat(C/X.k));return function(ne){if(ne===1)ne=X;else{var re=J(ne),ue=C/re[2];ne=new Dr(ue,Y[0]-re[0]*ue,Y[1]-re[1]*ue)}D.zoom(null,ne)}})}function A(q,F,z){return!z&&q.__zooming||new L(q,F)}function L(q,F){this.that=q,this.args=F,this.active=0,this.sourceEvent=null,this.extent=t.apply(q,F),this.taps=0}L.prototype={event:function(q){return q&&(this.sourceEvent=q),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(q,F){return this.mouse&&q!=="mouse"&&(this.mouse[1]=F.invert(this.mouse[0])),this.touch0&&q!=="touch"&&(this.touch0[1]=F.invert(this.touch0[0])),this.touch1&&q!=="touch"&&(this.touch1[1]=F.invert(this.touch1[0])),this.that.__zoom=F,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(q){var F=wn(this.that).datum();f.call(q,this.that,new FT(q,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:f}),F)}};function R(q,...F){if(!e.apply(this,arguments))return;var z=A(this,F).event(q),G=this.__zoom,Q=Math.max(o[0],Math.min(o[1],G.k*Math.pow(2,l.apply(this,arguments)))),K=$n(q);if(z.wheel)(z.mouse[0][0]!==K[0]||z.mouse[0][1]!==K[1])&&(z.mouse[1]=G.invert(z.mouse[0]=K)),clearTimeout(z.wheel);else{if(G.k===Q)return;z.mouse=[K,G.invert(K)],nc(this),z.start()}_o(q),z.wheel=setTimeout(D,w),z.zoom("mouse",n(k(N(G,Q),z.mouse[0],z.mouse[1]),z.extent,s));function D(){z.wheel=null,z.end()}}function V(q,...F){if(g||!e.apply(this,arguments))return;var z=q.currentTarget,G=A(this,F,!0).event(q),Q=wn(q.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",C,!0),K=$n(q,z),D=q.clientX,$=q.clientY;n_(q.view),wh(q),G.mouse=[K,this.__zoom.invert(K)],nc(this),G.start();function Y(P){if(_o(P),!G.moved){var X=P.clientX-D,J=P.clientY-$;G.moved=X*X+J*J>E}G.event(P).zoom("mouse",n(k(G.that.__zoom,G.mouse[0]=$n(P,z),G.mouse[1]),G.extent,s))}function C(P){Q.on("mousemove.zoom mouseup.zoom",null),r_(P.view,G.moved),_o(P),G.event(P).end()}}function H(q,...F){if(e.apply(this,arguments)){var z=this.__zoom,G=$n(q.changedTouches?q.changedTouches[0]:q,this),Q=z.invert(G),K=z.k*(q.shiftKey?.5:2),D=n(k(N(z,K),G,Q),t.apply(this,F),s);_o(q),c>0?wn(this).transition().duration(c).call(M,D,G,q):wn(this).call(_.transform,D,G,q)}}function B(q,...F){if(e.apply(this,arguments)){var z=q.touches,G=z.length,Q=A(this,F,q.changedTouches.length===G).event(q),K,D,$,Y;for(wh(q),D=0;D"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:l})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:l}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Po=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],b_=["Enter"," ","Escape"],w_={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var ga;(function(e){e.Strict="strict",e.Loose="loose"})(ga||(ga={}));var el;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(el||(el={}));var Go;(function(e){e.Partial="partial",e.Full="full"})(Go||(Go={}));const __={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var bi;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(bi||(bi={}));var mc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(mc||(mc={}));var ve;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ve||(ve={}));const Av={[ve.Left]:ve.Right,[ve.Right]:ve.Left,[ve.Top]:ve.Bottom,[ve.Bottom]:ve.Top};function S_(e){return e===null?null:e?"valid":"invalid"}const k_=e=>"id"in e&&"source"in e&&"target"in e,JT=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Am=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),ts=(e,t=[0,0])=>{const{width:n,height:l}=Hr(e),a=e.origin??t,o=n*a[0],s=l*a[1];return{x:e.position.x-o,y:e.position.y-s}},WT=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((l,a)=>{const o=typeof a=="string";let s=!t.nodeLookup&&!o?a:void 0;t.nodeLookup&&(s=o?t.nodeLookup.get(a):Am(a)?a:t.nodeLookup.get(a.id));const c=s?gc(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Oc(l,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Lc(n)},ns=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},l=!1;return e.forEach(a=>{(t.filter===void 0||t.filter(a))&&(n=Oc(n,gc(a)),l=!0)}),l?Lc(n):{x:0,y:0,width:0,height:0}},zm=(e,t,[n,l,a]=[0,0,1],o=!1,s=!1)=>{const c={...is(t,[n,l,a]),width:t.width/a,height:t.height/a},h=[];for(const f of e.values()){const{measured:m,selectable:p=!0,hidden:g=!1}=f;if(s&&!p||g)continue;const b=m.width??f.width??f.initialWidth??null,w=m.height??f.height??f.initialHeight??null,E=Fo(c,ya(f)),S=(b??0)*(w??0),_=o&&E>0;(!f.internals.handleBounds||_||E>=S||f.dragging)&&h.push(f)}return h},eA=(e,t)=>{const n=new Set;return e.forEach(l=>{n.add(l.id)}),t.filter(l=>n.has(l.source)||n.has(l.target))};function tA(e,t){const n=new Map,l=t!=null&&t.nodes?new Set(t.nodes.map(a=>a.id)):null;return e.forEach(a=>{a.measured.width&&a.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!a.hidden)&&(!l||l.has(a.id))&&n.set(a.id,a)}),n}async function nA({nodes:e,width:t,height:n,panZoom:l,minZoom:a,maxZoom:o},s){if(e.size===0)return Promise.resolve(!0);const c=tA(e,s),h=ns(c),f=Mm(h,t,n,(s==null?void 0:s.minZoom)??a,(s==null?void 0:s.maxZoom)??o,(s==null?void 0:s.padding)??.1);return await l.setViewport(f,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function E_({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:l=[0,0],nodeExtent:a,onError:o}){const s=n.get(e),c=s.parentId?n.get(s.parentId):void 0,{x:h,y:f}=c?c.internals.positionAbsolute:{x:0,y:0},m=s.origin??l;let p=s.extent||a;if(s.extent==="parent"&&!s.expandParent)if(!c)o==null||o("005",ar.error005());else{const b=c.measured.width,w=c.measured.height;b&&w&&(p=[[h,f],[h+b,f+w]])}else c&&va(s.extent)&&(p=[[s.extent[0][0]+h,s.extent[0][1]+f],[s.extent[1][0]+h,s.extent[1][1]+f]]);const g=va(p)?il(t,p,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(o==null||o("015",ar.error015())),{position:{x:g.x-h+(s.measured.width??0)*m[0],y:g.y-f+(s.measured.height??0)*m[1]},positionAbsolute:g}}async function rA({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:l,onBeforeDelete:a}){const o=new Set(e.map(g=>g.id)),s=[];for(const g of n){if(g.deletable===!1)continue;const b=o.has(g.id),w=!b&&g.parentId&&s.find(E=>E.id===g.parentId);(b||w)&&s.push(g)}const c=new Set(t.map(g=>g.id)),h=l.filter(g=>g.deletable!==!1),m=eA(s,h);for(const g of h)c.has(g.id)&&!m.find(w=>w.id===g.id)&&m.push(g);if(!a)return{edges:m,nodes:s};const p=await a({nodes:s,edges:m});return typeof p=="boolean"?p?{edges:m,nodes:s}:{edges:[],nodes:[]}:p}const xa=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),il=(e={x:0,y:0},t,n)=>({x:xa(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:xa(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function N_(e,t,n){const{width:l,height:a}=Hr(n),{x:o,y:s}=n.internals.positionAbsolute;return il(e,[[o,s],[o+l,s+a]],t)}const zv=(e,t,n)=>en?-xa(Math.abs(e-n),1,t)/t:0,C_=(e,t,n=15,l=40)=>{const a=zv(e.x,l,t.width-l)*n,o=zv(e.y,l,t.height-l)*n;return[a,o]},Oc=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),em=({x:e,y:t,width:n,height:l})=>({x:e,y:t,x2:e+n,y2:t+l}),Lc=({x:e,y:t,x2:n,y2:l})=>({x:e,y:t,width:n-e,height:l-t}),ya=(e,t=[0,0])=>{var a,o;const{x:n,y:l}=Am(e)?e.internals.positionAbsolute:ts(e,t);return{x:n,y:l,width:((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},gc=(e,t=[0,0])=>{var a,o;const{x:n,y:l}=Am(e)?e.internals.positionAbsolute:ts(e,t);return{x:n,y:l,x2:n+(((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0),y2:l+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},j_=(e,t)=>Lc(Oc(em(e),em(t))),Fo=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),l=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*l)},Mv=e=>Vn(e.width)&&Vn(e.height)&&Vn(e.x)&&Vn(e.y),Vn=e=>!isNaN(e)&&isFinite(e),iA=(e,t)=>{},rs=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),is=({x:e,y:t},[n,l,a],o=!1,s=[1,1])=>{const c={x:(e-n)/a,y:(t-l)/a};return o?rs(c,s):c},xc=({x:e,y:t},[n,l,a])=>({x:e*a+n,y:t*a+l});function Wl(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function lA(e,t,n){if(typeof e=="string"||typeof e=="number"){const l=Wl(e,n),a=Wl(e,t);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof e=="object"){const l=Wl(e.top??e.y??0,n),a=Wl(e.bottom??e.y??0,n),o=Wl(e.left??e.x??0,t),s=Wl(e.right??e.x??0,t);return{top:l,right:s,bottom:a,left:o,x:o+s,y:l+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function aA(e,t,n,l,a,o){const{x:s,y:c}=xc(e,[t,n,l]),{x:h,y:f}=xc({x:e.x+e.width,y:e.y+e.height},[t,n,l]),m=a-h,p=o-f;return{left:Math.floor(s),top:Math.floor(c),right:Math.floor(m),bottom:Math.floor(p)}}const Mm=(e,t,n,l,a,o)=>{const s=lA(o,t,n),c=(t-s.x)/e.width,h=(n-s.y)/e.height,f=Math.min(c,h),m=xa(f,l,a),p=e.x+e.width/2,g=e.y+e.height/2,b=t/2-p*m,w=n/2-g*m,E=aA(e,b,w,m,t,n),S={left:Math.min(E.left-s.left,0),top:Math.min(E.top-s.top,0),right:Math.min(E.right-s.right,0),bottom:Math.min(E.bottom-s.bottom,0)};return{x:b-S.left+S.right,y:w-S.top+S.bottom,zoom:m}},Yo=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function va(e){return e!=null&&e!=="parent"}function Hr(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function T_(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function A_(e,t={width:0,height:0},n,l,a){const o={...e},s=l.get(n);if(s){const c=s.origin||a;o.x+=s.internals.positionAbsolute.x-(t.width??0)*c[0],o.y+=s.internals.positionAbsolute.y-(t.height??0)*c[1]}return o}function Dv(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function oA(){let e,t;return{promise:new Promise((l,a)=>{e=l,t=a}),resolve:e,reject:t}}function sA(e){return{...w_,...e||{}}}function Ro(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:l,containerBounds:a}){const{x:o,y:s}=Pn(e),c=is({x:o-((a==null?void 0:a.left)??0),y:s-((a==null?void 0:a.top)??0)},l),{x:h,y:f}=n?rs(c,t):c;return{xSnapped:h,ySnapped:f,...c}}const Dm=e=>({width:e.offsetWidth,height:e.offsetHeight}),z_=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},uA=["INPUT","SELECT","TEXTAREA"];function M_(e){var l,a;const t=((a=(l=e.composedPath)==null?void 0:l.call(e))==null?void 0:a[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:uA.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const D_=e=>"clientX"in e,Pn=(e,t)=>{var o,s;const n=D_(e),l=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,a=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:l-((t==null?void 0:t.left)??0),y:a-((t==null?void 0:t.top)??0)}},Rv=(e,t,n,l,a)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(s=>{const c=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:a,position:s.getAttribute("data-handlepos"),x:(c.left-n.left)/l,y:(c.top-n.top)/l,...Dm(s)}})};function R_({sourceX:e,sourceY:t,targetX:n,targetY:l,sourceControlX:a,sourceControlY:o,targetControlX:s,targetControlY:c}){const h=e*.125+a*.375+s*.375+n*.125,f=t*.125+o*.375+c*.375+l*.125,m=Math.abs(h-e),p=Math.abs(f-t);return[h,f,m,p]}function Vu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Ov({pos:e,x1:t,y1:n,x2:l,y2:a,c:o}){switch(e){case ve.Left:return[t-Vu(t-l,o),n];case ve.Right:return[t+Vu(l-t,o),n];case ve.Top:return[t,n-Vu(n-a,o)];case ve.Bottom:return[t,n+Vu(a-n,o)]}}function Rm({sourceX:e,sourceY:t,sourcePosition:n=ve.Bottom,targetX:l,targetY:a,targetPosition:o=ve.Top,curvature:s=.25}){const[c,h]=Ov({pos:n,x1:e,y1:t,x2:l,y2:a,c:s}),[f,m]=Ov({pos:o,x1:l,y1:a,x2:e,y2:t,c:s}),[p,g,b,w]=R_({sourceX:e,sourceY:t,targetX:l,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:f,targetControlY:m});return[`M${e},${t} C${c},${h} ${f},${m} ${l},${a}`,p,g,b,w]}function O_({sourceX:e,sourceY:t,targetX:n,targetY:l}){const a=Math.abs(n-e)/2,o=n0}const dA=({source:e,sourceHandle:t,target:n,targetHandle:l})=>`xy-edge__${e}${t||""}-${n}${l||""}`,hA=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),pA=(e,t,n={})=>{if(!e.source||!e.target)return t;const l=n.getEdgeId||dA;let a;return k_(e)?a={...e}:a={...e,id:l(e)},hA(a,t)?t:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,t.concat(a))};function L_({sourceX:e,sourceY:t,targetX:n,targetY:l}){const[a,o,s,c]=O_({sourceX:e,sourceY:t,targetX:n,targetY:l});return[`M ${e},${t}L ${n},${l}`,a,o,s,c]}const Lv={[ve.Left]:{x:-1,y:0},[ve.Right]:{x:1,y:0},[ve.Top]:{x:0,y:-1},[ve.Bottom]:{x:0,y:1}},mA=({source:e,sourcePosition:t=ve.Bottom,target:n})=>t===ve.Left||t===ve.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function gA({source:e,sourcePosition:t=ve.Bottom,target:n,targetPosition:l=ve.Top,center:a,offset:o,stepPosition:s}){const c=Lv[t],h=Lv[l],f={x:e.x+c.x*o,y:e.y+c.y*o},m={x:n.x+h.x*o,y:n.y+h.y*o},p=mA({source:f,sourcePosition:t,target:m}),g=p.x!==0?"x":"y",b=p[g];let w=[],E,S;const _={x:0,y:0},N={x:0,y:0},[,,k,T]=O_({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[g]*h[g]===-1){g==="x"?(E=a.x??f.x+(m.x-f.x)*s,S=a.y??(f.y+m.y)/2):(E=a.x??(f.x+m.x)/2,S=a.y??f.y+(m.y-f.y)*s);const A=[{x:E,y:f.y},{x:E,y:m.y}],L=[{x:f.x,y:S},{x:m.x,y:S}];c[g]===b?w=g==="x"?A:L:w=g==="x"?L:A}else{const A=[{x:f.x,y:m.y}],L=[{x:m.x,y:f.y}];if(g==="x"?w=c.x===b?L:A:w=c.y===b?A:L,t===l){const U=Math.abs(e[g]-n[g]);if(U<=o){const ee=Math.min(o-1,o-U);c[g]===b?_[g]=(f[g]>e[g]?-1:1)*ee:N[g]=(m[g]>n[g]?-1:1)*ee}}if(t!==l){const U=g==="x"?"y":"x",ee=c[g]===h[U],q=f[U]>m[U],F=f[U]=B?(E=(R.x+V.x)/2,S=w[0].y):(E=w[0].x,S=(R.y+V.y)/2)}return[[e,{x:f.x+_.x,y:f.y+_.y},...w,{x:m.x+N.x,y:m.y+N.y},n],E,S,k,T]}function xA(e,t,n,l){const a=Math.min(Hv(e,t)/2,Hv(t,n)/2,l),{x:o,y:s}=t;if(e.x===o&&o===n.x||e.y===s&&s===n.y)return`L${o} ${s}`;if(e.y===s){const f=e.x{let T="";return k>0&&kn.id===t):e[0])||null}function nm(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(l=>`${l}=${e[l]}`).join("&")}`:""}function vA(e,{id:t,defaultColor:n,defaultMarkerStart:l,defaultMarkerEnd:a}){const o=new Set;return e.reduce((s,c)=>([c.markerStart||l,c.markerEnd||a].forEach(h=>{if(h&&typeof h=="object"){const f=nm(h,t);o.has(f)||(s.push({id:f,color:h.color||n,...h}),o.add(f))}}),s),[]).sort((s,c)=>s.id.localeCompare(c.id))}const H_=1e3,bA=10,Om={nodeOrigin:[0,0],nodeExtent:Po,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},wA={...Om,checkEquality:!0};function Lm(e,t){const n={...e};for(const l in t)t[l]!==void 0&&(n[l]=t[l]);return n}function _A(e,t,n){const l=Lm(Om,n);for(const a of e.values())if(a.parentId)Bm(a,e,t,l);else{const o=ts(a,l.nodeOrigin),s=va(a.extent)?a.extent:l.nodeExtent,c=il(o,s,Hr(a));a.internals.positionAbsolute=c}}function SA(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],l=[];for(const a of e.handles){const o={id:a.id,width:a.width??1,height:a.height??1,nodeId:e.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?n.push(o):a.type==="target"&&l.push(o)}return{source:n,target:l}}function Hm(e){return e==="manual"}function rm(e,t,n,l={}){var f,m;const a=Lm(wA,l),o={i:0},s=new Map(t),c=a!=null&&a.elevateNodesOnSelect&&!Hm(a.zIndexMode)?H_:0;let h=e.length>0;t.clear(),n.clear();for(const p of e){let g=s.get(p.id);if(a.checkEquality&&p===(g==null?void 0:g.internals.userNode))t.set(p.id,g);else{const b=ts(p,a.nodeOrigin),w=va(p.extent)?p.extent:a.nodeExtent,E=il(b,w,Hr(p));g={...a.defaults,...p,measured:{width:(f=p.measured)==null?void 0:f.width,height:(m=p.measured)==null?void 0:m.height},internals:{positionAbsolute:E,handleBounds:SA(p,g),z:B_(p,c,a.zIndexMode),userNode:p}},t.set(p.id,g)}(g.measured===void 0||g.measured.width===void 0||g.measured.height===void 0)&&!g.hidden&&(h=!1),p.parentId&&Bm(g,t,n,l,o)}return h}function kA(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Bm(e,t,n,l,a){const{elevateNodesOnSelect:o,nodeOrigin:s,nodeExtent:c,zIndexMode:h}=Lm(Om,l),f=e.parentId,m=t.get(f);if(!m){console.warn(`Parent node ${f} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}kA(e,n),a&&!m.parentId&&m.internals.rootParentIndex===void 0&&h==="auto"&&(m.internals.rootParentIndex=++a.i,m.internals.z=m.internals.z+a.i*bA),a&&m.internals.rootParentIndex!==void 0&&(a.i=m.internals.rootParentIndex);const p=o&&!Hm(h)?H_:0,{x:g,y:b,z:w}=EA(e,m,s,c,p,h),{positionAbsolute:E}=e.internals,S=g!==E.x||b!==E.y;(S||w!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:S?{x:g,y:b}:E,z:w}})}function B_(e,t,n){const l=Vn(e.zIndex)?e.zIndex:0;return Hm(n)?l:l+(e.selected?t:0)}function EA(e,t,n,l,a,o){const{x:s,y:c}=t.internals.positionAbsolute,h=Hr(e),f=ts(e,n),m=va(e.extent)?il(f,e.extent,h):f;let p=il({x:s+m.x,y:c+m.y},l,h);e.extent==="parent"&&(p=N_(p,h,t));const g=B_(e,a,o),b=t.internals.z??0;return{x:p.x,y:p.y,z:b>=g?b+1:g}}function Im(e,t,n,l=[0,0]){var s;const a=[],o=new Map;for(const c of e){const h=t.get(c.parentId);if(!h)continue;const f=((s=o.get(c.parentId))==null?void 0:s.expandedRect)??ya(h),m=j_(f,c.rect);o.set(c.parentId,{expandedRect:m,parent:h})}return o.size>0&&o.forEach(({expandedRect:c,parent:h},f)=>{var k;const m=h.internals.positionAbsolute,p=Hr(h),g=h.origin??l,b=c.x0||w>0||_||N)&&(a.push({id:f,type:"position",position:{x:h.position.x-b+_,y:h.position.y-w+N}}),(k=n.get(f))==null||k.forEach(T=>{e.some(M=>M.id===T.id)||a.push({id:T.id,type:"position",position:{x:T.position.x+b,y:T.position.y+w}})})),(p.width0){const b=Im(g,t,n,a);f.push(...b)}return{changes:f,updatedInternals:h}}async function CA({delta:e,panZoom:t,transform:n,translateExtent:l,width:a,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[a,o]],l),c=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(c)}function $v(e,t,n,l,a,o){let s=a;const c=l.get(s)||new Map;l.set(s,c.set(n,t)),s=`${a}-${e}`;const h=l.get(s)||new Map;if(l.set(s,h.set(n,t)),o){s=`${a}-${e}-${o}`;const f=l.get(s)||new Map;l.set(s,f.set(n,t))}}function I_(e,t,n){e.clear(),t.clear();for(const l of n){const{source:a,target:o,sourceHandle:s=null,targetHandle:c=null}=l,h={edgeId:l.id,source:a,target:o,sourceHandle:s,targetHandle:c},f=`${a}-${s}--${o}-${c}`,m=`${o}-${c}--${a}-${s}`;$v("source",h,m,e,a,s),$v("target",h,f,e,o,c),t.set(l.id,l)}}function q_(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:q_(n,t):!1}function Uv(e,t,n){var a;let l=e;do{if((a=l==null?void 0:l.matches)!=null&&a.call(l,t))return!0;if(l===n)return!1;l=l==null?void 0:l.parentElement}while(l);return!1}function jA(e,t,n,l){const a=new Map;for(const[o,s]of e)if((s.selected||s.id===l)&&(!s.parentId||!q_(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const c=e.get(o);c&&a.set(o,{id:o,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return a}function _h({nodeId:e,dragItems:t,nodeLookup:n,dragging:l=!0}){var s,c,h;const a=[];for(const[f,m]of t){const p=(s=n.get(f))==null?void 0:s.internals.userNode;p&&a.push({...p,position:m.position,dragging:l})}if(!e)return[a[0],a];const o=(c=n.get(e))==null?void 0:c.internals.userNode;return[o?{...o,position:((h=t.get(e))==null?void 0:h.position)||o.position,dragging:l}:a[0],a]}function TA({dragItems:e,snapGrid:t,x:n,y:l}){const a=e.values().next().value;if(!a)return null;const o={x:n-a.distance.x,y:l-a.distance.y},s=rs(o,t);return{x:s.x-o.x,y:s.y-o.y}}function AA({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:l,onDragStop:a}){let o={x:null,y:null},s=0,c=new Map,h=!1,f={x:0,y:0},m=null,p=!1,g=null,b=!1,w=!1,E=null;function S({noDragClassName:N,handleSelector:k,domNode:T,isSelectable:M,nodeId:A,nodeClickDistance:L=0}){g=wn(T);function R({x:U,y:ee}){const{nodeLookup:q,nodeExtent:F,snapGrid:z,snapToGrid:G,nodeOrigin:Q,onNodeDrag:K,onSelectionDrag:D,onError:$,updateNodePositions:Y}=t();o={x:U,y:ee};let C=!1;const P=c.size>1,X=P&&F?em(ns(c)):null,J=P&&G?TA({dragItems:c,snapGrid:z,x:U,y:ee}):null;for(const[ne,re]of c){if(!q.has(ne))continue;let ue={x:U-re.distance.x,y:ee-re.distance.y};G&&(ue=J?{x:Math.round(ue.x+J.x),y:Math.round(ue.y+J.y)}:rs(ue,z));let xe=null;if(P&&F&&!re.extent&&X){const{positionAbsolute:pe}=re.internals,Se=pe.x-X.x+F[0][0],Oe=pe.x+re.measured.width-X.x2+F[1][0],Te=pe.y-X.y+F[0][1],ft=pe.y+re.measured.height-X.y2+F[1][1];xe=[[Se,Te],[Oe,ft]]}const{position:be,positionAbsolute:ye}=E_({nodeId:ne,nextPosition:ue,nodeLookup:q,nodeExtent:xe||F,nodeOrigin:Q,onError:$});C=C||re.position.x!==be.x||re.position.y!==be.y,re.position=be,re.internals.positionAbsolute=ye}if(w=w||C,!!C&&(Y(c,!0),E&&(l||K||!A&&D))){const[ne,re]=_h({nodeId:A,dragItems:c,nodeLookup:q});l==null||l(E,c,ne,re),K==null||K(E,ne,re),A||D==null||D(E,re)}}async function V(){if(!m)return;const{transform:U,panBy:ee,autoPanSpeed:q,autoPanOnNodeDrag:F}=t();if(!F){h=!1,cancelAnimationFrame(s);return}const[z,G]=C_(f,m,q);(z!==0||G!==0)&&(o.x=(o.x??0)-z/U[2],o.y=(o.y??0)-G/U[2],await ee({x:z,y:G})&&R(o)),s=requestAnimationFrame(V)}function H(U){var P;const{nodeLookup:ee,multiSelectionActive:q,nodesDraggable:F,transform:z,snapGrid:G,snapToGrid:Q,selectNodesOnDrag:K,onNodeDragStart:D,onSelectionDragStart:$,unselectNodesAndEdges:Y}=t();p=!0,(!K||!M)&&!q&&A&&((P=ee.get(A))!=null&&P.selected||Y()),M&&K&&A&&(e==null||e(A));const C=Ro(U.sourceEvent,{transform:z,snapGrid:G,snapToGrid:Q,containerBounds:m});if(o=C,c=jA(ee,F,C,A),c.size>0&&(n||D||!A&&$)){const[X,J]=_h({nodeId:A,dragItems:c,nodeLookup:ee});n==null||n(U.sourceEvent,c,X,J),D==null||D(U.sourceEvent,X,J),A||$==null||$(U.sourceEvent,J)}}const B=i_().clickDistance(L).on("start",U=>{const{domNode:ee,nodeDragThreshold:q,transform:F,snapGrid:z,snapToGrid:G}=t();m=(ee==null?void 0:ee.getBoundingClientRect())||null,b=!1,w=!1,E=U.sourceEvent,q===0&&H(U),o=Ro(U.sourceEvent,{transform:F,snapGrid:z,snapToGrid:G,containerBounds:m}),f=Pn(U.sourceEvent,m)}).on("drag",U=>{const{autoPanOnNodeDrag:ee,transform:q,snapGrid:F,snapToGrid:z,nodeDragThreshold:G,nodeLookup:Q}=t(),K=Ro(U.sourceEvent,{transform:q,snapGrid:F,snapToGrid:z,containerBounds:m});if(E=U.sourceEvent,(U.sourceEvent.type==="touchmove"&&U.sourceEvent.touches.length>1||A&&!Q.has(A))&&(b=!0),!b){if(!h&&ee&&p&&(h=!0,V()),!p){const D=Pn(U.sourceEvent,m),$=D.x-f.x,Y=D.y-f.y;Math.sqrt($*$+Y*Y)>G&&H(U)}(o.x!==K.xSnapped||o.y!==K.ySnapped)&&c&&p&&(f=Pn(U.sourceEvent,m),R(K))}}).on("end",U=>{if(!(!p||b)&&(h=!1,p=!1,cancelAnimationFrame(s),c.size>0)){const{nodeLookup:ee,updateNodePositions:q,onNodeDragStop:F,onSelectionDragStop:z}=t();if(w&&(q(c,!1),w=!1),a||F||!A&&z){const[G,Q]=_h({nodeId:A,dragItems:c,nodeLookup:ee,dragging:!1});a==null||a(U.sourceEvent,c,G,Q),F==null||F(U.sourceEvent,G,Q),A||z==null||z(U.sourceEvent,Q)}}}).filter(U=>{const ee=U.target;return!U.button&&(!N||!Uv(ee,`.${N}`,T))&&(!k||Uv(ee,k,T))});g.call(B)}function _(){g==null||g.on(".drag",null)}return{update:S,destroy:_}}function zA(e,t,n){const l=[],a={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())Fo(a,ya(o))>0&&l.push(o);return l}const MA=250;function DA(e,t,n,l){var c,h;let a=[],o=1/0;const s=zA(e,n,t+MA);for(const f of s){const m=[...((c=f.internals.handleBounds)==null?void 0:c.source)??[],...((h=f.internals.handleBounds)==null?void 0:h.target)??[]];for(const p of m){if(l.nodeId===p.nodeId&&l.type===p.type&&l.id===p.id)continue;const{x:g,y:b}=ll(f,p,p.position,!0),w=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(b-e.y,2));w>t||(w1){const f=l.type==="source"?"target":"source";return a.find(m=>m.type===f)??a[0]}return a[0]}function $_(e,t,n,l,a,o=!1){var f,m,p;const s=l.get(e);if(!s)return null;const c=a==="strict"?(f=s.internals.handleBounds)==null?void 0:f[t]:[...((m=s.internals.handleBounds)==null?void 0:m.source)??[],...((p=s.internals.handleBounds)==null?void 0:p.target)??[]],h=(n?c==null?void 0:c.find(g=>g.id===n):c==null?void 0:c[0])??null;return h&&o?{...h,...ll(s,h,h.position,!0)}:h}function U_(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function RA(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const V_=()=>!0;function OA(e,{connectionMode:t,connectionRadius:n,handleId:l,nodeId:a,edgeUpdaterType:o,isTarget:s,domNode:c,nodeLookup:h,lib:f,autoPanOnConnect:m,flowId:p,panBy:g,cancelConnection:b,onConnectStart:w,onConnect:E,onConnectEnd:S,isValidConnection:_=V_,onReconnectEnd:N,updateConnection:k,getTransform:T,getFromHandle:M,autoPanSpeed:A,dragThreshold:L=1,handleDomNode:R}){const V=z_(e.target);let H=0,B;const{x:U,y:ee}=Pn(e),q=U_(o,R),F=c==null?void 0:c.getBoundingClientRect();let z=!1;if(!F||!q)return;const G=$_(a,q,l,h,t);if(!G)return;let Q=Pn(e,F),K=!1,D=null,$=!1,Y=null;function C(){if(!m||!F)return;const[be,ye]=C_(Q,F,A);g({x:be,y:ye}),H=requestAnimationFrame(C)}const P={...G,nodeId:a,type:q,position:G.position},X=h.get(a);let ne={inProgress:!0,isValid:null,from:ll(X,P,ve.Left,!0),fromHandle:P,fromPosition:P.position,fromNode:X,to:Q,toHandle:null,toPosition:Av[P.position],toNode:null,pointer:Q};function re(){z=!0,k(ne),w==null||w(e,{nodeId:a,handleId:l,handleType:q})}L===0&&re();function ue(be){if(!z){const{x:ft,y:rt}=Pn(be),Dt=ft-U,Pt=rt-ee;if(!(Dt*Dt+Pt*Pt>L*L))return;re()}if(!M()||!P){xe(be);return}const ye=T();Q=Pn(be,F),B=DA(is(Q,ye,!1,[1,1]),n,h,P),K||(C(),K=!0);const pe=P_(be,{handle:B,connectionMode:t,fromNodeId:a,fromHandleId:l,fromType:s?"target":"source",isValidConnection:_,doc:V,lib:f,flowId:p,nodeLookup:h});Y=pe.handleDomNode,D=pe.connection,$=RA(!!B,pe.isValid);const Se=h.get(a),Oe=Se?ll(Se,P,ve.Left,!0):ne.from,Te={...ne,from:Oe,isValid:$,to:pe.toHandle&&$?xc({x:pe.toHandle.x,y:pe.toHandle.y},ye):Q,toHandle:pe.toHandle,toPosition:$&&pe.toHandle?pe.toHandle.position:Av[P.position],toNode:pe.toHandle?h.get(pe.toHandle.nodeId):null,pointer:Q};k(Te),ne=Te}function xe(be){if(!("touches"in be&&be.touches.length>0)){if(z){(B||Y)&&D&&$&&(E==null||E(D));const{inProgress:ye,...pe}=ne,Se={...pe,toPosition:ne.toHandle?ne.toPosition:null};S==null||S(be,Se),o&&(N==null||N(be,Se))}b(),cancelAnimationFrame(H),K=!1,$=!1,D=null,Y=null,V.removeEventListener("mousemove",ue),V.removeEventListener("mouseup",xe),V.removeEventListener("touchmove",ue),V.removeEventListener("touchend",xe)}}V.addEventListener("mousemove",ue),V.addEventListener("mouseup",xe),V.addEventListener("touchmove",ue),V.addEventListener("touchend",xe)}function P_(e,{handle:t,connectionMode:n,fromNodeId:l,fromHandleId:a,fromType:o,doc:s,lib:c,flowId:h,isValidConnection:f=V_,nodeLookup:m}){const p=o==="target",g=t?s.querySelector(`.${c}-flow__handle[data-id="${h}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:b,y:w}=Pn(e),E=s.elementFromPoint(b,w),S=E!=null&&E.classList.contains(`${c}-flow__handle`)?E:g,_={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const N=U_(void 0,S),k=S.getAttribute("data-nodeid"),T=S.getAttribute("data-handleid"),M=S.classList.contains("connectable"),A=S.classList.contains("connectableend");if(!k||!N)return _;const L={source:p?k:l,sourceHandle:p?T:a,target:p?l:k,targetHandle:p?a:T};_.connection=L;const V=M&&A&&(n===ga.Strict?p&&N==="source"||!p&&N==="target":k!==l||T!==a);_.isValid=V&&f(L),_.toHandle=$_(k,N,T,m,n,!0)}return _}const im={onPointerDown:OA,isValid:P_};function LA({domNode:e,panZoom:t,getTransform:n,getViewScale:l}){const a=wn(e);function o({translateExtent:c,width:h,height:f,zoomStep:m=1,pannable:p=!0,zoomable:g=!0,inversePan:b=!1}){const w=k=>{if(k.sourceEvent.type!=="wheel"||!t)return;const T=n(),M=k.sourceEvent.ctrlKey&&Yo()?10:1,A=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*m,L=T[2]*Math.pow(2,A*M);t.scaleTo(L)};let E=[0,0];const S=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(E=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},_=k=>{const T=n();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!t)return;const M=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],A=[M[0]-E[0],M[1]-E[1]];E=M;const L=l()*Math.max(T[2],Math.log(T[2]))*(b?-1:1),R={x:T[0]-A[0]*L,y:T[1]-A[1]*L},V=[[0,0],[h,f]];t.setViewportConstrained({x:R.x,y:R.y,zoom:T[2]},V,c)},N=v_().on("start",S).on("zoom",p?_:null).on("zoom.wheel",g?w:null);a.call(N,{})}function s(){a.on("zoom",null)}return{update:o,destroy:s,pointer:$n}}const Hc=e=>({x:e.x,y:e.y,zoom:e.k}),Sh=({x:e,y:t,zoom:n})=>Rc.translate(e,t).scale(n),aa=(e,t)=>e.target.closest(`.${t}`),G_=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),HA=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,kh=(e,t=0,n=HA,l=()=>{})=>{const a=typeof t=="number"&&t>0;return a||l(),a?e.transition().duration(t).ease(n).on("end",l):e},F_=e=>{const t=e.ctrlKey&&Yo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function BA({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:o,zoomOnPinch:s,onPanZoomStart:c,onPanZoom:h,onPanZoomEnd:f}){return m=>{if(aa(m,t))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(m.ctrlKey&&s){const S=$n(m),_=F_(m),N=p*Math.pow(2,_);l.scaleTo(n,N,S,m);return}const g=m.deltaMode===1?20:1;let b=a===el.Vertical?0:m.deltaX*g,w=a===el.Horizontal?0:m.deltaY*g;!Yo()&&m.shiftKey&&a!==el.Vertical&&(b=m.deltaY*g,w=0),l.translateBy(n,-(b/p)*o,-(w/p)*o,{internal:!0});const E=Hc(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(h==null||h(m,E),e.panScrollTimeout=setTimeout(()=>{f==null||f(m,E),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c==null||c(m,E))}}function IA({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(l,a){const o=l.type==="wheel",s=!t&&o&&!l.ctrlKey,c=aa(l,e);if(l.ctrlKey&&o&&c&&l.preventDefault(),s||c)return null;l.preventDefault(),n.call(this,l,a)}}function qA({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return l=>{var o,s,c;if((o=l.sourceEvent)!=null&&o.internal)return;const a=Hc(l.transform);e.mouseButton=((s=l.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=a,((c=l.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),n&&(n==null||n(l.sourceEvent,a))}}function $A({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:l,onPanZoom:a}){return o=>{var s,c;e.usedRightMouseButton=!!(n&&G_(t,e.mouseButton??0)),(s=o.sourceEvent)!=null&&s.sync||l([o.transform.x,o.transform.y,o.transform.k]),a&&!((c=o.sourceEvent)!=null&&c.internal)&&(a==null||a(o.sourceEvent,Hc(o.transform)))}}function UA({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:l,onPanZoomEnd:a,onPaneContextMenu:o}){return s=>{var c;if(!((c=s.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,o&&G_(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&o(s.sourceEvent),e.usedRightMouseButton=!1,l(!1),a)){const h=Hc(s.transform);e.prevViewport=h,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{a==null||a(s.sourceEvent,h)},n?150:0)}}}function VA({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:l,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:c,noPanClassName:h,lib:f,connectionInProgress:m}){return p=>{var S;const g=e||t,b=n&&p.ctrlKey,w=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(aa(p,`${f}-flow__node`)||aa(p,`${f}-flow__edge`)))return!0;if(!l&&!g&&!a&&!o&&!n||s||m&&!w||aa(p,c)&&w||aa(p,h)&&(!w||a&&w&&!e)||!n&&p.ctrlKey&&w)return!1;if(!n&&p.type==="touchstart"&&((S=p.touches)==null?void 0:S.length)>1)return p.preventDefault(),!1;if(!g&&!a&&!b&&w||!l&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(l)&&!l.includes(p.button)&&p.type==="mousedown")return!1;const E=Array.isArray(l)&&l.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||w)&&E}}function PA({domNode:e,minZoom:t,maxZoom:n,translateExtent:l,viewport:a,onPanZoom:o,onPanZoomStart:s,onPanZoomEnd:c,onDraggingChange:h}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=e.getBoundingClientRect(),p=v_().scaleExtent([t,n]).translateExtent(l),g=wn(e).call(p);N({x:a.x,y:a.y,zoom:xa(a.zoom,t,n)},[[0,0],[m.width,m.height]],l);const b=g.on("wheel.zoom"),w=g.on("dblclick.zoom");p.wheelDelta(F_);function E(B,U){return g?new Promise(ee=>{p==null||p.interpolate((U==null?void 0:U.interpolate)==="linear"?Do:Wu).transform(kh(g,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function S({noWheelClassName:B,noPanClassName:U,onPaneContextMenu:ee,userSelectionActive:q,panOnScroll:F,panOnDrag:z,panOnScrollMode:G,panOnScrollSpeed:Q,preventScrolling:K,zoomOnPinch:D,zoomOnScroll:$,zoomOnDoubleClick:Y,zoomActivationKeyPressed:C,lib:P,onTransformChange:X,connectionInProgress:J,paneClickDistance:ne,selectionOnDrag:re}){q&&!f.isZoomingOrPanning&&_();const ue=F&&!C&&!q;p.clickDistance(re?1/0:!Vn(ne)||ne<0?0:ne);const xe=ue?BA({zoomPanValues:f,noWheelClassName:B,d3Selection:g,d3Zoom:p,panOnScrollMode:G,panOnScrollSpeed:Q,zoomOnPinch:D,onPanZoomStart:s,onPanZoom:o,onPanZoomEnd:c}):IA({noWheelClassName:B,preventScrolling:K,d3ZoomHandler:b});if(g.on("wheel.zoom",xe,{passive:!1}),!q){const ye=qA({zoomPanValues:f,onDraggingChange:h,onPanZoomStart:s});p.on("start",ye);const pe=$A({zoomPanValues:f,panOnDrag:z,onPaneContextMenu:!!ee,onPanZoom:o,onTransformChange:X});p.on("zoom",pe);const Se=UA({zoomPanValues:f,panOnDrag:z,panOnScroll:F,onPaneContextMenu:ee,onPanZoomEnd:c,onDraggingChange:h});p.on("end",Se)}const be=VA({zoomActivationKeyPressed:C,panOnDrag:z,zoomOnScroll:$,panOnScroll:F,zoomOnDoubleClick:Y,zoomOnPinch:D,userSelectionActive:q,noPanClassName:U,noWheelClassName:B,lib:P,connectionInProgress:J});p.filter(be),Y?g.on("dblclick.zoom",w):g.on("dblclick.zoom",null)}function _(){p.on("zoom",null)}async function N(B,U,ee){const q=Sh(B),F=p==null?void 0:p.constrain()(q,U,ee);return F&&await E(F),new Promise(z=>z(F))}async function k(B,U){const ee=Sh(B);return await E(ee,U),new Promise(q=>q(ee))}function T(B){if(g){const U=Sh(B),ee=g.property("__zoom");(ee.k!==B.zoom||ee.x!==B.x||ee.y!==B.y)&&(p==null||p.transform(g,U,null,{sync:!0}))}}function M(){const B=g?y_(g.node()):{x:0,y:0,k:1};return{x:B.x,y:B.y,zoom:B.k}}function A(B,U){return g?new Promise(ee=>{p==null||p.interpolate((U==null?void 0:U.interpolate)==="linear"?Do:Wu).scaleTo(kh(g,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function L(B,U){return g?new Promise(ee=>{p==null||p.interpolate((U==null?void 0:U.interpolate)==="linear"?Do:Wu).scaleBy(kh(g,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function R(B){p==null||p.scaleExtent(B)}function V(B){p==null||p.translateExtent(B)}function H(B){const U=!Vn(B)||B<0?0:B;p==null||p.clickDistance(U)}return{update:S,destroy:_,setViewport:k,setViewportConstrained:N,getViewport:M,scaleTo:A,scaleBy:L,setScaleExtent:R,setTranslateExtent:V,syncViewport:T,setClickDistance:H}}var ba;(function(e){e.Line="line",e.Handle="handle"})(ba||(ba={}));function GA({width:e,prevWidth:t,height:n,prevHeight:l,affectsX:a,affectsY:o}){const s=e-t,c=n-l,h=[s>0?1:s<0?-1:0,c>0?1:c<0?-1:0];return s&&a&&(h[0]=h[0]*-1),c&&o&&(h[1]=h[1]*-1),h}function Vv(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),l=e.includes("left"),a=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:l,affectsY:a}}function gi(e,t){return Math.max(0,t-e)}function xi(e,t){return Math.max(0,e-t)}function Pu(e,t,n){return Math.max(0,t-e,e-n)}function Pv(e,t){return e?!t:t}function FA(e,t,n,l,a,o,s,c){let{affectsX:h,affectsY:f}=t;const{isHorizontal:m,isVertical:p}=t,g=m&&p,{xSnapped:b,ySnapped:w}=n,{minWidth:E,maxWidth:S,minHeight:_,maxHeight:N}=l,{x:k,y:T,width:M,height:A,aspectRatio:L}=e;let R=Math.floor(m?b-e.pointerX:0),V=Math.floor(p?w-e.pointerY:0);const H=M+(h?-R:R),B=A+(f?-V:V),U=-o[0]*M,ee=-o[1]*A;let q=Pu(H,E,S),F=Pu(B,_,N);if(s){let Q=0,K=0;h&&R<0?Q=gi(k+R+U,s[0][0]):!h&&R>0&&(Q=xi(k+H+U,s[1][0])),f&&V<0?K=gi(T+V+ee,s[0][1]):!f&&V>0&&(K=xi(T+B+ee,s[1][1])),q=Math.max(q,Q),F=Math.max(F,K)}if(c){let Q=0,K=0;h&&R>0?Q=xi(k+R,c[0][0]):!h&&R<0&&(Q=gi(k+H,c[1][0])),f&&V>0?K=xi(T+V,c[0][1]):!f&&V<0&&(K=gi(T+B,c[1][1])),q=Math.max(q,Q),F=Math.max(F,K)}if(a){if(m){const Q=Pu(H/L,_,N)*L;if(q=Math.max(q,Q),s){let K=0;!h&&!f||h&&!f&&g?K=xi(T+ee+H/L,s[1][1])*L:K=gi(T+ee+(h?R:-R)/L,s[0][1])*L,q=Math.max(q,K)}if(c){let K=0;!h&&!f||h&&!f&&g?K=gi(T+H/L,c[1][1])*L:K=xi(T+(h?R:-R)/L,c[0][1])*L,q=Math.max(q,K)}}if(p){const Q=Pu(B*L,E,S)/L;if(F=Math.max(F,Q),s){let K=0;!h&&!f||f&&!h&&g?K=xi(k+B*L+U,s[1][0])/L:K=gi(k+(f?V:-V)*L+U,s[0][0])/L,F=Math.max(F,K)}if(c){let K=0;!h&&!f||f&&!h&&g?K=gi(k+B*L,c[1][0])/L:K=xi(k+(f?V:-V)*L,c[0][0])/L,F=Math.max(F,K)}}}V=V+(V<0?F:-F),R=R+(R<0?q:-q),a&&(g?H>B*L?V=(Pv(h,f)?-R:R)/L:R=(Pv(h,f)?-V:V)*L:m?(V=R/L,f=h):(R=V*L,h=f));const z=h?k+R:k,G=f?T+V:T;return{width:M+(h?-R:R),height:A+(f?-V:V),x:o[0]*R*(h?-1:1)+z,y:o[1]*V*(f?-1:1)+G}}const Y_={width:0,height:0,x:0,y:0},YA={...Y_,pointerX:0,pointerY:0,aspectRatio:1};function XA(e){return[[0,0],[e.measured.width,e.measured.height]]}function QA(e,t,n){const l=t.position.x+e.position.x,a=t.position.y+e.position.y,o=e.measured.width??0,s=e.measured.height??0,c=n[0]*o,h=n[1]*s;return[[l-c,a-h],[l+o-c,a+s-h]]}function ZA({domNode:e,nodeId:t,getStoreItems:n,onChange:l,onEnd:a}){const o=wn(e);let s={controlDirection:Vv("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:f,boundaries:m,keepAspectRatio:p,resizeDirection:g,onResizeStart:b,onResize:w,onResizeEnd:E,shouldResize:S}){let _={...Y_},N={...YA};s={boundaries:m,resizeDirection:g,keepAspectRatio:p,controlDirection:Vv(f)};let k,T=null,M=[],A,L,R,V=!1;const H=i_().on("start",B=>{const{nodeLookup:U,transform:ee,snapGrid:q,snapToGrid:F,nodeOrigin:z,paneDomNode:G}=n();if(k=U.get(t),!k)return;T=(G==null?void 0:G.getBoundingClientRect())??null;const{xSnapped:Q,ySnapped:K}=Ro(B.sourceEvent,{transform:ee,snapGrid:q,snapToGrid:F,containerBounds:T});_={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},N={..._,pointerX:Q,pointerY:K,aspectRatio:_.width/_.height},A=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(A=U.get(k.parentId),L=A&&k.extent==="parent"?XA(A):void 0),M=[],R=void 0;for(const[D,$]of U)if($.parentId===t&&(M.push({id:D,position:{...$.position},extent:$.extent}),$.extent==="parent"||$.expandParent)){const Y=QA($,k,$.origin??z);R?R=[[Math.min(Y[0][0],R[0][0]),Math.min(Y[0][1],R[0][1])],[Math.max(Y[1][0],R[1][0]),Math.max(Y[1][1],R[1][1])]]:R=Y}b==null||b(B,{..._})}).on("drag",B=>{const{transform:U,snapGrid:ee,snapToGrid:q,nodeOrigin:F}=n(),z=Ro(B.sourceEvent,{transform:U,snapGrid:ee,snapToGrid:q,containerBounds:T}),G=[];if(!k)return;const{x:Q,y:K,width:D,height:$}=_,Y={},C=k.origin??F,{width:P,height:X,x:J,y:ne}=FA(N,s.controlDirection,z,s.boundaries,s.keepAspectRatio,C,L,R),re=P!==D,ue=X!==$,xe=J!==Q&&re,be=ne!==K&&ue;if(!xe&&!be&&!re&&!ue)return;if((xe||be||C[0]===1||C[1]===1)&&(Y.x=xe?J:_.x,Y.y=be?ne:_.y,_.x=Y.x,_.y=Y.y,M.length>0)){const Oe=J-Q,Te=ne-K;for(const ft of M)ft.position={x:ft.position.x-Oe+C[0]*(P-D),y:ft.position.y-Te+C[1]*(X-$)},G.push(ft)}if((re||ue)&&(Y.width=re&&(!s.resizeDirection||s.resizeDirection==="horizontal")?P:_.width,Y.height=ue&&(!s.resizeDirection||s.resizeDirection==="vertical")?X:_.height,_.width=Y.width,_.height=Y.height),A&&k.expandParent){const Oe=C[0]*(Y.width??0);Y.x&&Y.x{V&&(E==null||E(B,{..._}),a==null||a({..._}),V=!1)});o.call(H)}function h(){o.on(".drag",null)}return{update:c,destroy:h}}var Eh={exports:{}},Nh={},Ch={exports:{}},jh={};/** * @license React * use-sync-external-store-shim.production.js * @@ -308,7 +313,7 @@ Error generating stack: `+d.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Gv;function ZA(){if(Gv)return jh;Gv=1;var e=Jo();function t(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var n=typeof Object.is=="function"?Object.is:t,l=e.useState,a=e.useEffect,o=e.useLayoutEffect,s=e.useDebugValue;function c(p,g){var b=g(),w=l({inst:{value:b,getSnapshot:g}}),E=w[0].inst,S=w[1];return o(function(){E.value=b,E.getSnapshot=g,h(E)&&S({inst:E})},[p,b,g]),a(function(){return h(E)&&S({inst:E}),p(function(){h(E)&&S({inst:E})})},[p]),s(b),b}function h(p){var g=p.getSnapshot;p=p.value;try{var b=g();return!n(p,b)}catch{return!0}}function f(p,g){return g()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return jh.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,jh}var Fv;function KA(){return Fv||(Fv=1,Ch.exports=ZA()),Ch.exports}/** + */var Gv;function KA(){if(Gv)return jh;Gv=1;var e=Jo();function t(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var n=typeof Object.is=="function"?Object.is:t,l=e.useState,a=e.useEffect,o=e.useLayoutEffect,s=e.useDebugValue;function c(p,g){var b=g(),w=l({inst:{value:b,getSnapshot:g}}),E=w[0].inst,S=w[1];return o(function(){E.value=b,E.getSnapshot=g,h(E)&&S({inst:E})},[p,b,g]),a(function(){return h(E)&&S({inst:E}),p(function(){h(E)&&S({inst:E})})},[p]),s(b),b}function h(p){var g=p.getSnapshot;p=p.value;try{var b=g();return!n(p,b)}catch{return!0}}function f(p,g){return g()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return jh.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,jh}var Fv;function JA(){return Fv||(Fv=1,Ch.exports=KA()),Ch.exports}/** * @license React * use-sync-external-store-shim/with-selector.production.js * @@ -316,41 +321,41 @@ Error generating stack: `+d.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Yv;function JA(){if(Yv)return Nh;Yv=1;var e=Jo(),t=KA();function n(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var l=typeof Object.is=="function"?Object.is:n,a=t.useSyncExternalStore,o=e.useRef,s=e.useEffect,c=e.useMemo,h=e.useDebugValue;return Nh.useSyncExternalStoreWithSelector=function(f,m,p,g,b){var w=o(null);if(w.current===null){var E={hasValue:!1,value:null};w.current=E}else E=w.current;w=c(function(){function _(A){if(!N){if(N=!0,k=A,A=g(A),b!==void 0&&E.hasValue){var L=E.value;if(b(L,A))return T=L}return T=A}if(L=T,l(k,A))return L;var R=g(A);return b!==void 0&&b(L,R)?(k=A,L):(k=A,T=R)}var N=!1,k,T,M=p===void 0?null:p;return[function(){return _(m())},M===null?void 0:function(){return _(M())}]},[m,p,g,b]);var S=a(f,w[0],w[1]);return s(function(){E.hasValue=!0,E.value=S},[S]),h(S),S},Nh}var Xv;function WA(){return Xv||(Xv=1,Eh.exports=JA()),Eh.exports}var ez=WA();const tz=Ko(ez),nz={},Qv=e=>{let t;const n=new Set,l=(m,p)=>{const g=typeof m=="function"?m(t):m;if(!Object.is(g,t)){const b=t;t=p??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(w=>w(t,b))}},a=()=>t,h={setState:l,getState:a,getInitialState:()=>f,subscribe:m=>(n.add(m),()=>n.delete(m)),destroy:()=>{(nz?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},f=t=e(l,a,h);return h},rz=e=>e?Qv(e):Qv,{useDebugValue:iz}=ra,{useSyncExternalStoreWithSelector:lz}=tz,az=e=>e;function X_(e,t=az,n){const l=lz(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return iz(l),l}const Zv=(e,t)=>{const n=rz(e),l=(a,o=t)=>X_(n,a,o);return Object.assign(l,n),l},oz=(e,t)=>e?Zv(e,t):Zv;function mt(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[l,a]of e)if(!Object.is(a,t.get(l)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const l of e)if(!t.has(l))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const l of n)if(!Object.prototype.hasOwnProperty.call(t,l)||!Object.is(e[l],t[l]))return!1;return!0}var sz=pw();const Bc=I.createContext(null),uz=Bc.Provider,Q_=ar.error001();function Ye(e,t){const n=I.useContext(Bc);if(n===null)throw new Error(Q_);return X_(n,e,t)}function gt(){const e=I.useContext(Bc);if(e===null)throw new Error(Q_);return I.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Kv={display:"none"},cz={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Z_="react-flow__node-desc",K_="react-flow__edge-desc",fz="react-flow__aria-live",dz=e=>e.ariaLiveMessage,hz=e=>e.ariaLabelConfig;function pz({rfId:e}){const t=Ye(dz);return y.jsx("div",{id:`${fz}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:cz,children:t})}function mz({rfId:e,disableKeyboardA11y:t}){const n=Ye(hz);return y.jsxs(y.Fragment,{children:[y.jsx("div",{id:`${Z_}-${e}`,style:Kv,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),y.jsx("div",{id:`${K_}-${e}`,style:Kv,children:n["edge.a11yDescription.default"]}),!t&&y.jsx(pz,{rfId:e})]})}const Ic=I.forwardRef(({position:e="top-left",children:t,className:n,style:l,...a},o)=>{const s=`${e}`.split("-");return y.jsx("div",{className:Mt(["react-flow__panel",n,...s]),style:l,ref:o,...a,children:t})});Ic.displayName="Panel";function gz({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:y.jsx(Ic,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:y.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const xz=e=>{const t=[],n=[];for(const[,l]of e.nodeLookup)l.selected&&t.push(l.internals.userNode);for(const[,l]of e.edgeLookup)l.selected&&n.push(l);return{selectedNodes:t,selectedEdges:n}},Gu=e=>e.id;function yz(e,t){return mt(e.selectedNodes.map(Gu),t.selectedNodes.map(Gu))&&mt(e.selectedEdges.map(Gu),t.selectedEdges.map(Gu))}function vz({onSelectionChange:e}){const t=gt(),{selectedNodes:n,selectedEdges:l}=Ye(xz,yz);return I.useEffect(()=>{const a={nodes:n,edges:l};e==null||e(a),t.getState().onSelectionChangeHandlers.forEach(o=>o(a))},[n,l,e]),null}const bz=e=>!!e.onSelectionChangeHandlers;function wz({onSelectionChange:e}){const t=Ye(bz);return e||t?y.jsx(vz,{onSelectionChange:e}):null}const J_=[0,0],_z={x:0,y:0,zoom:1},Sz=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Jv=[...Sz,"rfId"],kz=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Wv={translateExtent:Po,nodeOrigin:J_,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Ez(e){const{setNodes:t,setEdges:n,setMinZoom:l,setMaxZoom:a,setTranslateExtent:o,setNodeExtent:s,reset:c,setDefaultNodesAndEdges:h}=Ye(kz,mt),f=gt();I.useEffect(()=>(h(e.defaultNodes,e.defaultEdges),()=>{m.current=Wv,c()}),[]);const m=I.useRef(Wv);return I.useEffect(()=>{for(const p of Jv){const g=e[p],b=m.current[p];g!==b&&(typeof e[p]>"u"||(p==="nodes"?t(g):p==="edges"?n(g):p==="minZoom"?l(g):p==="maxZoom"?a(g):p==="translateExtent"?o(g):p==="nodeExtent"?s(g):p==="ariaLabelConfig"?f.setState({ariaLabelConfig:oA(g)}):p==="fitView"?f.setState({fitViewQueued:g}):p==="fitViewOptions"?f.setState({fitViewOptions:g}):f.setState({[p]:g})))}m.current=e},Jv.map(p=>e[p])),null}function eb(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Nz(e){var l;const[t,n]=I.useState(e==="system"?null:e);return I.useEffect(()=>{if(e!=="system"){n(e);return}const a=eb(),o=()=>n(a!=null&&a.matches?"dark":"light");return o(),a==null||a.addEventListener("change",o),()=>{a==null||a.removeEventListener("change",o)}},[e]),t!==null?t:(l=eb())!=null&&l.matches?"dark":"light"}const tb=typeof document<"u"?document:null;function Xo(e=null,t={target:tb,actInsideInputWithModifier:!0}){const[n,l]=I.useState(!1),a=I.useRef(!1),o=I.useRef(new Set([])),[s,c]=I.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",` + */var Yv;function WA(){if(Yv)return Nh;Yv=1;var e=Jo(),t=JA();function n(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var l=typeof Object.is=="function"?Object.is:n,a=t.useSyncExternalStore,o=e.useRef,s=e.useEffect,c=e.useMemo,h=e.useDebugValue;return Nh.useSyncExternalStoreWithSelector=function(f,m,p,g,b){var w=o(null);if(w.current===null){var E={hasValue:!1,value:null};w.current=E}else E=w.current;w=c(function(){function _(A){if(!N){if(N=!0,k=A,A=g(A),b!==void 0&&E.hasValue){var L=E.value;if(b(L,A))return T=L}return T=A}if(L=T,l(k,A))return L;var R=g(A);return b!==void 0&&b(L,R)?(k=A,L):(k=A,T=R)}var N=!1,k,T,M=p===void 0?null:p;return[function(){return _(m())},M===null?void 0:function(){return _(M())}]},[m,p,g,b]);var S=a(f,w[0],w[1]);return s(function(){E.hasValue=!0,E.value=S},[S]),h(S),S},Nh}var Xv;function ez(){return Xv||(Xv=1,Eh.exports=WA()),Eh.exports}var tz=ez();const nz=Ko(tz),rz={},Qv=e=>{let t;const n=new Set,l=(m,p)=>{const g=typeof m=="function"?m(t):m;if(!Object.is(g,t)){const b=t;t=p??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(w=>w(t,b))}},a=()=>t,h={setState:l,getState:a,getInitialState:()=>f,subscribe:m=>(n.add(m),()=>n.delete(m)),destroy:()=>{(rz?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},f=t=e(l,a,h);return h},iz=e=>e?Qv(e):Qv,{useDebugValue:lz}=ia,{useSyncExternalStoreWithSelector:az}=nz,oz=e=>e;function X_(e,t=oz,n){const l=az(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return lz(l),l}const Zv=(e,t)=>{const n=iz(e),l=(a,o=t)=>X_(n,a,o);return Object.assign(l,n),l},sz=(e,t)=>e?Zv(e,t):Zv;function mt(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[l,a]of e)if(!Object.is(a,t.get(l)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const l of e)if(!t.has(l))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const l of n)if(!Object.prototype.hasOwnProperty.call(t,l)||!Object.is(e[l],t[l]))return!1;return!0}var uz=pw();const Bc=I.createContext(null),cz=Bc.Provider,Q_=ar.error001();function Ye(e,t){const n=I.useContext(Bc);if(n===null)throw new Error(Q_);return X_(n,e,t)}function gt(){const e=I.useContext(Bc);if(e===null)throw new Error(Q_);return I.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Kv={display:"none"},fz={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Z_="react-flow__node-desc",K_="react-flow__edge-desc",dz="react-flow__aria-live",hz=e=>e.ariaLiveMessage,pz=e=>e.ariaLabelConfig;function mz({rfId:e}){const t=Ye(hz);return y.jsx("div",{id:`${dz}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:fz,children:t})}function gz({rfId:e,disableKeyboardA11y:t}){const n=Ye(pz);return y.jsxs(y.Fragment,{children:[y.jsx("div",{id:`${Z_}-${e}`,style:Kv,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),y.jsx("div",{id:`${K_}-${e}`,style:Kv,children:n["edge.a11yDescription.default"]}),!t&&y.jsx(mz,{rfId:e})]})}const Ic=I.forwardRef(({position:e="top-left",children:t,className:n,style:l,...a},o)=>{const s=`${e}`.split("-");return y.jsx("div",{className:Mt(["react-flow__panel",n,...s]),style:l,ref:o,...a,children:t})});Ic.displayName="Panel";function xz({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:y.jsx(Ic,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:y.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const yz=e=>{const t=[],n=[];for(const[,l]of e.nodeLookup)l.selected&&t.push(l.internals.userNode);for(const[,l]of e.edgeLookup)l.selected&&n.push(l);return{selectedNodes:t,selectedEdges:n}},Gu=e=>e.id;function vz(e,t){return mt(e.selectedNodes.map(Gu),t.selectedNodes.map(Gu))&&mt(e.selectedEdges.map(Gu),t.selectedEdges.map(Gu))}function bz({onSelectionChange:e}){const t=gt(),{selectedNodes:n,selectedEdges:l}=Ye(yz,vz);return I.useEffect(()=>{const a={nodes:n,edges:l};e==null||e(a),t.getState().onSelectionChangeHandlers.forEach(o=>o(a))},[n,l,e]),null}const wz=e=>!!e.onSelectionChangeHandlers;function _z({onSelectionChange:e}){const t=Ye(wz);return e||t?y.jsx(bz,{onSelectionChange:e}):null}const J_=[0,0],Sz={x:0,y:0,zoom:1},kz=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Jv=[...kz,"rfId"],Ez=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Wv={translateExtent:Po,nodeOrigin:J_,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Nz(e){const{setNodes:t,setEdges:n,setMinZoom:l,setMaxZoom:a,setTranslateExtent:o,setNodeExtent:s,reset:c,setDefaultNodesAndEdges:h}=Ye(Ez,mt),f=gt();I.useEffect(()=>(h(e.defaultNodes,e.defaultEdges),()=>{m.current=Wv,c()}),[]);const m=I.useRef(Wv);return I.useEffect(()=>{for(const p of Jv){const g=e[p],b=m.current[p];g!==b&&(typeof e[p]>"u"||(p==="nodes"?t(g):p==="edges"?n(g):p==="minZoom"?l(g):p==="maxZoom"?a(g):p==="translateExtent"?o(g):p==="nodeExtent"?s(g):p==="ariaLabelConfig"?f.setState({ariaLabelConfig:sA(g)}):p==="fitView"?f.setState({fitViewQueued:g}):p==="fitViewOptions"?f.setState({fitViewOptions:g}):f.setState({[p]:g})))}m.current=e},Jv.map(p=>e[p])),null}function eb(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Cz(e){var l;const[t,n]=I.useState(e==="system"?null:e);return I.useEffect(()=>{if(e!=="system"){n(e);return}const a=eb(),o=()=>n(a!=null&&a.matches?"dark":"light");return o(),a==null||a.addEventListener("change",o),()=>{a==null||a.removeEventListener("change",o)}},[e]),t!==null?t:(l=eb())!=null&&l.matches?"dark":"light"}const tb=typeof document<"u"?document:null;function Xo(e=null,t={target:tb,actInsideInputWithModifier:!0}){const[n,l]=I.useState(!1),a=I.useRef(!1),o=I.useRef(new Set([])),[s,c]=I.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",` `).replace(` `,` +`).split(` -`)),m=f.reduce((p,g)=>p.concat(...g),[]);return[f,m]}return[[],[]]},[e]);return I.useEffect(()=>{const h=(t==null?void 0:t.target)??tb,f=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const m=b=>{var S,_;if(a.current=b.ctrlKey||b.metaKey||b.shiftKey||b.altKey,(!a.current||a.current&&!f)&&M_(b))return!1;const E=rb(b.code,c);if(o.current.add(b[E]),nb(s,o.current,!1)){const N=((_=(S=b.composedPath)==null?void 0:S.call(b))==null?void 0:_[0])||b.target,k=(N==null?void 0:N.nodeName)==="BUTTON"||(N==null?void 0:N.nodeName)==="A";t.preventDefault!==!1&&(a.current||!k)&&b.preventDefault(),l(!0)}},p=b=>{const w=rb(b.code,c);nb(s,o.current,!0)?(l(!1),o.current.clear()):o.current.delete(b[w]),b.key==="Meta"&&o.current.clear(),a.current=!1},g=()=>{o.current.clear(),l(!1)};return h==null||h.addEventListener("keydown",m),h==null||h.addEventListener("keyup",p),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{h==null||h.removeEventListener("keydown",m),h==null||h.removeEventListener("keyup",p),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,l]),n}function nb(e,t,n){return e.filter(l=>n||l.length===t.size).some(l=>l.every(a=>t.has(a)))}function rb(e,t){return t.includes(e)?"code":"key"}const Cz=()=>{const e=gt();return I.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:l}=e.getState();return l?l.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[l,a,o],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??l,y:t.y??a,zoom:t.zoom??o},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,l]=e.getState().transform;return{x:t,y:n,zoom:l}},setCenter:async(t,n,l)=>e.getState().setCenter(t,n,l),fitBounds:async(t,n)=>{const{width:l,height:a,minZoom:o,maxZoom:s,panZoom:c}=e.getState(),h=Mm(t,l,a,o,s,(n==null?void 0:n.padding)??.1);return c?(await c.setViewport(h,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:l,snapGrid:a,snapToGrid:o,domNode:s}=e.getState();if(!s)return t;const{x:c,y:h}=s.getBoundingClientRect(),f={x:t.x-c,y:t.y-h},m=n.snapGrid??a,p=n.snapToGrid??o;return is(f,l,p,m)},flowToScreenPosition:t=>{const{transform:n,domNode:l}=e.getState();if(!l)return t;const{x:a,y:o}=l.getBoundingClientRect(),s=xc(t,n);return{x:s.x+a,y:s.y+o}}}),[])};function W_(e,t){const n=[],l=new Map,a=[];for(const o of e)if(o.type==="add"){a.push(o);continue}else if(o.type==="remove"||o.type==="replace")l.set(o.id,[o]);else{const s=l.get(o.id);s?s.push(o):l.set(o.id,[o])}for(const o of t){const s=l.get(o.id);if(!s){n.push(o);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const c={...o};for(const h of s)jz(h,c);n.push(c)}return a.length&&a.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function jz(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function eS(e,t){return W_(e,t)}function tS(e,t){return W_(e,t)}function Xi(e,t){return{id:e,type:"select",selected:t}}function aa(e,t=new Set,n=!1){const l=[];for(const[a,o]of e){const s=t.has(a);!(o.selected===void 0&&!s)&&o.selected!==s&&(n&&(o.selected=s),l.push(Xi(o.id,s)))}return l}function ib({items:e=[],lookup:t}){var a;const n=[],l=new Map(e.map(o=>[o.id,o]));for(const[o,s]of e.entries()){const c=t.get(s.id),h=((a=c==null?void 0:c.internals)==null?void 0:a.userNode)??c;h!==void 0&&h!==s&&n.push({id:s.id,item:s,type:"replace"}),h===void 0&&n.push({item:s,type:"add",index:o})}for(const[o]of t)l.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function lb(e){return{id:e.id,type:"remove"}}const ab=e=>KT(e),Tz=e=>k_(e);function nS(e){return I.forwardRef(e)}const Az=typeof window<"u"?I.useLayoutEffect:I.useEffect;function ob(e){const[t,n]=I.useState(BigInt(0)),[l]=I.useState(()=>zz(()=>n(a=>a+BigInt(1))));return Az(()=>{const a=l.get();a.length&&(e(a),l.reset())},[t]),l}function zz(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const rS=I.createContext(null);function Mz({children:e}){const t=gt(),n=I.useCallback(c=>{const{nodes:h=[],setNodes:f,hasDefaultNodes:m,onNodesChange:p,nodeLookup:g,fitViewQueued:b,onNodesChangeMiddlewareMap:w}=t.getState();let E=h;for(const _ of c)E=typeof _=="function"?_(E):_;let S=ib({items:E,lookup:g});for(const _ of w.values())S=_(S);m&&f(E),S.length>0?p==null||p(S):b&&window.requestAnimationFrame(()=>{const{fitViewQueued:_,nodes:N,setNodes:k}=t.getState();_&&k(N)})},[]),l=ob(n),a=I.useCallback(c=>{const{edges:h=[],setEdges:f,hasDefaultEdges:m,onEdgesChange:p,edgeLookup:g}=t.getState();let b=h;for(const w of c)b=typeof w=="function"?w(b):w;m?f(b):p&&p(ib({items:b,lookup:g}))},[]),o=ob(a),s=I.useMemo(()=>({nodeQueue:l,edgeQueue:o}),[]);return y.jsx(rS.Provider,{value:s,children:e})}function Dz(){const e=I.useContext(rS);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Rz=e=>!!e.panZoom;function ul(){const e=Cz(),t=gt(),n=Dz(),l=Ye(Rz),a=I.useMemo(()=>{const o=p=>t.getState().nodeLookup.get(p),s=p=>{n.nodeQueue.push(p)},c=p=>{n.edgeQueue.push(p)},h=p=>{var _,N;const{nodeLookup:g,nodeOrigin:b}=t.getState(),w=ab(p)?p:g.get(p.id),E=w.parentId?A_(w.position,w.measured,w.parentId,g,b):w.position,S={...w,position:E,width:((_=w.measured)==null?void 0:_.width)??w.width,height:((N=w.measured)==null?void 0:N.height)??w.height};return xa(S)},f=(p,g,b={replace:!1})=>{s(w=>w.map(E=>{if(E.id===p){const S=typeof g=="function"?g(E):g;return b.replace&&ab(S)?S:{...E,...S}}return E}))},m=(p,g,b={replace:!1})=>{c(w=>w.map(E=>{if(E.id===p){const S=typeof g=="function"?g(E):g;return b.replace&&Tz(S)?S:{...E,...S}}return E}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>{var g;return(g=o(p))==null?void 0:g.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(g=>({...g}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:s,setEdges:c,addNodes:p=>{const g=Array.isArray(p)?p:[p];n.nodeQueue.push(b=>[...b,...g])},addEdges:p=>{const g=Array.isArray(p)?p:[p];n.edgeQueue.push(b=>[...b,...g])},toObject:()=>{const{nodes:p=[],edges:g=[],transform:b}=t.getState(),[w,E,S]=b;return{nodes:p.map(_=>({..._})),edges:g.map(_=>({..._})),viewport:{x:w,y:E,zoom:S}}},deleteElements:async({nodes:p=[],edges:g=[]})=>{const{nodes:b,edges:w,onNodesDelete:E,onEdgesDelete:S,triggerNodeChanges:_,triggerEdgeChanges:N,onDelete:k,onBeforeDelete:T}=t.getState(),{nodes:M,edges:A}=await nA({nodesToRemove:p,edgesToRemove:g,nodes:b,edges:w,onBeforeDelete:T}),L=A.length>0,R=M.length>0;if(L){const V=A.map(lb);S==null||S(A),N(V)}if(R){const V=M.map(lb);E==null||E(M),_(V)}return(R||L)&&(k==null||k({nodes:M,edges:A})),{deletedNodes:M,deletedEdges:A}},getIntersectingNodes:(p,g=!0,b)=>{const w=Mv(p),E=w?p:h(p),S=b!==void 0;return E?(b||t.getState().nodes).filter(_=>{const N=t.getState().nodeLookup.get(_.id);if(N&&!w&&(_.id===p.id||!N.internals.positionAbsolute))return!1;const k=xa(S?_:N),T=Fo(k,E);return g&&T>0||T>=k.width*k.height||T>=E.width*E.height}):[]},isNodeIntersecting:(p,g,b=!0)=>{const E=Mv(p)?p:h(p);if(!E)return!1;const S=Fo(E,g);return b&&S>0||S>=g.width*g.height||S>=E.width*E.height},updateNode:f,updateNodeData:(p,g,b={replace:!1})=>{f(p,w=>{const E=typeof g=="function"?g(w):g;return b.replace?{...w,data:E}:{...w,data:{...w.data,...E}}},b)},updateEdge:m,updateEdgeData:(p,g,b={replace:!1})=>{m(p,w=>{const E=typeof g=="function"?g(w):g;return b.replace?{...w,data:E}:{...w,data:{...w.data,...E}}},b)},getNodesBounds:p=>{const{nodeLookup:g,nodeOrigin:b}=t.getState();return JT(p,{nodeLookup:g,nodeOrigin:b})},getHandleConnections:({type:p,id:g,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}-${p}${g?`-${g}`:""}`))==null?void 0:w.values())??[])},getNodeConnections:({type:p,handleId:g,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}${p?g?`-${p}-${g}`:`-${p}`:""}`))==null?void 0:w.values())??[])},fitView:async p=>{const g=t.getState().fitViewResolver??aA();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:g}),n.nodeQueue.push(b=>[...b]),g.promise}}},[]);return I.useMemo(()=>({...a,...e,viewportInitialized:l}),[l])}const sb=e=>e.selected,Oz=typeof window<"u"?window:void 0;function Lz({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=gt(),{deleteElements:l}=ul(),a=Xo(e,{actInsideInputWithModifier:!1}),o=Xo(t,{target:Oz});I.useEffect(()=>{if(a){const{edges:s,nodes:c}=n.getState();l({nodes:c.filter(sb),edges:s.filter(sb)}),n.setState({nodesSelectionActive:!1})}},[a]),I.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function Hz(e){const t=gt();I.useEffect(()=>{const n=()=>{var a,o,s,c;if(!e.current||!(((o=(a=e.current).checkVisibility)==null?void 0:o.call(a))??!0))return!1;const l=Dm(e.current);(l.height===0||l.width===0)&&((c=(s=t.getState()).onError)==null||c.call(s,"004",ar.error004())),t.setState({width:l.width||500,height:l.height||500})};if(e.current){n(),window.addEventListener("resize",n);const l=new ResizeObserver(()=>n());return l.observe(e.current),()=>{window.removeEventListener("resize",n),l&&e.current&&l.unobserve(e.current)}}},[])}const qc={position:"absolute",width:"100%",height:"100%",top:0,left:0},Bz=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Iz({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:l=!1,panOnScrollSpeed:a=.5,panOnScrollMode:o=el.Free,zoomOnDoubleClick:s=!0,panOnDrag:c=!0,defaultViewport:h,translateExtent:f,minZoom:m,maxZoom:p,zoomActivationKeyCode:g,preventScrolling:b=!0,children:w,noWheelClassName:E,noPanClassName:S,onViewportChange:_,isControlledViewport:N,paneClickDistance:k,selectionOnDrag:T}){const M=gt(),A=I.useRef(null),{userSelectionActive:L,lib:R,connectionInProgress:V}=Ye(Bz,mt),H=Xo(g),B=I.useRef();Hz(A);const U=I.useCallback(ee=>{_==null||_({x:ee[0],y:ee[1],zoom:ee[2]}),N||M.setState({transform:ee})},[_,N]);return I.useEffect(()=>{if(A.current){B.current=VA({domNode:A.current,minZoom:m,maxZoom:p,translateExtent:f,viewport:h,onDraggingChange:z=>M.setState(G=>G.paneDragging===z?G:{paneDragging:z}),onPanZoomStart:(z,G)=>{const{onViewportChangeStart:Q,onMoveStart:K}=M.getState();K==null||K(z,G),Q==null||Q(G)},onPanZoom:(z,G)=>{const{onViewportChange:Q,onMove:K}=M.getState();K==null||K(z,G),Q==null||Q(G)},onPanZoomEnd:(z,G)=>{const{onViewportChangeEnd:Q,onMoveEnd:K}=M.getState();K==null||K(z,G),Q==null||Q(G)}});const{x:ee,y:q,zoom:F}=B.current.getViewport();return M.setState({panZoom:B.current,transform:[ee,q,F],domNode:A.current.closest(".react-flow")}),()=>{var z;(z=B.current)==null||z.destroy()}}},[]),I.useEffect(()=>{var ee;(ee=B.current)==null||ee.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:l,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:s,panOnDrag:c,zoomActivationKeyPressed:H,preventScrolling:b,noPanClassName:S,userSelectionActive:L,noWheelClassName:E,lib:R,onTransformChange:U,connectionInProgress:V,selectionOnDrag:T,paneClickDistance:k})},[e,t,n,l,a,o,s,c,H,b,S,L,E,R,U,V,T,k]),y.jsx("div",{className:"react-flow__renderer",ref:A,style:qc,children:w})}const qz=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function $z(){const{userSelectionActive:e,userSelectionRect:t}=Ye(qz,mt);return e&&t?y.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Th=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Uz=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Vz({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Go.Full,panOnDrag:l,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:h,onPaneContextMenu:f,onPaneScroll:m,onPaneMouseEnter:p,onPaneMouseMove:g,onPaneMouseLeave:b,children:w}){const E=gt(),{userSelectionActive:S,elementsSelectable:_,dragging:N,connectionInProgress:k}=Ye(Uz,mt),T=_&&(e||S),M=I.useRef(null),A=I.useRef(),L=I.useRef(new Set),R=I.useRef(new Set),V=I.useRef(!1),H=Q=>{if(V.current||k){V.current=!1;return}h==null||h(Q),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},B=Q=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){Q.preventDefault();return}f==null||f(Q)},U=m?Q=>m(Q):void 0,ee=Q=>{V.current&&(Q.stopPropagation(),V.current=!1)},q=Q=>{var X,J;const{domNode:K}=E.getState();if(A.current=K==null?void 0:K.getBoundingClientRect(),!A.current)return;const D=Q.target===M.current;if(!D&&!!Q.target.closest(".nokey")||!e||!(o&&D||t)||Q.button!==0||!Q.isPrimary)return;(J=(X=Q.target)==null?void 0:X.setPointerCapture)==null||J.call(X,Q.pointerId),V.current=!1;const{x:C,y:P}=Vn(Q.nativeEvent,A.current);E.setState({userSelectionRect:{width:0,height:0,startX:C,startY:P,x:C,y:P}}),D||(Q.stopPropagation(),Q.preventDefault())},F=Q=>{const{userSelectionRect:K,transform:D,nodeLookup:$,edgeLookup:Y,connectionLookup:C,triggerNodeChanges:P,triggerEdgeChanges:X,defaultEdgeOptions:J,resetSelectedElements:ne}=E.getState();if(!A.current||!K)return;const{x:re,y:ue}=Vn(Q.nativeEvent,A.current),{startX:xe,startY:be}=K;if(!V.current){const je=t?0:a;if(Math.hypot(re-xe,ue-be)<=je)return;ne(),s==null||s(Q)}V.current=!0;const ye={startX:xe,startY:be,x:reje.id)),R.current=new Set;const Oe=(J==null?void 0:J.selectable)??!0;for(const je of L.current){const ft=C.get(je);if(ft)for(const{edgeId:rt}of ft.values()){const Dt=Y.get(rt);Dt&&(Dt.selectable??Oe)&&R.current.add(rt)}}if(!Dv(pe,L.current)){const je=aa($,L.current,!0);P(je)}if(!Dv(Se,R.current)){const je=aa(Y,R.current);X(je)}E.setState({userSelectionRect:ye,userSelectionActive:!0,nodesSelectionActive:!1})},z=Q=>{var K,D;Q.button===0&&((D=(K=Q.target)==null?void 0:K.releasePointerCapture)==null||D.call(K,Q.pointerId),!S&&Q.target===M.current&&E.getState().userSelectionRect&&(H==null||H(Q)),E.setState({userSelectionActive:!1,userSelectionRect:null}),V.current&&(c==null||c(Q),E.setState({nodesSelectionActive:L.current.size>0})))},G=l===!0||Array.isArray(l)&&l.includes(0);return y.jsxs("div",{className:Mt(["react-flow__pane",{draggable:G,dragging:N,selection:e}]),onClick:T?void 0:Th(H,M),onContextMenu:Th(B,M),onWheel:Th(U,M),onPointerEnter:T?void 0:p,onPointerMove:T?F:g,onPointerUp:T?z:void 0,onPointerDownCapture:T?q:void 0,onClickCapture:T?ee:void 0,onPointerLeave:b,ref:M,style:qc,children:[w,y.jsx($z,{})]})}function lm({id:e,store:t,unselect:n=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:o,multiSelectionActive:s,nodeLookup:c,onError:h}=t.getState(),f=c.get(e);if(!f){h==null||h("012",ar.error012(e));return}t.setState({nodesSelectionActive:!1}),f.selected?(n||f.selected&&s)&&(o({nodes:[f],edges:[]}),requestAnimationFrame(()=>{var m;return(m=l==null?void 0:l.current)==null?void 0:m.blur()})):a([e])}function iS({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:l,nodeId:a,isSelectable:o,nodeClickDistance:s}){const c=gt(),[h,f]=I.useState(!1),m=I.useRef();return I.useEffect(()=>{m.current=TA({getStoreItems:()=>c.getState(),onNodeMouseDown:p=>{lm({id:p,store:c,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),I.useEffect(()=>{if(!(t||!e.current||!m.current))return m.current.update({noDragClassName:n,handleSelector:l,domNode:e.current,isSelectable:o,nodeId:a,nodeClickDistance:s}),()=>{var p;(p=m.current)==null||p.destroy()}},[n,l,t,o,e,a,s]),h}const Pz=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function lS(){const e=gt();return I.useCallback(n=>{const{nodeExtent:l,snapToGrid:a,snapGrid:o,nodesDraggable:s,onError:c,updateNodePositions:h,nodeLookup:f,nodeOrigin:m}=e.getState(),p=new Map,g=Pz(s),b=a?o[0]:5,w=a?o[1]:5,E=n.direction.x*b*n.factor,S=n.direction.y*w*n.factor;for(const[,_]of f){if(!g(_))continue;let N={x:_.internals.positionAbsolute.x+E,y:_.internals.positionAbsolute.y+S};a&&(N=rs(N,o));const{position:k,positionAbsolute:T}=E_({nodeId:_.id,nextPosition:N,nodeLookup:f,nodeExtent:l,nodeOrigin:m,onError:c});_.position=k,_.internals.positionAbsolute=T,p.set(_.id,_)}h(p)},[])}const qm=I.createContext(null),Gz=qm.Provider;qm.Consumer;const aS=()=>I.useContext(qm),Fz=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Yz=(e,t,n)=>l=>{const{connectionClickStartHandle:a,connectionMode:o,connection:s}=l,{fromHandle:c,toHandle:h,isValid:f}=s,m=(h==null?void 0:h.nodeId)===e&&(h==null?void 0:h.id)===t&&(h==null?void 0:h.type)===n;return{connectingFrom:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n,connectingTo:m,clickConnecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,isPossibleEndHandle:o===ma.Strict?(c==null?void 0:c.type)!==n:e!==(c==null?void 0:c.nodeId)||t!==(c==null?void 0:c.id),connectionInProcess:!!c,clickConnectionInProcess:!!a,valid:m&&f}};function Xz({type:e="source",position:t=ve.Top,isValidConnection:n,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:o=!0,id:s,onConnect:c,children:h,className:f,onMouseDown:m,onTouchStart:p,...g},b){var F,z;const w=s||null,E=e==="target",S=gt(),_=aS(),{connectOnClick:N,noPanClassName:k,rfId:T}=Ye(Fz,mt),{connectingFrom:M,connectingTo:A,clickConnecting:L,isPossibleEndHandle:R,connectionInProcess:V,clickConnectionInProcess:H,valid:B}=Ye(Yz(_,w,e),mt);_||(z=(F=S.getState()).onError)==null||z.call(F,"010",ar.error010());const U=G=>{const{defaultEdgeOptions:Q,onConnect:K,hasDefaultEdges:D}=S.getState(),$={...Q,...G};if(D){const{edges:Y,setEdges:C}=S.getState();C(hA($,Y))}K==null||K($),c==null||c($)},ee=G=>{if(!_)return;const Q=D_(G.nativeEvent);if(a&&(Q&&G.button===0||!Q)){const K=S.getState();im.onPointerDown(G.nativeEvent,{handleDomNode:G.currentTarget,autoPanOnConnect:K.autoPanOnConnect,connectionMode:K.connectionMode,connectionRadius:K.connectionRadius,domNode:K.domNode,nodeLookup:K.nodeLookup,lib:K.lib,isTarget:E,handleId:w,nodeId:_,flowId:K.rfId,panBy:K.panBy,cancelConnection:K.cancelConnection,onConnectStart:K.onConnectStart,onConnectEnd:(...D)=>{var $,Y;return(Y=($=S.getState()).onConnectEnd)==null?void 0:Y.call($,...D)},updateConnection:K.updateConnection,onConnect:U,isValidConnection:n||((...D)=>{var $,Y;return((Y=($=S.getState()).isValidConnection)==null?void 0:Y.call($,...D))??!0}),getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,autoPanSpeed:K.autoPanSpeed,dragThreshold:K.connectionDragThreshold})}Q?m==null||m(G):p==null||p(G)},q=G=>{const{onClickConnectStart:Q,onClickConnectEnd:K,connectionClickStartHandle:D,connectionMode:$,isValidConnection:Y,lib:C,rfId:P,nodeLookup:X,connection:J}=S.getState();if(!_||!D&&!a)return;if(!D){Q==null||Q(G.nativeEvent,{nodeId:_,handleId:w,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:_,type:e,id:w}});return}const ne=z_(G.target),re=n||Y,{connection:ue,isValid:xe}=im.isValid(G.nativeEvent,{handle:{nodeId:_,id:w,type:e},connectionMode:$,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:re,flowId:P,doc:ne,lib:C,nodeLookup:X});xe&&ue&&U(ue);const be=structuredClone(J);delete be.inProgress,be.toPosition=be.toHandle?be.toHandle.position:null,K==null||K(G,be),S.setState({connectionClickStartHandle:null})};return y.jsx("div",{"data-handleid":w,"data-nodeid":_,"data-handlepos":t,"data-id":`${T}-${_}-${w}-${e}`,className:Mt(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",k,f,{source:!E,target:E,connectable:l,connectablestart:a,connectableend:o,clickconnecting:L,connectingfrom:M,connectingto:A,valid:B,connectionindicator:l&&(!V||R)&&(V||H?o:a)}]),onMouseDown:ee,onTouchStart:ee,onClick:N?q:void 0,ref:b,...g,children:h})}const bt=I.memo(nS(Xz));function Qz({data:e,isConnectable:t,sourcePosition:n=ve.Bottom}){return y.jsxs(y.Fragment,{children:[e==null?void 0:e.label,y.jsx(bt,{type:"source",position:n,isConnectable:t})]})}function Zz({data:e,isConnectable:t,targetPosition:n=ve.Top,sourcePosition:l=ve.Bottom}){return y.jsxs(y.Fragment,{children:[y.jsx(bt,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,y.jsx(bt,{type:"source",position:l,isConnectable:t})]})}function Kz(){return null}function Jz({data:e,isConnectable:t,targetPosition:n=ve.Top}){return y.jsxs(y.Fragment,{children:[y.jsx(bt,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const yc={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ub={input:Qz,default:Zz,output:Jz,group:Kz};function Wz(e){var t,n,l,a;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((l=e.style)==null?void 0:l.width),height:e.height??((a=e.style)==null?void 0:a.height)}}const eM=e=>{const{width:t,height:n,x:l,y:a}=ns(e.nodeLookup,{filter:o=>!!o.selected});return{width:Un(t)?t:null,height:Un(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${l}px,${a}px)`}};function tM({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const l=gt(),{width:a,height:o,transformString:s,userSelectionActive:c}=Ye(eM,mt),h=lS(),f=I.useRef(null);I.useEffect(()=>{var b;n||(b=f.current)==null||b.focus({preventScroll:!0})},[n]);const m=!c&&a!==null&&o!==null;if(iS({nodeRef:f,disabled:!m}),!m)return null;const p=e?b=>{const w=l.getState().nodes.filter(E=>E.selected);e(b,w)}:void 0,g=b=>{Object.prototype.hasOwnProperty.call(yc,b.key)&&(b.preventDefault(),h({direction:yc[b.key],factor:b.shiftKey?4:1}))};return y.jsx("div",{className:Mt(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:y.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:g,style:{width:a,height:o}})})}const cb=typeof window<"u"?window:void 0,nM=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function oS({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:s,paneClickDistance:c,deleteKeyCode:h,selectionKeyCode:f,selectionOnDrag:m,selectionMode:p,onSelectionStart:g,onSelectionEnd:b,multiSelectionKeyCode:w,panActivationKeyCode:E,zoomActivationKeyCode:S,elementsSelectable:_,zoomOnScroll:N,zoomOnPinch:k,panOnScroll:T,panOnScrollSpeed:M,panOnScrollMode:A,zoomOnDoubleClick:L,panOnDrag:R,defaultViewport:V,translateExtent:H,minZoom:B,maxZoom:U,preventScrolling:ee,onSelectionContextMenu:q,noWheelClassName:F,noPanClassName:z,disableKeyboardA11y:G,onViewportChange:Q,isControlledViewport:K}){const{nodesSelectionActive:D,userSelectionActive:$}=Ye(nM,mt),Y=Xo(f,{target:cb}),C=Xo(E,{target:cb}),P=C||R,X=C||T,J=m&&P!==!0,ne=Y||$||J;return Lz({deleteKeyCode:h,multiSelectionKeyCode:w}),y.jsx(Iz,{onPaneContextMenu:o,elementsSelectable:_,zoomOnScroll:N,zoomOnPinch:k,panOnScroll:X,panOnScrollSpeed:M,panOnScrollMode:A,zoomOnDoubleClick:L,panOnDrag:!Y&&P,defaultViewport:V,translateExtent:H,minZoom:B,maxZoom:U,zoomActivationKeyCode:S,preventScrolling:ee,noWheelClassName:F,noPanClassName:z,onViewportChange:Q,isControlledViewport:K,paneClickDistance:c,selectionOnDrag:J,children:y.jsxs(Vz,{onSelectionStart:g,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:s,panOnDrag:P,isSelecting:!!ne,selectionMode:p,selectionKeyPressed:Y,paneClickDistance:c,selectionOnDrag:J,children:[e,D&&y.jsx(tM,{onSelectionContextMenu:q,noPanClassName:z,disableKeyboardA11y:G})]})})}oS.displayName="FlowRenderer";const rM=I.memo(oS),iM=e=>t=>e?zm(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function lM(e){return Ye(I.useCallback(iM(e),[e]),mt)}const aM=e=>e.updateNodeInternals;function oM(){const e=Ye(aM),[t]=I.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const l=new Map;n.forEach(a=>{const o=a.target.getAttribute("data-id");l.set(o,{id:o,nodeElement:a.target,force:!0})}),e(l)}));return I.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function sM({node:e,nodeType:t,hasDimensions:n,resizeObserver:l}){const a=gt(),o=I.useRef(null),s=I.useRef(null),c=I.useRef(e.sourcePosition),h=I.useRef(e.targetPosition),f=I.useRef(t),m=n&&!!e.internals.handleBounds;return I.useEffect(()=>{o.current&&!e.hidden&&(!m||s.current!==o.current)&&(s.current&&(l==null||l.unobserve(s.current)),l==null||l.observe(o.current),s.current=o.current)},[m,e.hidden]),I.useEffect(()=>()=>{s.current&&(l==null||l.unobserve(s.current),s.current=null)},[]),I.useEffect(()=>{if(o.current){const p=f.current!==t,g=c.current!==e.sourcePosition,b=h.current!==e.targetPosition;(p||g||b)&&(f.current=t,c.current=e.sourcePosition,h.current=e.targetPosition,a.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function uM({id:e,onClick:t,onMouseEnter:n,onMouseMove:l,onMouseLeave:a,onContextMenu:o,onDoubleClick:s,nodesDraggable:c,elementsSelectable:h,nodesConnectable:f,nodesFocusable:m,resizeObserver:p,noDragClassName:g,noPanClassName:b,disableKeyboardA11y:w,rfId:E,nodeTypes:S,nodeClickDistance:_,onError:N}){const{node:k,internals:T,isParent:M}=Ye(re=>{const ue=re.nodeLookup.get(e),xe=re.parentLookup.has(e);return{node:ue,internals:ue.internals,isParent:xe}},mt);let A=k.type||"default",L=(S==null?void 0:S[A])||ub[A];L===void 0&&(N==null||N("003",ar.error003(A)),A="default",L=(S==null?void 0:S.default)||ub.default);const R=!!(k.draggable||c&&typeof k.draggable>"u"),V=!!(k.selectable||h&&typeof k.selectable>"u"),H=!!(k.connectable||f&&typeof k.connectable>"u"),B=!!(k.focusable||m&&typeof k.focusable>"u"),U=gt(),ee=T_(k),q=sM({node:k,nodeType:A,hasDimensions:ee,resizeObserver:p}),F=iS({nodeRef:q,disabled:k.hidden||!R,noDragClassName:g,handleSelector:k.dragHandle,nodeId:e,isSelectable:V,nodeClickDistance:_}),z=lS();if(k.hidden)return null;const G=Hr(k),Q=Wz(k),K=V||R||t||n||l||a,D=n?re=>n(re,{...T.userNode}):void 0,$=l?re=>l(re,{...T.userNode}):void 0,Y=a?re=>a(re,{...T.userNode}):void 0,C=o?re=>o(re,{...T.userNode}):void 0,P=s?re=>s(re,{...T.userNode}):void 0,X=re=>{const{selectNodesOnDrag:ue,nodeDragThreshold:xe}=U.getState();V&&(!ue||!R||xe>0)&&lm({id:e,store:U,nodeRef:q}),t&&t(re,{...T.userNode})},J=re=>{if(!(M_(re.nativeEvent)||w)){if(b_.includes(re.key)&&V){const ue=re.key==="Escape";lm({id:e,store:U,unselect:ue,nodeRef:q})}else if(R&&k.selected&&Object.prototype.hasOwnProperty.call(yc,re.key)){re.preventDefault();const{ariaLabelConfig:ue}=U.getState();U.setState({ariaLiveMessage:ue["node.a11yDescription.ariaLiveMessage"]({direction:re.key.replace("Arrow","").toLowerCase(),x:~~T.positionAbsolute.x,y:~~T.positionAbsolute.y})}),z({direction:yc[re.key],factor:re.shiftKey?4:1})}}},ne=()=>{var Se;if(w||!((Se=q.current)!=null&&Se.matches(":focus-visible")))return;const{transform:re,width:ue,height:xe,autoPanOnNodeFocus:be,setCenter:ye}=U.getState();if(!be)return;zm(new Map([[e,k]]),{x:0,y:0,width:ue,height:xe},re,!0).length>0||ye(k.position.x+G.width/2,k.position.y+G.height/2,{zoom:re[2]})};return y.jsx("div",{className:Mt(["react-flow__node",`react-flow__node-${A}`,{[b]:R},k.className,{selected:k.selected,selectable:V,parent:M,draggable:R,dragging:F}]),ref:q,style:{zIndex:T.z,transform:`translate(${T.positionAbsolute.x}px,${T.positionAbsolute.y}px)`,pointerEvents:K?"all":"none",visibility:ee?"visible":"hidden",...k.style,...Q},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:D,onMouseMove:$,onMouseLeave:Y,onContextMenu:C,onClick:X,onDoubleClick:P,onKeyDown:B?J:void 0,tabIndex:B?0:void 0,onFocus:B?ne:void 0,role:k.ariaRole??(B?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${Z_}-${E}`,"aria-label":k.ariaLabel,...k.domAttributes,children:y.jsx(Gz,{value:e,children:y.jsx(L,{id:e,data:k.data,type:A,positionAbsoluteX:T.positionAbsolute.x,positionAbsoluteY:T.positionAbsolute.y,selected:k.selected??!1,selectable:V,draggable:R,deletable:k.deletable??!0,isConnectable:H,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:F,dragHandle:k.dragHandle,zIndex:T.z,parentId:k.parentId,...G})})})}var cM=I.memo(uM);const fM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function sS(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:l,elementsSelectable:a,onError:o}=Ye(fM,mt),s=lM(e.onlyRenderVisibleElements),c=oM();return y.jsx("div",{className:"react-flow__nodes",style:qc,children:s.map(h=>y.jsx(cM,{id:h,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t,nodesConnectable:n,nodesFocusable:l,elementsSelectable:a,nodeClickDistance:e.nodeClickDistance,onError:o},h))})}sS.displayName="NodeRenderer";const dM=I.memo(sS);function hM(e){return Ye(I.useCallback(n=>{if(!e)return n.edges.map(a=>a.id);const l=[];if(n.width&&n.height)for(const a of n.edges){const o=n.nodeLookup.get(a.source),s=n.nodeLookup.get(a.target);o&&s&&cA({sourceNode:o,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&l.push(a.id)}return l},[e]),mt)}const pM=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return y.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},mM=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return y.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},fb={[mc.Arrow]:pM,[mc.ArrowClosed]:mM};function gM(e){const t=gt();return I.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(fb,e)?fb[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",ar.error009(e)),null)},[e])}const xM=({id:e,type:t,color:n,width:l=12.5,height:a=12.5,markerUnits:o="strokeWidth",strokeWidth:s,orient:c="auto-start-reverse"})=>{const h=gM(t);return h?y.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${l}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:c,refX:"0",refY:"0",children:y.jsx(h,{color:n,strokeWidth:s})}):null},uS=({defaultColor:e,rfId:t})=>{const n=Ye(o=>o.edges),l=Ye(o=>o.defaultEdgeOptions),a=I.useMemo(()=>yA(n,{id:t,defaultColor:e,defaultMarkerStart:l==null?void 0:l.markerStart,defaultMarkerEnd:l==null?void 0:l.markerEnd}),[n,l,t,e]);return a.length?y.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:y.jsx("defs",{children:a.map(o=>y.jsx(xM,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};uS.displayName="MarkerDefinitions";var yM=I.memo(uS);function cS({x:e,y:t,label:n,labelStyle:l,labelShowBg:a=!0,labelBgStyle:o,labelBgPadding:s=[2,4],labelBgBorderRadius:c=2,children:h,className:f,...m}){const[p,g]=I.useState({x:1,y:0,width:0,height:0}),b=Mt(["react-flow__edge-textwrapper",f]),w=I.useRef(null);return I.useEffect(()=>{if(w.current){const E=w.current.getBBox();g({x:E.x,y:E.y,width:E.width,height:E.height})}},[n]),n?y.jsxs("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:b,visibility:p.width?"visible":"hidden",...m,children:[a&&y.jsx("rect",{width:p.width+2*s[0],x:-s[0],y:-s[1],height:p.height+2*s[1],className:"react-flow__edge-textbg",style:o,rx:c,ry:c}),y.jsx("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:w,style:l,children:n}),h]}):null}cS.displayName="EdgeText";const vM=I.memo(cS);function ls({path:e,labelX:t,labelY:n,label:l,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:h,interactionWidth:f=20,...m}){return y.jsxs(y.Fragment,{children:[y.jsx("path",{...m,d:e,fill:"none",className:Mt(["react-flow__edge-path",m.className])}),f?y.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,l&&Un(t)&&Un(n)?y.jsx(vM,{x:t,y:n,label:l,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:h}):null]})}function db({pos:e,x1:t,y1:n,x2:l,y2:a}){return e===ve.Left||e===ve.Right?[.5*(t+l),n]:[t,.5*(n+a)]}function fS({sourceX:e,sourceY:t,sourcePosition:n=ve.Bottom,targetX:l,targetY:a,targetPosition:o=ve.Top}){const[s,c]=db({pos:n,x1:e,y1:t,x2:l,y2:a}),[h,f]=db({pos:o,x1:l,y1:a,x2:e,y2:t}),[m,p,g,b]=R_({sourceX:e,sourceY:t,targetX:l,targetY:a,sourceControlX:s,sourceControlY:c,targetControlX:h,targetControlY:f});return[`M${e},${t} C${s},${c} ${h},${f} ${l},${a}`,m,p,g,b]}function dS(e){return I.memo(({id:t,sourceX:n,sourceY:l,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,label:h,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,interactionWidth:_})=>{const[N,k,T]=fS({sourceX:n,sourceY:l,sourcePosition:s,targetX:a,targetY:o,targetPosition:c}),M=e.isInternal?void 0:t;return y.jsx(ls,{id:M,path:N,labelX:k,labelY:T,label:h,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,interactionWidth:_})})}const bM=dS({isInternal:!1}),hS=dS({isInternal:!0});bM.displayName="SimpleBezierEdge";hS.displayName="SimpleBezierEdgeInternal";function pS(e){return I.memo(({id:t,sourceX:n,sourceY:l,targetX:a,targetY:o,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:g,sourcePosition:b=ve.Bottom,targetPosition:w=ve.Top,markerEnd:E,markerStart:S,pathOptions:_,interactionWidth:N})=>{const[k,T,M]=tm({sourceX:n,sourceY:l,sourcePosition:b,targetX:a,targetY:o,targetPosition:w,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset,stepPosition:_==null?void 0:_.stepPosition}),A=e.isInternal?void 0:t;return y.jsx(ls,{id:A,path:k,labelX:T,labelY:M,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:g,markerEnd:E,markerStart:S,interactionWidth:N})})}const mS=pS({isInternal:!1}),gS=pS({isInternal:!0});mS.displayName="SmoothStepEdge";gS.displayName="SmoothStepEdgeInternal";function xS(e){return I.memo(({id:t,...n})=>{var a;const l=e.isInternal?void 0:t;return y.jsx(mS,{...n,id:l,pathOptions:I.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(a=n.pathOptions)==null?void 0:a.offset])})})}const wM=xS({isInternal:!1}),yS=xS({isInternal:!0});wM.displayName="StepEdge";yS.displayName="StepEdgeInternal";function vS(e){return I.memo(({id:t,sourceX:n,sourceY:l,targetX:a,targetY:o,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:g,markerEnd:b,markerStart:w,interactionWidth:E})=>{const[S,_,N]=L_({sourceX:n,sourceY:l,targetX:a,targetY:o}),k=e.isInternal?void 0:t;return y.jsx(ls,{id:k,path:S,labelX:_,labelY:N,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:g,markerEnd:b,markerStart:w,interactionWidth:E})})}const _M=vS({isInternal:!1}),bS=vS({isInternal:!0});_M.displayName="StraightEdge";bS.displayName="StraightEdgeInternal";function wS(e){return I.memo(({id:t,sourceX:n,sourceY:l,targetX:a,targetY:o,sourcePosition:s=ve.Bottom,targetPosition:c=ve.Top,label:h,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,pathOptions:_,interactionWidth:N})=>{const[k,T,M]=Rm({sourceX:n,sourceY:l,sourcePosition:s,targetX:a,targetY:o,targetPosition:c,curvature:_==null?void 0:_.curvature}),A=e.isInternal?void 0:t;return y.jsx(ls,{id:A,path:k,labelX:T,labelY:M,label:h,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,interactionWidth:N})})}const SM=wS({isInternal:!1}),_S=wS({isInternal:!0});SM.displayName="BezierEdge";_S.displayName="BezierEdgeInternal";const hb={default:_S,straight:bS,step:yS,smoothstep:gS,simplebezier:hS},pb={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},kM=(e,t,n)=>n===ve.Left?e-t:n===ve.Right?e+t:e,EM=(e,t,n)=>n===ve.Top?e-t:n===ve.Bottom?e+t:e,mb="react-flow__edgeupdater";function gb({position:e,centerX:t,centerY:n,radius:l=10,onMouseDown:a,onMouseEnter:o,onMouseOut:s,type:c}){return y.jsx("circle",{onMouseDown:a,onMouseEnter:o,onMouseOut:s,className:Mt([mb,`${mb}-${c}`]),cx:kM(t,l,e),cy:EM(n,l,e),r:l,stroke:"transparent",fill:"transparent"})}function NM({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:l,sourceY:a,targetX:o,targetY:s,sourcePosition:c,targetPosition:h,onReconnect:f,onReconnectStart:m,onReconnectEnd:p,setReconnecting:g,setUpdateHover:b}){const w=gt(),E=(T,M)=>{if(T.button!==0)return;const{autoPanOnConnect:A,domNode:L,connectionMode:R,connectionRadius:V,lib:H,onConnectStart:B,cancelConnection:U,nodeLookup:ee,rfId:q,panBy:F,updateConnection:z}=w.getState(),G=M.type==="target",Q=($,Y)=>{g(!1),p==null||p($,n,M.type,Y)},K=$=>f==null?void 0:f(n,$),D=($,Y)=>{g(!0),m==null||m(T,n,M.type),B==null||B($,Y)};im.onPointerDown(T.nativeEvent,{autoPanOnConnect:A,connectionMode:R,connectionRadius:V,domNode:L,handleId:M.id,nodeId:M.nodeId,nodeLookup:ee,isTarget:G,edgeUpdaterType:M.type,lib:H,flowId:q,cancelConnection:U,panBy:F,isValidConnection:(...$)=>{var Y,C;return((C=(Y=w.getState()).isValidConnection)==null?void 0:C.call(Y,...$))??!0},onConnect:K,onConnectStart:D,onConnectEnd:(...$)=>{var Y,C;return(C=(Y=w.getState()).onConnectEnd)==null?void 0:C.call(Y,...$)},onReconnectEnd:Q,updateConnection:z,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:T.currentTarget})},S=T=>E(T,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),_=T=>E(T,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),N=()=>b(!0),k=()=>b(!1);return y.jsxs(y.Fragment,{children:[(e===!0||e==="source")&&y.jsx(gb,{position:c,centerX:l,centerY:a,radius:t,onMouseDown:S,onMouseEnter:N,onMouseOut:k,type:"source"}),(e===!0||e==="target")&&y.jsx(gb,{position:h,centerX:o,centerY:s,radius:t,onMouseDown:_,onMouseEnter:N,onMouseOut:k,type:"target"})]})}function CM({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:l,onClick:a,onDoubleClick:o,onContextMenu:s,onMouseEnter:c,onMouseMove:h,onMouseLeave:f,reconnectRadius:m,onReconnect:p,onReconnectStart:g,onReconnectEnd:b,rfId:w,edgeTypes:E,noPanClassName:S,onError:_,disableKeyboardA11y:N}){let k=Ye(ye=>ye.edgeLookup.get(e));const T=Ye(ye=>ye.defaultEdgeOptions);k=T?{...T,...k}:k;let M=k.type||"default",A=(E==null?void 0:E[M])||hb[M];A===void 0&&(_==null||_("011",ar.error011(M)),M="default",A=(E==null?void 0:E.default)||hb.default);const L=!!(k.focusable||t&&typeof k.focusable>"u"),R=typeof p<"u"&&(k.reconnectable||n&&typeof k.reconnectable>"u"),V=!!(k.selectable||l&&typeof k.selectable>"u"),H=I.useRef(null),[B,U]=I.useState(!1),[ee,q]=I.useState(!1),F=gt(),{zIndex:z,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:$,targetPosition:Y}=Ye(I.useCallback(ye=>{const pe=ye.nodeLookup.get(k.source),Se=ye.nodeLookup.get(k.target);if(!pe||!Se)return{zIndex:k.zIndex,...pb};const Oe=xA({id:e,sourceNode:pe,targetNode:Se,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:ye.connectionMode,onError:_});return{zIndex:uA({selected:k.selected,zIndex:k.zIndex,sourceNode:pe,targetNode:Se,elevateOnSelect:ye.elevateEdgesOnSelect,zIndexMode:ye.zIndexMode}),...Oe||pb}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex]),mt),C=I.useMemo(()=>k.markerStart?`url('#${nm(k.markerStart,w)}')`:void 0,[k.markerStart,w]),P=I.useMemo(()=>k.markerEnd?`url('#${nm(k.markerEnd,w)}')`:void 0,[k.markerEnd,w]);if(k.hidden||G===null||Q===null||K===null||D===null)return null;const X=ye=>{var je;const{addSelectedEdges:pe,unselectNodesAndEdges:Se,multiSelectionActive:Oe}=F.getState();V&&(F.setState({nodesSelectionActive:!1}),k.selected&&Oe?(Se({nodes:[],edges:[k]}),(je=H.current)==null||je.blur()):pe([e])),a&&a(ye,k)},J=o?ye=>{o(ye,{...k})}:void 0,ne=s?ye=>{s(ye,{...k})}:void 0,re=c?ye=>{c(ye,{...k})}:void 0,ue=h?ye=>{h(ye,{...k})}:void 0,xe=f?ye=>{f(ye,{...k})}:void 0,be=ye=>{var pe;if(!N&&b_.includes(ye.key)&&V){const{unselectNodesAndEdges:Se,addSelectedEdges:Oe}=F.getState();ye.key==="Escape"?((pe=H.current)==null||pe.blur(),Se({edges:[k]})):Oe([e])}};return y.jsx("svg",{style:{zIndex:z},children:y.jsxs("g",{className:Mt(["react-flow__edge",`react-flow__edge-${M}`,k.className,S,{selected:k.selected,animated:k.animated,inactive:!V&&!a,updating:B,selectable:V}]),onClick:X,onDoubleClick:J,onContextMenu:ne,onMouseEnter:re,onMouseMove:ue,onMouseLeave:xe,onKeyDown:L?be:void 0,tabIndex:L?0:void 0,role:k.ariaRole??(L?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":L?`${K_}-${w}`:void 0,ref:H,...k.domAttributes,children:[!ee&&y.jsx(A,{id:e,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:V,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:$,targetPosition:Y,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:C,markerEnd:P,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),R&&y.jsx(NM,{edge:k,isReconnectable:R,reconnectRadius:m,onReconnect:p,onReconnectStart:g,onReconnectEnd:b,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:$,targetPosition:Y,setUpdateHover:U,setReconnecting:q})]})})}var jM=I.memo(CM);const TM=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function SS({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:l,noPanClassName:a,onReconnect:o,onEdgeContextMenu:s,onEdgeMouseEnter:c,onEdgeMouseMove:h,onEdgeMouseLeave:f,onEdgeClick:m,reconnectRadius:p,onEdgeDoubleClick:g,onReconnectStart:b,onReconnectEnd:w,disableKeyboardA11y:E}){const{edgesFocusable:S,edgesReconnectable:_,elementsSelectable:N,onError:k}=Ye(TM,mt),T=hM(t);return y.jsxs("div",{className:"react-flow__edges",children:[y.jsx(yM,{defaultColor:e,rfId:n}),T.map(M=>y.jsx(jM,{id:M,edgesFocusable:S,edgesReconnectable:_,elementsSelectable:N,noPanClassName:a,onReconnect:o,onContextMenu:s,onMouseEnter:c,onMouseMove:h,onMouseLeave:f,onClick:m,reconnectRadius:p,onDoubleClick:g,onReconnectStart:b,onReconnectEnd:w,rfId:n,onError:k,edgeTypes:l,disableKeyboardA11y:E},M))]})}SS.displayName="EdgeRenderer";const AM=I.memo(SS),zM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function MM({children:e}){const t=Ye(zM);return y.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function DM(e){const t=ul(),n=I.useRef(!1);I.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const RM=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function OM(e){const t=Ye(RM),n=gt();return I.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function LM(e){return e.connection.inProgress?{...e.connection,to:is(e.connection.to,e.transform)}:{...e.connection}}function HM(e){return LM}function BM(e){const t=HM();return Ye(t,mt)}const IM=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function qM({containerStyle:e,style:t,type:n,component:l}){const{nodesConnectable:a,width:o,height:s,isValid:c,inProgress:h}=Ye(IM,mt);return!(o&&a&&h)?null:y.jsx("svg",{style:e,width:o,height:s,className:"react-flow__connectionline react-flow__container",children:y.jsx("g",{className:Mt(["react-flow__connection",S_(c)]),children:y.jsx(kS,{style:t,type:n,CustomComponent:l,isValid:c})})})}const kS=({style:e,type:t=bi.Bezier,CustomComponent:n,isValid:l})=>{const{inProgress:a,from:o,fromNode:s,fromHandle:c,fromPosition:h,to:f,toNode:m,toHandle:p,toPosition:g,pointer:b}=BM();if(!a)return;if(n)return y.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:c,fromX:o.x,fromY:o.y,toX:f.x,toY:f.y,fromPosition:h,toPosition:g,connectionStatus:S_(l),toNode:m,toHandle:p,pointer:b});let w="";const E={sourceX:o.x,sourceY:o.y,sourcePosition:h,targetX:f.x,targetY:f.y,targetPosition:g};switch(t){case bi.Bezier:[w]=Rm(E);break;case bi.SimpleBezier:[w]=fS(E);break;case bi.Step:[w]=tm({...E,borderRadius:0});break;case bi.SmoothStep:[w]=tm(E);break;default:[w]=L_(E)}return y.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};kS.displayName="ConnectionLine";const $M={};function xb(e=$M){I.useRef(e),gt(),I.useEffect(()=>{},[e])}function UM(){gt(),I.useRef(!1),I.useEffect(()=>{},[])}function ES({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:o,onEdgeDoubleClick:s,onNodeMouseEnter:c,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:m,onSelectionContextMenu:p,onSelectionStart:g,onSelectionEnd:b,connectionLineType:w,connectionLineStyle:E,connectionLineComponent:S,connectionLineContainerStyle:_,selectionKeyCode:N,selectionOnDrag:k,selectionMode:T,multiSelectionKeyCode:M,panActivationKeyCode:A,zoomActivationKeyCode:L,deleteKeyCode:R,onlyRenderVisibleElements:V,elementsSelectable:H,defaultViewport:B,translateExtent:U,minZoom:ee,maxZoom:q,preventScrolling:F,defaultMarkerColor:z,zoomOnScroll:G,zoomOnPinch:Q,panOnScroll:K,panOnScrollSpeed:D,panOnScrollMode:$,zoomOnDoubleClick:Y,panOnDrag:C,onPaneClick:P,onPaneMouseEnter:X,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneScroll:re,onPaneContextMenu:ue,paneClickDistance:xe,nodeClickDistance:be,onEdgeContextMenu:ye,onEdgeMouseEnter:pe,onEdgeMouseMove:Se,onEdgeMouseLeave:Oe,reconnectRadius:je,onReconnect:ft,onReconnectStart:rt,onReconnectEnd:Dt,noDragClassName:Pt,noWheelClassName:Bt,noPanClassName:kn,disableKeyboardA11y:Rn,nodeExtent:Rt,rfId:qr,viewport:ce,onViewportChange:ge}){return xb(e),xb(t),UM(),DM(n),OM(ce),y.jsx(rM,{onPaneClick:P,onPaneMouseEnter:X,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneContextMenu:ue,onPaneScroll:re,paneClickDistance:xe,deleteKeyCode:R,selectionKeyCode:N,selectionOnDrag:k,selectionMode:T,onSelectionStart:g,onSelectionEnd:b,multiSelectionKeyCode:M,panActivationKeyCode:A,zoomActivationKeyCode:L,elementsSelectable:H,zoomOnScroll:G,zoomOnPinch:Q,zoomOnDoubleClick:Y,panOnScroll:K,panOnScrollSpeed:D,panOnScrollMode:$,panOnDrag:C,defaultViewport:B,translateExtent:U,minZoom:ee,maxZoom:q,onSelectionContextMenu:p,preventScrolling:F,noDragClassName:Pt,noWheelClassName:Bt,noPanClassName:kn,disableKeyboardA11y:Rn,onViewportChange:ge,isControlledViewport:!!ce,children:y.jsxs(MM,{children:[y.jsx(AM,{edgeTypes:t,onEdgeClick:a,onEdgeDoubleClick:s,onReconnect:ft,onReconnectStart:rt,onReconnectEnd:Dt,onlyRenderVisibleElements:V,onEdgeContextMenu:ye,onEdgeMouseEnter:pe,onEdgeMouseMove:Se,onEdgeMouseLeave:Oe,reconnectRadius:je,defaultMarkerColor:z,noPanClassName:kn,disableKeyboardA11y:Rn,rfId:qr}),y.jsx(qM,{style:E,type:w,component:S,containerStyle:_}),y.jsx("div",{className:"react-flow__edgelabel-renderer"}),y.jsx(dM,{nodeTypes:e,onNodeClick:l,onNodeDoubleClick:o,onNodeMouseEnter:c,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:m,nodeClickDistance:be,onlyRenderVisibleElements:V,noPanClassName:kn,noDragClassName:Pt,disableKeyboardA11y:Rn,nodeExtent:Rt,rfId:qr}),y.jsx("div",{className:"react-flow__viewport-portal"})]})})}ES.displayName="GraphView";const VM=I.memo(ES),yb=({nodes:e,edges:t,defaultNodes:n,defaultEdges:l,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:h=.5,maxZoom:f=2,nodeOrigin:m,nodeExtent:p,zIndexMode:g="basic"}={})=>{const b=new Map,w=new Map,E=new Map,S=new Map,_=l??t??[],N=n??e??[],k=m??[0,0],T=p??Po;I_(E,S,_);const M=rm(N,b,w,{nodeOrigin:k,nodeExtent:T,zIndexMode:g});let A=[0,0,1];if(s&&a&&o){const L=ns(b,{filter:B=>!!((B.width||B.initialWidth)&&(B.height||B.initialHeight))}),{x:R,y:V,zoom:H}=Mm(L,a,o,h,f,(c==null?void 0:c.padding)??.1);A=[R,V,H]}return{rfId:"1",width:a??0,height:o??0,transform:A,nodes:N,nodesInitialized:M,nodeLookup:b,parentLookup:w,edges:_,edgeLookup:S,connectionLookup:E,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:h,maxZoom:f,translateExtent:Po,nodeExtent:T,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ma.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:k,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:c,fitViewResolver:null,connection:{...__},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:rA,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:w_,zIndexMode:g,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},PM=({nodes:e,edges:t,defaultNodes:n,defaultEdges:l,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:h,maxZoom:f,nodeOrigin:m,nodeExtent:p,zIndexMode:g})=>oz((b,w)=>{async function E(){const{nodeLookup:S,panZoom:_,fitViewOptions:N,fitViewResolver:k,width:T,height:M,minZoom:A,maxZoom:L}=w();_&&(await tA({nodes:S,width:T,height:M,panZoom:_,minZoom:A,maxZoom:L},N),k==null||k.resolve(!0),b({fitViewResolver:null}))}return{...yb({nodes:e,edges:t,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:h,maxZoom:f,nodeOrigin:m,nodeExtent:p,defaultNodes:n,defaultEdges:l,zIndexMode:g}),setNodes:S=>{const{nodeLookup:_,parentLookup:N,nodeOrigin:k,elevateNodesOnSelect:T,fitViewQueued:M,zIndexMode:A}=w(),L=rm(S,_,N,{nodeOrigin:k,nodeExtent:p,elevateNodesOnSelect:T,checkEquality:!0,zIndexMode:A});M&&L?(E(),b({nodes:S,nodesInitialized:L,fitViewQueued:!1,fitViewOptions:void 0})):b({nodes:S,nodesInitialized:L})},setEdges:S=>{const{connectionLookup:_,edgeLookup:N}=w();I_(_,N,S),b({edges:S})},setDefaultNodesAndEdges:(S,_)=>{if(S){const{setNodes:N}=w();N(S),b({hasDefaultNodes:!0})}if(_){const{setEdges:N}=w();N(_),b({hasDefaultEdges:!0})}},updateNodeInternals:S=>{const{triggerNodeChanges:_,nodeLookup:N,parentLookup:k,domNode:T,nodeOrigin:M,nodeExtent:A,debug:L,fitViewQueued:R,zIndexMode:V}=w(),{changes:H,updatedInternals:B}=EA(S,N,k,T,M,A,V);B&&(wA(N,k,{nodeOrigin:M,nodeExtent:A,zIndexMode:V}),R?(E(),b({fitViewQueued:!1,fitViewOptions:void 0})):b({}),(H==null?void 0:H.length)>0&&(L&&console.log("React Flow: trigger node changes",H),_==null||_(H)))},updateNodePositions:(S,_=!1)=>{const N=[];let k=[];const{nodeLookup:T,triggerNodeChanges:M,connection:A,updateConnection:L,onNodesChangeMiddlewareMap:R}=w();for(const[V,H]of S){const B=T.get(V),U=!!(B!=null&&B.expandParent&&(B!=null&&B.parentId)&&(H!=null&&H.position)),ee={id:V,type:"position",position:U?{x:Math.max(0,H.position.x),y:Math.max(0,H.position.y)}:H.position,dragging:_};if(B&&A.inProgress&&A.fromNode.id===B.id){const q=ll(B,A.fromHandle,ve.Left,!0);L({...A,from:q})}U&&B.parentId&&N.push({id:V,parentId:B.parentId,rect:{...H.internals.positionAbsolute,width:H.measured.width??0,height:H.measured.height??0}}),k.push(ee)}if(N.length>0){const{parentLookup:V,nodeOrigin:H}=w(),B=Im(N,T,V,H);k.push(...B)}for(const V of R.values())k=V(k);M(k)},triggerNodeChanges:S=>{const{onNodesChange:_,setNodes:N,nodes:k,hasDefaultNodes:T,debug:M}=w();if(S!=null&&S.length){if(T){const A=eS(S,k);N(A)}M&&console.log("React Flow: trigger node changes",S),_==null||_(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:_,setEdges:N,edges:k,hasDefaultEdges:T,debug:M}=w();if(S!=null&&S.length){if(T){const A=tS(S,k);N(A)}M&&console.log("React Flow: trigger edge changes",S),_==null||_(S)}},addSelectedNodes:S=>{const{multiSelectionActive:_,edgeLookup:N,nodeLookup:k,triggerNodeChanges:T,triggerEdgeChanges:M}=w();if(_){const A=S.map(L=>Xi(L,!0));T(A);return}T(aa(k,new Set([...S]),!0)),M(aa(N))},addSelectedEdges:S=>{const{multiSelectionActive:_,edgeLookup:N,nodeLookup:k,triggerNodeChanges:T,triggerEdgeChanges:M}=w();if(_){const A=S.map(L=>Xi(L,!0));M(A);return}M(aa(N,new Set([...S]))),T(aa(k,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:_}={})=>{const{edges:N,nodes:k,nodeLookup:T,triggerNodeChanges:M,triggerEdgeChanges:A}=w(),L=S||k,R=_||N,V=[];for(const B of L){if(!B.selected)continue;const U=T.get(B.id);U&&(U.selected=!1),V.push(Xi(B.id,!1))}const H=[];for(const B of R)B.selected&&H.push(Xi(B.id,!1));M(V),A(H)},setMinZoom:S=>{const{panZoom:_,maxZoom:N}=w();_==null||_.setScaleExtent([S,N]),b({minZoom:S})},setMaxZoom:S=>{const{panZoom:_,minZoom:N}=w();_==null||_.setScaleExtent([N,S]),b({maxZoom:S})},setTranslateExtent:S=>{var _;(_=w().panZoom)==null||_.setTranslateExtent(S),b({translateExtent:S})},resetSelectedElements:()=>{const{edges:S,nodes:_,triggerNodeChanges:N,triggerEdgeChanges:k,elementsSelectable:T}=w();if(!T)return;const M=_.reduce((L,R)=>R.selected?[...L,Xi(R.id,!1)]:L,[]),A=S.reduce((L,R)=>R.selected?[...L,Xi(R.id,!1)]:L,[]);N(M),k(A)},setNodeExtent:S=>{const{nodes:_,nodeLookup:N,parentLookup:k,nodeOrigin:T,elevateNodesOnSelect:M,nodeExtent:A,zIndexMode:L}=w();S[0][0]===A[0][0]&&S[0][1]===A[0][1]&&S[1][0]===A[1][0]&&S[1][1]===A[1][1]||(rm(_,N,k,{nodeOrigin:T,nodeExtent:S,elevateNodesOnSelect:M,checkEquality:!1,zIndexMode:L}),b({nodeExtent:S}))},panBy:S=>{const{transform:_,width:N,height:k,panZoom:T,translateExtent:M}=w();return NA({delta:S,panZoom:T,transform:_,translateExtent:M,width:N,height:k})},setCenter:async(S,_,N)=>{const{width:k,height:T,maxZoom:M,panZoom:A}=w();if(!A)return Promise.resolve(!1);const L=typeof(N==null?void 0:N.zoom)<"u"?N.zoom:M;return await A.setViewport({x:k/2-S*L,y:T/2-_*L,zoom:L},{duration:N==null?void 0:N.duration,ease:N==null?void 0:N.ease,interpolate:N==null?void 0:N.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{b({connection:{...__}})},updateConnection:S=>{b({connection:S})},reset:()=>b({...yb()})}},Object.is);function GM({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:l,initialWidth:a,initialHeight:o,initialMinZoom:s,initialMaxZoom:c,initialFitViewOptions:h,fitView:f,nodeOrigin:m,nodeExtent:p,zIndexMode:g,children:b}){const[w]=I.useState(()=>PM({nodes:e,edges:t,defaultNodes:n,defaultEdges:l,width:a,height:o,fitView:f,minZoom:s,maxZoom:c,fitViewOptions:h,nodeOrigin:m,nodeExtent:p,zIndexMode:g}));return y.jsx(uz,{value:w,children:y.jsx(Mz,{children:b})})}function FM({children:e,nodes:t,edges:n,defaultNodes:l,defaultEdges:a,width:o,height:s,fitView:c,fitViewOptions:h,minZoom:f,maxZoom:m,nodeOrigin:p,nodeExtent:g,zIndexMode:b}){return I.useContext(Bc)?y.jsx(y.Fragment,{children:e}):y.jsx(GM,{initialNodes:t,initialEdges:n,defaultNodes:l,defaultEdges:a,initialWidth:o,initialHeight:s,fitView:c,initialFitViewOptions:h,initialMinZoom:f,initialMaxZoom:m,nodeOrigin:p,nodeExtent:g,zIndexMode:b,children:e})}const YM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function XM({nodes:e,edges:t,defaultNodes:n,defaultEdges:l,className:a,nodeTypes:o,edgeTypes:s,onNodeClick:c,onEdgeClick:h,onInit:f,onMove:m,onMoveStart:p,onMoveEnd:g,onConnect:b,onConnectStart:w,onConnectEnd:E,onClickConnectStart:S,onClickConnectEnd:_,onNodeMouseEnter:N,onNodeMouseMove:k,onNodeMouseLeave:T,onNodeContextMenu:M,onNodeDoubleClick:A,onNodeDragStart:L,onNodeDrag:R,onNodeDragStop:V,onNodesDelete:H,onEdgesDelete:B,onDelete:U,onSelectionChange:ee,onSelectionDragStart:q,onSelectionDrag:F,onSelectionDragStop:z,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onBeforeDelete:D,connectionMode:$,connectionLineType:Y=bi.Bezier,connectionLineStyle:C,connectionLineComponent:P,connectionLineContainerStyle:X,deleteKeyCode:J="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:re=!1,selectionMode:ue=Go.Full,panActivationKeyCode:xe="Space",multiSelectionKeyCode:be=Yo()?"Meta":"Control",zoomActivationKeyCode:ye=Yo()?"Meta":"Control",snapToGrid:pe,snapGrid:Se,onlyRenderVisibleElements:Oe=!1,selectNodesOnDrag:je,nodesDraggable:ft,autoPanOnNodeFocus:rt,nodesConnectable:Dt,nodesFocusable:Pt,nodeOrigin:Bt=J_,edgesFocusable:kn,edgesReconnectable:Rn,elementsSelectable:Rt=!0,defaultViewport:qr=_z,minZoom:ce=.5,maxZoom:ge=2,translateExtent:Ne=Po,preventScrolling:Ie=!0,nodeExtent:Xe,defaultMarkerColor:Zt="#b1b1b7",zoomOnScroll:On=!0,zoomOnPinch:It=!0,panOnScroll:wt=!1,panOnScrollSpeed:Gt=.5,panOnScrollMode:et=el.Free,zoomOnDoubleClick:Zn=!0,panOnDrag:fn=!0,onPaneClick:Xc,onPaneMouseEnter:fl,onPaneMouseMove:dl,onPaneMouseLeave:hl,onPaneScroll:ur,onPaneContextMenu:pl,paneClickDistance:ki=1,nodeClickDistance:Qc=0,children:cs,onReconnect:ka,onReconnectStart:Ei,onReconnectEnd:Zc,onEdgeContextMenu:fs,onEdgeDoubleClick:ds,onEdgeMouseEnter:hs,onEdgeMouseMove:Ea,onEdgeMouseLeave:Na,reconnectRadius:ps=10,onNodesChange:ms,onEdgesChange:Kn,noDragClassName:Ot="nodrag",noWheelClassName:Ft="nowheel",noPanClassName:cr="nopan",fitView:ml,fitViewOptions:gs,connectOnClick:Kc,attributionPosition:xs,proOptions:Ni,defaultEdgeOptions:Ca,elevateNodesOnSelect:$r=!0,elevateEdgesOnSelect:Ur=!1,disableKeyboardA11y:Vr=!1,autoPanOnConnect:Pr,autoPanOnNodeDrag:kt,autoPanSpeed:ys,connectionRadius:vs,isValidConnection:fr,onError:Gr,style:Jc,id:ja,nodeDragThreshold:bs,connectionDragThreshold:Wc,viewport:gl,onViewportChange:xl,width:Ln,height:Wt,colorMode:ws="light",debug:ef,onScroll:Fr,ariaLabelConfig:_s,zIndexMode:Ci="basic",...tf},en){const ji=ja||"1",Ss=Nz(ws),Ta=I.useCallback(dr=>{dr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Fr==null||Fr(dr)},[Fr]);return y.jsx("div",{"data-testid":"rf__wrapper",...tf,onScroll:Ta,style:{...Jc,...YM},ref:en,className:Mt(["react-flow",a,Ss]),id:ja,role:"application",children:y.jsxs(FM,{nodes:e,edges:t,width:Ln,height:Wt,fitView:ml,fitViewOptions:gs,minZoom:ce,maxZoom:ge,nodeOrigin:Bt,nodeExtent:Xe,zIndexMode:Ci,children:[y.jsx(VM,{onInit:f,onNodeClick:c,onEdgeClick:h,onNodeMouseEnter:N,onNodeMouseMove:k,onNodeMouseLeave:T,onNodeContextMenu:M,onNodeDoubleClick:A,nodeTypes:o,edgeTypes:s,connectionLineType:Y,connectionLineStyle:C,connectionLineComponent:P,connectionLineContainerStyle:X,selectionKeyCode:ne,selectionOnDrag:re,selectionMode:ue,deleteKeyCode:J,multiSelectionKeyCode:be,panActivationKeyCode:xe,zoomActivationKeyCode:ye,onlyRenderVisibleElements:Oe,defaultViewport:qr,translateExtent:Ne,minZoom:ce,maxZoom:ge,preventScrolling:Ie,zoomOnScroll:On,zoomOnPinch:It,zoomOnDoubleClick:Zn,panOnScroll:wt,panOnScrollSpeed:Gt,panOnScrollMode:et,panOnDrag:fn,onPaneClick:Xc,onPaneMouseEnter:fl,onPaneMouseMove:dl,onPaneMouseLeave:hl,onPaneScroll:ur,onPaneContextMenu:pl,paneClickDistance:ki,nodeClickDistance:Qc,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onReconnect:ka,onReconnectStart:Ei,onReconnectEnd:Zc,onEdgeContextMenu:fs,onEdgeDoubleClick:ds,onEdgeMouseEnter:hs,onEdgeMouseMove:Ea,onEdgeMouseLeave:Na,reconnectRadius:ps,defaultMarkerColor:Zt,noDragClassName:Ot,noWheelClassName:Ft,noPanClassName:cr,rfId:ji,disableKeyboardA11y:Vr,nodeExtent:Xe,viewport:gl,onViewportChange:xl}),y.jsx(Ez,{nodes:e,edges:t,defaultNodes:n,defaultEdges:l,onConnect:b,onConnectStart:w,onConnectEnd:E,onClickConnectStart:S,onClickConnectEnd:_,nodesDraggable:ft,autoPanOnNodeFocus:rt,nodesConnectable:Dt,nodesFocusable:Pt,edgesFocusable:kn,edgesReconnectable:Rn,elementsSelectable:Rt,elevateNodesOnSelect:$r,elevateEdgesOnSelect:Ur,minZoom:ce,maxZoom:ge,nodeExtent:Xe,onNodesChange:ms,onEdgesChange:Kn,snapToGrid:pe,snapGrid:Se,connectionMode:$,translateExtent:Ne,connectOnClick:Kc,defaultEdgeOptions:Ca,fitView:ml,fitViewOptions:gs,onNodesDelete:H,onEdgesDelete:B,onDelete:U,onNodeDragStart:L,onNodeDrag:R,onNodeDragStop:V,onSelectionDrag:F,onSelectionDragStart:q,onSelectionDragStop:z,onMove:m,onMoveStart:p,onMoveEnd:g,noPanClassName:cr,nodeOrigin:Bt,rfId:ji,autoPanOnConnect:Pr,autoPanOnNodeDrag:kt,autoPanSpeed:ys,onError:Gr,connectionRadius:vs,isValidConnection:fr,selectNodesOnDrag:je,nodeDragThreshold:bs,connectionDragThreshold:Wc,onBeforeDelete:D,debug:ef,ariaLabelConfig:_s,zIndexMode:Ci}),y.jsx(wz,{onSelectionChange:ee}),cs,y.jsx(gz,{proOptions:Ni,position:xs}),y.jsx(mz,{rfId:ji,disableKeyboardA11y:Vr})]})})}var QM=nS(XM);const ZM=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function KM({children:e}){const t=Ye(ZM);return t?sz.createPortal(e,t):null}function JM(e){const[t,n]=I.useState(e),l=I.useCallback(a=>n(o=>eS(a,o)),[]);return[t,n,l]}function WM(e){const[t,n]=I.useState(e),l=I.useCallback(a=>n(o=>tS(a,o)),[]);return[t,n,l]}function e5({dimensions:e,lineWidth:t,variant:n,className:l}){return y.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Mt(["react-flow__background-pattern",n,l])})}function t5({radius:e,className:t}){return y.jsx("circle",{cx:e,cy:e,r:e,className:Mt(["react-flow__background-pattern","dots",t])})}var Rr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Rr||(Rr={}));const n5={[Rr.Dots]:1,[Rr.Lines]:1,[Rr.Cross]:6},r5=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function NS({id:e,variant:t=Rr.Dots,gap:n=20,size:l,lineWidth:a=1,offset:o=0,color:s,bgColor:c,style:h,className:f,patternClassName:m}){const p=I.useRef(null),{transform:g,patternId:b}=Ye(r5,mt),w=l||n5[t],E=t===Rr.Dots,S=t===Rr.Cross,_=Array.isArray(n)?n:[n,n],N=[_[0]*g[2]||1,_[1]*g[2]||1],k=w*g[2],T=Array.isArray(o)?o:[o,o],M=S?[k,k]:N,A=[T[0]*g[2]||1+M[0]/2,T[1]*g[2]||1+M[1]/2],L=`${b}${e||""}`;return y.jsxs("svg",{className:Mt(["react-flow__background",f]),style:{...h,...qc,"--xy-background-color-props":c,"--xy-background-pattern-color-props":s},ref:p,"data-testid":"rf__background",children:[y.jsx("pattern",{id:L,x:g[0]%N[0],y:g[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${A[0]},-${A[1]})`,children:E?y.jsx(t5,{radius:k/2,className:m}):y.jsx(e5,{dimensions:M,lineWidth:a,variant:t,className:m})}),y.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${L})`})]})}NS.displayName="Background";const i5=I.memo(NS);function l5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:y.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function a5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:y.jsx("path",{d:"M0 0h32v4.2H0z"})})}function o5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:y.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function s5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function u5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Fu({children:e,className:t,...n}){return y.jsx("button",{type:"button",className:Mt(["react-flow__controls-button",t]),...n,children:e})}const c5=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function CS({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:o,onZoomOut:s,onFitView:c,onInteractiveChange:h,className:f,children:m,position:p="bottom-left",orientation:g="vertical","aria-label":b}){const w=gt(),{isInteractive:E,minZoomReached:S,maxZoomReached:_,ariaLabelConfig:N}=Ye(c5,mt),{zoomIn:k,zoomOut:T,fitView:M}=ul(),A=()=>{k(),o==null||o()},L=()=>{T(),s==null||s()},R=()=>{M(a),c==null||c()},V=()=>{w.setState({nodesDraggable:!E,nodesConnectable:!E,elementsSelectable:!E}),h==null||h(!E)},H=g==="horizontal"?"horizontal":"vertical";return y.jsxs(Ic,{className:Mt(["react-flow__controls",H,f]),position:p,style:e,"data-testid":"rf__controls","aria-label":b??N["controls.ariaLabel"],children:[t&&y.jsxs(y.Fragment,{children:[y.jsx(Fu,{onClick:A,className:"react-flow__controls-zoomin",title:N["controls.zoomIn.ariaLabel"],"aria-label":N["controls.zoomIn.ariaLabel"],disabled:_,children:y.jsx(l5,{})}),y.jsx(Fu,{onClick:L,className:"react-flow__controls-zoomout",title:N["controls.zoomOut.ariaLabel"],"aria-label":N["controls.zoomOut.ariaLabel"],disabled:S,children:y.jsx(a5,{})})]}),n&&y.jsx(Fu,{className:"react-flow__controls-fitview",onClick:R,title:N["controls.fitView.ariaLabel"],"aria-label":N["controls.fitView.ariaLabel"],children:y.jsx(o5,{})}),l&&y.jsx(Fu,{className:"react-flow__controls-interactive",onClick:V,title:N["controls.interactive.ariaLabel"],"aria-label":N["controls.interactive.ariaLabel"],children:E?y.jsx(u5,{}):y.jsx(s5,{})}),m]})}CS.displayName="Controls";const f5=I.memo(CS);function d5({id:e,x:t,y:n,width:l,height:a,style:o,color:s,strokeColor:c,strokeWidth:h,className:f,borderRadius:m,shapeRendering:p,selected:g,onClick:b}){const{background:w,backgroundColor:E}=o||{},S=s||w||E;return y.jsx("rect",{className:Mt(["react-flow__minimap-node",{selected:g},f]),x:t,y:n,rx:m,ry:m,width:l,height:a,style:{fill:S,stroke:c,strokeWidth:h},shapeRendering:p,onClick:b?_=>b(_,e):void 0})}const h5=I.memo(d5),p5=e=>e.nodes.map(t=>t.id),Ah=e=>e instanceof Function?e:()=>e;function m5({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:o=h5,onClick:s}){const c=Ye(p5,mt),h=Ah(t),f=Ah(e),m=Ah(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return y.jsx(y.Fragment,{children:c.map(g=>y.jsx(x5,{id:g,nodeColorFunc:h,nodeStrokeColorFunc:f,nodeClassNameFunc:m,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:o,onClick:s,shapeRendering:p},g))})}function g5({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:o,shapeRendering:s,NodeComponent:c,onClick:h}){const{node:f,x:m,y:p,width:g,height:b}=Ye(w=>{const E=w.nodeLookup.get(e);if(!E)return{node:void 0,x:0,y:0,width:0,height:0};const S=E.internals.userNode,{x:_,y:N}=E.internals.positionAbsolute,{width:k,height:T}=Hr(S);return{node:S,x:_,y:N,width:k,height:T}},mt);return!f||f.hidden||!T_(f)?null:y.jsx(c,{x:m,y:p,width:g,height:b,style:f.style,selected:!!f.selected,className:l(f),color:t(f),borderRadius:a,strokeColor:n(f),strokeWidth:o,shapeRendering:s,onClick:h,id:f.id})}const x5=I.memo(g5);var y5=I.memo(m5);const v5=200,b5=150,w5=e=>!e.hidden,_5=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?j_(ns(e.nodeLookup,{filter:w5}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},S5="react-flow__minimap-desc";function jS({style:e,className:t,nodeStrokeColor:n,nodeColor:l,nodeClassName:a="",nodeBorderRadius:o=5,nodeStrokeWidth:s,nodeComponent:c,bgColor:h,maskColor:f,maskStrokeColor:m,maskStrokeWidth:p,position:g="bottom-right",onClick:b,onNodeClick:w,pannable:E=!1,zoomable:S=!1,ariaLabel:_,inversePan:N,zoomStep:k=1,offsetScale:T=5}){const M=gt(),A=I.useRef(null),{boundingRect:L,viewBB:R,rfId:V,panZoom:H,translateExtent:B,flowWidth:U,flowHeight:ee,ariaLabelConfig:q}=Ye(_5,mt),F=(e==null?void 0:e.width)??v5,z=(e==null?void 0:e.height)??b5,G=L.width/F,Q=L.height/z,K=Math.max(G,Q),D=K*F,$=K*z,Y=T*K,C=L.x-(D-L.width)/2-Y,P=L.y-($-L.height)/2-Y,X=D+Y*2,J=$+Y*2,ne=`${S5}-${V}`,re=I.useRef(0),ue=I.useRef();re.current=K,I.useEffect(()=>{if(A.current&&H)return ue.current=OA({domNode:A.current,panZoom:H,getTransform:()=>M.getState().transform,getViewScale:()=>re.current}),()=>{var pe;(pe=ue.current)==null||pe.destroy()}},[H]),I.useEffect(()=>{var pe;(pe=ue.current)==null||pe.update({translateExtent:B,width:U,height:ee,inversePan:N,pannable:E,zoomStep:k,zoomable:S})},[E,S,N,k,B,U,ee]);const xe=b?pe=>{var je;const[Se,Oe]=((je=ue.current)==null?void 0:je.pointer(pe))||[0,0];b(pe,{x:Se,y:Oe})}:void 0,be=w?I.useCallback((pe,Se)=>{const Oe=M.getState().nodeLookup.get(Se).internals.userNode;w(pe,Oe)},[]):void 0,ye=_??q["minimap.ariaLabel"];return y.jsx(Ic,{position:g,style:{...e,"--xy-minimap-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*K:void 0,"--xy-minimap-node-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:Mt(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:y.jsxs("svg",{width:F,height:z,viewBox:`${C} ${P} ${X} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:A,onClick:xe,children:[ye&&y.jsx("title",{id:ne,children:ye}),y.jsx(y5,{onClick:be,nodeColor:l,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:a,nodeStrokeWidth:s,nodeComponent:c}),y.jsx("path",{className:"react-flow__minimap-mask",d:`M${C-Y},${P-Y}h${X+Y*2}v${J+Y*2}h${-X-Y*2}z - M${R.x},${R.y}h${R.width}v${R.height}h${-R.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}jS.displayName="MiniMap";const k5=I.memo(jS),E5=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,N5={[va.Line]:"right",[va.Handle]:"bottom-right"};function C5({nodeId:e,position:t,variant:n=va.Handle,className:l,style:a=void 0,children:o,color:s,minWidth:c=10,minHeight:h=10,maxWidth:f=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:g,autoScale:b=!0,shouldResize:w,onResizeStart:E,onResize:S,onResizeEnd:_}){const N=aS(),k=typeof e=="string"?e:N,T=gt(),M=I.useRef(null),A=n===va.Handle,L=Ye(I.useCallback(E5(A&&b),[A,b]),mt),R=I.useRef(null),V=t??N5[n];I.useEffect(()=>{if(!(!M.current||!k))return R.current||(R.current=QA({domNode:M.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:B,transform:U,snapGrid:ee,snapToGrid:q,nodeOrigin:F,domNode:z}=T.getState();return{nodeLookup:B,transform:U,snapGrid:ee,snapToGrid:q,nodeOrigin:F,paneDomNode:z}},onChange:(B,U)=>{const{triggerNodeChanges:ee,nodeLookup:q,parentLookup:F,nodeOrigin:z}=T.getState(),G=[],Q={x:B.x,y:B.y},K=q.get(k);if(K&&K.expandParent&&K.parentId){const D=K.origin??z,$=B.width??K.measured.width??0,Y=B.height??K.measured.height??0,C={id:K.id,parentId:K.parentId,rect:{width:$,height:Y,...A_({x:B.x??K.position.x,y:B.y??K.position.y},{width:$,height:Y},K.parentId,q,D)}},P=Im([C],q,F,z);G.push(...P),Q.x=B.x?Math.max(D[0]*$,B.x):void 0,Q.y=B.y?Math.max(D[1]*Y,B.y):void 0}if(Q.x!==void 0&&Q.y!==void 0){const D={id:k,type:"position",position:{...Q}};G.push(D)}if(B.width!==void 0&&B.height!==void 0){const $={id:k,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:B.width,height:B.height}};G.push($)}for(const D of U){const $={...D,type:"position"};G.push($)}ee(G)},onEnd:({width:B,height:U})=>{const ee={id:k,type:"dimensions",resizing:!1,dimensions:{width:B,height:U}};T.getState().triggerNodeChanges([ee])}})),R.current.update({controlPosition:V,boundaries:{minWidth:c,minHeight:h,maxWidth:f,maxHeight:m},keepAspectRatio:p,resizeDirection:g,onResizeStart:E,onResize:S,onResizeEnd:_,shouldResize:w}),()=>{var B;(B=R.current)==null||B.destroy()}},[V,c,h,f,m,p,E,S,_,w]);const H=V.split("-");return y.jsx("div",{className:Mt(["react-flow__resize-control","nodrag",...H,n,l]),ref:M,style:{...a,scale:L,...s&&{[A?"backgroundColor":"borderColor"]:s}},children:o})}I.memo(C5);function as(e,t){if(t.length===0)return null;let n=e[t[0]];for(let l=1;ll.viewContextPath),t=se(l=>l.nodes),n=se(l=>l.subworkflowContexts);return I.useMemo(()=>{var l;return e.length===0?t:((l=as(n,e))==null?void 0:l.nodes)??t},[e,t,n])}function j5(){const e=se(l=>l.viewContextPath),t=se(l=>l.groupProgress),n=se(l=>l.subworkflowContexts);return I.useMemo(()=>{var l;return e.length===0?t:((l=as(n,e))==null?void 0:l.groupProgress)??t},[e,t,n])}function T5(){const e=se(l=>l.viewContextPath),t=se(l=>l.highlightedEdges),n=se(l=>l.subworkflowContexts);return I.useMemo(()=>{var l;return e.length===0?t:((l=as(n,e))==null?void 0:l.highlightedEdges)??t},[e,t,n])}function $m(){const e=se(n=>n.viewContextPath),t=se(n=>n.subworkflowContexts);return I.useMemo(()=>{var n;return e.length===0?t:((n=as(t,e))==null?void 0:n.children)??[]},[e,t])}function A5(){const e=se(f=>f.viewContextPath),t=se(f=>f.agents),n=se(f=>f.routes),l=se(f=>f.parallelGroups),a=se(f=>f.forEachGroups),o=se(f=>f.nodes),s=se(f=>f.groupProgress),c=se(f=>f.entryPoint),h=se(f=>f.subworkflowContexts);return I.useMemo(()=>{if(e.length===0)return{agents:t,routes:n,parallelGroups:l,forEachGroups:a,nodes:o,groupProgress:s,entryPoint:c,subworkflowContexts:h,parentAgent:null};const f=as(h,e);return f?{agents:f.agents,routes:f.routes,parallelGroups:f.parallelGroups,forEachGroups:f.forEachGroups,nodes:f.nodes,groupProgress:f.groupProgress,entryPoint:f.entryPoint,subworkflowContexts:f.children,parentAgent:f.parentAgent}:{agents:t,routes:n,parallelGroups:l,forEachGroups:a,nodes:o,groupProgress:s,entryPoint:c,subworkflowContexts:h,parentAgent:null}},[e,t,n,l,a,o,s,c,h])}function z5(){const e=new URLSearchParams(window.location.search);return{subworkflowPath:e.get("subworkflow"),agent:e.get("agent")}}function vb(e,t){const n=[];let l=e;for(const a of t){let o=-1;for(let s=l.length-1;s>=0;s--)if(l[s].slotKey===a){o=s;break}if(o===-1){for(let s=l.length-1;s>=0;s--)if(l[s].parentAgent===a){o=s;break}}if(o===-1)return{path:n,failedSegment:a};n.push(o),l=l[o].children}return{path:n,failedSegment:null}}function am(e,t,n=[]){const l=[];for(let a=0;ac.name===t)&&l.push({path:s,ctx:o}),o.children.length>0&&l.push(...am(o.children,t,s))}return l}function M5(e){return e.length===0?null:[...e].sort((t,n)=>{const l=t.ctx.status==="running"?1:0,a=n.ctx.status==="running"?1:0;if(l!==a)return a-l;if(t.path.length!==n.path.length)return n.path.length-t.path.length;for(let o=0;o{if(n.current||!s)return;let c=null,h=null,f=null;const m=()=>{if(n.current)return;n.current=!0,c&&clearTimeout(c),h&&clearTimeout(h),f&&f();const b=se.getState();if(b.agents.length===0){t({message:"Workflow state did not load."});return}let w=[];if(a){const E=a.split("/").filter(Boolean),S=vb(b.subworkflowContexts,E);if(S.failedSegment){const _=E.slice(0,S.path.length).join("/");t({message:`Subworkflow "${S.failedSegment}" not found${_?` (resolved: ${_})`:""}. It may not have started yet.`});return}w=S.path}if(o){if((w.length===0?b.agents:(()=>{let S,_=b.subworkflowContexts;for(const N of w){if(S=_[N],!S)break;_=S.children}return(S==null?void 0:S.agents)??[]})()).some(S=>S.name===o))se.setState({viewContextPath:w,selectedNode:o});else{const S=am(b.subworkflowContexts,o);if(S.length===0){const N=a||"root workflow";se.setState({viewContextPath:w,selectedNode:null}),t({message:`Agent "${o}" not found in ${N}.`});return}if(a){const N=S.slice(0,5).map(T=>D5(b.subworkflowContexts,T.path)).join(", "),k=S.length>5?`, and ${S.length-5} more`:"";se.setState({viewContextPath:w,selectedNode:null}),t({message:`Agent "${o}" not found in ${a}. Found in: ${N}${k}`});return}const _=M5(S);se.setState({viewContextPath:_.path,selectedNode:o})}setTimeout(()=>{l({nodes:[{id:o}],padding:.5,duration:400})},200)}else a&&se.setState({viewContextPath:w,selectedNode:null})},p=()=>{const b=se.getState();if(b.agents.length===0)return!1;if(b.workflowStatus!=="running"&&b.workflowStatus!=="pending")return!0;if(a){const w=a.split("/").filter(Boolean),{failedSegment:E}=vb(b.subworkflowContexts,w);if(E)return!1}return!(o&&!a&&!b.agents.some(E=>E.name===o)&&am(b.subworkflowContexts,o).length===0)},g=()=>{c&&clearTimeout(c),c=setTimeout(()=>{n.current||p()&&m()},200)};return f=se.subscribe(g),h=setTimeout(()=>{n.current||m()},5e3),g(),()=>{c&&clearTimeout(c),h&&clearTimeout(h),f&&f()}},[s,a,o,l]),e}var zh,bb;function Um(){if(bb)return zh;bb=1;var e="\0",t="\0",n="";class l{constructor(m){Tt(this,"_isDirected",!0);Tt(this,"_isMultigraph",!1);Tt(this,"_isCompound",!1);Tt(this,"_label");Tt(this,"_defaultNodeLabelFn",()=>{});Tt(this,"_defaultEdgeLabelFn",()=>{});Tt(this,"_nodes",{});Tt(this,"_in",{});Tt(this,"_preds",{});Tt(this,"_out",{});Tt(this,"_sucs",{});Tt(this,"_edgeObjs",{});Tt(this,"_edgeLabels",{});Tt(this,"_nodeCount",0);Tt(this,"_edgeCount",0);Tt(this,"_parent");Tt(this,"_children");m&&(this._isDirected=Object.hasOwn(m,"directed")?m.directed:!0,this._isMultigraph=Object.hasOwn(m,"multigraph")?m.multigraph:!1,this._isCompound=Object.hasOwn(m,"compound")?m.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(m){return this._label=m,this}graph(){return this._label}setDefaultNodeLabel(m){return this._defaultNodeLabelFn=m,typeof m!="function"&&(this._defaultNodeLabelFn=()=>m),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var m=this;return this.nodes().filter(p=>Object.keys(m._in[p]).length===0)}sinks(){var m=this;return this.nodes().filter(p=>Object.keys(m._out[p]).length===0)}setNodes(m,p){var g=arguments,b=this;return m.forEach(function(w){g.length>1?b.setNode(w,p):b.setNode(w)}),this}setNode(m,p){return Object.hasOwn(this._nodes,m)?(arguments.length>1&&(this._nodes[m]=p),this):(this._nodes[m]=arguments.length>1?p:this._defaultNodeLabelFn(m),this._isCompound&&(this._parent[m]=t,this._children[m]={},this._children[t][m]=!0),this._in[m]={},this._preds[m]={},this._out[m]={},this._sucs[m]={},++this._nodeCount,this)}node(m){return this._nodes[m]}hasNode(m){return Object.hasOwn(this._nodes,m)}removeNode(m){var p=this;if(Object.hasOwn(this._nodes,m)){var g=b=>p.removeEdge(p._edgeObjs[b]);delete this._nodes[m],this._isCompound&&(this._removeFromParentsChildList(m),delete this._parent[m],this.children(m).forEach(function(b){p.setParent(b)}),delete this._children[m]),Object.keys(this._in[m]).forEach(g),delete this._in[m],delete this._preds[m],Object.keys(this._out[m]).forEach(g),delete this._out[m],delete this._sucs[m],--this._nodeCount}return this}setParent(m,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(p===void 0)p=t;else{p+="";for(var g=p;g!==void 0;g=this.parent(g))if(g===m)throw new Error("Setting "+p+" as parent of "+m+" would create a cycle");this.setNode(p)}return this.setNode(m),this._removeFromParentsChildList(m),this._parent[m]=p,this._children[p][m]=!0,this}_removeFromParentsChildList(m){delete this._children[this._parent[m]][m]}parent(m){if(this._isCompound){var p=this._parent[m];if(p!==t)return p}}children(m=t){if(this._isCompound){var p=this._children[m];if(p)return Object.keys(p)}else{if(m===t)return this.nodes();if(this.hasNode(m))return[]}}predecessors(m){var p=this._preds[m];if(p)return Object.keys(p)}successors(m){var p=this._sucs[m];if(p)return Object.keys(p)}neighbors(m){var p=this.predecessors(m);if(p){const b=new Set(p);for(var g of this.successors(m))b.add(g);return Array.from(b.values())}}isLeaf(m){var p;return this.isDirected()?p=this.successors(m):p=this.neighbors(m),p.length===0}filterNodes(m){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var g=this;Object.entries(this._nodes).forEach(function([E,S]){m(E)&&p.setNode(E,S)}),Object.values(this._edgeObjs).forEach(function(E){p.hasNode(E.v)&&p.hasNode(E.w)&&p.setEdge(E,g.edge(E))});var b={};function w(E){var S=g.parent(E);return S===void 0||p.hasNode(S)?(b[E]=S,S):S in b?b[S]:w(S)}return this._isCompound&&p.nodes().forEach(E=>p.setParent(E,w(E))),p}setDefaultEdgeLabel(m){return this._defaultEdgeLabelFn=m,typeof m!="function"&&(this._defaultEdgeLabelFn=()=>m),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(m,p){var g=this,b=arguments;return m.reduce(function(w,E){return b.length>1?g.setEdge(w,E,p):g.setEdge(w,E),E}),this}setEdge(){var m,p,g,b,w=!1,E=arguments[0];typeof E=="object"&&E!==null&&"v"in E?(m=E.v,p=E.w,g=E.name,arguments.length===2&&(b=arguments[1],w=!0)):(m=E,p=arguments[1],g=arguments[3],arguments.length>2&&(b=arguments[2],w=!0)),m=""+m,p=""+p,g!==void 0&&(g=""+g);var S=s(this._isDirected,m,p,g);if(Object.hasOwn(this._edgeLabels,S))return w&&(this._edgeLabels[S]=b),this;if(g!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(m),this.setNode(p),this._edgeLabels[S]=w?b:this._defaultEdgeLabelFn(m,p,g);var _=c(this._isDirected,m,p,g);return m=_.v,p=_.w,Object.freeze(_),this._edgeObjs[S]=_,a(this._preds[p],m),a(this._sucs[m],p),this._in[p][S]=_,this._out[m][S]=_,this._edgeCount++,this}edge(m,p,g){var b=arguments.length===1?h(this._isDirected,arguments[0]):s(this._isDirected,m,p,g);return this._edgeLabels[b]}edgeAsObj(){const m=this.edge(...arguments);return typeof m!="object"?{label:m}:m}hasEdge(m,p,g){var b=arguments.length===1?h(this._isDirected,arguments[0]):s(this._isDirected,m,p,g);return Object.hasOwn(this._edgeLabels,b)}removeEdge(m,p,g){var b=arguments.length===1?h(this._isDirected,arguments[0]):s(this._isDirected,m,p,g),w=this._edgeObjs[b];return w&&(m=w.v,p=w.w,delete this._edgeLabels[b],delete this._edgeObjs[b],o(this._preds[p],m),o(this._sucs[m],p),delete this._in[p][b],delete this._out[m][b],this._edgeCount--),this}inEdges(m,p){var g=this._in[m];if(g){var b=Object.values(g);return p?b.filter(w=>w.v===p):b}}outEdges(m,p){var g=this._out[m];if(g){var b=Object.values(g);return p?b.filter(w=>w.w===p):b}}nodeEdges(m,p){var g=this.inEdges(m,p);if(g)return g.concat(this.outEdges(m,p))}}function a(f,m){f[m]?f[m]++:f[m]=1}function o(f,m){--f[m]||delete f[m]}function s(f,m,p,g){var b=""+m,w=""+p;if(!f&&b>w){var E=b;b=w,w=E}return b+n+w+n+(g===void 0?e:g)}function c(f,m,p,g){var b=""+m,w=""+p;if(!f&&b>w){var E=b;b=w,w=E}var S={v:b,w};return g&&(S.name=g),S}function h(f,m){return s(f,m.v,m.w,m.name)}return zh=l,zh}var Mh,wb;function O5(){return wb||(wb=1,Mh="2.2.4"),Mh}var Dh,_b;function L5(){return _b||(_b=1,Dh={Graph:Um(),version:O5()}),Dh}var Rh,Sb;function H5(){if(Sb)return Rh;Sb=1;var e=Um();Rh={write:t,read:a};function t(o){var s={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:n(o),edges:l(o)};return o.graph()!==void 0&&(s.value=structuredClone(o.graph())),s}function n(o){return o.nodes().map(function(s){var c=o.node(s),h=o.parent(s),f={v:s};return c!==void 0&&(f.value=c),h!==void 0&&(f.parent=h),f})}function l(o){return o.edges().map(function(s){var c=o.edge(s),h={v:s.v,w:s.w};return s.name!==void 0&&(h.name=s.name),c!==void 0&&(h.value=c),h})}function a(o){var s=new e(o.options).setGraph(o.value);return o.nodes.forEach(function(c){s.setNode(c.v,c.value),c.parent&&s.setParent(c.v,c.parent)}),o.edges.forEach(function(c){s.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),s}return Rh}var Oh,kb;function B5(){if(kb)return Oh;kb=1,Oh=e;function e(t){var n={},l=[],a;function o(s){Object.hasOwn(n,s)||(n[s]=!0,a.push(s),t.successors(s).forEach(o),t.predecessors(s).forEach(o))}return t.nodes().forEach(function(s){a=[],o(s),a.length&&l.push(a)}),l}return Oh}var Lh,Eb;function TS(){if(Eb)return Lh;Eb=1;class e{constructor(){Tt(this,"_arr",[]);Tt(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var l=this._keyIndices[n];if(l!==void 0)return this._arr[l].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,l){var a=this._keyIndices;if(n=String(n),!Object.hasOwn(a,n)){var o=this._arr,s=o.length;return a[n]=s,o.push({key:n,priority:l}),this._decrease(s),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,l){var a=this._keyIndices[n];if(l>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[a].priority+" New: "+l);this._arr[a].priority=l,this._decrease(a)}_heapify(n){var l=this._arr,a=2*n,o=a+1,s=n;a>1,!(l[o].priority1;function n(a,o,s,c){return l(a,String(o),s||t,c||function(h){return a.outEdges(h)})}function l(a,o,s,c){var h={},f=new e,m,p,g=function(b){var w=b.v!==m?b.v:b.w,E=h[w],S=s(b),_=p.distance+S;if(S<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+b+" Weight: "+S);_0&&(m=f.removeMin(),p=h[m],p.distance!==Number.POSITIVE_INFINITY);)c(m).forEach(g);return h}return Hh}var Bh,Cb;function I5(){if(Cb)return Bh;Cb=1;var e=AS();Bh=t;function t(n,l,a){return n.nodes().reduce(function(o,s){return o[s]=e(n,s,l,a),o},{})}return Bh}var Ih,jb;function zS(){if(jb)return Ih;jb=1,Ih=e;function e(t){var n=0,l=[],a={},o=[];function s(c){var h=a[c]={onStack:!0,lowlink:n,index:n++};if(l.push(c),t.successors(c).forEach(function(p){Object.hasOwn(a,p)?a[p].onStack&&(h.lowlink=Math.min(h.lowlink,a[p].index)):(s(p),h.lowlink=Math.min(h.lowlink,a[p].lowlink))}),h.lowlink===h.index){var f=[],m;do m=l.pop(),a[m].onStack=!1,f.push(m);while(c!==m);o.push(f)}}return t.nodes().forEach(function(c){Object.hasOwn(a,c)||s(c)}),o}return Ih}var qh,Tb;function q5(){if(Tb)return qh;Tb=1;var e=zS();qh=t;function t(n){return e(n).filter(function(l){return l.length>1||l.length===1&&n.hasEdge(l[0],l[0])})}return qh}var $h,Ab;function $5(){if(Ab)return $h;Ab=1,$h=t;var e=()=>1;function t(l,a,o){return n(l,a||e,o||function(s){return l.outEdges(s)})}function n(l,a,o){var s={},c=l.nodes();return c.forEach(function(h){s[h]={},s[h][h]={distance:0},c.forEach(function(f){h!==f&&(s[h][f]={distance:Number.POSITIVE_INFINITY})}),o(h).forEach(function(f){var m=f.v===h?f.w:f.v,p=a(f);s[h][m]={distance:p,predecessor:h}})}),c.forEach(function(h){var f=s[h];c.forEach(function(m){var p=s[m];c.forEach(function(g){var b=p[h],w=f[g],E=p[g],S=b.distance+w.distance;Sa.successors(p):p=>a.neighbors(p),h=s==="post"?t:n,f=[],m={};return o.forEach(p=>{if(!a.hasNode(p))throw new Error("Graph does not have node: "+p);h(p,c,m,f)}),f}function t(a,o,s,c){for(var h=[[a,!1]];h.length>0;){var f=h.pop();f[1]?c.push(f[0]):Object.hasOwn(s,f[0])||(s[f[0]]=!0,h.push([f[0],!0]),l(o(f[0]),m=>h.push([m,!1])))}}function n(a,o,s,c){for(var h=[a];h.length>0;){var f=h.pop();Object.hasOwn(s,f)||(s[f]=!0,c.push(f),l(o(f),m=>h.push(m)))}}function l(a,o){for(var s=a.length;s--;)o(a[s],s,a);return a}return Ph}var Gh,Rb;function V5(){if(Rb)return Gh;Rb=1;var e=DS();Gh=t;function t(n,l){return e(n,l,"post")}return Gh}var Fh,Ob;function P5(){if(Ob)return Fh;Ob=1;var e=DS();Fh=t;function t(n,l){return e(n,l,"pre")}return Fh}var Yh,Lb;function G5(){if(Lb)return Yh;Lb=1;var e=Um(),t=TS();Yh=n;function n(l,a){var o=new e,s={},c=new t,h;function f(p){var g=p.v===h?p.w:p.v,b=c.priority(g);if(b!==void 0){var w=a(p);w0;){if(h=c.removeMin(),Object.hasOwn(s,h))o.setEdge(h,s[h]);else{if(m)throw new Error("Input graph is not connected: "+l);m=!0}l.nodeEdges(h).forEach(f)}return o}return Yh}var Xh,Hb;function F5(){return Hb||(Hb=1,Xh={components:B5(),dijkstra:AS(),dijkstraAll:I5(),findCycles:q5(),floydWarshall:$5(),isAcyclic:U5(),postorder:V5(),preorder:P5(),prim:G5(),tarjan:zS(),topsort:MS()}),Xh}var Qh,Bb;function Yn(){if(Bb)return Qh;Bb=1;var e=L5();return Qh={Graph:e.Graph,json:H5(),alg:F5(),version:e.version},Qh}var Zh,Ib;function Y5(){if(Ib)return Zh;Ib=1;class e{constructor(){let a={};a._next=a._prev=a,this._sentinel=a}dequeue(){let a=this._sentinel,o=a._prev;if(o!==a)return t(o),o}enqueue(a){let o=this._sentinel;a._prev&&a._next&&t(a),a._next=o._next,o._next._prev=a,o._next=a,a._prev=o}toString(){let a=[],o=this._sentinel,s=o._prev;for(;s!==o;)a.push(JSON.stringify(s,n)),s=s._prev;return"["+a.join(", ")+"]"}}function t(l){l._prev._next=l._next,l._next._prev=l._prev,delete l._next,delete l._prev}function n(l,a){if(l!=="_next"&&l!=="_prev")return a}return Zh=e,Zh}var Kh,qb;function X5(){if(qb)return Kh;qb=1;let e=Yn().Graph,t=Y5();Kh=l;let n=()=>1;function l(f,m){if(f.nodeCount()<=1)return[];let p=s(f,m||n);return a(p.graph,p.buckets,p.zeroIdx).flatMap(b=>f.outEdges(b.v,b.w))}function a(f,m,p){let g=[],b=m[m.length-1],w=m[0],E;for(;f.nodeCount();){for(;E=w.dequeue();)o(f,m,p,E);for(;E=b.dequeue();)o(f,m,p,E);if(f.nodeCount()){for(let S=m.length-2;S>0;--S)if(E=m[S].dequeue(),E){g=g.concat(o(f,m,p,E,!0));break}}}return g}function o(f,m,p,g,b){let w=b?[]:void 0;return f.inEdges(g.v).forEach(E=>{let S=f.edge(E),_=f.node(E.v);b&&w.push({v:E.v,w:E.w}),_.out-=S,c(m,p,_)}),f.outEdges(g.v).forEach(E=>{let S=f.edge(E),_=E.w,N=f.node(_);N.in-=S,c(m,p,N)}),f.removeNode(g.v),w}function s(f,m){let p=new e,g=0,b=0;f.nodes().forEach(S=>{p.setNode(S,{v:S,in:0,out:0})}),f.edges().forEach(S=>{let _=p.edge(S.v,S.w)||0,N=m(S),k=_+N;p.setEdge(S.v,S.w,k),b=Math.max(b,p.node(S.v).out+=N),g=Math.max(g,p.node(S.w).in+=N)});let w=h(b+g+3).map(()=>new t),E=g+1;return p.nodes().forEach(S=>{c(w,E,p.node(S))}),{graph:p,buckets:w,zeroIdx:E}}function c(f,m,p){p.out?p.in?f[p.out-p.in+m].enqueue(p):f[f.length-1].enqueue(p):f[0].enqueue(p)}function h(f){const m=[];for(let p=0;pV.setNode(H,R.node(H))),R.edges().forEach(H=>{let B=V.edge(H.v,H.w)||{weight:0,minlen:1},U=R.edge(H);V.setEdge(H.v,H.w,{weight:B.weight+U.weight,minlen:Math.max(B.minlen,U.minlen)})}),V}function l(R){let V=new e({multigraph:R.isMultigraph()}).setGraph(R.graph());return R.nodes().forEach(H=>{R.children(H).length||V.setNode(H,R.node(H))}),R.edges().forEach(H=>{V.setEdge(H,R.edge(H))}),V}function a(R){let V=R.nodes().map(H=>{let B={};return R.outEdges(H).forEach(U=>{B[U.w]=(B[U.w]||0)+R.edge(U).weight}),B});return L(R.nodes(),V)}function o(R){let V=R.nodes().map(H=>{let B={};return R.inEdges(H).forEach(U=>{B[U.v]=(B[U.v]||0)+R.edge(U).weight}),B});return L(R.nodes(),V)}function s(R,V){let H=R.x,B=R.y,U=V.x-H,ee=V.y-B,q=R.width/2,F=R.height/2;if(!U&&!ee)throw new Error("Not possible to find intersection inside of the rectangle");let z,G;return Math.abs(ee)*q>Math.abs(U)*F?(ee<0&&(F=-F),z=F*U/ee,G=F):(U<0&&(q=-q),z=q,G=q*ee/U),{x:H+z,y:B+G}}function c(R){let V=T(w(R)+1).map(()=>[]);return R.nodes().forEach(H=>{let B=R.node(H),U=B.rank;U!==void 0&&(V[U][B.order]=H)}),V}function h(R){let V=R.nodes().map(B=>{let U=R.node(B).rank;return U===void 0?Number.MAX_VALUE:U}),H=b(Math.min,V);R.nodes().forEach(B=>{let U=R.node(B);Object.hasOwn(U,"rank")&&(U.rank-=H)})}function f(R){let V=R.nodes().map(q=>R.node(q).rank),H=b(Math.min,V),B=[];R.nodes().forEach(q=>{let F=R.node(q).rank-H;B[F]||(B[F]=[]),B[F].push(q)});let U=0,ee=R.graph().nodeRankFactor;Array.from(B).forEach((q,F)=>{q===void 0&&F%ee!==0?--U:q!==void 0&&U&&q.forEach(z=>R.node(z).rank+=U)})}function m(R,V,H,B){let U={width:0,height:0};return arguments.length>=4&&(U.rank=H,U.order=B),t(R,"border",U,V)}function p(R,V=g){const H=[];for(let B=0;Bg){const H=p(V);return R.apply(null,H.map(B=>R.apply(null,B)))}else return R.apply(null,V)}function w(R){const H=R.nodes().map(B=>{let U=R.node(B).rank;return U===void 0?Number.MIN_VALUE:U});return b(Math.max,H)}function E(R,V){let H={lhs:[],rhs:[]};return R.forEach(B=>{V(B)?H.lhs.push(B):H.rhs.push(B)}),H}function S(R,V){let H=Date.now();try{return V()}finally{console.log(R+" time: "+(Date.now()-H)+"ms")}}function _(R,V){return V()}let N=0;function k(R){var V=++N;return R+(""+V)}function T(R,V,H=1){V==null&&(V=R,R=0);let B=ee=>eeVB[V]),Object.entries(R).reduce((B,[U,ee])=>(B[U]=H(ee,U),B),{})}function L(R,V){return R.reduce((H,B,U)=>(H[B]=V[U],H),{})}return Jh}var Wh,Ub;function Q5(){if(Ub)return Wh;Ub=1;let e=X5(),t=zt().uniqueId;Wh={run:n,undo:a};function n(o){(o.graph().acyclicer==="greedy"?e(o,c(o)):l(o)).forEach(h=>{let f=o.edge(h);o.removeEdge(h),f.forwardName=h.name,f.reversed=!0,o.setEdge(h.w,h.v,f,t("rev"))});function c(h){return f=>h.edge(f).weight}}function l(o){let s=[],c={},h={};function f(m){Object.hasOwn(h,m)||(h[m]=!0,c[m]=!0,o.outEdges(m).forEach(p=>{Object.hasOwn(c,p.w)?s.push(p):f(p.w)}),delete c[m])}return o.nodes().forEach(f),s}function a(o){o.edges().forEach(s=>{let c=o.edge(s);if(c.reversed){o.removeEdge(s);let h=c.forwardName;delete c.reversed,delete c.forwardName,o.setEdge(s.w,s.v,c,h)}})}return Wh}var ep,Vb;function Z5(){if(Vb)return ep;Vb=1;let e=zt();ep={run:t,undo:l};function t(a){a.graph().dummyChains=[],a.edges().forEach(o=>n(a,o))}function n(a,o){let s=o.v,c=a.node(s).rank,h=o.w,f=a.node(h).rank,m=o.name,p=a.edge(o),g=p.labelRank;if(f===c+1)return;a.removeEdge(o);let b,w,E;for(E=0,++c;c{let s=a.node(o),c=s.edgeLabel,h;for(a.setEdge(s.edgeObj,c);s.dummy;)h=a.successors(o)[0],a.removeNode(o),c.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(c.x=s.x,c.y=s.y,c.width=s.width,c.height=s.height),o=h,s=a.node(o)})}return ep}var tp,Pb;function vc(){if(Pb)return tp;Pb=1;const{applyWithChunking:e}=zt();tp={longestPath:t,slack:n};function t(l){var a={};function o(s){var c=l.node(s);if(Object.hasOwn(a,s))return c.rank;a[s]=!0;let h=l.outEdges(s).map(m=>m==null?Number.POSITIVE_INFINITY:o(m.w)-l.edge(m).minlen);var f=e(Math.min,h);return f===Number.POSITIVE_INFINITY&&(f=0),c.rank=f}l.sources().forEach(o)}function n(l,a){return l.node(a.w).rank-l.node(a.v).rank-l.edge(a).minlen}return tp}var np,Gb;function RS(){if(Gb)return np;Gb=1;var e=Yn().Graph,t=vc().slack;np=n;function n(s){var c=new e({directed:!1}),h=s.nodes()[0],f=s.nodeCount();c.setNode(h,{});for(var m,p;l(c,s){var p=m.v,g=f===p?m.w:p;!s.hasNode(g)&&!t(c,m)&&(s.setNode(g,{}),s.setEdge(f,g,{}),h(g))})}return s.nodes().forEach(h),s.nodeCount()}function a(s,c){return c.edges().reduce((f,m)=>{let p=Number.POSITIVE_INFINITY;return s.hasNode(m.v)!==s.hasNode(m.w)&&(p=t(c,m)),pc.node(f).rank+=h)}return np}var rp,Fb;function K5(){if(Fb)return rp;Fb=1;var e=RS(),t=vc().slack,n=vc().longestPath,l=Yn().alg.preorder,a=Yn().alg.postorder,o=zt().simplify;rp=s,s.initLowLimValues=m,s.initCutValues=c,s.calcCutValue=f,s.leaveEdge=g,s.enterEdge=b,s.exchangeEdges=w;function s(N){N=o(N),n(N);var k=e(N);m(k),c(k,N);for(var T,M;T=g(k);)M=b(k,N,T),w(k,N,T,M)}function c(N,k){var T=a(N,N.nodes());T=T.slice(0,T.length-1),T.forEach(M=>h(N,k,M))}function h(N,k,T){var M=N.node(T),A=M.parent;N.edge(T,A).cutvalue=f(N,k,T)}function f(N,k,T){var M=N.node(T),A=M.parent,L=!0,R=k.edge(T,A),V=0;return R||(L=!1,R=k.edge(A,T)),V=R.weight,k.nodeEdges(T).forEach(H=>{var B=H.v===T,U=B?H.w:H.v;if(U!==A){var ee=B===L,q=k.edge(H).weight;if(V+=ee?q:-q,S(N,T,U)){var F=N.edge(T,U).cutvalue;V+=ee?-F:F}}}),V}function m(N,k){arguments.length<2&&(k=N.nodes()[0]),p(N,{},1,k)}function p(N,k,T,M,A){var L=T,R=N.node(M);return k[M]=!0,N.neighbors(M).forEach(V=>{Object.hasOwn(k,V)||(T=p(N,k,T,V,M))}),R.low=L,R.lim=T++,A?R.parent=A:delete R.parent,T}function g(N){return N.edges().find(k=>N.edge(k).cutvalue<0)}function b(N,k,T){var M=T.v,A=T.w;k.hasEdge(M,A)||(M=T.w,A=T.v);var L=N.node(M),R=N.node(A),V=L,H=!1;L.lim>R.lim&&(V=R,H=!0);var B=k.edges().filter(U=>H===_(N,N.node(U.v),V)&&H!==_(N,N.node(U.w),V));return B.reduce((U,ee)=>t(k,ee)!k.node(A).parent),M=l(N,T);M=M.slice(1),M.forEach(A=>{var L=N.node(A).parent,R=k.edge(A,L),V=!1;R||(R=k.edge(L,A),V=!0),k.node(A).rank=k.node(L).rank+(V?R.minlen:-R.minlen)})}function S(N,k,T){return N.hasEdge(k,T)}function _(N,k,T){return T.low<=k.lim&&k.lim<=T.lim}return rp}var ip,Yb;function J5(){if(Yb)return ip;Yb=1;var e=vc(),t=e.longestPath,n=RS(),l=K5();ip=a;function a(h){var f=h.graph().ranker;if(f instanceof Function)return f(h);switch(h.graph().ranker){case"network-simplex":c(h);break;case"tight-tree":s(h);break;case"longest-path":o(h);break;case"none":break;default:c(h)}}var o=t;function s(h){t(h),n(h)}function c(h){l(h)}return ip}var lp,Xb;function W5(){if(Xb)return lp;Xb=1,lp=e;function e(l){let a=n(l);l.graph().dummyChains.forEach(o=>{let s=l.node(o),c=s.edgeObj,h=t(l,a,c.v,c.w),f=h.path,m=h.lca,p=0,g=f[p],b=!0;for(;o!==c.w;){if(s=l.node(o),b){for(;(g=f[p])!==m&&l.node(g).maxRankf||m>a[p].lim));for(g=p,p=s;(p=l.parent(p))!==g;)h.push(p);return{path:c.concat(h.reverse()),lca:g}}function n(l){let a={},o=0;function s(c){let h=o;l.children(c).forEach(s),a[c]={low:h,lim:o++}}return l.children().forEach(s),a}return lp}var ap,Qb;function e4(){if(Qb)return ap;Qb=1;let e=zt();ap={run:t,cleanup:o};function t(s){let c=e.addDummyNode(s,"root",{},"_root"),h=l(s),f=Object.values(h),m=e.applyWithChunking(Math.max,f)-1,p=2*m+1;s.graph().nestingRoot=c,s.edges().forEach(b=>s.edge(b).minlen*=p);let g=a(s)+1;s.children().forEach(b=>n(s,c,p,g,m,h,b)),s.graph().nodeRankFactor=p}function n(s,c,h,f,m,p,g){let b=s.children(g);if(!b.length){g!==c&&s.setEdge(c,g,{weight:0,minlen:h});return}let w=e.addBorderNode(s,"_bt"),E=e.addBorderNode(s,"_bb"),S=s.node(g);s.setParent(w,g),S.borderTop=w,s.setParent(E,g),S.borderBottom=E,b.forEach(_=>{n(s,c,h,f,m,p,_);let N=s.node(_),k=N.borderTop?N.borderTop:_,T=N.borderBottom?N.borderBottom:_,M=N.borderTop?f:2*f,A=k!==T?1:m-p[g]+1;s.setEdge(w,k,{weight:M,minlen:A,nestingEdge:!0}),s.setEdge(T,E,{weight:M,minlen:A,nestingEdge:!0})}),s.parent(g)||s.setEdge(c,w,{weight:0,minlen:m+p[g]})}function l(s){var c={};function h(f,m){var p=s.children(f);p&&p.length&&p.forEach(g=>h(g,m+1)),c[f]=m}return s.children().forEach(f=>h(f,1)),c}function a(s){return s.edges().reduce((c,h)=>c+s.edge(h).weight,0)}function o(s){var c=s.graph();s.removeNode(c.nestingRoot),delete c.nestingRoot,s.edges().forEach(h=>{var f=s.edge(h);f.nestingEdge&&s.removeEdge(h)})}return ap}var op,Zb;function t4(){if(Zb)return op;Zb=1;let e=zt();op=t;function t(l){function a(o){let s=l.children(o),c=l.node(o);if(s.length&&s.forEach(a),Object.hasOwn(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(let h=c.minRank,f=c.maxRank+1;hl(h.node(f))),h.edges().forEach(f=>l(h.edge(f)))}function l(h){let f=h.width;h.width=h.height,h.height=f}function a(h){h.nodes().forEach(f=>o(h.node(f))),h.edges().forEach(f=>{let m=h.edge(f);m.points.forEach(o),Object.hasOwn(m,"y")&&o(m)})}function o(h){h.y=-h.y}function s(h){h.nodes().forEach(f=>c(h.node(f))),h.edges().forEach(f=>{let m=h.edge(f);m.points.forEach(c),Object.hasOwn(m,"x")&&c(m)})}function c(h){let f=h.x;h.x=h.y,h.y=f}return sp}var up,Jb;function r4(){if(Jb)return up;Jb=1;let e=zt();up=t;function t(n){let l={},a=n.nodes().filter(m=>!n.children(m).length),o=a.map(m=>n.node(m).rank),s=e.applyWithChunking(Math.max,o),c=e.range(s+1).map(()=>[]);function h(m){if(l[m])return;l[m]=!0;let p=n.node(m);c[p.rank].push(m),n.successors(m).forEach(h)}return a.sort((m,p)=>n.node(m).rank-n.node(p).rank).forEach(h),c}return up}var cp,Wb;function i4(){if(Wb)return cp;Wb=1;let e=zt().zipObject;cp=t;function t(l,a){let o=0;for(let s=1;sb)),c=a.flatMap(g=>l.outEdges(g).map(b=>({pos:s[b.w],weight:l.edge(b).weight})).sort((b,w)=>b.pos-w.pos)),h=1;for(;h{let b=g.pos+h;m[b]+=g.weight;let w=0;for(;b>0;)b%2&&(w+=m[b+1]),b=b-1>>1,m[b]+=g.weight;p+=g.weight*w}),p}return cp}var fp,e1;function l4(){if(e1)return fp;e1=1,fp=e;function e(t,n=[]){return n.map(l=>{let a=t.inEdges(l);if(a.length){let o=a.reduce((s,c)=>{let h=t.edge(c),f=t.node(c.v);return{sum:s.sum+h.weight*f.order,weight:s.weight+h.weight}},{sum:0,weight:0});return{v:l,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:l}})}return fp}var dp,t1;function a4(){if(t1)return dp;t1=1;let e=zt();dp=t;function t(a,o){let s={};a.forEach((h,f)=>{let m=s[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:f};h.barycenter!==void 0&&(m.barycenter=h.barycenter,m.weight=h.weight)}),o.edges().forEach(h=>{let f=s[h.v],m=s[h.w];f!==void 0&&m!==void 0&&(m.indegree++,f.out.push(s[h.w]))});let c=Object.values(s).filter(h=>!h.indegree);return n(c)}function n(a){let o=[];function s(h){return f=>{f.merged||(f.barycenter===void 0||h.barycenter===void 0||f.barycenter>=h.barycenter)&&l(h,f)}}function c(h){return f=>{f.in.push(h),--f.indegree===0&&a.push(f)}}for(;a.length;){let h=a.pop();o.push(h),h.in.reverse().forEach(s(h)),h.out.forEach(c(h))}return o.filter(h=>!h.merged).map(h=>e.pick(h,["vs","i","barycenter","weight"]))}function l(a,o){let s=0,c=0;a.weight&&(s+=a.barycenter*a.weight,c+=a.weight),o.weight&&(s+=o.barycenter*o.weight,c+=o.weight),a.vs=o.vs.concat(a.vs),a.barycenter=s/c,a.weight=c,a.i=Math.min(o.i,a.i),o.merged=!0}return dp}var hp,n1;function o4(){if(n1)return hp;n1=1;let e=zt();hp=t;function t(a,o){let s=e.partition(a,w=>Object.hasOwn(w,"barycenter")),c=s.lhs,h=s.rhs.sort((w,E)=>E.i-w.i),f=[],m=0,p=0,g=0;c.sort(l(!!o)),g=n(f,h,g),c.forEach(w=>{g+=w.vs.length,f.push(w.vs),m+=w.barycenter*w.weight,p+=w.weight,g=n(f,h,g)});let b={vs:f.flat(!0)};return p&&(b.barycenter=m/p,b.weight=p),b}function n(a,o,s){let c;for(;o.length&&(c=o[o.length-1]).i<=s;)o.pop(),a.push(c.vs),s++;return s}function l(a){return(o,s)=>o.barycenters.barycenter?1:a?s.i-o.i:o.i-s.i}return hp}var pp,r1;function s4(){if(r1)return pp;r1=1;let e=l4(),t=a4(),n=o4();pp=l;function l(s,c,h,f){let m=s.children(c),p=s.node(c),g=p?p.borderLeft:void 0,b=p?p.borderRight:void 0,w={};g&&(m=m.filter(N=>N!==g&&N!==b));let E=e(s,m);E.forEach(N=>{if(s.children(N.v).length){let k=l(s,N.v,h,f);w[N.v]=k,Object.hasOwn(k,"barycenter")&&o(N,k)}});let S=t(E,h);a(S,w);let _=n(S,f);if(g&&(_.vs=[g,_.vs,b].flat(!0),s.predecessors(g).length)){let N=s.node(s.predecessors(g)[0]),k=s.node(s.predecessors(b)[0]);Object.hasOwn(_,"barycenter")||(_.barycenter=0,_.weight=0),_.barycenter=(_.barycenter*_.weight+N.order+k.order)/(_.weight+2),_.weight+=2}return _}function a(s,c){s.forEach(h=>{h.vs=h.vs.flatMap(f=>c[f]?c[f].vs:f)})}function o(s,c){s.barycenter!==void 0?(s.barycenter=(s.barycenter*s.weight+c.barycenter*c.weight)/(s.weight+c.weight),s.weight+=c.weight):(s.barycenter=c.barycenter,s.weight=c.weight)}return pp}var mp,i1;function u4(){if(i1)return mp;i1=1;let e=Yn().Graph,t=zt();mp=n;function n(a,o,s,c){c||(c=a.nodes());let h=l(a),f=new e({compound:!0}).setGraph({root:h}).setDefaultNodeLabel(m=>a.node(m));return c.forEach(m=>{let p=a.node(m),g=a.parent(m);(p.rank===o||p.minRank<=o&&o<=p.maxRank)&&(f.setNode(m),f.setParent(m,g||h),a[s](m).forEach(b=>{let w=b.v===m?b.w:b.v,E=f.edge(w,m),S=E!==void 0?E.weight:0;f.setEdge(w,m,{weight:a.edge(b).weight+S})}),Object.hasOwn(p,"minRank")&&f.setNode(m,{borderLeft:p.borderLeft[o],borderRight:p.borderRight[o]}))}),f}function l(a){for(var o;a.hasNode(o=t.uniqueId("_root")););return o}return mp}var gp,l1;function c4(){if(l1)return gp;l1=1,gp=e;function e(t,n,l){let a={},o;l.forEach(s=>{let c=t.parent(s),h,f;for(;c;){if(h=t.parent(c),h?(f=a[h],a[h]=c):(f=o,o=c),f&&f!==c){n.setEdge(f,c);return}c=h}})}return gp}var xp,a1;function f4(){if(a1)return xp;a1=1;let e=r4(),t=i4(),n=s4(),l=u4(),a=c4(),o=Yn().Graph,s=zt();xp=c;function c(p,g){if(g&&typeof g.customOrder=="function"){g.customOrder(p,c);return}let b=s.maxRank(p),w=h(p,s.range(1,b+1),"inEdges"),E=h(p,s.range(b-1,-1,-1),"outEdges"),S=e(p);if(m(p,S),g&&g.disableOptimalOrderHeuristic)return;let _=Number.POSITIVE_INFINITY,N;for(let k=0,T=0;T<4;++k,++T){f(k%2?w:E,k%4>=2),S=s.buildLayerMatrix(p);let M=t(p,S);M<_&&(T=0,N=Object.assign({},S),_=M)}m(p,N)}function h(p,g,b){const w=new Map,E=(S,_)=>{w.has(S)||w.set(S,[]),w.get(S).push(_)};for(const S of p.nodes()){const _=p.node(S);if(typeof _.rank=="number"&&E(_.rank,S),typeof _.minRank=="number"&&typeof _.maxRank=="number")for(let N=_.minRank;N<=_.maxRank;N++)N!==_.rank&&E(N,S)}return g.map(function(S){return l(p,S,b,w.get(S)||[])})}function f(p,g){let b=new o;p.forEach(function(w){let E=w.graph().root,S=n(w,E,b,g);S.vs.forEach((_,N)=>w.node(_).order=N),a(w,b,S.vs)})}function m(p,g){Object.values(g).forEach(b=>b.forEach((w,E)=>p.node(w).order=E))}return xp}var yp,o1;function d4(){if(o1)return yp;o1=1;let e=Yn().Graph,t=zt();yp={positionX:b,findType1Conflicts:n,findType2Conflicts:l,addConflict:o,hasConflict:s,verticalAlignment:c,horizontalCompaction:h,alignCoordinates:p,findSmallestWidthAlignment:m,balance:g};function n(S,_){let N={};function k(T,M){let A=0,L=0,R=T.length,V=M[M.length-1];return M.forEach((H,B)=>{let U=a(S,H),ee=U?S.node(U).order:R;(U||H===V)&&(M.slice(L,B+1).forEach(q=>{S.predecessors(q).forEach(F=>{let z=S.node(F),G=z.order;(G{H=M[B],S.node(H).dummy&&S.predecessors(H).forEach(U=>{let ee=S.node(U);ee.dummy&&(ee.orderV)&&o(N,U,H)})})}function T(M,A){let L=-1,R,V=0;return A.forEach((H,B)=>{if(S.node(H).dummy==="border"){let U=S.predecessors(H);U.length&&(R=S.node(U[0]).order,k(A,V,B,L,R),V=B,L=R)}k(A,V,A.length,R,M.length)}),A}return _.length&&_.reduce(T),N}function a(S,_){if(S.node(_).dummy)return S.predecessors(_).find(N=>S.node(N).dummy)}function o(S,_,N){if(_>N){let T=_;_=N,N=T}let k=S[_];k||(S[_]=k={}),k[N]=!0}function s(S,_,N){if(_>N){let k=_;_=N,N=k}return!!S[_]&&Object.hasOwn(S[_],N)}function c(S,_,N,k){let T={},M={},A={};return _.forEach(L=>{L.forEach((R,V)=>{T[R]=R,M[R]=R,A[R]=V})}),_.forEach(L=>{let R=-1;L.forEach(V=>{let H=k(V);if(H.length){H=H.sort((U,ee)=>A[U]-A[ee]);let B=(H.length-1)/2;for(let U=Math.floor(B),ee=Math.ceil(B);U<=ee;++U){let q=H[U];M[V]===V&&RMath.max(U,M[ee.v]+A.edge(ee)),0)}function H(B){let U=A.outEdges(B).reduce((q,F)=>Math.min(q,M[F.w]-A.edge(F)),Number.POSITIVE_INFINITY),ee=S.node(B);U!==Number.POSITIVE_INFINITY&&ee.borderType!==L&&(M[B]=Math.max(M[B],U))}return R(V,A.predecessors.bind(A)),R(H,A.successors.bind(A)),Object.keys(k).forEach(B=>M[B]=M[N[B]]),M}function f(S,_,N,k){let T=new e,M=S.graph(),A=w(M.nodesep,M.edgesep,k);return _.forEach(L=>{let R;L.forEach(V=>{let H=N[V];if(T.setNode(H),R){var B=N[R],U=T.edge(B,H);T.setEdge(B,H,Math.max(A(S,V,R),U||0))}R=V})}),T}function m(S,_){return Object.values(_).reduce((N,k)=>{let T=Number.NEGATIVE_INFINITY,M=Number.POSITIVE_INFINITY;Object.entries(k).forEach(([L,R])=>{let V=E(S,L)/2;T=Math.max(R+V,T),M=Math.min(R-V,M)});const A=T-M;return A{["l","r"].forEach(A=>{let L=M+A,R=S[L];if(R===_)return;let V=Object.values(R),H=k-t.applyWithChunking(Math.min,V);A!=="l"&&(H=T-t.applyWithChunking(Math.max,V)),H&&(S[L]=t.mapValues(R,B=>B+H))})})}function g(S,_){return t.mapValues(S.ul,(N,k)=>{if(_)return S[_.toLowerCase()][k];{let T=Object.values(S).map(M=>M[k]).sort((M,A)=>M-A);return(T[1]+T[2])/2}})}function b(S){let _=t.buildLayerMatrix(S),N=Object.assign(n(S,_),l(S,_)),k={},T;["u","d"].forEach(A=>{T=A==="u"?_:Object.values(_).reverse(),["l","r"].forEach(L=>{L==="r"&&(T=T.map(B=>Object.values(B).reverse()));let R=(A==="u"?S.predecessors:S.successors).bind(S),V=c(S,T,N,R),H=h(S,T,V.root,V.align,L==="r");L==="r"&&(H=t.mapValues(H,B=>-B)),k[A+L]=H})});let M=m(S,k);return p(k,M),g(k,S.graph().align)}function w(S,_,N){return(k,T,M)=>{let A=k.node(T),L=k.node(M),R=0,V;if(R+=A.width/2,Object.hasOwn(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":V=-A.width/2;break;case"r":V=A.width/2;break}if(V&&(R+=N?V:-V),V=0,R+=(A.dummy?_:S)/2,R+=(L.dummy?_:S)/2,R+=L.width/2,Object.hasOwn(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":V=L.width/2;break;case"r":V=-L.width/2;break}return V&&(R+=N?V:-V),V=0,R}}function E(S,_){return S.node(_).width}return yp}var vp,s1;function h4(){if(s1)return vp;s1=1;let e=zt(),t=d4().positionX;vp=n;function n(a){a=e.asNonCompoundGraph(a),l(a),Object.entries(t(a)).forEach(([o,s])=>a.node(o).x=s)}function l(a){let o=e.buildLayerMatrix(a),s=a.graph().ranksep,c=0;o.forEach(h=>{const f=h.reduce((m,p)=>{const g=a.node(p).height;return m>g?m:g},0);h.forEach(m=>a.node(m).y=c+f/2),c+=f+s})}return vp}var bp,u1;function p4(){if(u1)return bp;u1=1;let e=Q5(),t=Z5(),n=J5(),l=zt().normalizeRanks,a=W5(),o=zt().removeEmptyRanks,s=e4(),c=t4(),h=n4(),f=f4(),m=h4(),p=zt(),g=Yn().Graph;bp=b;function b(C,P){let X=P&&P.debugTiming?p.time:p.notime;X("layout",()=>{let J=X(" buildLayoutGraph",()=>R(C));X(" runLayout",()=>w(J,X,P)),X(" updateInputGraph",()=>E(C,J))})}function w(C,P,X){P(" makeSpaceForEdgeLabels",()=>V(C)),P(" removeSelfEdges",()=>Q(C)),P(" acyclic",()=>e.run(C)),P(" nestingGraph.run",()=>s.run(C)),P(" rank",()=>n(p.asNonCompoundGraph(C))),P(" injectEdgeLabelProxies",()=>H(C)),P(" removeEmptyRanks",()=>o(C)),P(" nestingGraph.cleanup",()=>s.cleanup(C)),P(" normalizeRanks",()=>l(C)),P(" assignRankMinMax",()=>B(C)),P(" removeEdgeLabelProxies",()=>U(C)),P(" normalize.run",()=>t.run(C)),P(" parentDummyChains",()=>a(C)),P(" addBorderSegments",()=>c(C)),P(" order",()=>f(C,X)),P(" insertSelfEdges",()=>K(C)),P(" adjustCoordinateSystem",()=>h.adjust(C)),P(" position",()=>m(C)),P(" positionSelfEdges",()=>D(C)),P(" removeBorderNodes",()=>G(C)),P(" normalize.undo",()=>t.undo(C)),P(" fixupEdgeLabelCoords",()=>F(C)),P(" undoCoordinateSystem",()=>h.undo(C)),P(" translateGraph",()=>ee(C)),P(" assignNodeIntersects",()=>q(C)),P(" reversePoints",()=>z(C)),P(" acyclic.undo",()=>e.undo(C))}function E(C,P){C.nodes().forEach(X=>{let J=C.node(X),ne=P.node(X);J&&(J.x=ne.x,J.y=ne.y,J.rank=ne.rank,P.children(X).length&&(J.width=ne.width,J.height=ne.height))}),C.edges().forEach(X=>{let J=C.edge(X),ne=P.edge(X);J.points=ne.points,Object.hasOwn(ne,"x")&&(J.x=ne.x,J.y=ne.y)}),C.graph().width=P.graph().width,C.graph().height=P.graph().height}let S=["nodesep","edgesep","ranksep","marginx","marginy"],_={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["acyclicer","ranker","rankdir","align"],k=["width","height","rank"],T={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],A={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},L=["labelpos"];function R(C){let P=new g({multigraph:!0,compound:!0}),X=Y(C.graph());return P.setGraph(Object.assign({},_,$(X,S),p.pick(X,N))),C.nodes().forEach(J=>{let ne=Y(C.node(J));const re=$(ne,k);Object.keys(T).forEach(ue=>{re[ue]===void 0&&(re[ue]=T[ue])}),P.setNode(J,re),P.setParent(J,C.parent(J))}),C.edges().forEach(J=>{let ne=Y(C.edge(J));P.setEdge(J,Object.assign({},A,$(ne,M),p.pick(ne,L)))}),P}function V(C){let P=C.graph();P.ranksep/=2,C.edges().forEach(X=>{let J=C.edge(X);J.minlen*=2,J.labelpos.toLowerCase()!=="c"&&(P.rankdir==="TB"||P.rankdir==="BT"?J.width+=J.labeloffset:J.height+=J.labeloffset)})}function H(C){C.edges().forEach(P=>{let X=C.edge(P);if(X.width&&X.height){let J=C.node(P.v),re={rank:(C.node(P.w).rank-J.rank)/2+J.rank,e:P};p.addDummyNode(C,"edge-proxy",re,"_ep")}})}function B(C){let P=0;C.nodes().forEach(X=>{let J=C.node(X);J.borderTop&&(J.minRank=C.node(J.borderTop).rank,J.maxRank=C.node(J.borderBottom).rank,P=Math.max(P,J.maxRank))}),C.graph().maxRank=P}function U(C){C.nodes().forEach(P=>{let X=C.node(P);X.dummy==="edge-proxy"&&(C.edge(X.e).labelRank=X.rank,C.removeNode(P))})}function ee(C){let P=Number.POSITIVE_INFINITY,X=0,J=Number.POSITIVE_INFINITY,ne=0,re=C.graph(),ue=re.marginx||0,xe=re.marginy||0;function be(ye){let pe=ye.x,Se=ye.y,Oe=ye.width,je=ye.height;P=Math.min(P,pe-Oe/2),X=Math.max(X,pe+Oe/2),J=Math.min(J,Se-je/2),ne=Math.max(ne,Se+je/2)}C.nodes().forEach(ye=>be(C.node(ye))),C.edges().forEach(ye=>{let pe=C.edge(ye);Object.hasOwn(pe,"x")&&be(pe)}),P-=ue,J-=xe,C.nodes().forEach(ye=>{let pe=C.node(ye);pe.x-=P,pe.y-=J}),C.edges().forEach(ye=>{let pe=C.edge(ye);pe.points.forEach(Se=>{Se.x-=P,Se.y-=J}),Object.hasOwn(pe,"x")&&(pe.x-=P),Object.hasOwn(pe,"y")&&(pe.y-=J)}),re.width=X-P+ue,re.height=ne-J+xe}function q(C){C.edges().forEach(P=>{let X=C.edge(P),J=C.node(P.v),ne=C.node(P.w),re,ue;X.points?(re=X.points[0],ue=X.points[X.points.length-1]):(X.points=[],re=ne,ue=J),X.points.unshift(p.intersectRect(J,re)),X.points.push(p.intersectRect(ne,ue))})}function F(C){C.edges().forEach(P=>{let X=C.edge(P);if(Object.hasOwn(X,"x"))switch((X.labelpos==="l"||X.labelpos==="r")&&(X.width-=X.labeloffset),X.labelpos){case"l":X.x-=X.width/2+X.labeloffset;break;case"r":X.x+=X.width/2+X.labeloffset;break}})}function z(C){C.edges().forEach(P=>{let X=C.edge(P);X.reversed&&X.points.reverse()})}function G(C){C.nodes().forEach(P=>{if(C.children(P).length){let X=C.node(P),J=C.node(X.borderTop),ne=C.node(X.borderBottom),re=C.node(X.borderLeft[X.borderLeft.length-1]),ue=C.node(X.borderRight[X.borderRight.length-1]);X.width=Math.abs(ue.x-re.x),X.height=Math.abs(ne.y-J.y),X.x=re.x+X.width/2,X.y=J.y+X.height/2}}),C.nodes().forEach(P=>{C.node(P).dummy==="border"&&C.removeNode(P)})}function Q(C){C.edges().forEach(P=>{if(P.v===P.w){var X=C.node(P.v);X.selfEdges||(X.selfEdges=[]),X.selfEdges.push({e:P,label:C.edge(P)}),C.removeEdge(P)}})}function K(C){var P=p.buildLayerMatrix(C);P.forEach(X=>{var J=0;X.forEach((ne,re)=>{var ue=C.node(ne);ue.order=re+J,(ue.selfEdges||[]).forEach(xe=>{p.addDummyNode(C,"selfedge",{width:xe.label.width,height:xe.label.height,rank:ue.rank,order:re+ ++J,e:xe.e,label:xe.label},"_se")}),delete ue.selfEdges})})}function D(C){C.nodes().forEach(P=>{var X=C.node(P);if(X.dummy==="selfedge"){var J=C.node(X.e.v),ne=J.x+J.width/2,re=J.y,ue=X.x-ne,xe=J.height/2;C.setEdge(X.e,X.label),C.removeNode(P),X.label.points=[{x:ne+2*ue/3,y:re-xe},{x:ne+5*ue/6,y:re-xe},{x:ne+ue,y:re},{x:ne+5*ue/6,y:re+xe},{x:ne+2*ue/3,y:re+xe}],X.label.x=X.x,X.label.y=X.y}})}function $(C,P){return p.mapValues(p.pick(C,P),Number)}function Y(C){var P={};return C&&Object.entries(C).forEach(([X,J])=>{typeof X=="string"&&(X=X.toLowerCase()),P[X]=J}),P}return bp}var wp,c1;function m4(){if(c1)return wp;c1=1;let e=zt(),t=Yn().Graph;wp={debugOrdering:n};function n(l){let a=e.buildLayerMatrix(l),o=new t({compound:!0,multigraph:!0}).setGraph({});return l.nodes().forEach(s=>{o.setNode(s,{label:s}),o.setParent(s,"layer"+l.node(s).rank)}),l.edges().forEach(s=>o.setEdge(s.v,s.w,{},s.name)),a.forEach((s,c)=>{let h="layer"+c;o.setNode(h,{rank:"same"}),s.reduce((f,m)=>(o.setEdge(f,m,{style:"invis"}),m))}),o}return wp}var _p,f1;function g4(){return f1||(f1=1,_p="1.1.8"),_p}var Sp,d1;function x4(){return d1||(d1=1,Sp={graphlib:Yn(),layout:p4(),debug:m4(),util:{time:zt().time,notime:zt().notime},version:g4()}),Sp}var y4=x4();const h1=Ko(y4),Mo=200,oa=56,p1=20,m1=40,v4=20,g1=12;function b4(e,t,n,l,a,o,s,c){const h=[],f=[],m=new Set,p=new Set,g=new Map;for(const N of n)for(const k of N.agents)p.add(k),g.set(k,N.name);for(const N of n){const k=a[N.name],T=N.agents.length,M=Mo+p1*2,A=m1+T*oa+(T-1)*g1+v4;h.push({id:N.name,type:"groupNode",position:{x:0,y:0},data:{label:N.name,type:"parallel_group",status:(k==null?void 0:k.status)||"pending",groupName:N.name,progress:o[N.name]},style:{width:M,height:A}});for(let L=0;L$entryPoint",source:"$start",target:s,type:"animatedEdge",data:{},animated:!1})}const w=new Set(h.map(N=>N.id)),E=new Map;for(const N of h)N.parentId&&E.set(N.id,N.parentId);const S=new Map;for(const N of t){const k=E.get(N.from)??N.from,T=E.get(N.to)??N.to;if(!w.has(k)||!w.has(T)||k===T)continue;const M=`${k}->${T}`,A=S.get(M);if(A){A.when!==N.when&&(f[A.idx].data={when:void 0});continue}const L=f.length;S.set(M,{when:N.when,idx:L});const R=`${M}${N.when?`[${N.when}]`:""}`;f.push({id:R,source:k,target:T,type:"animatedEdge",data:{when:N.when},animated:!1})}const _=w4(h,f,"$start");return _4(h,f,_),{nodes:h,edges:f}}function w4(e,t,n){const l=new Set(e.filter(f=>!f.parentId).map(f=>f.id)),a=new Map;for(const f of t)!l.has(f.source)||!l.has(f.target)||(a.has(f.source)||a.set(f.source,[]),a.get(f.source).push({target:f.target,edgeId:f.id}));for(const f of a.values())f.sort((m,p)=>m.targetp.target?1:0);const o=new Set,s=new Set,c=new Set,h=f=>{c.add(f),s.add(f);for(const{target:m,edgeId:p}of a.get(f)??[])s.has(m)?o.add(p):c.has(m)||h(m);s.delete(f)};l.has(n)&&h(n);for(const f of[...a.keys()].sort())c.has(f)||h(f);return o}function _4(e,t,n){var a,o,s,c;const l=new h1.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:"TB",nodesep:50,ranksep:70,marginx:30,marginy:30});for(const h of e){if(h.parentId)continue;const f=h.type==="groupNode",m=f&&((a=h.style)==null?void 0:a.width)||Mo,p=f&&((o=h.style)==null?void 0:o.height)||oa;l.setNode(h.id,{width:m,height:p})}for(const h of t)!l.hasNode(h.source)||!l.hasNode(h.target)||(n.has(h.id)?l.setEdge(h.target,h.source):l.setEdge(h.source,h.target));h1.layout(l);for(const h of e){if(h.parentId)continue;const f=l.node(h.id);if(!f)continue;const m=h.type==="groupNode",p=m&&((s=h.style)==null?void 0:s.width)||Mo,g=m&&((c=h.style)==null?void 0:c.height)||oa;h.position={x:f.x-p/2,y:f.y-g/2}}}const De={pending:"#6b7280",running:"#3b82f6",completed:"#22c55e",failed:"#ef4444",paused:"#f59e0b",idle:"#6b7280",waiting:"#a855f7"},S4=70,x1=90;function wa({data:e,children:t}){const[n,l]=I.useState(!1),a=I.useRef(null),o=I.useCallback(()=>{a.current=setTimeout(()=>l(!0),200)},[]),s=I.useCallback(()=>{a.current&&clearTimeout(a.current),l(!1)},[]),c=De[e.status]||De.pending;return y.jsxs("div",{className:"relative",onMouseEnter:o,onMouseLeave:s,children:[t,n&&y.jsxs("div",{className:Ae("absolute z-50 bottom-full left-1/2 -translate-x-1/2 mb-2","bg-[var(--surface-raised)] border border-[var(--border)] shadow-lg","rounded-lg px-3 py-2 max-w-[260px] pointer-events-none","animate-[tooltip-in_150ms_ease-out]"),children:[y.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 w-0 h-0 border-x-[6px] border-x-transparent border-t-[6px] border-t-[var(--border)]"}),y.jsxs("div",{className:"flex flex-col gap-1.5 text-[11px]",children:[y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:c}}),y.jsx("span",{className:"font-medium text-[var(--text)] capitalize",children:e.status}),e.iteration!=null&&e.iteration>1&&y.jsxs("span",{className:"text-[var(--text-muted)] ml-auto",children:["iter ",e.iteration]})]}),y.jsx("div",{className:"h-px bg-[var(--border)]"}),y.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[e.elapsed!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Elapsed"}),y.jsx("span",{className:"text-[var(--text)] font-mono",children:ot(e.elapsed)})]}),e.model&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Model"}),y.jsx("span",{className:"text-[var(--text)] truncate",children:e.model})]}),e.tokens!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Tokens"}),y.jsxs("span",{className:"text-[var(--text)] font-mono",children:[Pn(e.tokens),e.inputTokens!=null&&e.outputTokens!=null&&y.jsxs("span",{className:"text-[var(--text-muted)]",children:[" ","(",Pn(e.inputTokens),"↑ ",Pn(e.outputTokens),"↓)"]})]})]}),e.costUsd!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Cost"}),y.jsx("span",{className:"text-[var(--text)] font-mono",children:wi(e.costUsd)})]}),e.exitCode!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Exit code"}),y.jsx("span",{className:Ae("font-mono",e.exitCode===0?"text-[var(--completed)]":"text-[var(--failed)]"),children:e.exitCode})]}),e.selectedOption&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Selected"}),y.jsx("span",{className:"text-[var(--text)] truncate",children:e.selectedOption})]})]}),e.errorMessage&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"h-px bg-[var(--border)]"}),y.jsxs("div",{className:"text-red-400 leading-tight",children:[e.errorType&&y.jsxs("span",{className:"font-medium",children:[e.errorType,": "]}),y.jsxs("span",{className:"break-words",children:[e.errorMessage.slice(0,120),e.errorMessage.length>120?"...":""]})]})]})]})]})]})}const k4=I.memo(function({data:t,id:n,selected:l}){var L;const a=t,o=Qn(),c=((L=o[n])==null?void 0:L.status)||a.status||"pending",h=De[c]||De.pending,f=o[n],m=f==null?void 0:f.elapsed,p=f==null?void 0:f.model,g=f==null?void 0:f.tokens,b=f==null?void 0:f.input_tokens,w=f==null?void 0:f.output_tokens,E=f==null?void 0:f.cost_usd,S=f==null?void 0:f.iteration,_=f==null?void 0:f.error_type,N=f==null?void 0:f.error_message,k=f==null?void 0:f.context_pct,T=E4(n,c),M=N4(c),A=(()=>{if(c==="failed"&&N)return{text:N.length>40?N.slice(0,37)+"...":N,className:"text-red-400"};if(c==="running")return{text:T,className:"text-[var(--text-muted)]"};if(c==="completed"){const R=[];return m!=null&&R.push(ot(m)),g!=null&&R.push(`${Pn(g)} tok`),E!=null&&R.push(wi(E)),{text:R.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(bt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(wa,{data:{status:c,elapsed:m,model:p,tokens:g,inputTokens:b,outputTokens:w,costUsd:E,iteration:S,errorType:_,errorMessage:N},children:y.jsxs("div",{className:Ae("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",M),style:{borderColor:h},children:[y.jsx("div",{className:Ae("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${h}20`},children:y.jsx(cN,{className:"w-3.5 h-3.5",style:{color:h}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),S!=null&&S>1&&y.jsxs("span",{className:"flex-shrink-0 inline-flex items-center justify-center px-1.5 py-0.5 rounded-full text-[9px] font-bold leading-none",style:{backgroundColor:`${h}25`,color:h},children:["x",S]})]}),A.text&&y.jsx("span",{className:Ae("text-[10px] truncate leading-tight",A.className),children:A.text})]}),k!=null&&y.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-[2px] rounded-b-lg overflow-hidden",style:{backgroundColor:"rgba(255,255,255,0.06)"},children:y.jsx("div",{className:Ae("h-full transition-all duration-500",k>=x1?"animate-[context-pulse_2s_ease-in-out_infinite]":""),style:{width:`${Math.min(k,100)}%`,backgroundColor:k>=x1?"#ef4444":k>=S4?"#f59e0b":"#22c55e"}})})]})}),y.jsx(bt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function E4(e,t){var h;const n=(h=Qn()[e])==null?void 0:h.startedAt,l=se(f=>f.replayMode),a=se(f=>f.lastEventTime),[o,s]=I.useState("0.0s"),c=I.useRef(null);return I.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=n??a??0;s(ot((a??p)-p));return}const f=n!=null?n*1e3:Date.now(),m=()=>{const p=(Date.now()-f)/1e3;s(ot(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,n,l,a]),o}function N4(e){const t=I.useRef(e),[n,l]=I.useState("");return I.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),n}const C4=I.memo(function({data:t,id:n,selected:l}){var _;const a=t,o=Qn(),c=((_=o[n])==null?void 0:_.status)||a.status||"pending",h=De[c]||De.pending,f=o[n],m=f==null?void 0:f.elapsed,p=f==null?void 0:f.exit_code,g=f==null?void 0:f.error_type,b=f==null?void 0:f.error_message,w=j4(n,c),E=T4(c),S=(()=>{if(c==="failed"&&b)return{text:b.length>40?b.slice(0,37)+"...":b,className:"text-red-400"};if(c==="running")return{text:w,className:"text-[var(--text-muted)]"};if(c==="completed"){const N=[];return m!=null&&N.push(ot(m)),p!=null&&N.push(`exit ${p}`),{text:N.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(bt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(wa,{data:{status:c,elapsed:m,exitCode:p,errorType:g,errorMessage:b},children:y.jsxs("div",{className:Ae("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",E),style:{borderColor:h},children:[y.jsx("div",{className:Ae("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${h}20`},children:y.jsx(kN,{className:"w-3.5 h-3.5",style:{color:h}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),S.text&&y.jsx("span",{className:Ae("text-[10px] truncate leading-tight",S.className),children:S.text})]})]})}),y.jsx(bt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function j4(e,t){var h;const n=(h=Qn()[e])==null?void 0:h.startedAt,l=se(f=>f.replayMode),a=se(f=>f.lastEventTime),[o,s]=I.useState("0.0s"),c=I.useRef(null);return I.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=n??a??0;s(ot((a??p)-p));return}const f=n!=null?n*1e3:Date.now(),m=()=>{const p=(Date.now()-f)/1e3;s(ot(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,n,l,a]),o}function T4(e){const t=I.useRef(e),[n,l]=I.useState("");return I.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),n}const A4=I.memo(function({data:t,id:n,selected:l}){var N;const a=t,o=Qn(),c=((N=o[n])==null?void 0:N.status)||a.status||"pending",h=De[c]||De.pending,f=o[n],m=f==null?void 0:f.elapsed,p=f==null?void 0:f.set_output_keys,g=f==null?void 0:f.set_value_repr,b=f==null?void 0:f.error_type,w=f==null?void 0:f.error_message,E=z4(n,c),S=M4(c),_=(()=>{if(c==="failed"&&w)return{text:w.length>40?w.slice(0,37)+"...":w,className:"text-red-400"};if(c==="running")return{text:E,className:"text-[var(--text-muted)]"};if(c==="completed"){const k=[];if(m!=null&&k.push(ot(m)),p&&p.length>0)k.push(`${p.length} key${p.length===1?"":"s"}`);else if(g){const T=g.length>24?g.slice(0,21)+"…":g;k.push(T)}return{text:k.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(bt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(wa,{data:{status:c,elapsed:m,errorType:b,errorMessage:w},children:y.jsxs("div",{className:Ae("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",S),style:{borderColor:h},children:[y.jsx("div",{className:Ae("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${h}20`},children:y.jsx(EN,{className:"w-3.5 h-3.5",style:{color:h}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),_.text&&y.jsx("span",{className:Ae("text-[10px] truncate leading-tight",_.className),children:_.text})]})]})}),y.jsx(bt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function z4(e,t){var h;const n=(h=Qn()[e])==null?void 0:h.startedAt,l=se(f=>f.replayMode),a=se(f=>f.lastEventTime),[o,s]=I.useState("0.0s"),c=I.useRef(null);return I.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=n??a??0;s(ot((a??p)-p));return}const f=n!=null?n*1e3:Date.now(),m=()=>{const p=(Date.now()-f)/1e3;s(ot(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,n,l,a]),o}function M4(e){const t=I.useRef(e),[n,l]=I.useState("");return I.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),n}const D4=I.memo(function({data:t,id:n,selected:l}){var p,g;const a=t,o=Qn(),c=((p=o[n])==null?void 0:p.status)||a.status||"pending",h=De[c]||De.pending,f=(g=o[n])==null?void 0:g.selected_option,m=R4(c);return y.jsxs(y.Fragment,{children:[y.jsx(bt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(wa,{data:{status:c,selectedOption:f},children:y.jsxs("div",{className:Ae("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 border-dashed bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="waiting"&&"shadow-[0_0_12px_var(--waiting-muted)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",m),style:{borderColor:h},children:[y.jsx("div",{className:Ae("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="waiting"&&"animate-pulse"),style:{backgroundColor:`${h}20`},children:y.jsx(SN,{className:"w-3.5 h-3.5",style:{color:h}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),c==="waiting"&&y.jsx("span",{className:"text-[10px] text-[var(--waiting)] truncate leading-tight",children:"Awaiting input..."}),c==="completed"&&f&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] truncate leading-tight",children:f})]})]})}),y.jsx(bt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function R4(e){const t=I.useRef(e),[n,l]=I.useState("");return I.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"||e==="waiting"?l("node-activate"):(a==="running"||a==="waiting")&&e==="completed"&&l("node-complete");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),n}const O4=I.memo(function({data:t,id:n,selected:l}){var S;const a=t,s=a.type==="for_each_group"?wN:yN,c=a.progress,m=((S=Qn()[n])==null?void 0:S.status)||a.status||"pending",p=De[m]||De.pending,g=L4(m),b=c?`${c.completed+c.failed}/${c.total}${c.failed>0?` (${c.failed} failed)`:""}`:null,w=c&&c.total>0?(c.completed+c.failed)/c.total*100:0,E=c!=null&&c.failed>0;return y.jsxs(y.Fragment,{children:[y.jsx(bt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsxs("div",{className:Ae("flex flex-col gap-1 px-4 py-3 rounded-xl border-2 border-dashed bg-[var(--surface)]/80 min-w-[180px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",m==="running"&&"shadow-[0_0_16px_var(--running-glow)]",g),style:{borderColor:p,minHeight:"100%"},children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(s,{className:"w-3.5 h-3.5",style:{color:p}}),y.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:a.label})]}),b&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] font-mono",children:b}),c&&c.total>0&&m==="running"&&y.jsx("div",{className:"w-full h-1 rounded-full bg-[var(--border)] overflow-hidden mt-0.5",children:y.jsx("div",{className:"h-full rounded-full transition-all duration-500 ease-out",style:{width:`${w}%`,backgroundColor:E?"var(--failed)":"var(--completed)"}})})]}),y.jsx(bt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function L4(e){const t=I.useRef(e),[n,l]=I.useState("");return I.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),n}const H4=I.memo(function({data:t,id:n,selected:l}){const a=t,s=se(S=>{var _;return(_=S.nodes[n])==null?void 0:_.status})||a.status||"pending",c=De[s]||De.pending,h=se(S=>{var _;return(_=S.nodes[n])==null?void 0:_.elapsed}),f=se(S=>{var _;return(_=S.nodes[n])==null?void 0:_.error_message}),m=se(S=>S.navigateIntoSubworkflow),p=$m(),g=p.some(S=>S.parentAgent===n),b=p.find(S=>S.parentAgent===n),w=b==null?void 0:b.workflowName,E=(()=>{if(s==="failed"&&f)return{text:f.length>35?f.slice(0,32)+"...":f,className:"text-red-400"};if(s==="running")return{text:w||"Running subworkflow…",className:"text-[var(--text-muted)]"};if(s==="completed"){const S=[];return w&&S.push(w),h!=null&&S.push(`${h.toFixed(1)}s`),{text:S.join(" · ")||"Done",className:"text-[var(--text-muted)]"}}return{text:w||null,className:"text-[var(--text-muted)]"}})();return y.jsxs(y.Fragment,{children:[y.jsx(bt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(wa,{data:{status:s,elapsed:h,errorType:void 0,errorMessage:f,iteration:void 0},children:y.jsxs("div",{className:Ae("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[240px] transition-all duration-300 cursor-pointer",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",s==="running"&&"shadow-[0_0_12px_var(--running-glow)]"),style:{borderColor:c,borderStyle:"dashed"},onDoubleClick:S=>{g&&(S.stopPropagation(),m(n))},children:[y.jsx("div",{className:Ae("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",s==="running"&&"animate-pulse"),style:{backgroundColor:`${c}20`},children:y.jsx(kc,{className:"w-3.5 h-3.5",style:{color:c}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("div",{className:"flex items-center gap-1",children:y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label})}),E.text&&y.jsx("span",{className:Ae("text-[10px] truncate leading-tight",E.className),children:E.text})]}),g&&y.jsx(Lr,{className:"w-3.5 h-3.5 flex-shrink-0 text-[var(--text-muted)]"})]})}),y.jsx(bt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),B4=I.memo(function({data:t,id:n,selected:l}){var k;const a=t,o=Qn(),c=((k=o[n])==null?void 0:k.status)||a.status||"pending",h=De[c]||De.pending,f=o[n],m=(f==null?void 0:f.duration_seconds)??(f==null?void 0:f.requested_seconds),p=f==null?void 0:f.waited_seconds,g=f==null?void 0:f.elapsed,b=f==null?void 0:f.interrupted,w=f==null?void 0:f.error_type,E=f==null?void 0:f.error_message,S=I4(n,c),_=q4(c),N=(()=>{if(c==="failed"&&E)return{text:E.length>40?E.slice(0,37)+"...":E,className:"text-red-400"};if(c==="running"){const T=typeof m=="number"?` / ${ot(m)}`:"";return{text:`${S}${T}`,className:"text-[var(--text-muted)]"}}if(c==="completed"){const T=[];return p!=null?T.push(ot(p)):g!=null&&T.push(ot(g)),b&&T.push("interrupted"),{text:T.join(" · ")||null,className:"text-[var(--text-muted)]"}}return c==="pending"&&typeof m=="number"?{text:ot(m),className:"text-[var(--text-muted)]"}:{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(bt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(wa,{data:{status:c,elapsed:p??g,errorType:w,errorMessage:E},children:y.jsxs("div",{className:Ae("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",_),style:{borderColor:h},children:[y.jsx("div",{className:Ae("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${h}20`},children:y.jsx(xw,{className:"w-3.5 h-3.5",style:{color:h}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),N.text&&y.jsx("span",{className:Ae("text-[10px] truncate leading-tight",N.className),children:N.text})]})]})}),y.jsx(bt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function I4(e,t){var h;const n=(h=Qn()[e])==null?void 0:h.startedAt,l=se(f=>f.replayMode),a=se(f=>f.lastEventTime),[o,s]=I.useState("0.0s"),c=I.useRef(null);return I.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=n??a??0;s(ot((a??p)-p));return}const f=n!=null?n*1e3:Date.now(),m=()=>{const p=(Date.now()-f)/1e3;s(ot(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,n,l,a]),o}function q4(e){const t=I.useRef(e),[n,l]=I.useState("");return I.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),n}const $4=I.memo(function({data:t,selected:n}){const a=t.status||"pending",o=a==="completed",s=a==="failed",c=!o&&!s,h=o?De.completed:s?De.failed:De.pending;return y.jsxs(y.Fragment,{children:[y.jsx(bt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx("div",{className:Ae("flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300",o?"bg-[var(--completed)] shadow-[0_0_16px_var(--completed-muted)]":s?"bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]":"bg-[var(--node-bg)]",n&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]"),style:{borderColor:h},children:o?y.jsx(Ki,{className:"w-5 h-5 text-white",strokeWidth:3}):s?y.jsx(Sw,{className:"w-3.5 h-3.5 text-white",fill:"white"}):y.jsx(Ki,{className:"w-5 h-5",strokeWidth:2.5,style:{color:c?De.pending:h}})})]})}),U4=I.memo(function({data:t,selected:n}){const a=t.status||"pending",o=De[a]||De.pending,s=a==="running"||a==="completed";return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:Ae("flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300",s?"bg-[var(--completed)]":"bg-[var(--node-bg)]",n&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",s&&"shadow-[0_0_12px_var(--completed-muted)]"),style:{borderColor:o},children:y.jsx(Ec,{className:"w-4 h-4 ml-0.5",style:{color:s?"white":o}})}),y.jsx(bt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),y1="#a78bfa",V4=I.memo(function({data:t,selected:n}){const l=t,a=l.status||"pending",o=a==="running"||a==="completed",s=o?y1:De[a]||y1,c=l.parentAgent,h=se(f=>f.navigateUp);return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex flex-col items-center gap-1",children:[y.jsx("div",{className:Ae("flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer",o?"bg-[#a78bfa]":"bg-[var(--node-bg)]",n&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",o&&"shadow-[0_0_12px_rgba(167,139,250,0.4)]"),style:{borderColor:s},onDoubleClick:f=>{f.stopPropagation(),h()},children:y.jsx(sN,{className:"w-4 h-4",style:{color:o?"white":s}})}),c&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] whitespace-nowrap",children:["from ",y.jsx("span",{className:"font-medium text-[var(--text)]",children:c})]})]}),y.jsx(bt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),v1="#a78bfa",P4=I.memo(function({data:t,selected:n}){const l=t,a=l.status||"pending",o=a==="completed",s=a==="failed",c=o?v1:s?De.failed:v1,h=l.parentAgent,f=se(m=>m.navigateUp);return y.jsxs(y.Fragment,{children:[y.jsx(bt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsxs("div",{className:"flex flex-col items-center gap-1",children:[y.jsx("div",{className:Ae("flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer",o?"bg-[#a78bfa] shadow-[0_0_12px_rgba(167,139,250,0.4)]":s?"bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]":"bg-[var(--node-bg)]",n&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]"),style:{borderColor:c},onDoubleClick:m=>{m.stopPropagation(),f()},children:y.jsx(uN,{className:"w-4 h-4",style:{color:o||s?"white":c}})}),h&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] whitespace-nowrap",children:["return to ",y.jsx("span",{className:"font-medium text-[var(--text)]",children:h})]})]})]})}),G4=I.memo(function({id:t,sourceX:n,sourceY:l,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,source:h,target:f,data:m}){const p=T5(),g=I.useMemo(()=>p.find(V=>V.from===h&&V.to===f),[p,h,f]),[b,w,E]=Rm({sourceX:n,sourceY:l,targetX:a,targetY:o,sourcePosition:s,targetPosition:c}),S=m==null?void 0:m.when,_=!!S,N=(g==null?void 0:g.state)==="taken",k=(g==null?void 0:g.state)==="highlighted",T=(g==null?void 0:g.state)==="failed";let M="var(--edge-color)",A=2,L;T?(M="var(--failed)",A=3):N?(M="var(--edge-taken)",A=3):k&&(M="var(--edge-active)",A=3),_&&!N&&!k&&!T&&(L="6 3");const R=T?"failed":N?"taken":k?"active":"default";return y.jsxs(y.Fragment,{children:[y.jsx(ls,{id:t,path:b,style:{stroke:M,strokeWidth:A,strokeDasharray:L,transition:"stroke 0.3s ease, stroke-width 0.3s ease"},markerEnd:`url(#arrow-${R})`}),_&&y.jsx(KM,{children:y.jsx("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${w}px,${E}px)`,pointerEvents:"all"},children:y.jsx("span",{className:"inline-block px-1.5 py-0.5 rounded-full text-[9px] font-mono leading-tight max-w-[140px] truncate",style:{backgroundColor:T?"var(--failed)":N?"var(--edge-taken)":"var(--surface)",color:T||N?"var(--bg)":"var(--text-muted)",border:`1px solid ${T?"var(--failed)":N?"var(--edge-taken)":"var(--border)"}`},title:S,children:S})})}),N&&y.jsx("circle",{r:"3",fill:"var(--edge-taken)",children:y.jsx("animateMotion",{dur:"1s",repeatCount:"indefinite",path:b})}),T&&y.jsx("circle",{r:"3",fill:"var(--failed)",opacity:"0.8",children:y.jsx("animateMotion",{dur:"1.5s",repeatCount:"indefinite",path:b})})]})});function F4(){const e=se(s=>s.workflowStatus),t=se(s=>s.workflowFailure),n=se(s=>s.workflowFailedAgent),l=se(s=>s.selectNode);if(e!=="failed"||!t)return null;const a=t.message||t.error_type||"Unknown error",o=t.error_type==="TimeoutError";return y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:Ae("flex items-center gap-2 px-4 py-2 rounded-lg","bg-red-950/90 border border-red-500/40 shadow-lg shadow-red-500/10","backdrop-blur-sm max-w-[560px]"),children:[y.jsx(lc,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),y.jsxs("div",{className:"flex flex-col min-w-0",children:[y.jsx("span",{className:"text-xs font-medium text-red-300",children:"Workflow Failed"}),y.jsx("span",{className:"text-[11px] text-red-400/80 truncate",children:a}),o&&t.current_agent&&y.jsxs("span",{className:"text-[10px] text-red-400/60 truncate",children:["Timed out on agent: ",t.current_agent]}),t.checkpoint_path&&y.jsxs("span",{className:"text-[10px] text-red-400/50 truncate",title:t.checkpoint_path,children:["Checkpoint: ",t.checkpoint_path.split("/").pop()]})]}),n&&y.jsxs("button",{onClick:()=>l(n),className:"flex items-center gap-1 px-2 py-1 rounded text-[10px] font-medium text-red-300 bg-red-500/20 hover:bg-red-500/30 transition-colors flex-shrink-0 ml-1",children:[y.jsx(mN,{className:"w-3 h-3"}),"View"]})]})})}function Y4(){const[e,t]=I.useState(!1),n=se(h=>h.workflowStatus),l=se(h=>h.totalCost),a=se(h=>h.totalTokens),o=se(h=>h.agentsCompleted),s=se(h=>h.agentsTotal),c=Ew();return n!=="completed"||e?null:y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:Ae("flex items-center gap-3 px-4 py-2 rounded-lg","bg-green-950/90 border border-green-500/40 shadow-lg shadow-green-500/10","backdrop-blur-sm"),children:[y.jsx(dN,{className:"w-4 h-4 text-green-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs font-medium text-green-300",children:"Completed"}),y.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-green-400/80 font-mono",children:[y.jsx("span",{children:c}),s>0&&y.jsxs("span",{children:[o,"/",s," agents"]}),a>0&&y.jsxs("span",{children:[Pn(a)," tok"]}),l>0&&y.jsx("span",{children:wi(l)})]}),y.jsx("button",{onClick:()=>t(!0),className:"p-0.5 rounded text-green-500/60 hover:text-green-300 transition-colors flex-shrink-0 ml-1",children:y.jsx(sl,{className:"w-3.5 h-3.5"})})]})})}const X4={agentNode:k4,scriptNode:C4,setNode:A4,gateNode:D4,groupNode:O4,workflowNode:H4,waitNode:B4,endNode:$4,startNode:U4,ingressNode:V4,egressNode:P4},Q4={animatedEdge:G4},Z4={type:"animatedEdge"};function K4(){return y.jsx("svg",{style:{position:"absolute",width:0,height:0},children:y.jsxs("defs",{children:[y.jsx("marker",{id:"arrow-default",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-color)"})}),y.jsx("marker",{id:"arrow-active",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-active)"})}),y.jsx("marker",{id:"arrow-taken",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-taken)"})}),y.jsx("marker",{id:"arrow-failed",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--failed)"})})]})})}function J4(){const e=A5(),t=se(z=>z.viewContextPath),n=se(z=>z.selectNode),l=se(z=>z.selectedNode),a=se(z=>z.workflowStatus),o=se(z=>z.wsStatus),s=se(z=>z.workflowFailedAgent),c=se(z=>z.navigateIntoSubworkflow),{agents:h,routes:f,parallelGroups:m,forEachGroups:p,nodes:g,groupProgress:b,entryPoint:w,subworkflowContexts:E,parentAgent:S}=e,[_,N,k]=JM([]),[T,M,A]=WM([]),L=I.useRef(!1),R=I.useRef(""),V=JSON.stringify(t);I.useEffect(()=>{if(h.length===0){R.current!==V&&(L.current=!1,R.current=V,N([]),M([]));return}if(R.current!==V&&(L.current=!1,R.current=V),L.current)return;L.current=!0;const{nodes:z,edges:G}=b4(h,f,m,p,g,b,w,S);N(z),M(G)},[h,f,m,p,g,b,w,N,M,V,S]),I.useEffect(()=>{L.current&&N(z=>z.map(G=>{const Q=g[G.id];if(!Q)return G;const K=Q.status||"pending",D=G.data.status;if(K!==D){const $={...G.data,status:K};return G.data.groupName&&b[G.data.groupName]&&($.progress=b[G.data.groupName]),{...G,data:$}}if(G.data.groupName&&b[G.data.groupName]){const $=G.data.progress,Y=b[G.data.groupName];if(Y&&(!$||$.completed!==Y.completed||$.failed!==Y.failed))return{...G,data:{...G.data,progress:Y}}}return G}))},[g,b,N]);const H=I.useCallback((z,G)=>{G.type==="groupNode"&&G.data.type!=="for_each_group"||n(G.id)},[n]),B=I.useCallback((z,G)=>{E.some(K=>K.parentAgent===G.id)&&c(G.id)},[E,c]),U=I.useCallback(()=>{n(null)},[n]),ee=I.useCallback(z=>{var Q;const G=((Q=z.data)==null?void 0:Q.status)||"pending";return De[G]??De.pending??"#6b7280"},[]);I.useEffect(()=>{N(z=>z.map(G=>({...G,selected:G.id===l})))},[l,N]),I.useEffect(()=>{a==="failed"&&s&&n(s)},[a,s,n]);const q=a==="pending"&&h.length===0,F=(()=>{switch(o){case"connecting":return"Connecting to workflow…";case"reconnecting":return"Reconnecting…";case"disconnected":return"Connection lost. Retrying…";default:return"Waiting for workflow…"}})();return y.jsxs("div",{className:"w-full h-full relative",children:[y.jsx(K4,{}),y.jsx(F4,{}),y.jsx(Y4,{}),q&&y.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center pointer-events-none",children:[y.jsxs("div",{className:"relative mb-3",children:[y.jsx(jN,{className:"w-8 h-8 text-[var(--accent)] opacity-20"}),y.jsx(da,{className:"w-8 h-8 text-[var(--text-muted)] animate-spin absolute inset-0 opacity-40"})]}),y.jsx("p",{className:"text-sm text-[var(--text-muted)] animate-pulse",children:F})]}),y.jsxs(QM,{nodes:_,edges:T,onNodesChange:k,onEdgesChange:A,onNodeClick:H,onNodeDoubleClick:B,onPaneClick:U,nodeTypes:X4,edgeTypes:Q4,defaultEdgeOptions:Z4,fitView:!0,fitViewOptions:{padding:.2},minZoom:.2,maxZoom:2,proOptions:{hideAttribution:!0},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,children:[y.jsx(i5,{variant:Rr.Dots,gap:20,size:1,color:"var(--border-subtle)"}),y.jsx(k5,{nodeColor:ee,maskColor:"var(--minimap-mask)",style:{background:"var(--minimap-bg)"},pannable:!0,zoomable:!0}),y.jsx(f5,{showInteractive:!1,children:y.jsx(W4,{})}),y.jsx(eD,{}),y.jsx(tD,{viewPathKey:V}),y.jsx(nD,{})]})]})}function W4(){const{fitView:e}=ul(),t=I.useCallback(()=>{e({padding:.2,duration:300})},[e]);return y.jsx("button",{onClick:t,className:"react-flow__controls-button",title:"Fit view (F)",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:y.jsx(vN,{className:"w-3.5 h-3.5"})})}function eD(){const{fitView:e}=ul();return I.useEffect(()=>{const t=n=>{var a;const l=(a=n.target)==null?void 0:a.tagName;l==="INPUT"||l==="TEXTAREA"||l==="SELECT"||n.key==="f"&&!n.ctrlKey&&!n.metaKey&&!n.altKey&&e({padding:.2,duration:300})};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),null}function tD({viewPathKey:e}){const{fitView:t}=ul(),n=I.useRef(e);return I.useEffect(()=>{n.current!==e&&(n.current=e,setTimeout(()=>t({padding:.2,duration:300}),50))},[e,t]),null}function nD(){const e=R5();return e?y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-amber-950/90 border border-amber-500/40 shadow-lg shadow-amber-500/10 backdrop-blur-sm max-w-[560px]",children:[y.jsx("span",{className:"text-xs text-amber-300",children:"⚠"}),y.jsx("span",{className:"text-[11px] text-amber-400/80",children:e.message}),y.jsx("a",{href:window.location.pathname,className:"px-2 py-0.5 rounded text-[10px] font-medium text-amber-300 bg-amber-500/20 hover:bg-amber-500/30 transition-colors flex-shrink-0 ml-1",children:"Root"})]})}):null}function Br({items:e}){const t=e.filter(n=>n.value!=null&&n.value!=="");return t.length===0?null:y.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1.5 text-xs",children:t.map(({label:n,value:l})=>y.jsxs("div",{className:"contents",children:[y.jsx("dt",{className:"text-[var(--text-muted)] whitespace-nowrap",children:n}),y.jsx("dd",{className:"text-[var(--text)] break-words",children:typeof l=="object"?JSON.stringify(l):String(l)})]},n))})}function OS(e){const t=[];return e.elapsed!=null&&t.push({label:"Elapsed",value:ot(e.elapsed)}),e.model&&t.push({label:"Model",value:e.model}),e.reasoning_effort&&t.push({label:"Reasoning",value:e.reasoning_effort}),e.tokens!=null&&t.push({label:"Tokens",value:Pn(e.tokens)}),e.input_tokens!=null&&e.output_tokens!=null&&t.push({label:"In / Out",value:`${Pn(e.input_tokens)} / ${Pn(e.output_tokens)}`}),e.cost_usd!=null&&t.push({label:"Cost",value:wi(e.cost_usd)}),e.context_window_used!=null&&e.context_window_max!=null&&t.push({label:"Context",value:qN(e.context_window_used,e.context_window_max)}),e.iteration!=null&&t.push({label:"Iteration",value:e.iteration}),e.error_type&&t.push({label:"Error",value:e.error_type}),e.error_message&&t.push({label:"Message",value:e.error_message}),t}function _i({output:e,title:t="Output",defaultExpanded:n=!0,maxHeight:l="300px"}){const[a,o]=I.useState(n),[s,c]=I.useState(!1),h=kw(e);if(!h)return null;const f=typeof e=="object"&&e!==null,m=async()=>{await navigator.clipboard.writeText(h),c(!0),setTimeout(()=>c(!1),2e3)};return y.jsxs("div",{className:"space-y-1.5",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold",children:[a?y.jsx(ol,{className:"w-3 h-3"}):y.jsx(Lr,{className:"w-3 h-3"}),t]}),a&&y.jsx("button",{onClick:m,className:"flex items-center gap-1 text-[10px] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",title:"Copy to clipboard",children:s?y.jsx(Ki,{className:"w-3 h-3 text-[var(--completed)]"}):y.jsx(vw,{className:"w-3 h-3"})})]}),a&&y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md p-3 font-mono text-[11px] leading-relaxed text-[var(--text)] overflow-auto whitespace-pre-wrap break-words",style:{maxHeight:l},children:f?y.jsx(rD,{text:h}):h})]})}function rD({text:e}){const t=e.split(/("(?:[^"\\]|\\.)*")/g);return y.jsx(y.Fragment,{children:t.map((n,l)=>{if(l%2===1){const o=t.slice(l+1).join(""),s=/^\s*:/.test(o);return y.jsx("span",{className:s?"text-blue-400":"text-green-400",children:n},l)}const a=n.replace(/\b(true|false|null)\b|(-?\d+\.?\d*(?:e[+-]?\d+)?)/gi,(o,s,c)=>s?`${o}`:c?`${o}`:o);return y.jsx("span",{dangerouslySetInnerHTML:{__html:a}},l)})})}function Vm({activity:e,defaultExpanded:t=!0}){const[n,l]=I.useState(t),a=I.useRef(null);return I.useEffect(()=>{a.current&&n&&(a.current.scrollTop=a.current.scrollHeight)},[e.length,n]),e.length===0?null:y.jsxs("div",{className:"space-y-1.5",children:[y.jsxs("button",{onClick:()=>l(!n),className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold",children:[n?y.jsx(ol,{className:"w-3 h-3"}):y.jsx(Lr,{className:"w-3 h-3"}),"Activity (",e.length,")"]}),n&&y.jsx("div",{ref:a,className:"max-h-[400px] overflow-y-auto space-y-0.5",children:e.map((o,s)=>y.jsx(iD,{entry:o},s))})]})}function iD({entry:e}){const t={reasoning:"text-indigo-400/70","tool-start":"text-blue-400","tool-complete":"text-green-400",turn:"text-amber-400",message:"text-[var(--text)]"};return y.jsxs("div",{className:Ae("py-1.5 px-2 rounded text-[11px] leading-relaxed border-b border-[var(--border-subtle)] last:border-b-0"),children:[y.jsxs("div",{className:"flex items-start gap-1.5",children:[y.jsx("span",{className:"w-4 text-center flex-shrink-0",children:e.icon}),y.jsx("span",{className:"text-[var(--text-muted)] uppercase text-[9px] font-semibold tracking-wider w-12 flex-shrink-0 pt-px",children:e.label}),y.jsx("span",{className:Ae("break-words",t[e.type]||"text-[var(--text)]"),children:typeof e.text=="object"?JSON.stringify(e.text):e.text})]}),e.detail&&y.jsx("div",{className:"mt-1 ml-[4.25rem] px-2 py-1 bg-[var(--bg)] rounded text-[10px] font-mono text-[var(--text-muted)] whitespace-pre-wrap break-words max-h-24 overflow-y-auto",children:typeof e.detail=="object"?JSON.stringify(e.detail,null,2):e.detail})]})}function b1({node:e}){const t=e.status,n=De[t]||De.pending,l=e.iterationHistory&&e.iterationHistory.length>0;return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${n}20`,color:n},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Agent"})]}),l?y.jsx(w1,{label:`Iteration ${e.iteration??"?"} (current)`,defaultExpanded:!0,status:t,snapshot:{iteration:e.iteration??0,prompt:e.prompt,output:e.output,elapsed:e.elapsed,model:e.model,reasoning_effort:e.reasoning_effort,tokens:e.tokens,input_tokens:e.input_tokens,output_tokens:e.output_tokens,cost_usd:e.cost_usd,activity:e.activity,error_type:e.error_type,error_message:e.error_message}}):y.jsxs(y.Fragment,{children:[y.jsx(Br,{items:OS(e)}),e.prompt&&y.jsx(_i,{output:e.prompt,title:"Input / Prompt",defaultExpanded:!0}),y.jsx(Vm,{activity:e.activity,defaultExpanded:t!=="completed"}),e.output!=null&&y.jsx(_i,{output:e.output,title:"Output"})]}),l&&[...e.iterationHistory].reverse().map(a=>y.jsx(w1,{label:`Iteration ${a.iteration}`,defaultExpanded:!1,status:t,snapshot:a},a.iteration))]})}function w1({label:e,defaultExpanded:t,snapshot:n,status:l}){const[a,o]=I.useState(t);return y.jsxs("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:[y.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-2 w-full px-3 py-2 bg-[var(--bg)] hover:bg-[var(--node-bg)] transition-colors text-left",children:[a?y.jsx(ol,{className:"w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0"}):y.jsx(Lr,{className:"w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("span",{className:"text-xs font-semibold text-[var(--text)]",children:e}),n.elapsed!=null&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] ml-auto",children:lD(n.elapsed)})]}),a&&y.jsxs("div",{className:"px-3 py-3 space-y-3 border-t border-[var(--border)]",children:[y.jsx(Br,{items:OS(n)}),n.prompt&&y.jsx(_i,{output:n.prompt,title:"Input / Prompt",defaultExpanded:!1}),y.jsx(Vm,{activity:n.activity,defaultExpanded:t&&l!=="completed"}),n.output!=null&&y.jsx(_i,{output:n.output,title:"Output",defaultExpanded:!0}),n.error_type&&y.jsxs("div",{className:"text-xs text-red-400",children:[y.jsx("span",{className:"font-semibold",children:n.error_type}),n.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",n.error_message]})]})]})]})}function lD(e){if(e<1)return`${(e*1e3).toFixed(0)}ms`;if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=(e%60).toFixed(0);return`${t}m ${n}s`}function aD({node:e}){const t=e.status,n=De[t]||De.pending,l=[];e.elapsed!=null&&l.push({label:"Elapsed",value:ot(e.elapsed)}),e.exit_code!=null&&l.push({label:"Exit Code",value:e.exit_code}),e.error_type&&l.push({label:"Error",value:e.error_type}),e.error_message&&l.push({label:"Message",value:e.error_message});let a="";return e.stdout&&(a+=e.stdout),e.stderr&&(a+=(a?` +`)),m=f.reduce((p,g)=>p.concat(...g),[]);return[f,m]}return[[],[]]},[e]);return I.useEffect(()=>{const h=(t==null?void 0:t.target)??tb,f=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const m=b=>{var S,_;if(a.current=b.ctrlKey||b.metaKey||b.shiftKey||b.altKey,(!a.current||a.current&&!f)&&M_(b))return!1;const E=rb(b.code,c);if(o.current.add(b[E]),nb(s,o.current,!1)){const N=((_=(S=b.composedPath)==null?void 0:S.call(b))==null?void 0:_[0])||b.target,k=(N==null?void 0:N.nodeName)==="BUTTON"||(N==null?void 0:N.nodeName)==="A";t.preventDefault!==!1&&(a.current||!k)&&b.preventDefault(),l(!0)}},p=b=>{const w=rb(b.code,c);nb(s,o.current,!0)?(l(!1),o.current.clear()):o.current.delete(b[w]),b.key==="Meta"&&o.current.clear(),a.current=!1},g=()=>{o.current.clear(),l(!1)};return h==null||h.addEventListener("keydown",m),h==null||h.addEventListener("keyup",p),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{h==null||h.removeEventListener("keydown",m),h==null||h.removeEventListener("keyup",p),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,l]),n}function nb(e,t,n){return e.filter(l=>n||l.length===t.size).some(l=>l.every(a=>t.has(a)))}function rb(e,t){return t.includes(e)?"code":"key"}const jz=()=>{const e=gt();return I.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:l}=e.getState();return l?l.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[l,a,o],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??l,y:t.y??a,zoom:t.zoom??o},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,l]=e.getState().transform;return{x:t,y:n,zoom:l}},setCenter:async(t,n,l)=>e.getState().setCenter(t,n,l),fitBounds:async(t,n)=>{const{width:l,height:a,minZoom:o,maxZoom:s,panZoom:c}=e.getState(),h=Mm(t,l,a,o,s,(n==null?void 0:n.padding)??.1);return c?(await c.setViewport(h,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:l,snapGrid:a,snapToGrid:o,domNode:s}=e.getState();if(!s)return t;const{x:c,y:h}=s.getBoundingClientRect(),f={x:t.x-c,y:t.y-h},m=n.snapGrid??a,p=n.snapToGrid??o;return is(f,l,p,m)},flowToScreenPosition:t=>{const{transform:n,domNode:l}=e.getState();if(!l)return t;const{x:a,y:o}=l.getBoundingClientRect(),s=xc(t,n);return{x:s.x+a,y:s.y+o}}}),[])};function W_(e,t){const n=[],l=new Map,a=[];for(const o of e)if(o.type==="add"){a.push(o);continue}else if(o.type==="remove"||o.type==="replace")l.set(o.id,[o]);else{const s=l.get(o.id);s?s.push(o):l.set(o.id,[o])}for(const o of t){const s=l.get(o.id);if(!s){n.push(o);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const c={...o};for(const h of s)Tz(h,c);n.push(c)}return a.length&&a.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function Tz(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function eS(e,t){return W_(e,t)}function tS(e,t){return W_(e,t)}function Xi(e,t){return{id:e,type:"select",selected:t}}function oa(e,t=new Set,n=!1){const l=[];for(const[a,o]of e){const s=t.has(a);!(o.selected===void 0&&!s)&&o.selected!==s&&(n&&(o.selected=s),l.push(Xi(o.id,s)))}return l}function ib({items:e=[],lookup:t}){var a;const n=[],l=new Map(e.map(o=>[o.id,o]));for(const[o,s]of e.entries()){const c=t.get(s.id),h=((a=c==null?void 0:c.internals)==null?void 0:a.userNode)??c;h!==void 0&&h!==s&&n.push({id:s.id,item:s,type:"replace"}),h===void 0&&n.push({item:s,type:"add",index:o})}for(const[o]of t)l.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function lb(e){return{id:e.id,type:"remove"}}const ab=e=>JT(e),Az=e=>k_(e);function nS(e){return I.forwardRef(e)}const zz=typeof window<"u"?I.useLayoutEffect:I.useEffect;function ob(e){const[t,n]=I.useState(BigInt(0)),[l]=I.useState(()=>Mz(()=>n(a=>a+BigInt(1))));return zz(()=>{const a=l.get();a.length&&(e(a),l.reset())},[t]),l}function Mz(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const rS=I.createContext(null);function Dz({children:e}){const t=gt(),n=I.useCallback(c=>{const{nodes:h=[],setNodes:f,hasDefaultNodes:m,onNodesChange:p,nodeLookup:g,fitViewQueued:b,onNodesChangeMiddlewareMap:w}=t.getState();let E=h;for(const _ of c)E=typeof _=="function"?_(E):_;let S=ib({items:E,lookup:g});for(const _ of w.values())S=_(S);m&&f(E),S.length>0?p==null||p(S):b&&window.requestAnimationFrame(()=>{const{fitViewQueued:_,nodes:N,setNodes:k}=t.getState();_&&k(N)})},[]),l=ob(n),a=I.useCallback(c=>{const{edges:h=[],setEdges:f,hasDefaultEdges:m,onEdgesChange:p,edgeLookup:g}=t.getState();let b=h;for(const w of c)b=typeof w=="function"?w(b):w;m?f(b):p&&p(ib({items:b,lookup:g}))},[]),o=ob(a),s=I.useMemo(()=>({nodeQueue:l,edgeQueue:o}),[]);return y.jsx(rS.Provider,{value:s,children:e})}function Rz(){const e=I.useContext(rS);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Oz=e=>!!e.panZoom;function ul(){const e=jz(),t=gt(),n=Rz(),l=Ye(Oz),a=I.useMemo(()=>{const o=p=>t.getState().nodeLookup.get(p),s=p=>{n.nodeQueue.push(p)},c=p=>{n.edgeQueue.push(p)},h=p=>{var _,N;const{nodeLookup:g,nodeOrigin:b}=t.getState(),w=ab(p)?p:g.get(p.id),E=w.parentId?A_(w.position,w.measured,w.parentId,g,b):w.position,S={...w,position:E,width:((_=w.measured)==null?void 0:_.width)??w.width,height:((N=w.measured)==null?void 0:N.height)??w.height};return ya(S)},f=(p,g,b={replace:!1})=>{s(w=>w.map(E=>{if(E.id===p){const S=typeof g=="function"?g(E):g;return b.replace&&ab(S)?S:{...E,...S}}return E}))},m=(p,g,b={replace:!1})=>{c(w=>w.map(E=>{if(E.id===p){const S=typeof g=="function"?g(E):g;return b.replace&&Az(S)?S:{...E,...S}}return E}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>{var g;return(g=o(p))==null?void 0:g.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(g=>({...g}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:s,setEdges:c,addNodes:p=>{const g=Array.isArray(p)?p:[p];n.nodeQueue.push(b=>[...b,...g])},addEdges:p=>{const g=Array.isArray(p)?p:[p];n.edgeQueue.push(b=>[...b,...g])},toObject:()=>{const{nodes:p=[],edges:g=[],transform:b}=t.getState(),[w,E,S]=b;return{nodes:p.map(_=>({..._})),edges:g.map(_=>({..._})),viewport:{x:w,y:E,zoom:S}}},deleteElements:async({nodes:p=[],edges:g=[]})=>{const{nodes:b,edges:w,onNodesDelete:E,onEdgesDelete:S,triggerNodeChanges:_,triggerEdgeChanges:N,onDelete:k,onBeforeDelete:T}=t.getState(),{nodes:M,edges:A}=await rA({nodesToRemove:p,edgesToRemove:g,nodes:b,edges:w,onBeforeDelete:T}),L=A.length>0,R=M.length>0;if(L){const V=A.map(lb);S==null||S(A),N(V)}if(R){const V=M.map(lb);E==null||E(M),_(V)}return(R||L)&&(k==null||k({nodes:M,edges:A})),{deletedNodes:M,deletedEdges:A}},getIntersectingNodes:(p,g=!0,b)=>{const w=Mv(p),E=w?p:h(p),S=b!==void 0;return E?(b||t.getState().nodes).filter(_=>{const N=t.getState().nodeLookup.get(_.id);if(N&&!w&&(_.id===p.id||!N.internals.positionAbsolute))return!1;const k=ya(S?_:N),T=Fo(k,E);return g&&T>0||T>=k.width*k.height||T>=E.width*E.height}):[]},isNodeIntersecting:(p,g,b=!0)=>{const E=Mv(p)?p:h(p);if(!E)return!1;const S=Fo(E,g);return b&&S>0||S>=g.width*g.height||S>=E.width*E.height},updateNode:f,updateNodeData:(p,g,b={replace:!1})=>{f(p,w=>{const E=typeof g=="function"?g(w):g;return b.replace?{...w,data:E}:{...w,data:{...w.data,...E}}},b)},updateEdge:m,updateEdgeData:(p,g,b={replace:!1})=>{m(p,w=>{const E=typeof g=="function"?g(w):g;return b.replace?{...w,data:E}:{...w,data:{...w.data,...E}}},b)},getNodesBounds:p=>{const{nodeLookup:g,nodeOrigin:b}=t.getState();return WT(p,{nodeLookup:g,nodeOrigin:b})},getHandleConnections:({type:p,id:g,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}-${p}${g?`-${g}`:""}`))==null?void 0:w.values())??[])},getNodeConnections:({type:p,handleId:g,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}${p?g?`-${p}-${g}`:`-${p}`:""}`))==null?void 0:w.values())??[])},fitView:async p=>{const g=t.getState().fitViewResolver??oA();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:g}),n.nodeQueue.push(b=>[...b]),g.promise}}},[]);return I.useMemo(()=>({...a,...e,viewportInitialized:l}),[l])}const sb=e=>e.selected,Lz=typeof window<"u"?window:void 0;function Hz({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=gt(),{deleteElements:l}=ul(),a=Xo(e,{actInsideInputWithModifier:!1}),o=Xo(t,{target:Lz});I.useEffect(()=>{if(a){const{edges:s,nodes:c}=n.getState();l({nodes:c.filter(sb),edges:s.filter(sb)}),n.setState({nodesSelectionActive:!1})}},[a]),I.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function Bz(e){const t=gt();I.useEffect(()=>{const n=()=>{var a,o,s,c;if(!e.current||!(((o=(a=e.current).checkVisibility)==null?void 0:o.call(a))??!0))return!1;const l=Dm(e.current);(l.height===0||l.width===0)&&((c=(s=t.getState()).onError)==null||c.call(s,"004",ar.error004())),t.setState({width:l.width||500,height:l.height||500})};if(e.current){n(),window.addEventListener("resize",n);const l=new ResizeObserver(()=>n());return l.observe(e.current),()=>{window.removeEventListener("resize",n),l&&e.current&&l.unobserve(e.current)}}},[])}const qc={position:"absolute",width:"100%",height:"100%",top:0,left:0},Iz=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function qz({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:l=!1,panOnScrollSpeed:a=.5,panOnScrollMode:o=el.Free,zoomOnDoubleClick:s=!0,panOnDrag:c=!0,defaultViewport:h,translateExtent:f,minZoom:m,maxZoom:p,zoomActivationKeyCode:g,preventScrolling:b=!0,children:w,noWheelClassName:E,noPanClassName:S,onViewportChange:_,isControlledViewport:N,paneClickDistance:k,selectionOnDrag:T}){const M=gt(),A=I.useRef(null),{userSelectionActive:L,lib:R,connectionInProgress:V}=Ye(Iz,mt),H=Xo(g),B=I.useRef();Bz(A);const U=I.useCallback(ee=>{_==null||_({x:ee[0],y:ee[1],zoom:ee[2]}),N||M.setState({transform:ee})},[_,N]);return I.useEffect(()=>{if(A.current){B.current=PA({domNode:A.current,minZoom:m,maxZoom:p,translateExtent:f,viewport:h,onDraggingChange:z=>M.setState(G=>G.paneDragging===z?G:{paneDragging:z}),onPanZoomStart:(z,G)=>{const{onViewportChangeStart:Q,onMoveStart:K}=M.getState();K==null||K(z,G),Q==null||Q(G)},onPanZoom:(z,G)=>{const{onViewportChange:Q,onMove:K}=M.getState();K==null||K(z,G),Q==null||Q(G)},onPanZoomEnd:(z,G)=>{const{onViewportChangeEnd:Q,onMoveEnd:K}=M.getState();K==null||K(z,G),Q==null||Q(G)}});const{x:ee,y:q,zoom:F}=B.current.getViewport();return M.setState({panZoom:B.current,transform:[ee,q,F],domNode:A.current.closest(".react-flow")}),()=>{var z;(z=B.current)==null||z.destroy()}}},[]),I.useEffect(()=>{var ee;(ee=B.current)==null||ee.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:l,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:s,panOnDrag:c,zoomActivationKeyPressed:H,preventScrolling:b,noPanClassName:S,userSelectionActive:L,noWheelClassName:E,lib:R,onTransformChange:U,connectionInProgress:V,selectionOnDrag:T,paneClickDistance:k})},[e,t,n,l,a,o,s,c,H,b,S,L,E,R,U,V,T,k]),y.jsx("div",{className:"react-flow__renderer",ref:A,style:qc,children:w})}const $z=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Uz(){const{userSelectionActive:e,userSelectionRect:t}=Ye($z,mt);return e&&t?y.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Th=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Vz=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Pz({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Go.Full,panOnDrag:l,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:h,onPaneContextMenu:f,onPaneScroll:m,onPaneMouseEnter:p,onPaneMouseMove:g,onPaneMouseLeave:b,children:w}){const E=gt(),{userSelectionActive:S,elementsSelectable:_,dragging:N,connectionInProgress:k}=Ye(Vz,mt),T=_&&(e||S),M=I.useRef(null),A=I.useRef(),L=I.useRef(new Set),R=I.useRef(new Set),V=I.useRef(!1),H=Q=>{if(V.current||k){V.current=!1;return}h==null||h(Q),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},B=Q=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){Q.preventDefault();return}f==null||f(Q)},U=m?Q=>m(Q):void 0,ee=Q=>{V.current&&(Q.stopPropagation(),V.current=!1)},q=Q=>{var X,J;const{domNode:K}=E.getState();if(A.current=K==null?void 0:K.getBoundingClientRect(),!A.current)return;const D=Q.target===M.current;if(!D&&!!Q.target.closest(".nokey")||!e||!(o&&D||t)||Q.button!==0||!Q.isPrimary)return;(J=(X=Q.target)==null?void 0:X.setPointerCapture)==null||J.call(X,Q.pointerId),V.current=!1;const{x:C,y:P}=Pn(Q.nativeEvent,A.current);E.setState({userSelectionRect:{width:0,height:0,startX:C,startY:P,x:C,y:P}}),D||(Q.stopPropagation(),Q.preventDefault())},F=Q=>{const{userSelectionRect:K,transform:D,nodeLookup:$,edgeLookup:Y,connectionLookup:C,triggerNodeChanges:P,triggerEdgeChanges:X,defaultEdgeOptions:J,resetSelectedElements:ne}=E.getState();if(!A.current||!K)return;const{x:re,y:ue}=Pn(Q.nativeEvent,A.current),{startX:xe,startY:be}=K;if(!V.current){const Te=t?0:a;if(Math.hypot(re-xe,ue-be)<=Te)return;ne(),s==null||s(Q)}V.current=!0;const ye={startX:xe,startY:be,x:reTe.id)),R.current=new Set;const Oe=(J==null?void 0:J.selectable)??!0;for(const Te of L.current){const ft=C.get(Te);if(ft)for(const{edgeId:rt}of ft.values()){const Dt=Y.get(rt);Dt&&(Dt.selectable??Oe)&&R.current.add(rt)}}if(!Dv(pe,L.current)){const Te=oa($,L.current,!0);P(Te)}if(!Dv(Se,R.current)){const Te=oa(Y,R.current);X(Te)}E.setState({userSelectionRect:ye,userSelectionActive:!0,nodesSelectionActive:!1})},z=Q=>{var K,D;Q.button===0&&((D=(K=Q.target)==null?void 0:K.releasePointerCapture)==null||D.call(K,Q.pointerId),!S&&Q.target===M.current&&E.getState().userSelectionRect&&(H==null||H(Q)),E.setState({userSelectionActive:!1,userSelectionRect:null}),V.current&&(c==null||c(Q),E.setState({nodesSelectionActive:L.current.size>0})))},G=l===!0||Array.isArray(l)&&l.includes(0);return y.jsxs("div",{className:Mt(["react-flow__pane",{draggable:G,dragging:N,selection:e}]),onClick:T?void 0:Th(H,M),onContextMenu:Th(B,M),onWheel:Th(U,M),onPointerEnter:T?void 0:p,onPointerMove:T?F:g,onPointerUp:T?z:void 0,onPointerDownCapture:T?q:void 0,onClickCapture:T?ee:void 0,onPointerLeave:b,ref:M,style:qc,children:[w,y.jsx(Uz,{})]})}function lm({id:e,store:t,unselect:n=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:o,multiSelectionActive:s,nodeLookup:c,onError:h}=t.getState(),f=c.get(e);if(!f){h==null||h("012",ar.error012(e));return}t.setState({nodesSelectionActive:!1}),f.selected?(n||f.selected&&s)&&(o({nodes:[f],edges:[]}),requestAnimationFrame(()=>{var m;return(m=l==null?void 0:l.current)==null?void 0:m.blur()})):a([e])}function iS({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:l,nodeId:a,isSelectable:o,nodeClickDistance:s}){const c=gt(),[h,f]=I.useState(!1),m=I.useRef();return I.useEffect(()=>{m.current=AA({getStoreItems:()=>c.getState(),onNodeMouseDown:p=>{lm({id:p,store:c,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),I.useEffect(()=>{if(!(t||!e.current||!m.current))return m.current.update({noDragClassName:n,handleSelector:l,domNode:e.current,isSelectable:o,nodeId:a,nodeClickDistance:s}),()=>{var p;(p=m.current)==null||p.destroy()}},[n,l,t,o,e,a,s]),h}const Gz=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function lS(){const e=gt();return I.useCallback(n=>{const{nodeExtent:l,snapToGrid:a,snapGrid:o,nodesDraggable:s,onError:c,updateNodePositions:h,nodeLookup:f,nodeOrigin:m}=e.getState(),p=new Map,g=Gz(s),b=a?o[0]:5,w=a?o[1]:5,E=n.direction.x*b*n.factor,S=n.direction.y*w*n.factor;for(const[,_]of f){if(!g(_))continue;let N={x:_.internals.positionAbsolute.x+E,y:_.internals.positionAbsolute.y+S};a&&(N=rs(N,o));const{position:k,positionAbsolute:T}=E_({nodeId:_.id,nextPosition:N,nodeLookup:f,nodeExtent:l,nodeOrigin:m,onError:c});_.position=k,_.internals.positionAbsolute=T,p.set(_.id,_)}h(p)},[])}const qm=I.createContext(null),Fz=qm.Provider;qm.Consumer;const aS=()=>I.useContext(qm),Yz=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Xz=(e,t,n)=>l=>{const{connectionClickStartHandle:a,connectionMode:o,connection:s}=l,{fromHandle:c,toHandle:h,isValid:f}=s,m=(h==null?void 0:h.nodeId)===e&&(h==null?void 0:h.id)===t&&(h==null?void 0:h.type)===n;return{connectingFrom:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n,connectingTo:m,clickConnecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,isPossibleEndHandle:o===ga.Strict?(c==null?void 0:c.type)!==n:e!==(c==null?void 0:c.nodeId)||t!==(c==null?void 0:c.id),connectionInProcess:!!c,clickConnectionInProcess:!!a,valid:m&&f}};function Qz({type:e="source",position:t=ve.Top,isValidConnection:n,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:o=!0,id:s,onConnect:c,children:h,className:f,onMouseDown:m,onTouchStart:p,...g},b){var F,z;const w=s||null,E=e==="target",S=gt(),_=aS(),{connectOnClick:N,noPanClassName:k,rfId:T}=Ye(Yz,mt),{connectingFrom:M,connectingTo:A,clickConnecting:L,isPossibleEndHandle:R,connectionInProcess:V,clickConnectionInProcess:H,valid:B}=Ye(Xz(_,w,e),mt);_||(z=(F=S.getState()).onError)==null||z.call(F,"010",ar.error010());const U=G=>{const{defaultEdgeOptions:Q,onConnect:K,hasDefaultEdges:D}=S.getState(),$={...Q,...G};if(D){const{edges:Y,setEdges:C}=S.getState();C(pA($,Y))}K==null||K($),c==null||c($)},ee=G=>{if(!_)return;const Q=D_(G.nativeEvent);if(a&&(Q&&G.button===0||!Q)){const K=S.getState();im.onPointerDown(G.nativeEvent,{handleDomNode:G.currentTarget,autoPanOnConnect:K.autoPanOnConnect,connectionMode:K.connectionMode,connectionRadius:K.connectionRadius,domNode:K.domNode,nodeLookup:K.nodeLookup,lib:K.lib,isTarget:E,handleId:w,nodeId:_,flowId:K.rfId,panBy:K.panBy,cancelConnection:K.cancelConnection,onConnectStart:K.onConnectStart,onConnectEnd:(...D)=>{var $,Y;return(Y=($=S.getState()).onConnectEnd)==null?void 0:Y.call($,...D)},updateConnection:K.updateConnection,onConnect:U,isValidConnection:n||((...D)=>{var $,Y;return((Y=($=S.getState()).isValidConnection)==null?void 0:Y.call($,...D))??!0}),getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,autoPanSpeed:K.autoPanSpeed,dragThreshold:K.connectionDragThreshold})}Q?m==null||m(G):p==null||p(G)},q=G=>{const{onClickConnectStart:Q,onClickConnectEnd:K,connectionClickStartHandle:D,connectionMode:$,isValidConnection:Y,lib:C,rfId:P,nodeLookup:X,connection:J}=S.getState();if(!_||!D&&!a)return;if(!D){Q==null||Q(G.nativeEvent,{nodeId:_,handleId:w,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:_,type:e,id:w}});return}const ne=z_(G.target),re=n||Y,{connection:ue,isValid:xe}=im.isValid(G.nativeEvent,{handle:{nodeId:_,id:w,type:e},connectionMode:$,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:re,flowId:P,doc:ne,lib:C,nodeLookup:X});xe&&ue&&U(ue);const be=structuredClone(J);delete be.inProgress,be.toPosition=be.toHandle?be.toHandle.position:null,K==null||K(G,be),S.setState({connectionClickStartHandle:null})};return y.jsx("div",{"data-handleid":w,"data-nodeid":_,"data-handlepos":t,"data-id":`${T}-${_}-${w}-${e}`,className:Mt(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",k,f,{source:!E,target:E,connectable:l,connectablestart:a,connectableend:o,clickconnecting:L,connectingfrom:M,connectingto:A,valid:B,connectionindicator:l&&(!V||R)&&(V||H?o:a)}]),onMouseDown:ee,onTouchStart:ee,onClick:N?q:void 0,ref:b,...g,children:h})}const xt=I.memo(nS(Qz));function Zz({data:e,isConnectable:t,sourcePosition:n=ve.Bottom}){return y.jsxs(y.Fragment,{children:[e==null?void 0:e.label,y.jsx(xt,{type:"source",position:n,isConnectable:t})]})}function Kz({data:e,isConnectable:t,targetPosition:n=ve.Top,sourcePosition:l=ve.Bottom}){return y.jsxs(y.Fragment,{children:[y.jsx(xt,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,y.jsx(xt,{type:"source",position:l,isConnectable:t})]})}function Jz(){return null}function Wz({data:e,isConnectable:t,targetPosition:n=ve.Top}){return y.jsxs(y.Fragment,{children:[y.jsx(xt,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const yc={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ub={input:Zz,default:Kz,output:Wz,group:Jz};function eM(e){var t,n,l,a;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((l=e.style)==null?void 0:l.width),height:e.height??((a=e.style)==null?void 0:a.height)}}const tM=e=>{const{width:t,height:n,x:l,y:a}=ns(e.nodeLookup,{filter:o=>!!o.selected});return{width:Vn(t)?t:null,height:Vn(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${l}px,${a}px)`}};function nM({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const l=gt(),{width:a,height:o,transformString:s,userSelectionActive:c}=Ye(tM,mt),h=lS(),f=I.useRef(null);I.useEffect(()=>{var b;n||(b=f.current)==null||b.focus({preventScroll:!0})},[n]);const m=!c&&a!==null&&o!==null;if(iS({nodeRef:f,disabled:!m}),!m)return null;const p=e?b=>{const w=l.getState().nodes.filter(E=>E.selected);e(b,w)}:void 0,g=b=>{Object.prototype.hasOwnProperty.call(yc,b.key)&&(b.preventDefault(),h({direction:yc[b.key],factor:b.shiftKey?4:1}))};return y.jsx("div",{className:Mt(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:y.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:g,style:{width:a,height:o}})})}const cb=typeof window<"u"?window:void 0,rM=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function oS({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:s,paneClickDistance:c,deleteKeyCode:h,selectionKeyCode:f,selectionOnDrag:m,selectionMode:p,onSelectionStart:g,onSelectionEnd:b,multiSelectionKeyCode:w,panActivationKeyCode:E,zoomActivationKeyCode:S,elementsSelectable:_,zoomOnScroll:N,zoomOnPinch:k,panOnScroll:T,panOnScrollSpeed:M,panOnScrollMode:A,zoomOnDoubleClick:L,panOnDrag:R,defaultViewport:V,translateExtent:H,minZoom:B,maxZoom:U,preventScrolling:ee,onSelectionContextMenu:q,noWheelClassName:F,noPanClassName:z,disableKeyboardA11y:G,onViewportChange:Q,isControlledViewport:K}){const{nodesSelectionActive:D,userSelectionActive:$}=Ye(rM,mt),Y=Xo(f,{target:cb}),C=Xo(E,{target:cb}),P=C||R,X=C||T,J=m&&P!==!0,ne=Y||$||J;return Hz({deleteKeyCode:h,multiSelectionKeyCode:w}),y.jsx(qz,{onPaneContextMenu:o,elementsSelectable:_,zoomOnScroll:N,zoomOnPinch:k,panOnScroll:X,panOnScrollSpeed:M,panOnScrollMode:A,zoomOnDoubleClick:L,panOnDrag:!Y&&P,defaultViewport:V,translateExtent:H,minZoom:B,maxZoom:U,zoomActivationKeyCode:S,preventScrolling:ee,noWheelClassName:F,noPanClassName:z,onViewportChange:Q,isControlledViewport:K,paneClickDistance:c,selectionOnDrag:J,children:y.jsxs(Pz,{onSelectionStart:g,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:s,panOnDrag:P,isSelecting:!!ne,selectionMode:p,selectionKeyPressed:Y,paneClickDistance:c,selectionOnDrag:J,children:[e,D&&y.jsx(nM,{onSelectionContextMenu:q,noPanClassName:z,disableKeyboardA11y:G})]})})}oS.displayName="FlowRenderer";const iM=I.memo(oS),lM=e=>t=>e?zm(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function aM(e){return Ye(I.useCallback(lM(e),[e]),mt)}const oM=e=>e.updateNodeInternals;function sM(){const e=Ye(oM),[t]=I.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const l=new Map;n.forEach(a=>{const o=a.target.getAttribute("data-id");l.set(o,{id:o,nodeElement:a.target,force:!0})}),e(l)}));return I.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function uM({node:e,nodeType:t,hasDimensions:n,resizeObserver:l}){const a=gt(),o=I.useRef(null),s=I.useRef(null),c=I.useRef(e.sourcePosition),h=I.useRef(e.targetPosition),f=I.useRef(t),m=n&&!!e.internals.handleBounds;return I.useEffect(()=>{o.current&&!e.hidden&&(!m||s.current!==o.current)&&(s.current&&(l==null||l.unobserve(s.current)),l==null||l.observe(o.current),s.current=o.current)},[m,e.hidden]),I.useEffect(()=>()=>{s.current&&(l==null||l.unobserve(s.current),s.current=null)},[]),I.useEffect(()=>{if(o.current){const p=f.current!==t,g=c.current!==e.sourcePosition,b=h.current!==e.targetPosition;(p||g||b)&&(f.current=t,c.current=e.sourcePosition,h.current=e.targetPosition,a.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function cM({id:e,onClick:t,onMouseEnter:n,onMouseMove:l,onMouseLeave:a,onContextMenu:o,onDoubleClick:s,nodesDraggable:c,elementsSelectable:h,nodesConnectable:f,nodesFocusable:m,resizeObserver:p,noDragClassName:g,noPanClassName:b,disableKeyboardA11y:w,rfId:E,nodeTypes:S,nodeClickDistance:_,onError:N}){const{node:k,internals:T,isParent:M}=Ye(re=>{const ue=re.nodeLookup.get(e),xe=re.parentLookup.has(e);return{node:ue,internals:ue.internals,isParent:xe}},mt);let A=k.type||"default",L=(S==null?void 0:S[A])||ub[A];L===void 0&&(N==null||N("003",ar.error003(A)),A="default",L=(S==null?void 0:S.default)||ub.default);const R=!!(k.draggable||c&&typeof k.draggable>"u"),V=!!(k.selectable||h&&typeof k.selectable>"u"),H=!!(k.connectable||f&&typeof k.connectable>"u"),B=!!(k.focusable||m&&typeof k.focusable>"u"),U=gt(),ee=T_(k),q=uM({node:k,nodeType:A,hasDimensions:ee,resizeObserver:p}),F=iS({nodeRef:q,disabled:k.hidden||!R,noDragClassName:g,handleSelector:k.dragHandle,nodeId:e,isSelectable:V,nodeClickDistance:_}),z=lS();if(k.hidden)return null;const G=Hr(k),Q=eM(k),K=V||R||t||n||l||a,D=n?re=>n(re,{...T.userNode}):void 0,$=l?re=>l(re,{...T.userNode}):void 0,Y=a?re=>a(re,{...T.userNode}):void 0,C=o?re=>o(re,{...T.userNode}):void 0,P=s?re=>s(re,{...T.userNode}):void 0,X=re=>{const{selectNodesOnDrag:ue,nodeDragThreshold:xe}=U.getState();V&&(!ue||!R||xe>0)&&lm({id:e,store:U,nodeRef:q}),t&&t(re,{...T.userNode})},J=re=>{if(!(M_(re.nativeEvent)||w)){if(b_.includes(re.key)&&V){const ue=re.key==="Escape";lm({id:e,store:U,unselect:ue,nodeRef:q})}else if(R&&k.selected&&Object.prototype.hasOwnProperty.call(yc,re.key)){re.preventDefault();const{ariaLabelConfig:ue}=U.getState();U.setState({ariaLiveMessage:ue["node.a11yDescription.ariaLiveMessage"]({direction:re.key.replace("Arrow","").toLowerCase(),x:~~T.positionAbsolute.x,y:~~T.positionAbsolute.y})}),z({direction:yc[re.key],factor:re.shiftKey?4:1})}}},ne=()=>{var Se;if(w||!((Se=q.current)!=null&&Se.matches(":focus-visible")))return;const{transform:re,width:ue,height:xe,autoPanOnNodeFocus:be,setCenter:ye}=U.getState();if(!be)return;zm(new Map([[e,k]]),{x:0,y:0,width:ue,height:xe},re,!0).length>0||ye(k.position.x+G.width/2,k.position.y+G.height/2,{zoom:re[2]})};return y.jsx("div",{className:Mt(["react-flow__node",`react-flow__node-${A}`,{[b]:R},k.className,{selected:k.selected,selectable:V,parent:M,draggable:R,dragging:F}]),ref:q,style:{zIndex:T.z,transform:`translate(${T.positionAbsolute.x}px,${T.positionAbsolute.y}px)`,pointerEvents:K?"all":"none",visibility:ee?"visible":"hidden",...k.style,...Q},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:D,onMouseMove:$,onMouseLeave:Y,onContextMenu:C,onClick:X,onDoubleClick:P,onKeyDown:B?J:void 0,tabIndex:B?0:void 0,onFocus:B?ne:void 0,role:k.ariaRole??(B?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${Z_}-${E}`,"aria-label":k.ariaLabel,...k.domAttributes,children:y.jsx(Fz,{value:e,children:y.jsx(L,{id:e,data:k.data,type:A,positionAbsoluteX:T.positionAbsolute.x,positionAbsoluteY:T.positionAbsolute.y,selected:k.selected??!1,selectable:V,draggable:R,deletable:k.deletable??!0,isConnectable:H,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:F,dragHandle:k.dragHandle,zIndex:T.z,parentId:k.parentId,...G})})})}var fM=I.memo(cM);const dM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function sS(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:l,elementsSelectable:a,onError:o}=Ye(dM,mt),s=aM(e.onlyRenderVisibleElements),c=sM();return y.jsx("div",{className:"react-flow__nodes",style:qc,children:s.map(h=>y.jsx(fM,{id:h,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t,nodesConnectable:n,nodesFocusable:l,elementsSelectable:a,nodeClickDistance:e.nodeClickDistance,onError:o},h))})}sS.displayName="NodeRenderer";const hM=I.memo(sS);function pM(e){return Ye(I.useCallback(n=>{if(!e)return n.edges.map(a=>a.id);const l=[];if(n.width&&n.height)for(const a of n.edges){const o=n.nodeLookup.get(a.source),s=n.nodeLookup.get(a.target);o&&s&&fA({sourceNode:o,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&l.push(a.id)}return l},[e]),mt)}const mM=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return y.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},gM=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return y.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},fb={[mc.Arrow]:mM,[mc.ArrowClosed]:gM};function xM(e){const t=gt();return I.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(fb,e)?fb[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",ar.error009(e)),null)},[e])}const yM=({id:e,type:t,color:n,width:l=12.5,height:a=12.5,markerUnits:o="strokeWidth",strokeWidth:s,orient:c="auto-start-reverse"})=>{const h=xM(t);return h?y.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${l}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:c,refX:"0",refY:"0",children:y.jsx(h,{color:n,strokeWidth:s})}):null},uS=({defaultColor:e,rfId:t})=>{const n=Ye(o=>o.edges),l=Ye(o=>o.defaultEdgeOptions),a=I.useMemo(()=>vA(n,{id:t,defaultColor:e,defaultMarkerStart:l==null?void 0:l.markerStart,defaultMarkerEnd:l==null?void 0:l.markerEnd}),[n,l,t,e]);return a.length?y.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:y.jsx("defs",{children:a.map(o=>y.jsx(yM,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};uS.displayName="MarkerDefinitions";var vM=I.memo(uS);function cS({x:e,y:t,label:n,labelStyle:l,labelShowBg:a=!0,labelBgStyle:o,labelBgPadding:s=[2,4],labelBgBorderRadius:c=2,children:h,className:f,...m}){const[p,g]=I.useState({x:1,y:0,width:0,height:0}),b=Mt(["react-flow__edge-textwrapper",f]),w=I.useRef(null);return I.useEffect(()=>{if(w.current){const E=w.current.getBBox();g({x:E.x,y:E.y,width:E.width,height:E.height})}},[n]),n?y.jsxs("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:b,visibility:p.width?"visible":"hidden",...m,children:[a&&y.jsx("rect",{width:p.width+2*s[0],x:-s[0],y:-s[1],height:p.height+2*s[1],className:"react-flow__edge-textbg",style:o,rx:c,ry:c}),y.jsx("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:w,style:l,children:n}),h]}):null}cS.displayName="EdgeText";const bM=I.memo(cS);function ls({path:e,labelX:t,labelY:n,label:l,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:h,interactionWidth:f=20,...m}){return y.jsxs(y.Fragment,{children:[y.jsx("path",{...m,d:e,fill:"none",className:Mt(["react-flow__edge-path",m.className])}),f?y.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,l&&Vn(t)&&Vn(n)?y.jsx(bM,{x:t,y:n,label:l,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:h}):null]})}function db({pos:e,x1:t,y1:n,x2:l,y2:a}){return e===ve.Left||e===ve.Right?[.5*(t+l),n]:[t,.5*(n+a)]}function fS({sourceX:e,sourceY:t,sourcePosition:n=ve.Bottom,targetX:l,targetY:a,targetPosition:o=ve.Top}){const[s,c]=db({pos:n,x1:e,y1:t,x2:l,y2:a}),[h,f]=db({pos:o,x1:l,y1:a,x2:e,y2:t}),[m,p,g,b]=R_({sourceX:e,sourceY:t,targetX:l,targetY:a,sourceControlX:s,sourceControlY:c,targetControlX:h,targetControlY:f});return[`M${e},${t} C${s},${c} ${h},${f} ${l},${a}`,m,p,g,b]}function dS(e){return I.memo(({id:t,sourceX:n,sourceY:l,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,label:h,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,interactionWidth:_})=>{const[N,k,T]=fS({sourceX:n,sourceY:l,sourcePosition:s,targetX:a,targetY:o,targetPosition:c}),M=e.isInternal?void 0:t;return y.jsx(ls,{id:M,path:N,labelX:k,labelY:T,label:h,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,interactionWidth:_})})}const wM=dS({isInternal:!1}),hS=dS({isInternal:!0});wM.displayName="SimpleBezierEdge";hS.displayName="SimpleBezierEdgeInternal";function pS(e){return I.memo(({id:t,sourceX:n,sourceY:l,targetX:a,targetY:o,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:g,sourcePosition:b=ve.Bottom,targetPosition:w=ve.Top,markerEnd:E,markerStart:S,pathOptions:_,interactionWidth:N})=>{const[k,T,M]=tm({sourceX:n,sourceY:l,sourcePosition:b,targetX:a,targetY:o,targetPosition:w,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset,stepPosition:_==null?void 0:_.stepPosition}),A=e.isInternal?void 0:t;return y.jsx(ls,{id:A,path:k,labelX:T,labelY:M,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:g,markerEnd:E,markerStart:S,interactionWidth:N})})}const mS=pS({isInternal:!1}),gS=pS({isInternal:!0});mS.displayName="SmoothStepEdge";gS.displayName="SmoothStepEdgeInternal";function xS(e){return I.memo(({id:t,...n})=>{var a;const l=e.isInternal?void 0:t;return y.jsx(mS,{...n,id:l,pathOptions:I.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(a=n.pathOptions)==null?void 0:a.offset])})})}const _M=xS({isInternal:!1}),yS=xS({isInternal:!0});_M.displayName="StepEdge";yS.displayName="StepEdgeInternal";function vS(e){return I.memo(({id:t,sourceX:n,sourceY:l,targetX:a,targetY:o,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:g,markerEnd:b,markerStart:w,interactionWidth:E})=>{const[S,_,N]=L_({sourceX:n,sourceY:l,targetX:a,targetY:o}),k=e.isInternal?void 0:t;return y.jsx(ls,{id:k,path:S,labelX:_,labelY:N,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:g,markerEnd:b,markerStart:w,interactionWidth:E})})}const SM=vS({isInternal:!1}),bS=vS({isInternal:!0});SM.displayName="StraightEdge";bS.displayName="StraightEdgeInternal";function wS(e){return I.memo(({id:t,sourceX:n,sourceY:l,targetX:a,targetY:o,sourcePosition:s=ve.Bottom,targetPosition:c=ve.Top,label:h,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,pathOptions:_,interactionWidth:N})=>{const[k,T,M]=Rm({sourceX:n,sourceY:l,sourcePosition:s,targetX:a,targetY:o,targetPosition:c,curvature:_==null?void 0:_.curvature}),A=e.isInternal?void 0:t;return y.jsx(ls,{id:A,path:k,labelX:T,labelY:M,label:h,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,interactionWidth:N})})}const kM=wS({isInternal:!1}),_S=wS({isInternal:!0});kM.displayName="BezierEdge";_S.displayName="BezierEdgeInternal";const hb={default:_S,straight:bS,step:yS,smoothstep:gS,simplebezier:hS},pb={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},EM=(e,t,n)=>n===ve.Left?e-t:n===ve.Right?e+t:e,NM=(e,t,n)=>n===ve.Top?e-t:n===ve.Bottom?e+t:e,mb="react-flow__edgeupdater";function gb({position:e,centerX:t,centerY:n,radius:l=10,onMouseDown:a,onMouseEnter:o,onMouseOut:s,type:c}){return y.jsx("circle",{onMouseDown:a,onMouseEnter:o,onMouseOut:s,className:Mt([mb,`${mb}-${c}`]),cx:EM(t,l,e),cy:NM(n,l,e),r:l,stroke:"transparent",fill:"transparent"})}function CM({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:l,sourceY:a,targetX:o,targetY:s,sourcePosition:c,targetPosition:h,onReconnect:f,onReconnectStart:m,onReconnectEnd:p,setReconnecting:g,setUpdateHover:b}){const w=gt(),E=(T,M)=>{if(T.button!==0)return;const{autoPanOnConnect:A,domNode:L,connectionMode:R,connectionRadius:V,lib:H,onConnectStart:B,cancelConnection:U,nodeLookup:ee,rfId:q,panBy:F,updateConnection:z}=w.getState(),G=M.type==="target",Q=($,Y)=>{g(!1),p==null||p($,n,M.type,Y)},K=$=>f==null?void 0:f(n,$),D=($,Y)=>{g(!0),m==null||m(T,n,M.type),B==null||B($,Y)};im.onPointerDown(T.nativeEvent,{autoPanOnConnect:A,connectionMode:R,connectionRadius:V,domNode:L,handleId:M.id,nodeId:M.nodeId,nodeLookup:ee,isTarget:G,edgeUpdaterType:M.type,lib:H,flowId:q,cancelConnection:U,panBy:F,isValidConnection:(...$)=>{var Y,C;return((C=(Y=w.getState()).isValidConnection)==null?void 0:C.call(Y,...$))??!0},onConnect:K,onConnectStart:D,onConnectEnd:(...$)=>{var Y,C;return(C=(Y=w.getState()).onConnectEnd)==null?void 0:C.call(Y,...$)},onReconnectEnd:Q,updateConnection:z,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:T.currentTarget})},S=T=>E(T,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),_=T=>E(T,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),N=()=>b(!0),k=()=>b(!1);return y.jsxs(y.Fragment,{children:[(e===!0||e==="source")&&y.jsx(gb,{position:c,centerX:l,centerY:a,radius:t,onMouseDown:S,onMouseEnter:N,onMouseOut:k,type:"source"}),(e===!0||e==="target")&&y.jsx(gb,{position:h,centerX:o,centerY:s,radius:t,onMouseDown:_,onMouseEnter:N,onMouseOut:k,type:"target"})]})}function jM({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:l,onClick:a,onDoubleClick:o,onContextMenu:s,onMouseEnter:c,onMouseMove:h,onMouseLeave:f,reconnectRadius:m,onReconnect:p,onReconnectStart:g,onReconnectEnd:b,rfId:w,edgeTypes:E,noPanClassName:S,onError:_,disableKeyboardA11y:N}){let k=Ye(ye=>ye.edgeLookup.get(e));const T=Ye(ye=>ye.defaultEdgeOptions);k=T?{...T,...k}:k;let M=k.type||"default",A=(E==null?void 0:E[M])||hb[M];A===void 0&&(_==null||_("011",ar.error011(M)),M="default",A=(E==null?void 0:E.default)||hb.default);const L=!!(k.focusable||t&&typeof k.focusable>"u"),R=typeof p<"u"&&(k.reconnectable||n&&typeof k.reconnectable>"u"),V=!!(k.selectable||l&&typeof k.selectable>"u"),H=I.useRef(null),[B,U]=I.useState(!1),[ee,q]=I.useState(!1),F=gt(),{zIndex:z,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:$,targetPosition:Y}=Ye(I.useCallback(ye=>{const pe=ye.nodeLookup.get(k.source),Se=ye.nodeLookup.get(k.target);if(!pe||!Se)return{zIndex:k.zIndex,...pb};const Oe=yA({id:e,sourceNode:pe,targetNode:Se,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:ye.connectionMode,onError:_});return{zIndex:cA({selected:k.selected,zIndex:k.zIndex,sourceNode:pe,targetNode:Se,elevateOnSelect:ye.elevateEdgesOnSelect,zIndexMode:ye.zIndexMode}),...Oe||pb}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex]),mt),C=I.useMemo(()=>k.markerStart?`url('#${nm(k.markerStart,w)}')`:void 0,[k.markerStart,w]),P=I.useMemo(()=>k.markerEnd?`url('#${nm(k.markerEnd,w)}')`:void 0,[k.markerEnd,w]);if(k.hidden||G===null||Q===null||K===null||D===null)return null;const X=ye=>{var Te;const{addSelectedEdges:pe,unselectNodesAndEdges:Se,multiSelectionActive:Oe}=F.getState();V&&(F.setState({nodesSelectionActive:!1}),k.selected&&Oe?(Se({nodes:[],edges:[k]}),(Te=H.current)==null||Te.blur()):pe([e])),a&&a(ye,k)},J=o?ye=>{o(ye,{...k})}:void 0,ne=s?ye=>{s(ye,{...k})}:void 0,re=c?ye=>{c(ye,{...k})}:void 0,ue=h?ye=>{h(ye,{...k})}:void 0,xe=f?ye=>{f(ye,{...k})}:void 0,be=ye=>{var pe;if(!N&&b_.includes(ye.key)&&V){const{unselectNodesAndEdges:Se,addSelectedEdges:Oe}=F.getState();ye.key==="Escape"?((pe=H.current)==null||pe.blur(),Se({edges:[k]})):Oe([e])}};return y.jsx("svg",{style:{zIndex:z},children:y.jsxs("g",{className:Mt(["react-flow__edge",`react-flow__edge-${M}`,k.className,S,{selected:k.selected,animated:k.animated,inactive:!V&&!a,updating:B,selectable:V}]),onClick:X,onDoubleClick:J,onContextMenu:ne,onMouseEnter:re,onMouseMove:ue,onMouseLeave:xe,onKeyDown:L?be:void 0,tabIndex:L?0:void 0,role:k.ariaRole??(L?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":L?`${K_}-${w}`:void 0,ref:H,...k.domAttributes,children:[!ee&&y.jsx(A,{id:e,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:V,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:$,targetPosition:Y,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:C,markerEnd:P,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),R&&y.jsx(CM,{edge:k,isReconnectable:R,reconnectRadius:m,onReconnect:p,onReconnectStart:g,onReconnectEnd:b,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:$,targetPosition:Y,setUpdateHover:U,setReconnecting:q})]})})}var TM=I.memo(jM);const AM=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function SS({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:l,noPanClassName:a,onReconnect:o,onEdgeContextMenu:s,onEdgeMouseEnter:c,onEdgeMouseMove:h,onEdgeMouseLeave:f,onEdgeClick:m,reconnectRadius:p,onEdgeDoubleClick:g,onReconnectStart:b,onReconnectEnd:w,disableKeyboardA11y:E}){const{edgesFocusable:S,edgesReconnectable:_,elementsSelectable:N,onError:k}=Ye(AM,mt),T=pM(t);return y.jsxs("div",{className:"react-flow__edges",children:[y.jsx(vM,{defaultColor:e,rfId:n}),T.map(M=>y.jsx(TM,{id:M,edgesFocusable:S,edgesReconnectable:_,elementsSelectable:N,noPanClassName:a,onReconnect:o,onContextMenu:s,onMouseEnter:c,onMouseMove:h,onMouseLeave:f,onClick:m,reconnectRadius:p,onDoubleClick:g,onReconnectStart:b,onReconnectEnd:w,rfId:n,onError:k,edgeTypes:l,disableKeyboardA11y:E},M))]})}SS.displayName="EdgeRenderer";const zM=I.memo(SS),MM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function DM({children:e}){const t=Ye(MM);return y.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function RM(e){const t=ul(),n=I.useRef(!1);I.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const OM=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function LM(e){const t=Ye(OM),n=gt();return I.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function HM(e){return e.connection.inProgress?{...e.connection,to:is(e.connection.to,e.transform)}:{...e.connection}}function BM(e){return HM}function IM(e){const t=BM();return Ye(t,mt)}const qM=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function $M({containerStyle:e,style:t,type:n,component:l}){const{nodesConnectable:a,width:o,height:s,isValid:c,inProgress:h}=Ye(qM,mt);return!(o&&a&&h)?null:y.jsx("svg",{style:e,width:o,height:s,className:"react-flow__connectionline react-flow__container",children:y.jsx("g",{className:Mt(["react-flow__connection",S_(c)]),children:y.jsx(kS,{style:t,type:n,CustomComponent:l,isValid:c})})})}const kS=({style:e,type:t=bi.Bezier,CustomComponent:n,isValid:l})=>{const{inProgress:a,from:o,fromNode:s,fromHandle:c,fromPosition:h,to:f,toNode:m,toHandle:p,toPosition:g,pointer:b}=IM();if(!a)return;if(n)return y.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:c,fromX:o.x,fromY:o.y,toX:f.x,toY:f.y,fromPosition:h,toPosition:g,connectionStatus:S_(l),toNode:m,toHandle:p,pointer:b});let w="";const E={sourceX:o.x,sourceY:o.y,sourcePosition:h,targetX:f.x,targetY:f.y,targetPosition:g};switch(t){case bi.Bezier:[w]=Rm(E);break;case bi.SimpleBezier:[w]=fS(E);break;case bi.Step:[w]=tm({...E,borderRadius:0});break;case bi.SmoothStep:[w]=tm(E);break;default:[w]=L_(E)}return y.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};kS.displayName="ConnectionLine";const UM={};function xb(e=UM){I.useRef(e),gt(),I.useEffect(()=>{},[e])}function VM(){gt(),I.useRef(!1),I.useEffect(()=>{},[])}function ES({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:o,onEdgeDoubleClick:s,onNodeMouseEnter:c,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:m,onSelectionContextMenu:p,onSelectionStart:g,onSelectionEnd:b,connectionLineType:w,connectionLineStyle:E,connectionLineComponent:S,connectionLineContainerStyle:_,selectionKeyCode:N,selectionOnDrag:k,selectionMode:T,multiSelectionKeyCode:M,panActivationKeyCode:A,zoomActivationKeyCode:L,deleteKeyCode:R,onlyRenderVisibleElements:V,elementsSelectable:H,defaultViewport:B,translateExtent:U,minZoom:ee,maxZoom:q,preventScrolling:F,defaultMarkerColor:z,zoomOnScroll:G,zoomOnPinch:Q,panOnScroll:K,panOnScrollSpeed:D,panOnScrollMode:$,zoomOnDoubleClick:Y,panOnDrag:C,onPaneClick:P,onPaneMouseEnter:X,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneScroll:re,onPaneContextMenu:ue,paneClickDistance:xe,nodeClickDistance:be,onEdgeContextMenu:ye,onEdgeMouseEnter:pe,onEdgeMouseMove:Se,onEdgeMouseLeave:Oe,reconnectRadius:Te,onReconnect:ft,onReconnectStart:rt,onReconnectEnd:Dt,noDragClassName:Pt,noWheelClassName:Bt,noPanClassName:kn,disableKeyboardA11y:On,nodeExtent:Rt,rfId:qr,viewport:ce,onViewportChange:ge}){return xb(e),xb(t),VM(),RM(n),LM(ce),y.jsx(iM,{onPaneClick:P,onPaneMouseEnter:X,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneContextMenu:ue,onPaneScroll:re,paneClickDistance:xe,deleteKeyCode:R,selectionKeyCode:N,selectionOnDrag:k,selectionMode:T,onSelectionStart:g,onSelectionEnd:b,multiSelectionKeyCode:M,panActivationKeyCode:A,zoomActivationKeyCode:L,elementsSelectable:H,zoomOnScroll:G,zoomOnPinch:Q,zoomOnDoubleClick:Y,panOnScroll:K,panOnScrollSpeed:D,panOnScrollMode:$,panOnDrag:C,defaultViewport:B,translateExtent:U,minZoom:ee,maxZoom:q,onSelectionContextMenu:p,preventScrolling:F,noDragClassName:Pt,noWheelClassName:Bt,noPanClassName:kn,disableKeyboardA11y:On,onViewportChange:ge,isControlledViewport:!!ce,children:y.jsxs(DM,{children:[y.jsx(zM,{edgeTypes:t,onEdgeClick:a,onEdgeDoubleClick:s,onReconnect:ft,onReconnectStart:rt,onReconnectEnd:Dt,onlyRenderVisibleElements:V,onEdgeContextMenu:ye,onEdgeMouseEnter:pe,onEdgeMouseMove:Se,onEdgeMouseLeave:Oe,reconnectRadius:Te,defaultMarkerColor:z,noPanClassName:kn,disableKeyboardA11y:On,rfId:qr}),y.jsx($M,{style:E,type:w,component:S,containerStyle:_}),y.jsx("div",{className:"react-flow__edgelabel-renderer"}),y.jsx(hM,{nodeTypes:e,onNodeClick:l,onNodeDoubleClick:o,onNodeMouseEnter:c,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:m,nodeClickDistance:be,onlyRenderVisibleElements:V,noPanClassName:kn,noDragClassName:Pt,disableKeyboardA11y:On,nodeExtent:Rt,rfId:qr}),y.jsx("div",{className:"react-flow__viewport-portal"})]})})}ES.displayName="GraphView";const PM=I.memo(ES),yb=({nodes:e,edges:t,defaultNodes:n,defaultEdges:l,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:h=.5,maxZoom:f=2,nodeOrigin:m,nodeExtent:p,zIndexMode:g="basic"}={})=>{const b=new Map,w=new Map,E=new Map,S=new Map,_=l??t??[],N=n??e??[],k=m??[0,0],T=p??Po;I_(E,S,_);const M=rm(N,b,w,{nodeOrigin:k,nodeExtent:T,zIndexMode:g});let A=[0,0,1];if(s&&a&&o){const L=ns(b,{filter:B=>!!((B.width||B.initialWidth)&&(B.height||B.initialHeight))}),{x:R,y:V,zoom:H}=Mm(L,a,o,h,f,(c==null?void 0:c.padding)??.1);A=[R,V,H]}return{rfId:"1",width:a??0,height:o??0,transform:A,nodes:N,nodesInitialized:M,nodeLookup:b,parentLookup:w,edges:_,edgeLookup:S,connectionLookup:E,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:h,maxZoom:f,translateExtent:Po,nodeExtent:T,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ga.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:k,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:c,fitViewResolver:null,connection:{...__},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:iA,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:w_,zIndexMode:g,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},GM=({nodes:e,edges:t,defaultNodes:n,defaultEdges:l,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:h,maxZoom:f,nodeOrigin:m,nodeExtent:p,zIndexMode:g})=>sz((b,w)=>{async function E(){const{nodeLookup:S,panZoom:_,fitViewOptions:N,fitViewResolver:k,width:T,height:M,minZoom:A,maxZoom:L}=w();_&&(await nA({nodes:S,width:T,height:M,panZoom:_,minZoom:A,maxZoom:L},N),k==null||k.resolve(!0),b({fitViewResolver:null}))}return{...yb({nodes:e,edges:t,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:h,maxZoom:f,nodeOrigin:m,nodeExtent:p,defaultNodes:n,defaultEdges:l,zIndexMode:g}),setNodes:S=>{const{nodeLookup:_,parentLookup:N,nodeOrigin:k,elevateNodesOnSelect:T,fitViewQueued:M,zIndexMode:A}=w(),L=rm(S,_,N,{nodeOrigin:k,nodeExtent:p,elevateNodesOnSelect:T,checkEquality:!0,zIndexMode:A});M&&L?(E(),b({nodes:S,nodesInitialized:L,fitViewQueued:!1,fitViewOptions:void 0})):b({nodes:S,nodesInitialized:L})},setEdges:S=>{const{connectionLookup:_,edgeLookup:N}=w();I_(_,N,S),b({edges:S})},setDefaultNodesAndEdges:(S,_)=>{if(S){const{setNodes:N}=w();N(S),b({hasDefaultNodes:!0})}if(_){const{setEdges:N}=w();N(_),b({hasDefaultEdges:!0})}},updateNodeInternals:S=>{const{triggerNodeChanges:_,nodeLookup:N,parentLookup:k,domNode:T,nodeOrigin:M,nodeExtent:A,debug:L,fitViewQueued:R,zIndexMode:V}=w(),{changes:H,updatedInternals:B}=NA(S,N,k,T,M,A,V);B&&(_A(N,k,{nodeOrigin:M,nodeExtent:A,zIndexMode:V}),R?(E(),b({fitViewQueued:!1,fitViewOptions:void 0})):b({}),(H==null?void 0:H.length)>0&&(L&&console.log("React Flow: trigger node changes",H),_==null||_(H)))},updateNodePositions:(S,_=!1)=>{const N=[];let k=[];const{nodeLookup:T,triggerNodeChanges:M,connection:A,updateConnection:L,onNodesChangeMiddlewareMap:R}=w();for(const[V,H]of S){const B=T.get(V),U=!!(B!=null&&B.expandParent&&(B!=null&&B.parentId)&&(H!=null&&H.position)),ee={id:V,type:"position",position:U?{x:Math.max(0,H.position.x),y:Math.max(0,H.position.y)}:H.position,dragging:_};if(B&&A.inProgress&&A.fromNode.id===B.id){const q=ll(B,A.fromHandle,ve.Left,!0);L({...A,from:q})}U&&B.parentId&&N.push({id:V,parentId:B.parentId,rect:{...H.internals.positionAbsolute,width:H.measured.width??0,height:H.measured.height??0}}),k.push(ee)}if(N.length>0){const{parentLookup:V,nodeOrigin:H}=w(),B=Im(N,T,V,H);k.push(...B)}for(const V of R.values())k=V(k);M(k)},triggerNodeChanges:S=>{const{onNodesChange:_,setNodes:N,nodes:k,hasDefaultNodes:T,debug:M}=w();if(S!=null&&S.length){if(T){const A=eS(S,k);N(A)}M&&console.log("React Flow: trigger node changes",S),_==null||_(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:_,setEdges:N,edges:k,hasDefaultEdges:T,debug:M}=w();if(S!=null&&S.length){if(T){const A=tS(S,k);N(A)}M&&console.log("React Flow: trigger edge changes",S),_==null||_(S)}},addSelectedNodes:S=>{const{multiSelectionActive:_,edgeLookup:N,nodeLookup:k,triggerNodeChanges:T,triggerEdgeChanges:M}=w();if(_){const A=S.map(L=>Xi(L,!0));T(A);return}T(oa(k,new Set([...S]),!0)),M(oa(N))},addSelectedEdges:S=>{const{multiSelectionActive:_,edgeLookup:N,nodeLookup:k,triggerNodeChanges:T,triggerEdgeChanges:M}=w();if(_){const A=S.map(L=>Xi(L,!0));M(A);return}M(oa(N,new Set([...S]))),T(oa(k,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:_}={})=>{const{edges:N,nodes:k,nodeLookup:T,triggerNodeChanges:M,triggerEdgeChanges:A}=w(),L=S||k,R=_||N,V=[];for(const B of L){if(!B.selected)continue;const U=T.get(B.id);U&&(U.selected=!1),V.push(Xi(B.id,!1))}const H=[];for(const B of R)B.selected&&H.push(Xi(B.id,!1));M(V),A(H)},setMinZoom:S=>{const{panZoom:_,maxZoom:N}=w();_==null||_.setScaleExtent([S,N]),b({minZoom:S})},setMaxZoom:S=>{const{panZoom:_,minZoom:N}=w();_==null||_.setScaleExtent([N,S]),b({maxZoom:S})},setTranslateExtent:S=>{var _;(_=w().panZoom)==null||_.setTranslateExtent(S),b({translateExtent:S})},resetSelectedElements:()=>{const{edges:S,nodes:_,triggerNodeChanges:N,triggerEdgeChanges:k,elementsSelectable:T}=w();if(!T)return;const M=_.reduce((L,R)=>R.selected?[...L,Xi(R.id,!1)]:L,[]),A=S.reduce((L,R)=>R.selected?[...L,Xi(R.id,!1)]:L,[]);N(M),k(A)},setNodeExtent:S=>{const{nodes:_,nodeLookup:N,parentLookup:k,nodeOrigin:T,elevateNodesOnSelect:M,nodeExtent:A,zIndexMode:L}=w();S[0][0]===A[0][0]&&S[0][1]===A[0][1]&&S[1][0]===A[1][0]&&S[1][1]===A[1][1]||(rm(_,N,k,{nodeOrigin:T,nodeExtent:S,elevateNodesOnSelect:M,checkEquality:!1,zIndexMode:L}),b({nodeExtent:S}))},panBy:S=>{const{transform:_,width:N,height:k,panZoom:T,translateExtent:M}=w();return CA({delta:S,panZoom:T,transform:_,translateExtent:M,width:N,height:k})},setCenter:async(S,_,N)=>{const{width:k,height:T,maxZoom:M,panZoom:A}=w();if(!A)return Promise.resolve(!1);const L=typeof(N==null?void 0:N.zoom)<"u"?N.zoom:M;return await A.setViewport({x:k/2-S*L,y:T/2-_*L,zoom:L},{duration:N==null?void 0:N.duration,ease:N==null?void 0:N.ease,interpolate:N==null?void 0:N.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{b({connection:{...__}})},updateConnection:S=>{b({connection:S})},reset:()=>b({...yb()})}},Object.is);function FM({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:l,initialWidth:a,initialHeight:o,initialMinZoom:s,initialMaxZoom:c,initialFitViewOptions:h,fitView:f,nodeOrigin:m,nodeExtent:p,zIndexMode:g,children:b}){const[w]=I.useState(()=>GM({nodes:e,edges:t,defaultNodes:n,defaultEdges:l,width:a,height:o,fitView:f,minZoom:s,maxZoom:c,fitViewOptions:h,nodeOrigin:m,nodeExtent:p,zIndexMode:g}));return y.jsx(cz,{value:w,children:y.jsx(Dz,{children:b})})}function YM({children:e,nodes:t,edges:n,defaultNodes:l,defaultEdges:a,width:o,height:s,fitView:c,fitViewOptions:h,minZoom:f,maxZoom:m,nodeOrigin:p,nodeExtent:g,zIndexMode:b}){return I.useContext(Bc)?y.jsx(y.Fragment,{children:e}):y.jsx(FM,{initialNodes:t,initialEdges:n,defaultNodes:l,defaultEdges:a,initialWidth:o,initialHeight:s,fitView:c,initialFitViewOptions:h,initialMinZoom:f,initialMaxZoom:m,nodeOrigin:p,nodeExtent:g,zIndexMode:b,children:e})}const XM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function QM({nodes:e,edges:t,defaultNodes:n,defaultEdges:l,className:a,nodeTypes:o,edgeTypes:s,onNodeClick:c,onEdgeClick:h,onInit:f,onMove:m,onMoveStart:p,onMoveEnd:g,onConnect:b,onConnectStart:w,onConnectEnd:E,onClickConnectStart:S,onClickConnectEnd:_,onNodeMouseEnter:N,onNodeMouseMove:k,onNodeMouseLeave:T,onNodeContextMenu:M,onNodeDoubleClick:A,onNodeDragStart:L,onNodeDrag:R,onNodeDragStop:V,onNodesDelete:H,onEdgesDelete:B,onDelete:U,onSelectionChange:ee,onSelectionDragStart:q,onSelectionDrag:F,onSelectionDragStop:z,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onBeforeDelete:D,connectionMode:$,connectionLineType:Y=bi.Bezier,connectionLineStyle:C,connectionLineComponent:P,connectionLineContainerStyle:X,deleteKeyCode:J="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:re=!1,selectionMode:ue=Go.Full,panActivationKeyCode:xe="Space",multiSelectionKeyCode:be=Yo()?"Meta":"Control",zoomActivationKeyCode:ye=Yo()?"Meta":"Control",snapToGrid:pe,snapGrid:Se,onlyRenderVisibleElements:Oe=!1,selectNodesOnDrag:Te,nodesDraggable:ft,autoPanOnNodeFocus:rt,nodesConnectable:Dt,nodesFocusable:Pt,nodeOrigin:Bt=J_,edgesFocusable:kn,edgesReconnectable:On,elementsSelectable:Rt=!0,defaultViewport:qr=Sz,minZoom:ce=.5,maxZoom:ge=2,translateExtent:Ne=Po,preventScrolling:qe=!0,nodeExtent:Xe,defaultMarkerColor:Zt="#b1b1b7",zoomOnScroll:Ln=!0,zoomOnPinch:It=!0,panOnScroll:wt=!1,panOnScrollSpeed:Gt=.5,panOnScrollMode:et=el.Free,zoomOnDoubleClick:Zn=!0,panOnDrag:fn=!0,onPaneClick:Xc,onPaneMouseEnter:dl,onPaneMouseMove:hl,onPaneMouseLeave:pl,onPaneScroll:ur,onPaneContextMenu:ml,paneClickDistance:ki=1,nodeClickDistance:Qc=0,children:cs,onReconnect:ka,onReconnectStart:Ei,onReconnectEnd:Zc,onEdgeContextMenu:fs,onEdgeDoubleClick:ds,onEdgeMouseEnter:hs,onEdgeMouseMove:Ea,onEdgeMouseLeave:Na,reconnectRadius:ps=10,onNodesChange:ms,onEdgesChange:Kn,noDragClassName:Ot="nodrag",noWheelClassName:Ft="nowheel",noPanClassName:cr="nopan",fitView:gl,fitViewOptions:gs,connectOnClick:Kc,attributionPosition:xs,proOptions:Ni,defaultEdgeOptions:Ca,elevateNodesOnSelect:$r=!0,elevateEdgesOnSelect:Ur=!1,disableKeyboardA11y:Vr=!1,autoPanOnConnect:Pr,autoPanOnNodeDrag:kt,autoPanSpeed:ys,connectionRadius:vs,isValidConnection:fr,onError:Gr,style:Jc,id:ja,nodeDragThreshold:bs,connectionDragThreshold:Wc,viewport:xl,onViewportChange:yl,width:Hn,height:Wt,colorMode:ws="light",debug:ef,onScroll:Fr,ariaLabelConfig:_s,zIndexMode:Ci="basic",...tf},en){const ji=ja||"1",Ss=Cz(ws),Ta=I.useCallback(dr=>{dr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Fr==null||Fr(dr)},[Fr]);return y.jsx("div",{"data-testid":"rf__wrapper",...tf,onScroll:Ta,style:{...Jc,...XM},ref:en,className:Mt(["react-flow",a,Ss]),id:ja,role:"application",children:y.jsxs(YM,{nodes:e,edges:t,width:Hn,height:Wt,fitView:gl,fitViewOptions:gs,minZoom:ce,maxZoom:ge,nodeOrigin:Bt,nodeExtent:Xe,zIndexMode:Ci,children:[y.jsx(PM,{onInit:f,onNodeClick:c,onEdgeClick:h,onNodeMouseEnter:N,onNodeMouseMove:k,onNodeMouseLeave:T,onNodeContextMenu:M,onNodeDoubleClick:A,nodeTypes:o,edgeTypes:s,connectionLineType:Y,connectionLineStyle:C,connectionLineComponent:P,connectionLineContainerStyle:X,selectionKeyCode:ne,selectionOnDrag:re,selectionMode:ue,deleteKeyCode:J,multiSelectionKeyCode:be,panActivationKeyCode:xe,zoomActivationKeyCode:ye,onlyRenderVisibleElements:Oe,defaultViewport:qr,translateExtent:Ne,minZoom:ce,maxZoom:ge,preventScrolling:qe,zoomOnScroll:Ln,zoomOnPinch:It,zoomOnDoubleClick:Zn,panOnScroll:wt,panOnScrollSpeed:Gt,panOnScrollMode:et,panOnDrag:fn,onPaneClick:Xc,onPaneMouseEnter:dl,onPaneMouseMove:hl,onPaneMouseLeave:pl,onPaneScroll:ur,onPaneContextMenu:ml,paneClickDistance:ki,nodeClickDistance:Qc,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onReconnect:ka,onReconnectStart:Ei,onReconnectEnd:Zc,onEdgeContextMenu:fs,onEdgeDoubleClick:ds,onEdgeMouseEnter:hs,onEdgeMouseMove:Ea,onEdgeMouseLeave:Na,reconnectRadius:ps,defaultMarkerColor:Zt,noDragClassName:Ot,noWheelClassName:Ft,noPanClassName:cr,rfId:ji,disableKeyboardA11y:Vr,nodeExtent:Xe,viewport:xl,onViewportChange:yl}),y.jsx(Nz,{nodes:e,edges:t,defaultNodes:n,defaultEdges:l,onConnect:b,onConnectStart:w,onConnectEnd:E,onClickConnectStart:S,onClickConnectEnd:_,nodesDraggable:ft,autoPanOnNodeFocus:rt,nodesConnectable:Dt,nodesFocusable:Pt,edgesFocusable:kn,edgesReconnectable:On,elementsSelectable:Rt,elevateNodesOnSelect:$r,elevateEdgesOnSelect:Ur,minZoom:ce,maxZoom:ge,nodeExtent:Xe,onNodesChange:ms,onEdgesChange:Kn,snapToGrid:pe,snapGrid:Se,connectionMode:$,translateExtent:Ne,connectOnClick:Kc,defaultEdgeOptions:Ca,fitView:gl,fitViewOptions:gs,onNodesDelete:H,onEdgesDelete:B,onDelete:U,onNodeDragStart:L,onNodeDrag:R,onNodeDragStop:V,onSelectionDrag:F,onSelectionDragStart:q,onSelectionDragStop:z,onMove:m,onMoveStart:p,onMoveEnd:g,noPanClassName:cr,nodeOrigin:Bt,rfId:ji,autoPanOnConnect:Pr,autoPanOnNodeDrag:kt,autoPanSpeed:ys,onError:Gr,connectionRadius:vs,isValidConnection:fr,selectNodesOnDrag:Te,nodeDragThreshold:bs,connectionDragThreshold:Wc,onBeforeDelete:D,debug:ef,ariaLabelConfig:_s,zIndexMode:Ci}),y.jsx(_z,{onSelectionChange:ee}),cs,y.jsx(xz,{proOptions:Ni,position:xs}),y.jsx(gz,{rfId:ji,disableKeyboardA11y:Vr})]})})}var ZM=nS(QM);const KM=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function JM({children:e}){const t=Ye(KM);return t?uz.createPortal(e,t):null}function WM(e){const[t,n]=I.useState(e),l=I.useCallback(a=>n(o=>eS(a,o)),[]);return[t,n,l]}function e5(e){const[t,n]=I.useState(e),l=I.useCallback(a=>n(o=>tS(a,o)),[]);return[t,n,l]}function t5({dimensions:e,lineWidth:t,variant:n,className:l}){return y.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Mt(["react-flow__background-pattern",n,l])})}function n5({radius:e,className:t}){return y.jsx("circle",{cx:e,cy:e,r:e,className:Mt(["react-flow__background-pattern","dots",t])})}var Rr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Rr||(Rr={}));const r5={[Rr.Dots]:1,[Rr.Lines]:1,[Rr.Cross]:6},i5=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function NS({id:e,variant:t=Rr.Dots,gap:n=20,size:l,lineWidth:a=1,offset:o=0,color:s,bgColor:c,style:h,className:f,patternClassName:m}){const p=I.useRef(null),{transform:g,patternId:b}=Ye(i5,mt),w=l||r5[t],E=t===Rr.Dots,S=t===Rr.Cross,_=Array.isArray(n)?n:[n,n],N=[_[0]*g[2]||1,_[1]*g[2]||1],k=w*g[2],T=Array.isArray(o)?o:[o,o],M=S?[k,k]:N,A=[T[0]*g[2]||1+M[0]/2,T[1]*g[2]||1+M[1]/2],L=`${b}${e||""}`;return y.jsxs("svg",{className:Mt(["react-flow__background",f]),style:{...h,...qc,"--xy-background-color-props":c,"--xy-background-pattern-color-props":s},ref:p,"data-testid":"rf__background",children:[y.jsx("pattern",{id:L,x:g[0]%N[0],y:g[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${A[0]},-${A[1]})`,children:E?y.jsx(n5,{radius:k/2,className:m}):y.jsx(t5,{dimensions:M,lineWidth:a,variant:t,className:m})}),y.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${L})`})]})}NS.displayName="Background";const l5=I.memo(NS);function a5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:y.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function o5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:y.jsx("path",{d:"M0 0h32v4.2H0z"})})}function s5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:y.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function u5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function c5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Fu({children:e,className:t,...n}){return y.jsx("button",{type:"button",className:Mt(["react-flow__controls-button",t]),...n,children:e})}const f5=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function CS({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:o,onZoomOut:s,onFitView:c,onInteractiveChange:h,className:f,children:m,position:p="bottom-left",orientation:g="vertical","aria-label":b}){const w=gt(),{isInteractive:E,minZoomReached:S,maxZoomReached:_,ariaLabelConfig:N}=Ye(f5,mt),{zoomIn:k,zoomOut:T,fitView:M}=ul(),A=()=>{k(),o==null||o()},L=()=>{T(),s==null||s()},R=()=>{M(a),c==null||c()},V=()=>{w.setState({nodesDraggable:!E,nodesConnectable:!E,elementsSelectable:!E}),h==null||h(!E)},H=g==="horizontal"?"horizontal":"vertical";return y.jsxs(Ic,{className:Mt(["react-flow__controls",H,f]),position:p,style:e,"data-testid":"rf__controls","aria-label":b??N["controls.ariaLabel"],children:[t&&y.jsxs(y.Fragment,{children:[y.jsx(Fu,{onClick:A,className:"react-flow__controls-zoomin",title:N["controls.zoomIn.ariaLabel"],"aria-label":N["controls.zoomIn.ariaLabel"],disabled:_,children:y.jsx(a5,{})}),y.jsx(Fu,{onClick:L,className:"react-flow__controls-zoomout",title:N["controls.zoomOut.ariaLabel"],"aria-label":N["controls.zoomOut.ariaLabel"],disabled:S,children:y.jsx(o5,{})})]}),n&&y.jsx(Fu,{className:"react-flow__controls-fitview",onClick:R,title:N["controls.fitView.ariaLabel"],"aria-label":N["controls.fitView.ariaLabel"],children:y.jsx(s5,{})}),l&&y.jsx(Fu,{className:"react-flow__controls-interactive",onClick:V,title:N["controls.interactive.ariaLabel"],"aria-label":N["controls.interactive.ariaLabel"],children:E?y.jsx(c5,{}):y.jsx(u5,{})}),m]})}CS.displayName="Controls";const d5=I.memo(CS);function h5({id:e,x:t,y:n,width:l,height:a,style:o,color:s,strokeColor:c,strokeWidth:h,className:f,borderRadius:m,shapeRendering:p,selected:g,onClick:b}){const{background:w,backgroundColor:E}=o||{},S=s||w||E;return y.jsx("rect",{className:Mt(["react-flow__minimap-node",{selected:g},f]),x:t,y:n,rx:m,ry:m,width:l,height:a,style:{fill:S,stroke:c,strokeWidth:h},shapeRendering:p,onClick:b?_=>b(_,e):void 0})}const p5=I.memo(h5),m5=e=>e.nodes.map(t=>t.id),Ah=e=>e instanceof Function?e:()=>e;function g5({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:o=p5,onClick:s}){const c=Ye(m5,mt),h=Ah(t),f=Ah(e),m=Ah(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return y.jsx(y.Fragment,{children:c.map(g=>y.jsx(y5,{id:g,nodeColorFunc:h,nodeStrokeColorFunc:f,nodeClassNameFunc:m,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:o,onClick:s,shapeRendering:p},g))})}function x5({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:o,shapeRendering:s,NodeComponent:c,onClick:h}){const{node:f,x:m,y:p,width:g,height:b}=Ye(w=>{const E=w.nodeLookup.get(e);if(!E)return{node:void 0,x:0,y:0,width:0,height:0};const S=E.internals.userNode,{x:_,y:N}=E.internals.positionAbsolute,{width:k,height:T}=Hr(S);return{node:S,x:_,y:N,width:k,height:T}},mt);return!f||f.hidden||!T_(f)?null:y.jsx(c,{x:m,y:p,width:g,height:b,style:f.style,selected:!!f.selected,className:l(f),color:t(f),borderRadius:a,strokeColor:n(f),strokeWidth:o,shapeRendering:s,onClick:h,id:f.id})}const y5=I.memo(x5);var v5=I.memo(g5);const b5=200,w5=150,_5=e=>!e.hidden,S5=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?j_(ns(e.nodeLookup,{filter:_5}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},k5="react-flow__minimap-desc";function jS({style:e,className:t,nodeStrokeColor:n,nodeColor:l,nodeClassName:a="",nodeBorderRadius:o=5,nodeStrokeWidth:s,nodeComponent:c,bgColor:h,maskColor:f,maskStrokeColor:m,maskStrokeWidth:p,position:g="bottom-right",onClick:b,onNodeClick:w,pannable:E=!1,zoomable:S=!1,ariaLabel:_,inversePan:N,zoomStep:k=1,offsetScale:T=5}){const M=gt(),A=I.useRef(null),{boundingRect:L,viewBB:R,rfId:V,panZoom:H,translateExtent:B,flowWidth:U,flowHeight:ee,ariaLabelConfig:q}=Ye(S5,mt),F=(e==null?void 0:e.width)??b5,z=(e==null?void 0:e.height)??w5,G=L.width/F,Q=L.height/z,K=Math.max(G,Q),D=K*F,$=K*z,Y=T*K,C=L.x-(D-L.width)/2-Y,P=L.y-($-L.height)/2-Y,X=D+Y*2,J=$+Y*2,ne=`${k5}-${V}`,re=I.useRef(0),ue=I.useRef();re.current=K,I.useEffect(()=>{if(A.current&&H)return ue.current=LA({domNode:A.current,panZoom:H,getTransform:()=>M.getState().transform,getViewScale:()=>re.current}),()=>{var pe;(pe=ue.current)==null||pe.destroy()}},[H]),I.useEffect(()=>{var pe;(pe=ue.current)==null||pe.update({translateExtent:B,width:U,height:ee,inversePan:N,pannable:E,zoomStep:k,zoomable:S})},[E,S,N,k,B,U,ee]);const xe=b?pe=>{var Te;const[Se,Oe]=((Te=ue.current)==null?void 0:Te.pointer(pe))||[0,0];b(pe,{x:Se,y:Oe})}:void 0,be=w?I.useCallback((pe,Se)=>{const Oe=M.getState().nodeLookup.get(Se).internals.userNode;w(pe,Oe)},[]):void 0,ye=_??q["minimap.ariaLabel"];return y.jsx(Ic,{position:g,style:{...e,"--xy-minimap-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*K:void 0,"--xy-minimap-node-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:Mt(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:y.jsxs("svg",{width:F,height:z,viewBox:`${C} ${P} ${X} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:A,onClick:xe,children:[ye&&y.jsx("title",{id:ne,children:ye}),y.jsx(v5,{onClick:be,nodeColor:l,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:a,nodeStrokeWidth:s,nodeComponent:c}),y.jsx("path",{className:"react-flow__minimap-mask",d:`M${C-Y},${P-Y}h${X+Y*2}v${J+Y*2}h${-X-Y*2}z + M${R.x},${R.y}h${R.width}v${R.height}h${-R.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}jS.displayName="MiniMap";const E5=I.memo(jS),N5=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,C5={[ba.Line]:"right",[ba.Handle]:"bottom-right"};function j5({nodeId:e,position:t,variant:n=ba.Handle,className:l,style:a=void 0,children:o,color:s,minWidth:c=10,minHeight:h=10,maxWidth:f=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:g,autoScale:b=!0,shouldResize:w,onResizeStart:E,onResize:S,onResizeEnd:_}){const N=aS(),k=typeof e=="string"?e:N,T=gt(),M=I.useRef(null),A=n===ba.Handle,L=Ye(I.useCallback(N5(A&&b),[A,b]),mt),R=I.useRef(null),V=t??C5[n];I.useEffect(()=>{if(!(!M.current||!k))return R.current||(R.current=ZA({domNode:M.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:B,transform:U,snapGrid:ee,snapToGrid:q,nodeOrigin:F,domNode:z}=T.getState();return{nodeLookup:B,transform:U,snapGrid:ee,snapToGrid:q,nodeOrigin:F,paneDomNode:z}},onChange:(B,U)=>{const{triggerNodeChanges:ee,nodeLookup:q,parentLookup:F,nodeOrigin:z}=T.getState(),G=[],Q={x:B.x,y:B.y},K=q.get(k);if(K&&K.expandParent&&K.parentId){const D=K.origin??z,$=B.width??K.measured.width??0,Y=B.height??K.measured.height??0,C={id:K.id,parentId:K.parentId,rect:{width:$,height:Y,...A_({x:B.x??K.position.x,y:B.y??K.position.y},{width:$,height:Y},K.parentId,q,D)}},P=Im([C],q,F,z);G.push(...P),Q.x=B.x?Math.max(D[0]*$,B.x):void 0,Q.y=B.y?Math.max(D[1]*Y,B.y):void 0}if(Q.x!==void 0&&Q.y!==void 0){const D={id:k,type:"position",position:{...Q}};G.push(D)}if(B.width!==void 0&&B.height!==void 0){const $={id:k,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:B.width,height:B.height}};G.push($)}for(const D of U){const $={...D,type:"position"};G.push($)}ee(G)},onEnd:({width:B,height:U})=>{const ee={id:k,type:"dimensions",resizing:!1,dimensions:{width:B,height:U}};T.getState().triggerNodeChanges([ee])}})),R.current.update({controlPosition:V,boundaries:{minWidth:c,minHeight:h,maxWidth:f,maxHeight:m},keepAspectRatio:p,resizeDirection:g,onResizeStart:E,onResize:S,onResizeEnd:_,shouldResize:w}),()=>{var B;(B=R.current)==null||B.destroy()}},[V,c,h,f,m,p,E,S,_,w]);const H=V.split("-");return y.jsx("div",{className:Mt(["react-flow__resize-control","nodrag",...H,n,l]),ref:M,style:{...a,scale:L,...s&&{[A?"backgroundColor":"borderColor"]:s}},children:o})}I.memo(j5);function as(e,t){if(t.length===0)return null;let n=e[t[0]];for(let l=1;ll.viewContextPath),t=se(l=>l.nodes),n=se(l=>l.subworkflowContexts);return I.useMemo(()=>{var l;return e.length===0?t:((l=as(n,e))==null?void 0:l.nodes)??t},[e,t,n])}function T5(){const e=se(l=>l.viewContextPath),t=se(l=>l.groupProgress),n=se(l=>l.subworkflowContexts);return I.useMemo(()=>{var l;return e.length===0?t:((l=as(n,e))==null?void 0:l.groupProgress)??t},[e,t,n])}function A5(){const e=se(l=>l.viewContextPath),t=se(l=>l.highlightedEdges),n=se(l=>l.subworkflowContexts);return I.useMemo(()=>{var l;return e.length===0?t:((l=as(n,e))==null?void 0:l.highlightedEdges)??t},[e,t,n])}function $m(){const e=se(n=>n.viewContextPath),t=se(n=>n.subworkflowContexts);return I.useMemo(()=>{var n;return e.length===0?t:((n=as(t,e))==null?void 0:n.children)??[]},[e,t])}function z5(){const e=se(f=>f.viewContextPath),t=se(f=>f.agents),n=se(f=>f.routes),l=se(f=>f.parallelGroups),a=se(f=>f.forEachGroups),o=se(f=>f.nodes),s=se(f=>f.groupProgress),c=se(f=>f.entryPoint),h=se(f=>f.subworkflowContexts);return I.useMemo(()=>{if(e.length===0)return{agents:t,routes:n,parallelGroups:l,forEachGroups:a,nodes:o,groupProgress:s,entryPoint:c,subworkflowContexts:h,parentAgent:null};const f=as(h,e);return f?{agents:f.agents,routes:f.routes,parallelGroups:f.parallelGroups,forEachGroups:f.forEachGroups,nodes:f.nodes,groupProgress:f.groupProgress,entryPoint:f.entryPoint,subworkflowContexts:f.children,parentAgent:f.parentAgent}:{agents:t,routes:n,parallelGroups:l,forEachGroups:a,nodes:o,groupProgress:s,entryPoint:c,subworkflowContexts:h,parentAgent:null}},[e,t,n,l,a,o,s,c,h])}function M5(){const e=new URLSearchParams(window.location.search);return{subworkflowPath:e.get("subworkflow"),agent:e.get("agent")}}function vb(e,t){const n=[];let l=e;for(const a of t){let o=-1;for(let s=l.length-1;s>=0;s--)if(l[s].slotKey===a){o=s;break}if(o===-1){for(let s=l.length-1;s>=0;s--)if(l[s].parentAgent===a){o=s;break}}if(o===-1)return{path:n,failedSegment:a};n.push(o),l=l[o].children}return{path:n,failedSegment:null}}function am(e,t,n=[]){const l=[];for(let a=0;ac.name===t)&&l.push({path:s,ctx:o}),o.children.length>0&&l.push(...am(o.children,t,s))}return l}function D5(e){return e.length===0?null:[...e].sort((t,n)=>{const l=t.ctx.status==="running"?1:0,a=n.ctx.status==="running"?1:0;if(l!==a)return a-l;if(t.path.length!==n.path.length)return n.path.length-t.path.length;for(let o=0;o{if(n.current||!s)return;let c=null,h=null,f=null;const m=()=>{if(n.current)return;n.current=!0,c&&clearTimeout(c),h&&clearTimeout(h),f&&f();const b=se.getState();if(b.agents.length===0){t({message:"Workflow state did not load."});return}let w=[];if(a){const E=a.split("/").filter(Boolean),S=vb(b.subworkflowContexts,E);if(S.failedSegment){const _=E.slice(0,S.path.length).join("/");t({message:`Subworkflow "${S.failedSegment}" not found${_?` (resolved: ${_})`:""}. It may not have started yet.`});return}w=S.path}if(o){if((w.length===0?b.agents:(()=>{let S,_=b.subworkflowContexts;for(const N of w){if(S=_[N],!S)break;_=S.children}return(S==null?void 0:S.agents)??[]})()).some(S=>S.name===o))se.setState({viewContextPath:w,selectedNode:o});else{const S=am(b.subworkflowContexts,o);if(S.length===0){const N=a||"root workflow";se.setState({viewContextPath:w,selectedNode:null}),t({message:`Agent "${o}" not found in ${N}.`});return}if(a){const N=S.slice(0,5).map(T=>R5(b.subworkflowContexts,T.path)).join(", "),k=S.length>5?`, and ${S.length-5} more`:"";se.setState({viewContextPath:w,selectedNode:null}),t({message:`Agent "${o}" not found in ${a}. Found in: ${N}${k}`});return}const _=D5(S);se.setState({viewContextPath:_.path,selectedNode:o})}setTimeout(()=>{l({nodes:[{id:o}],padding:.5,duration:400})},200)}else a&&se.setState({viewContextPath:w,selectedNode:null})},p=()=>{const b=se.getState();if(b.agents.length===0)return!1;if(b.workflowStatus!=="running"&&b.workflowStatus!=="pending")return!0;if(a){const w=a.split("/").filter(Boolean),{failedSegment:E}=vb(b.subworkflowContexts,w);if(E)return!1}return!(o&&!a&&!b.agents.some(E=>E.name===o)&&am(b.subworkflowContexts,o).length===0)},g=()=>{c&&clearTimeout(c),c=setTimeout(()=>{n.current||p()&&m()},200)};return f=se.subscribe(g),h=setTimeout(()=>{n.current||m()},5e3),g(),()=>{c&&clearTimeout(c),h&&clearTimeout(h),f&&f()}},[s,a,o,l]),e}var zh,bb;function Um(){if(bb)return zh;bb=1;var e="\0",t="\0",n="";class l{constructor(m){Tt(this,"_isDirected",!0);Tt(this,"_isMultigraph",!1);Tt(this,"_isCompound",!1);Tt(this,"_label");Tt(this,"_defaultNodeLabelFn",()=>{});Tt(this,"_defaultEdgeLabelFn",()=>{});Tt(this,"_nodes",{});Tt(this,"_in",{});Tt(this,"_preds",{});Tt(this,"_out",{});Tt(this,"_sucs",{});Tt(this,"_edgeObjs",{});Tt(this,"_edgeLabels",{});Tt(this,"_nodeCount",0);Tt(this,"_edgeCount",0);Tt(this,"_parent");Tt(this,"_children");m&&(this._isDirected=Object.hasOwn(m,"directed")?m.directed:!0,this._isMultigraph=Object.hasOwn(m,"multigraph")?m.multigraph:!1,this._isCompound=Object.hasOwn(m,"compound")?m.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(m){return this._label=m,this}graph(){return this._label}setDefaultNodeLabel(m){return this._defaultNodeLabelFn=m,typeof m!="function"&&(this._defaultNodeLabelFn=()=>m),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var m=this;return this.nodes().filter(p=>Object.keys(m._in[p]).length===0)}sinks(){var m=this;return this.nodes().filter(p=>Object.keys(m._out[p]).length===0)}setNodes(m,p){var g=arguments,b=this;return m.forEach(function(w){g.length>1?b.setNode(w,p):b.setNode(w)}),this}setNode(m,p){return Object.hasOwn(this._nodes,m)?(arguments.length>1&&(this._nodes[m]=p),this):(this._nodes[m]=arguments.length>1?p:this._defaultNodeLabelFn(m),this._isCompound&&(this._parent[m]=t,this._children[m]={},this._children[t][m]=!0),this._in[m]={},this._preds[m]={},this._out[m]={},this._sucs[m]={},++this._nodeCount,this)}node(m){return this._nodes[m]}hasNode(m){return Object.hasOwn(this._nodes,m)}removeNode(m){var p=this;if(Object.hasOwn(this._nodes,m)){var g=b=>p.removeEdge(p._edgeObjs[b]);delete this._nodes[m],this._isCompound&&(this._removeFromParentsChildList(m),delete this._parent[m],this.children(m).forEach(function(b){p.setParent(b)}),delete this._children[m]),Object.keys(this._in[m]).forEach(g),delete this._in[m],delete this._preds[m],Object.keys(this._out[m]).forEach(g),delete this._out[m],delete this._sucs[m],--this._nodeCount}return this}setParent(m,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(p===void 0)p=t;else{p+="";for(var g=p;g!==void 0;g=this.parent(g))if(g===m)throw new Error("Setting "+p+" as parent of "+m+" would create a cycle");this.setNode(p)}return this.setNode(m),this._removeFromParentsChildList(m),this._parent[m]=p,this._children[p][m]=!0,this}_removeFromParentsChildList(m){delete this._children[this._parent[m]][m]}parent(m){if(this._isCompound){var p=this._parent[m];if(p!==t)return p}}children(m=t){if(this._isCompound){var p=this._children[m];if(p)return Object.keys(p)}else{if(m===t)return this.nodes();if(this.hasNode(m))return[]}}predecessors(m){var p=this._preds[m];if(p)return Object.keys(p)}successors(m){var p=this._sucs[m];if(p)return Object.keys(p)}neighbors(m){var p=this.predecessors(m);if(p){const b=new Set(p);for(var g of this.successors(m))b.add(g);return Array.from(b.values())}}isLeaf(m){var p;return this.isDirected()?p=this.successors(m):p=this.neighbors(m),p.length===0}filterNodes(m){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var g=this;Object.entries(this._nodes).forEach(function([E,S]){m(E)&&p.setNode(E,S)}),Object.values(this._edgeObjs).forEach(function(E){p.hasNode(E.v)&&p.hasNode(E.w)&&p.setEdge(E,g.edge(E))});var b={};function w(E){var S=g.parent(E);return S===void 0||p.hasNode(S)?(b[E]=S,S):S in b?b[S]:w(S)}return this._isCompound&&p.nodes().forEach(E=>p.setParent(E,w(E))),p}setDefaultEdgeLabel(m){return this._defaultEdgeLabelFn=m,typeof m!="function"&&(this._defaultEdgeLabelFn=()=>m),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(m,p){var g=this,b=arguments;return m.reduce(function(w,E){return b.length>1?g.setEdge(w,E,p):g.setEdge(w,E),E}),this}setEdge(){var m,p,g,b,w=!1,E=arguments[0];typeof E=="object"&&E!==null&&"v"in E?(m=E.v,p=E.w,g=E.name,arguments.length===2&&(b=arguments[1],w=!0)):(m=E,p=arguments[1],g=arguments[3],arguments.length>2&&(b=arguments[2],w=!0)),m=""+m,p=""+p,g!==void 0&&(g=""+g);var S=s(this._isDirected,m,p,g);if(Object.hasOwn(this._edgeLabels,S))return w&&(this._edgeLabels[S]=b),this;if(g!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(m),this.setNode(p),this._edgeLabels[S]=w?b:this._defaultEdgeLabelFn(m,p,g);var _=c(this._isDirected,m,p,g);return m=_.v,p=_.w,Object.freeze(_),this._edgeObjs[S]=_,a(this._preds[p],m),a(this._sucs[m],p),this._in[p][S]=_,this._out[m][S]=_,this._edgeCount++,this}edge(m,p,g){var b=arguments.length===1?h(this._isDirected,arguments[0]):s(this._isDirected,m,p,g);return this._edgeLabels[b]}edgeAsObj(){const m=this.edge(...arguments);return typeof m!="object"?{label:m}:m}hasEdge(m,p,g){var b=arguments.length===1?h(this._isDirected,arguments[0]):s(this._isDirected,m,p,g);return Object.hasOwn(this._edgeLabels,b)}removeEdge(m,p,g){var b=arguments.length===1?h(this._isDirected,arguments[0]):s(this._isDirected,m,p,g),w=this._edgeObjs[b];return w&&(m=w.v,p=w.w,delete this._edgeLabels[b],delete this._edgeObjs[b],o(this._preds[p],m),o(this._sucs[m],p),delete this._in[p][b],delete this._out[m][b],this._edgeCount--),this}inEdges(m,p){var g=this._in[m];if(g){var b=Object.values(g);return p?b.filter(w=>w.v===p):b}}outEdges(m,p){var g=this._out[m];if(g){var b=Object.values(g);return p?b.filter(w=>w.w===p):b}}nodeEdges(m,p){var g=this.inEdges(m,p);if(g)return g.concat(this.outEdges(m,p))}}function a(f,m){f[m]?f[m]++:f[m]=1}function o(f,m){--f[m]||delete f[m]}function s(f,m,p,g){var b=""+m,w=""+p;if(!f&&b>w){var E=b;b=w,w=E}return b+n+w+n+(g===void 0?e:g)}function c(f,m,p,g){var b=""+m,w=""+p;if(!f&&b>w){var E=b;b=w,w=E}var S={v:b,w};return g&&(S.name=g),S}function h(f,m){return s(f,m.v,m.w,m.name)}return zh=l,zh}var Mh,wb;function L5(){return wb||(wb=1,Mh="2.2.4"),Mh}var Dh,_b;function H5(){return _b||(_b=1,Dh={Graph:Um(),version:L5()}),Dh}var Rh,Sb;function B5(){if(Sb)return Rh;Sb=1;var e=Um();Rh={write:t,read:a};function t(o){var s={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:n(o),edges:l(o)};return o.graph()!==void 0&&(s.value=structuredClone(o.graph())),s}function n(o){return o.nodes().map(function(s){var c=o.node(s),h=o.parent(s),f={v:s};return c!==void 0&&(f.value=c),h!==void 0&&(f.parent=h),f})}function l(o){return o.edges().map(function(s){var c=o.edge(s),h={v:s.v,w:s.w};return s.name!==void 0&&(h.name=s.name),c!==void 0&&(h.value=c),h})}function a(o){var s=new e(o.options).setGraph(o.value);return o.nodes.forEach(function(c){s.setNode(c.v,c.value),c.parent&&s.setParent(c.v,c.parent)}),o.edges.forEach(function(c){s.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),s}return Rh}var Oh,kb;function I5(){if(kb)return Oh;kb=1,Oh=e;function e(t){var n={},l=[],a;function o(s){Object.hasOwn(n,s)||(n[s]=!0,a.push(s),t.successors(s).forEach(o),t.predecessors(s).forEach(o))}return t.nodes().forEach(function(s){a=[],o(s),a.length&&l.push(a)}),l}return Oh}var Lh,Eb;function TS(){if(Eb)return Lh;Eb=1;class e{constructor(){Tt(this,"_arr",[]);Tt(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var l=this._keyIndices[n];if(l!==void 0)return this._arr[l].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,l){var a=this._keyIndices;if(n=String(n),!Object.hasOwn(a,n)){var o=this._arr,s=o.length;return a[n]=s,o.push({key:n,priority:l}),this._decrease(s),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,l){var a=this._keyIndices[n];if(l>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[a].priority+" New: "+l);this._arr[a].priority=l,this._decrease(a)}_heapify(n){var l=this._arr,a=2*n,o=a+1,s=n;a>1,!(l[o].priority1;function n(a,o,s,c){return l(a,String(o),s||t,c||function(h){return a.outEdges(h)})}function l(a,o,s,c){var h={},f=new e,m,p,g=function(b){var w=b.v!==m?b.v:b.w,E=h[w],S=s(b),_=p.distance+S;if(S<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+b+" Weight: "+S);_0&&(m=f.removeMin(),p=h[m],p.distance!==Number.POSITIVE_INFINITY);)c(m).forEach(g);return h}return Hh}var Bh,Cb;function q5(){if(Cb)return Bh;Cb=1;var e=AS();Bh=t;function t(n,l,a){return n.nodes().reduce(function(o,s){return o[s]=e(n,s,l,a),o},{})}return Bh}var Ih,jb;function zS(){if(jb)return Ih;jb=1,Ih=e;function e(t){var n=0,l=[],a={},o=[];function s(c){var h=a[c]={onStack:!0,lowlink:n,index:n++};if(l.push(c),t.successors(c).forEach(function(p){Object.hasOwn(a,p)?a[p].onStack&&(h.lowlink=Math.min(h.lowlink,a[p].index)):(s(p),h.lowlink=Math.min(h.lowlink,a[p].lowlink))}),h.lowlink===h.index){var f=[],m;do m=l.pop(),a[m].onStack=!1,f.push(m);while(c!==m);o.push(f)}}return t.nodes().forEach(function(c){Object.hasOwn(a,c)||s(c)}),o}return Ih}var qh,Tb;function $5(){if(Tb)return qh;Tb=1;var e=zS();qh=t;function t(n){return e(n).filter(function(l){return l.length>1||l.length===1&&n.hasEdge(l[0],l[0])})}return qh}var $h,Ab;function U5(){if(Ab)return $h;Ab=1,$h=t;var e=()=>1;function t(l,a,o){return n(l,a||e,o||function(s){return l.outEdges(s)})}function n(l,a,o){var s={},c=l.nodes();return c.forEach(function(h){s[h]={},s[h][h]={distance:0},c.forEach(function(f){h!==f&&(s[h][f]={distance:Number.POSITIVE_INFINITY})}),o(h).forEach(function(f){var m=f.v===h?f.w:f.v,p=a(f);s[h][m]={distance:p,predecessor:h}})}),c.forEach(function(h){var f=s[h];c.forEach(function(m){var p=s[m];c.forEach(function(g){var b=p[h],w=f[g],E=p[g],S=b.distance+w.distance;Sa.successors(p):p=>a.neighbors(p),h=s==="post"?t:n,f=[],m={};return o.forEach(p=>{if(!a.hasNode(p))throw new Error("Graph does not have node: "+p);h(p,c,m,f)}),f}function t(a,o,s,c){for(var h=[[a,!1]];h.length>0;){var f=h.pop();f[1]?c.push(f[0]):Object.hasOwn(s,f[0])||(s[f[0]]=!0,h.push([f[0],!0]),l(o(f[0]),m=>h.push([m,!1])))}}function n(a,o,s,c){for(var h=[a];h.length>0;){var f=h.pop();Object.hasOwn(s,f)||(s[f]=!0,c.push(f),l(o(f),m=>h.push(m)))}}function l(a,o){for(var s=a.length;s--;)o(a[s],s,a);return a}return Ph}var Gh,Rb;function P5(){if(Rb)return Gh;Rb=1;var e=DS();Gh=t;function t(n,l){return e(n,l,"post")}return Gh}var Fh,Ob;function G5(){if(Ob)return Fh;Ob=1;var e=DS();Fh=t;function t(n,l){return e(n,l,"pre")}return Fh}var Yh,Lb;function F5(){if(Lb)return Yh;Lb=1;var e=Um(),t=TS();Yh=n;function n(l,a){var o=new e,s={},c=new t,h;function f(p){var g=p.v===h?p.w:p.v,b=c.priority(g);if(b!==void 0){var w=a(p);w0;){if(h=c.removeMin(),Object.hasOwn(s,h))o.setEdge(h,s[h]);else{if(m)throw new Error("Input graph is not connected: "+l);m=!0}l.nodeEdges(h).forEach(f)}return o}return Yh}var Xh,Hb;function Y5(){return Hb||(Hb=1,Xh={components:I5(),dijkstra:AS(),dijkstraAll:q5(),findCycles:$5(),floydWarshall:U5(),isAcyclic:V5(),postorder:P5(),preorder:G5(),prim:F5(),tarjan:zS(),topsort:MS()}),Xh}var Qh,Bb;function Xn(){if(Bb)return Qh;Bb=1;var e=H5();return Qh={Graph:e.Graph,json:B5(),alg:Y5(),version:e.version},Qh}var Zh,Ib;function X5(){if(Ib)return Zh;Ib=1;class e{constructor(){let a={};a._next=a._prev=a,this._sentinel=a}dequeue(){let a=this._sentinel,o=a._prev;if(o!==a)return t(o),o}enqueue(a){let o=this._sentinel;a._prev&&a._next&&t(a),a._next=o._next,o._next._prev=a,o._next=a,a._prev=o}toString(){let a=[],o=this._sentinel,s=o._prev;for(;s!==o;)a.push(JSON.stringify(s,n)),s=s._prev;return"["+a.join(", ")+"]"}}function t(l){l._prev._next=l._next,l._next._prev=l._prev,delete l._next,delete l._prev}function n(l,a){if(l!=="_next"&&l!=="_prev")return a}return Zh=e,Zh}var Kh,qb;function Q5(){if(qb)return Kh;qb=1;let e=Xn().Graph,t=X5();Kh=l;let n=()=>1;function l(f,m){if(f.nodeCount()<=1)return[];let p=s(f,m||n);return a(p.graph,p.buckets,p.zeroIdx).flatMap(b=>f.outEdges(b.v,b.w))}function a(f,m,p){let g=[],b=m[m.length-1],w=m[0],E;for(;f.nodeCount();){for(;E=w.dequeue();)o(f,m,p,E);for(;E=b.dequeue();)o(f,m,p,E);if(f.nodeCount()){for(let S=m.length-2;S>0;--S)if(E=m[S].dequeue(),E){g=g.concat(o(f,m,p,E,!0));break}}}return g}function o(f,m,p,g,b){let w=b?[]:void 0;return f.inEdges(g.v).forEach(E=>{let S=f.edge(E),_=f.node(E.v);b&&w.push({v:E.v,w:E.w}),_.out-=S,c(m,p,_)}),f.outEdges(g.v).forEach(E=>{let S=f.edge(E),_=E.w,N=f.node(_);N.in-=S,c(m,p,N)}),f.removeNode(g.v),w}function s(f,m){let p=new e,g=0,b=0;f.nodes().forEach(S=>{p.setNode(S,{v:S,in:0,out:0})}),f.edges().forEach(S=>{let _=p.edge(S.v,S.w)||0,N=m(S),k=_+N;p.setEdge(S.v,S.w,k),b=Math.max(b,p.node(S.v).out+=N),g=Math.max(g,p.node(S.w).in+=N)});let w=h(b+g+3).map(()=>new t),E=g+1;return p.nodes().forEach(S=>{c(w,E,p.node(S))}),{graph:p,buckets:w,zeroIdx:E}}function c(f,m,p){p.out?p.in?f[p.out-p.in+m].enqueue(p):f[f.length-1].enqueue(p):f[0].enqueue(p)}function h(f){const m=[];for(let p=0;pV.setNode(H,R.node(H))),R.edges().forEach(H=>{let B=V.edge(H.v,H.w)||{weight:0,minlen:1},U=R.edge(H);V.setEdge(H.v,H.w,{weight:B.weight+U.weight,minlen:Math.max(B.minlen,U.minlen)})}),V}function l(R){let V=new e({multigraph:R.isMultigraph()}).setGraph(R.graph());return R.nodes().forEach(H=>{R.children(H).length||V.setNode(H,R.node(H))}),R.edges().forEach(H=>{V.setEdge(H,R.edge(H))}),V}function a(R){let V=R.nodes().map(H=>{let B={};return R.outEdges(H).forEach(U=>{B[U.w]=(B[U.w]||0)+R.edge(U).weight}),B});return L(R.nodes(),V)}function o(R){let V=R.nodes().map(H=>{let B={};return R.inEdges(H).forEach(U=>{B[U.v]=(B[U.v]||0)+R.edge(U).weight}),B});return L(R.nodes(),V)}function s(R,V){let H=R.x,B=R.y,U=V.x-H,ee=V.y-B,q=R.width/2,F=R.height/2;if(!U&&!ee)throw new Error("Not possible to find intersection inside of the rectangle");let z,G;return Math.abs(ee)*q>Math.abs(U)*F?(ee<0&&(F=-F),z=F*U/ee,G=F):(U<0&&(q=-q),z=q,G=q*ee/U),{x:H+z,y:B+G}}function c(R){let V=T(w(R)+1).map(()=>[]);return R.nodes().forEach(H=>{let B=R.node(H),U=B.rank;U!==void 0&&(V[U][B.order]=H)}),V}function h(R){let V=R.nodes().map(B=>{let U=R.node(B).rank;return U===void 0?Number.MAX_VALUE:U}),H=b(Math.min,V);R.nodes().forEach(B=>{let U=R.node(B);Object.hasOwn(U,"rank")&&(U.rank-=H)})}function f(R){let V=R.nodes().map(q=>R.node(q).rank),H=b(Math.min,V),B=[];R.nodes().forEach(q=>{let F=R.node(q).rank-H;B[F]||(B[F]=[]),B[F].push(q)});let U=0,ee=R.graph().nodeRankFactor;Array.from(B).forEach((q,F)=>{q===void 0&&F%ee!==0?--U:q!==void 0&&U&&q.forEach(z=>R.node(z).rank+=U)})}function m(R,V,H,B){let U={width:0,height:0};return arguments.length>=4&&(U.rank=H,U.order=B),t(R,"border",U,V)}function p(R,V=g){const H=[];for(let B=0;Bg){const H=p(V);return R.apply(null,H.map(B=>R.apply(null,B)))}else return R.apply(null,V)}function w(R){const H=R.nodes().map(B=>{let U=R.node(B).rank;return U===void 0?Number.MIN_VALUE:U});return b(Math.max,H)}function E(R,V){let H={lhs:[],rhs:[]};return R.forEach(B=>{V(B)?H.lhs.push(B):H.rhs.push(B)}),H}function S(R,V){let H=Date.now();try{return V()}finally{console.log(R+" time: "+(Date.now()-H)+"ms")}}function _(R,V){return V()}let N=0;function k(R){var V=++N;return R+(""+V)}function T(R,V,H=1){V==null&&(V=R,R=0);let B=ee=>eeVB[V]),Object.entries(R).reduce((B,[U,ee])=>(B[U]=H(ee,U),B),{})}function L(R,V){return R.reduce((H,B,U)=>(H[B]=V[U],H),{})}return Jh}var Wh,Ub;function Z5(){if(Ub)return Wh;Ub=1;let e=Q5(),t=zt().uniqueId;Wh={run:n,undo:a};function n(o){(o.graph().acyclicer==="greedy"?e(o,c(o)):l(o)).forEach(h=>{let f=o.edge(h);o.removeEdge(h),f.forwardName=h.name,f.reversed=!0,o.setEdge(h.w,h.v,f,t("rev"))});function c(h){return f=>h.edge(f).weight}}function l(o){let s=[],c={},h={};function f(m){Object.hasOwn(h,m)||(h[m]=!0,c[m]=!0,o.outEdges(m).forEach(p=>{Object.hasOwn(c,p.w)?s.push(p):f(p.w)}),delete c[m])}return o.nodes().forEach(f),s}function a(o){o.edges().forEach(s=>{let c=o.edge(s);if(c.reversed){o.removeEdge(s);let h=c.forwardName;delete c.reversed,delete c.forwardName,o.setEdge(s.w,s.v,c,h)}})}return Wh}var ep,Vb;function K5(){if(Vb)return ep;Vb=1;let e=zt();ep={run:t,undo:l};function t(a){a.graph().dummyChains=[],a.edges().forEach(o=>n(a,o))}function n(a,o){let s=o.v,c=a.node(s).rank,h=o.w,f=a.node(h).rank,m=o.name,p=a.edge(o),g=p.labelRank;if(f===c+1)return;a.removeEdge(o);let b,w,E;for(E=0,++c;c{let s=a.node(o),c=s.edgeLabel,h;for(a.setEdge(s.edgeObj,c);s.dummy;)h=a.successors(o)[0],a.removeNode(o),c.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(c.x=s.x,c.y=s.y,c.width=s.width,c.height=s.height),o=h,s=a.node(o)})}return ep}var tp,Pb;function vc(){if(Pb)return tp;Pb=1;const{applyWithChunking:e}=zt();tp={longestPath:t,slack:n};function t(l){var a={};function o(s){var c=l.node(s);if(Object.hasOwn(a,s))return c.rank;a[s]=!0;let h=l.outEdges(s).map(m=>m==null?Number.POSITIVE_INFINITY:o(m.w)-l.edge(m).minlen);var f=e(Math.min,h);return f===Number.POSITIVE_INFINITY&&(f=0),c.rank=f}l.sources().forEach(o)}function n(l,a){return l.node(a.w).rank-l.node(a.v).rank-l.edge(a).minlen}return tp}var np,Gb;function RS(){if(Gb)return np;Gb=1;var e=Xn().Graph,t=vc().slack;np=n;function n(s){var c=new e({directed:!1}),h=s.nodes()[0],f=s.nodeCount();c.setNode(h,{});for(var m,p;l(c,s){var p=m.v,g=f===p?m.w:p;!s.hasNode(g)&&!t(c,m)&&(s.setNode(g,{}),s.setEdge(f,g,{}),h(g))})}return s.nodes().forEach(h),s.nodeCount()}function a(s,c){return c.edges().reduce((f,m)=>{let p=Number.POSITIVE_INFINITY;return s.hasNode(m.v)!==s.hasNode(m.w)&&(p=t(c,m)),pc.node(f).rank+=h)}return np}var rp,Fb;function J5(){if(Fb)return rp;Fb=1;var e=RS(),t=vc().slack,n=vc().longestPath,l=Xn().alg.preorder,a=Xn().alg.postorder,o=zt().simplify;rp=s,s.initLowLimValues=m,s.initCutValues=c,s.calcCutValue=f,s.leaveEdge=g,s.enterEdge=b,s.exchangeEdges=w;function s(N){N=o(N),n(N);var k=e(N);m(k),c(k,N);for(var T,M;T=g(k);)M=b(k,N,T),w(k,N,T,M)}function c(N,k){var T=a(N,N.nodes());T=T.slice(0,T.length-1),T.forEach(M=>h(N,k,M))}function h(N,k,T){var M=N.node(T),A=M.parent;N.edge(T,A).cutvalue=f(N,k,T)}function f(N,k,T){var M=N.node(T),A=M.parent,L=!0,R=k.edge(T,A),V=0;return R||(L=!1,R=k.edge(A,T)),V=R.weight,k.nodeEdges(T).forEach(H=>{var B=H.v===T,U=B?H.w:H.v;if(U!==A){var ee=B===L,q=k.edge(H).weight;if(V+=ee?q:-q,S(N,T,U)){var F=N.edge(T,U).cutvalue;V+=ee?-F:F}}}),V}function m(N,k){arguments.length<2&&(k=N.nodes()[0]),p(N,{},1,k)}function p(N,k,T,M,A){var L=T,R=N.node(M);return k[M]=!0,N.neighbors(M).forEach(V=>{Object.hasOwn(k,V)||(T=p(N,k,T,V,M))}),R.low=L,R.lim=T++,A?R.parent=A:delete R.parent,T}function g(N){return N.edges().find(k=>N.edge(k).cutvalue<0)}function b(N,k,T){var M=T.v,A=T.w;k.hasEdge(M,A)||(M=T.w,A=T.v);var L=N.node(M),R=N.node(A),V=L,H=!1;L.lim>R.lim&&(V=R,H=!0);var B=k.edges().filter(U=>H===_(N,N.node(U.v),V)&&H!==_(N,N.node(U.w),V));return B.reduce((U,ee)=>t(k,ee)!k.node(A).parent),M=l(N,T);M=M.slice(1),M.forEach(A=>{var L=N.node(A).parent,R=k.edge(A,L),V=!1;R||(R=k.edge(L,A),V=!0),k.node(A).rank=k.node(L).rank+(V?R.minlen:-R.minlen)})}function S(N,k,T){return N.hasEdge(k,T)}function _(N,k,T){return T.low<=k.lim&&k.lim<=T.lim}return rp}var ip,Yb;function W5(){if(Yb)return ip;Yb=1;var e=vc(),t=e.longestPath,n=RS(),l=J5();ip=a;function a(h){var f=h.graph().ranker;if(f instanceof Function)return f(h);switch(h.graph().ranker){case"network-simplex":c(h);break;case"tight-tree":s(h);break;case"longest-path":o(h);break;case"none":break;default:c(h)}}var o=t;function s(h){t(h),n(h)}function c(h){l(h)}return ip}var lp,Xb;function e4(){if(Xb)return lp;Xb=1,lp=e;function e(l){let a=n(l);l.graph().dummyChains.forEach(o=>{let s=l.node(o),c=s.edgeObj,h=t(l,a,c.v,c.w),f=h.path,m=h.lca,p=0,g=f[p],b=!0;for(;o!==c.w;){if(s=l.node(o),b){for(;(g=f[p])!==m&&l.node(g).maxRankf||m>a[p].lim));for(g=p,p=s;(p=l.parent(p))!==g;)h.push(p);return{path:c.concat(h.reverse()),lca:g}}function n(l){let a={},o=0;function s(c){let h=o;l.children(c).forEach(s),a[c]={low:h,lim:o++}}return l.children().forEach(s),a}return lp}var ap,Qb;function t4(){if(Qb)return ap;Qb=1;let e=zt();ap={run:t,cleanup:o};function t(s){let c=e.addDummyNode(s,"root",{},"_root"),h=l(s),f=Object.values(h),m=e.applyWithChunking(Math.max,f)-1,p=2*m+1;s.graph().nestingRoot=c,s.edges().forEach(b=>s.edge(b).minlen*=p);let g=a(s)+1;s.children().forEach(b=>n(s,c,p,g,m,h,b)),s.graph().nodeRankFactor=p}function n(s,c,h,f,m,p,g){let b=s.children(g);if(!b.length){g!==c&&s.setEdge(c,g,{weight:0,minlen:h});return}let w=e.addBorderNode(s,"_bt"),E=e.addBorderNode(s,"_bb"),S=s.node(g);s.setParent(w,g),S.borderTop=w,s.setParent(E,g),S.borderBottom=E,b.forEach(_=>{n(s,c,h,f,m,p,_);let N=s.node(_),k=N.borderTop?N.borderTop:_,T=N.borderBottom?N.borderBottom:_,M=N.borderTop?f:2*f,A=k!==T?1:m-p[g]+1;s.setEdge(w,k,{weight:M,minlen:A,nestingEdge:!0}),s.setEdge(T,E,{weight:M,minlen:A,nestingEdge:!0})}),s.parent(g)||s.setEdge(c,w,{weight:0,minlen:m+p[g]})}function l(s){var c={};function h(f,m){var p=s.children(f);p&&p.length&&p.forEach(g=>h(g,m+1)),c[f]=m}return s.children().forEach(f=>h(f,1)),c}function a(s){return s.edges().reduce((c,h)=>c+s.edge(h).weight,0)}function o(s){var c=s.graph();s.removeNode(c.nestingRoot),delete c.nestingRoot,s.edges().forEach(h=>{var f=s.edge(h);f.nestingEdge&&s.removeEdge(h)})}return ap}var op,Zb;function n4(){if(Zb)return op;Zb=1;let e=zt();op=t;function t(l){function a(o){let s=l.children(o),c=l.node(o);if(s.length&&s.forEach(a),Object.hasOwn(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(let h=c.minRank,f=c.maxRank+1;hl(h.node(f))),h.edges().forEach(f=>l(h.edge(f)))}function l(h){let f=h.width;h.width=h.height,h.height=f}function a(h){h.nodes().forEach(f=>o(h.node(f))),h.edges().forEach(f=>{let m=h.edge(f);m.points.forEach(o),Object.hasOwn(m,"y")&&o(m)})}function o(h){h.y=-h.y}function s(h){h.nodes().forEach(f=>c(h.node(f))),h.edges().forEach(f=>{let m=h.edge(f);m.points.forEach(c),Object.hasOwn(m,"x")&&c(m)})}function c(h){let f=h.x;h.x=h.y,h.y=f}return sp}var up,Jb;function i4(){if(Jb)return up;Jb=1;let e=zt();up=t;function t(n){let l={},a=n.nodes().filter(m=>!n.children(m).length),o=a.map(m=>n.node(m).rank),s=e.applyWithChunking(Math.max,o),c=e.range(s+1).map(()=>[]);function h(m){if(l[m])return;l[m]=!0;let p=n.node(m);c[p.rank].push(m),n.successors(m).forEach(h)}return a.sort((m,p)=>n.node(m).rank-n.node(p).rank).forEach(h),c}return up}var cp,Wb;function l4(){if(Wb)return cp;Wb=1;let e=zt().zipObject;cp=t;function t(l,a){let o=0;for(let s=1;sb)),c=a.flatMap(g=>l.outEdges(g).map(b=>({pos:s[b.w],weight:l.edge(b).weight})).sort((b,w)=>b.pos-w.pos)),h=1;for(;h{let b=g.pos+h;m[b]+=g.weight;let w=0;for(;b>0;)b%2&&(w+=m[b+1]),b=b-1>>1,m[b]+=g.weight;p+=g.weight*w}),p}return cp}var fp,e1;function a4(){if(e1)return fp;e1=1,fp=e;function e(t,n=[]){return n.map(l=>{let a=t.inEdges(l);if(a.length){let o=a.reduce((s,c)=>{let h=t.edge(c),f=t.node(c.v);return{sum:s.sum+h.weight*f.order,weight:s.weight+h.weight}},{sum:0,weight:0});return{v:l,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:l}})}return fp}var dp,t1;function o4(){if(t1)return dp;t1=1;let e=zt();dp=t;function t(a,o){let s={};a.forEach((h,f)=>{let m=s[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:f};h.barycenter!==void 0&&(m.barycenter=h.barycenter,m.weight=h.weight)}),o.edges().forEach(h=>{let f=s[h.v],m=s[h.w];f!==void 0&&m!==void 0&&(m.indegree++,f.out.push(s[h.w]))});let c=Object.values(s).filter(h=>!h.indegree);return n(c)}function n(a){let o=[];function s(h){return f=>{f.merged||(f.barycenter===void 0||h.barycenter===void 0||f.barycenter>=h.barycenter)&&l(h,f)}}function c(h){return f=>{f.in.push(h),--f.indegree===0&&a.push(f)}}for(;a.length;){let h=a.pop();o.push(h),h.in.reverse().forEach(s(h)),h.out.forEach(c(h))}return o.filter(h=>!h.merged).map(h=>e.pick(h,["vs","i","barycenter","weight"]))}function l(a,o){let s=0,c=0;a.weight&&(s+=a.barycenter*a.weight,c+=a.weight),o.weight&&(s+=o.barycenter*o.weight,c+=o.weight),a.vs=o.vs.concat(a.vs),a.barycenter=s/c,a.weight=c,a.i=Math.min(o.i,a.i),o.merged=!0}return dp}var hp,n1;function s4(){if(n1)return hp;n1=1;let e=zt();hp=t;function t(a,o){let s=e.partition(a,w=>Object.hasOwn(w,"barycenter")),c=s.lhs,h=s.rhs.sort((w,E)=>E.i-w.i),f=[],m=0,p=0,g=0;c.sort(l(!!o)),g=n(f,h,g),c.forEach(w=>{g+=w.vs.length,f.push(w.vs),m+=w.barycenter*w.weight,p+=w.weight,g=n(f,h,g)});let b={vs:f.flat(!0)};return p&&(b.barycenter=m/p,b.weight=p),b}function n(a,o,s){let c;for(;o.length&&(c=o[o.length-1]).i<=s;)o.pop(),a.push(c.vs),s++;return s}function l(a){return(o,s)=>o.barycenters.barycenter?1:a?s.i-o.i:o.i-s.i}return hp}var pp,r1;function u4(){if(r1)return pp;r1=1;let e=a4(),t=o4(),n=s4();pp=l;function l(s,c,h,f){let m=s.children(c),p=s.node(c),g=p?p.borderLeft:void 0,b=p?p.borderRight:void 0,w={};g&&(m=m.filter(N=>N!==g&&N!==b));let E=e(s,m);E.forEach(N=>{if(s.children(N.v).length){let k=l(s,N.v,h,f);w[N.v]=k,Object.hasOwn(k,"barycenter")&&o(N,k)}});let S=t(E,h);a(S,w);let _=n(S,f);if(g&&(_.vs=[g,_.vs,b].flat(!0),s.predecessors(g).length)){let N=s.node(s.predecessors(g)[0]),k=s.node(s.predecessors(b)[0]);Object.hasOwn(_,"barycenter")||(_.barycenter=0,_.weight=0),_.barycenter=(_.barycenter*_.weight+N.order+k.order)/(_.weight+2),_.weight+=2}return _}function a(s,c){s.forEach(h=>{h.vs=h.vs.flatMap(f=>c[f]?c[f].vs:f)})}function o(s,c){s.barycenter!==void 0?(s.barycenter=(s.barycenter*s.weight+c.barycenter*c.weight)/(s.weight+c.weight),s.weight+=c.weight):(s.barycenter=c.barycenter,s.weight=c.weight)}return pp}var mp,i1;function c4(){if(i1)return mp;i1=1;let e=Xn().Graph,t=zt();mp=n;function n(a,o,s,c){c||(c=a.nodes());let h=l(a),f=new e({compound:!0}).setGraph({root:h}).setDefaultNodeLabel(m=>a.node(m));return c.forEach(m=>{let p=a.node(m),g=a.parent(m);(p.rank===o||p.minRank<=o&&o<=p.maxRank)&&(f.setNode(m),f.setParent(m,g||h),a[s](m).forEach(b=>{let w=b.v===m?b.w:b.v,E=f.edge(w,m),S=E!==void 0?E.weight:0;f.setEdge(w,m,{weight:a.edge(b).weight+S})}),Object.hasOwn(p,"minRank")&&f.setNode(m,{borderLeft:p.borderLeft[o],borderRight:p.borderRight[o]}))}),f}function l(a){for(var o;a.hasNode(o=t.uniqueId("_root")););return o}return mp}var gp,l1;function f4(){if(l1)return gp;l1=1,gp=e;function e(t,n,l){let a={},o;l.forEach(s=>{let c=t.parent(s),h,f;for(;c;){if(h=t.parent(c),h?(f=a[h],a[h]=c):(f=o,o=c),f&&f!==c){n.setEdge(f,c);return}c=h}})}return gp}var xp,a1;function d4(){if(a1)return xp;a1=1;let e=i4(),t=l4(),n=u4(),l=c4(),a=f4(),o=Xn().Graph,s=zt();xp=c;function c(p,g){if(g&&typeof g.customOrder=="function"){g.customOrder(p,c);return}let b=s.maxRank(p),w=h(p,s.range(1,b+1),"inEdges"),E=h(p,s.range(b-1,-1,-1),"outEdges"),S=e(p);if(m(p,S),g&&g.disableOptimalOrderHeuristic)return;let _=Number.POSITIVE_INFINITY,N;for(let k=0,T=0;T<4;++k,++T){f(k%2?w:E,k%4>=2),S=s.buildLayerMatrix(p);let M=t(p,S);M<_&&(T=0,N=Object.assign({},S),_=M)}m(p,N)}function h(p,g,b){const w=new Map,E=(S,_)=>{w.has(S)||w.set(S,[]),w.get(S).push(_)};for(const S of p.nodes()){const _=p.node(S);if(typeof _.rank=="number"&&E(_.rank,S),typeof _.minRank=="number"&&typeof _.maxRank=="number")for(let N=_.minRank;N<=_.maxRank;N++)N!==_.rank&&E(N,S)}return g.map(function(S){return l(p,S,b,w.get(S)||[])})}function f(p,g){let b=new o;p.forEach(function(w){let E=w.graph().root,S=n(w,E,b,g);S.vs.forEach((_,N)=>w.node(_).order=N),a(w,b,S.vs)})}function m(p,g){Object.values(g).forEach(b=>b.forEach((w,E)=>p.node(w).order=E))}return xp}var yp,o1;function h4(){if(o1)return yp;o1=1;let e=Xn().Graph,t=zt();yp={positionX:b,findType1Conflicts:n,findType2Conflicts:l,addConflict:o,hasConflict:s,verticalAlignment:c,horizontalCompaction:h,alignCoordinates:p,findSmallestWidthAlignment:m,balance:g};function n(S,_){let N={};function k(T,M){let A=0,L=0,R=T.length,V=M[M.length-1];return M.forEach((H,B)=>{let U=a(S,H),ee=U?S.node(U).order:R;(U||H===V)&&(M.slice(L,B+1).forEach(q=>{S.predecessors(q).forEach(F=>{let z=S.node(F),G=z.order;(G{H=M[B],S.node(H).dummy&&S.predecessors(H).forEach(U=>{let ee=S.node(U);ee.dummy&&(ee.orderV)&&o(N,U,H)})})}function T(M,A){let L=-1,R,V=0;return A.forEach((H,B)=>{if(S.node(H).dummy==="border"){let U=S.predecessors(H);U.length&&(R=S.node(U[0]).order,k(A,V,B,L,R),V=B,L=R)}k(A,V,A.length,R,M.length)}),A}return _.length&&_.reduce(T),N}function a(S,_){if(S.node(_).dummy)return S.predecessors(_).find(N=>S.node(N).dummy)}function o(S,_,N){if(_>N){let T=_;_=N,N=T}let k=S[_];k||(S[_]=k={}),k[N]=!0}function s(S,_,N){if(_>N){let k=_;_=N,N=k}return!!S[_]&&Object.hasOwn(S[_],N)}function c(S,_,N,k){let T={},M={},A={};return _.forEach(L=>{L.forEach((R,V)=>{T[R]=R,M[R]=R,A[R]=V})}),_.forEach(L=>{let R=-1;L.forEach(V=>{let H=k(V);if(H.length){H=H.sort((U,ee)=>A[U]-A[ee]);let B=(H.length-1)/2;for(let U=Math.floor(B),ee=Math.ceil(B);U<=ee;++U){let q=H[U];M[V]===V&&RMath.max(U,M[ee.v]+A.edge(ee)),0)}function H(B){let U=A.outEdges(B).reduce((q,F)=>Math.min(q,M[F.w]-A.edge(F)),Number.POSITIVE_INFINITY),ee=S.node(B);U!==Number.POSITIVE_INFINITY&&ee.borderType!==L&&(M[B]=Math.max(M[B],U))}return R(V,A.predecessors.bind(A)),R(H,A.successors.bind(A)),Object.keys(k).forEach(B=>M[B]=M[N[B]]),M}function f(S,_,N,k){let T=new e,M=S.graph(),A=w(M.nodesep,M.edgesep,k);return _.forEach(L=>{let R;L.forEach(V=>{let H=N[V];if(T.setNode(H),R){var B=N[R],U=T.edge(B,H);T.setEdge(B,H,Math.max(A(S,V,R),U||0))}R=V})}),T}function m(S,_){return Object.values(_).reduce((N,k)=>{let T=Number.NEGATIVE_INFINITY,M=Number.POSITIVE_INFINITY;Object.entries(k).forEach(([L,R])=>{let V=E(S,L)/2;T=Math.max(R+V,T),M=Math.min(R-V,M)});const A=T-M;return A{["l","r"].forEach(A=>{let L=M+A,R=S[L];if(R===_)return;let V=Object.values(R),H=k-t.applyWithChunking(Math.min,V);A!=="l"&&(H=T-t.applyWithChunking(Math.max,V)),H&&(S[L]=t.mapValues(R,B=>B+H))})})}function g(S,_){return t.mapValues(S.ul,(N,k)=>{if(_)return S[_.toLowerCase()][k];{let T=Object.values(S).map(M=>M[k]).sort((M,A)=>M-A);return(T[1]+T[2])/2}})}function b(S){let _=t.buildLayerMatrix(S),N=Object.assign(n(S,_),l(S,_)),k={},T;["u","d"].forEach(A=>{T=A==="u"?_:Object.values(_).reverse(),["l","r"].forEach(L=>{L==="r"&&(T=T.map(B=>Object.values(B).reverse()));let R=(A==="u"?S.predecessors:S.successors).bind(S),V=c(S,T,N,R),H=h(S,T,V.root,V.align,L==="r");L==="r"&&(H=t.mapValues(H,B=>-B)),k[A+L]=H})});let M=m(S,k);return p(k,M),g(k,S.graph().align)}function w(S,_,N){return(k,T,M)=>{let A=k.node(T),L=k.node(M),R=0,V;if(R+=A.width/2,Object.hasOwn(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":V=-A.width/2;break;case"r":V=A.width/2;break}if(V&&(R+=N?V:-V),V=0,R+=(A.dummy?_:S)/2,R+=(L.dummy?_:S)/2,R+=L.width/2,Object.hasOwn(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":V=L.width/2;break;case"r":V=-L.width/2;break}return V&&(R+=N?V:-V),V=0,R}}function E(S,_){return S.node(_).width}return yp}var vp,s1;function p4(){if(s1)return vp;s1=1;let e=zt(),t=h4().positionX;vp=n;function n(a){a=e.asNonCompoundGraph(a),l(a),Object.entries(t(a)).forEach(([o,s])=>a.node(o).x=s)}function l(a){let o=e.buildLayerMatrix(a),s=a.graph().ranksep,c=0;o.forEach(h=>{const f=h.reduce((m,p)=>{const g=a.node(p).height;return m>g?m:g},0);h.forEach(m=>a.node(m).y=c+f/2),c+=f+s})}return vp}var bp,u1;function m4(){if(u1)return bp;u1=1;let e=Z5(),t=K5(),n=W5(),l=zt().normalizeRanks,a=e4(),o=zt().removeEmptyRanks,s=t4(),c=n4(),h=r4(),f=d4(),m=p4(),p=zt(),g=Xn().Graph;bp=b;function b(C,P){let X=P&&P.debugTiming?p.time:p.notime;X("layout",()=>{let J=X(" buildLayoutGraph",()=>R(C));X(" runLayout",()=>w(J,X,P)),X(" updateInputGraph",()=>E(C,J))})}function w(C,P,X){P(" makeSpaceForEdgeLabels",()=>V(C)),P(" removeSelfEdges",()=>Q(C)),P(" acyclic",()=>e.run(C)),P(" nestingGraph.run",()=>s.run(C)),P(" rank",()=>n(p.asNonCompoundGraph(C))),P(" injectEdgeLabelProxies",()=>H(C)),P(" removeEmptyRanks",()=>o(C)),P(" nestingGraph.cleanup",()=>s.cleanup(C)),P(" normalizeRanks",()=>l(C)),P(" assignRankMinMax",()=>B(C)),P(" removeEdgeLabelProxies",()=>U(C)),P(" normalize.run",()=>t.run(C)),P(" parentDummyChains",()=>a(C)),P(" addBorderSegments",()=>c(C)),P(" order",()=>f(C,X)),P(" insertSelfEdges",()=>K(C)),P(" adjustCoordinateSystem",()=>h.adjust(C)),P(" position",()=>m(C)),P(" positionSelfEdges",()=>D(C)),P(" removeBorderNodes",()=>G(C)),P(" normalize.undo",()=>t.undo(C)),P(" fixupEdgeLabelCoords",()=>F(C)),P(" undoCoordinateSystem",()=>h.undo(C)),P(" translateGraph",()=>ee(C)),P(" assignNodeIntersects",()=>q(C)),P(" reversePoints",()=>z(C)),P(" acyclic.undo",()=>e.undo(C))}function E(C,P){C.nodes().forEach(X=>{let J=C.node(X),ne=P.node(X);J&&(J.x=ne.x,J.y=ne.y,J.rank=ne.rank,P.children(X).length&&(J.width=ne.width,J.height=ne.height))}),C.edges().forEach(X=>{let J=C.edge(X),ne=P.edge(X);J.points=ne.points,Object.hasOwn(ne,"x")&&(J.x=ne.x,J.y=ne.y)}),C.graph().width=P.graph().width,C.graph().height=P.graph().height}let S=["nodesep","edgesep","ranksep","marginx","marginy"],_={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["acyclicer","ranker","rankdir","align"],k=["width","height","rank"],T={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],A={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},L=["labelpos"];function R(C){let P=new g({multigraph:!0,compound:!0}),X=Y(C.graph());return P.setGraph(Object.assign({},_,$(X,S),p.pick(X,N))),C.nodes().forEach(J=>{let ne=Y(C.node(J));const re=$(ne,k);Object.keys(T).forEach(ue=>{re[ue]===void 0&&(re[ue]=T[ue])}),P.setNode(J,re),P.setParent(J,C.parent(J))}),C.edges().forEach(J=>{let ne=Y(C.edge(J));P.setEdge(J,Object.assign({},A,$(ne,M),p.pick(ne,L)))}),P}function V(C){let P=C.graph();P.ranksep/=2,C.edges().forEach(X=>{let J=C.edge(X);J.minlen*=2,J.labelpos.toLowerCase()!=="c"&&(P.rankdir==="TB"||P.rankdir==="BT"?J.width+=J.labeloffset:J.height+=J.labeloffset)})}function H(C){C.edges().forEach(P=>{let X=C.edge(P);if(X.width&&X.height){let J=C.node(P.v),re={rank:(C.node(P.w).rank-J.rank)/2+J.rank,e:P};p.addDummyNode(C,"edge-proxy",re,"_ep")}})}function B(C){let P=0;C.nodes().forEach(X=>{let J=C.node(X);J.borderTop&&(J.minRank=C.node(J.borderTop).rank,J.maxRank=C.node(J.borderBottom).rank,P=Math.max(P,J.maxRank))}),C.graph().maxRank=P}function U(C){C.nodes().forEach(P=>{let X=C.node(P);X.dummy==="edge-proxy"&&(C.edge(X.e).labelRank=X.rank,C.removeNode(P))})}function ee(C){let P=Number.POSITIVE_INFINITY,X=0,J=Number.POSITIVE_INFINITY,ne=0,re=C.graph(),ue=re.marginx||0,xe=re.marginy||0;function be(ye){let pe=ye.x,Se=ye.y,Oe=ye.width,Te=ye.height;P=Math.min(P,pe-Oe/2),X=Math.max(X,pe+Oe/2),J=Math.min(J,Se-Te/2),ne=Math.max(ne,Se+Te/2)}C.nodes().forEach(ye=>be(C.node(ye))),C.edges().forEach(ye=>{let pe=C.edge(ye);Object.hasOwn(pe,"x")&&be(pe)}),P-=ue,J-=xe,C.nodes().forEach(ye=>{let pe=C.node(ye);pe.x-=P,pe.y-=J}),C.edges().forEach(ye=>{let pe=C.edge(ye);pe.points.forEach(Se=>{Se.x-=P,Se.y-=J}),Object.hasOwn(pe,"x")&&(pe.x-=P),Object.hasOwn(pe,"y")&&(pe.y-=J)}),re.width=X-P+ue,re.height=ne-J+xe}function q(C){C.edges().forEach(P=>{let X=C.edge(P),J=C.node(P.v),ne=C.node(P.w),re,ue;X.points?(re=X.points[0],ue=X.points[X.points.length-1]):(X.points=[],re=ne,ue=J),X.points.unshift(p.intersectRect(J,re)),X.points.push(p.intersectRect(ne,ue))})}function F(C){C.edges().forEach(P=>{let X=C.edge(P);if(Object.hasOwn(X,"x"))switch((X.labelpos==="l"||X.labelpos==="r")&&(X.width-=X.labeloffset),X.labelpos){case"l":X.x-=X.width/2+X.labeloffset;break;case"r":X.x+=X.width/2+X.labeloffset;break}})}function z(C){C.edges().forEach(P=>{let X=C.edge(P);X.reversed&&X.points.reverse()})}function G(C){C.nodes().forEach(P=>{if(C.children(P).length){let X=C.node(P),J=C.node(X.borderTop),ne=C.node(X.borderBottom),re=C.node(X.borderLeft[X.borderLeft.length-1]),ue=C.node(X.borderRight[X.borderRight.length-1]);X.width=Math.abs(ue.x-re.x),X.height=Math.abs(ne.y-J.y),X.x=re.x+X.width/2,X.y=J.y+X.height/2}}),C.nodes().forEach(P=>{C.node(P).dummy==="border"&&C.removeNode(P)})}function Q(C){C.edges().forEach(P=>{if(P.v===P.w){var X=C.node(P.v);X.selfEdges||(X.selfEdges=[]),X.selfEdges.push({e:P,label:C.edge(P)}),C.removeEdge(P)}})}function K(C){var P=p.buildLayerMatrix(C);P.forEach(X=>{var J=0;X.forEach((ne,re)=>{var ue=C.node(ne);ue.order=re+J,(ue.selfEdges||[]).forEach(xe=>{p.addDummyNode(C,"selfedge",{width:xe.label.width,height:xe.label.height,rank:ue.rank,order:re+ ++J,e:xe.e,label:xe.label},"_se")}),delete ue.selfEdges})})}function D(C){C.nodes().forEach(P=>{var X=C.node(P);if(X.dummy==="selfedge"){var J=C.node(X.e.v),ne=J.x+J.width/2,re=J.y,ue=X.x-ne,xe=J.height/2;C.setEdge(X.e,X.label),C.removeNode(P),X.label.points=[{x:ne+2*ue/3,y:re-xe},{x:ne+5*ue/6,y:re-xe},{x:ne+ue,y:re},{x:ne+5*ue/6,y:re+xe},{x:ne+2*ue/3,y:re+xe}],X.label.x=X.x,X.label.y=X.y}})}function $(C,P){return p.mapValues(p.pick(C,P),Number)}function Y(C){var P={};return C&&Object.entries(C).forEach(([X,J])=>{typeof X=="string"&&(X=X.toLowerCase()),P[X]=J}),P}return bp}var wp,c1;function g4(){if(c1)return wp;c1=1;let e=zt(),t=Xn().Graph;wp={debugOrdering:n};function n(l){let a=e.buildLayerMatrix(l),o=new t({compound:!0,multigraph:!0}).setGraph({});return l.nodes().forEach(s=>{o.setNode(s,{label:s}),o.setParent(s,"layer"+l.node(s).rank)}),l.edges().forEach(s=>o.setEdge(s.v,s.w,{},s.name)),a.forEach((s,c)=>{let h="layer"+c;o.setNode(h,{rank:"same"}),s.reduce((f,m)=>(o.setEdge(f,m,{style:"invis"}),m))}),o}return wp}var _p,f1;function x4(){return f1||(f1=1,_p="1.1.8"),_p}var Sp,d1;function y4(){return d1||(d1=1,Sp={graphlib:Xn(),layout:m4(),debug:g4(),util:{time:zt().time,notime:zt().notime},version:x4()}),Sp}var v4=y4();const h1=Ko(v4),Mo=200,sa=56,p1=20,m1=40,b4=20,g1=12;function w4(e,t,n,l,a,o,s,c){const h=[],f=[],m=new Set,p=new Set,g=new Map;for(const N of n)for(const k of N.agents)p.add(k),g.set(k,N.name);for(const N of n){const k=a[N.name],T=N.agents.length,M=Mo+p1*2,A=m1+T*sa+(T-1)*g1+b4;h.push({id:N.name,type:"groupNode",position:{x:0,y:0},data:{label:N.name,type:"parallel_group",status:(k==null?void 0:k.status)||"pending",groupName:N.name,progress:o[N.name]},style:{width:M,height:A}});for(let L=0;L$entryPoint",source:"$start",target:s,type:"animatedEdge",data:{},animated:!1})}const w=new Set(h.map(N=>N.id)),E=new Map;for(const N of h)N.parentId&&E.set(N.id,N.parentId);const S=new Map;for(const N of t){const k=E.get(N.from)??N.from,T=E.get(N.to)??N.to;if(!w.has(k)||!w.has(T)||k===T)continue;const M=`${k}->${T}`,A=S.get(M);if(A){A.when!==N.when&&(f[A.idx].data={when:void 0});continue}const L=f.length;S.set(M,{when:N.when,idx:L});const R=`${M}${N.when?`[${N.when}]`:""}`;f.push({id:R,source:k,target:T,type:"animatedEdge",data:{when:N.when},animated:!1})}const _=_4(h,f,"$start");return S4(h,f,_),{nodes:h,edges:f}}function _4(e,t,n){const l=new Set(e.filter(f=>!f.parentId).map(f=>f.id)),a=new Map;for(const f of t)!l.has(f.source)||!l.has(f.target)||(a.has(f.source)||a.set(f.source,[]),a.get(f.source).push({target:f.target,edgeId:f.id}));for(const f of a.values())f.sort((m,p)=>m.targetp.target?1:0);const o=new Set,s=new Set,c=new Set,h=f=>{c.add(f),s.add(f);for(const{target:m,edgeId:p}of a.get(f)??[])s.has(m)?o.add(p):c.has(m)||h(m);s.delete(f)};l.has(n)&&h(n);for(const f of[...a.keys()].sort())c.has(f)||h(f);return o}function S4(e,t,n){var a,o,s,c;const l=new h1.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:"TB",nodesep:50,ranksep:70,marginx:30,marginy:30});for(const h of e){if(h.parentId)continue;const f=h.type==="groupNode",m=f&&((a=h.style)==null?void 0:a.width)||Mo,p=f&&((o=h.style)==null?void 0:o.height)||sa;l.setNode(h.id,{width:m,height:p})}for(const h of t)!l.hasNode(h.source)||!l.hasNode(h.target)||(n.has(h.id)?l.setEdge(h.target,h.source):l.setEdge(h.source,h.target));h1.layout(l);for(const h of e){if(h.parentId)continue;const f=l.node(h.id);if(!f)continue;const m=h.type==="groupNode",p=m&&((s=h.style)==null?void 0:s.width)||Mo,g=m&&((c=h.style)==null?void 0:c.height)||sa;h.position={x:f.x-p/2,y:f.y-g/2}}}const ze={pending:"#6b7280",running:"#3b82f6",completed:"#22c55e",failed:"#ef4444",paused:"#f59e0b",idle:"#6b7280",waiting:"#a855f7"},k4=70,x1=90;function cl({data:e,children:t}){const[n,l]=I.useState(!1),a=I.useRef(null),o=I.useCallback(()=>{a.current=setTimeout(()=>l(!0),200)},[]),s=I.useCallback(()=>{a.current&&clearTimeout(a.current),l(!1)},[]),c=ze[e.status]||ze.pending;return y.jsxs("div",{className:"relative",onMouseEnter:o,onMouseLeave:s,children:[t,n&&y.jsxs("div",{className:je("absolute z-50 bottom-full left-1/2 -translate-x-1/2 mb-2","bg-[var(--surface-raised)] border border-[var(--border)] shadow-lg","rounded-lg px-3 py-2 max-w-[260px] pointer-events-none","animate-[tooltip-in_150ms_ease-out]"),children:[y.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 w-0 h-0 border-x-[6px] border-x-transparent border-t-[6px] border-t-[var(--border)]"}),y.jsxs("div",{className:"flex flex-col gap-1.5 text-[11px]",children:[y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:c}}),y.jsx("span",{className:"font-medium text-[var(--text)] capitalize",children:e.status}),e.iteration!=null&&e.iteration>1&&y.jsxs("span",{className:"text-[var(--text-muted)] ml-auto",children:["iter ",e.iteration]})]}),y.jsx("div",{className:"h-px bg-[var(--border)]"}),y.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[e.elapsed!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Elapsed"}),y.jsx("span",{className:"text-[var(--text)] font-mono",children:ot(e.elapsed)})]}),e.model&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Model"}),y.jsx("span",{className:"text-[var(--text)] truncate",children:e.model})]}),e.tokens!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Tokens"}),y.jsxs("span",{className:"text-[var(--text)] font-mono",children:[Gn(e.tokens),e.inputTokens!=null&&e.outputTokens!=null&&y.jsxs("span",{className:"text-[var(--text-muted)]",children:[" ","(",Gn(e.inputTokens),"↑ ",Gn(e.outputTokens),"↓)"]})]})]}),e.costUsd!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Cost"}),y.jsx("span",{className:"text-[var(--text)] font-mono",children:wi(e.costUsd)})]}),e.exitCode!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Exit code"}),y.jsx("span",{className:je("font-mono",e.exitCode===0?"text-[var(--completed)]":"text-[var(--failed)]"),children:e.exitCode})]}),e.selectedOption&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Selected"}),y.jsx("span",{className:"text-[var(--text)] truncate",children:e.selectedOption})]}),e.terminationStatus&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Termination"}),y.jsx("span",{className:je("font-mono capitalize",e.terminationStatus==="success"?"text-[var(--completed)]":"text-[var(--failed)]"),children:e.terminationStatus})]})]}),e.reason&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"h-px bg-[var(--border)]"}),y.jsxs("div",{className:je("leading-tight break-words",e.terminationStatus==="failed"?"text-red-400":"text-[var(--text)]"),children:[y.jsx("span",{className:"text-[var(--text-muted)] mr-1",children:"Reason:"}),e.reason.slice(0,160),e.reason.length>160?"...":""]})]}),e.errorMessage&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"h-px bg-[var(--border)]"}),y.jsxs("div",{className:"text-red-400 leading-tight",children:[e.errorType&&y.jsxs("span",{className:"font-medium",children:[e.errorType,": "]}),y.jsxs("span",{className:"break-words",children:[e.errorMessage.slice(0,120),e.errorMessage.length>120?"...":""]})]})]})]})]})]})}const E4=I.memo(function({data:t,id:n,selected:l}){var L;const a=t,o=Rn(),c=((L=o[n])==null?void 0:L.status)||a.status||"pending",h=ze[c]||ze.pending,f=o[n],m=f==null?void 0:f.elapsed,p=f==null?void 0:f.model,g=f==null?void 0:f.tokens,b=f==null?void 0:f.input_tokens,w=f==null?void 0:f.output_tokens,E=f==null?void 0:f.cost_usd,S=f==null?void 0:f.iteration,_=f==null?void 0:f.error_type,N=f==null?void 0:f.error_message,k=f==null?void 0:f.context_pct,T=N4(n,c),M=C4(c),A=(()=>{if(c==="failed"&&N)return{text:N.length>40?N.slice(0,37)+"...":N,className:"text-red-400"};if(c==="running")return{text:T,className:"text-[var(--text-muted)]"};if(c==="completed"){const R=[];return m!=null&&R.push(ot(m)),g!=null&&R.push(`${Gn(g)} tok`),E!=null&&R.push(wi(E)),{text:R.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(xt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(cl,{data:{status:c,elapsed:m,model:p,tokens:g,inputTokens:b,outputTokens:w,costUsd:E,iteration:S,errorType:_,errorMessage:N},children:y.jsxs("div",{className:je("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",M),style:{borderColor:h},children:[y.jsx("div",{className:je("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${h}20`},children:y.jsx(cN,{className:"w-3.5 h-3.5",style:{color:h}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),S!=null&&S>1&&y.jsxs("span",{className:"flex-shrink-0 inline-flex items-center justify-center px-1.5 py-0.5 rounded-full text-[9px] font-bold leading-none",style:{backgroundColor:`${h}25`,color:h},children:["x",S]})]}),A.text&&y.jsx("span",{className:je("text-[10px] truncate leading-tight",A.className),children:A.text})]}),k!=null&&y.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-[2px] rounded-b-lg overflow-hidden",style:{backgroundColor:"rgba(255,255,255,0.06)"},children:y.jsx("div",{className:je("h-full transition-all duration-500",k>=x1?"animate-[context-pulse_2s_ease-in-out_infinite]":""),style:{width:`${Math.min(k,100)}%`,backgroundColor:k>=x1?"#ef4444":k>=k4?"#f59e0b":"#22c55e"}})})]})}),y.jsx(xt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function N4(e,t){var h;const n=(h=Rn()[e])==null?void 0:h.startedAt,l=se(f=>f.replayMode),a=se(f=>f.lastEventTime),[o,s]=I.useState("0.0s"),c=I.useRef(null);return I.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=n??a??0;s(ot((a??p)-p));return}const f=n!=null?n*1e3:Date.now(),m=()=>{const p=(Date.now()-f)/1e3;s(ot(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,n,l,a]),o}function C4(e){const t=I.useRef(e),[n,l]=I.useState("");return I.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),n}const j4=I.memo(function({data:t,id:n,selected:l}){var _;const a=t,o=Rn(),c=((_=o[n])==null?void 0:_.status)||a.status||"pending",h=ze[c]||ze.pending,f=o[n],m=f==null?void 0:f.elapsed,p=f==null?void 0:f.exit_code,g=f==null?void 0:f.error_type,b=f==null?void 0:f.error_message,w=T4(n,c),E=A4(c),S=(()=>{if(c==="failed"&&b)return{text:b.length>40?b.slice(0,37)+"...":b,className:"text-red-400"};if(c==="running")return{text:w,className:"text-[var(--text-muted)]"};if(c==="completed"){const N=[];return m!=null&&N.push(ot(m)),p!=null&&N.push(`exit ${p}`),{text:N.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(xt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(cl,{data:{status:c,elapsed:m,exitCode:p,errorType:g,errorMessage:b},children:y.jsxs("div",{className:je("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",E),style:{borderColor:h},children:[y.jsx("div",{className:je("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${h}20`},children:y.jsx(EN,{className:"w-3.5 h-3.5",style:{color:h}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),S.text&&y.jsx("span",{className:je("text-[10px] truncate leading-tight",S.className),children:S.text})]})]})}),y.jsx(xt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function T4(e,t){var h;const n=(h=Rn()[e])==null?void 0:h.startedAt,l=se(f=>f.replayMode),a=se(f=>f.lastEventTime),[o,s]=I.useState("0.0s"),c=I.useRef(null);return I.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=n??a??0;s(ot((a??p)-p));return}const f=n!=null?n*1e3:Date.now(),m=()=>{const p=(Date.now()-f)/1e3;s(ot(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,n,l,a]),o}function A4(e){const t=I.useRef(e),[n,l]=I.useState("");return I.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),n}const z4=I.memo(function({data:t,id:n,selected:l}){var N;const a=t,o=Rn(),c=((N=o[n])==null?void 0:N.status)||a.status||"pending",h=ze[c]||ze.pending,f=o[n],m=f==null?void 0:f.elapsed,p=f==null?void 0:f.set_output_keys,g=f==null?void 0:f.set_value_repr,b=f==null?void 0:f.error_type,w=f==null?void 0:f.error_message,E=M4(n,c),S=D4(c),_=(()=>{if(c==="failed"&&w)return{text:w.length>40?w.slice(0,37)+"...":w,className:"text-red-400"};if(c==="running")return{text:E,className:"text-[var(--text-muted)]"};if(c==="completed"){const k=[];if(m!=null&&k.push(ot(m)),p&&p.length>0)k.push(`${p.length} key${p.length===1?"":"s"}`);else if(g){const T=g.length>24?g.slice(0,21)+"…":g;k.push(T)}return{text:k.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(xt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(cl,{data:{status:c,elapsed:m,errorType:b,errorMessage:w},children:y.jsxs("div",{className:je("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",S),style:{borderColor:h},children:[y.jsx("div",{className:je("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${h}20`},children:y.jsx(NN,{className:"w-3.5 h-3.5",style:{color:h}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),_.text&&y.jsx("span",{className:je("text-[10px] truncate leading-tight",_.className),children:_.text})]})]})}),y.jsx(xt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function M4(e,t){var h;const n=(h=Rn()[e])==null?void 0:h.startedAt,l=se(f=>f.replayMode),a=se(f=>f.lastEventTime),[o,s]=I.useState("0.0s"),c=I.useRef(null);return I.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=n??a??0;s(ot((a??p)-p));return}const f=n!=null?n*1e3:Date.now(),m=()=>{const p=(Date.now()-f)/1e3;s(ot(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,n,l,a]),o}function D4(e){const t=I.useRef(e),[n,l]=I.useState("");return I.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),n}const R4=I.memo(function({data:t,id:n,selected:l}){var p,g;const a=t,o=Rn(),c=((p=o[n])==null?void 0:p.status)||a.status||"pending",h=ze[c]||ze.pending,f=(g=o[n])==null?void 0:g.selected_option,m=O4(c);return y.jsxs(y.Fragment,{children:[y.jsx(xt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(cl,{data:{status:c,selectedOption:f},children:y.jsxs("div",{className:je("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 border-dashed bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="waiting"&&"shadow-[0_0_12px_var(--waiting-muted)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",m),style:{borderColor:h},children:[y.jsx("div",{className:je("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="waiting"&&"animate-pulse"),style:{backgroundColor:`${h}20`},children:y.jsx(kN,{className:"w-3.5 h-3.5",style:{color:h}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),c==="waiting"&&y.jsx("span",{className:"text-[10px] text-[var(--waiting)] truncate leading-tight",children:"Awaiting input..."}),c==="completed"&&f&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] truncate leading-tight",children:f})]})]})}),y.jsx(xt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function O4(e){const t=I.useRef(e),[n,l]=I.useState("");return I.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"||e==="waiting"?l("node-activate"):(a==="running"||a==="waiting")&&e==="completed"&&l("node-complete");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),n}const L4=I.memo(function({data:t,id:n,selected:l}){var S;const a=t,s=a.type==="for_each_group"?_N:yN,c=a.progress,m=((S=Rn()[n])==null?void 0:S.status)||a.status||"pending",p=ze[m]||ze.pending,g=H4(m),b=c?`${c.completed+c.failed}/${c.total}${c.failed>0?` (${c.failed} failed)`:""}`:null,w=c&&c.total>0?(c.completed+c.failed)/c.total*100:0,E=c!=null&&c.failed>0;return y.jsxs(y.Fragment,{children:[y.jsx(xt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsxs("div",{className:je("flex flex-col gap-1 px-4 py-3 rounded-xl border-2 border-dashed bg-[var(--surface)]/80 min-w-[180px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",m==="running"&&"shadow-[0_0_16px_var(--running-glow)]",g),style:{borderColor:p,minHeight:"100%"},children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(s,{className:"w-3.5 h-3.5",style:{color:p}}),y.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:a.label})]}),b&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] font-mono",children:b}),c&&c.total>0&&m==="running"&&y.jsx("div",{className:"w-full h-1 rounded-full bg-[var(--border)] overflow-hidden mt-0.5",children:y.jsx("div",{className:"h-full rounded-full transition-all duration-500 ease-out",style:{width:`${w}%`,backgroundColor:E?"var(--failed)":"var(--completed)"}})})]}),y.jsx(xt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function H4(e){const t=I.useRef(e),[n,l]=I.useState("");return I.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),n}const B4=I.memo(function({data:t,id:n,selected:l}){const a=t,s=se(S=>{var _;return(_=S.nodes[n])==null?void 0:_.status})||a.status||"pending",c=ze[s]||ze.pending,h=se(S=>{var _;return(_=S.nodes[n])==null?void 0:_.elapsed}),f=se(S=>{var _;return(_=S.nodes[n])==null?void 0:_.error_message}),m=se(S=>S.navigateIntoSubworkflow),p=$m(),g=p.some(S=>S.parentAgent===n),b=p.find(S=>S.parentAgent===n),w=b==null?void 0:b.workflowName,E=(()=>{if(s==="failed"&&f)return{text:f.length>35?f.slice(0,32)+"...":f,className:"text-red-400"};if(s==="running")return{text:w||"Running subworkflow…",className:"text-[var(--text-muted)]"};if(s==="completed"){const S=[];return w&&S.push(w),h!=null&&S.push(`${h.toFixed(1)}s`),{text:S.join(" · ")||"Done",className:"text-[var(--text-muted)]"}}return{text:w||null,className:"text-[var(--text-muted)]"}})();return y.jsxs(y.Fragment,{children:[y.jsx(xt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(cl,{data:{status:s,elapsed:h,errorType:void 0,errorMessage:f,iteration:void 0},children:y.jsxs("div",{className:je("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[240px] transition-all duration-300 cursor-pointer",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",s==="running"&&"shadow-[0_0_12px_var(--running-glow)]"),style:{borderColor:c,borderStyle:"dashed"},onDoubleClick:S=>{g&&(S.stopPropagation(),m(n))},children:[y.jsx("div",{className:je("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",s==="running"&&"animate-pulse"),style:{backgroundColor:`${c}20`},children:y.jsx(kc,{className:"w-3.5 h-3.5",style:{color:c}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("div",{className:"flex items-center gap-1",children:y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label})}),E.text&&y.jsx("span",{className:je("text-[10px] truncate leading-tight",E.className),children:E.text})]}),g&&y.jsx(Lr,{className:"w-3.5 h-3.5 flex-shrink-0 text-[var(--text-muted)]"})]})}),y.jsx(xt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),I4=I.memo(function({data:t,id:n,selected:l}){var k;const a=t,o=Rn(),c=((k=o[n])==null?void 0:k.status)||a.status||"pending",h=ze[c]||ze.pending,f=o[n],m=(f==null?void 0:f.duration_seconds)??(f==null?void 0:f.requested_seconds),p=f==null?void 0:f.waited_seconds,g=f==null?void 0:f.elapsed,b=f==null?void 0:f.interrupted,w=f==null?void 0:f.error_type,E=f==null?void 0:f.error_message,S=q4(n,c),_=$4(c),N=(()=>{if(c==="failed"&&E)return{text:E.length>40?E.slice(0,37)+"...":E,className:"text-red-400"};if(c==="running"){const T=typeof m=="number"?` / ${ot(m)}`:"";return{text:`${S}${T}`,className:"text-[var(--text-muted)]"}}if(c==="completed"){const T=[];return p!=null?T.push(ot(p)):g!=null&&T.push(ot(g)),b&&T.push("interrupted"),{text:T.join(" · ")||null,className:"text-[var(--text-muted)]"}}return c==="pending"&&typeof m=="number"?{text:ot(m),className:"text-[var(--text-muted)]"}:{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(xt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(cl,{data:{status:c,elapsed:p??g,errorType:w,errorMessage:E},children:y.jsxs("div",{className:je("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",_),style:{borderColor:h},children:[y.jsx("div",{className:je("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${h}20`},children:y.jsx(xw,{className:"w-3.5 h-3.5",style:{color:h}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),N.text&&y.jsx("span",{className:je("text-[10px] truncate leading-tight",N.className),children:N.text})]})]})}),y.jsx(xt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function q4(e,t){var h;const n=(h=Rn()[e])==null?void 0:h.startedAt,l=se(f=>f.replayMode),a=se(f=>f.lastEventTime),[o,s]=I.useState("0.0s"),c=I.useRef(null);return I.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=n??a??0;s(ot((a??p)-p));return}const f=n!=null?n*1e3:Date.now(),m=()=>{const p=(Date.now()-f)/1e3;s(ot(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,n,l,a]),o}function $4(e){const t=I.useRef(e),[n,l]=I.useState("");return I.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),n}const U4=I.memo(function({data:t,id:n,selected:l}){var S;const a=t,o=Rn(),c=((S=o[n])==null?void 0:S.status)||a.status||"pending",h=ze[c]||ze.pending,f=o[n],m=f==null?void 0:f.termination_reason,p=f==null?void 0:f.termination_status,g=f==null?void 0:f.error_message,b=f==null?void 0:f.error_type,w=m||g,E=c==="failed"?"text-red-400":c==="completed"?"text-green-400":"text-[var(--text-muted)]";return y.jsxs(y.Fragment,{children:[y.jsx(xt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(cl,{data:{status:c,reason:m,terminationStatus:p,errorType:b,errorMessage:g},children:y.jsxs("div",{className:je("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[260px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="completed"&&"shadow-[0_0_12px_var(--completed-muted)]",c==="failed"&&"shadow-[0_0_12px_var(--failed-muted)]"),style:{borderColor:h},children:[y.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",style:{backgroundColor:`${h}20`},children:y.jsx(bN,{className:"w-3.5 h-3.5",style:{color:h},fill:c==="completed"||c==="failed"?h:"transparent",fillOpacity:.2})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),y.jsxs("span",{className:"text-[10px] uppercase tracking-wide text-[var(--text-muted)] truncate leading-tight",children:["terminate",p?` · ${p}`:""]}),w&&y.jsx("span",{className:je("text-[10px] truncate leading-tight mt-0.5",E),title:w,children:w.length>50?w.slice(0,47)+"...":w})]})]})})]})}),V4=I.memo(function({data:t,selected:n}){const a=t.status||"pending",o=a==="completed",s=a==="failed",c=!o&&!s,h=o?ze.completed:s?ze.failed:ze.pending;return y.jsxs(y.Fragment,{children:[y.jsx(xt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx("div",{className:je("flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300",o?"bg-[var(--completed)] shadow-[0_0_16px_var(--completed-muted)]":s?"bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]":"bg-[var(--node-bg)]",n&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]"),style:{borderColor:h},children:o?y.jsx(Ki,{className:"w-5 h-5 text-white",strokeWidth:3}):s?y.jsx(Sw,{className:"w-3.5 h-3.5 text-white",fill:"white"}):y.jsx(Ki,{className:"w-5 h-5",strokeWidth:2.5,style:{color:c?ze.pending:h}})})]})}),P4=I.memo(function({data:t,selected:n}){const a=t.status||"pending",o=ze[a]||ze.pending,s=a==="running"||a==="completed";return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:je("flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300",s?"bg-[var(--completed)]":"bg-[var(--node-bg)]",n&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",s&&"shadow-[0_0_12px_var(--completed-muted)]"),style:{borderColor:o},children:y.jsx(Ec,{className:"w-4 h-4 ml-0.5",style:{color:s?"white":o}})}),y.jsx(xt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),y1="#a78bfa",G4=I.memo(function({data:t,selected:n}){const l=t,a=l.status||"pending",o=a==="running"||a==="completed",s=o?y1:ze[a]||y1,c=l.parentAgent,h=se(f=>f.navigateUp);return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex flex-col items-center gap-1",children:[y.jsx("div",{className:je("flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer",o?"bg-[#a78bfa]":"bg-[var(--node-bg)]",n&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",o&&"shadow-[0_0_12px_rgba(167,139,250,0.4)]"),style:{borderColor:s},onDoubleClick:f=>{f.stopPropagation(),h()},children:y.jsx(sN,{className:"w-4 h-4",style:{color:o?"white":s}})}),c&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] whitespace-nowrap",children:["from ",y.jsx("span",{className:"font-medium text-[var(--text)]",children:c})]})]}),y.jsx(xt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),v1="#a78bfa",F4=I.memo(function({data:t,selected:n}){const l=t,a=l.status||"pending",o=a==="completed",s=a==="failed",c=o?v1:s?ze.failed:v1,h=l.parentAgent,f=se(m=>m.navigateUp);return y.jsxs(y.Fragment,{children:[y.jsx(xt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsxs("div",{className:"flex flex-col items-center gap-1",children:[y.jsx("div",{className:je("flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer",o?"bg-[#a78bfa] shadow-[0_0_12px_rgba(167,139,250,0.4)]":s?"bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]":"bg-[var(--node-bg)]",n&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]"),style:{borderColor:c},onDoubleClick:m=>{m.stopPropagation(),f()},children:y.jsx(uN,{className:"w-4 h-4",style:{color:o||s?"white":c}})}),h&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] whitespace-nowrap",children:["return to ",y.jsx("span",{className:"font-medium text-[var(--text)]",children:h})]})]})]})}),Y4=I.memo(function({id:t,sourceX:n,sourceY:l,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,source:h,target:f,data:m}){const p=A5(),g=I.useMemo(()=>p.find(V=>V.from===h&&V.to===f),[p,h,f]),[b,w,E]=Rm({sourceX:n,sourceY:l,targetX:a,targetY:o,sourcePosition:s,targetPosition:c}),S=m==null?void 0:m.when,_=!!S,N=(g==null?void 0:g.state)==="taken",k=(g==null?void 0:g.state)==="highlighted",T=(g==null?void 0:g.state)==="failed";let M="var(--edge-color)",A=2,L;T?(M="var(--failed)",A=3):N?(M="var(--edge-taken)",A=3):k&&(M="var(--edge-active)",A=3),_&&!N&&!k&&!T&&(L="6 3");const R=T?"failed":N?"taken":k?"active":"default";return y.jsxs(y.Fragment,{children:[y.jsx(ls,{id:t,path:b,style:{stroke:M,strokeWidth:A,strokeDasharray:L,transition:"stroke 0.3s ease, stroke-width 0.3s ease"},markerEnd:`url(#arrow-${R})`}),_&&y.jsx(JM,{children:y.jsx("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${w}px,${E}px)`,pointerEvents:"all"},children:y.jsx("span",{className:"inline-block px-1.5 py-0.5 rounded-full text-[9px] font-mono leading-tight max-w-[140px] truncate",style:{backgroundColor:T?"var(--failed)":N?"var(--edge-taken)":"var(--surface)",color:T||N?"var(--bg)":"var(--text-muted)",border:`1px solid ${T?"var(--failed)":N?"var(--edge-taken)":"var(--border)"}`},title:S,children:S})})}),N&&y.jsx("circle",{r:"3",fill:"var(--edge-taken)",children:y.jsx("animateMotion",{dur:"1s",repeatCount:"indefinite",path:b})}),T&&y.jsx("circle",{r:"3",fill:"var(--failed)",opacity:"0.8",children:y.jsx("animateMotion",{dur:"1.5s",repeatCount:"indefinite",path:b})})]})});function X4(){const e=se(f=>f.workflowStatus),t=se(f=>f.workflowFailure),n=se(f=>f.workflowFailedAgent),l=se(f=>f.workflowTermination),a=se(f=>f.selectNode);if(e!=="failed"||!t)return null;const o=(l==null?void 0:l.is_explicit)&&l.status==="failed",s=o?l.termination_reason||t.message||"Workflow terminated":t.message||t.error_type||"Unknown error",c=o?"Workflow Terminated":"Workflow Failed",h=t.error_type==="TimeoutError";return y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:je("flex items-center gap-2 px-4 py-2 rounded-lg","bg-red-950/90 border border-red-500/40 shadow-lg shadow-red-500/10","backdrop-blur-sm max-w-[560px]"),children:[y.jsx(lc,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),y.jsxs("div",{className:"flex flex-col min-w-0",children:[y.jsx("span",{className:"text-xs font-medium text-red-300",children:c}),y.jsx("span",{className:"text-[11px] text-red-400/80 truncate",children:s}),o&&(l==null?void 0:l.terminated_by)&&y.jsxs("span",{className:"text-[10px] text-red-400/60 truncate",children:["Terminated by: ",l.terminated_by]}),h&&t.current_agent&&y.jsxs("span",{className:"text-[10px] text-red-400/60 truncate",children:["Timed out on agent: ",t.current_agent]}),t.checkpoint_path&&y.jsxs("span",{className:"text-[10px] text-red-400/50 truncate",title:t.checkpoint_path,children:["Checkpoint: ",t.checkpoint_path.split("/").pop()]})]}),n&&y.jsxs("button",{onClick:()=>a(n),className:"flex items-center gap-1 px-2 py-1 rounded text-[10px] font-medium text-red-300 bg-red-500/20 hover:bg-red-500/30 transition-colors flex-shrink-0 ml-1",children:[y.jsx(mN,{className:"w-3 h-3"}),"View"]})]})})}function Q4(){const[e,t]=I.useState(!1),n=se(m=>m.workflowStatus),l=se(m=>m.workflowTermination),a=se(m=>m.totalCost),o=se(m=>m.totalTokens),s=se(m=>m.agentsCompleted),c=se(m=>m.agentsTotal),h=Ew();if(n!=="completed"||e)return null;const f=(l==null?void 0:l.is_explicit)&&l.status==="success";return y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:je("flex items-center gap-3 px-4 py-2 rounded-lg","bg-green-950/90 border border-green-500/40 shadow-lg shadow-green-500/10","backdrop-blur-sm max-w-[560px]"),children:[y.jsx(dN,{className:"w-4 h-4 text-green-400 flex-shrink-0"}),y.jsxs("div",{className:"flex flex-col min-w-0",children:[y.jsx("span",{className:"text-xs font-medium text-green-300",children:f?"Workflow Terminated":"Completed"}),f&&(l==null?void 0:l.termination_reason)&&y.jsx("span",{className:"text-[11px] text-green-400/80 truncate",children:l.termination_reason}),f&&(l==null?void 0:l.terminated_by)&&y.jsxs("span",{className:"text-[10px] text-green-400/60 truncate",children:["Terminated by: ",l.terminated_by]})]}),y.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-green-400/80 font-mono flex-shrink-0 ml-auto",children:[y.jsx("span",{children:h}),c>0&&y.jsxs("span",{children:[s,"/",c," agents"]}),o>0&&y.jsxs("span",{children:[Gn(o)," tok"]}),a>0&&y.jsx("span",{children:wi(a)})]}),y.jsx("button",{onClick:()=>t(!0),className:"p-0.5 rounded text-green-500/60 hover:text-green-300 transition-colors flex-shrink-0 ml-1",children:y.jsx(sl,{className:"w-3.5 h-3.5"})})]})})}const Z4={agentNode:E4,scriptNode:j4,setNode:z4,gateNode:R4,groupNode:L4,workflowNode:B4,waitNode:I4,terminateNode:U4,endNode:V4,startNode:P4,ingressNode:G4,egressNode:F4},K4={animatedEdge:Y4},J4={type:"animatedEdge"};function W4(){return y.jsx("svg",{style:{position:"absolute",width:0,height:0},children:y.jsxs("defs",{children:[y.jsx("marker",{id:"arrow-default",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-color)"})}),y.jsx("marker",{id:"arrow-active",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-active)"})}),y.jsx("marker",{id:"arrow-taken",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-taken)"})}),y.jsx("marker",{id:"arrow-failed",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--failed)"})})]})})}function eD(){const e=z5(),t=se(z=>z.viewContextPath),n=se(z=>z.selectNode),l=se(z=>z.selectedNode),a=se(z=>z.workflowStatus),o=se(z=>z.wsStatus),s=se(z=>z.workflowFailedAgent),c=se(z=>z.navigateIntoSubworkflow),{agents:h,routes:f,parallelGroups:m,forEachGroups:p,nodes:g,groupProgress:b,entryPoint:w,subworkflowContexts:E,parentAgent:S}=e,[_,N,k]=WM([]),[T,M,A]=e5([]),L=I.useRef(!1),R=I.useRef(""),V=JSON.stringify(t);I.useEffect(()=>{if(h.length===0){R.current!==V&&(L.current=!1,R.current=V,N([]),M([]));return}if(R.current!==V&&(L.current=!1,R.current=V),L.current)return;L.current=!0;const{nodes:z,edges:G}=w4(h,f,m,p,g,b,w,S);N(z),M(G)},[h,f,m,p,g,b,w,N,M,V,S]),I.useEffect(()=>{L.current&&N(z=>z.map(G=>{const Q=g[G.id];if(!Q)return G;const K=Q.status||"pending",D=G.data.status;if(K!==D){const $={...G.data,status:K};return G.data.groupName&&b[G.data.groupName]&&($.progress=b[G.data.groupName]),{...G,data:$}}if(G.data.groupName&&b[G.data.groupName]){const $=G.data.progress,Y=b[G.data.groupName];if(Y&&(!$||$.completed!==Y.completed||$.failed!==Y.failed))return{...G,data:{...G.data,progress:Y}}}return G}))},[g,b,N]);const H=I.useCallback((z,G)=>{G.type==="groupNode"&&G.data.type!=="for_each_group"||n(G.id)},[n]),B=I.useCallback((z,G)=>{E.some(K=>K.parentAgent===G.id)&&c(G.id)},[E,c]),U=I.useCallback(()=>{n(null)},[n]),ee=I.useCallback(z=>{var Q;const G=((Q=z.data)==null?void 0:Q.status)||"pending";return ze[G]??ze.pending??"#6b7280"},[]);I.useEffect(()=>{N(z=>z.map(G=>({...G,selected:G.id===l})))},[l,N]),I.useEffect(()=>{a==="failed"&&s&&n(s)},[a,s,n]);const q=a==="pending"&&h.length===0,F=(()=>{switch(o){case"connecting":return"Connecting to workflow…";case"reconnecting":return"Reconnecting…";case"disconnected":return"Connection lost. Retrying…";default:return"Waiting for workflow…"}})();return y.jsxs("div",{className:"w-full h-full relative",children:[y.jsx(W4,{}),y.jsx(X4,{}),y.jsx(Q4,{}),q&&y.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center pointer-events-none",children:[y.jsxs("div",{className:"relative mb-3",children:[y.jsx(TN,{className:"w-8 h-8 text-[var(--accent)] opacity-20"}),y.jsx(ha,{className:"w-8 h-8 text-[var(--text-muted)] animate-spin absolute inset-0 opacity-40"})]}),y.jsx("p",{className:"text-sm text-[var(--text-muted)] animate-pulse",children:F})]}),y.jsxs(ZM,{nodes:_,edges:T,onNodesChange:k,onEdgesChange:A,onNodeClick:H,onNodeDoubleClick:B,onPaneClick:U,nodeTypes:Z4,edgeTypes:K4,defaultEdgeOptions:J4,fitView:!0,fitViewOptions:{padding:.2},minZoom:.2,maxZoom:2,proOptions:{hideAttribution:!0},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,children:[y.jsx(l5,{variant:Rr.Dots,gap:20,size:1,color:"var(--border-subtle)"}),y.jsx(E5,{nodeColor:ee,maskColor:"var(--minimap-mask)",style:{background:"var(--minimap-bg)"},pannable:!0,zoomable:!0}),y.jsx(d5,{showInteractive:!1,children:y.jsx(tD,{})}),y.jsx(nD,{}),y.jsx(rD,{viewPathKey:V}),y.jsx(iD,{})]})]})}function tD(){const{fitView:e}=ul(),t=I.useCallback(()=>{e({padding:.2,duration:300})},[e]);return y.jsx("button",{onClick:t,className:"react-flow__controls-button",title:"Fit view (F)",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:y.jsx(vN,{className:"w-3.5 h-3.5"})})}function nD(){const{fitView:e}=ul();return I.useEffect(()=>{const t=n=>{var a;const l=(a=n.target)==null?void 0:a.tagName;l==="INPUT"||l==="TEXTAREA"||l==="SELECT"||n.key==="f"&&!n.ctrlKey&&!n.metaKey&&!n.altKey&&e({padding:.2,duration:300})};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),null}function rD({viewPathKey:e}){const{fitView:t}=ul(),n=I.useRef(e);return I.useEffect(()=>{n.current!==e&&(n.current=e,setTimeout(()=>t({padding:.2,duration:300}),50))},[e,t]),null}function iD(){const e=O5();return e?y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-amber-950/90 border border-amber-500/40 shadow-lg shadow-amber-500/10 backdrop-blur-sm max-w-[560px]",children:[y.jsx("span",{className:"text-xs text-amber-300",children:"⚠"}),y.jsx("span",{className:"text-[11px] text-amber-400/80",children:e.message}),y.jsx("a",{href:window.location.pathname,className:"px-2 py-0.5 rounded text-[10px] font-medium text-amber-300 bg-amber-500/20 hover:bg-amber-500/30 transition-colors flex-shrink-0 ml-1",children:"Root"})]})}):null}function Br({items:e}){const t=e.filter(n=>n.value!=null&&n.value!=="");return t.length===0?null:y.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1.5 text-xs",children:t.map(({label:n,value:l})=>y.jsxs("div",{className:"contents",children:[y.jsx("dt",{className:"text-[var(--text-muted)] whitespace-nowrap",children:n}),y.jsx("dd",{className:"text-[var(--text)] break-words",children:typeof l=="object"?JSON.stringify(l):String(l)})]},n))})}function OS(e){const t=[];return e.elapsed!=null&&t.push({label:"Elapsed",value:ot(e.elapsed)}),e.model&&t.push({label:"Model",value:e.model}),e.reasoning_effort&&t.push({label:"Reasoning",value:e.reasoning_effort}),e.tokens!=null&&t.push({label:"Tokens",value:Gn(e.tokens)}),e.input_tokens!=null&&e.output_tokens!=null&&t.push({label:"In / Out",value:`${Gn(e.input_tokens)} / ${Gn(e.output_tokens)}`}),e.cost_usd!=null&&t.push({label:"Cost",value:wi(e.cost_usd)}),e.context_window_used!=null&&e.context_window_max!=null&&t.push({label:"Context",value:$N(e.context_window_used,e.context_window_max)}),e.iteration!=null&&t.push({label:"Iteration",value:e.iteration}),e.error_type&&t.push({label:"Error",value:e.error_type}),e.error_message&&t.push({label:"Message",value:e.error_message}),t}function _i({output:e,title:t="Output",defaultExpanded:n=!0,maxHeight:l="300px"}){const[a,o]=I.useState(n),[s,c]=I.useState(!1),h=kw(e);if(!h)return null;const f=typeof e=="object"&&e!==null,m=async()=>{await navigator.clipboard.writeText(h),c(!0),setTimeout(()=>c(!1),2e3)};return y.jsxs("div",{className:"space-y-1.5",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold",children:[a?y.jsx(ol,{className:"w-3 h-3"}):y.jsx(Lr,{className:"w-3 h-3"}),t]}),a&&y.jsx("button",{onClick:m,className:"flex items-center gap-1 text-[10px] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",title:"Copy to clipboard",children:s?y.jsx(Ki,{className:"w-3 h-3 text-[var(--completed)]"}):y.jsx(vw,{className:"w-3 h-3"})})]}),a&&y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md p-3 font-mono text-[11px] leading-relaxed text-[var(--text)] overflow-auto whitespace-pre-wrap break-words",style:{maxHeight:l},children:f?y.jsx(lD,{text:h}):h})]})}function lD({text:e}){const t=e.split(/("(?:[^"\\]|\\.)*")/g);return y.jsx(y.Fragment,{children:t.map((n,l)=>{if(l%2===1){const o=t.slice(l+1).join(""),s=/^\s*:/.test(o);return y.jsx("span",{className:s?"text-blue-400":"text-green-400",children:n},l)}const a=n.replace(/\b(true|false|null)\b|(-?\d+\.?\d*(?:e[+-]?\d+)?)/gi,(o,s,c)=>s?`${o}`:c?`${o}`:o);return y.jsx("span",{dangerouslySetInnerHTML:{__html:a}},l)})})}function Vm({activity:e,defaultExpanded:t=!0}){const[n,l]=I.useState(t),a=I.useRef(null);return I.useEffect(()=>{a.current&&n&&(a.current.scrollTop=a.current.scrollHeight)},[e.length,n]),e.length===0?null:y.jsxs("div",{className:"space-y-1.5",children:[y.jsxs("button",{onClick:()=>l(!n),className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold",children:[n?y.jsx(ol,{className:"w-3 h-3"}):y.jsx(Lr,{className:"w-3 h-3"}),"Activity (",e.length,")"]}),n&&y.jsx("div",{ref:a,className:"max-h-[400px] overflow-y-auto space-y-0.5",children:e.map((o,s)=>y.jsx(aD,{entry:o},s))})]})}function aD({entry:e}){const t={reasoning:"text-indigo-400/70","tool-start":"text-blue-400","tool-complete":"text-green-400",turn:"text-amber-400",message:"text-[var(--text)]"};return y.jsxs("div",{className:je("py-1.5 px-2 rounded text-[11px] leading-relaxed border-b border-[var(--border-subtle)] last:border-b-0"),children:[y.jsxs("div",{className:"flex items-start gap-1.5",children:[y.jsx("span",{className:"w-4 text-center flex-shrink-0",children:e.icon}),y.jsx("span",{className:"text-[var(--text-muted)] uppercase text-[9px] font-semibold tracking-wider w-12 flex-shrink-0 pt-px",children:e.label}),y.jsx("span",{className:je("break-words",t[e.type]||"text-[var(--text)]"),children:typeof e.text=="object"?JSON.stringify(e.text):e.text})]}),e.detail&&y.jsx("div",{className:"mt-1 ml-[4.25rem] px-2 py-1 bg-[var(--bg)] rounded text-[10px] font-mono text-[var(--text-muted)] whitespace-pre-wrap break-words max-h-24 overflow-y-auto",children:typeof e.detail=="object"?JSON.stringify(e.detail,null,2):e.detail})]})}function b1({node:e}){const t=e.status,n=ze[t]||ze.pending,l=e.iterationHistory&&e.iterationHistory.length>0;return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${n}20`,color:n},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Agent"})]}),l?y.jsx(w1,{label:`Iteration ${e.iteration??"?"} (current)`,defaultExpanded:!0,status:t,snapshot:{iteration:e.iteration??0,prompt:e.prompt,output:e.output,elapsed:e.elapsed,model:e.model,reasoning_effort:e.reasoning_effort,tokens:e.tokens,input_tokens:e.input_tokens,output_tokens:e.output_tokens,cost_usd:e.cost_usd,activity:e.activity,error_type:e.error_type,error_message:e.error_message}}):y.jsxs(y.Fragment,{children:[y.jsx(Br,{items:OS(e)}),e.prompt&&y.jsx(_i,{output:e.prompt,title:"Input / Prompt",defaultExpanded:!0}),y.jsx(Vm,{activity:e.activity,defaultExpanded:t!=="completed"}),e.output!=null&&y.jsx(_i,{output:e.output,title:"Output"})]}),l&&[...e.iterationHistory].reverse().map(a=>y.jsx(w1,{label:`Iteration ${a.iteration}`,defaultExpanded:!1,status:t,snapshot:a},a.iteration))]})}function w1({label:e,defaultExpanded:t,snapshot:n,status:l}){const[a,o]=I.useState(t);return y.jsxs("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:[y.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-2 w-full px-3 py-2 bg-[var(--bg)] hover:bg-[var(--node-bg)] transition-colors text-left",children:[a?y.jsx(ol,{className:"w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0"}):y.jsx(Lr,{className:"w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("span",{className:"text-xs font-semibold text-[var(--text)]",children:e}),n.elapsed!=null&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] ml-auto",children:oD(n.elapsed)})]}),a&&y.jsxs("div",{className:"px-3 py-3 space-y-3 border-t border-[var(--border)]",children:[y.jsx(Br,{items:OS(n)}),n.prompt&&y.jsx(_i,{output:n.prompt,title:"Input / Prompt",defaultExpanded:!1}),y.jsx(Vm,{activity:n.activity,defaultExpanded:t&&l!=="completed"}),n.output!=null&&y.jsx(_i,{output:n.output,title:"Output",defaultExpanded:!0}),n.error_type&&y.jsxs("div",{className:"text-xs text-red-400",children:[y.jsx("span",{className:"font-semibold",children:n.error_type}),n.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",n.error_message]})]})]})]})}function oD(e){if(e<1)return`${(e*1e3).toFixed(0)}ms`;if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=(e%60).toFixed(0);return`${t}m ${n}s`}function sD({node:e}){const t=e.status,n=ze[t]||ze.pending,l=[];e.elapsed!=null&&l.push({label:"Elapsed",value:ot(e.elapsed)}),e.exit_code!=null&&l.push({label:"Exit Code",value:e.exit_code}),e.error_type&&l.push({label:"Error",value:e.error_type}),e.error_message&&l.push({label:"Message",value:e.error_message});let a="";return e.stdout&&(a+=e.stdout),e.stderr&&(a+=(a?` --- stderr --- -`:"")+e.stderr),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${n}20`,color:n},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Script"})]}),y.jsx(Br,{items:l}),a&&y.jsx(_i,{output:a,title:"Output"})]})}function oD({node:e}){const t=e.status,n=De[t]||De.pending,l=e.set_output_type,a=e.set_output_keys,o=e.set_value_repr,s=(a==null?void 0:a.length)??0,c=[];return e.elapsed!=null&&c.push({label:"Elapsed",value:ot(e.elapsed)}),l&&c.push({label:"Output Type",value:l}),s>0?c.push({label:"Bindings",value:a.join(", ")}):t==="completed"&&c.push({label:"Bindings",value:"scalar"}),e.error_type&&c.push({label:"Error",value:e.error_type}),e.error_message&&c.push({label:"Message",value:e.error_message}),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${n}20`,color:n},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Set"})]}),y.jsx(Br,{items:c}),o&&y.jsx(_i,{output:o,title:"Value preview"})]})}function sD(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const uD=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cD=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fD={};function _1(e,t){return(fD.jsx?cD:uD).test(e)}const dD=/[ \t\n\f\r]/g;function hD(e){return typeof e=="object"?e.type==="text"?S1(e.value):!1:S1(e)}function S1(e){return e.replace(dD,"")===""}class os{constructor(t,n,l){this.normal=n,this.property=t,l&&(this.space=l)}}os.prototype.normal={};os.prototype.property={};os.prototype.space=void 0;function LS(e,t){const n={},l={};for(const a of e)Object.assign(n,a.property),Object.assign(l,a.normal);return new os(n,l,t)}function om(e){return e.toLowerCase()}class cn{constructor(t,n){this.attribute=n,this.property=t}}cn.prototype.attribute="";cn.prototype.booleanish=!1;cn.prototype.boolean=!1;cn.prototype.commaOrSpaceSeparated=!1;cn.prototype.commaSeparated=!1;cn.prototype.defined=!1;cn.prototype.mustUseProperty=!1;cn.prototype.number=!1;cn.prototype.overloadedBoolean=!1;cn.prototype.property="";cn.prototype.spaceSeparated=!1;cn.prototype.space=void 0;let pD=0;const He=cl(),At=cl(),sm=cl(),me=cl(),ct=cl(),fa=cl(),vn=cl();function cl(){return 2**++pD}const um=Object.freeze(Object.defineProperty({__proto__:null,boolean:He,booleanish:At,commaOrSpaceSeparated:vn,commaSeparated:fa,number:me,overloadedBoolean:sm,spaceSeparated:ct},Symbol.toStringTag,{value:"Module"})),kp=Object.keys(um);class Pm extends cn{constructor(t,n,l,a){let o=-1;if(super(t,n),k1(this,"space",a),typeof l=="number")for(;++o4&&n.slice(0,4)==="data"&&vD.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(E1,_D);l="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!E1.test(o)){let s=o.replace(yD,wD);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}a=Pm}return new a(l,t)}function wD(e){return"-"+e.toLowerCase()}function _D(e){return e.charAt(1).toUpperCase()}const SD=LS([HS,mD,qS,$S,US],"html"),Gm=LS([HS,gD,qS,$S,US],"svg");function kD(e){return e.join(" ").trim()}var Wl={},Ep,N1;function ED(){if(N1)return Ep;N1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,s=/^[;\s]*/,c=/^\s+|\s+$/g,h=` -`,f="/",m="*",p="",g="comment",b="declaration";function w(S,_){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];_=_||{};var N=1,k=1;function T(q){var F=q.match(t);F&&(N+=F.length);var z=q.lastIndexOf(h);k=~z?q.length-z:k+q.length}function M(){var q={line:N,column:k};return function(F){return F.position=new A(q),V(),F}}function A(q){this.start=q,this.end={line:N,column:k},this.source=_.source}A.prototype.content=S;function L(q){var F=new Error(_.source+":"+N+":"+k+": "+q);if(F.reason=q,F.filename=_.source,F.line=N,F.column=k,F.source=S,!_.silent)throw F}function R(q){var F=q.exec(S);if(F){var z=F[0];return T(z),S=S.slice(z.length),F}}function V(){R(n)}function H(q){var F;for(q=q||[];F=B();)F!==!1&&q.push(F);return q}function B(){var q=M();if(!(f!=S.charAt(0)||m!=S.charAt(1))){for(var F=2;p!=S.charAt(F)&&(m!=S.charAt(F)||f!=S.charAt(F+1));)++F;if(F+=2,p===S.charAt(F-1))return L("End of comment missing");var z=S.slice(2,F-2);return k+=2,T(z),S=S.slice(F),k+=2,q({type:g,comment:z})}}function U(){var q=M(),F=R(l);if(F){if(B(),!R(a))return L("property missing ':'");var z=R(o),G=q({type:b,property:E(F[0].replace(e,p)),value:z?E(z[0].replace(e,p)):p});return R(s),G}}function ee(){var q=[];H(q);for(var F;F=U();)F!==!1&&(q.push(F),H(q));return q}return V(),ee()}function E(S){return S?S.replace(c,p):p}return Ep=w,Ep}var C1;function ND(){if(C1)return Wl;C1=1;var e=Wl&&Wl.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Wl,"__esModule",{value:!0}),Wl.default=n;const t=e(ED());function n(l,a){let o=null;if(!l||typeof l!="string")return o;const s=(0,t.default)(l),c=typeof a=="function";return s.forEach(h=>{if(h.type!=="declaration")return;const{property:f,value:m}=h;c?a(f,m,h):m&&(o=o||{},o[f]=m)}),o}return Wl}var So={},j1;function CD(){if(j1)return So;j1=1,Object.defineProperty(So,"__esModule",{value:!0}),So.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(f){return!f||n.test(f)||e.test(f)},s=function(f,m){return m.toUpperCase()},c=function(f,m){return"".concat(m,"-")},h=function(f,m){return m===void 0&&(m={}),o(f)?f:(f=f.toLowerCase(),m.reactCompat?f=f.replace(a,c):f=f.replace(l,c),f.replace(t,s))};return So.camelCase=h,So}var ko,T1;function jD(){if(T1)return ko;T1=1;var e=ko&&ko.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(ND()),n=CD();function l(a,o){var s={};return!a||typeof a!="string"||(0,t.default)(a,function(c,h){c&&h&&(s[(0,n.camelCase)(c,o)]=h)}),s}return l.default=l,ko=l,ko}var TD=jD();const AD=Ko(TD),VS=PS("end"),Fm=PS("start");function PS(e){return t;function t(n){const l=n&&n.position&&n.position[e]||{};if(typeof l.line=="number"&&l.line>0&&typeof l.column=="number"&&l.column>0)return{line:l.line,column:l.column,offset:typeof l.offset=="number"&&l.offset>-1?l.offset:void 0}}}function zD(e){const t=Fm(e),n=VS(e);if(t&&n)return{start:t,end:n}}function Oo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?A1(e.position):"start"in e||"end"in e?A1(e):"line"in e||"column"in e?cm(e):""}function cm(e){return z1(e&&e.line)+":"+z1(e&&e.column)}function A1(e){return cm(e&&e.start)+"-"+cm(e&&e.end)}function z1(e){return e&&typeof e=="number"?e:1}class Qt extends Error{constructor(t,n,l){super(),typeof n=="string"&&(l=n,n=void 0);let a="",o={},s=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?a=t:!o.cause&&t&&(s=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof l=="string"){const h=l.indexOf(":");h===-1?o.ruleId=l:(o.source=l.slice(0,h),o.ruleId=l.slice(h+1))}if(!o.place&&o.ancestors&&o.ancestors){const h=o.ancestors[o.ancestors.length-1];h&&(o.place=h.position)}const c=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=c?c.line:void 0,this.name=Oo(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=s&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Qt.prototype.file="";Qt.prototype.name="";Qt.prototype.reason="";Qt.prototype.message="";Qt.prototype.stack="";Qt.prototype.column=void 0;Qt.prototype.line=void 0;Qt.prototype.ancestors=void 0;Qt.prototype.cause=void 0;Qt.prototype.fatal=void 0;Qt.prototype.place=void 0;Qt.prototype.ruleId=void 0;Qt.prototype.source=void 0;const Ym={}.hasOwnProperty,MD=new Map,DD=/[A-Z]/g,RD=new Set(["table","tbody","thead","tfoot","tr"]),OD=new Set(["td","th"]),GS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function LD(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let l;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");l=PD(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");l=VD(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:l,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Gm:SD,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=FS(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function FS(e,t,n){if(t.type==="element")return HD(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return BD(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return qD(e,t,n);if(t.type==="mdxjsEsm")return ID(e,t);if(t.type==="root")return $D(e,t,n);if(t.type==="text")return UD(e,t)}function HD(e,t,n){const l=e.schema;let a=l;t.tagName.toLowerCase()==="svg"&&l.space==="html"&&(a=Gm,e.schema=a),e.ancestors.push(t);const o=XS(e,t.tagName,!1),s=GD(e,t);let c=Qm(e,t);return RD.has(t.tagName)&&(c=c.filter(function(h){return typeof h=="string"?!hD(h):!0})),YS(e,s,o,t),Xm(s,c),e.ancestors.pop(),e.schema=l,e.create(t,o,s,n)}function BD(e,t){if(t.data&&t.data.estree&&e.evaluater){const l=t.data.estree.body[0];return l.type,e.evaluater.evaluateExpression(l.expression)}Qo(e,t.position)}function ID(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Qo(e,t.position)}function qD(e,t,n){const l=e.schema;let a=l;t.name==="svg"&&l.space==="html"&&(a=Gm,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:XS(e,t.name,!0),s=FD(e,t),c=Qm(e,t);return YS(e,s,o,t),Xm(s,c),e.ancestors.pop(),e.schema=l,e.create(t,o,s,n)}function $D(e,t,n){const l={};return Xm(l,Qm(e,t)),e.create(t,e.Fragment,l,n)}function UD(e,t){return t.value}function YS(e,t,n,l){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=l)}function Xm(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function VD(e,t,n){return l;function l(a,o,s,c){const f=Array.isArray(s.children)?n:t;return c?f(o,s,c):f(o,s)}}function PD(e,t){return n;function n(l,a,o,s){const c=Array.isArray(o.children),h=Fm(l);return t(a,o,s,c,{columnNumber:h?h.column-1:void 0,fileName:e,lineNumber:h?h.line:void 0},void 0)}}function GD(e,t){const n={};let l,a;for(a in t.properties)if(a!=="children"&&Ym.call(t.properties,a)){const o=YD(e,a,t.properties[a]);if(o){const[s,c]=o;e.tableCellAlignToStyle&&s==="align"&&typeof c=="string"&&OD.has(t.tagName)?l=c:n[s]=c}}if(l){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=l}return n}function FD(e,t){const n={};for(const l of t.attributes)if(l.type==="mdxJsxExpressionAttribute")if(l.data&&l.data.estree&&e.evaluater){const o=l.data.estree.body[0];o.type;const s=o.expression;s.type;const c=s.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else Qo(e,t.position);else{const a=l.name;let o;if(l.value&&typeof l.value=="object")if(l.value.data&&l.value.data.estree&&e.evaluater){const c=l.value.data.estree.body[0];c.type,o=e.evaluater.evaluateExpression(c.expression)}else Qo(e,t.position);else o=l.value===null?!0:l.value;n[a]=o}return n}function Qm(e,t){const n=[];let l=-1;const a=e.passKeys?new Map:MD;for(;++la?0:a+t:t=t>a?a:t,n=n>0?n:0,l.length<1e4)s=Array.from(l),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);o0?(_n(e,e.length,0,t),e):t}const R1={}.hasOwnProperty;function ZS(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Fn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Jt=Si(/[A-Za-z]/),Xt=Si(/[\dA-Za-z]/),nR=Si(/[#-'*+\--9=?A-Z^-~]/);function bc(e){return e!==null&&(e<32||e===127)}const fm=Si(/\d/),rR=Si(/[\dA-Fa-f]/),iR=Si(/[!-/:-@[-`{-~]/);function Ee(e){return e!==null&&e<-2}function ut(e){return e!==null&&(e<0||e===32)}function Ve(e){return e===-2||e===-1||e===32}const $c=Si(new RegExp("\\p{P}|\\p{S}","u")),al=Si(/\s/);function Si(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Sa(e){const t=[];let n=-1,l=0,a=0;for(;++n55295&&o<57344){const c=e.charCodeAt(n+1);o<56320&&c>56319&&c<57344?(s=String.fromCharCode(o,c),a=1):s="�"}else s=String.fromCharCode(o);s&&(t.push(e.slice(l,n),encodeURIComponent(s)),l=n+a+1,s=""),a&&(n+=a,a=0)}return t.join("")+e.slice(l)}function Qe(e,t,n,l){const a=l?l-1:Number.POSITIVE_INFINITY;let o=0;return s;function s(h){return Ve(h)?(e.enter(n),c(h)):t(h)}function c(h){return Ve(h)&&o++s))return;const L=t.events.length;let R=L,V,H;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){if(V){H=t.events[R][1].end;break}V=!0}for(_(l),A=L;Ak;){const M=n[T];t.containerState=M[1],M[0].exit.call(t,e)}n.length=k}function N(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function uR(e,t,n){return Qe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ba(e){if(e===null||ut(e)||al(e))return 1;if($c(e))return 2}function Uc(e,t,n){const l=[];let a=-1;for(;++a1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[l][1].end},g={...e[n][1].start};L1(p,-h),L1(g,h),s={type:h>1?"strongSequence":"emphasisSequence",start:p,end:{...e[l][1].end}},c={type:h>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:g},o={type:h>1?"strongText":"emphasisText",start:{...e[l][1].end},end:{...e[n][1].start}},a={type:h>1?"strong":"emphasis",start:{...s.start},end:{...c.end}},e[l][1].end={...s.start},e[n][1].start={...c.end},f=[],e[l][1].end.offset-e[l][1].start.offset&&(f=Dn(f,[["enter",e[l][1],t],["exit",e[l][1],t]])),f=Dn(f,[["enter",a,t],["enter",s,t],["exit",s,t],["enter",o,t]]),f=Dn(f,Uc(t.parser.constructs.insideSpan.null,e.slice(l+1,n),t)),f=Dn(f,[["exit",o,t],["enter",c,t],["exit",c,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(m=2,f=Dn(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):m=0,_n(e,l-1,n-l+3,f),n=l+f.length-m-2;break}}for(n=-1;++n0&&Ve(A)?Qe(e,N,"linePrefix",o+1)(A):N(A)}function N(A){return A===null||Ee(A)?e.check(H1,E,T)(A):(e.enter("codeFlowValue"),k(A))}function k(A){return A===null||Ee(A)?(e.exit("codeFlowValue"),N(A)):(e.consume(A),k)}function T(A){return e.exit("codeFenced"),t(A)}function M(A,L,R){let V=0;return H;function H(F){return A.enter("lineEnding"),A.consume(F),A.exit("lineEnding"),B}function B(F){return A.enter("codeFencedFence"),Ve(F)?Qe(A,U,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):U(F)}function U(F){return F===c?(A.enter("codeFencedFenceSequence"),ee(F)):R(F)}function ee(F){return F===c?(V++,A.consume(F),ee):V>=s?(A.exit("codeFencedFenceSequence"),Ve(F)?Qe(A,q,"whitespace")(F):q(F)):R(F)}function q(F){return F===null||Ee(F)?(A.exit("codeFencedFence"),L(F)):R(F)}}}function wR(e,t,n){const l=this;return a;function a(s){return s===null?n(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o)}function o(s){return l.parser.lazy[l.now().line]?n(s):t(s)}}const Cp={name:"codeIndented",tokenize:SR},_R={partial:!0,tokenize:kR};function SR(e,t,n){const l=this;return a;function a(f){return e.enter("codeIndented"),Qe(e,o,"linePrefix",5)(f)}function o(f){const m=l.events[l.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?s(f):n(f)}function s(f){return f===null?h(f):Ee(f)?e.attempt(_R,s,h)(f):(e.enter("codeFlowValue"),c(f))}function c(f){return f===null||Ee(f)?(e.exit("codeFlowValue"),s(f)):(e.consume(f),c)}function h(f){return e.exit("codeIndented"),t(f)}}function kR(e,t,n){const l=this;return a;function a(s){return l.parser.lazy[l.now().line]?n(s):Ee(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),a):Qe(e,o,"linePrefix",5)(s)}function o(s){const c=l.events[l.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(s):Ee(s)?a(s):n(s)}}const ER={name:"codeText",previous:CR,resolve:NR,tokenize:jR};function NR(e){let t=e.length-4,n=3,l,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(l=n;++l=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-l+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-l+this.left.length).reverse())}splice(t,n,l){const a=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return l&&Eo(this.left,l),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Eo(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Eo(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(s):e.interrupt(l.parser.constructs.flow,n,t)(s)}}function nk(e,t,n,l,a,o,s,c,h){const f=h||Number.POSITIVE_INFINITY;let m=0;return p;function p(_){return _===60?(e.enter(l),e.enter(a),e.enter(o),e.consume(_),e.exit(o),g):_===null||_===32||_===41||bc(_)?n(_):(e.enter(l),e.enter(s),e.enter(c),e.enter("chunkString",{contentType:"string"}),E(_))}function g(_){return _===62?(e.enter(o),e.consume(_),e.exit(o),e.exit(a),e.exit(l),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),b(_))}function b(_){return _===62?(e.exit("chunkString"),e.exit(c),g(_)):_===null||_===60||Ee(_)?n(_):(e.consume(_),_===92?w:b)}function w(_){return _===60||_===62||_===92?(e.consume(_),b):b(_)}function E(_){return!m&&(_===null||_===41||ut(_))?(e.exit("chunkString"),e.exit(c),e.exit(s),e.exit(l),t(_)):m999||b===null||b===91||b===93&&!h||b===94&&!c&&"_hiddenFootnoteSupport"in s.parser.constructs?n(b):b===93?(e.exit(o),e.enter(a),e.consume(b),e.exit(a),e.exit(l),t):Ee(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===null||b===91||b===93||Ee(b)||c++>999?(e.exit("chunkString"),m(b)):(e.consume(b),h||(h=!Ve(b)),b===92?g:p)}function g(b){return b===91||b===92||b===93?(e.consume(b),c++,p):p(b)}}function ik(e,t,n,l,a,o){let s;return c;function c(g){return g===34||g===39||g===40?(e.enter(l),e.enter(a),e.consume(g),e.exit(a),s=g===40?41:g,h):n(g)}function h(g){return g===s?(e.enter(a),e.consume(g),e.exit(a),e.exit(l),t):(e.enter(o),f(g))}function f(g){return g===s?(e.exit(o),h(s)):g===null?n(g):Ee(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),Qe(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(g))}function m(g){return g===s||g===null||Ee(g)?(e.exit("chunkString"),f(g)):(e.consume(g),g===92?p:m)}function p(g){return g===s||g===92?(e.consume(g),m):m(g)}}function Lo(e,t){let n;return l;function l(a){return Ee(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,l):Ve(a)?Qe(e,l,n?"linePrefix":"lineSuffix")(a):t(a)}}const LR={name:"definition",tokenize:BR},HR={partial:!0,tokenize:IR};function BR(e,t,n){const l=this;let a;return o;function o(b){return e.enter("definition"),s(b)}function s(b){return rk.call(l,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function c(b){return a=Fn(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),h):n(b)}function h(b){return ut(b)?Lo(e,f)(b):f(b)}function f(b){return nk(e,m,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function m(b){return e.attempt(HR,p,p)(b)}function p(b){return Ve(b)?Qe(e,g,"whitespace")(b):g(b)}function g(b){return b===null||Ee(b)?(e.exit("definition"),l.parser.defined.push(a),t(b)):n(b)}}function IR(e,t,n){return l;function l(c){return ut(c)?Lo(e,a)(c):n(c)}function a(c){return ik(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function o(c){return Ve(c)?Qe(e,s,"whitespace")(c):s(c)}function s(c){return c===null||Ee(c)?t(c):n(c)}}const qR={name:"hardBreakEscape",tokenize:$R};function $R(e,t,n){return l;function l(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return Ee(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const UR={name:"headingAtx",resolve:VR,tokenize:PR};function VR(e,t){let n=e.length-2,l=3,a,o;return e[l][1].type==="whitespace"&&(l+=2),n-2>l&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(l===n-1||n-4>l&&e[n-2][1].type==="whitespace")&&(n-=l+1===n?2:4),n>l&&(a={type:"atxHeadingText",start:e[l][1].start,end:e[n][1].end},o={type:"chunkText",start:e[l][1].start,end:e[n][1].end,contentType:"text"},_n(e,l,n-l+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function PR(e,t,n){let l=0;return a;function a(m){return e.enter("atxHeading"),o(m)}function o(m){return e.enter("atxHeadingSequence"),s(m)}function s(m){return m===35&&l++<6?(e.consume(m),s):m===null||ut(m)?(e.exit("atxHeadingSequence"),c(m)):n(m)}function c(m){return m===35?(e.enter("atxHeadingSequence"),h(m)):m===null||Ee(m)?(e.exit("atxHeading"),t(m)):Ve(m)?Qe(e,c,"whitespace")(m):(e.enter("atxHeadingText"),f(m))}function h(m){return m===35?(e.consume(m),h):(e.exit("atxHeadingSequence"),c(m))}function f(m){return m===null||m===35||ut(m)?(e.exit("atxHeadingText"),c(m)):(e.consume(m),f)}}const GR=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],I1=["pre","script","style","textarea"],FR={concrete:!0,name:"htmlFlow",resolveTo:QR,tokenize:ZR},YR={partial:!0,tokenize:JR},XR={partial:!0,tokenize:KR};function QR(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function ZR(e,t,n){const l=this;let a,o,s,c,h;return f;function f(C){return m(C)}function m(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),p}function p(C){return C===33?(e.consume(C),g):C===47?(e.consume(C),o=!0,E):C===63?(e.consume(C),a=3,l.interrupt?t:D):Jt(C)?(e.consume(C),s=String.fromCharCode(C),S):n(C)}function g(C){return C===45?(e.consume(C),a=2,b):C===91?(e.consume(C),a=5,c=0,w):Jt(C)?(e.consume(C),a=4,l.interrupt?t:D):n(C)}function b(C){return C===45?(e.consume(C),l.interrupt?t:D):n(C)}function w(C){const P="CDATA[";return C===P.charCodeAt(c++)?(e.consume(C),c===P.length?l.interrupt?t:U:w):n(C)}function E(C){return Jt(C)?(e.consume(C),s=String.fromCharCode(C),S):n(C)}function S(C){if(C===null||C===47||C===62||ut(C)){const P=C===47,X=s.toLowerCase();return!P&&!o&&I1.includes(X)?(a=1,l.interrupt?t(C):U(C)):GR.includes(s.toLowerCase())?(a=6,P?(e.consume(C),_):l.interrupt?t(C):U(C)):(a=7,l.interrupt&&!l.parser.lazy[l.now().line]?n(C):o?N(C):k(C))}return C===45||Xt(C)?(e.consume(C),s+=String.fromCharCode(C),S):n(C)}function _(C){return C===62?(e.consume(C),l.interrupt?t:U):n(C)}function N(C){return Ve(C)?(e.consume(C),N):H(C)}function k(C){return C===47?(e.consume(C),H):C===58||C===95||Jt(C)?(e.consume(C),T):Ve(C)?(e.consume(C),k):H(C)}function T(C){return C===45||C===46||C===58||C===95||Xt(C)?(e.consume(C),T):M(C)}function M(C){return C===61?(e.consume(C),A):Ve(C)?(e.consume(C),M):k(C)}function A(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),h=C,L):Ve(C)?(e.consume(C),A):R(C)}function L(C){return C===h?(e.consume(C),h=null,V):C===null||Ee(C)?n(C):(e.consume(C),L)}function R(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||ut(C)?M(C):(e.consume(C),R)}function V(C){return C===47||C===62||Ve(C)?k(C):n(C)}function H(C){return C===62?(e.consume(C),B):n(C)}function B(C){return C===null||Ee(C)?U(C):Ve(C)?(e.consume(C),B):n(C)}function U(C){return C===45&&a===2?(e.consume(C),z):C===60&&a===1?(e.consume(C),G):C===62&&a===4?(e.consume(C),$):C===63&&a===3?(e.consume(C),D):C===93&&a===5?(e.consume(C),K):Ee(C)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(YR,Y,ee)(C)):C===null||Ee(C)?(e.exit("htmlFlowData"),ee(C)):(e.consume(C),U)}function ee(C){return e.check(XR,q,Y)(C)}function q(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),F}function F(C){return C===null||Ee(C)?ee(C):(e.enter("htmlFlowData"),U(C))}function z(C){return C===45?(e.consume(C),D):U(C)}function G(C){return C===47?(e.consume(C),s="",Q):U(C)}function Q(C){if(C===62){const P=s.toLowerCase();return I1.includes(P)?(e.consume(C),$):U(C)}return Jt(C)&&s.length<8?(e.consume(C),s+=String.fromCharCode(C),Q):U(C)}function K(C){return C===93?(e.consume(C),D):U(C)}function D(C){return C===62?(e.consume(C),$):C===45&&a===2?(e.consume(C),D):U(C)}function $(C){return C===null||Ee(C)?(e.exit("htmlFlowData"),Y(C)):(e.consume(C),$)}function Y(C){return e.exit("htmlFlow"),t(C)}}function KR(e,t,n){const l=this;return a;function a(s){return Ee(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o):n(s)}function o(s){return l.parser.lazy[l.now().line]?n(s):t(s)}}function JR(e,t,n){return l;function l(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(ss,t,n)}}const WR={name:"htmlText",tokenize:eO};function eO(e,t,n){const l=this;let a,o,s;return c;function c(D){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(D),h}function h(D){return D===33?(e.consume(D),f):D===47?(e.consume(D),M):D===63?(e.consume(D),k):Jt(D)?(e.consume(D),R):n(D)}function f(D){return D===45?(e.consume(D),m):D===91?(e.consume(D),o=0,w):Jt(D)?(e.consume(D),N):n(D)}function m(D){return D===45?(e.consume(D),b):n(D)}function p(D){return D===null?n(D):D===45?(e.consume(D),g):Ee(D)?(s=p,G(D)):(e.consume(D),p)}function g(D){return D===45?(e.consume(D),b):p(D)}function b(D){return D===62?z(D):D===45?g(D):p(D)}function w(D){const $="CDATA[";return D===$.charCodeAt(o++)?(e.consume(D),o===$.length?E:w):n(D)}function E(D){return D===null?n(D):D===93?(e.consume(D),S):Ee(D)?(s=E,G(D)):(e.consume(D),E)}function S(D){return D===93?(e.consume(D),_):E(D)}function _(D){return D===62?z(D):D===93?(e.consume(D),_):E(D)}function N(D){return D===null||D===62?z(D):Ee(D)?(s=N,G(D)):(e.consume(D),N)}function k(D){return D===null?n(D):D===63?(e.consume(D),T):Ee(D)?(s=k,G(D)):(e.consume(D),k)}function T(D){return D===62?z(D):k(D)}function M(D){return Jt(D)?(e.consume(D),A):n(D)}function A(D){return D===45||Xt(D)?(e.consume(D),A):L(D)}function L(D){return Ee(D)?(s=L,G(D)):Ve(D)?(e.consume(D),L):z(D)}function R(D){return D===45||Xt(D)?(e.consume(D),R):D===47||D===62||ut(D)?V(D):n(D)}function V(D){return D===47?(e.consume(D),z):D===58||D===95||Jt(D)?(e.consume(D),H):Ee(D)?(s=V,G(D)):Ve(D)?(e.consume(D),V):z(D)}function H(D){return D===45||D===46||D===58||D===95||Xt(D)?(e.consume(D),H):B(D)}function B(D){return D===61?(e.consume(D),U):Ee(D)?(s=B,G(D)):Ve(D)?(e.consume(D),B):V(D)}function U(D){return D===null||D===60||D===61||D===62||D===96?n(D):D===34||D===39?(e.consume(D),a=D,ee):Ee(D)?(s=U,G(D)):Ve(D)?(e.consume(D),U):(e.consume(D),q)}function ee(D){return D===a?(e.consume(D),a=void 0,F):D===null?n(D):Ee(D)?(s=ee,G(D)):(e.consume(D),ee)}function q(D){return D===null||D===34||D===39||D===60||D===61||D===96?n(D):D===47||D===62||ut(D)?V(D):(e.consume(D),q)}function F(D){return D===47||D===62||ut(D)?V(D):n(D)}function z(D){return D===62?(e.consume(D),e.exit("htmlTextData"),e.exit("htmlText"),t):n(D)}function G(D){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),Q}function Q(D){return Ve(D)?Qe(e,K,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):K(D)}function K(D){return e.enter("htmlTextData"),s(D)}}const Jm={name:"labelEnd",resolveAll:iO,resolveTo:lO,tokenize:aO},tO={tokenize:oO},nO={tokenize:sO},rO={tokenize:uO};function iO(e){let t=-1;const n=[];for(;++t=3&&(f===null||Ee(f))?(e.exit("thematicBreak"),t(f)):n(f)}function h(f){return f===a?(e.consume(f),l++,h):(e.exit("thematicBreakSequence"),Ve(f)?Qe(e,c,"whitespace")(f):c(f))}}const sn={continuation:{tokenize:vO},exit:wO,name:"list",tokenize:yO},gO={partial:!0,tokenize:_O},xO={partial:!0,tokenize:bO};function yO(e,t,n){const l=this,a=l.events[l.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,s=0;return c;function c(b){const w=l.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!l.containerState.marker||b===l.containerState.marker:fm(b)){if(l.containerState.type||(l.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(rc,n,f)(b):f(b);if(!l.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),h(b)}return n(b)}function h(b){return fm(b)&&++s<10?(e.consume(b),h):(!l.interrupt||s<2)&&(l.containerState.marker?b===l.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),f(b)):n(b)}function f(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),l.containerState.marker=l.containerState.marker||b,e.check(ss,l.interrupt?n:m,e.attempt(gO,g,p))}function m(b){return l.containerState.initialBlankLine=!0,o++,g(b)}function p(b){return Ve(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),g):n(b)}function g(b){return l.containerState.size=o+l.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(b)}}function vO(e,t,n){const l=this;return l.containerState._closeFlow=void 0,e.check(ss,a,o);function a(c){return l.containerState.furtherBlankLines=l.containerState.furtherBlankLines||l.containerState.initialBlankLine,Qe(e,t,"listItemIndent",l.containerState.size+1)(c)}function o(c){return l.containerState.furtherBlankLines||!Ve(c)?(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,s(c)):(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,e.attempt(xO,t,s)(c))}function s(c){return l.containerState._closeFlow=!0,l.interrupt=void 0,Qe(e,e.attempt(sn,t,n),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function bO(e,t,n){const l=this;return Qe(e,a,"listItemIndent",l.containerState.size+1);function a(o){const s=l.events[l.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===l.containerState.size?t(o):n(o)}}function wO(e){e.exit(this.containerState.type)}function _O(e,t,n){const l=this;return Qe(e,a,"listItemPrefixWhitespace",l.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const s=l.events[l.events.length-1];return!Ve(o)&&s&&s[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const q1={name:"setextUnderline",resolveTo:SO,tokenize:kO};function SO(e,t){let n=e.length,l,a,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){l=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const s={type:"setextHeading",start:{...e[l][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",s,t]),e.splice(o+1,0,["exit",e[l][1],t]),e[l][1].end={...e[o][1].end}):e[l][1]=s,e.push(["exit",s,t]),e}function kO(e,t,n){const l=this;let a;return o;function o(f){let m=l.events.length,p;for(;m--;)if(l.events[m][1].type!=="lineEnding"&&l.events[m][1].type!=="linePrefix"&&l.events[m][1].type!=="content"){p=l.events[m][1].type==="paragraph";break}return!l.parser.lazy[l.now().line]&&(l.interrupt||p)?(e.enter("setextHeadingLine"),a=f,s(f)):n(f)}function s(f){return e.enter("setextHeadingLineSequence"),c(f)}function c(f){return f===a?(e.consume(f),c):(e.exit("setextHeadingLineSequence"),Ve(f)?Qe(e,h,"lineSuffix")(f):h(f))}function h(f){return f===null||Ee(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const EO={tokenize:NO};function NO(e){const t=this,n=e.attempt(ss,l,e.attempt(this.parser.constructs.flowInitial,a,Qe(e,e.attempt(this.parser.constructs.flow,a,e.attempt(zR,a)),"linePrefix")));return n;function l(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const CO={resolveAll:ak()},jO=lk("string"),TO=lk("text");function lk(e){return{resolveAll:ak(e==="text"?AO:void 0),tokenize:t};function t(n){const l=this,a=this.parser.constructs[e],o=n.attempt(a,s,c);return s;function s(m){return f(m)?o(m):c(m)}function c(m){if(m===null){n.consume(m);return}return n.enter("data"),n.consume(m),h}function h(m){return f(m)?(n.exit("data"),o(m)):(n.consume(m),h)}function f(m){if(m===null)return!0;const p=a[m];let g=-1;if(p)for(;++g-1){const c=s[0];typeof c=="string"?s[0]=c.slice(l):s.shift()}o>0&&s.push(e[a].slice(0,o))}return s}function VO(e,t){let n=-1;const l=[];let a;for(;++n0?c.push({label:"Bindings",value:a.join(", ")}):t==="completed"&&c.push({label:"Bindings",value:"scalar"}),e.error_type&&c.push({label:"Error",value:e.error_type}),e.error_message&&c.push({label:"Message",value:e.error_message}),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${n}20`,color:n},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Set"})]}),y.jsx(Br,{items:c}),o&&y.jsx(_i,{output:o,title:"Value preview"})]})}function cD(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const fD=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,dD=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,hD={};function _1(e,t){return(hD.jsx?dD:fD).test(e)}const pD=/[ \t\n\f\r]/g;function mD(e){return typeof e=="object"?e.type==="text"?S1(e.value):!1:S1(e)}function S1(e){return e.replace(pD,"")===""}class os{constructor(t,n,l){this.normal=n,this.property=t,l&&(this.space=l)}}os.prototype.normal={};os.prototype.property={};os.prototype.space=void 0;function LS(e,t){const n={},l={};for(const a of e)Object.assign(n,a.property),Object.assign(l,a.normal);return new os(n,l,t)}function om(e){return e.toLowerCase()}class cn{constructor(t,n){this.attribute=n,this.property=t}}cn.prototype.attribute="";cn.prototype.booleanish=!1;cn.prototype.boolean=!1;cn.prototype.commaOrSpaceSeparated=!1;cn.prototype.commaSeparated=!1;cn.prototype.defined=!1;cn.prototype.mustUseProperty=!1;cn.prototype.number=!1;cn.prototype.overloadedBoolean=!1;cn.prototype.property="";cn.prototype.spaceSeparated=!1;cn.prototype.space=void 0;let gD=0;const He=fl(),At=fl(),sm=fl(),me=fl(),ct=fl(),da=fl(),vn=fl();function fl(){return 2**++gD}const um=Object.freeze(Object.defineProperty({__proto__:null,boolean:He,booleanish:At,commaOrSpaceSeparated:vn,commaSeparated:da,number:me,overloadedBoolean:sm,spaceSeparated:ct},Symbol.toStringTag,{value:"Module"})),kp=Object.keys(um);class Pm extends cn{constructor(t,n,l,a){let o=-1;if(super(t,n),k1(this,"space",a),typeof l=="number")for(;++o4&&n.slice(0,4)==="data"&&wD.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(E1,kD);l="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!E1.test(o)){let s=o.replace(bD,SD);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}a=Pm}return new a(l,t)}function SD(e){return"-"+e.toLowerCase()}function kD(e){return e.charAt(1).toUpperCase()}const ED=LS([HS,xD,qS,$S,US],"html"),Gm=LS([HS,yD,qS,$S,US],"svg");function ND(e){return e.join(" ").trim()}var ea={},Ep,N1;function CD(){if(N1)return Ep;N1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,s=/^[;\s]*/,c=/^\s+|\s+$/g,h=` +`,f="/",m="*",p="",g="comment",b="declaration";function w(S,_){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];_=_||{};var N=1,k=1;function T(q){var F=q.match(t);F&&(N+=F.length);var z=q.lastIndexOf(h);k=~z?q.length-z:k+q.length}function M(){var q={line:N,column:k};return function(F){return F.position=new A(q),V(),F}}function A(q){this.start=q,this.end={line:N,column:k},this.source=_.source}A.prototype.content=S;function L(q){var F=new Error(_.source+":"+N+":"+k+": "+q);if(F.reason=q,F.filename=_.source,F.line=N,F.column=k,F.source=S,!_.silent)throw F}function R(q){var F=q.exec(S);if(F){var z=F[0];return T(z),S=S.slice(z.length),F}}function V(){R(n)}function H(q){var F;for(q=q||[];F=B();)F!==!1&&q.push(F);return q}function B(){var q=M();if(!(f!=S.charAt(0)||m!=S.charAt(1))){for(var F=2;p!=S.charAt(F)&&(m!=S.charAt(F)||f!=S.charAt(F+1));)++F;if(F+=2,p===S.charAt(F-1))return L("End of comment missing");var z=S.slice(2,F-2);return k+=2,T(z),S=S.slice(F),k+=2,q({type:g,comment:z})}}function U(){var q=M(),F=R(l);if(F){if(B(),!R(a))return L("property missing ':'");var z=R(o),G=q({type:b,property:E(F[0].replace(e,p)),value:z?E(z[0].replace(e,p)):p});return R(s),G}}function ee(){var q=[];H(q);for(var F;F=U();)F!==!1&&(q.push(F),H(q));return q}return V(),ee()}function E(S){return S?S.replace(c,p):p}return Ep=w,Ep}var C1;function jD(){if(C1)return ea;C1=1;var e=ea&&ea.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(ea,"__esModule",{value:!0}),ea.default=n;const t=e(CD());function n(l,a){let o=null;if(!l||typeof l!="string")return o;const s=(0,t.default)(l),c=typeof a=="function";return s.forEach(h=>{if(h.type!=="declaration")return;const{property:f,value:m}=h;c?a(f,m,h):m&&(o=o||{},o[f]=m)}),o}return ea}var So={},j1;function TD(){if(j1)return So;j1=1,Object.defineProperty(So,"__esModule",{value:!0}),So.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(f){return!f||n.test(f)||e.test(f)},s=function(f,m){return m.toUpperCase()},c=function(f,m){return"".concat(m,"-")},h=function(f,m){return m===void 0&&(m={}),o(f)?f:(f=f.toLowerCase(),m.reactCompat?f=f.replace(a,c):f=f.replace(l,c),f.replace(t,s))};return So.camelCase=h,So}var ko,T1;function AD(){if(T1)return ko;T1=1;var e=ko&&ko.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(jD()),n=TD();function l(a,o){var s={};return!a||typeof a!="string"||(0,t.default)(a,function(c,h){c&&h&&(s[(0,n.camelCase)(c,o)]=h)}),s}return l.default=l,ko=l,ko}var zD=AD();const MD=Ko(zD),VS=PS("end"),Fm=PS("start");function PS(e){return t;function t(n){const l=n&&n.position&&n.position[e]||{};if(typeof l.line=="number"&&l.line>0&&typeof l.column=="number"&&l.column>0)return{line:l.line,column:l.column,offset:typeof l.offset=="number"&&l.offset>-1?l.offset:void 0}}}function DD(e){const t=Fm(e),n=VS(e);if(t&&n)return{start:t,end:n}}function Oo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?A1(e.position):"start"in e||"end"in e?A1(e):"line"in e||"column"in e?cm(e):""}function cm(e){return z1(e&&e.line)+":"+z1(e&&e.column)}function A1(e){return cm(e&&e.start)+"-"+cm(e&&e.end)}function z1(e){return e&&typeof e=="number"?e:1}class Qt extends Error{constructor(t,n,l){super(),typeof n=="string"&&(l=n,n=void 0);let a="",o={},s=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?a=t:!o.cause&&t&&(s=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof l=="string"){const h=l.indexOf(":");h===-1?o.ruleId=l:(o.source=l.slice(0,h),o.ruleId=l.slice(h+1))}if(!o.place&&o.ancestors&&o.ancestors){const h=o.ancestors[o.ancestors.length-1];h&&(o.place=h.position)}const c=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=c?c.line:void 0,this.name=Oo(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=s&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Qt.prototype.file="";Qt.prototype.name="";Qt.prototype.reason="";Qt.prototype.message="";Qt.prototype.stack="";Qt.prototype.column=void 0;Qt.prototype.line=void 0;Qt.prototype.ancestors=void 0;Qt.prototype.cause=void 0;Qt.prototype.fatal=void 0;Qt.prototype.place=void 0;Qt.prototype.ruleId=void 0;Qt.prototype.source=void 0;const Ym={}.hasOwnProperty,RD=new Map,OD=/[A-Z]/g,LD=new Set(["table","tbody","thead","tfoot","tr"]),HD=new Set(["td","th"]),GS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function BD(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let l;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");l=FD(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");l=GD(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:l,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Gm:ED,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=FS(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function FS(e,t,n){if(t.type==="element")return ID(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return qD(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return UD(e,t,n);if(t.type==="mdxjsEsm")return $D(e,t);if(t.type==="root")return VD(e,t,n);if(t.type==="text")return PD(e,t)}function ID(e,t,n){const l=e.schema;let a=l;t.tagName.toLowerCase()==="svg"&&l.space==="html"&&(a=Gm,e.schema=a),e.ancestors.push(t);const o=XS(e,t.tagName,!1),s=YD(e,t);let c=Qm(e,t);return LD.has(t.tagName)&&(c=c.filter(function(h){return typeof h=="string"?!mD(h):!0})),YS(e,s,o,t),Xm(s,c),e.ancestors.pop(),e.schema=l,e.create(t,o,s,n)}function qD(e,t){if(t.data&&t.data.estree&&e.evaluater){const l=t.data.estree.body[0];return l.type,e.evaluater.evaluateExpression(l.expression)}Qo(e,t.position)}function $D(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Qo(e,t.position)}function UD(e,t,n){const l=e.schema;let a=l;t.name==="svg"&&l.space==="html"&&(a=Gm,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:XS(e,t.name,!0),s=XD(e,t),c=Qm(e,t);return YS(e,s,o,t),Xm(s,c),e.ancestors.pop(),e.schema=l,e.create(t,o,s,n)}function VD(e,t,n){const l={};return Xm(l,Qm(e,t)),e.create(t,e.Fragment,l,n)}function PD(e,t){return t.value}function YS(e,t,n,l){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=l)}function Xm(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function GD(e,t,n){return l;function l(a,o,s,c){const f=Array.isArray(s.children)?n:t;return c?f(o,s,c):f(o,s)}}function FD(e,t){return n;function n(l,a,o,s){const c=Array.isArray(o.children),h=Fm(l);return t(a,o,s,c,{columnNumber:h?h.column-1:void 0,fileName:e,lineNumber:h?h.line:void 0},void 0)}}function YD(e,t){const n={};let l,a;for(a in t.properties)if(a!=="children"&&Ym.call(t.properties,a)){const o=QD(e,a,t.properties[a]);if(o){const[s,c]=o;e.tableCellAlignToStyle&&s==="align"&&typeof c=="string"&&HD.has(t.tagName)?l=c:n[s]=c}}if(l){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=l}return n}function XD(e,t){const n={};for(const l of t.attributes)if(l.type==="mdxJsxExpressionAttribute")if(l.data&&l.data.estree&&e.evaluater){const o=l.data.estree.body[0];o.type;const s=o.expression;s.type;const c=s.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else Qo(e,t.position);else{const a=l.name;let o;if(l.value&&typeof l.value=="object")if(l.value.data&&l.value.data.estree&&e.evaluater){const c=l.value.data.estree.body[0];c.type,o=e.evaluater.evaluateExpression(c.expression)}else Qo(e,t.position);else o=l.value===null?!0:l.value;n[a]=o}return n}function Qm(e,t){const n=[];let l=-1;const a=e.passKeys?new Map:RD;for(;++la?0:a+t:t=t>a?a:t,n=n>0?n:0,l.length<1e4)s=Array.from(l),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);o0?(_n(e,e.length,0,t),e):t}const R1={}.hasOwnProperty;function ZS(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Yn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Jt=Si(/[A-Za-z]/),Xt=Si(/[\dA-Za-z]/),iR=Si(/[#-'*+\--9=?A-Z^-~]/);function bc(e){return e!==null&&(e<32||e===127)}const fm=Si(/\d/),lR=Si(/[\dA-Fa-f]/),aR=Si(/[!-/:-@[-`{-~]/);function Ee(e){return e!==null&&e<-2}function ut(e){return e!==null&&(e<0||e===32)}function Ve(e){return e===-2||e===-1||e===32}const $c=Si(new RegExp("\\p{P}|\\p{S}","u")),al=Si(/\s/);function Si(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Sa(e){const t=[];let n=-1,l=0,a=0;for(;++n55295&&o<57344){const c=e.charCodeAt(n+1);o<56320&&c>56319&&c<57344?(s=String.fromCharCode(o,c),a=1):s="�"}else s=String.fromCharCode(o);s&&(t.push(e.slice(l,n),encodeURIComponent(s)),l=n+a+1,s=""),a&&(n+=a,a=0)}return t.join("")+e.slice(l)}function Qe(e,t,n,l){const a=l?l-1:Number.POSITIVE_INFINITY;let o=0;return s;function s(h){return Ve(h)?(e.enter(n),c(h)):t(h)}function c(h){return Ve(h)&&o++s))return;const L=t.events.length;let R=L,V,H;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){if(V){H=t.events[R][1].end;break}V=!0}for(_(l),A=L;Ak;){const M=n[T];t.containerState=M[1],M[0].exit.call(t,e)}n.length=k}function N(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function fR(e,t,n){return Qe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function wa(e){if(e===null||ut(e)||al(e))return 1;if($c(e))return 2}function Uc(e,t,n){const l=[];let a=-1;for(;++a1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[l][1].end},g={...e[n][1].start};L1(p,-h),L1(g,h),s={type:h>1?"strongSequence":"emphasisSequence",start:p,end:{...e[l][1].end}},c={type:h>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:g},o={type:h>1?"strongText":"emphasisText",start:{...e[l][1].end},end:{...e[n][1].start}},a={type:h>1?"strong":"emphasis",start:{...s.start},end:{...c.end}},e[l][1].end={...s.start},e[n][1].start={...c.end},f=[],e[l][1].end.offset-e[l][1].start.offset&&(f=Dn(f,[["enter",e[l][1],t],["exit",e[l][1],t]])),f=Dn(f,[["enter",a,t],["enter",s,t],["exit",s,t],["enter",o,t]]),f=Dn(f,Uc(t.parser.constructs.insideSpan.null,e.slice(l+1,n),t)),f=Dn(f,[["exit",o,t],["enter",c,t],["exit",c,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(m=2,f=Dn(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):m=0,_n(e,l-1,n-l+3,f),n=l+f.length-m-2;break}}for(n=-1;++n0&&Ve(A)?Qe(e,N,"linePrefix",o+1)(A):N(A)}function N(A){return A===null||Ee(A)?e.check(H1,E,T)(A):(e.enter("codeFlowValue"),k(A))}function k(A){return A===null||Ee(A)?(e.exit("codeFlowValue"),N(A)):(e.consume(A),k)}function T(A){return e.exit("codeFenced"),t(A)}function M(A,L,R){let V=0;return H;function H(F){return A.enter("lineEnding"),A.consume(F),A.exit("lineEnding"),B}function B(F){return A.enter("codeFencedFence"),Ve(F)?Qe(A,U,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):U(F)}function U(F){return F===c?(A.enter("codeFencedFenceSequence"),ee(F)):R(F)}function ee(F){return F===c?(V++,A.consume(F),ee):V>=s?(A.exit("codeFencedFenceSequence"),Ve(F)?Qe(A,q,"whitespace")(F):q(F)):R(F)}function q(F){return F===null||Ee(F)?(A.exit("codeFencedFence"),L(F)):R(F)}}}function SR(e,t,n){const l=this;return a;function a(s){return s===null?n(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o)}function o(s){return l.parser.lazy[l.now().line]?n(s):t(s)}}const Cp={name:"codeIndented",tokenize:ER},kR={partial:!0,tokenize:NR};function ER(e,t,n){const l=this;return a;function a(f){return e.enter("codeIndented"),Qe(e,o,"linePrefix",5)(f)}function o(f){const m=l.events[l.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?s(f):n(f)}function s(f){return f===null?h(f):Ee(f)?e.attempt(kR,s,h)(f):(e.enter("codeFlowValue"),c(f))}function c(f){return f===null||Ee(f)?(e.exit("codeFlowValue"),s(f)):(e.consume(f),c)}function h(f){return e.exit("codeIndented"),t(f)}}function NR(e,t,n){const l=this;return a;function a(s){return l.parser.lazy[l.now().line]?n(s):Ee(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),a):Qe(e,o,"linePrefix",5)(s)}function o(s){const c=l.events[l.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(s):Ee(s)?a(s):n(s)}}const CR={name:"codeText",previous:TR,resolve:jR,tokenize:AR};function jR(e){let t=e.length-4,n=3,l,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(l=n;++l=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-l+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-l+this.left.length).reverse())}splice(t,n,l){const a=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return l&&Eo(this.left,l),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Eo(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Eo(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(s):e.interrupt(l.parser.constructs.flow,n,t)(s)}}function nk(e,t,n,l,a,o,s,c,h){const f=h||Number.POSITIVE_INFINITY;let m=0;return p;function p(_){return _===60?(e.enter(l),e.enter(a),e.enter(o),e.consume(_),e.exit(o),g):_===null||_===32||_===41||bc(_)?n(_):(e.enter(l),e.enter(s),e.enter(c),e.enter("chunkString",{contentType:"string"}),E(_))}function g(_){return _===62?(e.enter(o),e.consume(_),e.exit(o),e.exit(a),e.exit(l),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),b(_))}function b(_){return _===62?(e.exit("chunkString"),e.exit(c),g(_)):_===null||_===60||Ee(_)?n(_):(e.consume(_),_===92?w:b)}function w(_){return _===60||_===62||_===92?(e.consume(_),b):b(_)}function E(_){return!m&&(_===null||_===41||ut(_))?(e.exit("chunkString"),e.exit(c),e.exit(s),e.exit(l),t(_)):m999||b===null||b===91||b===93&&!h||b===94&&!c&&"_hiddenFootnoteSupport"in s.parser.constructs?n(b):b===93?(e.exit(o),e.enter(a),e.consume(b),e.exit(a),e.exit(l),t):Ee(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===null||b===91||b===93||Ee(b)||c++>999?(e.exit("chunkString"),m(b)):(e.consume(b),h||(h=!Ve(b)),b===92?g:p)}function g(b){return b===91||b===92||b===93?(e.consume(b),c++,p):p(b)}}function ik(e,t,n,l,a,o){let s;return c;function c(g){return g===34||g===39||g===40?(e.enter(l),e.enter(a),e.consume(g),e.exit(a),s=g===40?41:g,h):n(g)}function h(g){return g===s?(e.enter(a),e.consume(g),e.exit(a),e.exit(l),t):(e.enter(o),f(g))}function f(g){return g===s?(e.exit(o),h(s)):g===null?n(g):Ee(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),Qe(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(g))}function m(g){return g===s||g===null||Ee(g)?(e.exit("chunkString"),f(g)):(e.consume(g),g===92?p:m)}function p(g){return g===s||g===92?(e.consume(g),m):m(g)}}function Lo(e,t){let n;return l;function l(a){return Ee(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,l):Ve(a)?Qe(e,l,n?"linePrefix":"lineSuffix")(a):t(a)}}const BR={name:"definition",tokenize:qR},IR={partial:!0,tokenize:$R};function qR(e,t,n){const l=this;let a;return o;function o(b){return e.enter("definition"),s(b)}function s(b){return rk.call(l,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function c(b){return a=Yn(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),h):n(b)}function h(b){return ut(b)?Lo(e,f)(b):f(b)}function f(b){return nk(e,m,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function m(b){return e.attempt(IR,p,p)(b)}function p(b){return Ve(b)?Qe(e,g,"whitespace")(b):g(b)}function g(b){return b===null||Ee(b)?(e.exit("definition"),l.parser.defined.push(a),t(b)):n(b)}}function $R(e,t,n){return l;function l(c){return ut(c)?Lo(e,a)(c):n(c)}function a(c){return ik(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function o(c){return Ve(c)?Qe(e,s,"whitespace")(c):s(c)}function s(c){return c===null||Ee(c)?t(c):n(c)}}const UR={name:"hardBreakEscape",tokenize:VR};function VR(e,t,n){return l;function l(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return Ee(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const PR={name:"headingAtx",resolve:GR,tokenize:FR};function GR(e,t){let n=e.length-2,l=3,a,o;return e[l][1].type==="whitespace"&&(l+=2),n-2>l&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(l===n-1||n-4>l&&e[n-2][1].type==="whitespace")&&(n-=l+1===n?2:4),n>l&&(a={type:"atxHeadingText",start:e[l][1].start,end:e[n][1].end},o={type:"chunkText",start:e[l][1].start,end:e[n][1].end,contentType:"text"},_n(e,l,n-l+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function FR(e,t,n){let l=0;return a;function a(m){return e.enter("atxHeading"),o(m)}function o(m){return e.enter("atxHeadingSequence"),s(m)}function s(m){return m===35&&l++<6?(e.consume(m),s):m===null||ut(m)?(e.exit("atxHeadingSequence"),c(m)):n(m)}function c(m){return m===35?(e.enter("atxHeadingSequence"),h(m)):m===null||Ee(m)?(e.exit("atxHeading"),t(m)):Ve(m)?Qe(e,c,"whitespace")(m):(e.enter("atxHeadingText"),f(m))}function h(m){return m===35?(e.consume(m),h):(e.exit("atxHeadingSequence"),c(m))}function f(m){return m===null||m===35||ut(m)?(e.exit("atxHeadingText"),c(m)):(e.consume(m),f)}}const YR=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],I1=["pre","script","style","textarea"],XR={concrete:!0,name:"htmlFlow",resolveTo:KR,tokenize:JR},QR={partial:!0,tokenize:eO},ZR={partial:!0,tokenize:WR};function KR(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function JR(e,t,n){const l=this;let a,o,s,c,h;return f;function f(C){return m(C)}function m(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),p}function p(C){return C===33?(e.consume(C),g):C===47?(e.consume(C),o=!0,E):C===63?(e.consume(C),a=3,l.interrupt?t:D):Jt(C)?(e.consume(C),s=String.fromCharCode(C),S):n(C)}function g(C){return C===45?(e.consume(C),a=2,b):C===91?(e.consume(C),a=5,c=0,w):Jt(C)?(e.consume(C),a=4,l.interrupt?t:D):n(C)}function b(C){return C===45?(e.consume(C),l.interrupt?t:D):n(C)}function w(C){const P="CDATA[";return C===P.charCodeAt(c++)?(e.consume(C),c===P.length?l.interrupt?t:U:w):n(C)}function E(C){return Jt(C)?(e.consume(C),s=String.fromCharCode(C),S):n(C)}function S(C){if(C===null||C===47||C===62||ut(C)){const P=C===47,X=s.toLowerCase();return!P&&!o&&I1.includes(X)?(a=1,l.interrupt?t(C):U(C)):YR.includes(s.toLowerCase())?(a=6,P?(e.consume(C),_):l.interrupt?t(C):U(C)):(a=7,l.interrupt&&!l.parser.lazy[l.now().line]?n(C):o?N(C):k(C))}return C===45||Xt(C)?(e.consume(C),s+=String.fromCharCode(C),S):n(C)}function _(C){return C===62?(e.consume(C),l.interrupt?t:U):n(C)}function N(C){return Ve(C)?(e.consume(C),N):H(C)}function k(C){return C===47?(e.consume(C),H):C===58||C===95||Jt(C)?(e.consume(C),T):Ve(C)?(e.consume(C),k):H(C)}function T(C){return C===45||C===46||C===58||C===95||Xt(C)?(e.consume(C),T):M(C)}function M(C){return C===61?(e.consume(C),A):Ve(C)?(e.consume(C),M):k(C)}function A(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),h=C,L):Ve(C)?(e.consume(C),A):R(C)}function L(C){return C===h?(e.consume(C),h=null,V):C===null||Ee(C)?n(C):(e.consume(C),L)}function R(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||ut(C)?M(C):(e.consume(C),R)}function V(C){return C===47||C===62||Ve(C)?k(C):n(C)}function H(C){return C===62?(e.consume(C),B):n(C)}function B(C){return C===null||Ee(C)?U(C):Ve(C)?(e.consume(C),B):n(C)}function U(C){return C===45&&a===2?(e.consume(C),z):C===60&&a===1?(e.consume(C),G):C===62&&a===4?(e.consume(C),$):C===63&&a===3?(e.consume(C),D):C===93&&a===5?(e.consume(C),K):Ee(C)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(QR,Y,ee)(C)):C===null||Ee(C)?(e.exit("htmlFlowData"),ee(C)):(e.consume(C),U)}function ee(C){return e.check(ZR,q,Y)(C)}function q(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),F}function F(C){return C===null||Ee(C)?ee(C):(e.enter("htmlFlowData"),U(C))}function z(C){return C===45?(e.consume(C),D):U(C)}function G(C){return C===47?(e.consume(C),s="",Q):U(C)}function Q(C){if(C===62){const P=s.toLowerCase();return I1.includes(P)?(e.consume(C),$):U(C)}return Jt(C)&&s.length<8?(e.consume(C),s+=String.fromCharCode(C),Q):U(C)}function K(C){return C===93?(e.consume(C),D):U(C)}function D(C){return C===62?(e.consume(C),$):C===45&&a===2?(e.consume(C),D):U(C)}function $(C){return C===null||Ee(C)?(e.exit("htmlFlowData"),Y(C)):(e.consume(C),$)}function Y(C){return e.exit("htmlFlow"),t(C)}}function WR(e,t,n){const l=this;return a;function a(s){return Ee(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o):n(s)}function o(s){return l.parser.lazy[l.now().line]?n(s):t(s)}}function eO(e,t,n){return l;function l(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(ss,t,n)}}const tO={name:"htmlText",tokenize:nO};function nO(e,t,n){const l=this;let a,o,s;return c;function c(D){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(D),h}function h(D){return D===33?(e.consume(D),f):D===47?(e.consume(D),M):D===63?(e.consume(D),k):Jt(D)?(e.consume(D),R):n(D)}function f(D){return D===45?(e.consume(D),m):D===91?(e.consume(D),o=0,w):Jt(D)?(e.consume(D),N):n(D)}function m(D){return D===45?(e.consume(D),b):n(D)}function p(D){return D===null?n(D):D===45?(e.consume(D),g):Ee(D)?(s=p,G(D)):(e.consume(D),p)}function g(D){return D===45?(e.consume(D),b):p(D)}function b(D){return D===62?z(D):D===45?g(D):p(D)}function w(D){const $="CDATA[";return D===$.charCodeAt(o++)?(e.consume(D),o===$.length?E:w):n(D)}function E(D){return D===null?n(D):D===93?(e.consume(D),S):Ee(D)?(s=E,G(D)):(e.consume(D),E)}function S(D){return D===93?(e.consume(D),_):E(D)}function _(D){return D===62?z(D):D===93?(e.consume(D),_):E(D)}function N(D){return D===null||D===62?z(D):Ee(D)?(s=N,G(D)):(e.consume(D),N)}function k(D){return D===null?n(D):D===63?(e.consume(D),T):Ee(D)?(s=k,G(D)):(e.consume(D),k)}function T(D){return D===62?z(D):k(D)}function M(D){return Jt(D)?(e.consume(D),A):n(D)}function A(D){return D===45||Xt(D)?(e.consume(D),A):L(D)}function L(D){return Ee(D)?(s=L,G(D)):Ve(D)?(e.consume(D),L):z(D)}function R(D){return D===45||Xt(D)?(e.consume(D),R):D===47||D===62||ut(D)?V(D):n(D)}function V(D){return D===47?(e.consume(D),z):D===58||D===95||Jt(D)?(e.consume(D),H):Ee(D)?(s=V,G(D)):Ve(D)?(e.consume(D),V):z(D)}function H(D){return D===45||D===46||D===58||D===95||Xt(D)?(e.consume(D),H):B(D)}function B(D){return D===61?(e.consume(D),U):Ee(D)?(s=B,G(D)):Ve(D)?(e.consume(D),B):V(D)}function U(D){return D===null||D===60||D===61||D===62||D===96?n(D):D===34||D===39?(e.consume(D),a=D,ee):Ee(D)?(s=U,G(D)):Ve(D)?(e.consume(D),U):(e.consume(D),q)}function ee(D){return D===a?(e.consume(D),a=void 0,F):D===null?n(D):Ee(D)?(s=ee,G(D)):(e.consume(D),ee)}function q(D){return D===null||D===34||D===39||D===60||D===61||D===96?n(D):D===47||D===62||ut(D)?V(D):(e.consume(D),q)}function F(D){return D===47||D===62||ut(D)?V(D):n(D)}function z(D){return D===62?(e.consume(D),e.exit("htmlTextData"),e.exit("htmlText"),t):n(D)}function G(D){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),Q}function Q(D){return Ve(D)?Qe(e,K,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):K(D)}function K(D){return e.enter("htmlTextData"),s(D)}}const Jm={name:"labelEnd",resolveAll:aO,resolveTo:oO,tokenize:sO},rO={tokenize:uO},iO={tokenize:cO},lO={tokenize:fO};function aO(e){let t=-1;const n=[];for(;++t=3&&(f===null||Ee(f))?(e.exit("thematicBreak"),t(f)):n(f)}function h(f){return f===a?(e.consume(f),l++,h):(e.exit("thematicBreakSequence"),Ve(f)?Qe(e,c,"whitespace")(f):c(f))}}const sn={continuation:{tokenize:wO},exit:SO,name:"list",tokenize:bO},yO={partial:!0,tokenize:kO},vO={partial:!0,tokenize:_O};function bO(e,t,n){const l=this,a=l.events[l.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,s=0;return c;function c(b){const w=l.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!l.containerState.marker||b===l.containerState.marker:fm(b)){if(l.containerState.type||(l.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(rc,n,f)(b):f(b);if(!l.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),h(b)}return n(b)}function h(b){return fm(b)&&++s<10?(e.consume(b),h):(!l.interrupt||s<2)&&(l.containerState.marker?b===l.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),f(b)):n(b)}function f(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),l.containerState.marker=l.containerState.marker||b,e.check(ss,l.interrupt?n:m,e.attempt(yO,g,p))}function m(b){return l.containerState.initialBlankLine=!0,o++,g(b)}function p(b){return Ve(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),g):n(b)}function g(b){return l.containerState.size=o+l.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(b)}}function wO(e,t,n){const l=this;return l.containerState._closeFlow=void 0,e.check(ss,a,o);function a(c){return l.containerState.furtherBlankLines=l.containerState.furtherBlankLines||l.containerState.initialBlankLine,Qe(e,t,"listItemIndent",l.containerState.size+1)(c)}function o(c){return l.containerState.furtherBlankLines||!Ve(c)?(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,s(c)):(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,e.attempt(vO,t,s)(c))}function s(c){return l.containerState._closeFlow=!0,l.interrupt=void 0,Qe(e,e.attempt(sn,t,n),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function _O(e,t,n){const l=this;return Qe(e,a,"listItemIndent",l.containerState.size+1);function a(o){const s=l.events[l.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===l.containerState.size?t(o):n(o)}}function SO(e){e.exit(this.containerState.type)}function kO(e,t,n){const l=this;return Qe(e,a,"listItemPrefixWhitespace",l.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const s=l.events[l.events.length-1];return!Ve(o)&&s&&s[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const q1={name:"setextUnderline",resolveTo:EO,tokenize:NO};function EO(e,t){let n=e.length,l,a,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){l=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const s={type:"setextHeading",start:{...e[l][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",s,t]),e.splice(o+1,0,["exit",e[l][1],t]),e[l][1].end={...e[o][1].end}):e[l][1]=s,e.push(["exit",s,t]),e}function NO(e,t,n){const l=this;let a;return o;function o(f){let m=l.events.length,p;for(;m--;)if(l.events[m][1].type!=="lineEnding"&&l.events[m][1].type!=="linePrefix"&&l.events[m][1].type!=="content"){p=l.events[m][1].type==="paragraph";break}return!l.parser.lazy[l.now().line]&&(l.interrupt||p)?(e.enter("setextHeadingLine"),a=f,s(f)):n(f)}function s(f){return e.enter("setextHeadingLineSequence"),c(f)}function c(f){return f===a?(e.consume(f),c):(e.exit("setextHeadingLineSequence"),Ve(f)?Qe(e,h,"lineSuffix")(f):h(f))}function h(f){return f===null||Ee(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const CO={tokenize:jO};function jO(e){const t=this,n=e.attempt(ss,l,e.attempt(this.parser.constructs.flowInitial,a,Qe(e,e.attempt(this.parser.constructs.flow,a,e.attempt(DR,a)),"linePrefix")));return n;function l(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const TO={resolveAll:ak()},AO=lk("string"),zO=lk("text");function lk(e){return{resolveAll:ak(e==="text"?MO:void 0),tokenize:t};function t(n){const l=this,a=this.parser.constructs[e],o=n.attempt(a,s,c);return s;function s(m){return f(m)?o(m):c(m)}function c(m){if(m===null){n.consume(m);return}return n.enter("data"),n.consume(m),h}function h(m){return f(m)?(n.exit("data"),o(m)):(n.consume(m),h)}function f(m){if(m===null)return!0;const p=a[m];let g=-1;if(p)for(;++g-1){const c=s[0];typeof c=="string"?s[0]=c.slice(l):s.shift()}o>0&&s.push(e[a].slice(0,o))}return s}function GO(e,t){let n=-1;const l=[];let a;for(;++n0){const Zt=Ne.tokenStack[Ne.tokenStack.length-1];(Zt[1]||U1).call(Ne,void 0,Zt[0])}for(ge.position={start:yi(ce.length>0?ce[0][1].start:{line:1,column:1,offset:0}),end:yi(ce.length>0?ce[ce.length-2][1].end:{line:1,column:1,offset:0})},Xe=-1;++Xe0&&(l.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:l,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function r6(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function i6(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function l6(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",l=String(t.identifier).toUpperCase(),a=Sa(l.toLowerCase()),o=e.footnoteOrder.indexOf(l);let s,c=e.footnoteCounts.get(l);c===void 0?(c=0,e.footnoteOrder.push(l),s=e.footnoteOrder.length):s=o+1,c+=1,e.footnoteCounts.set(l,c);const h={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(s)}]};e.patch(t,h);const f={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(t,f),e.applyData(t,f)}function a6(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function o6(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function uk(e,t){const n=t.referenceType;let l="]";if(n==="collapsed"?l+="[]":n==="full"&&(l+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+l}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const s=a[a.length-1];return s&&s.type==="text"?s.value+=l:a.push({type:"text",value:l}),a}function s6(e,t){const n=String(t.identifier).toUpperCase(),l=e.definitionById.get(n);if(!l)return uk(e,t);const a={src:Sa(l.url||""),alt:t.alt};l.title!==null&&l.title!==void 0&&(a.title=l.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function u6(e,t){const n={src:Sa(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const l={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,l),e.applyData(t,l)}function c6(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const l={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,l),e.applyData(t,l)}function f6(e,t){const n=String(t.identifier).toUpperCase(),l=e.definitionById.get(n);if(!l)return uk(e,t);const a={href:Sa(l.url||"")};l.title!==null&&l.title!==void 0&&(a.title=l.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function d6(e,t){const n={href:Sa(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const l={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function h6(e,t,n){const l=e.all(t),a=n?p6(n):ck(t),o={},s=[];if(typeof t.checked=="boolean"){const m=l[0];let p;m&&m.type==="element"&&m.tagName==="p"?p=m:(p={type:"element",tagName:"p",properties:{},children:[]},l.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let c=-1;for(;++c0){const Zt=Ne.tokenStack[Ne.tokenStack.length-1];(Zt[1]||U1).call(Ne,void 0,Zt[0])}for(ge.position={start:yi(ce.length>0?ce[0][1].start:{line:1,column:1,offset:0}),end:yi(ce.length>0?ce[ce.length-2][1].end:{line:1,column:1,offset:0})},Xe=-1;++Xe0&&(l.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:l,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function l6(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function a6(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function o6(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",l=String(t.identifier).toUpperCase(),a=Sa(l.toLowerCase()),o=e.footnoteOrder.indexOf(l);let s,c=e.footnoteCounts.get(l);c===void 0?(c=0,e.footnoteOrder.push(l),s=e.footnoteOrder.length):s=o+1,c+=1,e.footnoteCounts.set(l,c);const h={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(s)}]};e.patch(t,h);const f={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(t,f),e.applyData(t,f)}function s6(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function u6(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function uk(e,t){const n=t.referenceType;let l="]";if(n==="collapsed"?l+="[]":n==="full"&&(l+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+l}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const s=a[a.length-1];return s&&s.type==="text"?s.value+=l:a.push({type:"text",value:l}),a}function c6(e,t){const n=String(t.identifier).toUpperCase(),l=e.definitionById.get(n);if(!l)return uk(e,t);const a={src:Sa(l.url||""),alt:t.alt};l.title!==null&&l.title!==void 0&&(a.title=l.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function f6(e,t){const n={src:Sa(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const l={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,l),e.applyData(t,l)}function d6(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const l={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,l),e.applyData(t,l)}function h6(e,t){const n=String(t.identifier).toUpperCase(),l=e.definitionById.get(n);if(!l)return uk(e,t);const a={href:Sa(l.url||"")};l.title!==null&&l.title!==void 0&&(a.title=l.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function p6(e,t){const n={href:Sa(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const l={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function m6(e,t,n){const l=e.all(t),a=n?g6(n):ck(t),o={},s=[];if(typeof t.checked=="boolean"){const m=l[0];let p;m&&m.type==="element"&&m.tagName==="p"?p=m:(p={type:"element",tagName:"p",properties:{},children:[]},l.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let c=-1;for(;++c1}function m6(e,t){const n={},l=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a0){const s={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},c=Fm(t.children[1]),h=VS(t.children[t.children.length-1]);c&&h&&(s.position={start:c,end:h}),a.push(s)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function b6(e,t,n){const l=n?n.children:void 0,o=(l?l.indexOf(t):1)===0?"th":"td",s=n&&n.type==="table"?n.align:void 0,c=s?s.length:t.children.length;let h=-1;const f=[];for(;++h0,!0),l[0]),a=l.index+l[0].length,l=n.exec(t);return o.push(G1(t.slice(a),a>0,!1)),o.join("")}function G1(e,t,n){let l=0,a=e.length;if(t){let o=e.codePointAt(l);for(;o===V1||o===P1;)l++,o=e.codePointAt(l)}if(n){let o=e.codePointAt(a-1);for(;o===V1||o===P1;)a--,o=e.codePointAt(a-1)}return a>l?e.slice(l,a):""}function S6(e,t){const n={type:"text",value:_6(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function k6(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const E6={blockquote:e6,break:t6,code:n6,delete:r6,emphasis:i6,footnoteReference:l6,heading:a6,html:o6,imageReference:s6,image:u6,inlineCode:c6,linkReference:f6,link:d6,listItem:h6,list:m6,paragraph:g6,root:x6,strong:y6,table:v6,tableCell:w6,tableRow:b6,text:S6,thematicBreak:k6,toml:Yu,yaml:Yu,definition:Yu,footnoteDefinition:Yu};function Yu(){}const fk=-1,Vc=0,Ho=1,wc=2,Wm=3,eg=4,tg=5,ng=6,dk=7,hk=8,F1=typeof self=="object"?self:globalThis,N6=(e,t)=>{const n=(a,o)=>(e.set(o,a),a),l=a=>{if(e.has(a))return e.get(a);const[o,s]=t[a];switch(o){case Vc:case fk:return n(s,a);case Ho:{const c=n([],a);for(const h of s)c.push(l(h));return c}case wc:{const c=n({},a);for(const[h,f]of s)c[l(h)]=l(f);return c}case Wm:return n(new Date(s),a);case eg:{const{source:c,flags:h}=s;return n(new RegExp(c,h),a)}case tg:{const c=n(new Map,a);for(const[h,f]of s)c.set(l(h),l(f));return c}case ng:{const c=n(new Set,a);for(const h of s)c.add(l(h));return c}case dk:{const{name:c,message:h}=s;return n(new F1[c](h),a)}case hk:return n(BigInt(s),a);case"BigInt":return n(Object(BigInt(s)),a);case"ArrayBuffer":return n(new Uint8Array(s).buffer,s);case"DataView":{const{buffer:c}=new Uint8Array(s);return n(new DataView(c),s)}}return n(new F1[o](s),a)};return l},Y1=e=>N6(new Map,e)(0),ea="",{toString:C6}={},{keys:j6}=Object,No=e=>{const t=typeof e;if(t!=="object"||!e)return[Vc,t];const n=C6.call(e).slice(8,-1);switch(n){case"Array":return[Ho,ea];case"Object":return[wc,ea];case"Date":return[Wm,ea];case"RegExp":return[eg,ea];case"Map":return[tg,ea];case"Set":return[ng,ea];case"DataView":return[Ho,n]}return n.includes("Array")?[Ho,n]:n.includes("Error")?[dk,n]:[wc,n]},Xu=([e,t])=>e===Vc&&(t==="function"||t==="symbol"),T6=(e,t,n,l)=>{const a=(s,c)=>{const h=l.push(s)-1;return n.set(c,h),h},o=s=>{if(n.has(s))return n.get(s);let[c,h]=No(s);switch(c){case Vc:{let m=s;switch(h){case"bigint":c=hk,m=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+h);m=null;break;case"undefined":return a([fk],s)}return a([c,m],s)}case Ho:{if(h){let g=s;return h==="DataView"?g=new Uint8Array(s.buffer):h==="ArrayBuffer"&&(g=new Uint8Array(s)),a([h,[...g]],s)}const m=[],p=a([c,m],s);for(const g of s)m.push(o(g));return p}case wc:{if(h)switch(h){case"BigInt":return a([h,s.toString()],s);case"Boolean":case"Number":case"String":return a([h,s.valueOf()],s)}if(t&&"toJSON"in s)return o(s.toJSON());const m=[],p=a([c,m],s);for(const g of j6(s))(e||!Xu(No(s[g])))&&m.push([o(g),o(s[g])]);return p}case Wm:return a([c,s.toISOString()],s);case eg:{const{source:m,flags:p}=s;return a([c,{source:m,flags:p}],s)}case tg:{const m=[],p=a([c,m],s);for(const[g,b]of s)(e||!(Xu(No(g))||Xu(No(b))))&&m.push([o(g),o(b)]);return p}case ng:{const m=[],p=a([c,m],s);for(const g of s)(e||!Xu(No(g)))&&m.push(o(g));return p}}const{message:f}=s;return a([c,{name:h,message:f}],s)};return o},X1=(e,{json:t,lossy:n}={})=>{const l=[];return T6(!(t||n),!!t,new Map,l)(e),l},_c=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Y1(X1(e,t)):structuredClone(e):(e,t)=>Y1(X1(e,t));function A6(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function z6(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function M6(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||A6,l=e.options.footnoteBackLabel||z6,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",s=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let h=-1;for(;++h0&&w.push({type:"text",value:" "});let N=typeof n=="string"?n:n(h,b);typeof N=="string"&&(N={type:"text",value:N}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+g+(b>1?"-"+b:""),dataFootnoteBackref:"",ariaLabel:typeof l=="string"?l:l(h,b),className:["data-footnote-backref"]},children:Array.isArray(N)?N:[N]})}const S=m[m.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const N=S.children[S.children.length-1];N&&N.type==="text"?N.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...w)}else m.push(...w);const _={type:"element",tagName:"li",properties:{id:t+"fn-"+g},children:e.wrap(m,!0)};e.patch(f,_),c.push(_)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{..._c(s),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:` +`});const f={type:"element",tagName:"li",properties:o,children:s};return e.patch(t,f),e.applyData(t,f)}function g6(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let l=-1;for(;!t&&++l1}function x6(e,t){const n={},l=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a0){const s={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},c=Fm(t.children[1]),h=VS(t.children[t.children.length-1]);c&&h&&(s.position={start:c,end:h}),a.push(s)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function _6(e,t,n){const l=n?n.children:void 0,o=(l?l.indexOf(t):1)===0?"th":"td",s=n&&n.type==="table"?n.align:void 0,c=s?s.length:t.children.length;let h=-1;const f=[];for(;++h0,!0),l[0]),a=l.index+l[0].length,l=n.exec(t);return o.push(G1(t.slice(a),a>0,!1)),o.join("")}function G1(e,t,n){let l=0,a=e.length;if(t){let o=e.codePointAt(l);for(;o===V1||o===P1;)l++,o=e.codePointAt(l)}if(n){let o=e.codePointAt(a-1);for(;o===V1||o===P1;)a--,o=e.codePointAt(a-1)}return a>l?e.slice(l,a):""}function E6(e,t){const n={type:"text",value:k6(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function N6(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const C6={blockquote:n6,break:r6,code:i6,delete:l6,emphasis:a6,footnoteReference:o6,heading:s6,html:u6,imageReference:c6,image:f6,inlineCode:d6,linkReference:h6,link:p6,listItem:m6,list:x6,paragraph:y6,root:v6,strong:b6,table:w6,tableCell:S6,tableRow:_6,text:E6,thematicBreak:N6,toml:Yu,yaml:Yu,definition:Yu,footnoteDefinition:Yu};function Yu(){}const fk=-1,Vc=0,Ho=1,wc=2,Wm=3,eg=4,tg=5,ng=6,dk=7,hk=8,F1=typeof self=="object"?self:globalThis,j6=(e,t)=>{const n=(a,o)=>(e.set(o,a),a),l=a=>{if(e.has(a))return e.get(a);const[o,s]=t[a];switch(o){case Vc:case fk:return n(s,a);case Ho:{const c=n([],a);for(const h of s)c.push(l(h));return c}case wc:{const c=n({},a);for(const[h,f]of s)c[l(h)]=l(f);return c}case Wm:return n(new Date(s),a);case eg:{const{source:c,flags:h}=s;return n(new RegExp(c,h),a)}case tg:{const c=n(new Map,a);for(const[h,f]of s)c.set(l(h),l(f));return c}case ng:{const c=n(new Set,a);for(const h of s)c.add(l(h));return c}case dk:{const{name:c,message:h}=s;return n(new F1[c](h),a)}case hk:return n(BigInt(s),a);case"BigInt":return n(Object(BigInt(s)),a);case"ArrayBuffer":return n(new Uint8Array(s).buffer,s);case"DataView":{const{buffer:c}=new Uint8Array(s);return n(new DataView(c),s)}}return n(new F1[o](s),a)};return l},Y1=e=>j6(new Map,e)(0),ta="",{toString:T6}={},{keys:A6}=Object,No=e=>{const t=typeof e;if(t!=="object"||!e)return[Vc,t];const n=T6.call(e).slice(8,-1);switch(n){case"Array":return[Ho,ta];case"Object":return[wc,ta];case"Date":return[Wm,ta];case"RegExp":return[eg,ta];case"Map":return[tg,ta];case"Set":return[ng,ta];case"DataView":return[Ho,n]}return n.includes("Array")?[Ho,n]:n.includes("Error")?[dk,n]:[wc,n]},Xu=([e,t])=>e===Vc&&(t==="function"||t==="symbol"),z6=(e,t,n,l)=>{const a=(s,c)=>{const h=l.push(s)-1;return n.set(c,h),h},o=s=>{if(n.has(s))return n.get(s);let[c,h]=No(s);switch(c){case Vc:{let m=s;switch(h){case"bigint":c=hk,m=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+h);m=null;break;case"undefined":return a([fk],s)}return a([c,m],s)}case Ho:{if(h){let g=s;return h==="DataView"?g=new Uint8Array(s.buffer):h==="ArrayBuffer"&&(g=new Uint8Array(s)),a([h,[...g]],s)}const m=[],p=a([c,m],s);for(const g of s)m.push(o(g));return p}case wc:{if(h)switch(h){case"BigInt":return a([h,s.toString()],s);case"Boolean":case"Number":case"String":return a([h,s.valueOf()],s)}if(t&&"toJSON"in s)return o(s.toJSON());const m=[],p=a([c,m],s);for(const g of A6(s))(e||!Xu(No(s[g])))&&m.push([o(g),o(s[g])]);return p}case Wm:return a([c,s.toISOString()],s);case eg:{const{source:m,flags:p}=s;return a([c,{source:m,flags:p}],s)}case tg:{const m=[],p=a([c,m],s);for(const[g,b]of s)(e||!(Xu(No(g))||Xu(No(b))))&&m.push([o(g),o(b)]);return p}case ng:{const m=[],p=a([c,m],s);for(const g of s)(e||!Xu(No(g)))&&m.push(o(g));return p}}const{message:f}=s;return a([c,{name:h,message:f}],s)};return o},X1=(e,{json:t,lossy:n}={})=>{const l=[];return z6(!(t||n),!!t,new Map,l)(e),l},_c=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Y1(X1(e,t)):structuredClone(e):(e,t)=>Y1(X1(e,t));function M6(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function D6(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function R6(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||M6,l=e.options.footnoteBackLabel||D6,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",s=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let h=-1;for(;++h0&&w.push({type:"text",value:" "});let N=typeof n=="string"?n:n(h,b);typeof N=="string"&&(N={type:"text",value:N}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+g+(b>1?"-"+b:""),dataFootnoteBackref:"",ariaLabel:typeof l=="string"?l:l(h,b),className:["data-footnote-backref"]},children:Array.isArray(N)?N:[N]})}const S=m[m.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const N=S.children[S.children.length-1];N&&N.type==="text"?N.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...w)}else m.push(...w);const _={type:"element",tagName:"li",properties:{id:t+"fn-"+g},children:e.wrap(m,!0)};e.patch(f,_),c.push(_)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{..._c(s),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:` `},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:` -`}]}}const Pc=(function(e){if(e==null)return L6;if(typeof e=="function")return Gc(e);if(typeof e=="object")return Array.isArray(e)?D6(e):R6(e);if(typeof e=="string")return O6(e);throw new Error("Expected function, string, or object as test")});function D6(e){const t=[];let n=-1;for(;++n":""))+")"})}return g;function g(){let b=pk,w,E,S;if((!t||o(h,f,m[m.length-1]||void 0))&&(b=q6(n(h,m)),b[0]===hm))return b;if("children"in h&&h.children){const _=h;if(_.children&&b[0]!==I6)for(E=(l?_.children.length:-1)+s,S=m.concat(_);E>-1&&E<_.children.length;){const N=_.children[E];if(w=c(N,E,S)(),w[0]===hm)return w;E=typeof w[1]=="number"?w[1]:E+s}}return b}}}function q6(e){return Array.isArray(e)?e:typeof e=="number"?[B6,e]:e==null?pk:[e]}function rg(e,t,n,l){let a,o,s;typeof t=="function"&&typeof n!="function"?(o=void 0,s=t,a=n):(o=t,s=n,a=l),mk(e,o,c,a);function c(h,f){const m=f[f.length-1],p=m?m.children.indexOf(h):void 0;return s(h,p,m)}}const pm={}.hasOwnProperty,$6={};function U6(e,t){const n=t||$6,l=new Map,a=new Map,o=new Map,s={...E6,...n.handlers},c={all:f,applyData:P6,definitionById:l,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:s,one:h,options:n,patch:V6,wrap:F6};return rg(e,function(m){if(m.type==="definition"||m.type==="footnoteDefinition"){const p=m.type==="definition"?l:a,g=String(m.identifier).toUpperCase();p.has(g)||p.set(g,m)}}),c;function h(m,p){const g=m.type,b=c.handlers[g];if(pm.call(c.handlers,g)&&b)return b(c,m,p);if(c.options.passThrough&&c.options.passThrough.includes(g)){if("children"in m){const{children:E,...S}=m,_=_c(S);return _.children=c.all(m),_}return _c(m)}return(c.options.unknownHandler||G6)(c,m,p)}function f(m){const p=[];if("children"in m){const g=m.children;let b=-1;for(;++b":""))+")"})}return g;function g(){let b=pk,w,E,S;if((!t||o(h,f,m[m.length-1]||void 0))&&(b=U6(n(h,m)),b[0]===hm))return b;if("children"in h&&h.children){const _=h;if(_.children&&b[0]!==$6)for(E=(l?_.children.length:-1)+s,S=m.concat(_);E>-1&&E<_.children.length;){const N=_.children[E];if(w=c(N,E,S)(),w[0]===hm)return w;E=typeof w[1]=="number"?w[1]:E+s}}return b}}}function U6(e){return Array.isArray(e)?e:typeof e=="number"?[q6,e]:e==null?pk:[e]}function rg(e,t,n,l){let a,o,s;typeof t=="function"&&typeof n!="function"?(o=void 0,s=t,a=n):(o=t,s=n,a=l),mk(e,o,c,a);function c(h,f){const m=f[f.length-1],p=m?m.children.indexOf(h):void 0;return s(h,p,m)}}const pm={}.hasOwnProperty,V6={};function P6(e,t){const n=t||V6,l=new Map,a=new Map,o=new Map,s={...C6,...n.handlers},c={all:f,applyData:F6,definitionById:l,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:s,one:h,options:n,patch:G6,wrap:X6};return rg(e,function(m){if(m.type==="definition"||m.type==="footnoteDefinition"){const p=m.type==="definition"?l:a,g=String(m.identifier).toUpperCase();p.has(g)||p.set(g,m)}}),c;function h(m,p){const g=m.type,b=c.handlers[g];if(pm.call(c.handlers,g)&&b)return b(c,m,p);if(c.options.passThrough&&c.options.passThrough.includes(g)){if("children"in m){const{children:E,...S}=m,_=_c(S);return _.children=c.all(m),_}return _c(m)}return(c.options.unknownHandler||Y6)(c,m,p)}function f(m){const p=[];if("children"in m){const g=m.children;let b=-1;for(;++b0&&n.push({type:"text",value:` -`}),n}function Q1(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Z1(e,t){const n=U6(e,t),l=n.one(e,void 0),a=M6(n),o=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return a&&o.children.push({type:"text",value:` -`},a),o}function Y6(e,t){return e&&"run"in e?async function(n,l){const a=Z1(n,{file:l,...t});await e.run(a,l)}:function(n,l){return Z1(n,{file:l,...e||t})}}function K1(e){if(e)throw e}var Tp,J1;function X6(){if(J1)return Tp;J1=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,l=Object.getOwnPropertyDescriptor,a=function(f){return typeof Array.isArray=="function"?Array.isArray(f):t.call(f)==="[object Array]"},o=function(f){if(!f||t.call(f)!=="[object Object]")return!1;var m=e.call(f,"constructor"),p=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!m&&!p)return!1;var g;for(g in f);return typeof g>"u"||e.call(f,g)},s=function(f,m){n&&m.name==="__proto__"?n(f,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):f[m.name]=m.newValue},c=function(f,m){if(m==="__proto__")if(e.call(f,m)){if(l)return l(f,m).value}else return;return f[m]};return Tp=function h(){var f,m,p,g,b,w,E=arguments[0],S=1,_=arguments.length,N=!1;for(typeof E=="boolean"&&(N=E,E=arguments[1]||{},S=2),(E==null||typeof E!="object"&&typeof E!="function")&&(E={});S<_;++S)if(f=arguments[S],f!=null)for(m in f)p=c(E,m),g=c(f,m),E!==g&&(N&&g&&(o(g)||(b=a(g)))?(b?(b=!1,w=p&&a(p)?p:[]):w=p&&o(p)?p:{},s(E,{name:m,newValue:h(N,w,g)})):typeof g<"u"&&s(E,{name:m,newValue:g}));return E},Tp}var Q6=X6();const Ap=Ko(Q6);function mm(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Z6(){const e=[],t={run:n,use:l};return t;function n(...a){let o=-1;const s=a.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);c(null,...a);function c(h,...f){const m=e[++o];let p=-1;if(h){s(h);return}for(;++ps.length;let h;c&&s.push(a);try{h=e.apply(this,s)}catch(f){const m=f;if(c&&n)throw m;return a(m)}c||(h&&h.then&&typeof h.then=="function"?h.then(o,a):h instanceof Error?a(h):o(h))}function a(s,...c){n||(n=!0,t(s,...c))}function o(s){a(null,s)}}const rr={basename:J6,dirname:W6,extname:eL,join:tL,sep:"/"};function J6(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');us(e);let n=0,l=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else l<0&&(o=!0,l=a+1);return l<0?"":e.slice(n,l)}if(t===e)return"";let s=-1,c=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else s<0&&(o=!0,s=a+1),c>-1&&(e.codePointAt(a)===t.codePointAt(c--)?c<0&&(l=a):(c=-1,l=s));return n===l?l=s:l<0&&(l=e.length),e.slice(n,l)}function W6(e){if(us(e),e.length===0)return".";let t=-1,n=e.length,l;for(;--n;)if(e.codePointAt(n)===47){if(l){t=n;break}}else l||(l=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function eL(e){us(e);let t=e.length,n=-1,l=0,a=-1,o=0,s;for(;t--;){const c=e.codePointAt(t);if(c===47){if(s){l=t+1;break}continue}n<0&&(s=!0,n=t+1),c===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===l+1?"":e.slice(a,n)}function tL(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function rL(e,t){let n="",l=0,a=-1,o=0,s=-1,c,h;for(;++s<=e.length;){if(s2){if(h=n.lastIndexOf("/"),h!==n.length-1){h<0?(n="",l=0):(n=n.slice(0,h),l=n.length-1-n.lastIndexOf("/")),a=s,o=0;continue}}else if(n.length>0){n="",l=0,a=s,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",l=2)}else n.length>0?n+="/"+e.slice(a+1,s):n=e.slice(a+1,s),l=s-a-1;a=s,o=0}else c===46&&o>-1?o++:o=-1}return n}function us(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const iL={cwd:lL};function lL(){return"/"}function gm(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function aL(e){if(typeof e=="string")e=new URL(e);else if(!gm(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return oL(e)}function oL(e){if(e.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const t=e.pathname;let n=-1;for(;++n0){let[b,...w]=m;const E=l[g][1];mm(E)&&mm(b)&&(b=Ap(!0,E,b)),l[g]=[f,b,...w]}}}}const fL=new ig().freeze();function Rp(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Op(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Lp(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ew(e){if(!mm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function tw(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Qu(e){return dL(e)?e:new gk(e)}function dL(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function hL(e){return typeof e=="string"||pL(e)}function pL(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const mL="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",nw=[],rw={allowDangerousHtml:!0},gL=/^(https?|ircs?|mailto|xmpp)$/i,xL=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Fc(e){const t=yL(e),n=vL(e);return bL(t.runSync(t.parse(n),n),e)}function yL(e){const t=e.rehypePlugins||nw,n=e.remarkPlugins||nw,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...rw}:rw;return fL().use(WO).use(n).use(Y6,l).use(t)}function vL(e){const t=e.children||"",n=new gk;return typeof t=="string"&&(n.value=t),n}function bL(e,t){const n=t.allowedElements,l=t.allowElement,a=t.components,o=t.disallowedElements,s=t.skipHtml,c=t.unwrapDisallowed,h=t.urlTransform||wL;for(const m of xL)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+mL+m.id,void 0);return rg(e,f),LD(e,{Fragment:y.Fragment,components:a,ignoreInvalidStyle:!0,jsx:y.jsx,jsxs:y.jsxs,passKeys:!0,passNode:!0});function f(m,p,g){if(m.type==="raw"&&g&&typeof p=="number")return s?g.children.splice(p,1):g.children[p]={type:"text",value:m.value},p;if(m.type==="element"){let b;for(b in Np)if(Object.hasOwn(Np,b)&&Object.hasOwn(m.properties,b)){const w=m.properties[b],E=Np[b];(E===null||E.includes(m.tagName))&&(m.properties[b]=h(String(w||""),b,m))}}if(m.type==="element"){let b=n?!n.includes(m.tagName):o?o.includes(m.tagName):!1;if(!b&&l&&typeof p=="number"&&(b=!l(m,p,g)),b&&g&&typeof p=="number")return c&&m.children?g.children.splice(p,1,...m.children):g.children.splice(p,1),p}}}function wL(e){const t=e.indexOf(":"),n=e.indexOf("?"),l=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||l!==-1&&t>l||gL.test(e.slice(0,t))?e:""}function iw(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let l=0,a=n.indexOf(t);for(;a!==-1;)l++,a=n.indexOf(t,a+t.length);return l}function _L(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function SL(e,t,n){const a=Pc((n||{}).ignore||[]),o=kL(t);let s=-1;for(;++s0?{type:"text",value:A}:void 0),A===!1?g.lastIndex=T+1:(w!==T&&N.push({type:"text",value:f.value.slice(w,T)}),Array.isArray(A)?N.push(...A):A&&N.push(A),w=T+k[0].length,_=!0),!g.global)break;k=g.exec(f.value)}return _?(w?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],l=n.indexOf(")");const a=iw(e,"(");let o=iw(e,")");for(;l!==-1&&a>o;)e+=n.slice(0,l+1),n=n.slice(l+1),l=n.indexOf(")"),o++;return[e,n]}function xk(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||al(n)||$c(n))&&(!t||n!==47)}yk.peek=YL;function IL(){this.buffer()}function qL(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function $L(){this.buffer()}function UL(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function VL(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Fn(this.sliceSerialize(e)).toLowerCase(),n.label=t}function PL(e){this.exit(e)}function GL(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Fn(this.sliceSerialize(e)).toLowerCase(),n.label=t}function FL(e){this.exit(e)}function YL(){return"["}function yk(e,t,n,l){const a=n.createTracker(l);let o=a.move("[^");const s=n.enter("footnoteReference"),c=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),c(),s(),o+=a.move("]"),o}function XL(){return{enter:{gfmFootnoteCallString:IL,gfmFootnoteCall:qL,gfmFootnoteDefinitionLabelString:$L,gfmFootnoteDefinition:UL},exit:{gfmFootnoteCallString:VL,gfmFootnoteCall:PL,gfmFootnoteDefinitionLabelString:GL,gfmFootnoteDefinition:FL}}}function QL(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:yk},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(l,a,o,s){const c=o.createTracker(s);let h=c.move("[^");const f=o.enter("footnoteDefinition"),m=o.enter("label");return h+=c.move(o.safe(o.associationId(l),{before:h,after:"]"})),m(),h+=c.move("]:"),l.children&&l.children.length>0&&(c.shift(4),h+=c.move((t?` -`:" ")+o.indentLines(o.containerFlow(l,c.current()),t?vk:ZL))),f(),h}}function ZL(e,t,n){return t===0?e:vk(e,t,n)}function vk(e,t,n){return(n?"":" ")+e}const KL=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];bk.peek=n8;function JL(){return{canContainEols:["delete"],enter:{strikethrough:e8},exit:{strikethrough:t8}}}function WL(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:KL}],handlers:{delete:bk}}}function e8(e){this.enter({type:"delete",children:[]},e)}function t8(e){this.exit(e)}function bk(e,t,n,l){const a=n.createTracker(l),o=n.enter("strikethrough");let s=a.move("~~");return s+=n.containerPhrasing(e,{...a.current(),before:s,after:"~"}),s+=a.move("~~"),o(),s}function n8(){return"~"}function r8(e){return e.length}function i8(e,t){const n=t||{},l=(n.align||[]).concat(),a=n.stringLength||r8,o=[],s=[],c=[],h=[];let f=0,m=-1;for(;++mf&&(f=e[m].length);++_h[_])&&(h[_]=k)}E.push(N)}s[m]=E,c[m]=S}let p=-1;if(typeof l=="object"&&"length"in l)for(;++ph[p]&&(h[p]=N),b[p]=N),g[p]=k}s.splice(1,0,g),c.splice(1,0,b),m=-1;const w=[];for(;++m "),o.shift(2);const s=n.indentLines(n.containerFlow(e,o.current()),o8);return a(),s}function o8(e,t,n){return">"+(n?"":" ")+e}function s8(e,t){return aw(e,t.inConstruct,!0)&&!aw(e,t.notInConstruct,!1)}function aw(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let l=-1;for(;++ls&&(s=o):o=1,a=l+t.length,l=n.indexOf(t,a);return s}function c8(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function f8(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function d8(e,t,n,l){const a=f8(n),o=e.value||"",s=a==="`"?"GraveAccent":"Tilde";if(c8(e,n)){const p=n.enter("codeIndented"),g=n.indentLines(o,h8);return p(),g}const c=n.createTracker(l),h=a.repeat(Math.max(u8(o,a)+1,3)),f=n.enter("codeFenced");let m=c.move(h);if(e.lang){const p=n.enter(`codeFencedLang${s}`);m+=c.move(n.safe(e.lang,{before:m,after:" ",encode:["`"],...c.current()})),p()}if(e.lang&&e.meta){const p=n.enter(`codeFencedMeta${s}`);m+=c.move(" "),m+=c.move(n.safe(e.meta,{before:m,after:` +`}),n}function Q1(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Z1(e,t){const n=P6(e,t),l=n.one(e,void 0),a=R6(n),o=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return a&&o.children.push({type:"text",value:` +`},a),o}function Q6(e,t){return e&&"run"in e?async function(n,l){const a=Z1(n,{file:l,...t});await e.run(a,l)}:function(n,l){return Z1(n,{file:l,...e||t})}}function K1(e){if(e)throw e}var Tp,J1;function Z6(){if(J1)return Tp;J1=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,l=Object.getOwnPropertyDescriptor,a=function(f){return typeof Array.isArray=="function"?Array.isArray(f):t.call(f)==="[object Array]"},o=function(f){if(!f||t.call(f)!=="[object Object]")return!1;var m=e.call(f,"constructor"),p=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!m&&!p)return!1;var g;for(g in f);return typeof g>"u"||e.call(f,g)},s=function(f,m){n&&m.name==="__proto__"?n(f,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):f[m.name]=m.newValue},c=function(f,m){if(m==="__proto__")if(e.call(f,m)){if(l)return l(f,m).value}else return;return f[m]};return Tp=function h(){var f,m,p,g,b,w,E=arguments[0],S=1,_=arguments.length,N=!1;for(typeof E=="boolean"&&(N=E,E=arguments[1]||{},S=2),(E==null||typeof E!="object"&&typeof E!="function")&&(E={});S<_;++S)if(f=arguments[S],f!=null)for(m in f)p=c(E,m),g=c(f,m),E!==g&&(N&&g&&(o(g)||(b=a(g)))?(b?(b=!1,w=p&&a(p)?p:[]):w=p&&o(p)?p:{},s(E,{name:m,newValue:h(N,w,g)})):typeof g<"u"&&s(E,{name:m,newValue:g}));return E},Tp}var K6=Z6();const Ap=Ko(K6);function mm(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function J6(){const e=[],t={run:n,use:l};return t;function n(...a){let o=-1;const s=a.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);c(null,...a);function c(h,...f){const m=e[++o];let p=-1;if(h){s(h);return}for(;++ps.length;let h;c&&s.push(a);try{h=e.apply(this,s)}catch(f){const m=f;if(c&&n)throw m;return a(m)}c||(h&&h.then&&typeof h.then=="function"?h.then(o,a):h instanceof Error?a(h):o(h))}function a(s,...c){n||(n=!0,t(s,...c))}function o(s){a(null,s)}}const rr={basename:eL,dirname:tL,extname:nL,join:rL,sep:"/"};function eL(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');us(e);let n=0,l=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else l<0&&(o=!0,l=a+1);return l<0?"":e.slice(n,l)}if(t===e)return"";let s=-1,c=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else s<0&&(o=!0,s=a+1),c>-1&&(e.codePointAt(a)===t.codePointAt(c--)?c<0&&(l=a):(c=-1,l=s));return n===l?l=s:l<0&&(l=e.length),e.slice(n,l)}function tL(e){if(us(e),e.length===0)return".";let t=-1,n=e.length,l;for(;--n;)if(e.codePointAt(n)===47){if(l){t=n;break}}else l||(l=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function nL(e){us(e);let t=e.length,n=-1,l=0,a=-1,o=0,s;for(;t--;){const c=e.codePointAt(t);if(c===47){if(s){l=t+1;break}continue}n<0&&(s=!0,n=t+1),c===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===l+1?"":e.slice(a,n)}function rL(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function lL(e,t){let n="",l=0,a=-1,o=0,s=-1,c,h;for(;++s<=e.length;){if(s2){if(h=n.lastIndexOf("/"),h!==n.length-1){h<0?(n="",l=0):(n=n.slice(0,h),l=n.length-1-n.lastIndexOf("/")),a=s,o=0;continue}}else if(n.length>0){n="",l=0,a=s,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",l=2)}else n.length>0?n+="/"+e.slice(a+1,s):n=e.slice(a+1,s),l=s-a-1;a=s,o=0}else c===46&&o>-1?o++:o=-1}return n}function us(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const aL={cwd:oL};function oL(){return"/"}function gm(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function sL(e){if(typeof e=="string")e=new URL(e);else if(!gm(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return uL(e)}function uL(e){if(e.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const t=e.pathname;let n=-1;for(;++n0){let[b,...w]=m;const E=l[g][1];mm(E)&&mm(b)&&(b=Ap(!0,E,b)),l[g]=[f,b,...w]}}}}const hL=new ig().freeze();function Rp(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Op(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Lp(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ew(e){if(!mm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function tw(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Qu(e){return pL(e)?e:new gk(e)}function pL(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function mL(e){return typeof e=="string"||gL(e)}function gL(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const xL="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",nw=[],rw={allowDangerousHtml:!0},yL=/^(https?|ircs?|mailto|xmpp)$/i,vL=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Fc(e){const t=bL(e),n=wL(e);return _L(t.runSync(t.parse(n),n),e)}function bL(e){const t=e.rehypePlugins||nw,n=e.remarkPlugins||nw,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...rw}:rw;return hL().use(t6).use(n).use(Q6,l).use(t)}function wL(e){const t=e.children||"",n=new gk;return typeof t=="string"&&(n.value=t),n}function _L(e,t){const n=t.allowedElements,l=t.allowElement,a=t.components,o=t.disallowedElements,s=t.skipHtml,c=t.unwrapDisallowed,h=t.urlTransform||SL;for(const m of vL)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+xL+m.id,void 0);return rg(e,f),BD(e,{Fragment:y.Fragment,components:a,ignoreInvalidStyle:!0,jsx:y.jsx,jsxs:y.jsxs,passKeys:!0,passNode:!0});function f(m,p,g){if(m.type==="raw"&&g&&typeof p=="number")return s?g.children.splice(p,1):g.children[p]={type:"text",value:m.value},p;if(m.type==="element"){let b;for(b in Np)if(Object.hasOwn(Np,b)&&Object.hasOwn(m.properties,b)){const w=m.properties[b],E=Np[b];(E===null||E.includes(m.tagName))&&(m.properties[b]=h(String(w||""),b,m))}}if(m.type==="element"){let b=n?!n.includes(m.tagName):o?o.includes(m.tagName):!1;if(!b&&l&&typeof p=="number"&&(b=!l(m,p,g)),b&&g&&typeof p=="number")return c&&m.children?g.children.splice(p,1,...m.children):g.children.splice(p,1),p}}}function SL(e){const t=e.indexOf(":"),n=e.indexOf("?"),l=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||l!==-1&&t>l||yL.test(e.slice(0,t))?e:""}function iw(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let l=0,a=n.indexOf(t);for(;a!==-1;)l++,a=n.indexOf(t,a+t.length);return l}function kL(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function EL(e,t,n){const a=Pc((n||{}).ignore||[]),o=NL(t);let s=-1;for(;++s0?{type:"text",value:A}:void 0),A===!1?g.lastIndex=T+1:(w!==T&&N.push({type:"text",value:f.value.slice(w,T)}),Array.isArray(A)?N.push(...A):A&&N.push(A),w=T+k[0].length,_=!0),!g.global)break;k=g.exec(f.value)}return _?(w?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],l=n.indexOf(")");const a=iw(e,"(");let o=iw(e,")");for(;l!==-1&&a>o;)e+=n.slice(0,l+1),n=n.slice(l+1),l=n.indexOf(")"),o++;return[e,n]}function xk(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||al(n)||$c(n))&&(!t||n!==47)}yk.peek=QL;function $L(){this.buffer()}function UL(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function VL(){this.buffer()}function PL(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function GL(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Yn(this.sliceSerialize(e)).toLowerCase(),n.label=t}function FL(e){this.exit(e)}function YL(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Yn(this.sliceSerialize(e)).toLowerCase(),n.label=t}function XL(e){this.exit(e)}function QL(){return"["}function yk(e,t,n,l){const a=n.createTracker(l);let o=a.move("[^");const s=n.enter("footnoteReference"),c=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),c(),s(),o+=a.move("]"),o}function ZL(){return{enter:{gfmFootnoteCallString:$L,gfmFootnoteCall:UL,gfmFootnoteDefinitionLabelString:VL,gfmFootnoteDefinition:PL},exit:{gfmFootnoteCallString:GL,gfmFootnoteCall:FL,gfmFootnoteDefinitionLabelString:YL,gfmFootnoteDefinition:XL}}}function KL(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:yk},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(l,a,o,s){const c=o.createTracker(s);let h=c.move("[^");const f=o.enter("footnoteDefinition"),m=o.enter("label");return h+=c.move(o.safe(o.associationId(l),{before:h,after:"]"})),m(),h+=c.move("]:"),l.children&&l.children.length>0&&(c.shift(4),h+=c.move((t?` +`:" ")+o.indentLines(o.containerFlow(l,c.current()),t?vk:JL))),f(),h}}function JL(e,t,n){return t===0?e:vk(e,t,n)}function vk(e,t,n){return(n?"":" ")+e}const WL=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];bk.peek=i8;function e8(){return{canContainEols:["delete"],enter:{strikethrough:n8},exit:{strikethrough:r8}}}function t8(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:WL}],handlers:{delete:bk}}}function n8(e){this.enter({type:"delete",children:[]},e)}function r8(e){this.exit(e)}function bk(e,t,n,l){const a=n.createTracker(l),o=n.enter("strikethrough");let s=a.move("~~");return s+=n.containerPhrasing(e,{...a.current(),before:s,after:"~"}),s+=a.move("~~"),o(),s}function i8(){return"~"}function l8(e){return e.length}function a8(e,t){const n=t||{},l=(n.align||[]).concat(),a=n.stringLength||l8,o=[],s=[],c=[],h=[];let f=0,m=-1;for(;++mf&&(f=e[m].length);++_h[_])&&(h[_]=k)}E.push(N)}s[m]=E,c[m]=S}let p=-1;if(typeof l=="object"&&"length"in l)for(;++ph[p]&&(h[p]=N),b[p]=N),g[p]=k}s.splice(1,0,g),c.splice(1,0,b),m=-1;const w=[];for(;++m "),o.shift(2);const s=n.indentLines(n.containerFlow(e,o.current()),u8);return a(),s}function u8(e,t,n){return">"+(n?"":" ")+e}function c8(e,t){return aw(e,t.inConstruct,!0)&&!aw(e,t.notInConstruct,!1)}function aw(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let l=-1;for(;++ls&&(s=o):o=1,a=l+t.length,l=n.indexOf(t,a);return s}function d8(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function h8(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function p8(e,t,n,l){const a=h8(n),o=e.value||"",s=a==="`"?"GraveAccent":"Tilde";if(d8(e,n)){const p=n.enter("codeIndented"),g=n.indentLines(o,m8);return p(),g}const c=n.createTracker(l),h=a.repeat(Math.max(f8(o,a)+1,3)),f=n.enter("codeFenced");let m=c.move(h);if(e.lang){const p=n.enter(`codeFencedLang${s}`);m+=c.move(n.safe(e.lang,{before:m,after:" ",encode:["`"],...c.current()})),p()}if(e.lang&&e.meta){const p=n.enter(`codeFencedMeta${s}`);m+=c.move(" "),m+=c.move(n.safe(e.meta,{before:m,after:` `,encode:["`"],...c.current()})),p()}return m+=c.move(` `),o&&(m+=c.move(o+` -`)),m+=c.move(h),f(),m}function h8(e,t,n){return(n?"":" ")+e}function lg(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function p8(e,t,n,l){const a=lg(n),o=a==='"'?"Quote":"Apostrophe",s=n.enter("definition");let c=n.enter("label");const h=n.createTracker(l);let f=h.move("[");return f+=h.move(n.safe(n.associationId(e),{before:f,after:"]",...h.current()})),f+=h.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),f+=h.move("<"),f+=h.move(n.safe(e.url,{before:f,after:">",...h.current()})),f+=h.move(">")):(c=n.enter("destinationRaw"),f+=h.move(n.safe(e.url,{before:f,after:e.title?" ":` -`,...h.current()}))),c(),e.title&&(c=n.enter(`title${o}`),f+=h.move(" "+a),f+=h.move(n.safe(e.title,{before:f,after:a,...h.current()})),f+=h.move(a),c()),s(),f}function m8(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Zo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Sc(e,t,n){const l=ba(e),a=ba(t);return l===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:l===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}wk.peek=g8;function wk(e,t,n,l){const a=m8(n),o=n.enter("emphasis"),s=n.createTracker(l),c=s.move(a);let h=s.move(n.containerPhrasing(e,{after:a,before:c,...s.current()}));const f=h.charCodeAt(0),m=Sc(l.before.charCodeAt(l.before.length-1),f,a);m.inside&&(h=Zo(f)+h.slice(1));const p=h.charCodeAt(h.length-1),g=Sc(l.after.charCodeAt(0),p,a);g.inside&&(h=h.slice(0,-1)+Zo(p));const b=s.move(a);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:m.outside},c+h+b}function g8(e,t,n){return n.options.emphasis||"*"}function x8(e,t){let n=!1;return rg(e,function(l){if("value"in l&&/\r?\n|\r/.test(l.value)||l.type==="break")return n=!0,hm}),!!((!e.depth||e.depth<3)&&Zm(e)&&(t.options.setext||n))}function y8(e,t,n,l){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(l);if(x8(e,n)){const m=n.enter("headingSetext"),p=n.enter("phrasing"),g=n.containerPhrasing(e,{...o.current(),before:` +`)),m+=c.move(h),f(),m}function m8(e,t,n){return(n?"":" ")+e}function lg(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function g8(e,t,n,l){const a=lg(n),o=a==='"'?"Quote":"Apostrophe",s=n.enter("definition");let c=n.enter("label");const h=n.createTracker(l);let f=h.move("[");return f+=h.move(n.safe(n.associationId(e),{before:f,after:"]",...h.current()})),f+=h.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),f+=h.move("<"),f+=h.move(n.safe(e.url,{before:f,after:">",...h.current()})),f+=h.move(">")):(c=n.enter("destinationRaw"),f+=h.move(n.safe(e.url,{before:f,after:e.title?" ":` +`,...h.current()}))),c(),e.title&&(c=n.enter(`title${o}`),f+=h.move(" "+a),f+=h.move(n.safe(e.title,{before:f,after:a,...h.current()})),f+=h.move(a),c()),s(),f}function x8(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Zo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Sc(e,t,n){const l=wa(e),a=wa(t);return l===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:l===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}wk.peek=y8;function wk(e,t,n,l){const a=x8(n),o=n.enter("emphasis"),s=n.createTracker(l),c=s.move(a);let h=s.move(n.containerPhrasing(e,{after:a,before:c,...s.current()}));const f=h.charCodeAt(0),m=Sc(l.before.charCodeAt(l.before.length-1),f,a);m.inside&&(h=Zo(f)+h.slice(1));const p=h.charCodeAt(h.length-1),g=Sc(l.after.charCodeAt(0),p,a);g.inside&&(h=h.slice(0,-1)+Zo(p));const b=s.move(a);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:m.outside},c+h+b}function y8(e,t,n){return n.options.emphasis||"*"}function v8(e,t){let n=!1;return rg(e,function(l){if("value"in l&&/\r?\n|\r/.test(l.value)||l.type==="break")return n=!0,hm}),!!((!e.depth||e.depth<3)&&Zm(e)&&(t.options.setext||n))}function b8(e,t,n,l){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(l);if(v8(e,n)){const m=n.enter("headingSetext"),p=n.enter("phrasing"),g=n.containerPhrasing(e,{...o.current(),before:` `,after:` `});return p(),m(),g+` `+(a===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(` `))+1))}const s="#".repeat(a),c=n.enter("headingAtx"),h=n.enter("phrasing");o.move(s+" ");let f=n.containerPhrasing(e,{before:"# ",after:` -`,...o.current()});return/^[\t ]/.test(f)&&(f=Zo(f.charCodeAt(0))+f.slice(1)),f=f?s+" "+f:s,n.options.closeAtx&&(f+=" "+s),h(),c(),f}_k.peek=v8;function _k(e){return e.value||""}function v8(){return"<"}Sk.peek=b8;function Sk(e,t,n,l){const a=lg(n),o=a==='"'?"Quote":"Apostrophe",s=n.enter("image");let c=n.enter("label");const h=n.createTracker(l);let f=h.move("![");return f+=h.move(n.safe(e.alt,{before:f,after:"]",...h.current()})),f+=h.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),f+=h.move("<"),f+=h.move(n.safe(e.url,{before:f,after:">",...h.current()})),f+=h.move(">")):(c=n.enter("destinationRaw"),f+=h.move(n.safe(e.url,{before:f,after:e.title?" ":")",...h.current()}))),c(),e.title&&(c=n.enter(`title${o}`),f+=h.move(" "+a),f+=h.move(n.safe(e.title,{before:f,after:a,...h.current()})),f+=h.move(a),c()),f+=h.move(")"),s(),f}function b8(){return"!"}kk.peek=w8;function kk(e,t,n,l){const a=e.referenceType,o=n.enter("imageReference");let s=n.enter("label");const c=n.createTracker(l);let h=c.move("![");const f=n.safe(e.alt,{before:h,after:"]",...c.current()});h+=c.move(f+"]["),s();const m=n.stack;n.stack=[],s=n.enter("reference");const p=n.safe(n.associationId(e),{before:h,after:"]",...c.current()});return s(),n.stack=m,o(),a==="full"||!f||f!==p?h+=c.move(p+"]"):a==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function w8(){return"!"}Ek.peek=_8;function Ek(e,t,n){let l=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(l);)a+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++o\u007F]/.test(e.url))}Ck.peek=S8;function Ck(e,t,n,l){const a=lg(n),o=a==='"'?"Quote":"Apostrophe",s=n.createTracker(l);let c,h;if(Nk(e,n)){const m=n.stack;n.stack=[],c=n.enter("autolink");let p=s.move("<");return p+=s.move(n.containerPhrasing(e,{before:p,after:">",...s.current()})),p+=s.move(">"),c(),n.stack=m,p}c=n.enter("link"),h=n.enter("label");let f=s.move("[");return f+=s.move(n.containerPhrasing(e,{before:f,after:"](",...s.current()})),f+=s.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=n.enter("destinationLiteral"),f+=s.move("<"),f+=s.move(n.safe(e.url,{before:f,after:">",...s.current()})),f+=s.move(">")):(h=n.enter("destinationRaw"),f+=s.move(n.safe(e.url,{before:f,after:e.title?" ":")",...s.current()}))),h(),e.title&&(h=n.enter(`title${o}`),f+=s.move(" "+a),f+=s.move(n.safe(e.title,{before:f,after:a,...s.current()})),f+=s.move(a),h()),f+=s.move(")"),c(),f}function S8(e,t,n){return Nk(e,n)?"<":"["}jk.peek=k8;function jk(e,t,n,l){const a=e.referenceType,o=n.enter("linkReference");let s=n.enter("label");const c=n.createTracker(l);let h=c.move("[");const f=n.containerPhrasing(e,{before:h,after:"]",...c.current()});h+=c.move(f+"]["),s();const m=n.stack;n.stack=[],s=n.enter("reference");const p=n.safe(n.associationId(e),{before:h,after:"]",...c.current()});return s(),n.stack=m,o(),a==="full"||!f||f!==p?h+=c.move(p+"]"):a==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function k8(){return"["}function ag(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function E8(e){const t=ag(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function N8(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Tk(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function C8(e,t,n,l){const a=n.enter("list"),o=n.bulletCurrent;let s=e.ordered?N8(n):ag(n);const c=e.ordered?s==="."?")":".":E8(n);let h=t&&n.bulletLastUsed?s===n.bulletLastUsed:!1;if(!e.ordered){const m=e.children?e.children[0]:void 0;if((s==="*"||s==="-")&&m&&(!m.children||!m.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(h=!0),Tk(n)===s&&m){let p=-1;for(;++p-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let s=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(s=Math.ceil(s/4)*4);const c=n.createTracker(l);c.move(o+" ".repeat(s-o.length)),c.shift(s);const h=n.enter("listItem"),f=n.indentLines(n.containerFlow(e,c.current()),m);return h(),f;function m(p,g,b){return g?(b?"":" ".repeat(s))+p:(b?o:o+" ".repeat(s-o.length))+p}}function A8(e,t,n,l){const a=n.enter("paragraph"),o=n.enter("phrasing"),s=n.containerPhrasing(e,l);return o(),a(),s}const z8=Pc(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function M8(e,t,n,l){return(e.children.some(function(s){return z8(s)})?n.containerPhrasing:n.containerFlow).call(n,e,l)}function D8(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Ak.peek=R8;function Ak(e,t,n,l){const a=D8(n),o=n.enter("strong"),s=n.createTracker(l),c=s.move(a+a);let h=s.move(n.containerPhrasing(e,{after:a,before:c,...s.current()}));const f=h.charCodeAt(0),m=Sc(l.before.charCodeAt(l.before.length-1),f,a);m.inside&&(h=Zo(f)+h.slice(1));const p=h.charCodeAt(h.length-1),g=Sc(l.after.charCodeAt(0),p,a);g.inside&&(h=h.slice(0,-1)+Zo(p));const b=s.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:m.outside},c+h+b}function R8(e,t,n){return n.options.strong||"*"}function O8(e,t,n,l){return n.safe(e.value,l)}function L8(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function H8(e,t,n){const l=(Tk(n)+(n.options.ruleSpaces?" ":"")).repeat(L8(n));return n.options.ruleSpaces?l.slice(0,-1):l}const zk={blockquote:a8,break:ow,code:d8,definition:p8,emphasis:wk,hardBreak:ow,heading:y8,html:_k,image:Sk,imageReference:kk,inlineCode:Ek,link:Ck,linkReference:jk,list:C8,listItem:T8,paragraph:A8,root:M8,strong:Ak,text:O8,thematicBreak:H8};function B8(){return{enter:{table:I8,tableData:sw,tableHeader:sw,tableRow:$8},exit:{codeText:U8,table:q8,tableData:qp,tableHeader:qp,tableRow:qp}}}function I8(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function q8(e){this.exit(e),this.data.inTable=void 0}function $8(e){this.enter({type:"tableRow",children:[]},e)}function qp(e){this.exit(e)}function sw(e){this.enter({type:"tableCell",children:[]},e)}function U8(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,V8));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function V8(e,t){return t==="|"?t:e}function P8(e){const t=e||{},n=t.tableCellPadding,l=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` +`,...o.current()});return/^[\t ]/.test(f)&&(f=Zo(f.charCodeAt(0))+f.slice(1)),f=f?s+" "+f:s,n.options.closeAtx&&(f+=" "+s),h(),c(),f}_k.peek=w8;function _k(e){return e.value||""}function w8(){return"<"}Sk.peek=_8;function Sk(e,t,n,l){const a=lg(n),o=a==='"'?"Quote":"Apostrophe",s=n.enter("image");let c=n.enter("label");const h=n.createTracker(l);let f=h.move("![");return f+=h.move(n.safe(e.alt,{before:f,after:"]",...h.current()})),f+=h.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),f+=h.move("<"),f+=h.move(n.safe(e.url,{before:f,after:">",...h.current()})),f+=h.move(">")):(c=n.enter("destinationRaw"),f+=h.move(n.safe(e.url,{before:f,after:e.title?" ":")",...h.current()}))),c(),e.title&&(c=n.enter(`title${o}`),f+=h.move(" "+a),f+=h.move(n.safe(e.title,{before:f,after:a,...h.current()})),f+=h.move(a),c()),f+=h.move(")"),s(),f}function _8(){return"!"}kk.peek=S8;function kk(e,t,n,l){const a=e.referenceType,o=n.enter("imageReference");let s=n.enter("label");const c=n.createTracker(l);let h=c.move("![");const f=n.safe(e.alt,{before:h,after:"]",...c.current()});h+=c.move(f+"]["),s();const m=n.stack;n.stack=[],s=n.enter("reference");const p=n.safe(n.associationId(e),{before:h,after:"]",...c.current()});return s(),n.stack=m,o(),a==="full"||!f||f!==p?h+=c.move(p+"]"):a==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function S8(){return"!"}Ek.peek=k8;function Ek(e,t,n){let l=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(l);)a+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++o\u007F]/.test(e.url))}Ck.peek=E8;function Ck(e,t,n,l){const a=lg(n),o=a==='"'?"Quote":"Apostrophe",s=n.createTracker(l);let c,h;if(Nk(e,n)){const m=n.stack;n.stack=[],c=n.enter("autolink");let p=s.move("<");return p+=s.move(n.containerPhrasing(e,{before:p,after:">",...s.current()})),p+=s.move(">"),c(),n.stack=m,p}c=n.enter("link"),h=n.enter("label");let f=s.move("[");return f+=s.move(n.containerPhrasing(e,{before:f,after:"](",...s.current()})),f+=s.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=n.enter("destinationLiteral"),f+=s.move("<"),f+=s.move(n.safe(e.url,{before:f,after:">",...s.current()})),f+=s.move(">")):(h=n.enter("destinationRaw"),f+=s.move(n.safe(e.url,{before:f,after:e.title?" ":")",...s.current()}))),h(),e.title&&(h=n.enter(`title${o}`),f+=s.move(" "+a),f+=s.move(n.safe(e.title,{before:f,after:a,...s.current()})),f+=s.move(a),h()),f+=s.move(")"),c(),f}function E8(e,t,n){return Nk(e,n)?"<":"["}jk.peek=N8;function jk(e,t,n,l){const a=e.referenceType,o=n.enter("linkReference");let s=n.enter("label");const c=n.createTracker(l);let h=c.move("[");const f=n.containerPhrasing(e,{before:h,after:"]",...c.current()});h+=c.move(f+"]["),s();const m=n.stack;n.stack=[],s=n.enter("reference");const p=n.safe(n.associationId(e),{before:h,after:"]",...c.current()});return s(),n.stack=m,o(),a==="full"||!f||f!==p?h+=c.move(p+"]"):a==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function N8(){return"["}function ag(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function C8(e){const t=ag(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function j8(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Tk(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function T8(e,t,n,l){const a=n.enter("list"),o=n.bulletCurrent;let s=e.ordered?j8(n):ag(n);const c=e.ordered?s==="."?")":".":C8(n);let h=t&&n.bulletLastUsed?s===n.bulletLastUsed:!1;if(!e.ordered){const m=e.children?e.children[0]:void 0;if((s==="*"||s==="-")&&m&&(!m.children||!m.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(h=!0),Tk(n)===s&&m){let p=-1;for(;++p-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let s=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(s=Math.ceil(s/4)*4);const c=n.createTracker(l);c.move(o+" ".repeat(s-o.length)),c.shift(s);const h=n.enter("listItem"),f=n.indentLines(n.containerFlow(e,c.current()),m);return h(),f;function m(p,g,b){return g?(b?"":" ".repeat(s))+p:(b?o:o+" ".repeat(s-o.length))+p}}function M8(e,t,n,l){const a=n.enter("paragraph"),o=n.enter("phrasing"),s=n.containerPhrasing(e,l);return o(),a(),s}const D8=Pc(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function R8(e,t,n,l){return(e.children.some(function(s){return D8(s)})?n.containerPhrasing:n.containerFlow).call(n,e,l)}function O8(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Ak.peek=L8;function Ak(e,t,n,l){const a=O8(n),o=n.enter("strong"),s=n.createTracker(l),c=s.move(a+a);let h=s.move(n.containerPhrasing(e,{after:a,before:c,...s.current()}));const f=h.charCodeAt(0),m=Sc(l.before.charCodeAt(l.before.length-1),f,a);m.inside&&(h=Zo(f)+h.slice(1));const p=h.charCodeAt(h.length-1),g=Sc(l.after.charCodeAt(0),p,a);g.inside&&(h=h.slice(0,-1)+Zo(p));const b=s.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:m.outside},c+h+b}function L8(e,t,n){return n.options.strong||"*"}function H8(e,t,n,l){return n.safe(e.value,l)}function B8(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function I8(e,t,n){const l=(Tk(n)+(n.options.ruleSpaces?" ":"")).repeat(B8(n));return n.options.ruleSpaces?l.slice(0,-1):l}const zk={blockquote:s8,break:ow,code:p8,definition:g8,emphasis:wk,hardBreak:ow,heading:b8,html:_k,image:Sk,imageReference:kk,inlineCode:Ek,link:Ck,linkReference:jk,list:T8,listItem:z8,paragraph:M8,root:R8,strong:Ak,text:H8,thematicBreak:I8};function q8(){return{enter:{table:$8,tableData:sw,tableHeader:sw,tableRow:V8},exit:{codeText:P8,table:U8,tableData:qp,tableHeader:qp,tableRow:qp}}}function $8(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function U8(e){this.exit(e),this.data.inTable=void 0}function V8(e){this.enter({type:"tableRow",children:[]},e)}function qp(e){this.exit(e)}function sw(e){this.enter({type:"tableCell",children:[]},e)}function P8(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,G8));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function G8(e,t){return t==="|"?t:e}function F8(e){const t=e||{},n=t.tableCellPadding,l=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:s,tableCell:h,tableRow:c}};function s(b,w,E,S){return f(m(b,E,S),b.align)}function c(b,w,E,S){const _=p(b,E,S),N=f([_]);return N.slice(0,N.indexOf(` -`))}function h(b,w,E,S){const _=E.enter("tableCell"),N=E.enter("phrasing"),k=E.containerPhrasing(b,{...S,before:o,after:o});return N(),_(),k}function f(b,w){return i8(b,{align:w,alignDelimiters:l,padding:n,stringLength:a})}function m(b,w,E){const S=b.children;let _=-1;const N=[],k=w.enter("table");for(;++_0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const s9={tokenize:g9,partial:!0};function u9(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:h9,continuation:{tokenize:p9},exit:m9}},text:{91:{name:"gfmFootnoteCall",tokenize:d9},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:c9,resolveTo:f9}}}}function c9(e,t,n){const l=this;let a=l.events.length;const o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let s;for(;a--;){const h=l.events[a][1];if(h.type==="labelImage"){s=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return c;function c(h){if(!s||!s._balanced)return n(h);const f=Fn(l.sliceSerialize({start:s.end,end:l.now()}));return f.codePointAt(0)!==94||!o.includes(f.slice(1))?n(h):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),t(h))}}function f9(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},c=[e[n+1],e[n+2],["enter",l,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",s,t],["exit",s,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",l,t]];return e.splice(n,e.length-n+1,...c),e}function d9(e,t,n){const l=this,a=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let o=0,s;return c;function c(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),h}function h(p){return p!==94?n(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(p){if(o>999||p===93&&!s||p===null||p===91||ut(p))return n(p);if(p===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return a.includes(Fn(l.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return ut(p)||(s=!0),o++,e.consume(p),p===92?m:f}function m(p){return p===91||p===92||p===93?(e.consume(p),o++,f):f(p)}}function h9(e,t,n){const l=this,a=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let o,s=0,c;return h;function h(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",m):n(w)}function m(w){if(s>999||w===93&&!c||w===null||w===91||ut(w))return n(w);if(w===93){e.exit("chunkString");const E=e.exit("gfmFootnoteDefinitionLabelString");return o=Fn(l.sliceSerialize(E)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return ut(w)||(c=!0),s++,e.consume(w),w===92?p:m}function p(w){return w===91||w===92||w===93?(e.consume(w),s++,m):m(w)}function g(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(o)||a.push(o),Qe(e,b,"gfmFootnoteDefinitionWhitespace")):n(w)}function b(w){return t(w)}}function p9(e,t,n){return e.check(ss,t,e.attempt(s9,t,n))}function m9(e){e.exit("gfmFootnoteDefinition")}function g9(e,t,n){const l=this;return Qe(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const s=l.events[l.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?t(o):n(o)}}function x9(e){let n=(e||{}).singleTilde;const l={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function a(s,c){let h=-1;for(;++h1?h(w):(s.consume(w),p++,b);if(p<2&&!n)return h(w);const S=s.exit("strikethroughSequenceTemporary"),_=ba(w);return S._open=!_||_===2&&!!E,S._close=!E||E===2&&!!_,c(w)}}}class y9{constructor(){this.map=[]}add(t,n,l){v9(this,t,n,l)}consume(t){if(this.map.sort(function(o,s){return o[0]-s[0]}),this.map.length===0)return;let n=this.map.length;const l=[];for(;n>0;)n-=1,l.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];l.push(t.slice()),t.length=0;let a=l.pop();for(;a;){for(const o of a)t.push(o);a=l.pop()}this.map.length=0}}function v9(e,t,n,l){let a=0;if(!(n===0&&l.length===0)){for(;a-1;){const q=l.events[B][1].type;if(q==="lineEnding"||q==="linePrefix")B--;else break}const U=B>-1?l.events[B][1].type:null,ee=U==="tableHead"||U==="tableRow"?A:h;return ee===A&&l.parser.lazy[l.now().line]?n(H):ee(H)}function h(H){return e.enter("tableHead"),e.enter("tableRow"),f(H)}function f(H){return H===124||(s=!0,o+=1),m(H)}function m(H){return H===null?n(H):Ee(H)?o>1?(o=0,l.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(H),e.exit("lineEnding"),b):n(H):Ve(H)?Qe(e,m,"whitespace")(H):(o+=1,s&&(s=!1,a+=1),H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),s=!0,m):(e.enter("data"),p(H)))}function p(H){return H===null||H===124||ut(H)?(e.exit("data"),m(H)):(e.consume(H),H===92?g:p)}function g(H){return H===92||H===124?(e.consume(H),p):p(H)}function b(H){return l.interrupt=!1,l.parser.lazy[l.now().line]?n(H):(e.enter("tableDelimiterRow"),s=!1,Ve(H)?Qe(e,w,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):w(H))}function w(H){return H===45||H===58?S(H):H===124?(s=!0,e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),E):M(H)}function E(H){return Ve(H)?Qe(e,S,"whitespace")(H):S(H)}function S(H){return H===58?(o+=1,s=!0,e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),_):H===45?(o+=1,_(H)):H===null||Ee(H)?T(H):M(H)}function _(H){return H===45?(e.enter("tableDelimiterFiller"),N(H)):M(H)}function N(H){return H===45?(e.consume(H),N):H===58?(s=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),k):(e.exit("tableDelimiterFiller"),k(H))}function k(H){return Ve(H)?Qe(e,T,"whitespace")(H):T(H)}function T(H){return H===124?w(H):H===null||Ee(H)?!s||a!==o?M(H):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(H)):M(H)}function M(H){return n(H)}function A(H){return e.enter("tableRow"),L(H)}function L(H){return H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),L):H===null||Ee(H)?(e.exit("tableRow"),t(H)):Ve(H)?Qe(e,L,"whitespace")(H):(e.enter("data"),R(H))}function R(H){return H===null||H===124||ut(H)?(e.exit("data"),L(H)):(e.consume(H),H===92?V:R)}function V(H){return H===92||H===124?(e.consume(H),R):R(H)}}function S9(e,t){let n=-1,l=!0,a=0,o=[0,0,0,0],s=[0,0,0,0],c=!1,h=0,f,m,p;const g=new y9;for(;++nn[2]+1){const w=n[2]+1,E=n[3]-n[2]-1;e.add(w,E,[])}}e.add(n[3]+1,0,[["exit",p,t]])}return a!==void 0&&(o.end=Object.assign({},na(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function cw(e,t,n,l,a){const o=[],s=na(t.events,n);a&&(a.end=Object.assign({},s),o.push(["exit",a,t])),l.end=Object.assign({},s),o.push(["exit",l,t]),e.add(n+1,0,o)}function na(e,t){const n=e[t],l=n[0]==="enter"?"start":"end";return n[1][l]}const k9={name:"tasklistCheck",tokenize:N9};function E9(){return{text:{91:k9}}}function N9(e,t,n){const l=this;return a;function a(h){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?n(h):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),o)}function o(h){return ut(h)?(e.enter("taskListCheckValueUnchecked"),e.consume(h),e.exit("taskListCheckValueUnchecked"),s):h===88||h===120?(e.enter("taskListCheckValueChecked"),e.consume(h),e.exit("taskListCheckValueChecked"),s):n(h)}function s(h){return h===93?(e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):n(h)}function c(h){return Ee(h)?t(h):Ve(h)?e.check({tokenize:C9},t,n)(h):n(h)}}function C9(e,t,n){return Qe(e,l,"whitespace");function l(a){return a===null?n(a):t(a)}}function j9(e){return ZS([W8(),u9(),x9(e),w9(),E9()])}const T9={};function Yc(e){const t=this,n=e||T9,l=t.data(),a=l.micromarkExtensions||(l.micromarkExtensions=[]),o=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),s=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);a.push(j9(n)),o.push(Q8()),s.push(Z8(n))}const A9=new Set([".md",".markdown",".mdx"]);function z9({filePath:e,onClose:t}){const[n,l]=I.useState(null),[a,o]=I.useState(null),[s,c]=I.useState(!0),h=I.useCallback(async()=>{c(!0),o(null);try{const m=e.split("/").map(b=>encodeURIComponent(b)).join("/"),p=await fetch(`/api/files/${m}`);if(!p.ok){const b=await p.json().catch(()=>({}));o(b.error||`HTTP ${p.status}`);return}const g=await p.json();l(g)}catch(m){o(m instanceof Error?m.message:"Failed to load file")}finally{c(!1)}},[e]);I.useEffect(()=>{h()},[h]),I.useEffect(()=>{const m=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const f=n?A9.has(n.extension):!1;return y.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:y.jsxs("div",{className:"relative flex flex-col w-[90vw] max-w-3xl max-h-[80vh] rounded-xl border border-[var(--border)] bg-[var(--surface)] shadow-2xl overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-[var(--border)] bg-[var(--surface-raised)] flex-shrink-0",children:[y.jsx(bw,{className:"w-4 h-4 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate flex-1",title:e,children:e}),n&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] flex-shrink-0 tabular-nums",children:D9(n.size)}),y.jsx("button",{onClick:t,className:"p-1 rounded-md text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--surface-hover)] transition-colors flex-shrink-0",title:"Close (Esc)",children:y.jsx(sl,{className:"w-4 h-4"})})]}),y.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4 min-h-0",children:[s&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(da,{className:"w-5 h-5 text-[var(--text-muted)] animate-spin"})}),a&&y.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/30",children:[y.jsx(lc,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs text-red-300",children:a})]}),n&&!a&&(f?y.jsx("div",{className:"file-viewer-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx(M9,{content:n.content})}):y.jsx("pre",{className:"font-mono text-[11px] leading-[1.6] text-[var(--text)] whitespace-pre-wrap break-words",children:n.content}))]})]})})}function M9({content:e}){return y.jsx(Fc,{remarkPlugins:[Yc],components:{h1:({children:t})=>y.jsx("h1",{className:"text-base font-bold mb-3 mt-2 text-[var(--text)]",children:t}),h2:({children:t})=>y.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 text-[var(--text)]",children:t}),h3:({children:t})=>y.jsx("h3",{className:"text-xs font-bold mb-1.5 mt-2 text-[var(--text)]",children:t}),p:({children:t})=>y.jsx("p",{className:"mb-2 last:mb-0",children:t}),ul:({children:t})=>y.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1 ml-2",children:t}),ol:({children:t})=>y.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1 ml-2",children:t}),li:({children:t})=>y.jsx("li",{children:t}),code:({children:t,className:n})=>(n==null?void 0:n.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-3 py-2 font-mono text-[11px] my-2 overflow-x-auto whitespace-pre",children:t}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:t}),pre:({children:t})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-3 py-2.5 font-mono text-[11px] my-2 overflow-x-auto",children:t}),strong:({children:t})=>y.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>y.jsx("em",{className:"italic",children:t}),a:({href:t,children:n})=>y.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:n}),blockquote:({children:t})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-3 my-2 opacity-80",children:t}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-3"}),table:({children:t})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:t})}),th:({children:t})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:t}),td:({children:t})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:t})},children:e})}function D9(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function R9({node:e}){const t=se(M=>M.sendGateResponse),n=se(M=>M.wsStatus),[l,a]=I.useState(null),[o,s]=I.useState(""),[c,h]=I.useState(null),[f,m]=I.useState(!1),[p,g]=I.useState(null),b=e.status==="waiting",w=e.status==="completed";I.useEffect(()=>{b&&(a(null),s(""),h(null),m(!1))},[b]);const E=b&&n==="connected"&&l===null,S=(M,A)=>{if(E){if(A){a(M),h(A);return}a(M),m(!0),t(e.name,M)}},_=()=>{if(l===null||c===null)return;const M={[c]:o};m(!0),t(e.name,l,M),h(null)},N=e.option_details,k=N==null?void 0:N.find(M=>M.value===e.selected_option),T=(k==null?void 0:k.label)||e.selected_option;return y.jsxs("div",{className:"space-y-3",children:[b&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/30",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-amber-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-amber-400 tracking-wide",children:"Decision Required"})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-amber-500/50 pl-3 py-0.5",children:y.jsx($p,{text:e.prompt,muted:!1,onFileClick:g})}),N&&N.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("div",{className:"flex flex-col gap-1.5",children:N.map(M=>{const A=l===M.value,L=l!==null&&!A;return y.jsx("button",{disabled:!E&&!A,onClick:()=>S(M.value,M.prompt_for),className:`w-full text-left px-3 py-2.5 rounded-lg border transition-all duration-150 ${A?"border-green-500/60 bg-green-500/10":L?"border-[var(--border)] opacity-40 cursor-default":"border-[var(--border)] bg-[var(--surface)] hover:border-amber-400/60 hover:bg-amber-500/5 cursor-pointer group"}`,children:y.jsxs("div",{className:"flex items-center gap-2.5",children:[y.jsx("div",{className:"flex-shrink-0",children:A?y.jsx("div",{className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center",children:y.jsx(Ki,{className:"w-2.5 h-2.5 text-white",strokeWidth:3})}):y.jsx("div",{className:`w-4 h-4 rounded-full border-2 transition-colors ${L?"border-[var(--border)]":"border-[var(--border)] group-hover:border-amber-400"}`})}),y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("span",{className:`text-xs font-medium ${A?"text-green-400":"text-[var(--text)]"}`,children:M.label})}),M.route&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] flex-shrink-0",children:["→ ",M.route]})]})},M.value)})}),f&&!c&&y.jsxs("div",{className:"flex items-center gap-2 px-1",children:[y.jsx(da,{className:"w-3 h-3 text-green-400 animate-spin"}),y.jsx("span",{className:"text-[10px] text-green-400",children:"Sending..."})]}),E&&y.jsx("p",{className:"text-[10px] text-[var(--text-muted)] px-1",children:"Select an option to continue the workflow"})]}),!N&&e.options&&e.options.length>0&&y.jsxs("div",{className:"space-y-1.5",children:[y.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"Options"}),y.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(M=>y.jsx("span",{className:"text-[11px] px-2 py-0.5 rounded border border-[var(--border)] text-[var(--text-muted)]",children:M},M))})]}),c&&y.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg)] overflow-hidden",children:[y.jsx("div",{className:"px-3 py-2 border-b border-[var(--border)] bg-[var(--surface)]",children:y.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:c})}),y.jsxs("div",{className:"p-3 space-y-2",children:[y.jsx("input",{type:"text",value:o,onChange:M=>s(M.target.value),onKeyDown:M=>M.key==="Enter"&&_(),placeholder:`Enter ${c}...`,className:"w-full text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-amber-400 transition-colors",autoFocus:!0}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("span",{className:"text-[10px] text-[var(--text-muted)]",children:"Press Enter or click Submit"}),y.jsxs("button",{onClick:_,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg bg-amber-500 text-white hover:bg-amber-600 transition-colors font-medium",children:[y.jsx(_w,{className:"w-3 h-3"}),"Submit"]})]})]})]})]}),w&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-green-500/10 border border-green-500/30",children:[y.jsx(Ki,{className:"w-3.5 h-3.5 text-green-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs font-semibold text-green-400 tracking-wide",children:"Decision Completed"})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-[var(--border)] pl-3 py-0.5",children:y.jsx($p,{text:e.prompt,muted:!0,onFileClick:g})}),T&&y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-green-500/30 bg-green-500/5",children:[y.jsx("div",{className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center flex-shrink-0",children:y.jsx(Ki,{className:"w-2.5 h-2.5 text-white",strokeWidth:3})}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)]",children:T}),e.route&&y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:["→ ",e.route]})]}),N&&N.length>1&&y.jsx("div",{className:"space-y-1",children:N.filter(M=>M.value!==e.selected_option).map(M=>y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg opacity-35",children:[y.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-[var(--border)] flex-shrink-0"}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:M.label}),M.route&&y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:["→ ",M.route]})]},M.value))}),!N&&e.options&&e.options.length>0&&y.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(M=>y.jsxs("span",{className:`text-[11px] px-2.5 py-1 rounded-lg border ${M===e.selected_option?"border-green-500/30 text-green-400 bg-green-500/5":"border-[var(--border)] text-[var(--text-muted)] opacity-40"}`,children:[M===e.selected_option&&"✓ ",M]},M))}),y.jsx(L9,{node:e})]}),!b&&!w&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Human Gate"}),y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] capitalize",children:["(",e.status,")"]})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-[var(--border)] pl-3 py-0.5",children:y.jsx($p,{text:e.prompt,muted:!0,onFileClick:g})})]}),p&&y.jsx(z9,{filePath:p,onClose:()=>g(null)})]})}function O9(e){return!(!e||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("//")||e.startsWith("#")||e.startsWith("/")||e.startsWith("\\"))}function $p({text:e,muted:t,onFileClick:n}){const l=t?"text-[var(--text-muted)]":"text-[var(--text)]";return y.jsx("div",{className:`gate-markdown text-xs leading-relaxed ${l}`,children:y.jsx(Fc,{remarkPlugins:[Yc],components:{h1:({children:a})=>y.jsx("h1",{className:"text-sm font-bold mb-2 mt-1",children:a}),h2:({children:a})=>y.jsx("h2",{className:"text-xs font-bold mb-1.5 mt-1",children:a}),h3:({children:a})=>y.jsx("h3",{className:"text-xs font-semibold mb-1 mt-1",children:a}),p:({children:a})=>y.jsx("p",{className:"mb-1.5 last:mb-0",children:a}),ul:({children:a})=>y.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:a}),ol:({children:a})=>y.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:a}),li:({children:a})=>y.jsx("li",{children:a}),code:({children:a,className:o})=>(o==null?void 0:o.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1.5 font-mono text-[11px] my-1 overflow-x-auto whitespace-pre",children:a}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:a}),pre:({children:a})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-2.5 py-2 font-mono text-[11px] my-1.5 overflow-x-auto",children:a}),strong:({children:a})=>y.jsx("strong",{className:"font-semibold",children:a}),em:({children:a})=>y.jsx("em",{className:"italic",children:a}),a:({href:a,children:o})=>n&&O9(a)?y.jsxs("button",{onClick:s=>{s.preventDefault(),n(a)},className:"inline-flex items-center gap-0.5 text-blue-400 hover:text-blue-300 underline underline-offset-2 cursor-pointer",title:`Open ${a}`,children:[y.jsx(bw,{className:"w-3 h-3 inline flex-shrink-0"}),o]}):y.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:o}),blockquote:({children:a})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-2.5 my-1.5 opacity-80",children:a}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-2"}),table:({children:a})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:a})}),th:({children:a})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:a}),td:({children:a})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:a})},children:e})})}function L9({node:e}){const t=[];if(e.route&&t.push({label:"Route",value:`→ ${e.route}`}),e.additional_input){const n=typeof e.additional_input=="object"?JSON.stringify(e.additional_input):e.additional_input;t.push({label:"Additional Input",value:n})}return t.length===0?null:y.jsx(Br,{items:t})}function H9({node:e}){const t=e.status,n=De[t]||De.pending,a=j5()[e.name],o=e.type==="for_each_group",[s,c]=I.useState(!0),h=[];e.elapsed!=null&&h.push({label:"Elapsed",value:ot(e.elapsed)}),a&&(h.push({label:"Total",value:a.total}),h.push({label:"Completed",value:a.completed}),a.failed>0&&h.push({label:"Failed",value:a.failed})),e.success_count!=null&&h.push({label:"Success",value:e.success_count}),e.failure_count!=null&&h.push({label:"Failures",value:e.failure_count});const f=e.for_each_items;return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${n}20`,color:n},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:o?"For-Each Group":"Parallel Group"})]}),a&&a.total>0&&y.jsxs("div",{className:"space-y-1",children:[y.jsxs("div",{className:"flex justify-between text-[10px] text-[var(--text-muted)]",children:[y.jsx("span",{children:"Progress"}),y.jsxs("span",{children:[a.completed+a.failed,"/",a.total]})]}),y.jsx("div",{className:"h-1.5 bg-[var(--bg)] rounded-full overflow-hidden",children:y.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${(a.completed+a.failed)/a.total*100}%`,background:a.failed>0?`linear-gradient(90deg, var(--completed) ${a.completed/(a.completed+a.failed)*100}%, var(--failed) 0%)`:"var(--completed)"}})})]}),y.jsx(Br,{items:h}),o&&f&&f.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("button",{onClick:()=>c(!s),className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold hover:text-[var(--text)] transition-colors",children:[s?y.jsx(ol,{className:"w-3 h-3"}):y.jsx(Lr,{className:"w-3 h-3"}),"Items (",f.length,")"]}),s&&y.jsx("div",{className:"space-y-1",children:f.map(m=>y.jsx(I9,{groupName:e.name,item:m},`${m.key}-${m.index}`))})]})]})}const B9={running:De.running,completed:De.completed,failed:De.failed};function I9({groupName:e,item:t}){const[n,l]=I.useState(t.status==="running"),a=B9[t.status],o=$m(),s=se(g=>g.navigateIntoSubworkflow),c=`${e}[${t.key}]`,h=o.find(g=>g.slotKey===c),f=!!h,m=!!(t.prompt||t.output!=null||t.activity&&t.activity.length>0||t.error_type),p=[];return t.elapsed!=null&&p.push({label:"Elapsed",value:ot(t.elapsed)}),t.tokens!=null&&p.push({label:"Tokens",value:Pn(t.tokens)}),t.cost_usd!=null&&p.push({label:"Cost",value:wi(t.cost_usd)}),y.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--surface)] overflow-hidden",children:[y.jsxs("button",{onClick:()=>m&&l(!n),className:"flex items-center gap-2 w-full px-3 py-2 text-left hover:bg-[var(--node-bg)] transition-colors",disabled:!m,children:[m?n?y.jsx(ol,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}):y.jsx(Lr,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}):t.status==="running"?y.jsx(da,{className:"w-3 h-3 animate-spin flex-shrink-0",style:{color:a}}):y.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ml-0.5 mr-0.5",style:{backgroundColor:a}}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate flex-1 min-w-0",children:t.key}),!n&&(t.elapsed!=null||t.tokens!=null||t.cost_usd!=null)&&y.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-[var(--text-muted)] flex-shrink-0",children:[t.elapsed!=null&&y.jsx("span",{children:ot(t.elapsed)}),t.tokens!=null&&y.jsx("span",{children:Pn(t.tokens)}),t.cost_usd!=null&&y.jsx("span",{children:wi(t.cost_usd)})]}),y.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider flex-shrink-0 px-1.5 py-0.5 rounded",style:{backgroundColor:`${a}20`,color:a},children:t.status}),f&&y.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),s(c)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.stopPropagation(),g.preventDefault(),s(c))},title:`Dive into ${(h==null?void 0:h.workflowName)??c}`,className:"flex-shrink-0 p-1 rounded hover:bg-[var(--accent)]/20 hover:text-[var(--accent)] transition-colors text-[var(--text-muted)] cursor-pointer",children:y.jsx(kc,{className:"w-3 h-3"})})]}),n&&m&&y.jsxs("div",{className:"px-3 py-3 space-y-3 border-t border-[var(--border)]",children:[p.length>0&&y.jsx(Br,{items:p}),t.prompt&&y.jsx(_i,{output:t.prompt,title:"Input / Prompt",defaultExpanded:!1}),t.activity&&t.activity.length>0&&y.jsx(Vm,{activity:t.activity,defaultExpanded:t.status!=="completed"}),t.output!=null&&y.jsx(_i,{output:t.output,title:"Output",defaultExpanded:!0}),t.status==="failed"&&(t.error_type||t.error_message)&&y.jsxs("div",{className:"text-xs text-red-400",children:[t.error_type&&y.jsx("span",{className:"font-semibold",children:t.error_type}),t.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",t.error_message]})]})]})]})}function q9({node:e}){const t=se(f=>f.engageDialog),n=se(f=>f.sendDialogDecline),l=se(f=>f.wsStatus),a=e.dialog_id||"",o=e.dialog_messages||[],s=l==="connected",c=o.find(f=>f.role==="agent"),h=()=>{s&&n(e.name,a)};return y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-fuchsia-500/10 border border-fuchsia-500/30",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-fuchsia-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-fuchsia-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-fuchsia-400 tracking-wide",children:"Dialog Requested"})]}),c&&y.jsxs("div",{className:"rounded-lg px-3 py-2 bg-amber-500/10 border border-amber-500/30",children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:e.name}),y.jsx("div",{className:"dialog-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx(Fc,{remarkPlugins:[Yc],children:c.content})})]}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"How would you like to proceed?"}),y.jsxs("div",{className:"flex gap-2",children:[y.jsxs("button",{onClick:t,disabled:!s,className:"flex-1 flex items-center justify-center gap-1.5 text-xs px-3 py-2 rounded-lg border border-fuchsia-500/40 bg-fuchsia-500/10 text-fuchsia-300 hover:bg-fuchsia-500/20 transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(ym,{className:"w-3 h-3"}),"💬 Discuss"]}),y.jsxs("button",{onClick:h,disabled:!s,className:"flex-1 flex items-center justify-center gap-1.5 text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--surface)] text-[var(--text-muted)] hover:bg-[var(--surface-hover)] transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(sl,{className:"w-3 h-3"}),"✕ Skip & continue"]})]})]})]})}function $9({node:e}){const t=e.status,n=De[t]||De.pending,l=se(c=>c.navigateIntoSubworkflow),o=$m().filter(c=>c.parentAgent===e.name),s=[];return e.elapsed!=null&&s.push({label:"Elapsed",value:ot(e.elapsed)}),e.cost_usd!=null&&s.push({label:"Cost",value:wi(e.cost_usd)}),e.tokens!=null&&s.push({label:"Tokens",value:Pn(e.tokens)}),e.iteration!=null&&e.iteration>1&&s.push({label:"Iteration",value:e.iteration}),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${n}20`,color:n},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Subworkflow Agent"})]}),y.jsx(Br,{items:s}),o.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:["Subworkflow Runs (",o.length,")"]}),y.jsx("div",{className:"space-y-1",children:o.map((c,h)=>y.jsx(U9,{ctx:c,onClick:()=>l(c.slotKey)},`${c.slotKey}-${c.iteration}-${h}`))})]}),t==="failed"&&(e.error_type||e.error_message)&&y.jsxs("div",{className:"text-xs text-red-400",children:[e.error_type&&y.jsx("span",{className:"font-semibold",children:e.error_type}),e.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",e.error_message]})]}),o.length===0&&t==="pending"&&y.jsx("div",{className:"text-xs text-[var(--text-muted)] italic",children:"Subworkflow has not started yet."})]})}function U9({ctx:e,onClick:t}){const n=De[e.status]||De.pending;return y.jsxs("button",{onClick:t,className:"flex items-center gap-2 w-full px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--surface)] hover:bg-[var(--node-bg)] transition-colors text-left",children:[y.jsx(kc,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:n}}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:e.workflowName||e.workflowFile||"Subworkflow"}),y.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-[var(--text-muted)]",children:[e.agentsTotal>0&&y.jsxs("span",{className:"flex items-center gap-0.5",children:[y.jsx(ww,{className:"w-2.5 h-2.5"}),e.agentsCompleted,"/",e.agentsTotal," agents"]}),e.totalCost>0&&y.jsxs("span",{className:"flex items-center gap-0.5",children:[y.jsx(yw,{className:"w-2.5 h-2.5"}),wi(e.totalCost)]})]})]}),y.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider flex-shrink-0 px-1.5 py-0.5 rounded",style:{backgroundColor:`${n}20`,color:n},children:e.status}),y.jsx(Lr,{className:"w-3.5 h-3.5 flex-shrink-0 text-[var(--text-muted)]"})]})}function V9({node:e}){const t=e.status,n=De[t]||De.pending,l=[],a=e.requested_seconds??e.duration_seconds;return a!=null&&l.push({label:"Requested",value:ot(a)}),e.waited_seconds!=null?l.push({label:"Waited",value:ot(e.waited_seconds)}):e.elapsed!=null&&l.push({label:"Elapsed",value:ot(e.elapsed)}),e.interrupted&&l.push({label:"Interrupted",value:"yes"}),e.reason&&l.push({label:"Reason",value:e.reason}),e.error_type&&l.push({label:"Error",value:e.error_type}),e.error_message&&l.push({label:"Message",value:e.error_message}),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${n}20`,color:n},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Wait"})]}),y.jsx(Br,{items:l})]})}function P9(){const e=se(h=>h.selectedNode),t=Qn(),n=se(h=>h.selectNode),l=se(h=>h.dialogEngaged),[a,o]=I.useState(!1);I.useEffect(()=>(requestAnimationFrame(()=>o(!0)),()=>o(!1)),[e]);const s=e?t[e]:null;if(!e||!s)return y.jsxs("div",{className:"h-full flex flex-col bg-[var(--surface)]",children:[y.jsx("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)]",children:y.jsx("h2",{className:"text-sm font-semibold text-[var(--text)]",children:"Detail"})}),y.jsx("div",{className:"flex-1 flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Click a node to view details"})})]});const c=(()=>{if(s.dialog_active&&!l)return q9;if(s.dialog_active&&l)return b1;switch(s.type){case"script":return aD;case"wait":return V9;case"set":return oD;case"human_gate":return R9;case"parallel_group":case"for_each_group":return H9;case"workflow":return $9;default:return b1}})();return y.jsxs("div",{className:Ae("h-full flex flex-col bg-[var(--surface)] transition-all duration-150 ease-out",a?"translate-x-0 opacity-100":"translate-x-4 opacity-0"),children:[y.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)] flex-shrink-0",children:[y.jsx("h2",{className:"text-sm font-semibold text-[var(--text)] truncate",children:e}),y.jsx("button",{onClick:()=>n(null),className:"p-1 rounded hover:bg-[var(--surface-hover)] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",title:"Close panel",children:y.jsx(sl,{className:"w-4 h-4"})})]}),y.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:y.jsx(c,{node:s})})]})}function ic(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function G9(){const e=se(S=>S.eventLog),t=se(S=>S.activityLog),n=se(S=>S.workflowOutput),l=se(S=>S.workflowStatus),[a,o]=I.useState("log"),[s,c]=I.useState(!1),[h,f]=I.useState(0),[m,p]=I.useState(0),g=I.useCallback(S=>{o(S),S==="log"&&f(e.length),S==="activity"&&p(t.length)},[e.length,t.length]);I.useEffect(()=>{a==="log"&&f(e.length)},[a,e.length]),I.useEffect(()=>{a==="activity"&&p(t.length)},[a,t.length]),I.useEffect(()=>{l==="completed"&&n!=null&&o("output")},[l,n]);const b=n!=null,w=a!=="log"?Math.max(0,e.length-h):0,E=a!=="activity"?Math.max(0,t.length-m):0;return s?y.jsx("div",{className:"flex items-center bg-[var(--surface)] border-t border-[var(--border)] px-3 py-1",children:y.jsxs("button",{onClick:()=>c(!1),className:"flex items-center gap-1.5 text-xs text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",children:[y.jsx(fN,{className:"w-3 h-3"}),y.jsx(ev,{className:"w-3 h-3"}),y.jsx("span",{children:"Output"}),t.length>0&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)]",children:["(",t.length,")"]})]})}):y.jsxs("div",{className:"flex flex-col h-full bg-[var(--surface)] border-t border-[var(--border)]",children:[y.jsxs("div",{className:"flex items-center justify-between px-2 flex-shrink-0 border-b border-[var(--border)]",children:[y.jsxs("div",{className:"flex items-center gap-0.5",children:[y.jsx(Up,{active:a==="log",onClick:()=>g("log"),icon:y.jsx(ev,{className:"w-3 h-3"}),label:"Log",count:e.length,unread:w}),y.jsx(Up,{active:a==="activity",onClick:()=>g("activity"),icon:y.jsx(gw,{className:"w-3 h-3"}),label:"Activity",count:t.length,unread:E}),y.jsx(Up,{active:a==="output",onClick:()=>g("output"),icon:y.jsx(xN,{className:"w-3 h-3"}),label:"Output",badge:b?l==="failed"?"error":"success":void 0})]}),y.jsx("button",{onClick:()=>c(!0),className:"p-1 rounded text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--surface-hover)] transition-colors",title:"Collapse panel",children:y.jsx(ol,{className:"w-3.5 h-3.5"})})]}),y.jsx("div",{className:"flex-1 overflow-hidden",children:a==="activity"?y.jsx(F9,{entries:t}):a==="log"?y.jsx(Y9,{entries:e}):y.jsx(X9,{output:n,status:l})})]})}function Up({active:e,onClick:t,icon:n,label:l,count:a,badge:o,unread:s}){return y.jsxs("button",{onClick:t,className:Ae("relative flex items-center gap-1.5 px-3 py-1.5 text-xs transition-colors border-b-2 -mb-px",e?"text-[var(--text)] border-[var(--accent)]":"text-[var(--text-muted)] border-transparent hover:text-[var(--text-secondary)]"),children:[n,y.jsx("span",{children:l}),a!=null&&a>0&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] tabular-nums",children:a}),o&&y.jsx("span",{className:Ae("w-1.5 h-1.5 rounded-full",o==="success"?"bg-[var(--completed)]":"bg-[var(--failed)]")}),!e&&s!=null&&s>0&&y.jsx("span",{className:"absolute -top-0.5 -right-0.5 flex h-3.5 min-w-[14px] items-center justify-center rounded-full bg-[var(--accent)] px-1",children:y.jsx("span",{className:"text-[8px] font-bold text-white leading-none tabular-nums",children:s>99?"99+":s})})]})}const fw={reasoning:{color:"text-indigo-400/70",label:"THINK",labelColor:"text-indigo-500"},"tool-start":{color:"text-blue-400",label:"TOOL →",labelColor:"text-blue-500"},"tool-complete":{color:"text-green-400",label:"TOOL ←",labelColor:"text-green-600"},turn:{color:"text-amber-400",label:"STEP",labelColor:"text-amber-500"},message:{color:"text-[var(--text)]",label:"MSG",labelColor:"text-[var(--text-muted)]"},prompt:{color:"text-cyan-400/70",label:"PROMPT",labelColor:"text-cyan-600"}};function F9({entries:e}){const t=I.useRef(null),n=I.useRef(!0),l=se(h=>h.selectNode),[a,o]=I.useState(""),s=I.useCallback(()=>{const h=t.current;if(!h)return;const f=h.scrollHeight-h.scrollTop-h.clientHeight<30;n.current=f},[]),c=I.useMemo(()=>{if(!a)return e;const h=a.toLowerCase();return e.filter(f=>f.source.toLowerCase().includes(h)||ic(f.message).toLowerCase().includes(h))},[e,a]);return I.useEffect(()=>{t.current&&n.current&&(t.current.scrollTop=t.current.scrollHeight)},[c.length]),e.length===0?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Waiting for agent activity…"})}):y.jsxs("div",{className:"h-full flex flex-col",children:[y.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-[var(--border-subtle)] flex-shrink-0",children:[y.jsx(_N,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("input",{type:"text",value:a,onChange:h=>o(h.target.value),placeholder:"Filter by agent or message…",className:"flex-1 bg-transparent text-[11px] text-[var(--text)] placeholder:text-[var(--text-muted)] outline-none min-w-0"}),a&&y.jsxs(y.Fragment,{children:[y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] tabular-nums flex-shrink-0",children:[c.length," of ",e.length]}),y.jsx("button",{onClick:()=>o(""),className:"text-[var(--text-muted)] hover:text-[var(--text)] transition-colors flex-shrink-0",title:"Clear filter",children:y.jsx(sl,{className:"w-3 h-3"})})]})]}),y.jsxs("div",{ref:t,onScroll:s,className:"flex-1 overflow-y-auto font-mono text-[11px] leading-[1.6] px-3 py-2",children:[c.map((h,f)=>{const m=fw[h.type]||fw.message,p=qk(h.timestamp);return y.jsxs("div",{className:"group",children:[y.jsxs("div",{className:"flex gap-1.5 hover:bg-[var(--surface-hover)] rounded px-1 -mx-1",children:[y.jsx("span",{className:"text-[var(--text-muted)] flex-shrink-0 select-none tabular-nums",children:p}),y.jsx("span",{className:Ae("flex-shrink-0 w-[5ch] text-[10px] font-semibold tabular-nums select-none",m.labelColor),children:m.label}),y.jsx("button",{onClick:()=>l(h.source),className:"text-[var(--text-secondary)] flex-shrink-0 min-w-[8ch] max-w-[16ch] truncate hover:text-[var(--accent)] hover:underline transition-colors text-left",title:`Select ${h.source}`,children:h.source}),y.jsx("span",{className:Ae("break-words min-w-0",m.color,h.type==="reasoning"&&"italic"),children:ic(h.message)})]}),h.detail&&y.jsx("div",{className:"ml-[calc(7ch+5ch+8ch+1rem)] px-2 py-1 my-0.5 bg-[var(--bg)] rounded text-[10px] text-[var(--text-muted)] whitespace-pre-wrap break-words max-h-24 overflow-y-auto border-l-2 border-[var(--border)]",children:ic(h.detail)})]},f)}),a&&c.length===0&&y.jsx("div",{className:"flex items-center justify-center py-4",children:y.jsxs("p",{className:"text-xs text-[var(--text-muted)]",children:['No matches for "',a,'"']})})]})]})}const dw={info:{color:"text-blue-400",icon:"›"},success:{color:"text-green-400",icon:"✓"},error:{color:"text-red-400",icon:"✗"},warning:{color:"text-amber-400",icon:"⚠"},debug:{color:"text-[var(--text-muted)]",icon:"·"}};function Y9({entries:e}){const t=I.useRef(null),n=I.useRef(!0),l=se(o=>o.selectNode),a=I.useCallback(()=>{const o=t.current;if(!o)return;const s=o.scrollHeight-o.scrollTop-o.clientHeight<30;n.current=s},[]);return I.useEffect(()=>{t.current&&n.current&&(t.current.scrollTop=t.current.scrollHeight)},[e.length]),e.length===0?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Waiting for events…"})}):y.jsx("div",{ref:t,onScroll:a,className:"h-full overflow-y-auto font-mono text-[11px] leading-[1.6] px-3 py-2",children:e.map((o,s)=>{const c=dw[o.level]||dw.info,h=qk(o.timestamp);return y.jsxs("div",{className:"flex gap-2 hover:bg-[var(--surface-hover)] rounded px-1 -mx-1",children:[y.jsx("span",{className:"text-[var(--text-muted)] flex-shrink-0 select-none tabular-nums",children:h}),y.jsx("span",{className:Ae("flex-shrink-0 w-3 text-center select-none",c.color),children:c.icon}),y.jsx("button",{onClick:()=>l(o.source),className:"text-[var(--text-secondary)] flex-shrink-0 min-w-[8ch] max-w-[16ch] truncate hover:text-[var(--accent)] hover:underline transition-colors text-left",title:`Select ${o.source}`,children:o.source}),y.jsx("span",{className:Ae("break-words",o.level==="error"?"text-red-400":o.level==="success"?"text-green-400":"text-[var(--text)]"),children:ic(o.message)})]},s)})})}function qk(e){const t=new Date(e*1e3),n=t.getHours().toString().padStart(2,"0"),l=t.getMinutes().toString().padStart(2,"0"),a=t.getSeconds().toString().padStart(2,"0");return`${n}:${l}:${a}`}function X9({output:e,status:t}){const[n,l]=I.useState(!1),a=kw(e),o=async()=>{a&&(await navigator.clipboard.writeText(a),l(!0),setTimeout(()=>l(!1),2e3))};return e==null?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t==="running"?"Workflow running — output will appear when complete…":t==="failed"?"Workflow failed — no output produced":"No output yet"})}):y.jsxs("div",{className:"h-full flex flex-col",children:[y.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-[var(--border-subtle)] flex-shrink-0",children:[y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] uppercase tracking-wider font-semibold",children:"Workflow Result"}),y.jsx("button",{onClick:o,className:"flex items-center gap-1 text-[10px] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors px-1.5 py-0.5 rounded hover:bg-[var(--surface-hover)]",title:"Copy to clipboard",children:n?y.jsxs(y.Fragment,{children:[y.jsx(Ki,{className:"w-3 h-3 text-[var(--completed)]"}),y.jsx("span",{className:"text-[var(--completed)]",children:"Copied"})]}):y.jsxs(y.Fragment,{children:[y.jsx(vw,{className:"w-3 h-3"}),y.jsx("span",{children:"Copy"})]})})]}),y.jsx("div",{className:"flex-1 overflow-auto px-3 py-2",children:y.jsx("pre",{className:"font-mono text-[11px] leading-relaxed text-[var(--text)] whitespace-pre-wrap break-words",children:typeof e=="object"?y.jsx(Q9,{text:a}):a})})]})}function Q9({text:e}){const t=e.split(/("(?:[^"\\]|\\.)*")/g);return y.jsx(y.Fragment,{children:t.map((n,l)=>{if(l%2===1){const o=t.slice(l+1).join(""),s=/^\s*:/.test(o);return y.jsx("span",{className:s?"text-blue-400":"text-green-400",children:n},l)}const a=n.replace(/\b(true|false|null)\b|(-?\d+\.?\d*(?:e[+-]?\d+)?)/gi,(o,s,c)=>s?`${o}`:c?`${o}`:o);return y.jsx("span",{dangerouslySetInnerHTML:{__html:a}},l)})})}function Z9({text:e}){return y.jsx("div",{className:"dialog-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx(Fc,{remarkPlugins:[Yc],components:{h1:({children:t})=>y.jsx("h1",{className:"text-sm font-bold mb-2 mt-1",children:t}),h2:({children:t})=>y.jsx("h2",{className:"text-xs font-bold mb-1.5 mt-1",children:t}),h3:({children:t})=>y.jsx("h3",{className:"text-xs font-semibold mb-1 mt-1",children:t}),p:({children:t})=>y.jsx("p",{className:"mb-1.5 last:mb-0",children:t}),ul:({children:t})=>y.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:t}),ol:({children:t})=>y.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:t}),li:({children:t})=>y.jsx("li",{children:t}),code:({children:t,className:n})=>(n==null?void 0:n.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1.5 font-mono text-[11px] my-1 overflow-x-auto whitespace-pre",children:t}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:t}),pre:({children:t})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-2.5 py-2 font-mono text-[11px] my-1.5 overflow-x-auto",children:t}),strong:({children:t})=>y.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>y.jsx("em",{className:"italic",children:t}),a:({href:t,children:n})=>y.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:n}),blockquote:({children:t})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-2.5 my-1.5 opacity-80",children:t}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-2"}),table:({children:t})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:t})}),th:({children:t})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:t}),td:({children:t})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:t})},children:e})})}function K9({node:e}){const t=se(g=>g.sendDialogMessage),n=se(g=>g.wsStatus),[l,a]=I.useState(""),o=I.useRef(null),s=e.dialog_active===!0,c=e.dialog_id||"",h=e.dialog_messages||[],f=s&&n==="connected";I.useEffect(()=>{var g;(g=o.current)==null||g.scrollIntoView({behavior:"smooth"})},[h.length,e.dialog_awaiting_response]);const m=()=>{!l.trim()||!f||(t(e.name,c,l.trim()),a(""))},p=g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),m())};return y.jsxs("div",{className:"flex flex-col h-full",children:[s?y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-fuchsia-500/10 border border-fuchsia-500/30 mb-3 flex-shrink-0",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-fuchsia-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-fuchsia-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-fuchsia-400 tracking-wide",children:"Dialog Mode"}),y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:[h.length," message",h.length!==1?"s":""]})]}):y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-[var(--surface)] border border-[var(--border)] mb-3 flex-shrink-0",children:[y.jsx(ym,{className:"w-3.5 h-3.5 text-[var(--text-muted)]"}),y.jsx("span",{className:"text-xs font-semibold text-[var(--text-muted)] tracking-wide",children:"Dialog Completed"}),y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:[h.length," message",h.length!==1?"s":""]})]}),y.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3 min-h-0 mb-3",children:[h.map((g,b)=>y.jsx("div",{className:`flex ${g.role==="user"?"justify-end":"justify-start"}`,children:y.jsxs("div",{className:`max-w-[85%] rounded-lg px-3 py-2 ${g.role==="agent"?"bg-amber-500/10 border border-amber-500/30":"bg-blue-500/10 border border-blue-500/30"}`,children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:g.role==="agent"?e.name:"You"}),y.jsx(Z9,{text:g.content})]})},b)),e.dialog_awaiting_response&&y.jsx("div",{className:"flex justify-start",children:y.jsxs("div",{className:"max-w-[85%] rounded-lg px-3 py-2 bg-amber-500/10 border border-amber-500/30",children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:e.name}),y.jsxs("div",{className:"flex gap-1 items-center h-4",children:[y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:0ms]"}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:150ms]"}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:300ms]"})]})]})}),y.jsx("div",{ref:o})]}),s&&y.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] pt-3",children:[y.jsxs("div",{className:"flex gap-2",children:[y.jsx("input",{type:"text",value:l,onChange:g=>a(g.target.value),onKeyDown:p,placeholder:"Type your message...",className:"flex-1 text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-fuchsia-400 transition-colors",disabled:!f,autoFocus:!0}),y.jsxs("button",{onClick:m,disabled:!f||!l.trim(),className:"flex items-center justify-center gap-1.5 text-xs px-8 py-2 rounded-lg bg-fuchsia-500 text-white hover:bg-fuchsia-600 transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(_w,{className:"w-3 h-3"}),"Send"]})]}),y.jsx("p",{className:"text-[10px] text-[var(--text-muted)] mt-1.5 px-1",children:'Press Enter to send · Type "done" to end dialog'})]})]})}function J9(){const e=se(l=>l.activeDialog),t=se(l=>l.nodes);if(!e)return null;const n=t[e.agentName];return n?y.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg)] overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3 border-b border-[var(--border)] bg-[var(--surface)] flex-shrink-0",children:[y.jsx(ym,{className:"w-4 h-4 text-fuchsia-400"}),y.jsxs("h2",{className:"text-sm font-semibold text-[var(--text)]",children:["Dialog with ",e.agentName]})]}),y.jsx("div",{className:"flex-1 overflow-hidden px-5 py-4",children:y.jsx(K9,{node:n})})]}):null}function W9(){const e=se(l=>l.selectedNode),t=se(l=>l.activeDialog),n=se(l=>l.dialogEngaged);return y.jsxs(Pp,{direction:"vertical",className:"flex-1 overflow-hidden",children:[y.jsx(Co,{defaultSize:70,minSize:30,children:y.jsxs(Pp,{direction:"horizontal",className:"h-full",children:[y.jsx(Co,{defaultSize:e?65:100,minSize:40,children:t&&n?y.jsx(J9,{}):y.jsx(J4,{})}),e&&y.jsxs(y.Fragment,{children:[y.jsx(Gp,{className:"w-[3px] bg-[var(--border)] hover:bg-[var(--text-muted)] transition-colors cursor-col-resize"}),y.jsx(Co,{defaultSize:35,minSize:20,maxSize:60,children:y.jsx(P9,{})})]})]})}),y.jsx(Gp,{className:"h-[3px] bg-[var(--border)] hover:bg-[var(--text-muted)] transition-colors cursor-row-resize"}),y.jsx(Co,{defaultSize:30,minSize:5,maxSize:70,collapsible:!0,children:y.jsx(G9,{})})]})}const hw=10;function eH(){const e=se(E=>E.iterationLimitGate),t=se(E=>E.wsStatus),n=se(E=>E.sendIterationLimitResponse),[l,a]=I.useState(String(hw)),[o,s]=I.useState(!1);I.useEffect(()=>{e!=null&&e.gate_id&&(a(String(hw)),s(!1))},[e==null?void 0:e.gate_id]);const c=I.useMemo(()=>{const E=Number(l);return!Number.isFinite(E)||E<0?null:Math.floor(E)},[l]);if(!e||e.skip_gates)return null;const h=e.agent_name??e.group_name??"workflow",f=t==="connected"&&!o,m=!f||c==null||c<=0,p=()=>e.agent_name!==void 0?{agent_name:e.agent_name}:{group_name:e.group_name},g=()=>{m||c==null||(s(!0),n(p(),e.gate_id,c))},b=()=>{f&&(s(!0),n(p(),e.gate_id,0))},w=E=>{E.key==="Enter"&&(E.preventDefault(),g())};return y.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"iteration-limit-title","data-testid":"iteration-limit-modal",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:y.jsxs("div",{className:"relative flex flex-col w-[90vw] max-w-md rounded-xl border border-amber-500/40 bg-[var(--surface)] shadow-2xl overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-[var(--border)] bg-amber-500/10",children:[y.jsx(lc,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),y.jsx("h2",{id:"iteration-limit-title",className:"text-sm font-semibold text-[var(--text)]",children:"Max iterations reached"})]}),y.jsxs("div",{className:"px-4 py-4 space-y-3",children:[y.jsxs("p",{className:"text-xs text-[var(--text)]",children:[y.jsx("span",{className:"font-semibold",children:h})," reached"," ",y.jsxs("span",{className:"tabular-nums",children:[e.current_iteration,"/",e.max_iterations]})," ","iterations."]}),e.possible_loop&&y.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-amber-500/5 border border-amber-500/30",children:[y.jsx(lc,{className:"w-3.5 h-3.5 text-amber-400 flex-shrink-0"}),y.jsx("span",{className:"text-[11px] text-amber-300",children:"The same agent has run repeatedly — this may indicate a loop."})]}),e.agent_history.length>0&&y.jsxs("div",{className:"space-y-1",children:[y.jsx("h3",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"Recent agents"}),y.jsx("ol",{className:"text-[11px] text-[var(--text-muted)] list-decimal list-inside space-y-0.5",children:e.agent_history.map((E,S)=>y.jsx("li",{children:E},`${S}-${E}`))})]}),y.jsxs("div",{className:"space-y-1.5",children:[y.jsx("label",{htmlFor:"iteration-limit-additional",className:"block text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"Additional iterations"}),y.jsx("input",{id:"iteration-limit-additional","data-testid":"iteration-limit-input",type:"number",min:0,step:1,value:l,onChange:E=>a(E.target.value),onKeyDown:w,disabled:!f,autoFocus:!0,className:"w-full text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-amber-400 transition-colors disabled:opacity-50"}),y.jsx("p",{className:"text-[10px] text-[var(--text-muted)]",children:"Enter a positive number to continue, or press Stop to end the workflow."})]}),t!=="connected"&&y.jsx("div",{className:"text-[11px] text-red-300",children:"Disconnected from server — reconnect to resolve this gate."})]}),y.jsxs("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-[var(--border)] bg-[var(--surface-raised)]",children:[y.jsxs("button",{type:"button","data-testid":"iteration-limit-stop",onClick:b,disabled:!f,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border border-[var(--border)] text-[var(--text)] hover:bg-[var(--surface-hover)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[y.jsx(hN,{className:"w-3.5 h-3.5"}),"Stop"]}),y.jsxs("button",{type:"button","data-testid":"iteration-limit-continue",onClick:g,disabled:m,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg bg-amber-500 text-white hover:bg-amber-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors font-medium",children:[y.jsx(Ec,{className:"w-3.5 h-3.5"}),"Continue"]})]})]})})}const tH=3e4;function nH(){const e=se(p=>p.processEvent),t=se(p=>p.replayState),n=se(p=>p.setWsStatus),l=se(p=>p.setWsSend),a=I.useRef(null),o=I.useRef(1e3),s=I.useRef(null),c=I.useRef(null),h=I.useRef(()=>{}),f=I.useCallback(()=>{n("reconnecting"),s.current=setTimeout(()=>{o.current=Math.min(o.current*2,tH),h.current()},o.current)},[n]),m=I.useCallback(()=>{n("connecting"),c.current&&c.current.abort();const p=new AbortController;c.current=p,fetch("/api/state",{signal:p.signal}).then(g=>g.json()).then(g=>{g&&g.length>0&&t(g);const w=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;try{const E=new WebSocket(w);a.current=E,E.onopen=()=>{o.current=1e3,n("connected"),l(S=>{E.readyState===WebSocket.OPEN&&E.send(JSON.stringify(S))})},E.onmessage=S=>{try{const _=JSON.parse(S.data);e(_)}catch(_){console.error("Failed to parse WebSocket message:",_)}},E.onclose=()=>{n("disconnected"),l(null),a.current=null,f()},E.onerror=()=>{}}catch{f()}}).catch(g=>{p.signal.aborted||(console.error("Failed to fetch state:",g),f())})},[e,t,n,l,f]);h.current=m,I.useEffect(()=>(m(),()=>{c.current&&c.current.abort(),s.current&&clearTimeout(s.current),a.current&&a.current.close(),l(null)}),[m,l])}function rH(){const e=se(f=>f.setReplayMode),t=se(f=>f.setWsStatus),n=se(f=>f.replayPlaying),l=se(f=>f.replayPosition),a=se(f=>f.replayTotalEvents),o=se(f=>f.replaySpeed),s=se(f=>f.replayEvents),c=se(f=>f.setReplayPosition);I.useEffect(()=>{t("connecting"),fetch("/api/state").then(f=>f.json()).then(f=>{e(f),t("connected")}).catch(f=>{console.error("Failed to load replay events:",f),t("disconnected")})},[e,t]);const h=I.useRef(null);I.useEffect(()=>{if(!n||l>=a){h.current&&clearTimeout(h.current),n&&l>=a&&se.getState().setReplayPlaying(!1);return}const f=s[l-1],m=s[l];let p=100;if(f&&m){const g=(m.timestamp-f.timestamp)*1e3;p=Math.max(16,Math.min(g/o,2e3))}return h.current=setTimeout(()=>{c(l+1)},p),()=>{h.current&&clearTimeout(h.current)}},[n,l,a,o,s,c])}function iH(){return nH(),null}function lH(){return rH(),null}function aH(){const[e,t]=I.useState(null),n=se(o=>o.replayMode),l=se(o=>o.selectNode),a=se(o=>o.workflowName);return I.useEffect(()=>{fetch("/api/replay/info").then(o=>{o.ok?t(!0):t(!1)}).catch(()=>t(!1))},[]),I.useEffect(()=>{document.title=a?`Conductor — ${a}`:"Conductor Dashboard"},[a]),I.useEffect(()=>{const o=s=>{s.key==="Escape"&&l(null)};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[l]),e===null?null:y.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg)]",children:[e?y.jsx(lH,{}):y.jsx(iH,{}),y.jsx(BN,{}),y.jsx(IN,{}),y.jsx(W9,{}),n?y.jsx(PN,{}):y.jsx($N,{}),!n&&y.jsx(eH,{})]})}iN.createRoot(document.getElementById("root")).render(y.jsx(I.StrictMode,{children:y.jsx(aH,{})})); +`))}function h(b,w,E,S){const _=E.enter("tableCell"),N=E.enter("phrasing"),k=E.containerPhrasing(b,{...S,before:o,after:o});return N(),_(),k}function f(b,w){return a8(b,{align:w,alignDelimiters:l,padding:n,stringLength:a})}function m(b,w,E){const S=b.children;let _=-1;const N=[],k=w.enter("table");for(;++_0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const c9={tokenize:y9,partial:!0};function f9(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:m9,continuation:{tokenize:g9},exit:x9}},text:{91:{name:"gfmFootnoteCall",tokenize:p9},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:d9,resolveTo:h9}}}}function d9(e,t,n){const l=this;let a=l.events.length;const o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let s;for(;a--;){const h=l.events[a][1];if(h.type==="labelImage"){s=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return c;function c(h){if(!s||!s._balanced)return n(h);const f=Yn(l.sliceSerialize({start:s.end,end:l.now()}));return f.codePointAt(0)!==94||!o.includes(f.slice(1))?n(h):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),t(h))}}function h9(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},c=[e[n+1],e[n+2],["enter",l,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",s,t],["exit",s,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",l,t]];return e.splice(n,e.length-n+1,...c),e}function p9(e,t,n){const l=this,a=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let o=0,s;return c;function c(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),h}function h(p){return p!==94?n(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(p){if(o>999||p===93&&!s||p===null||p===91||ut(p))return n(p);if(p===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return a.includes(Yn(l.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return ut(p)||(s=!0),o++,e.consume(p),p===92?m:f}function m(p){return p===91||p===92||p===93?(e.consume(p),o++,f):f(p)}}function m9(e,t,n){const l=this,a=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let o,s=0,c;return h;function h(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",m):n(w)}function m(w){if(s>999||w===93&&!c||w===null||w===91||ut(w))return n(w);if(w===93){e.exit("chunkString");const E=e.exit("gfmFootnoteDefinitionLabelString");return o=Yn(l.sliceSerialize(E)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return ut(w)||(c=!0),s++,e.consume(w),w===92?p:m}function p(w){return w===91||w===92||w===93?(e.consume(w),s++,m):m(w)}function g(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(o)||a.push(o),Qe(e,b,"gfmFootnoteDefinitionWhitespace")):n(w)}function b(w){return t(w)}}function g9(e,t,n){return e.check(ss,t,e.attempt(c9,t,n))}function x9(e){e.exit("gfmFootnoteDefinition")}function y9(e,t,n){const l=this;return Qe(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const s=l.events[l.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?t(o):n(o)}}function v9(e){let n=(e||{}).singleTilde;const l={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function a(s,c){let h=-1;for(;++h1?h(w):(s.consume(w),p++,b);if(p<2&&!n)return h(w);const S=s.exit("strikethroughSequenceTemporary"),_=wa(w);return S._open=!_||_===2&&!!E,S._close=!E||E===2&&!!_,c(w)}}}class b9{constructor(){this.map=[]}add(t,n,l){w9(this,t,n,l)}consume(t){if(this.map.sort(function(o,s){return o[0]-s[0]}),this.map.length===0)return;let n=this.map.length;const l=[];for(;n>0;)n-=1,l.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];l.push(t.slice()),t.length=0;let a=l.pop();for(;a;){for(const o of a)t.push(o);a=l.pop()}this.map.length=0}}function w9(e,t,n,l){let a=0;if(!(n===0&&l.length===0)){for(;a-1;){const q=l.events[B][1].type;if(q==="lineEnding"||q==="linePrefix")B--;else break}const U=B>-1?l.events[B][1].type:null,ee=U==="tableHead"||U==="tableRow"?A:h;return ee===A&&l.parser.lazy[l.now().line]?n(H):ee(H)}function h(H){return e.enter("tableHead"),e.enter("tableRow"),f(H)}function f(H){return H===124||(s=!0,o+=1),m(H)}function m(H){return H===null?n(H):Ee(H)?o>1?(o=0,l.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(H),e.exit("lineEnding"),b):n(H):Ve(H)?Qe(e,m,"whitespace")(H):(o+=1,s&&(s=!1,a+=1),H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),s=!0,m):(e.enter("data"),p(H)))}function p(H){return H===null||H===124||ut(H)?(e.exit("data"),m(H)):(e.consume(H),H===92?g:p)}function g(H){return H===92||H===124?(e.consume(H),p):p(H)}function b(H){return l.interrupt=!1,l.parser.lazy[l.now().line]?n(H):(e.enter("tableDelimiterRow"),s=!1,Ve(H)?Qe(e,w,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):w(H))}function w(H){return H===45||H===58?S(H):H===124?(s=!0,e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),E):M(H)}function E(H){return Ve(H)?Qe(e,S,"whitespace")(H):S(H)}function S(H){return H===58?(o+=1,s=!0,e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),_):H===45?(o+=1,_(H)):H===null||Ee(H)?T(H):M(H)}function _(H){return H===45?(e.enter("tableDelimiterFiller"),N(H)):M(H)}function N(H){return H===45?(e.consume(H),N):H===58?(s=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),k):(e.exit("tableDelimiterFiller"),k(H))}function k(H){return Ve(H)?Qe(e,T,"whitespace")(H):T(H)}function T(H){return H===124?w(H):H===null||Ee(H)?!s||a!==o?M(H):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(H)):M(H)}function M(H){return n(H)}function A(H){return e.enter("tableRow"),L(H)}function L(H){return H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),L):H===null||Ee(H)?(e.exit("tableRow"),t(H)):Ve(H)?Qe(e,L,"whitespace")(H):(e.enter("data"),R(H))}function R(H){return H===null||H===124||ut(H)?(e.exit("data"),L(H)):(e.consume(H),H===92?V:R)}function V(H){return H===92||H===124?(e.consume(H),R):R(H)}}function E9(e,t){let n=-1,l=!0,a=0,o=[0,0,0,0],s=[0,0,0,0],c=!1,h=0,f,m,p;const g=new b9;for(;++nn[2]+1){const w=n[2]+1,E=n[3]-n[2]-1;e.add(w,E,[])}}e.add(n[3]+1,0,[["exit",p,t]])}return a!==void 0&&(o.end=Object.assign({},ra(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function cw(e,t,n,l,a){const o=[],s=ra(t.events,n);a&&(a.end=Object.assign({},s),o.push(["exit",a,t])),l.end=Object.assign({},s),o.push(["exit",l,t]),e.add(n+1,0,o)}function ra(e,t){const n=e[t],l=n[0]==="enter"?"start":"end";return n[1][l]}const N9={name:"tasklistCheck",tokenize:j9};function C9(){return{text:{91:N9}}}function j9(e,t,n){const l=this;return a;function a(h){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?n(h):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),o)}function o(h){return ut(h)?(e.enter("taskListCheckValueUnchecked"),e.consume(h),e.exit("taskListCheckValueUnchecked"),s):h===88||h===120?(e.enter("taskListCheckValueChecked"),e.consume(h),e.exit("taskListCheckValueChecked"),s):n(h)}function s(h){return h===93?(e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):n(h)}function c(h){return Ee(h)?t(h):Ve(h)?e.check({tokenize:T9},t,n)(h):n(h)}}function T9(e,t,n){return Qe(e,l,"whitespace");function l(a){return a===null?n(a):t(a)}}function A9(e){return ZS([t9(),f9(),v9(e),S9(),C9()])}const z9={};function Yc(e){const t=this,n=e||z9,l=t.data(),a=l.micromarkExtensions||(l.micromarkExtensions=[]),o=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),s=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);a.push(A9(n)),o.push(K8()),s.push(J8(n))}const M9=new Set([".md",".markdown",".mdx"]);function D9({filePath:e,onClose:t}){const[n,l]=I.useState(null),[a,o]=I.useState(null),[s,c]=I.useState(!0),h=I.useCallback(async()=>{c(!0),o(null);try{const m=e.split("/").map(b=>encodeURIComponent(b)).join("/"),p=await fetch(`/api/files/${m}`);if(!p.ok){const b=await p.json().catch(()=>({}));o(b.error||`HTTP ${p.status}`);return}const g=await p.json();l(g)}catch(m){o(m instanceof Error?m.message:"Failed to load file")}finally{c(!1)}},[e]);I.useEffect(()=>{h()},[h]),I.useEffect(()=>{const m=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const f=n?M9.has(n.extension):!1;return y.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:y.jsxs("div",{className:"relative flex flex-col w-[90vw] max-w-3xl max-h-[80vh] rounded-xl border border-[var(--border)] bg-[var(--surface)] shadow-2xl overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-[var(--border)] bg-[var(--surface-raised)] flex-shrink-0",children:[y.jsx(bw,{className:"w-4 h-4 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate flex-1",title:e,children:e}),n&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] flex-shrink-0 tabular-nums",children:O9(n.size)}),y.jsx("button",{onClick:t,className:"p-1 rounded-md text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--surface-hover)] transition-colors flex-shrink-0",title:"Close (Esc)",children:y.jsx(sl,{className:"w-4 h-4"})})]}),y.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4 min-h-0",children:[s&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(ha,{className:"w-5 h-5 text-[var(--text-muted)] animate-spin"})}),a&&y.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/30",children:[y.jsx(lc,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs text-red-300",children:a})]}),n&&!a&&(f?y.jsx("div",{className:"file-viewer-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx(R9,{content:n.content})}):y.jsx("pre",{className:"font-mono text-[11px] leading-[1.6] text-[var(--text)] whitespace-pre-wrap break-words",children:n.content}))]})]})})}function R9({content:e}){return y.jsx(Fc,{remarkPlugins:[Yc],components:{h1:({children:t})=>y.jsx("h1",{className:"text-base font-bold mb-3 mt-2 text-[var(--text)]",children:t}),h2:({children:t})=>y.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 text-[var(--text)]",children:t}),h3:({children:t})=>y.jsx("h3",{className:"text-xs font-bold mb-1.5 mt-2 text-[var(--text)]",children:t}),p:({children:t})=>y.jsx("p",{className:"mb-2 last:mb-0",children:t}),ul:({children:t})=>y.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1 ml-2",children:t}),ol:({children:t})=>y.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1 ml-2",children:t}),li:({children:t})=>y.jsx("li",{children:t}),code:({children:t,className:n})=>(n==null?void 0:n.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-3 py-2 font-mono text-[11px] my-2 overflow-x-auto whitespace-pre",children:t}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:t}),pre:({children:t})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-3 py-2.5 font-mono text-[11px] my-2 overflow-x-auto",children:t}),strong:({children:t})=>y.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>y.jsx("em",{className:"italic",children:t}),a:({href:t,children:n})=>y.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:n}),blockquote:({children:t})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-3 my-2 opacity-80",children:t}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-3"}),table:({children:t})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:t})}),th:({children:t})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:t}),td:({children:t})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:t})},children:e})}function O9(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function L9({node:e}){const t=se(M=>M.sendGateResponse),n=se(M=>M.wsStatus),[l,a]=I.useState(null),[o,s]=I.useState(""),[c,h]=I.useState(null),[f,m]=I.useState(!1),[p,g]=I.useState(null),b=e.status==="waiting",w=e.status==="completed";I.useEffect(()=>{b&&(a(null),s(""),h(null),m(!1))},[b]);const E=b&&n==="connected"&&l===null,S=(M,A)=>{if(E){if(A){a(M),h(A);return}a(M),m(!0),t(e.name,M)}},_=()=>{if(l===null||c===null)return;const M={[c]:o};m(!0),t(e.name,l,M),h(null)},N=e.option_details,k=N==null?void 0:N.find(M=>M.value===e.selected_option),T=(k==null?void 0:k.label)||e.selected_option;return y.jsxs("div",{className:"space-y-3",children:[b&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/30",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-amber-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-amber-400 tracking-wide",children:"Decision Required"})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-amber-500/50 pl-3 py-0.5",children:y.jsx($p,{text:e.prompt,muted:!1,onFileClick:g})}),N&&N.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("div",{className:"flex flex-col gap-1.5",children:N.map(M=>{const A=l===M.value,L=l!==null&&!A;return y.jsx("button",{disabled:!E&&!A,onClick:()=>S(M.value,M.prompt_for),className:`w-full text-left px-3 py-2.5 rounded-lg border transition-all duration-150 ${A?"border-green-500/60 bg-green-500/10":L?"border-[var(--border)] opacity-40 cursor-default":"border-[var(--border)] bg-[var(--surface)] hover:border-amber-400/60 hover:bg-amber-500/5 cursor-pointer group"}`,children:y.jsxs("div",{className:"flex items-center gap-2.5",children:[y.jsx("div",{className:"flex-shrink-0",children:A?y.jsx("div",{className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center",children:y.jsx(Ki,{className:"w-2.5 h-2.5 text-white",strokeWidth:3})}):y.jsx("div",{className:`w-4 h-4 rounded-full border-2 transition-colors ${L?"border-[var(--border)]":"border-[var(--border)] group-hover:border-amber-400"}`})}),y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("span",{className:`text-xs font-medium ${A?"text-green-400":"text-[var(--text)]"}`,children:M.label})}),M.route&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] flex-shrink-0",children:["→ ",M.route]})]})},M.value)})}),f&&!c&&y.jsxs("div",{className:"flex items-center gap-2 px-1",children:[y.jsx(ha,{className:"w-3 h-3 text-green-400 animate-spin"}),y.jsx("span",{className:"text-[10px] text-green-400",children:"Sending..."})]}),E&&y.jsx("p",{className:"text-[10px] text-[var(--text-muted)] px-1",children:"Select an option to continue the workflow"})]}),!N&&e.options&&e.options.length>0&&y.jsxs("div",{className:"space-y-1.5",children:[y.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"Options"}),y.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(M=>y.jsx("span",{className:"text-[11px] px-2 py-0.5 rounded border border-[var(--border)] text-[var(--text-muted)]",children:M},M))})]}),c&&y.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg)] overflow-hidden",children:[y.jsx("div",{className:"px-3 py-2 border-b border-[var(--border)] bg-[var(--surface)]",children:y.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:c})}),y.jsxs("div",{className:"p-3 space-y-2",children:[y.jsx("input",{type:"text",value:o,onChange:M=>s(M.target.value),onKeyDown:M=>M.key==="Enter"&&_(),placeholder:`Enter ${c}...`,className:"w-full text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-amber-400 transition-colors",autoFocus:!0}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("span",{className:"text-[10px] text-[var(--text-muted)]",children:"Press Enter or click Submit"}),y.jsxs("button",{onClick:_,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg bg-amber-500 text-white hover:bg-amber-600 transition-colors font-medium",children:[y.jsx(_w,{className:"w-3 h-3"}),"Submit"]})]})]})]})]}),w&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-green-500/10 border border-green-500/30",children:[y.jsx(Ki,{className:"w-3.5 h-3.5 text-green-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs font-semibold text-green-400 tracking-wide",children:"Decision Completed"})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-[var(--border)] pl-3 py-0.5",children:y.jsx($p,{text:e.prompt,muted:!0,onFileClick:g})}),T&&y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-green-500/30 bg-green-500/5",children:[y.jsx("div",{className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center flex-shrink-0",children:y.jsx(Ki,{className:"w-2.5 h-2.5 text-white",strokeWidth:3})}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)]",children:T}),e.route&&y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:["→ ",e.route]})]}),N&&N.length>1&&y.jsx("div",{className:"space-y-1",children:N.filter(M=>M.value!==e.selected_option).map(M=>y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg opacity-35",children:[y.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-[var(--border)] flex-shrink-0"}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:M.label}),M.route&&y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:["→ ",M.route]})]},M.value))}),!N&&e.options&&e.options.length>0&&y.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(M=>y.jsxs("span",{className:`text-[11px] px-2.5 py-1 rounded-lg border ${M===e.selected_option?"border-green-500/30 text-green-400 bg-green-500/5":"border-[var(--border)] text-[var(--text-muted)] opacity-40"}`,children:[M===e.selected_option&&"✓ ",M]},M))}),y.jsx(B9,{node:e})]}),!b&&!w&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Human Gate"}),y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] capitalize",children:["(",e.status,")"]})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-[var(--border)] pl-3 py-0.5",children:y.jsx($p,{text:e.prompt,muted:!0,onFileClick:g})})]}),p&&y.jsx(D9,{filePath:p,onClose:()=>g(null)})]})}function H9(e){return!(!e||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("//")||e.startsWith("#")||e.startsWith("/")||e.startsWith("\\"))}function $p({text:e,muted:t,onFileClick:n}){const l=t?"text-[var(--text-muted)]":"text-[var(--text)]";return y.jsx("div",{className:`gate-markdown text-xs leading-relaxed ${l}`,children:y.jsx(Fc,{remarkPlugins:[Yc],components:{h1:({children:a})=>y.jsx("h1",{className:"text-sm font-bold mb-2 mt-1",children:a}),h2:({children:a})=>y.jsx("h2",{className:"text-xs font-bold mb-1.5 mt-1",children:a}),h3:({children:a})=>y.jsx("h3",{className:"text-xs font-semibold mb-1 mt-1",children:a}),p:({children:a})=>y.jsx("p",{className:"mb-1.5 last:mb-0",children:a}),ul:({children:a})=>y.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:a}),ol:({children:a})=>y.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:a}),li:({children:a})=>y.jsx("li",{children:a}),code:({children:a,className:o})=>(o==null?void 0:o.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1.5 font-mono text-[11px] my-1 overflow-x-auto whitespace-pre",children:a}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:a}),pre:({children:a})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-2.5 py-2 font-mono text-[11px] my-1.5 overflow-x-auto",children:a}),strong:({children:a})=>y.jsx("strong",{className:"font-semibold",children:a}),em:({children:a})=>y.jsx("em",{className:"italic",children:a}),a:({href:a,children:o})=>n&&H9(a)?y.jsxs("button",{onClick:s=>{s.preventDefault(),n(a)},className:"inline-flex items-center gap-0.5 text-blue-400 hover:text-blue-300 underline underline-offset-2 cursor-pointer",title:`Open ${a}`,children:[y.jsx(bw,{className:"w-3 h-3 inline flex-shrink-0"}),o]}):y.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:o}),blockquote:({children:a})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-2.5 my-1.5 opacity-80",children:a}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-2"}),table:({children:a})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:a})}),th:({children:a})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:a}),td:({children:a})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:a})},children:e})})}function B9({node:e}){const t=[];if(e.route&&t.push({label:"Route",value:`→ ${e.route}`}),e.additional_input){const n=typeof e.additional_input=="object"?JSON.stringify(e.additional_input):e.additional_input;t.push({label:"Additional Input",value:n})}return t.length===0?null:y.jsx(Br,{items:t})}function I9({node:e}){const t=e.status,n=ze[t]||ze.pending,a=T5()[e.name],o=e.type==="for_each_group",[s,c]=I.useState(!0),h=[];e.elapsed!=null&&h.push({label:"Elapsed",value:ot(e.elapsed)}),a&&(h.push({label:"Total",value:a.total}),h.push({label:"Completed",value:a.completed}),a.failed>0&&h.push({label:"Failed",value:a.failed})),e.success_count!=null&&h.push({label:"Success",value:e.success_count}),e.failure_count!=null&&h.push({label:"Failures",value:e.failure_count});const f=e.for_each_items;return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${n}20`,color:n},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:o?"For-Each Group":"Parallel Group"})]}),a&&a.total>0&&y.jsxs("div",{className:"space-y-1",children:[y.jsxs("div",{className:"flex justify-between text-[10px] text-[var(--text-muted)]",children:[y.jsx("span",{children:"Progress"}),y.jsxs("span",{children:[a.completed+a.failed,"/",a.total]})]}),y.jsx("div",{className:"h-1.5 bg-[var(--bg)] rounded-full overflow-hidden",children:y.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${(a.completed+a.failed)/a.total*100}%`,background:a.failed>0?`linear-gradient(90deg, var(--completed) ${a.completed/(a.completed+a.failed)*100}%, var(--failed) 0%)`:"var(--completed)"}})})]}),y.jsx(Br,{items:h}),o&&f&&f.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("button",{onClick:()=>c(!s),className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold hover:text-[var(--text)] transition-colors",children:[s?y.jsx(ol,{className:"w-3 h-3"}):y.jsx(Lr,{className:"w-3 h-3"}),"Items (",f.length,")"]}),s&&y.jsx("div",{className:"space-y-1",children:f.map(m=>y.jsx($9,{groupName:e.name,item:m},`${m.key}-${m.index}`))})]})]})}const q9={running:ze.running,completed:ze.completed,failed:ze.failed};function $9({groupName:e,item:t}){const[n,l]=I.useState(t.status==="running"),a=q9[t.status],o=$m(),s=se(g=>g.navigateIntoSubworkflow),c=`${e}[${t.key}]`,h=o.find(g=>g.slotKey===c),f=!!h,m=!!(t.prompt||t.output!=null||t.activity&&t.activity.length>0||t.error_type),p=[];return t.elapsed!=null&&p.push({label:"Elapsed",value:ot(t.elapsed)}),t.tokens!=null&&p.push({label:"Tokens",value:Gn(t.tokens)}),t.cost_usd!=null&&p.push({label:"Cost",value:wi(t.cost_usd)}),y.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--surface)] overflow-hidden",children:[y.jsxs("button",{onClick:()=>m&&l(!n),className:"flex items-center gap-2 w-full px-3 py-2 text-left hover:bg-[var(--node-bg)] transition-colors",disabled:!m,children:[m?n?y.jsx(ol,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}):y.jsx(Lr,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}):t.status==="running"?y.jsx(ha,{className:"w-3 h-3 animate-spin flex-shrink-0",style:{color:a}}):y.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ml-0.5 mr-0.5",style:{backgroundColor:a}}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate flex-1 min-w-0",children:t.key}),!n&&(t.elapsed!=null||t.tokens!=null||t.cost_usd!=null)&&y.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-[var(--text-muted)] flex-shrink-0",children:[t.elapsed!=null&&y.jsx("span",{children:ot(t.elapsed)}),t.tokens!=null&&y.jsx("span",{children:Gn(t.tokens)}),t.cost_usd!=null&&y.jsx("span",{children:wi(t.cost_usd)})]}),y.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider flex-shrink-0 px-1.5 py-0.5 rounded",style:{backgroundColor:`${a}20`,color:a},children:t.status}),f&&y.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),s(c)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.stopPropagation(),g.preventDefault(),s(c))},title:`Dive into ${(h==null?void 0:h.workflowName)??c}`,className:"flex-shrink-0 p-1 rounded hover:bg-[var(--accent)]/20 hover:text-[var(--accent)] transition-colors text-[var(--text-muted)] cursor-pointer",children:y.jsx(kc,{className:"w-3 h-3"})})]}),n&&m&&y.jsxs("div",{className:"px-3 py-3 space-y-3 border-t border-[var(--border)]",children:[p.length>0&&y.jsx(Br,{items:p}),t.prompt&&y.jsx(_i,{output:t.prompt,title:"Input / Prompt",defaultExpanded:!1}),t.activity&&t.activity.length>0&&y.jsx(Vm,{activity:t.activity,defaultExpanded:t.status!=="completed"}),t.output!=null&&y.jsx(_i,{output:t.output,title:"Output",defaultExpanded:!0}),t.status==="failed"&&(t.error_type||t.error_message)&&y.jsxs("div",{className:"text-xs text-red-400",children:[t.error_type&&y.jsx("span",{className:"font-semibold",children:t.error_type}),t.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",t.error_message]})]})]})]})}function U9({node:e}){const t=se(f=>f.engageDialog),n=se(f=>f.sendDialogDecline),l=se(f=>f.wsStatus),a=e.dialog_id||"",o=e.dialog_messages||[],s=l==="connected",c=o.find(f=>f.role==="agent"),h=()=>{s&&n(e.name,a)};return y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-fuchsia-500/10 border border-fuchsia-500/30",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-fuchsia-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-fuchsia-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-fuchsia-400 tracking-wide",children:"Dialog Requested"})]}),c&&y.jsxs("div",{className:"rounded-lg px-3 py-2 bg-amber-500/10 border border-amber-500/30",children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:e.name}),y.jsx("div",{className:"dialog-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx(Fc,{remarkPlugins:[Yc],children:c.content})})]}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"How would you like to proceed?"}),y.jsxs("div",{className:"flex gap-2",children:[y.jsxs("button",{onClick:t,disabled:!s,className:"flex-1 flex items-center justify-center gap-1.5 text-xs px-3 py-2 rounded-lg border border-fuchsia-500/40 bg-fuchsia-500/10 text-fuchsia-300 hover:bg-fuchsia-500/20 transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(ym,{className:"w-3 h-3"}),"💬 Discuss"]}),y.jsxs("button",{onClick:h,disabled:!s,className:"flex-1 flex items-center justify-center gap-1.5 text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--surface)] text-[var(--text-muted)] hover:bg-[var(--surface-hover)] transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(sl,{className:"w-3 h-3"}),"✕ Skip & continue"]})]})]})]})}function V9({node:e}){const t=e.status,n=ze[t]||ze.pending,l=se(c=>c.navigateIntoSubworkflow),o=$m().filter(c=>c.parentAgent===e.name),s=[];return e.elapsed!=null&&s.push({label:"Elapsed",value:ot(e.elapsed)}),e.cost_usd!=null&&s.push({label:"Cost",value:wi(e.cost_usd)}),e.tokens!=null&&s.push({label:"Tokens",value:Gn(e.tokens)}),e.iteration!=null&&e.iteration>1&&s.push({label:"Iteration",value:e.iteration}),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${n}20`,color:n},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Subworkflow Agent"})]}),y.jsx(Br,{items:s}),o.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:["Subworkflow Runs (",o.length,")"]}),y.jsx("div",{className:"space-y-1",children:o.map((c,h)=>y.jsx(P9,{ctx:c,onClick:()=>l(c.slotKey)},`${c.slotKey}-${c.iteration}-${h}`))})]}),t==="failed"&&(e.error_type||e.error_message)&&y.jsxs("div",{className:"text-xs text-red-400",children:[e.error_type&&y.jsx("span",{className:"font-semibold",children:e.error_type}),e.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",e.error_message]})]}),o.length===0&&t==="pending"&&y.jsx("div",{className:"text-xs text-[var(--text-muted)] italic",children:"Subworkflow has not started yet."})]})}function P9({ctx:e,onClick:t}){const n=ze[e.status]||ze.pending;return y.jsxs("button",{onClick:t,className:"flex items-center gap-2 w-full px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--surface)] hover:bg-[var(--node-bg)] transition-colors text-left",children:[y.jsx(kc,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:n}}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:e.workflowName||e.workflowFile||"Subworkflow"}),y.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-[var(--text-muted)]",children:[e.agentsTotal>0&&y.jsxs("span",{className:"flex items-center gap-0.5",children:[y.jsx(ww,{className:"w-2.5 h-2.5"}),e.agentsCompleted,"/",e.agentsTotal," agents"]}),e.totalCost>0&&y.jsxs("span",{className:"flex items-center gap-0.5",children:[y.jsx(yw,{className:"w-2.5 h-2.5"}),wi(e.totalCost)]})]})]}),y.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider flex-shrink-0 px-1.5 py-0.5 rounded",style:{backgroundColor:`${n}20`,color:n},children:e.status}),y.jsx(Lr,{className:"w-3.5 h-3.5 flex-shrink-0 text-[var(--text-muted)]"})]})}function G9({node:e}){const t=e.status,n=ze[t]||ze.pending,l=[],a=e.requested_seconds??e.duration_seconds;return a!=null&&l.push({label:"Requested",value:ot(a)}),e.waited_seconds!=null?l.push({label:"Waited",value:ot(e.waited_seconds)}):e.elapsed!=null&&l.push({label:"Elapsed",value:ot(e.elapsed)}),e.interrupted&&l.push({label:"Interrupted",value:"yes"}),e.reason&&l.push({label:"Reason",value:e.reason}),e.error_type&&l.push({label:"Error",value:e.error_type}),e.error_message&&l.push({label:"Message",value:e.error_message}),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${n}20`,color:n},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Wait"})]}),y.jsx(Br,{items:l})]})}function F9(){const e=se(h=>h.selectedNode),t=Rn(),n=se(h=>h.selectNode),l=se(h=>h.dialogEngaged),[a,o]=I.useState(!1);I.useEffect(()=>(requestAnimationFrame(()=>o(!0)),()=>o(!1)),[e]);const s=e?t[e]:null;if(!e||!s)return y.jsxs("div",{className:"h-full flex flex-col bg-[var(--surface)]",children:[y.jsx("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)]",children:y.jsx("h2",{className:"text-sm font-semibold text-[var(--text)]",children:"Detail"})}),y.jsx("div",{className:"flex-1 flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Click a node to view details"})})]});const c=(()=>{if(s.dialog_active&&!l)return U9;if(s.dialog_active&&l)return b1;switch(s.type){case"script":return sD;case"wait":return G9;case"set":return uD;case"human_gate":return L9;case"parallel_group":case"for_each_group":return I9;case"workflow":return V9;default:return b1}})();return y.jsxs("div",{className:je("h-full flex flex-col bg-[var(--surface)] transition-all duration-150 ease-out",a?"translate-x-0 opacity-100":"translate-x-4 opacity-0"),children:[y.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)] flex-shrink-0",children:[y.jsx("h2",{className:"text-sm font-semibold text-[var(--text)] truncate",children:e}),y.jsx("button",{onClick:()=>n(null),className:"p-1 rounded hover:bg-[var(--surface-hover)] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",title:"Close panel",children:y.jsx(sl,{className:"w-4 h-4"})})]}),y.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:y.jsx(c,{node:s})})]})}function ic(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Y9(){const e=se(S=>S.eventLog),t=se(S=>S.activityLog),n=se(S=>S.workflowOutput),l=se(S=>S.workflowStatus),[a,o]=I.useState("log"),[s,c]=I.useState(!1),[h,f]=I.useState(0),[m,p]=I.useState(0),g=I.useCallback(S=>{o(S),S==="log"&&f(e.length),S==="activity"&&p(t.length)},[e.length,t.length]);I.useEffect(()=>{a==="log"&&f(e.length)},[a,e.length]),I.useEffect(()=>{a==="activity"&&p(t.length)},[a,t.length]),I.useEffect(()=>{l==="completed"&&n!=null&&o("output")},[l,n]);const b=n!=null,w=a!=="log"?Math.max(0,e.length-h):0,E=a!=="activity"?Math.max(0,t.length-m):0;return s?y.jsx("div",{className:"flex items-center bg-[var(--surface)] border-t border-[var(--border)] px-3 py-1",children:y.jsxs("button",{onClick:()=>c(!1),className:"flex items-center gap-1.5 text-xs text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",children:[y.jsx(fN,{className:"w-3 h-3"}),y.jsx(ev,{className:"w-3 h-3"}),y.jsx("span",{children:"Output"}),t.length>0&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)]",children:["(",t.length,")"]})]})}):y.jsxs("div",{className:"flex flex-col h-full bg-[var(--surface)] border-t border-[var(--border)]",children:[y.jsxs("div",{className:"flex items-center justify-between px-2 flex-shrink-0 border-b border-[var(--border)]",children:[y.jsxs("div",{className:"flex items-center gap-0.5",children:[y.jsx(Up,{active:a==="log",onClick:()=>g("log"),icon:y.jsx(ev,{className:"w-3 h-3"}),label:"Log",count:e.length,unread:w}),y.jsx(Up,{active:a==="activity",onClick:()=>g("activity"),icon:y.jsx(gw,{className:"w-3 h-3"}),label:"Activity",count:t.length,unread:E}),y.jsx(Up,{active:a==="output",onClick:()=>g("output"),icon:y.jsx(xN,{className:"w-3 h-3"}),label:"Output",badge:b?l==="failed"?"error":"success":void 0})]}),y.jsx("button",{onClick:()=>c(!0),className:"p-1 rounded text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--surface-hover)] transition-colors",title:"Collapse panel",children:y.jsx(ol,{className:"w-3.5 h-3.5"})})]}),y.jsx("div",{className:"flex-1 overflow-hidden",children:a==="activity"?y.jsx(X9,{entries:t}):a==="log"?y.jsx(Q9,{entries:e}):y.jsx(Z9,{output:n,status:l})})]})}function Up({active:e,onClick:t,icon:n,label:l,count:a,badge:o,unread:s}){return y.jsxs("button",{onClick:t,className:je("relative flex items-center gap-1.5 px-3 py-1.5 text-xs transition-colors border-b-2 -mb-px",e?"text-[var(--text)] border-[var(--accent)]":"text-[var(--text-muted)] border-transparent hover:text-[var(--text-secondary)]"),children:[n,y.jsx("span",{children:l}),a!=null&&a>0&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] tabular-nums",children:a}),o&&y.jsx("span",{className:je("w-1.5 h-1.5 rounded-full",o==="success"?"bg-[var(--completed)]":"bg-[var(--failed)]")}),!e&&s!=null&&s>0&&y.jsx("span",{className:"absolute -top-0.5 -right-0.5 flex h-3.5 min-w-[14px] items-center justify-center rounded-full bg-[var(--accent)] px-1",children:y.jsx("span",{className:"text-[8px] font-bold text-white leading-none tabular-nums",children:s>99?"99+":s})})]})}const fw={reasoning:{color:"text-indigo-400/70",label:"THINK",labelColor:"text-indigo-500"},"tool-start":{color:"text-blue-400",label:"TOOL →",labelColor:"text-blue-500"},"tool-complete":{color:"text-green-400",label:"TOOL ←",labelColor:"text-green-600"},turn:{color:"text-amber-400",label:"STEP",labelColor:"text-amber-500"},message:{color:"text-[var(--text)]",label:"MSG",labelColor:"text-[var(--text-muted)]"},prompt:{color:"text-cyan-400/70",label:"PROMPT",labelColor:"text-cyan-600"}};function X9({entries:e}){const t=I.useRef(null),n=I.useRef(!0),l=se(h=>h.selectNode),[a,o]=I.useState(""),s=I.useCallback(()=>{const h=t.current;if(!h)return;const f=h.scrollHeight-h.scrollTop-h.clientHeight<30;n.current=f},[]),c=I.useMemo(()=>{if(!a)return e;const h=a.toLowerCase();return e.filter(f=>f.source.toLowerCase().includes(h)||ic(f.message).toLowerCase().includes(h))},[e,a]);return I.useEffect(()=>{t.current&&n.current&&(t.current.scrollTop=t.current.scrollHeight)},[c.length]),e.length===0?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Waiting for agent activity…"})}):y.jsxs("div",{className:"h-full flex flex-col",children:[y.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-[var(--border-subtle)] flex-shrink-0",children:[y.jsx(SN,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("input",{type:"text",value:a,onChange:h=>o(h.target.value),placeholder:"Filter by agent or message…",className:"flex-1 bg-transparent text-[11px] text-[var(--text)] placeholder:text-[var(--text-muted)] outline-none min-w-0"}),a&&y.jsxs(y.Fragment,{children:[y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] tabular-nums flex-shrink-0",children:[c.length," of ",e.length]}),y.jsx("button",{onClick:()=>o(""),className:"text-[var(--text-muted)] hover:text-[var(--text)] transition-colors flex-shrink-0",title:"Clear filter",children:y.jsx(sl,{className:"w-3 h-3"})})]})]}),y.jsxs("div",{ref:t,onScroll:s,className:"flex-1 overflow-y-auto font-mono text-[11px] leading-[1.6] px-3 py-2",children:[c.map((h,f)=>{const m=fw[h.type]||fw.message,p=qk(h.timestamp);return y.jsxs("div",{className:"group",children:[y.jsxs("div",{className:"flex gap-1.5 hover:bg-[var(--surface-hover)] rounded px-1 -mx-1",children:[y.jsx("span",{className:"text-[var(--text-muted)] flex-shrink-0 select-none tabular-nums",children:p}),y.jsx("span",{className:je("flex-shrink-0 w-[5ch] text-[10px] font-semibold tabular-nums select-none",m.labelColor),children:m.label}),y.jsx("button",{onClick:()=>l(h.source),className:"text-[var(--text-secondary)] flex-shrink-0 min-w-[8ch] max-w-[16ch] truncate hover:text-[var(--accent)] hover:underline transition-colors text-left",title:`Select ${h.source}`,children:h.source}),y.jsx("span",{className:je("break-words min-w-0",m.color,h.type==="reasoning"&&"italic"),children:ic(h.message)})]}),h.detail&&y.jsx("div",{className:"ml-[calc(7ch+5ch+8ch+1rem)] px-2 py-1 my-0.5 bg-[var(--bg)] rounded text-[10px] text-[var(--text-muted)] whitespace-pre-wrap break-words max-h-24 overflow-y-auto border-l-2 border-[var(--border)]",children:ic(h.detail)})]},f)}),a&&c.length===0&&y.jsx("div",{className:"flex items-center justify-center py-4",children:y.jsxs("p",{className:"text-xs text-[var(--text-muted)]",children:['No matches for "',a,'"']})})]})]})}const dw={info:{color:"text-blue-400",icon:"›"},success:{color:"text-green-400",icon:"✓"},error:{color:"text-red-400",icon:"✗"},warning:{color:"text-amber-400",icon:"⚠"},debug:{color:"text-[var(--text-muted)]",icon:"·"}};function Q9({entries:e}){const t=I.useRef(null),n=I.useRef(!0),l=se(o=>o.selectNode),a=I.useCallback(()=>{const o=t.current;if(!o)return;const s=o.scrollHeight-o.scrollTop-o.clientHeight<30;n.current=s},[]);return I.useEffect(()=>{t.current&&n.current&&(t.current.scrollTop=t.current.scrollHeight)},[e.length]),e.length===0?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Waiting for events…"})}):y.jsx("div",{ref:t,onScroll:a,className:"h-full overflow-y-auto font-mono text-[11px] leading-[1.6] px-3 py-2",children:e.map((o,s)=>{const c=dw[o.level]||dw.info,h=qk(o.timestamp);return y.jsxs("div",{className:"flex gap-2 hover:bg-[var(--surface-hover)] rounded px-1 -mx-1",children:[y.jsx("span",{className:"text-[var(--text-muted)] flex-shrink-0 select-none tabular-nums",children:h}),y.jsx("span",{className:je("flex-shrink-0 w-3 text-center select-none",c.color),children:c.icon}),y.jsx("button",{onClick:()=>l(o.source),className:"text-[var(--text-secondary)] flex-shrink-0 min-w-[8ch] max-w-[16ch] truncate hover:text-[var(--accent)] hover:underline transition-colors text-left",title:`Select ${o.source}`,children:o.source}),y.jsx("span",{className:je("break-words",o.level==="error"?"text-red-400":o.level==="success"?"text-green-400":"text-[var(--text)]"),children:ic(o.message)})]},s)})})}function qk(e){const t=new Date(e*1e3),n=t.getHours().toString().padStart(2,"0"),l=t.getMinutes().toString().padStart(2,"0"),a=t.getSeconds().toString().padStart(2,"0");return`${n}:${l}:${a}`}function Z9({output:e,status:t}){const[n,l]=I.useState(!1),a=kw(e),o=async()=>{a&&(await navigator.clipboard.writeText(a),l(!0),setTimeout(()=>l(!1),2e3))};return e==null?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t==="running"?"Workflow running — output will appear when complete…":t==="failed"?"Workflow failed — no output produced":"No output yet"})}):y.jsxs("div",{className:"h-full flex flex-col",children:[y.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-[var(--border-subtle)] flex-shrink-0",children:[y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] uppercase tracking-wider font-semibold",children:"Workflow Result"}),y.jsx("button",{onClick:o,className:"flex items-center gap-1 text-[10px] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors px-1.5 py-0.5 rounded hover:bg-[var(--surface-hover)]",title:"Copy to clipboard",children:n?y.jsxs(y.Fragment,{children:[y.jsx(Ki,{className:"w-3 h-3 text-[var(--completed)]"}),y.jsx("span",{className:"text-[var(--completed)]",children:"Copied"})]}):y.jsxs(y.Fragment,{children:[y.jsx(vw,{className:"w-3 h-3"}),y.jsx("span",{children:"Copy"})]})})]}),y.jsx("div",{className:"flex-1 overflow-auto px-3 py-2",children:y.jsx("pre",{className:"font-mono text-[11px] leading-relaxed text-[var(--text)] whitespace-pre-wrap break-words",children:typeof e=="object"?y.jsx(K9,{text:a}):a})})]})}function K9({text:e}){const t=e.split(/("(?:[^"\\]|\\.)*")/g);return y.jsx(y.Fragment,{children:t.map((n,l)=>{if(l%2===1){const o=t.slice(l+1).join(""),s=/^\s*:/.test(o);return y.jsx("span",{className:s?"text-blue-400":"text-green-400",children:n},l)}const a=n.replace(/\b(true|false|null)\b|(-?\d+\.?\d*(?:e[+-]?\d+)?)/gi,(o,s,c)=>s?`${o}`:c?`${o}`:o);return y.jsx("span",{dangerouslySetInnerHTML:{__html:a}},l)})})}function J9({text:e}){return y.jsx("div",{className:"dialog-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx(Fc,{remarkPlugins:[Yc],components:{h1:({children:t})=>y.jsx("h1",{className:"text-sm font-bold mb-2 mt-1",children:t}),h2:({children:t})=>y.jsx("h2",{className:"text-xs font-bold mb-1.5 mt-1",children:t}),h3:({children:t})=>y.jsx("h3",{className:"text-xs font-semibold mb-1 mt-1",children:t}),p:({children:t})=>y.jsx("p",{className:"mb-1.5 last:mb-0",children:t}),ul:({children:t})=>y.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:t}),ol:({children:t})=>y.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:t}),li:({children:t})=>y.jsx("li",{children:t}),code:({children:t,className:n})=>(n==null?void 0:n.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1.5 font-mono text-[11px] my-1 overflow-x-auto whitespace-pre",children:t}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:t}),pre:({children:t})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-2.5 py-2 font-mono text-[11px] my-1.5 overflow-x-auto",children:t}),strong:({children:t})=>y.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>y.jsx("em",{className:"italic",children:t}),a:({href:t,children:n})=>y.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:n}),blockquote:({children:t})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-2.5 my-1.5 opacity-80",children:t}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-2"}),table:({children:t})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:t})}),th:({children:t})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:t}),td:({children:t})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:t})},children:e})})}function W9({node:e}){const t=se(g=>g.sendDialogMessage),n=se(g=>g.wsStatus),[l,a]=I.useState(""),o=I.useRef(null),s=e.dialog_active===!0,c=e.dialog_id||"",h=e.dialog_messages||[],f=s&&n==="connected";I.useEffect(()=>{var g;(g=o.current)==null||g.scrollIntoView({behavior:"smooth"})},[h.length,e.dialog_awaiting_response]);const m=()=>{!l.trim()||!f||(t(e.name,c,l.trim()),a(""))},p=g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),m())};return y.jsxs("div",{className:"flex flex-col h-full",children:[s?y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-fuchsia-500/10 border border-fuchsia-500/30 mb-3 flex-shrink-0",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-fuchsia-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-fuchsia-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-fuchsia-400 tracking-wide",children:"Dialog Mode"}),y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:[h.length," message",h.length!==1?"s":""]})]}):y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-[var(--surface)] border border-[var(--border)] mb-3 flex-shrink-0",children:[y.jsx(ym,{className:"w-3.5 h-3.5 text-[var(--text-muted)]"}),y.jsx("span",{className:"text-xs font-semibold text-[var(--text-muted)] tracking-wide",children:"Dialog Completed"}),y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:[h.length," message",h.length!==1?"s":""]})]}),y.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3 min-h-0 mb-3",children:[h.map((g,b)=>y.jsx("div",{className:`flex ${g.role==="user"?"justify-end":"justify-start"}`,children:y.jsxs("div",{className:`max-w-[85%] rounded-lg px-3 py-2 ${g.role==="agent"?"bg-amber-500/10 border border-amber-500/30":"bg-blue-500/10 border border-blue-500/30"}`,children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:g.role==="agent"?e.name:"You"}),y.jsx(J9,{text:g.content})]})},b)),e.dialog_awaiting_response&&y.jsx("div",{className:"flex justify-start",children:y.jsxs("div",{className:"max-w-[85%] rounded-lg px-3 py-2 bg-amber-500/10 border border-amber-500/30",children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:e.name}),y.jsxs("div",{className:"flex gap-1 items-center h-4",children:[y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:0ms]"}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:150ms]"}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:300ms]"})]})]})}),y.jsx("div",{ref:o})]}),s&&y.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] pt-3",children:[y.jsxs("div",{className:"flex gap-2",children:[y.jsx("input",{type:"text",value:l,onChange:g=>a(g.target.value),onKeyDown:p,placeholder:"Type your message...",className:"flex-1 text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-fuchsia-400 transition-colors",disabled:!f,autoFocus:!0}),y.jsxs("button",{onClick:m,disabled:!f||!l.trim(),className:"flex items-center justify-center gap-1.5 text-xs px-8 py-2 rounded-lg bg-fuchsia-500 text-white hover:bg-fuchsia-600 transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(_w,{className:"w-3 h-3"}),"Send"]})]}),y.jsx("p",{className:"text-[10px] text-[var(--text-muted)] mt-1.5 px-1",children:'Press Enter to send · Type "done" to end dialog'})]})]})}function eH(){const e=se(l=>l.activeDialog),t=se(l=>l.nodes);if(!e)return null;const n=t[e.agentName];return n?y.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg)] overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3 border-b border-[var(--border)] bg-[var(--surface)] flex-shrink-0",children:[y.jsx(ym,{className:"w-4 h-4 text-fuchsia-400"}),y.jsxs("h2",{className:"text-sm font-semibold text-[var(--text)]",children:["Dialog with ",e.agentName]})]}),y.jsx("div",{className:"flex-1 overflow-hidden px-5 py-4",children:y.jsx(W9,{node:n})})]}):null}function tH(){const e=se(l=>l.selectedNode),t=se(l=>l.activeDialog),n=se(l=>l.dialogEngaged);return y.jsxs(Pp,{direction:"vertical",className:"flex-1 overflow-hidden",children:[y.jsx(Co,{defaultSize:70,minSize:30,children:y.jsxs(Pp,{direction:"horizontal",className:"h-full",children:[y.jsx(Co,{defaultSize:e?65:100,minSize:40,children:t&&n?y.jsx(eH,{}):y.jsx(eD,{})}),e&&y.jsxs(y.Fragment,{children:[y.jsx(Gp,{className:"w-[3px] bg-[var(--border)] hover:bg-[var(--text-muted)] transition-colors cursor-col-resize"}),y.jsx(Co,{defaultSize:35,minSize:20,maxSize:60,children:y.jsx(F9,{})})]})]})}),y.jsx(Gp,{className:"h-[3px] bg-[var(--border)] hover:bg-[var(--text-muted)] transition-colors cursor-row-resize"}),y.jsx(Co,{defaultSize:30,minSize:5,maxSize:70,collapsible:!0,children:y.jsx(Y9,{})})]})}const hw=10;function nH(){const e=se(E=>E.iterationLimitGate),t=se(E=>E.wsStatus),n=se(E=>E.sendIterationLimitResponse),[l,a]=I.useState(String(hw)),[o,s]=I.useState(!1);I.useEffect(()=>{e!=null&&e.gate_id&&(a(String(hw)),s(!1))},[e==null?void 0:e.gate_id]);const c=I.useMemo(()=>{const E=Number(l);return!Number.isFinite(E)||E<0?null:Math.floor(E)},[l]);if(!e||e.skip_gates)return null;const h=e.agent_name??e.group_name??"workflow",f=t==="connected"&&!o,m=!f||c==null||c<=0,p=()=>e.agent_name!==void 0?{agent_name:e.agent_name}:{group_name:e.group_name},g=()=>{m||c==null||(s(!0),n(p(),e.gate_id,c))},b=()=>{f&&(s(!0),n(p(),e.gate_id,0))},w=E=>{E.key==="Enter"&&(E.preventDefault(),g())};return y.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"iteration-limit-title","data-testid":"iteration-limit-modal",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:y.jsxs("div",{className:"relative flex flex-col w-[90vw] max-w-md rounded-xl border border-amber-500/40 bg-[var(--surface)] shadow-2xl overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-[var(--border)] bg-amber-500/10",children:[y.jsx(lc,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),y.jsx("h2",{id:"iteration-limit-title",className:"text-sm font-semibold text-[var(--text)]",children:"Max iterations reached"})]}),y.jsxs("div",{className:"px-4 py-4 space-y-3",children:[y.jsxs("p",{className:"text-xs text-[var(--text)]",children:[y.jsx("span",{className:"font-semibold",children:h})," reached"," ",y.jsxs("span",{className:"tabular-nums",children:[e.current_iteration,"/",e.max_iterations]})," ","iterations."]}),e.possible_loop&&y.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-amber-500/5 border border-amber-500/30",children:[y.jsx(lc,{className:"w-3.5 h-3.5 text-amber-400 flex-shrink-0"}),y.jsx("span",{className:"text-[11px] text-amber-300",children:"The same agent has run repeatedly — this may indicate a loop."})]}),e.agent_history.length>0&&y.jsxs("div",{className:"space-y-1",children:[y.jsx("h3",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"Recent agents"}),y.jsx("ol",{className:"text-[11px] text-[var(--text-muted)] list-decimal list-inside space-y-0.5",children:e.agent_history.map((E,S)=>y.jsx("li",{children:E},`${S}-${E}`))})]}),y.jsxs("div",{className:"space-y-1.5",children:[y.jsx("label",{htmlFor:"iteration-limit-additional",className:"block text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"Additional iterations"}),y.jsx("input",{id:"iteration-limit-additional","data-testid":"iteration-limit-input",type:"number",min:0,step:1,value:l,onChange:E=>a(E.target.value),onKeyDown:w,disabled:!f,autoFocus:!0,className:"w-full text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-amber-400 transition-colors disabled:opacity-50"}),y.jsx("p",{className:"text-[10px] text-[var(--text-muted)]",children:"Enter a positive number to continue, or press Stop to end the workflow."})]}),t!=="connected"&&y.jsx("div",{className:"text-[11px] text-red-300",children:"Disconnected from server — reconnect to resolve this gate."})]}),y.jsxs("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-[var(--border)] bg-[var(--surface-raised)]",children:[y.jsxs("button",{type:"button","data-testid":"iteration-limit-stop",onClick:b,disabled:!f,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border border-[var(--border)] text-[var(--text)] hover:bg-[var(--surface-hover)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[y.jsx(hN,{className:"w-3.5 h-3.5"}),"Stop"]}),y.jsxs("button",{type:"button","data-testid":"iteration-limit-continue",onClick:g,disabled:m,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg bg-amber-500 text-white hover:bg-amber-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors font-medium",children:[y.jsx(Ec,{className:"w-3.5 h-3.5"}),"Continue"]})]})]})})}const rH=3e4;function iH(){const e=se(p=>p.processEvent),t=se(p=>p.replayState),n=se(p=>p.setWsStatus),l=se(p=>p.setWsSend),a=I.useRef(null),o=I.useRef(1e3),s=I.useRef(null),c=I.useRef(null),h=I.useRef(()=>{}),f=I.useCallback(()=>{n("reconnecting"),s.current=setTimeout(()=>{o.current=Math.min(o.current*2,rH),h.current()},o.current)},[n]),m=I.useCallback(()=>{n("connecting"),c.current&&c.current.abort();const p=new AbortController;c.current=p,fetch("/api/state",{signal:p.signal}).then(g=>g.json()).then(g=>{g&&g.length>0&&t(g);const w=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;try{const E=new WebSocket(w);a.current=E,E.onopen=()=>{o.current=1e3,n("connected"),l(S=>{E.readyState===WebSocket.OPEN&&E.send(JSON.stringify(S))})},E.onmessage=S=>{try{const _=JSON.parse(S.data);e(_)}catch(_){console.error("Failed to parse WebSocket message:",_)}},E.onclose=()=>{n("disconnected"),l(null),a.current=null,f()},E.onerror=()=>{}}catch{f()}}).catch(g=>{p.signal.aborted||(console.error("Failed to fetch state:",g),f())})},[e,t,n,l,f]);h.current=m,I.useEffect(()=>(m(),()=>{c.current&&c.current.abort(),s.current&&clearTimeout(s.current),a.current&&a.current.close(),l(null)}),[m,l])}function lH(){const e=se(f=>f.setReplayMode),t=se(f=>f.setWsStatus),n=se(f=>f.replayPlaying),l=se(f=>f.replayPosition),a=se(f=>f.replayTotalEvents),o=se(f=>f.replaySpeed),s=se(f=>f.replayEvents),c=se(f=>f.setReplayPosition);I.useEffect(()=>{t("connecting"),fetch("/api/state").then(f=>f.json()).then(f=>{e(f),t("connected")}).catch(f=>{console.error("Failed to load replay events:",f),t("disconnected")})},[e,t]);const h=I.useRef(null);I.useEffect(()=>{if(!n||l>=a){h.current&&clearTimeout(h.current),n&&l>=a&&se.getState().setReplayPlaying(!1);return}const f=s[l-1],m=s[l];let p=100;if(f&&m){const g=(m.timestamp-f.timestamp)*1e3;p=Math.max(16,Math.min(g/o,2e3))}return h.current=setTimeout(()=>{c(l+1)},p),()=>{h.current&&clearTimeout(h.current)}},[n,l,a,o,s,c])}function aH(){return iH(),null}function oH(){return lH(),null}function sH(){const[e,t]=I.useState(null),n=se(o=>o.replayMode),l=se(o=>o.selectNode),a=se(o=>o.workflowName);return I.useEffect(()=>{fetch("/api/replay/info").then(o=>{o.ok?t(!0):t(!1)}).catch(()=>t(!1))},[]),I.useEffect(()=>{document.title=a?`Conductor — ${a}`:"Conductor Dashboard"},[a]),I.useEffect(()=>{const o=s=>{s.key==="Escape"&&l(null)};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[l]),e===null?null:y.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg)]",children:[e?y.jsx(oH,{}):y.jsx(aH,{}),y.jsx(IN,{}),y.jsx(qN,{}),y.jsx(tH,{}),n?y.jsx(GN,{}):y.jsx(UN,{}),!n&&y.jsx(nH,{})]})}iN.createRoot(document.getElementById("root")).render(y.jsx(I.StrictMode,{children:y.jsx(sH,{})})); diff --git a/src/conductor/web/static/assets/index-CQX53z_g.css b/src/conductor/web/static/assets/index-CjrhFxh5.css similarity index 63% rename from src/conductor/web/static/assets/index-CQX53z_g.css rename to src/conductor/web/static/assets/index-CjrhFxh5.css index 4d8be2bf..60b623db 100644 --- a/src/conductor/web/static/assets/index-CQX53z_g.css +++ b/src/conductor/web/static/assets/index-CjrhFxh5.css @@ -1 +1 @@ -/*! tailwindcss v4.2.1 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-950:oklch(25.8% .092 26.042);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-950:oklch(27.9% .077 45.635);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-950:oklch(26.6% .065 152.934);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-600:oklch(60.9% .126 221.723);--color-sky-400:oklch(74.6% .16 232.661);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-indigo-400:oklch(67.3% .182 276.935);--color-indigo-500:oklch(58.5% .233 277.117);--color-purple-400:oklch(71.4% .203 305.504);--color-fuchsia-300:oklch(83.3% .145 321.434);--color-fuchsia-400:oklch(74% .238 322.16);--color-fuchsia-500:oklch(66.7% .295 322.15);--color-fuchsia-600:oklch(59.1% .293 322.896);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-md:28rem;--container-3xl:48rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-wider:.05em;--leading-tight:1.25;--leading-relaxed:1.625;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--ease-out:cubic-bezier(0, 0, .2, 1);--animate-spin:spin 1s linear infinite;--animate-ping:ping 1s cubic-bezier(0, 0, .2, 1) infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--animate-bounce:bounce 1s infinite;--blur-sm:8px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.inset-0{inset:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.end{inset-inline-end:var(--spacing)}.-top-0\.5{top:calc(var(--spacing) * -.5)}.top-3{top:calc(var(--spacing) * 3)}.top-full{top:100%}.-right-0\.5{right:calc(var(--spacing) * -.5)}.right-0{right:calc(var(--spacing) * 0)}.bottom-0{bottom:calc(var(--spacing) * 0)}.bottom-full{bottom:100%}.left-0{left:calc(var(--spacing) * 0)}.left-1\/2{left:50%}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.-mx-1{margin-inline:calc(var(--spacing) * -1)}.my-0\.5{margin-block:calc(var(--spacing) * .5)}.my-1{margin-block:calc(var(--spacing) * 1)}.my-1\.5{margin-block:calc(var(--spacing) * 1.5)}.my-2{margin-block:calc(var(--spacing) * 2)}.my-3{margin-block:calc(var(--spacing) * 3)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mr-0\.5{margin-right:calc(var(--spacing) * .5)}.mr-1{margin-right:calc(var(--spacing) * 1)}.-mb-px{margin-bottom:-1px}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.ml-0\.5{margin-left:calc(var(--spacing) * .5)}.ml-1{margin-left:calc(var(--spacing) * 1)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-\[4\.25rem\]{margin-left:4.25rem}.ml-\[calc\(7ch\+5ch\+8ch\+1rem\)\]{margin-left:calc(20ch + 1rem)}.ml-auto{margin-left:auto}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.\!h-2{height:calc(var(--spacing) * 2)!important}.h-0{height:calc(var(--spacing) * 0)}.h-1{height:calc(var(--spacing) * 1)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3{height:calc(var(--spacing) * 3)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-8{height:calc(var(--spacing) * 8)}.h-11{height:calc(var(--spacing) * 11)}.h-\[2px\]{height:2px}.h-\[3px\]{height:3px}.h-\[90\%\]{height:90%}.h-full{height:100%}.h-px{height:1px}.max-h-24{max-height:calc(var(--spacing) * 24)}.max-h-\[80vh\]{max-height:80vh}.max-h-\[400px\]{max-height:400px}.min-h-0{min-height:calc(var(--spacing) * 0)}.\!w-2{width:calc(var(--spacing) * 2)!important}.w-0{width:calc(var(--spacing) * 0)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-2\.5{width:calc(var(--spacing) * 2.5)}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-4{width:calc(var(--spacing) * 4)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-8{width:calc(var(--spacing) * 8)}.w-11{width:calc(var(--spacing) * 11)}.w-12{width:calc(var(--spacing) * 12)}.w-\[3px\]{width:3px}.w-\[5ch\]{width:5ch}.w-\[80\%\]{width:80%}.w-\[90vw\]{width:90vw}.w-full{width:100%}.max-w-3xl{max-width:var(--container-3xl)}.max-w-\[16ch\]{max-width:16ch}.max-w-\[85\%\]{max-width:85%}.max-w-\[140px\]{max-width:140px}.max-w-\[220px\]{max-width:220px}.max-w-\[240px\]{max-width:240px}.max-w-\[260px\]{max-width:260px}.max-w-\[560px\]{max-width:560px}.max-w-md{max-width:var(--container-md)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-\[8ch\]{min-width:8ch}.min-w-\[14px\]{min-width:14px}.min-w-\[140px\]{min-width:140px}.min-w-\[180px\]{min-width:180px}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing) * 0);translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-4{--tw-translate-x:calc(var(--spacing) * 4);translate:var(--tw-translate-x) var(--tw-translate-y)}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-\[banner-in_200ms_ease-out\]{animation:.2s ease-out banner-in}.animate-\[context-pulse_2s_ease-in-out_infinite\]{animation:2s ease-in-out infinite context-pulse}.animate-\[tooltip-in_150ms_ease-out\]{animation:.15s ease-out tooltip-in}.animate-bounce{animation:var(--animate-bounce)}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-col-resize{cursor:col-resize}.cursor-default{cursor:default}.cursor-pointer{cursor:pointer}.cursor-row-resize{cursor:row-resize}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}.grid-cols-\[auto_1fr\]{grid-template-columns:auto 1fr}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-3{column-gap:calc(var(--spacing) * 3)}.gap-y-0\.5{row-gap:calc(var(--spacing) * .5)}.gap-y-1\.5{row-gap:calc(var(--spacing) * 1.5)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-t-lg{border-top-left-radius:var(--radius-lg);border-top-right-radius:var(--radius-lg)}.rounded-b-lg{border-bottom-right-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-x-\[6px\]{border-inline-style:var(--tw-border-style);border-inline-width:6px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-\[6px\]{border-top-style:var(--tw-border-style);border-top-width:6px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.\!border-none{--tw-border-style:none!important;border-style:none!important}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-\[var\(--accent\)\]{border-color:var(--accent)}.border-\[var\(--border\)\]{border-color:var(--border)}.border-\[var\(--border-subtle\)\]{border-color:var(--border-subtle)}.border-amber-500\/30{border-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/30{border-color:color-mix(in oklab,var(--color-amber-500) 30%,transparent)}}.border-amber-500\/40{border-color:#f99c0066}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/40{border-color:color-mix(in oklab,var(--color-amber-500) 40%,transparent)}}.border-amber-500\/50{border-color:#f99c0080}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/50{border-color:color-mix(in oklab,var(--color-amber-500) 50%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500) 30%,transparent)}}.border-emerald-500\/20{border-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.border-emerald-500\/20{border-color:color-mix(in oklab,var(--color-emerald-500) 20%,transparent)}}.border-fuchsia-500\/30{border-color:#e12afb4d}@supports (color:color-mix(in lab,red,red)){.border-fuchsia-500\/30{border-color:color-mix(in oklab,var(--color-fuchsia-500) 30%,transparent)}}.border-fuchsia-500\/40{border-color:#e12afb66}@supports (color:color-mix(in lab,red,red)){.border-fuchsia-500\/40{border-color:color-mix(in oklab,var(--color-fuchsia-500) 40%,transparent)}}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500) 30%,transparent)}}.border-green-500\/40{border-color:#00c75866}@supports (color:color-mix(in lab,red,red)){.border-green-500\/40{border-color:color-mix(in oklab,var(--color-green-500) 40%,transparent)}}.border-green-500\/60{border-color:#00c75899}@supports (color:color-mix(in lab,red,red)){.border-green-500\/60{border-color:color-mix(in oklab,var(--color-green-500) 60%,transparent)}}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500) 20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500) 30%,transparent)}}.border-red-500\/40{border-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.border-red-500\/40{border-color:color-mix(in oklab,var(--color-red-500) 40%,transparent)}}.border-transparent{border-color:#0000}.border-x-transparent{border-inline-color:#0000}.border-t-\[var\(--border\)\]{border-top-color:var(--border)}.\!bg-\[var\(--border\)\]{background-color:var(--border)!important}.bg-\[\#a78bfa\]{background-color:#a78bfa}.bg-\[var\(--accent\)\]{background-color:var(--accent)}.bg-\[var\(--bg\)\]{background-color:var(--bg)}.bg-\[var\(--border\)\]{background-color:var(--border)}.bg-\[var\(--completed\)\]{background-color:var(--completed)}.bg-\[var\(--failed\)\]{background-color:var(--failed)}.bg-\[var\(--node-bg\)\]{background-color:var(--node-bg)}.bg-\[var\(--pending\)\]{background-color:var(--pending)}.bg-\[var\(--running\)\]{background-color:var(--running)}.bg-\[var\(--surface\)\],.bg-\[var\(--surface\)\]\/80{background-color:var(--surface)}@supports (color:color-mix(in lab,red,red)){.bg-\[var\(--surface\)\]\/80{background-color:color-mix(in oklab,var(--surface) 80%,transparent)}}.bg-\[var\(--surface-hover\)\]{background-color:var(--surface-hover)}.bg-\[var\(--surface-raised\)\]{background-color:var(--surface-raised)}.bg-\[var\(--waiting\)\]{background-color:var(--waiting)}.bg-amber-400{background-color:var(--color-amber-400)}.bg-amber-400\/60{background-color:#fcbb0099}@supports (color:color-mix(in lab,red,red)){.bg-amber-400\/60{background-color:color-mix(in oklab,var(--color-amber-400) 60%,transparent)}}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-500\/5{background-color:#f99c000d}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/5{background-color:color-mix(in oklab,var(--color-amber-500) 5%,transparent)}}.bg-amber-500\/10{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/10{background-color:color-mix(in oklab,var(--color-amber-500) 10%,transparent)}}.bg-amber-500\/20{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/20{background-color:color-mix(in oklab,var(--color-amber-500) 20%,transparent)}}.bg-amber-950\/30{background-color:#4619014d}@supports (color:color-mix(in lab,red,red)){.bg-amber-950\/30{background-color:color-mix(in oklab,var(--color-amber-950) 30%,transparent)}}.bg-amber-950\/90{background-color:#461901e6}@supports (color:color-mix(in lab,red,red)){.bg-amber-950\/90{background-color:color-mix(in oklab,var(--color-amber-950) 90%,transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black) 50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black) 60%,transparent)}}.bg-blue-500\/10{background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/10{background-color:color-mix(in oklab,var(--color-blue-500) 10%,transparent)}}.bg-emerald-500\/10{background-color:#00bb7f1a}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/10{background-color:color-mix(in oklab,var(--color-emerald-500) 10%,transparent)}}.bg-fuchsia-400{background-color:var(--color-fuchsia-400)}.bg-fuchsia-500{background-color:var(--color-fuchsia-500)}.bg-fuchsia-500\/10{background-color:#e12afb1a}@supports (color:color-mix(in lab,red,red)){.bg-fuchsia-500\/10{background-color:color-mix(in oklab,var(--color-fuchsia-500) 10%,transparent)}}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/5{background-color:#00c7580d}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/5{background-color:color-mix(in oklab,var(--color-green-500) 5%,transparent)}}.bg-green-500\/10{background-color:#00c7581a}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/10{background-color:color-mix(in oklab,var(--color-green-500) 10%,transparent)}}.bg-green-950\/90{background-color:#032e15e6}@supports (color:color-mix(in lab,red,red)){.bg-green-950\/90{background-color:color-mix(in oklab,var(--color-green-950) 90%,transparent)}}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/10{background-color:color-mix(in oklab,var(--color-red-500) 10%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500) 20%,transparent)}}.bg-red-950\/50{background-color:#46080980}@supports (color:color-mix(in lab,red,red)){.bg-red-950\/50{background-color:color-mix(in oklab,var(--color-red-950) 50%,transparent)}}.bg-red-950\/90{background-color:#460809e6}@supports (color:color-mix(in lab,red,red)){.bg-red-950\/90{background-color:color-mix(in oklab,var(--color-red-950) 90%,transparent)}}.bg-transparent{background-color:#0000}.p-0{padding:calc(var(--spacing) * 0)}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:calc(var(--spacing) * 1)}.p-3{padding:calc(var(--spacing) * 3)}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-8{padding-inline:calc(var(--spacing) * 8)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-12{padding-block:calc(var(--spacing) * 12)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-px{padding-top:1px}.pl-2\.5{padding-left:calc(var(--spacing) * 2.5)}.pl-3{padding-left:calc(var(--spacing) * 3)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[13px\]{font-size:13px}.leading-6{--tw-leading:calc(var(--spacing) * 6);line-height:calc(var(--spacing) * 6)}.leading-\[1\.6\]{--tw-leading:1.6;line-height:1.6}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-words{overflow-wrap:break-word}.whitespace-nowrap{white-space:nowrap}.whitespace-pre{white-space:pre}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[var\(--accent\)\]{color:var(--accent)}.text-\[var\(--completed\)\]{color:var(--completed)}.text-\[var\(--failed\)\]{color:var(--failed)}.text-\[var\(--running\)\]{color:var(--running)}.text-\[var\(--text\)\]{color:var(--text)}.text-\[var\(--text-muted\)\]{color:var(--text-muted)}.text-\[var\(--text-secondary\)\]{color:var(--text-secondary)}.text-\[var\(--waiting\)\]{color:var(--waiting)}.text-amber-200{color:var(--color-amber-200)}.text-amber-300{color:var(--color-amber-300)}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/80{color:#fcbb00cc}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/80{color:color-mix(in oklab,var(--color-amber-400) 80%,transparent)}}.text-amber-500{color:var(--color-amber-500)}.text-blue-400{color:var(--color-blue-400)}.text-blue-500{color:var(--color-blue-500)}.text-cyan-400\/70{color:#00d2efb3}@supports (color:color-mix(in lab,red,red)){.text-cyan-400\/70{color:color-mix(in oklab,var(--color-cyan-400) 70%,transparent)}}.text-cyan-600{color:var(--color-cyan-600)}.text-emerald-400{color:var(--color-emerald-400)}.text-emerald-500\/70{color:#00bb7fb3}@supports (color:color-mix(in lab,red,red)){.text-emerald-500\/70{color:color-mix(in oklab,var(--color-emerald-500) 70%,transparent)}}.text-fuchsia-300{color:var(--color-fuchsia-300)}.text-fuchsia-400{color:var(--color-fuchsia-400)}.text-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-400\/80{color:#05df72cc}@supports (color:color-mix(in lab,red,red)){.text-green-400\/80{color:color-mix(in oklab,var(--color-green-400) 80%,transparent)}}.text-green-500\/60{color:#00c75899}@supports (color:color-mix(in lab,red,red)){.text-green-500\/60{color:color-mix(in oklab,var(--color-green-500) 60%,transparent)}}.text-green-600{color:var(--color-green-600)}.text-indigo-400\/70{color:#7d87ffb3}@supports (color:color-mix(in lab,red,red)){.text-indigo-400\/70{color:color-mix(in oklab,var(--color-indigo-400) 70%,transparent)}}.text-indigo-500{color:var(--color-indigo-500)}.text-purple-400{color:var(--color-purple-400)}.text-red-300{color:var(--color-red-300)}.text-red-400{color:var(--color-red-400)}.text-red-400\/50{color:#ff656880}@supports (color:color-mix(in lab,red,red)){.text-red-400\/50{color:color-mix(in oklab,var(--color-red-400) 50%,transparent)}}.text-red-400\/60{color:#ff656899}@supports (color:color-mix(in lab,red,red)){.text-red-400\/60{color:color-mix(in oklab,var(--color-red-400) 60%,transparent)}}.text-red-400\/80{color:#ff6568cc}@supports (color:color-mix(in lab,red,red)){.text-red-400\/80{color:color-mix(in oklab,var(--color-red-400) 80%,transparent)}}.text-sky-400{color:var(--color-sky-400)}.text-white{color:var(--color-white)}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.underline{text-decoration-line:underline}.underline-offset-2{text-underline-offset:2px}.opacity-0{opacity:0}.opacity-20{opacity:.2}.opacity-35{opacity:.35}.opacity-40{opacity:.4}.opacity-75{opacity:.75}.opacity-80{opacity:.8}.opacity-100{opacity:1}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_12px_rgba\(167\,139\,250\,0\.4\)\]{--tw-shadow:0 0 12px var(--tw-shadow-color,#a78bfa66);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_12px_var\(--completed-muted\)\]{--tw-shadow:0 0 12px var(--tw-shadow-color,var(--completed-muted));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_12px_var\(--running-glow\)\]{--tw-shadow:0 0 12px var(--tw-shadow-color,var(--running-glow));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_12px_var\(--waiting-muted\)\]{--tw-shadow:0 0 12px var(--tw-shadow-color,var(--waiting-muted));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_16px_var\(--completed-muted\)\]{--tw-shadow:0 0 16px var(--tw-shadow-color,var(--completed-muted));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_16px_var\(--failed-muted\)\]{--tw-shadow:0 0 16px var(--tw-shadow-color,var(--failed-muted));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_16px_var\(--running-glow\)\]{--tw-shadow:0 0 16px var(--tw-shadow-color,var(--running-glow));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-amber-500\/10{--tw-shadow-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.shadow-amber-500\/10{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-amber-500) 10%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-green-500\/10{--tw-shadow-color:#00c7581a}@supports (color:color-mix(in lab,red,red)){.shadow-green-500\/10{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-green-500) 10%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-red-500\/10{--tw-shadow-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.shadow-red-500\/10{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-red-500) 10%, transparent) var(--tw-shadow-alpha), transparent)}}.ring-\[var\(--accent\)\]{--tw-ring-color:var(--accent)}.ring-offset-1{--tw-ring-offset-width:1px;--tw-ring-offset-shadow:var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}.ring-offset-\[var\(--bg\)\]{--tw-ring-offset-color:var(--bg)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-500{--tw-duration:.5s;transition-duration:.5s}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.\[animation-delay\:0ms\]{animation-delay:0s}.\[animation-delay\:150ms\]{animation-delay:.15s}.\[animation-delay\:300ms\]{animation-delay:.3s}@media(hover:hover){.group-hover\:border-amber-400:is(:where(.group):hover *){border-color:var(--color-amber-400)}}.placeholder\:text-\[var\(--text-muted\)\]::placeholder{color:var(--text-muted)}.last\:mb-0:last-child{margin-bottom:calc(var(--spacing) * 0)}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){.hover\:border-amber-400\/60:hover{border-color:#fcbb0099}@supports (color:color-mix(in lab,red,red)){.hover\:border-amber-400\/60:hover{border-color:color-mix(in oklab,var(--color-amber-400) 60%,transparent)}}.hover\:border-emerald-500\/30:hover{border-color:#00bb7f4d}@supports (color:color-mix(in lab,red,red)){.hover\:border-emerald-500\/30:hover{border-color:color-mix(in oklab,var(--color-emerald-500) 30%,transparent)}}.hover\:border-red-500\/30:hover{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.hover\:border-red-500\/30:hover{border-color:color-mix(in oklab,var(--color-red-500) 30%,transparent)}}.hover\:bg-\[var\(--accent\)\]\/20:hover{background-color:var(--accent)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-\[var\(--accent\)\]\/20:hover{background-color:color-mix(in oklab,var(--accent) 20%,transparent)}}.hover\:bg-\[var\(--node-bg\)\]:hover{background-color:var(--node-bg)}.hover\:bg-\[var\(--surface\)\]:hover{background-color:var(--surface)}.hover\:bg-\[var\(--surface-hover\)\]:hover{background-color:var(--surface-hover)}.hover\:bg-\[var\(--text-muted\)\]:hover{background-color:var(--text-muted)}.hover\:bg-amber-500\/5:hover{background-color:#f99c000d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/5:hover{background-color:color-mix(in oklab,var(--color-amber-500) 5%,transparent)}}.hover\:bg-amber-500\/30:hover{background-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/30:hover{background-color:color-mix(in oklab,var(--color-amber-500) 30%,transparent)}}.hover\:bg-amber-600:hover{background-color:var(--color-amber-600)}.hover\:bg-emerald-500\/20:hover{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-emerald-500\/20:hover{background-color:color-mix(in oklab,var(--color-emerald-500) 20%,transparent)}}.hover\:bg-fuchsia-500\/20:hover{background-color:#e12afb33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-fuchsia-500\/20:hover{background-color:color-mix(in oklab,var(--color-fuchsia-500) 20%,transparent)}}.hover\:bg-fuchsia-600:hover{background-color:var(--color-fuchsia-600)}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500) 20%,transparent)}}.hover\:bg-red-500\/30:hover{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/30:hover{background-color:color-mix(in oklab,var(--color-red-500) 30%,transparent)}}.hover\:text-\[var\(--accent\)\]:hover{color:var(--accent)}.hover\:text-\[var\(--running\)\]:hover{color:var(--running)}.hover\:text-\[var\(--text\)\]:hover{color:var(--text)}.hover\:text-\[var\(--text-secondary\)\]:hover{color:var(--text-secondary)}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-green-300:hover{color:var(--color-green-300)}.hover\:underline:hover{text-decoration-line:underline}}.focus\:border-amber-400:focus{border-color:var(--color-amber-400)}.focus\:border-fuchsia-400:focus{border-color:var(--color-fuchsia-400)}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}}:root{--bg:#0a0a0f;--bg-subtle:#111118;--surface:#16161e;--surface-hover:#1c1c26;--surface-raised:#1e1e28;--border:#2a2a3a;--border-subtle:#223;--text:#e4e4ef;--text-secondary:#a0a0b8;--text-muted:#6b6b80;--pending:#52525b;--running:#3b82f6;--running-glow:#3b82f680;--completed:#22c55e;--completed-muted:#22c55e40;--failed:#ef4444;--failed-muted:#ef444440;--waiting:#f59e0b;--waiting-muted:#f59e0b40;--skipped:#6b7280;--accent:#6366f1;--accent-muted:#6366f140;--node-bg:#1e1e2a;--node-border:#2e2e42;--edge-color:#2e2e42;--edge-active:#3b82f6;--edge-taken:#22c55e;--minimap-bg:#0d0d14;--minimap-mask:#ffffff10;--minimap-node:#3b82f680;--font-sans:ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;--font-mono:ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace}*{box-sizing:border-box;margin:0;padding:0}html,body,#root{width:100%;height:100%;overflow:hidden}body{font-family:var(--font-sans);background:var(--bg);color:var(--text);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.react-flow__background{background:var(--bg)!important}.react-flow__minimap{background:var(--minimap-bg)!important;border:1px solid var(--border)!important;border-radius:8px!important}.react-flow__controls{overflow:hidden;border:1px solid var(--border)!important;border-radius:8px!important;box-shadow:0 4px 12px #0006!important}.react-flow__controls-button{background:var(--surface)!important;border:none!important;border-bottom:1px solid var(--border)!important;color:var(--text-secondary)!important;fill:var(--text-secondary)!important;width:32px!important;height:32px!important}.react-flow__controls-button:hover{background:var(--surface-hover)!important;color:var(--text)!important;fill:var(--text)!important}.react-flow__controls-button:last-child{border-bottom:none!important}@keyframes pulse-ring{0%{box-shadow:0 0 0 0 var(--running-glow)}70%{box-shadow:0 0 0 6px #0000}to{box-shadow:0 0 #0000}}@keyframes subtle-pulse{0%,to{opacity:1}50%{opacity:.7}}@keyframes context-pulse{0%,to{opacity:1}50%{opacity:.4}}@keyframes dash-flow{to{stroke-dashoffset:-20px}}@keyframes node-activate{0%{transform:scale(1)}50%{transform:scale(1.03)}to{transform:scale(1)}}@keyframes node-complete-glow{0%{box-shadow:0 0 0 0 var(--completed-muted)}50%{box-shadow:0 0 16px 4px var(--completed-muted)}to{box-shadow:0 0 #0000}}@keyframes node-fail-glow{0%{box-shadow:0 0 0 0 var(--failed-muted)}50%{box-shadow:0 0 16px 4px var(--failed-muted)}to{box-shadow:0 0 #0000}}.node-activate{animation:.3s ease-out node-activate}.node-complete{animation:.4s ease-out node-complete-glow}.node-fail{animation:.4s ease-out node-fail-glow}@keyframes tooltip-in{0%{opacity:0;transform:translate(-50%,4px)}to{opacity:1;transform:translate(-50%)}}@keyframes banner-in{0%{opacity:0;transform:translate(-50%,-8px)}to{opacity:1;transform:translate(-50%)}}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:0 0}::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}::-webkit-scrollbar-thumb:hover{background:var(--text-muted)}[data-panel-group-direction=horizontal]>[data-resize-handle-active],[data-panel-group-direction=vertical]>[data-resize-handle-active]{background-color:var(--accent)!important}[data-resize-handle]{transition:background-color .15s;background-color:var(--border)!important}[data-resize-handle]:hover{background-color:var(--text-muted)!important}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}@keyframes bounce{0%,to{animation-timing-function:cubic-bezier(.8,0,1,1);transform:translateY(-25%)}50%{animation-timing-function:cubic-bezier(0,0,.2,1);transform:none}}.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #777;--xy-background-pattern-lines-color-default: #777;--xy-background-pattern-cross-color-default: #777;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))} +/*! tailwindcss v4.2.1 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-950:oklch(25.8% .092 26.042);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-950:oklch(27.9% .077 45.635);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-950:oklch(26.6% .065 152.934);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-600:oklch(60.9% .126 221.723);--color-sky-400:oklch(74.6% .16 232.661);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-indigo-400:oklch(67.3% .182 276.935);--color-indigo-500:oklch(58.5% .233 277.117);--color-purple-400:oklch(71.4% .203 305.504);--color-fuchsia-300:oklch(83.3% .145 321.434);--color-fuchsia-400:oklch(74% .238 322.16);--color-fuchsia-500:oklch(66.7% .295 322.15);--color-fuchsia-600:oklch(59.1% .293 322.896);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-md:28rem;--container-3xl:48rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-wider:.05em;--leading-tight:1.25;--leading-relaxed:1.625;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--ease-out:cubic-bezier(0, 0, .2, 1);--animate-spin:spin 1s linear infinite;--animate-ping:ping 1s cubic-bezier(0, 0, .2, 1) infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--animate-bounce:bounce 1s infinite;--blur-sm:8px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.inset-0{inset:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.end{inset-inline-end:var(--spacing)}.-top-0\.5{top:calc(var(--spacing) * -.5)}.top-3{top:calc(var(--spacing) * 3)}.top-full{top:100%}.-right-0\.5{right:calc(var(--spacing) * -.5)}.right-0{right:calc(var(--spacing) * 0)}.bottom-0{bottom:calc(var(--spacing) * 0)}.bottom-full{bottom:100%}.left-0{left:calc(var(--spacing) * 0)}.left-1\/2{left:50%}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.-mx-1{margin-inline:calc(var(--spacing) * -1)}.my-0\.5{margin-block:calc(var(--spacing) * .5)}.my-1{margin-block:calc(var(--spacing) * 1)}.my-1\.5{margin-block:calc(var(--spacing) * 1.5)}.my-2{margin-block:calc(var(--spacing) * 2)}.my-3{margin-block:calc(var(--spacing) * 3)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mr-0\.5{margin-right:calc(var(--spacing) * .5)}.mr-1{margin-right:calc(var(--spacing) * 1)}.-mb-px{margin-bottom:-1px}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.ml-0\.5{margin-left:calc(var(--spacing) * .5)}.ml-1{margin-left:calc(var(--spacing) * 1)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-\[4\.25rem\]{margin-left:4.25rem}.ml-\[calc\(7ch\+5ch\+8ch\+1rem\)\]{margin-left:calc(20ch + 1rem)}.ml-auto{margin-left:auto}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.\!h-2{height:calc(var(--spacing) * 2)!important}.h-0{height:calc(var(--spacing) * 0)}.h-1{height:calc(var(--spacing) * 1)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3{height:calc(var(--spacing) * 3)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-8{height:calc(var(--spacing) * 8)}.h-11{height:calc(var(--spacing) * 11)}.h-\[2px\]{height:2px}.h-\[3px\]{height:3px}.h-\[90\%\]{height:90%}.h-full{height:100%}.h-px{height:1px}.max-h-24{max-height:calc(var(--spacing) * 24)}.max-h-\[80vh\]{max-height:80vh}.max-h-\[400px\]{max-height:400px}.min-h-0{min-height:calc(var(--spacing) * 0)}.\!w-2{width:calc(var(--spacing) * 2)!important}.w-0{width:calc(var(--spacing) * 0)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-2\.5{width:calc(var(--spacing) * 2.5)}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-4{width:calc(var(--spacing) * 4)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-8{width:calc(var(--spacing) * 8)}.w-11{width:calc(var(--spacing) * 11)}.w-12{width:calc(var(--spacing) * 12)}.w-\[3px\]{width:3px}.w-\[5ch\]{width:5ch}.w-\[80\%\]{width:80%}.w-\[90vw\]{width:90vw}.w-full{width:100%}.max-w-3xl{max-width:var(--container-3xl)}.max-w-\[16ch\]{max-width:16ch}.max-w-\[85\%\]{max-width:85%}.max-w-\[140px\]{max-width:140px}.max-w-\[220px\]{max-width:220px}.max-w-\[240px\]{max-width:240px}.max-w-\[260px\]{max-width:260px}.max-w-\[560px\]{max-width:560px}.max-w-md{max-width:var(--container-md)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-\[8ch\]{min-width:8ch}.min-w-\[14px\]{min-width:14px}.min-w-\[140px\]{min-width:140px}.min-w-\[180px\]{min-width:180px}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing) * 0);translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-4{--tw-translate-x:calc(var(--spacing) * 4);translate:var(--tw-translate-x) var(--tw-translate-y)}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-\[banner-in_200ms_ease-out\]{animation:.2s ease-out banner-in}.animate-\[context-pulse_2s_ease-in-out_infinite\]{animation:2s ease-in-out infinite context-pulse}.animate-\[tooltip-in_150ms_ease-out\]{animation:.15s ease-out tooltip-in}.animate-bounce{animation:var(--animate-bounce)}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-col-resize{cursor:col-resize}.cursor-default{cursor:default}.cursor-pointer{cursor:pointer}.cursor-row-resize{cursor:row-resize}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}.grid-cols-\[auto_1fr\]{grid-template-columns:auto 1fr}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-3{column-gap:calc(var(--spacing) * 3)}.gap-y-0\.5{row-gap:calc(var(--spacing) * .5)}.gap-y-1\.5{row-gap:calc(var(--spacing) * 1.5)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-t-lg{border-top-left-radius:var(--radius-lg);border-top-right-radius:var(--radius-lg)}.rounded-b-lg{border-bottom-right-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-x-\[6px\]{border-inline-style:var(--tw-border-style);border-inline-width:6px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-\[6px\]{border-top-style:var(--tw-border-style);border-top-width:6px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.\!border-none{--tw-border-style:none!important;border-style:none!important}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-\[var\(--accent\)\]{border-color:var(--accent)}.border-\[var\(--border\)\]{border-color:var(--border)}.border-\[var\(--border-subtle\)\]{border-color:var(--border-subtle)}.border-amber-500\/30{border-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/30{border-color:color-mix(in oklab,var(--color-amber-500) 30%,transparent)}}.border-amber-500\/40{border-color:#f99c0066}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/40{border-color:color-mix(in oklab,var(--color-amber-500) 40%,transparent)}}.border-amber-500\/50{border-color:#f99c0080}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/50{border-color:color-mix(in oklab,var(--color-amber-500) 50%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500) 30%,transparent)}}.border-emerald-500\/20{border-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.border-emerald-500\/20{border-color:color-mix(in oklab,var(--color-emerald-500) 20%,transparent)}}.border-fuchsia-500\/30{border-color:#e12afb4d}@supports (color:color-mix(in lab,red,red)){.border-fuchsia-500\/30{border-color:color-mix(in oklab,var(--color-fuchsia-500) 30%,transparent)}}.border-fuchsia-500\/40{border-color:#e12afb66}@supports (color:color-mix(in lab,red,red)){.border-fuchsia-500\/40{border-color:color-mix(in oklab,var(--color-fuchsia-500) 40%,transparent)}}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500) 30%,transparent)}}.border-green-500\/40{border-color:#00c75866}@supports (color:color-mix(in lab,red,red)){.border-green-500\/40{border-color:color-mix(in oklab,var(--color-green-500) 40%,transparent)}}.border-green-500\/60{border-color:#00c75899}@supports (color:color-mix(in lab,red,red)){.border-green-500\/60{border-color:color-mix(in oklab,var(--color-green-500) 60%,transparent)}}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500) 20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500) 30%,transparent)}}.border-red-500\/40{border-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.border-red-500\/40{border-color:color-mix(in oklab,var(--color-red-500) 40%,transparent)}}.border-transparent{border-color:#0000}.border-x-transparent{border-inline-color:#0000}.border-t-\[var\(--border\)\]{border-top-color:var(--border)}.\!bg-\[var\(--border\)\]{background-color:var(--border)!important}.bg-\[\#a78bfa\]{background-color:#a78bfa}.bg-\[var\(--accent\)\]{background-color:var(--accent)}.bg-\[var\(--bg\)\]{background-color:var(--bg)}.bg-\[var\(--border\)\]{background-color:var(--border)}.bg-\[var\(--completed\)\]{background-color:var(--completed)}.bg-\[var\(--failed\)\]{background-color:var(--failed)}.bg-\[var\(--node-bg\)\]{background-color:var(--node-bg)}.bg-\[var\(--pending\)\]{background-color:var(--pending)}.bg-\[var\(--running\)\]{background-color:var(--running)}.bg-\[var\(--surface\)\],.bg-\[var\(--surface\)\]\/80{background-color:var(--surface)}@supports (color:color-mix(in lab,red,red)){.bg-\[var\(--surface\)\]\/80{background-color:color-mix(in oklab,var(--surface) 80%,transparent)}}.bg-\[var\(--surface-hover\)\]{background-color:var(--surface-hover)}.bg-\[var\(--surface-raised\)\]{background-color:var(--surface-raised)}.bg-\[var\(--waiting\)\]{background-color:var(--waiting)}.bg-amber-400{background-color:var(--color-amber-400)}.bg-amber-400\/60{background-color:#fcbb0099}@supports (color:color-mix(in lab,red,red)){.bg-amber-400\/60{background-color:color-mix(in oklab,var(--color-amber-400) 60%,transparent)}}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-500\/5{background-color:#f99c000d}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/5{background-color:color-mix(in oklab,var(--color-amber-500) 5%,transparent)}}.bg-amber-500\/10{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/10{background-color:color-mix(in oklab,var(--color-amber-500) 10%,transparent)}}.bg-amber-500\/20{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/20{background-color:color-mix(in oklab,var(--color-amber-500) 20%,transparent)}}.bg-amber-950\/30{background-color:#4619014d}@supports (color:color-mix(in lab,red,red)){.bg-amber-950\/30{background-color:color-mix(in oklab,var(--color-amber-950) 30%,transparent)}}.bg-amber-950\/90{background-color:#461901e6}@supports (color:color-mix(in lab,red,red)){.bg-amber-950\/90{background-color:color-mix(in oklab,var(--color-amber-950) 90%,transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black) 50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black) 60%,transparent)}}.bg-blue-500\/10{background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/10{background-color:color-mix(in oklab,var(--color-blue-500) 10%,transparent)}}.bg-emerald-500\/10{background-color:#00bb7f1a}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/10{background-color:color-mix(in oklab,var(--color-emerald-500) 10%,transparent)}}.bg-fuchsia-400{background-color:var(--color-fuchsia-400)}.bg-fuchsia-500{background-color:var(--color-fuchsia-500)}.bg-fuchsia-500\/10{background-color:#e12afb1a}@supports (color:color-mix(in lab,red,red)){.bg-fuchsia-500\/10{background-color:color-mix(in oklab,var(--color-fuchsia-500) 10%,transparent)}}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/5{background-color:#00c7580d}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/5{background-color:color-mix(in oklab,var(--color-green-500) 5%,transparent)}}.bg-green-500\/10{background-color:#00c7581a}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/10{background-color:color-mix(in oklab,var(--color-green-500) 10%,transparent)}}.bg-green-950\/90{background-color:#032e15e6}@supports (color:color-mix(in lab,red,red)){.bg-green-950\/90{background-color:color-mix(in oklab,var(--color-green-950) 90%,transparent)}}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/10{background-color:color-mix(in oklab,var(--color-red-500) 10%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500) 20%,transparent)}}.bg-red-950\/50{background-color:#46080980}@supports (color:color-mix(in lab,red,red)){.bg-red-950\/50{background-color:color-mix(in oklab,var(--color-red-950) 50%,transparent)}}.bg-red-950\/90{background-color:#460809e6}@supports (color:color-mix(in lab,red,red)){.bg-red-950\/90{background-color:color-mix(in oklab,var(--color-red-950) 90%,transparent)}}.bg-transparent{background-color:#0000}.p-0{padding:calc(var(--spacing) * 0)}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:calc(var(--spacing) * 1)}.p-3{padding:calc(var(--spacing) * 3)}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-8{padding-inline:calc(var(--spacing) * 8)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-12{padding-block:calc(var(--spacing) * 12)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-px{padding-top:1px}.pl-2\.5{padding-left:calc(var(--spacing) * 2.5)}.pl-3{padding-left:calc(var(--spacing) * 3)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[13px\]{font-size:13px}.leading-6{--tw-leading:calc(var(--spacing) * 6);line-height:calc(var(--spacing) * 6)}.leading-\[1\.6\]{--tw-leading:1.6;line-height:1.6}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-words{overflow-wrap:break-word}.whitespace-nowrap{white-space:nowrap}.whitespace-pre{white-space:pre}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[var\(--accent\)\]{color:var(--accent)}.text-\[var\(--completed\)\]{color:var(--completed)}.text-\[var\(--failed\)\]{color:var(--failed)}.text-\[var\(--running\)\]{color:var(--running)}.text-\[var\(--text\)\]{color:var(--text)}.text-\[var\(--text-muted\)\]{color:var(--text-muted)}.text-\[var\(--text-secondary\)\]{color:var(--text-secondary)}.text-\[var\(--waiting\)\]{color:var(--waiting)}.text-amber-200{color:var(--color-amber-200)}.text-amber-300{color:var(--color-amber-300)}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/80{color:#fcbb00cc}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/80{color:color-mix(in oklab,var(--color-amber-400) 80%,transparent)}}.text-amber-500{color:var(--color-amber-500)}.text-blue-400{color:var(--color-blue-400)}.text-blue-500{color:var(--color-blue-500)}.text-cyan-400\/70{color:#00d2efb3}@supports (color:color-mix(in lab,red,red)){.text-cyan-400\/70{color:color-mix(in oklab,var(--color-cyan-400) 70%,transparent)}}.text-cyan-600{color:var(--color-cyan-600)}.text-emerald-400{color:var(--color-emerald-400)}.text-emerald-500\/70{color:#00bb7fb3}@supports (color:color-mix(in lab,red,red)){.text-emerald-500\/70{color:color-mix(in oklab,var(--color-emerald-500) 70%,transparent)}}.text-fuchsia-300{color:var(--color-fuchsia-300)}.text-fuchsia-400{color:var(--color-fuchsia-400)}.text-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-400\/60{color:#05df7299}@supports (color:color-mix(in lab,red,red)){.text-green-400\/60{color:color-mix(in oklab,var(--color-green-400) 60%,transparent)}}.text-green-400\/80{color:#05df72cc}@supports (color:color-mix(in lab,red,red)){.text-green-400\/80{color:color-mix(in oklab,var(--color-green-400) 80%,transparent)}}.text-green-500\/60{color:#00c75899}@supports (color:color-mix(in lab,red,red)){.text-green-500\/60{color:color-mix(in oklab,var(--color-green-500) 60%,transparent)}}.text-green-600{color:var(--color-green-600)}.text-indigo-400\/70{color:#7d87ffb3}@supports (color:color-mix(in lab,red,red)){.text-indigo-400\/70{color:color-mix(in oklab,var(--color-indigo-400) 70%,transparent)}}.text-indigo-500{color:var(--color-indigo-500)}.text-purple-400{color:var(--color-purple-400)}.text-red-300{color:var(--color-red-300)}.text-red-400{color:var(--color-red-400)}.text-red-400\/50{color:#ff656880}@supports (color:color-mix(in lab,red,red)){.text-red-400\/50{color:color-mix(in oklab,var(--color-red-400) 50%,transparent)}}.text-red-400\/60{color:#ff656899}@supports (color:color-mix(in lab,red,red)){.text-red-400\/60{color:color-mix(in oklab,var(--color-red-400) 60%,transparent)}}.text-red-400\/80{color:#ff6568cc}@supports (color:color-mix(in lab,red,red)){.text-red-400\/80{color:color-mix(in oklab,var(--color-red-400) 80%,transparent)}}.text-sky-400{color:var(--color-sky-400)}.text-white{color:var(--color-white)}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.underline{text-decoration-line:underline}.underline-offset-2{text-underline-offset:2px}.opacity-0{opacity:0}.opacity-20{opacity:.2}.opacity-35{opacity:.35}.opacity-40{opacity:.4}.opacity-75{opacity:.75}.opacity-80{opacity:.8}.opacity-100{opacity:1}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_12px_rgba\(167\,139\,250\,0\.4\)\]{--tw-shadow:0 0 12px var(--tw-shadow-color,#a78bfa66);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_12px_var\(--completed-muted\)\]{--tw-shadow:0 0 12px var(--tw-shadow-color,var(--completed-muted));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_12px_var\(--failed-muted\)\]{--tw-shadow:0 0 12px var(--tw-shadow-color,var(--failed-muted));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_12px_var\(--running-glow\)\]{--tw-shadow:0 0 12px var(--tw-shadow-color,var(--running-glow));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_12px_var\(--waiting-muted\)\]{--tw-shadow:0 0 12px var(--tw-shadow-color,var(--waiting-muted));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_16px_var\(--completed-muted\)\]{--tw-shadow:0 0 16px var(--tw-shadow-color,var(--completed-muted));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_16px_var\(--failed-muted\)\]{--tw-shadow:0 0 16px var(--tw-shadow-color,var(--failed-muted));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_16px_var\(--running-glow\)\]{--tw-shadow:0 0 16px var(--tw-shadow-color,var(--running-glow));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-amber-500\/10{--tw-shadow-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.shadow-amber-500\/10{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-amber-500) 10%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-green-500\/10{--tw-shadow-color:#00c7581a}@supports (color:color-mix(in lab,red,red)){.shadow-green-500\/10{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-green-500) 10%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-red-500\/10{--tw-shadow-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.shadow-red-500\/10{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-red-500) 10%, transparent) var(--tw-shadow-alpha), transparent)}}.ring-\[var\(--accent\)\]{--tw-ring-color:var(--accent)}.ring-offset-1{--tw-ring-offset-width:1px;--tw-ring-offset-shadow:var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}.ring-offset-\[var\(--bg\)\]{--tw-ring-offset-color:var(--bg)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-500{--tw-duration:.5s;transition-duration:.5s}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.\[animation-delay\:0ms\]{animation-delay:0s}.\[animation-delay\:150ms\]{animation-delay:.15s}.\[animation-delay\:300ms\]{animation-delay:.3s}@media(hover:hover){.group-hover\:border-amber-400:is(:where(.group):hover *){border-color:var(--color-amber-400)}}.placeholder\:text-\[var\(--text-muted\)\]::placeholder{color:var(--text-muted)}.last\:mb-0:last-child{margin-bottom:calc(var(--spacing) * 0)}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){.hover\:border-amber-400\/60:hover{border-color:#fcbb0099}@supports (color:color-mix(in lab,red,red)){.hover\:border-amber-400\/60:hover{border-color:color-mix(in oklab,var(--color-amber-400) 60%,transparent)}}.hover\:border-emerald-500\/30:hover{border-color:#00bb7f4d}@supports (color:color-mix(in lab,red,red)){.hover\:border-emerald-500\/30:hover{border-color:color-mix(in oklab,var(--color-emerald-500) 30%,transparent)}}.hover\:border-red-500\/30:hover{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.hover\:border-red-500\/30:hover{border-color:color-mix(in oklab,var(--color-red-500) 30%,transparent)}}.hover\:bg-\[var\(--accent\)\]\/20:hover{background-color:var(--accent)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-\[var\(--accent\)\]\/20:hover{background-color:color-mix(in oklab,var(--accent) 20%,transparent)}}.hover\:bg-\[var\(--node-bg\)\]:hover{background-color:var(--node-bg)}.hover\:bg-\[var\(--surface\)\]:hover{background-color:var(--surface)}.hover\:bg-\[var\(--surface-hover\)\]:hover{background-color:var(--surface-hover)}.hover\:bg-\[var\(--text-muted\)\]:hover{background-color:var(--text-muted)}.hover\:bg-amber-500\/5:hover{background-color:#f99c000d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/5:hover{background-color:color-mix(in oklab,var(--color-amber-500) 5%,transparent)}}.hover\:bg-amber-500\/30:hover{background-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/30:hover{background-color:color-mix(in oklab,var(--color-amber-500) 30%,transparent)}}.hover\:bg-amber-600:hover{background-color:var(--color-amber-600)}.hover\:bg-emerald-500\/20:hover{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-emerald-500\/20:hover{background-color:color-mix(in oklab,var(--color-emerald-500) 20%,transparent)}}.hover\:bg-fuchsia-500\/20:hover{background-color:#e12afb33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-fuchsia-500\/20:hover{background-color:color-mix(in oklab,var(--color-fuchsia-500) 20%,transparent)}}.hover\:bg-fuchsia-600:hover{background-color:var(--color-fuchsia-600)}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500) 20%,transparent)}}.hover\:bg-red-500\/30:hover{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/30:hover{background-color:color-mix(in oklab,var(--color-red-500) 30%,transparent)}}.hover\:text-\[var\(--accent\)\]:hover{color:var(--accent)}.hover\:text-\[var\(--running\)\]:hover{color:var(--running)}.hover\:text-\[var\(--text\)\]:hover{color:var(--text)}.hover\:text-\[var\(--text-secondary\)\]:hover{color:var(--text-secondary)}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-green-300:hover{color:var(--color-green-300)}.hover\:underline:hover{text-decoration-line:underline}}.focus\:border-amber-400:focus{border-color:var(--color-amber-400)}.focus\:border-fuchsia-400:focus{border-color:var(--color-fuchsia-400)}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}}:root{--bg:#0a0a0f;--bg-subtle:#111118;--surface:#16161e;--surface-hover:#1c1c26;--surface-raised:#1e1e28;--border:#2a2a3a;--border-subtle:#223;--text:#e4e4ef;--text-secondary:#a0a0b8;--text-muted:#6b6b80;--pending:#52525b;--running:#3b82f6;--running-glow:#3b82f680;--completed:#22c55e;--completed-muted:#22c55e40;--failed:#ef4444;--failed-muted:#ef444440;--waiting:#f59e0b;--waiting-muted:#f59e0b40;--skipped:#6b7280;--accent:#6366f1;--accent-muted:#6366f140;--node-bg:#1e1e2a;--node-border:#2e2e42;--edge-color:#2e2e42;--edge-active:#3b82f6;--edge-taken:#22c55e;--minimap-bg:#0d0d14;--minimap-mask:#ffffff10;--minimap-node:#3b82f680;--font-sans:ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;--font-mono:ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace}*{box-sizing:border-box;margin:0;padding:0}html,body,#root{width:100%;height:100%;overflow:hidden}body{font-family:var(--font-sans);background:var(--bg);color:var(--text);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.react-flow__background{background:var(--bg)!important}.react-flow__minimap{background:var(--minimap-bg)!important;border:1px solid var(--border)!important;border-radius:8px!important}.react-flow__controls{overflow:hidden;border:1px solid var(--border)!important;border-radius:8px!important;box-shadow:0 4px 12px #0006!important}.react-flow__controls-button{background:var(--surface)!important;border:none!important;border-bottom:1px solid var(--border)!important;color:var(--text-secondary)!important;fill:var(--text-secondary)!important;width:32px!important;height:32px!important}.react-flow__controls-button:hover{background:var(--surface-hover)!important;color:var(--text)!important;fill:var(--text)!important}.react-flow__controls-button:last-child{border-bottom:none!important}@keyframes pulse-ring{0%{box-shadow:0 0 0 0 var(--running-glow)}70%{box-shadow:0 0 0 6px #0000}to{box-shadow:0 0 #0000}}@keyframes subtle-pulse{0%,to{opacity:1}50%{opacity:.7}}@keyframes context-pulse{0%,to{opacity:1}50%{opacity:.4}}@keyframes dash-flow{to{stroke-dashoffset:-20px}}@keyframes node-activate{0%{transform:scale(1)}50%{transform:scale(1.03)}to{transform:scale(1)}}@keyframes node-complete-glow{0%{box-shadow:0 0 0 0 var(--completed-muted)}50%{box-shadow:0 0 16px 4px var(--completed-muted)}to{box-shadow:0 0 #0000}}@keyframes node-fail-glow{0%{box-shadow:0 0 0 0 var(--failed-muted)}50%{box-shadow:0 0 16px 4px var(--failed-muted)}to{box-shadow:0 0 #0000}}.node-activate{animation:.3s ease-out node-activate}.node-complete{animation:.4s ease-out node-complete-glow}.node-fail{animation:.4s ease-out node-fail-glow}@keyframes tooltip-in{0%{opacity:0;transform:translate(-50%,4px)}to{opacity:1;transform:translate(-50%)}}@keyframes banner-in{0%{opacity:0;transform:translate(-50%,-8px)}to{opacity:1;transform:translate(-50%)}}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:0 0}::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}::-webkit-scrollbar-thumb:hover{background:var(--text-muted)}[data-panel-group-direction=horizontal]>[data-resize-handle-active],[data-panel-group-direction=vertical]>[data-resize-handle-active]{background-color:var(--accent)!important}[data-resize-handle]{transition:background-color .15s;background-color:var(--border)!important}[data-resize-handle]:hover{background-color:var(--text-muted)!important}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}@keyframes bounce{0%,to{animation-timing-function:cubic-bezier(.8,0,1,1);transform:translateY(-25%)}50%{animation-timing-function:cubic-bezier(0,0,.2,1);transform:none}}.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #777;--xy-background-pattern-lines-color-default: #777;--xy-background-pattern-cross-color-default: #777;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))} diff --git a/src/conductor/web/static/index.html b/src/conductor/web/static/index.html index bd9b71df..ee10432d 100644 --- a/src/conductor/web/static/index.html +++ b/src/conductor/web/static/index.html @@ -5,8 +5,8 @@ Conductor Dashboard - - + +
From fff64527d300269d23893ab0f4ac19cd710cfd8d Mon Sep 17 00:00:00 2001 From: Jason Robert Date: Tue, 26 May 2026 15:10:13 -0400 Subject: [PATCH 5/5] fix(cli): keep dashboard alive when workflow ends via terminate (#219) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a workflow ended via `type: terminate status: failed`, the CLI killed the dashboard process immediately, preventing `--web` and `--web-bg` users from observing the terminated state. The `except WorkflowTerminated: raise` arm in `run_workflow_async` / `resume_workflow_async` propagated the exception past the post-execution dashboard lifecycle, so: - `--web`: dashboard died with the process exit, browser tab broke. - `--web-bg`: the bg child exited, port became unreachable; the user saw a working URL momentarily but the WebSocket was dead by the time the page loaded. Discovered while smoke-testing the new dashboard rendering for #219 \(commit ec5be86\): I gave the user a URL, the dashboard URL connected, but nothing rendered correctly because the underlying server was gone. Fix: defer the raise. Capture the `WorkflowTerminated` in a local variable, fall through to the existing post-execution lifecycle (which awaits `wait_for_clients_disconnect` for bg or `asyncio.Event().wait()` for foreground), and re-raise at the end. The CLI app.py handler still catches it and exits with code 1, so the failure signal to downstream tooling is preserved. Also adapted the verbose banner: shows "Workflow terminated" \(yellow\) instead of "Workflow complete" \(green\) on the terminate path, so the foreground prompt clearly distinguishes "workflow completed cleanly" from "workflow terminated explicitly, press Ctrl+C to exit". Verified end-to-end via Playwright against the live dashboard: - Failed-terminate: red "Workflow Terminated" banner with reason and `Terminated by: abort_unsafe`; node rendered as `terminateNode` with octagon icon and "TERMINATE · FAILED" sub-label. - Success-terminate: green "Workflow Terminated" banner; node shows "TERMINATE · SUCCESS" with the rendered reason inline. Both paths previously failed to render because the dashboard was dead before the page could connect. A unit test for this would need to mock most of the async lifecycle in `run_workflow_async` (config loading, dashboard creation, listener setup, the long `try/except` ladder) which is brittle for the value; tracked as a follow-up — the visual confirmation is the proof. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/conductor/cli/run.py | 88 ++++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 27 deletions(-) diff --git a/src/conductor/cli/run.py b/src/conductor/cli/run.py index cb51a1b8..8dadb84b 100644 --- a/src/conductor/cli/run.py +++ b/src/conductor/cli/run.py @@ -1338,23 +1338,24 @@ async def run_workflow_async( if dashboard is not None and interrupt_event is not None: dashboard.set_interrupt_event(interrupt_event) + terminate_exc: WorkflowTerminated | None = None try: if listener is not None: await listener.start() _verbose_console.print("[dim]Press Esc to interrupt and provide guidance[/dim]") result = await _run_with_stop_signal(engine, inputs, dashboard) - except WorkflowTerminated: - # Defense-in-depth: `_print_resume_instructions` already early- - # returns when no checkpoint was saved, and the engine skips - # the on-failure checkpoint save for `WorkflowTerminated` — - # so the hint wouldn't print today regardless. Catching the - # exception explicitly here makes the intent ("never resume an - # explicit termination") visible at the CLI layer, so a future - # refactor of either `_print_resume_instructions` or the - # engine's checkpoint policy cannot accidentally start - # surfacing a misleading "resume?" hint for intentional exits. - raise + except WorkflowTerminated as exc: + # Explicit `type: terminate status: failed` is an intentional + # outcome, not a crash — defer the raise so the dashboard + # stays alive for the same post-execution lifecycle as a + # successful run. Without this deferral the dashboard dies + # immediately and a `--web` / `--web-bg` user cannot see the + # rendered TerminateNode / red "Workflow Terminated" banner. + # Resume hint is still suppressed: explicit terminations are + # not resumable (defense-in-depth — see issue #219). + terminate_exc = exc + result = exc.output except BaseException: _print_resume_instructions(engine) raise @@ -1364,7 +1365,13 @@ async def run_workflow_async( # Log completion verbose_log_timing("Total workflow execution", time.time() - start_time) - verbose_log("Workflow completed successfully", style="green") + if terminate_exc is None: + verbose_log("Workflow completed successfully", style="green") + else: + verbose_log( + f"Workflow terminated explicitly at '{terminate_exc.terminated_by}'", + style="yellow", + ) # Display usage summary if cost tracking is enabled if config.workflow.cost.show_summary: @@ -1372,7 +1379,9 @@ async def run_workflow_async( if "usage" in summary: display_usage_summary(summary["usage"]) - # Post-execution dashboard lifecycle + # Post-execution dashboard lifecycle — runs for both clean exits + # and explicit-terminate failures so the user can observe the + # final dashboard state in either case. if dashboard is not None: # Auto-shutdown if either --web-bg was passed directly or # this is a background child process (CONDUCTOR_WEB_BG env var) @@ -1383,14 +1392,23 @@ async def run_workflow_async( from conductor.cli.app import is_verbose if is_verbose(): + banner = ( + "[bold yellow]Workflow terminated.[/bold yellow]" + if terminate_exc is not None + else "[bold green]Workflow complete.[/bold green]" + ) _verbose_console.print( - f"\n[bold green]Workflow complete.[/bold green] " + f"\n{banner} " f"Dashboard still running at {dashboard.url} — " f"press [bold]Ctrl+C[/bold] to exit." ) with contextlib.suppress(asyncio.CancelledError): await asyncio.Event().wait() + if terminate_exc is not None: + # Re-raise so the CLI handler emits the non-zero exit code + # and prints the structured termination message/output. + raise terminate_exc return result finally: # Clean up PID file if this is a background child process @@ -1916,21 +1934,21 @@ async def resume_workflow_async( if dashboard is not None and interrupt_event is not None: dashboard.set_interrupt_event(interrupt_event) + terminate_exc: WorkflowTerminated | None = None try: if listener is not None: await listener.start() _verbose_console.print("[dim]Press Esc to interrupt and provide guidance[/dim]") result = await _resume_with_stop_signal(engine, cp.current_agent, dashboard) - except WorkflowTerminated: - # Defense-in-depth: see the matching arm in - # `run_workflow_async` for the full rationale. In short, - # `_print_resume_instructions` is already a no-op when no - # checkpoint was saved (which is the case for an explicit - # termination), but pinning that contract at the CLI layer - # protects against future drift in either the helper or the - # engine's checkpoint policy. - raise + except WorkflowTerminated as exc: + # Mirror of the matching arm in `run_workflow_async`: defer + # the raise so the dashboard stays alive for + # explicit-terminate failures the same as it does for + # successful runs. Resume hints stay suppressed because + # explicit terminations are not resumable (see issue #219). + terminate_exc = exc + result = exc.output except BaseException: _print_resume_instructions(engine) raise @@ -1940,7 +1958,13 @@ async def resume_workflow_async( # Log completion verbose_log_timing("Total resumed execution", time.time() - start_time) - verbose_log("Workflow resumed successfully", style="green") + if terminate_exc is None: + verbose_log("Workflow resumed successfully", style="green") + else: + verbose_log( + f"Resumed workflow terminated explicitly at '{terminate_exc.terminated_by}'", + style="yellow", + ) # Display usage summary if cost tracking is enabled if config.workflow.cost.show_summary: @@ -1948,11 +1972,14 @@ async def resume_workflow_async( if "usage" in summary: display_usage_summary(summary["usage"]) - # Cleanup checkpoint after successful resume + # Cleanup checkpoint after the resumed run finishes. Both clean + # completion and explicit termination are terminal outcomes — the + # checkpoint we resumed from is no longer needed in either case. CheckpointManager.cleanup(cp.file_path) verbose_log(f"Checkpoint cleaned up: {cp.file_path}", style="dim") - # Post-execution dashboard lifecycle (parity with run) + # Post-execution dashboard lifecycle (parity with run) — kept + # alive for both clean exits and explicit-terminate failures. if dashboard is not None: is_bg = web_bg or os.environ.get("CONDUCTOR_WEB_BG") == "1" if is_bg: @@ -1961,14 +1988,21 @@ async def resume_workflow_async( from conductor.cli.app import is_verbose if is_verbose(): + banner = ( + "[bold yellow]Workflow terminated.[/bold yellow]" + if terminate_exc is not None + else "[bold green]Workflow complete.[/bold green]" + ) _verbose_console.print( - f"\n[bold green]Workflow complete.[/bold green] " + f"\n{banner} " f"Dashboard still running at {dashboard.url} — " f"press [bold]Ctrl+C[/bold] to exit." ) with contextlib.suppress(asyncio.CancelledError): await asyncio.Event().wait() + if terminate_exc is not None: + raise terminate_exc return result finally: # Clean up PID file if this is a background child process