diff --git a/AGENTS.md b/AGENTS.md index 6fc1d51c..4f1005d9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -87,9 +87,12 @@ make validate-examples # validate all examples - `agent.py` - `AgentExecutor` handles prompt rendering, tool resolution, and output validation for single agents - `script.py` - `ScriptExecutor` runs shell commands as workflow steps, capturing stdout/stderr/exit_code - `set_step.py` - `SetExecutor` evaluates Jinja2 expressions for `type: set` steps and binds typed values into the workflow context (no LLM, no subprocess). Supports single `value:` and multi `values:` forms with auto / explicit `output_type:` coercion. + - `wait.py` - `WaitExecutor` pauses workflow execution for a parsed duration via `asyncio.sleep`. Races the sleep against the engine's `interrupt_event` so Esc/Ctrl+G cancels in-flight waits immediately; the workflow-level `limits.timeout_seconds` also cancels it via `LimitEnforcer.wait_for_with_timeout`. Output contract is strictly `{"waited_seconds": float}` per issue #218. - `template.py` - Jinja2 template rendering - `output.py` - JSON output parsing and schema validation +- **duration.py**: `parse_duration(value)` shared helper. Accepts plain `int`/`float` seconds, or strings with `ms`/`s`/`m`/`h` suffix. Raises `ValueError` (nests cleanly inside Pydantic `ValidationError`). Rejects booleans. Bounds enforcement (e.g. > 0, 24h cap) lives in callers so the parser can be reused. + - **providers/**: SDK provider abstraction - `base.py` - `AgentProvider` ABC defining `execute()`, `validate_connection()`, `close()` - `copilot.py` - GitHub Copilot SDK implementation @@ -114,13 +117,14 @@ make validate-examples # validate all examples 1. CLI parses YAML via `config/loader.py` → `WorkflowConfig` 2. `WorkflowEngine` initializes with config and provider -3. Engine loops: find agent/parallel/for-each/script/set → execute → evaluate routes → next +3. Engine loops: find agent/parallel/for-each/script/set/wait → execute → evaluate routes → next 4. Parallel groups execute agents concurrently with context isolation (deep copy snapshot) 5. For-each groups resolve source arrays at runtime, inject loop variables (`{{ item }}`, `{{ _index }}`, `{{ _key }}`) 6. Script steps run shell commands via asyncio subprocess, expose stdout/stderr/exit_code to context 7. Set steps render Jinja2 expressions and bind typed values to context (no LLM, no subprocess) via the shared `WorkflowEngine._run_set_step` helper, which enforces `output:` schema in all three positions (main loop, parallel group, for-each iteration) and emits `set_started` / `set_completed` / `set_failed` -8. Routes evaluated via `Router` using Jinja2 or simpleeval expressions -9. Final output built from templates in `output:` section +8. Wait steps pause via `asyncio.sleep` (cancellable by interrupt or workflow timeout); expose `{"waited_seconds": float}` to context +9. Routes evaluated via `Router` using Jinja2 or simpleeval expressions +10. Final output built from templates in `output:` section ### Key Patterns diff --git a/CHANGELOG.md b/CHANGELOG.md index 101f89c5..487a98a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,34 @@ 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 +- 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, + external-system catch-up, and demos. The `duration:` field accepts + plain numbers (seconds), suffixed strings (`"500ms"`, `"60s"`, + `"2.5m"`, `"1h"`), or a Jinja2 template that renders to one of + those (e.g. `"{{ workflow.input.poll_interval }}s"`). Schema enforces + `0 < duration <= 24h` and rejects boolean values pre-coercion. + `Esc` / `Ctrl+G` cancels in-progress waits immediately (the engine + races the sleep against the interrupt event), and the workflow-level + `limits.timeout_seconds` also cancels them. Wait steps emit + `wait_started` / `wait_completed` / `wait_failed` events alongside + the generic `agent_started` (with `agent_type: "wait"`), so existing + dashboards keyed on agent lifecycle pick them up automatically. The + dashboard adds a dedicated `WaitNode` (clock icon) and `WaitDetail` + panel that show the requested duration, actual elapsed time, reason, + and an "interrupted" indicator. The public output contract is strict + — only `{"waited_seconds": float}` is exposed to workflow context; + extra metadata lives in event payloads. Wait steps count toward + `limits.max_iterations` (each pause is one step) but are not subject + to `max_agent_iterations` (per-LLM-agent tool counter). Wait cannot + be used inside `parallel` or `for_each` groups. New `examples/wait-step.yaml` + demonstrates a polling pattern with a templated poll interval and + route loop-back + ([#224](https://github.com/microsoft/conductor/pull/224), + closes [#218](https://github.com/microsoft/conductor/issues/218)). + ## [0.1.17](https://github.com/microsoft/conductor/compare/v0.1.16...v0.1.17) - 2026-05-21 ### Added diff --git a/README.md b/README.md index 87e4e352..a2bb08cc 100644 --- a/README.md +++ b/README.md @@ -302,6 +302,8 @@ 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 | +| [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) | **More examples and running instructions:** [examples/README.md](./examples/README.md) diff --git a/docs/configuration.md b/docs/configuration.md index 679469b4..4a0cecab 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -159,8 +159,8 @@ agents: Per-agent overrides always win over the workflow-wide default. The `reasoning.effort` field is **only** valid on standard `agent`-type agents; it -is rejected on `script`, `human_gate`, and `workflow` agents (which do not call -a model). +is rejected on `script`, `human_gate`, `workflow`, and `wait` agents (which do +not call a model). ### Per-provider translation diff --git a/docs/workflow-syntax.md b/docs/workflow-syntax.md index 24447f23..dac716c4 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 (default: agent) + type: agent # agent | human_gate | script | workflow | wait (default: agent) model: string # Optional: Model identifier (e.g., 'claude-sonnet-4.5') prompt: | # Required for type=agent: Agent instructions @@ -281,6 +281,70 @@ routes: **Environment variable note** — values in `env` are passed as-is to the subprocess (they are not rendered as Jinja2 templates). Use `${VAR}` syntax in the workflow YAML loader if you need environment variable substitution in env values. +### Wait Steps + +Wait steps pause workflow execution for a parsed duration via in-process `asyncio.sleep`. Use them for rate-limit cooldowns, polling intervals, and external-system catch-up — cross-platform, no shell `sleep` dependency. + +```yaml +agents: + - name: cooldown + type: wait + description: "Cool down between API bursts" # Optional + duration: 60s # Required: see "Duration format" below + reason: "Avoiding rate limit" # Optional: shown in dashboard + routes: + - to: next_step +``` + +**Duration format** — `duration` accepts: + +- A plain `int` or `float` (seconds): `duration: 60`, `duration: 1.5`. +- A string with a unit suffix: `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours). Examples: `"500ms"`, `"60s"`, `"2.5m"`, `"1h"`. +- A Jinja2 template that renders to one of the above. Templated durations defer literal validation to runtime: + + ```yaml + duration: "{{ workflow.input.poll_interval_seconds }}s" + ``` + +The resolved duration must be **greater than 0 and no more than 24 hours** (`86400s`). Longer pauses should reconsider `workflow.limits.timeout_seconds` first. + +**Output structure** — wait step output is strict — only `waited_seconds` is exposed: + +| Field | Type | Description | +|-------|------|-------------| +| `waited_seconds` | `number` | Wall-clock seconds actually slept (may be less than requested on interrupt) | + +Access in templates: `{{ cooldown.output.waited_seconds }}`. + +**Polling pattern** — wait composes with routing loop-backs to build polling workflows without writing any Python: + +```yaml +agents: + - name: check_status + type: script + command: ./poll-status.sh + routes: + - to: process_result + when: "status == 'ready'" + - to: wait_then_retry + + - name: wait_then_retry + type: wait + duration: "{{ workflow.input.poll_interval_seconds }}s" + routes: + - to: check_status # loop back + + - name: process_result + # ... +``` + +**Cancellation** — `Esc` / `Ctrl+G` cancels an in-progress wait immediately (the engine races the sleep against the interrupt event). The workflow-level `limits.timeout_seconds` also cancels in-flight waits via the standard timeout path. + +**Iteration counting** — wait steps count toward `workflow.limits.max_iterations` (each pause is one step). They are not subject to `max_agent_iterations`, which counts per-LLM-agent tool iterations. + +**Restrictions** — wait steps cannot have `prompt`, `model`, `provider`, `tools`, `system_prompt`, `options`, `command`, `args`, `env`, `working_dir`, `timeout`, `workflow`, `input_mapping`, `max_depth`, `max_session_seconds`, `max_agent_iterations`, `retry`, `dialog`, `reasoning`, `timeout_seconds`, or `output`. Wait steps also cannot be used inside `parallel` groups or `for_each` groups. + +See [`examples/wait-step.yaml`](../examples/wait-step.yaml) for a complete polling workflow. ### Set Steps Set steps evaluate one or more Jinja2 expressions and bind the typed results into the workflow context. No LLM call, no subprocess, no I/O — they're pure context transformations. Use them to combine inputs, derive flags from prior outputs, compute defaults, or normalise a value once for many downstream prompts to share. @@ -488,7 +552,7 @@ After the conversation, the agent re-executes with the dialog transcript as addi | `dialog.trigger_prompt` | string | Yes | Criteria for the LLM evaluator to decide when dialog is needed | **Behavior notes:** -- Dialog is supported on regular `agent` type only (not `human_gate`, `script`, or `workflow`) +- Dialog is supported on regular `agent` type only (not `human_gate`, `script`, `workflow`, or `wait`) - In web dashboard mode, the dialog temporarily replaces the graph area with a chat interface - When `--skip-gates` is set (e.g., CI/automation), dialogs are automatically skipped - The evaluator prompt should describe *when* to trigger dialog, not *what* to ask — the evaluator generates the opening question from the agent's output context @@ -782,6 +846,7 @@ workflow: - Each agent execution counts as 1 iteration - Parallel agents count individually (3 parallel agents = 3 iterations) - Loop-back patterns increment the counter on each iteration +- Script steps and wait steps each count as 1 iteration ### Timeout Behavior diff --git a/examples/README.md b/examples/README.md index ab09d6fa..767ce630 100644 --- a/examples/README.md +++ b/examples/README.md @@ -150,6 +150,51 @@ Research workflow demonstrating multi-provider patterns. Demonstrates: conductor run examples/multi-provider-research.yaml --input topic="Cloud computing" ``` +## Step Types + +### script-step.yaml + +Script step with shell command, JSON output parsing, and `exit_code`-based routing. +Demonstrates: +- `type: script` agents (cross-platform shell command execution) +- Capturing stdout/stderr/exit_code +- Routing on `exit_code` (`when: "exit_code == 0"`) +- Passing script output to downstream LLM agents + +```bash +conductor run examples/script-step.yaml +``` + +### wait-step.yaml + +Polling pattern with a wait step and a routing loop-back. Demonstrates: +- `type: wait` agents (pure `asyncio.sleep`, cross-platform — no shell `sleep` dependency) +- Templated `duration` (`"{{ workflow.input.poll_interval_seconds }}s"`) +- Loop-back from wait → script for polling +- `reason` field surfaced in the dashboard + +```bash +conductor run examples/wait-step.yaml \ + --input poll_interval_seconds=2 --input max_attempts=3 +``` + +### wait-smoke.yaml + +Minimal wait-only workflow — no LLM, no scripts, no provider required. +Useful as a smoke test for installation, dashboard rendering, and +interrupt/timeout behavior. Three sequential wait steps demonstrate +the three duration syntaxes (suffixed string, templated, plain numeric). + +```bash +conductor run examples/wait-smoke.yaml + +# Watch wait nodes animate in the dashboard: +conductor run examples/wait-smoke.yaml --web + +# Trigger the workflow timeout cancelling an in-flight wait: +conductor run examples/wait-smoke.yaml --input middle_duration_ms=10000 +``` + ## Planning and Implementation ### plan.yaml diff --git a/examples/wait-smoke.yaml b/examples/wait-smoke.yaml new file mode 100644 index 00000000..3fb9671c --- /dev/null +++ b/examples/wait-smoke.yaml @@ -0,0 +1,92 @@ +# Wait Smoke Test +# +# Minimal `type: wait` workflow with no LLM calls, no scripts, no +# provider dependency. Useful for: +# +# - Verifying conductor installs and runs without configuring a provider. +# - Quickly sanity-checking dashboard rendering of wait nodes (with --web). +# - Confirming Esc / Ctrl+G cancels an in-progress wait immediately. +# - Confirming workflow-level limits.timeout_seconds cancels a long wait. +# +# Three wait steps run sequentially, each demonstrating a different +# duration syntax (suffixed string, templated workflow.input, plain +# numeric). All three are short by default so the workflow finishes in +# under two seconds. +# +# Usage: +# conductor run examples/wait-smoke.yaml +# +# # Watch wait nodes animate in the dashboard: +# conductor run examples/wait-smoke.yaml --web +# +# # Override the templated middle wait: +# conductor run examples/wait-smoke.yaml --input middle_duration_ms=750 +# +# # Press Esc during the workflow to cancel the in-flight wait: +# conductor run examples/wait-smoke.yaml --input middle_duration_ms=30000 +# +# # Watch the workflow timeout cancel an in-flight wait: +# conductor run examples/wait-smoke.yaml --input middle_duration_ms=30000 +# # → workflow.limits.timeout_seconds (3) fires before middle finishes. + +workflow: + name: wait-smoke + description: Minimal wait-only workflow for smoke testing and demos + version: "1.0.0" + entry_point: first + + # No runtime block: wait steps don't call a provider, so this workflow + # runs without any provider configuration. The CLI defaults to + # `copilot` for parsing purposes, but no API calls are made. + + input: + middle_duration_ms: + type: number + default: 500 + description: Duration of the middle wait step, in milliseconds. + + limits: + # Each wait step counts as one iteration (it's a step, not an LLM + # call). Three waits + headroom for routing = 5. + max_iterations: 5 + # If the templated middle_duration_ms is set very high, the workflow + # timeout will fire and cancel the in-flight wait — useful for + # exercising the timeout path. + timeout_seconds: 3 + +agents: + # Suffixed string duration — the most common form. + - name: first + type: wait + description: First wait — fixed suffixed-string duration. + duration: 200ms + reason: First pause (suffixed-string duration) + routes: + - to: middle + + # Templated duration — reads from workflow.input. Renders locally + # (no LLM), so workflow.input is available without an explicit + # `input:` declaration. + - name: middle + type: wait + description: Middle wait — duration templated from workflow.input. + duration: "{{ workflow.input.middle_duration_ms }}ms" + reason: Middle pause (templated duration) + routes: + - to: last + + # Plain numeric duration — interpreted as seconds. + - name: last + type: wait + description: Last wait — plain numeric duration in seconds. + duration: 0.3 + reason: Final pause (plain numeric seconds) + routes: + - to: $end + +# Workflow output exposes each step's waited_seconds so callers can +# verify the contract end-to-end. +output: + first_waited: "{{ first.output.waited_seconds }}" + middle_waited: "{{ middle.output.waited_seconds }}" + last_waited: "{{ last.output.waited_seconds }}" diff --git a/examples/wait-step.yaml b/examples/wait-step.yaml new file mode 100644 index 00000000..763f22ce --- /dev/null +++ b/examples/wait-step.yaml @@ -0,0 +1,109 @@ +# Wait Step Example +# +# This example demonstrates the `type: wait` step. A wait step pauses +# workflow execution for a parsed duration (seconds, "Ns/Nm/Nh/Nms", +# or a Jinja2 template that evaluates to one of those). The pause is +# pure in-process asyncio.sleep — no shell `sleep` command, so it works +# cross-platform. +# +# This workflow demonstrates a common pattern: polling an external +# system until it returns a "ready" status, with a cool-down between +# attempts. The wait step's duration is templated from a workflow +# input so the caller controls the poll cadence. +# +# Usage: +# conductor run examples/wait-step.yaml \ +# --input poll_interval_seconds=2 --input max_attempts=3 + +workflow: + name: wait-step-demo + description: Polling pattern with a wait step and a routing loop-back + version: "1.0.0" + entry_point: check_status + + runtime: + provider: copilot + + input: + poll_interval_seconds: + type: number + default: 5 + description: Seconds to wait between polling attempts. + max_attempts: + type: number + default: 3 + description: Maximum number of polling attempts before giving up. + + limits: + # Wait steps count toward max_iterations (each pause is one step), + # so allow enough headroom for max_attempts polls + waits + summary. + max_iterations: 20 + timeout_seconds: 600 + +agents: + # A trivial script that simulates polling an external system. In a + # real workflow this would hit an HTTP endpoint, query a job queue, + # check a CDN, etc. Here we just bump a counter and report "ready" + # on the third attempt. + - name: check_status + type: script + description: Poll the (simulated) external system for readiness. + command: python3 + args: + - "-c" + - | + import json, os, sys, pathlib + # Use a small counter file in /tmp so reruns are independent. + p = pathlib.Path(os.environ["STATUS_FILE"]) + count = int(p.read_text()) if p.exists() else 0 + count += 1 + p.write_text(str(count)) + # `args` entries ARE Jinja2-templated by the engine (unlike + # `env`, which is passed as-is to the subprocess). We use a + # positional arg for the threshold so workflow.input renders + # correctly. + ready_after = int(sys.argv[1]) + ready = count >= ready_after + print(json.dumps({ + "status": "ready" if ready else "pending", + "attempt": count, + })) + - "{{ workflow.input.max_attempts }}" + env: + STATUS_FILE: /tmp/wait-step-demo.count + routes: + - to: summarize + when: "status == 'ready'" + - to: cool_down + + # Wait for the configured poll interval, then loop back to check_status. + # The duration template uses workflow.input.* directly — wait steps + # render locally (no LLM), so workflow.input is available without an + # explicit `input:` declaration. + - name: cool_down + type: wait + duration: "{{ workflow.input.poll_interval_seconds }}s" + reason: "Cooling down between polling attempts" + routes: + - to: check_status + + # Summarize the polling result. An ordinary agent reading the most + # recent check_status output and reporting back to the caller. + - name: summarize + description: Summarize the polling result. + model: claude-haiku-4.5 + input: + - "check_status.output" + prompt: | + The poll loop reported readiness on attempt {{ check_status.output.attempt }}. + Write a single short sentence summarizing the result. + output: + summary: + type: string + description: One-sentence summary of the polling result. + routes: + - to: $end + +output: + result: "{{ summarize.output.summary }}" + attempts: "{{ check_status.output.attempt }}" diff --git a/plugins/conductor/skills/conductor/SKILL.md b/plugins/conductor/skills/conductor/SKILL.md index a9c6fbcf..5185f128 100644 --- a/plugins/conductor/skills/conductor/SKILL.md +++ b/plugins/conductor/skills/conductor/SKILL.md @@ -100,6 +100,7 @@ For runtime config, context modes, limits, and cost tracking, see [references/au | `routes` | Where agent goes next (`$end` to finish, `self` to loop) | | `type: script` | Shell command step (captures stdout, stderr, exit_code; JSON stdout is auto-merged) | | `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`) | | `parallel` | Static parallel groups (fixed agent list) | | `for_each` | Dynamic parallel groups (runtime-determined array; supports `type: workflow` agents) | diff --git a/plugins/conductor/skills/conductor/references/authoring.md b/plugins/conductor/skills/conductor/references/authoring.md index f545a641..0df873a7 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, or workflow + type: agent # agent (default), human_gate, script, workflow, or wait description: What it does model: gpt-5.2 # Override workflow default provider: claude # Optional: per-agent provider override @@ -97,9 +97,9 @@ agents: timeout_seconds: 120 # Hard wall-clock cancellation for this agent (provider-backed only). # Engine wraps execution in asyncio.wait_for(); raises AgentTimeoutError. # Effective limit = min(timeout_seconds, remaining_workflow_timeout). - # Non-retryable. Forbidden on script/human_gate/workflow types. + # Non-retryable. Forbidden on script/human_gate/workflow/wait types. - retry: # Per-agent retry policy (optional, not allowed on script/human_gate/workflow) + retry: # Per-agent retry policy (optional, not allowed on script/human_gate/workflow/wait) max_attempts: 3 # 1-10, default 1 (no retry) backoff: exponential # exponential (default) or fixed delay_seconds: 2.0 # Base delay (0-300, default 2.0) @@ -127,7 +127,7 @@ agents: - **Copilot**: forwarded as `reasoning_effort` on the session. Validated against the model's advertised `supported_reasoning_efforts`; raises `ValidationError` for unsupported combinations (skipped in mock-handler mode or when capability metadata is absent). - **Claude**: enables extended thinking via `thinking={"type": "enabled", "budget_tokens": N}` with mapping `low=2048`, `medium=8192`, `high=16384`, `xhigh=32768`. Auto-coerces `temperature` to `1.0` (logged at INFO) and bumps `max_tokens` to fit `budget + 4096` (capped at 64000, logged at INFO when clamped). Only valid on thinking-capable models (`claude-3-7-*`, `claude-opus-4*`, `claude-sonnet-4*`, `claude-haiku-4*`); raises `ValidationError` otherwise. -Both providers surface reasoning content via `agent_reasoning` events visible in the dashboard, JSONL logs, and the console at `-vv`. Not allowed on `script`, `human_gate`, or `workflow` agent types. +Both providers surface reasoning content via `agent_reasoning` events visible in the dashboard, JSONL logs, and the console at `-vv`. Not allowed on `script`, `human_gate`, `workflow`, or `wait` agent types. ```yaml runtime: @@ -253,6 +253,71 @@ routes: Script agents **cannot** have: `prompt`, `provider`, `model`, `tools`, `output`, `system_prompt`, `options`, `retry`, `reasoning`, `dialog`, `max_session_seconds`, `max_agent_iterations`, `timeout_seconds` (use `timeout:` instead), `input_mapping`, or `max_depth`. Command and args support Jinja2 templating for dynamic values. +## Wait Steps (`type: wait`) + +Pause workflow execution for a parsed duration via in-process `asyncio.sleep`. Cross-platform — no shell `sleep` dependency. Use for rate-limit cooldowns, polling intervals, and external-system catch-up. + +```yaml +agents: + - name: cooldown + type: wait + description: Cool down between API bursts # Optional + duration: 60s # Required (see "Duration format") + reason: Avoiding rate limit # Optional, shown in dashboard + routes: + - to: next_call +``` + +### Duration Format + +- Plain `int`/`float` → seconds (e.g. `60`, `1.5`). +- Suffixed string: `ms`, `s`, `m`, `h` (e.g. `"500ms"`, `"60s"`, `"2.5m"`, `"1h"`). +- Jinja2 template rendering to one of the above (templates defer literal validation to runtime): + ```yaml + duration: "{{ workflow.input.poll_interval_seconds }}s" + ``` +- Must resolve to `> 0` and `≤ 86400s` (24h). Booleans are rejected. + +### Wait Output + +Strict — only one field: + +```jinja2 +{{ wait_name.output.waited_seconds }} # Actual seconds slept (may be < requested on interrupt) +``` + +### Polling Loop-back Pattern + +```yaml +agents: + - name: check_status + type: script + command: ./poll-status.sh + routes: + - to: process_result + when: "status == 'ready'" + - to: wait_then_retry + + - name: wait_then_retry + type: wait + duration: "{{ workflow.input.poll_interval_seconds }}s" + routes: + - to: check_status # loop back + + - name: process_result + # ... +``` + +### Wait Cancellation + +- `Esc` / `Ctrl+G` cancels in-progress waits immediately (the engine races the sleep against the interrupt event). +- Workflow-level `limits.timeout_seconds` cancels in-flight waits via the standard timeout path. + +### Wait Restrictions + +Wait agents **cannot** have: `prompt`, `model`, `provider`, `tools`, `system_prompt`, `options`, `command`, `args`, `env`, `working_dir`, `timeout`, `workflow`, `input_mapping`, `max_depth`, `max_session_seconds`, `max_agent_iterations`, `retry`, `dialog`, `reasoning`, `timeout_seconds`, or `output`. They also cannot be used inside `parallel` groups or `for_each` groups. + +See `examples/wait-step.yaml` for a complete polling workflow. ## Set Steps Set steps evaluate one or more Jinja2 expressions and bind the typed results into context. No LLM call, no subprocess, no I/O — these are pure context transformations. Use them when you'd otherwise duplicate a Jinja expression across many prompts, run `echo`-only script steps, or burn a model call on something deterministic. @@ -405,7 +470,7 @@ agents: - to: writer ``` -Only valid on provider-backed agents (not `script`, `human_gate`, or `workflow`). See `examples/dialog-mode.yaml` for a complete example. +Only valid on provider-backed agents (not `script`, `human_gate`, `workflow`, or `wait`). See `examples/dialog-mode.yaml` for a complete example. ## Workflow Metadata and Workspace Instructions diff --git a/plugins/conductor/skills/conductor/references/yaml-schema.md b/plugins/conductor/skills/conductor/references/yaml-schema.md index e692e77a..0d615583 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", or "workflow" + type: string # "agent" (default), "human_gate", "script", "workflow", or "wait" description: string # What this agent does model: string # Override default_model provider: string # Per-agent provider override ("copilot" or "claude") @@ -145,14 +145,14 @@ agents: timeout_seconds: float # Hard wall-clock timeout (>=1.0); engine wraps in asyncio.wait_for(). # Effective limit = min(timeout_seconds, remaining_workflow_timeout). # Raises AgentTimeoutError; non-retryable. - # Forbidden on script (use 'timeout' instead), human_gate, workflow. + # Forbidden on script (use 'timeout' instead), human_gate, workflow, wait. # Per-agent reasoning effort (overrides runtime.default_reasoning_effort) - # Not allowed for script, human_gate, or workflow agent types. + # Not allowed for script, human_gate, workflow, or wait agent types. reasoning: effort: string # low, medium, high, or xhigh - # Per-agent retry policy (optional, not allowed for script, human_gate, or workflow agents) + # Per-agent retry policy (optional, not allowed for script, human_gate, workflow, or wait agents) retry: max_attempts: integer # Max attempts including first (1-10, default: 1 = no retry) backoff: string # "exponential" (default) or "fixed" @@ -199,7 +199,7 @@ agents: Both providers continue to surface reasoning content via `agent_reasoning` events visible in the dashboard, JSONL logs, and console at `-vv`. -Forbidden on agent types: `script`, `human_gate`, `workflow`. +Forbidden on agent types: `script`, `human_gate`, `workflow`, `wait`. ## Script Agent Schema @@ -231,6 +231,47 @@ Script agents always produce: {{ script_name.output.exit_code }} # Process exit code (0 = success) ``` +## Wait Agent Schema + +Wait agents pause workflow execution for a parsed duration via in-process `asyncio.sleep`. Cross-platform — no shell `sleep` dependency. Use for rate-limit cooldowns, polling intervals, and external-system catch-up. + +```yaml +agents: + - name: string + type: wait # Required + description: string # Optional + duration: string | number # Required: see "Duration format" below + reason: string # Optional: human-readable reason (shown in dashboard) + input: [string] # Optional: context dependencies + routes: # Required: routing rules + - to: string + when: string # May reference waited_seconds +``` + +### Duration Format + +`duration` accepts: + +- A plain `int` or `float` (interpreted as seconds): `duration: 60`, `duration: 1.5` +- A string with a unit suffix — `ms`, `s`, `m`, `h`: `"500ms"`, `"60s"`, `"2.5m"`, `"1h"` +- A Jinja2 template rendering to one of the above: `"{{ workflow.input.interval }}s"` + (templates defer literal validation to runtime) + +The resolved duration must be **> 0 and ≤ 24h** (`86400s`). Booleans are rejected. + +### Wait Output + +Wait agents produce a single, strict field: + +```jinja2 +{{ wait_name.output.waited_seconds }} # Actual seconds slept (may be < requested on interrupt) +``` + +### Wait Restrictions + +Forbidden fields: `prompt`, `model`, `provider`, `tools`, `system_prompt`, `options`, `command`, `args`, `env`, `working_dir`, `timeout`, `workflow`, `input_mapping`, `max_depth`, `max_session_seconds`, `max_agent_iterations`, `retry`, `dialog`, `reasoning`, `timeout_seconds`, `output`. Wait steps cannot be used inside `parallel` or `for_each` groups. + +`Esc` / `Ctrl+G` cancels in-progress waits. Workflow-level `limits.timeout_seconds` also cancels them. ## Set Agent Schema Set agents evaluate Jinja2 expressions and bind typed values into the workflow context — no LLM call, no subprocess: @@ -634,12 +675,14 @@ runtime: - All route targets must be valid agent names, group names, `$end`, or `self` - `when` conditions must be valid Jinja2 expressions - `human_gate` agents require `options` and `prompt` +- `wait` agents require `duration`; literal values must be `> 0` and `≤ 86400s` (24h) ### Parallel Group Validation - Must contain at least 2 agents - All referenced agents must exist - Route targets must be valid +- `script`, `workflow`, and `wait` steps cannot be used inside parallel groups ### For-Each Validation @@ -647,6 +690,7 @@ runtime: - `as` must be a valid Python identifier, not a reserved name - `max_concurrent` must be 1-100 - Nested for-each groups are not allowed +- `script` and `wait` steps cannot be used as inline agents in for-each groups ### Routing Validation diff --git a/src/conductor/cli/run.py b/src/conductor/cli/run.py index 04a1d9d1..930938b5 100644 --- a/src/conductor/cli/run.py +++ b/src/conductor/cli/run.py @@ -812,6 +812,19 @@ def on_event(self, event: WorkflowEvent) -> None: d.get("elapsed", 0.0), ) + elif t == "wait_completed": + interrupted = d.get("interrupted", False) + waited = d.get("waited_seconds", d.get("elapsed", 0.0)) + suffix = " (interrupted)" if interrupted else "" + verbose_log(f" Wait done: {d.get('agent_name', '?')} after {waited:.2f}s{suffix}") + + elif t == "wait_failed": + verbose_log( + f" Wait failed: {d.get('agent_name', '?')} — " + f"{d.get('error_type', 'Error')}: {d.get('message', 'unknown')}", + style="red", + ) + def display_usage_summary(usage_data: dict[str, Any], console: Console | None = None) -> None: """Display final usage summary with token counts and costs. diff --git a/src/conductor/config/schema.py b/src/conductor/config/schema.py index 4167d69c..79e658ca 100644 --- a/src/conductor/config/schema.py +++ b/src/conductor/config/schema.py @@ -10,8 +10,13 @@ from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator +from conductor.duration import parse_duration from conductor.providers.reasoning import ReasoningEffort +# Maximum allowed wait-step duration (24 hours). Anything longer almost +# certainly wants ``limits.timeout_seconds`` reconsidered first. +MAX_WAIT_DURATION_SECONDS = 24 * 60 * 60 + class InputDef(BaseModel): """Definition for a workflow input parameter.""" @@ -458,7 +463,7 @@ class AgentDef(BaseModel): description: str | None = None """Human-readable description of agent's purpose.""" - type: Literal["agent", "human_gate", "script", "set", "workflow"] | None = None + type: Literal["agent", "human_gate", "script", "set", "wait", "workflow"] | None = None """Agent type. Defaults to 'agent' if not specified.""" provider: Literal["copilot", "claude"] | None = None @@ -526,6 +531,23 @@ class AgentDef(BaseModel): timeout: int | None = None """Per-script timeout in seconds.""" + duration: str | int | float | None = None + """Duration to pause for ``type='wait'`` steps. + + Accepts: + - Plain ``int`` or ``float`` — interpreted as seconds. + - String with a unit suffix: ``ms``, ``s``, ``m``, ``h`` + (e.g. ``"500ms"``, ``"60s"``, ``"2.5m"``, ``"1h"``). + - A Jinja2 template that renders to one of the above + (e.g. ``"{{ workflow.input.poll_interval_seconds }}s"``). + + The resolved duration must be greater than 0 and no more than 24h. + Templated durations defer literal validation to runtime. + """ + + reason: str | None = None + """Optional human-readable reason shown in the dashboard for ``type='wait'`` steps.""" + value: str | None = None """Jinja2 expression bound into context (required for single-binding 'set' type). @@ -726,6 +748,20 @@ def validate_timeout(cls, v: int | None) -> int | None: raise ValueError("timeout must be a positive integer") return v + @field_validator("duration", mode="before") + @classmethod + def reject_bool_duration(cls, v: Any) -> Any: + """Reject boolean values for ``duration`` before Pydantic coerces them to int. + + Pydantic v2 coerces ``True``/``False`` to ``1``/``0`` when the union + accepts ``int``. Catch it pre-coercion so a YAML ``duration: true`` is + rejected with a clear message instead of silently becoming a 1-second + wait. + """ + if isinstance(v, bool): + raise ValueError(f"duration must be a number or duration string, not boolean: {v!r}") + return v + @model_validator(mode="after") def validate_agent_type(self) -> AgentDef: """Ensure agent has required fields for its type.""" @@ -825,6 +861,60 @@ def validate_agent_type(self) -> AgentDef: raise ValueError("workflow agents cannot have 'values' (only 'set' agents do)") if self.output_type is not None: raise ValueError("workflow agents cannot have 'output_type' (only 'set' agents do)") + elif self.type == "wait": + if self.duration is None: + raise ValueError("wait agents require 'duration'") + if self.prompt: + raise ValueError("wait agents cannot have 'prompt'") + if self.provider: + raise ValueError("wait agents cannot have 'provider'") + if self.model: + raise ValueError("wait agents cannot have 'model'") + if self.tools is not None: + raise ValueError("wait agents cannot have 'tools'") + if self.system_prompt: + raise ValueError("wait agents cannot have 'system_prompt'") + if self.options: + raise ValueError("wait agents cannot have 'options'") + if self.command: + raise ValueError("wait agents cannot have 'command'") + if self.args: + raise ValueError("wait agents cannot have 'args'") + if self.env: + raise ValueError("wait agents cannot have 'env'") + if self.working_dir: + raise ValueError("wait agents cannot have 'working_dir'") + if self.timeout is not None: + raise ValueError("wait agents cannot have 'timeout'") + if self.workflow: + raise ValueError("wait agents cannot have 'workflow'") + if self.input_mapping is not None: + raise ValueError("wait agents cannot have 'input_mapping'") + if self.max_depth is not None: + raise ValueError("wait agents cannot have 'max_depth'") + if self.max_session_seconds: + raise ValueError("wait agents cannot have 'max_session_seconds'") + if self.max_agent_iterations is not None: + raise ValueError("wait agents cannot have 'max_agent_iterations'") + if self.retry is not None: + raise ValueError("wait agents cannot have 'retry'") + if self.dialog is not None: + raise ValueError("wait agents cannot have 'dialog'") + if self.reasoning is not None: + raise ValueError("wait agents cannot have 'reasoning'") + if self.timeout_seconds is not None: + raise ValueError("wait agents cannot have 'timeout_seconds'") + if self.output is not None: + raise ValueError( + "wait agents cannot have 'output' (output is fixed: {'waited_seconds': float})" + ) + if self.value is not None: + raise ValueError("wait agents cannot have 'value' (only 'set' agents do)") + if self.values is not None: + raise ValueError("wait agents cannot have 'values' (only 'set' agents do)") + if self.output_type is not None: + raise ValueError("wait agents cannot have 'output_type' (only 'set' agents do)") + self._validate_wait_duration() elif self.type == "set": if (self.value is None) == (self.values is None): raise ValueError("set agents require exactly one of 'value' or 'values'") @@ -873,6 +963,10 @@ def validate_agent_type(self) -> AgentDef: raise ValueError("set agents cannot have 'reasoning'") if self.timeout_seconds is not None: 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)") else: # Regular agent or human_gate — input_mapping is not valid if self.input_mapping is not None: @@ -902,8 +996,51 @@ 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. + 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: + raise ValueError( + f"'{self.type or 'agent'}' agents cannot have 'reason' " + "(only wait agents support reason)" + ) return self + def _validate_wait_duration(self) -> None: + """Validate ``duration`` for a ``wait`` agent. + + Templated durations (containing ``{{``) defer all literal + validation to runtime; for everything else we parse the value + and enforce ``0 < d <= MAX_WAIT_DURATION_SECONDS``. + + Note: Booleans are already rejected pre-coercion by the + :meth:`reject_bool_duration` ``mode="before"`` field validator, + so this method never sees ``True``/``False``. + """ + value = self.duration + + if isinstance(value, str) and "{{" in value: + return + + try: + seconds = parse_duration(value) # type: ignore[arg-type] + except ValueError as exc: + raise ValueError(f"wait duration is invalid: {exc}") from exc + + if seconds <= 0: + raise ValueError(f"wait duration must be > 0 seconds (got {seconds!r})") + if seconds > MAX_WAIT_DURATION_SECONDS: + raise ValueError( + f"wait duration {seconds!r}s exceeds the 24h cap " + f"({MAX_WAIT_DURATION_SECONDS}s); reconsider using " + "'limits.timeout_seconds' instead" + ) + class MCPServerDef(BaseModel): """Definition for an MCP server.""" diff --git a/src/conductor/config/validator.py b/src/conductor/config/validator.py index 0b887643..1f88e625 100644 --- a/src/conductor/config/validator.py +++ b/src/conductor/config/validator.py @@ -171,8 +171,8 @@ def validate_workflow_config( errors.extend(input_errors) warnings.extend(input_warnings) - # Validate tool references (skip for script and set agents, they don't use tools) - if agent.tools is not None and agent.tools and agent.type not in ("script", "set"): + # Validate tool references (skip for script, set, and wait agents — they don't use tools) + if agent.tools is not None and agent.tools and agent.type not in ("script", "set", "wait"): tool_errors = _validate_tool_references(agent.name, agent.tools, set(config.tools)) errors.extend(tool_errors) @@ -204,13 +204,18 @@ def validate_workflow_config( parallel_errors = _validate_parallel_groups(config) errors.extend(parallel_errors) - # Validate for_each groups: reject script steps as inline agents + # Validate for_each groups: reject script and wait steps as inline agents for for_each_group in config.for_each: if for_each_group.agent.type == "script": errors.append( f"For-each group '{for_each_group.name}' uses a script step as its " "inline agent. Script steps cannot be used in for_each groups." ) + if for_each_group.agent.type == "wait": + errors.append( + 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." + ) # Validate sub-workflow references (local paths and registry refs). # Skipped when workflow_path is not provided — relative paths cannot be @@ -493,6 +498,13 @@ def _validate_parallel_groups(config: WorkflowConfig) -> list[str]: "Script steps cannot be used in parallel groups." ) + # Validate no wait steps in parallel groups + if agent.type == "wait": + errors.append( + f"Agent '{agent_name}' in parallel group '{pg.name}' is a wait step. " + "Wait steps cannot be used in parallel groups." + ) + # Validate no workflow steps in parallel groups if agent.type == "workflow": errors.append( @@ -1385,7 +1397,7 @@ def _validate_template_references( ) elif ( is_explicit - and agent.type not in ("script", "set", "workflow", "human_gate") + and agent.type not in ("script", "set", "workflow", "human_gate", "wait") and input_name not in declared_workflow_inputs ): warnings.append( diff --git a/src/conductor/duration.py b/src/conductor/duration.py new file mode 100644 index 00000000..1f70d377 --- /dev/null +++ b/src/conductor/duration.py @@ -0,0 +1,83 @@ +"""Duration parsing for Conductor workflow steps. + +This module provides ``parse_duration`` for converting user-supplied +duration values (plain numbers or suffixed strings like ``"5m"``, +``"500ms"``, ``"1h"``) into a float seconds value. Used by the +``wait`` step type and shared as a primitive for other duration-aware +features. + +The parser raises :class:`ValueError` on invalid input so it nests +cleanly inside Pydantic ``ValidationError`` when called from schema +validators. Bounds checks (e.g., > 0, 24h cap) are intentionally left +to callers so the same parser can be reused for different policies. +""" + +from __future__ import annotations + +import re + +_DURATION_PATTERN = re.compile(r"^\s*(?P\d+(?:\.\d+)?)\s*(?Pms|s|m|h)?\s*$") + +_UNIT_TO_SECONDS: dict[str, float] = { + "ms": 1e-3, + "s": 1.0, + "m": 60.0, + "h": 3600.0, +} + + +def parse_duration(value: str | int | float) -> float: + """Parse a duration value into seconds. + + Accepts: + * Plain ``int`` or ``float`` — interpreted as seconds. + * Strings matching ```` where unit is one of + ``ms``, ``s``, ``m``, ``h``. Whitespace around the value and + between number/unit is tolerated. Omitting the unit defaults + to seconds. + + Examples:: + + parse_duration(60) # 60.0 + parse_duration(1.5) # 1.5 + parse_duration("60") # 60.0 + parse_duration("60s") # 60.0 + parse_duration("5m") # 300.0 + parse_duration("1h") # 3600.0 + parse_duration("500ms") # 0.5 + parse_duration("2.5m") # 150.0 + + Args: + value: The duration to parse. + + Returns: + Duration in seconds as a ``float``. + + Raises: + ValueError: If ``value`` is not a recognized duration. The + message is suitable for surfacing directly to a user in a + Pydantic ``ValidationError``. + """ + # Reject bool explicitly — Pydantic v2 / Python treat ``True`` as ``int(1)`` + # in many contexts, but accepting it here is almost certainly a mistake. + if isinstance(value, bool): + raise ValueError(f"duration must be a number or duration string, not boolean: {value!r}") + + if isinstance(value, (int, float)): + return float(value) + + if not isinstance(value, str): + raise ValueError( + f"duration must be a number or string like '60s'/'5m'/'1h', got {type(value).__name__}" + ) + + match = _DURATION_PATTERN.match(value) + if match is None: + raise ValueError( + f"duration {value!r} is not a valid duration; expected a number " + "or a value like '60s', '5m', '1h', '500ms'" + ) + + number = float(match.group("value")) + unit = match.group("unit") or "s" + return number * _UNIT_TO_SECONDS[unit] diff --git a/src/conductor/engine/context.py b/src/conductor/engine/context.py index f3025ad3..148a2523 100644 --- a/src/conductor/engine/context.py +++ b/src/conductor/engine/context.py @@ -27,7 +27,7 @@ # once at startup and present for the lifetime of the run. Per-step agent # outputs remain explicitly declared in ``input:`` for traceability, even for # local renders. -_LOCAL_RENDER_AGENT_TYPES = frozenset({"script", "set", "workflow"}) +_LOCAL_RENDER_AGENT_TYPES = frozenset({"script", "set", "wait", "workflow"}) def estimate_tokens(text: str) -> int: diff --git a/src/conductor/engine/workflow.py b/src/conductor/engine/workflow.py index bec22a4c..8bf9b08d 100644 --- a/src/conductor/engine/workflow.py +++ b/src/conductor/engine/workflow.py @@ -18,6 +18,7 @@ from pathlib import Path from typing import TYPE_CHECKING, Any +from conductor.duration import parse_duration from conductor.engine.checkpoint import CheckpointManager from conductor.engine.context import WorkflowContext from conductor.engine.limits import LimitEnforcer @@ -46,6 +47,7 @@ render_set_value_repr, ) from conductor.executor.template import TemplateRenderer +from conductor.executor.wait import WaitExecutor, WaitOutput from conductor.gates.human import ( GateResult, HumanGateHandler, @@ -366,6 +368,7 @@ def __init__( self.max_iterations_handler = MaxIterationsHandler(skip_gates=skip_gates) self.script_executor = ScriptExecutor() self.set_executor = SetExecutor() + self.wait_executor = WaitExecutor() self.usage_tracker = UsageTracker( pricing_overrides=self._build_pricing_overrides(), ) @@ -748,6 +751,32 @@ async def _execute_script(self, agent: AgentDef, context: dict[str, Any]) -> Scr operation_name=f"script '{agent.name}'", ) + async def _execute_wait(self, agent: AgentDef, context: dict[str, Any]) -> WaitOutput: + """Execute a wait step with workflow-level timeout enforcement. + + The wait races ``asyncio.sleep`` against the engine's + ``interrupt_event`` so Esc / Ctrl+G cancels an in-flight wait + immediately. The outer ``wait_for_with_timeout`` ensures the + workflow-level ``limits.timeout_seconds`` still fires if it + would expire before the wait completes. + + Args: + agent: Wait agent definition. + context: Workflow context for template rendering. + + Returns: + :class:`WaitOutput` with elapsed seconds and interrupt flag. + + Raises: + ValidationError: If the rendered duration is invalid. + ConductorTimeoutError: If the workflow timeout fires while + the wait is in progress. + """ + return await self.limits.wait_for_with_timeout( + self.wait_executor.execute(agent, context, interrupt_event=self._interrupt_event), + operation_name=f"wait '{agent.name}'", + ) + async def _run_set_step(self, agent: AgentDef, agent_context: dict[str, Any]) -> SetOutput: """Execute a set step end-to-end with full event + validation parity. @@ -2480,6 +2509,147 @@ async def _execute_loop(self, current_agent_name: str) -> dict[str, Any]: ) continue + # Handle wait steps + if agent.type == "wait": + agent_context = self.context.build_for_agent( + agent.name, + agent.input, + mode=self.config.workflow.context.mode, + agent_type=agent.type, + ) + _wait_start = _time.time() + + wait_execution_count = ( + self.limits.get_agent_execution_count(agent.name) + 1 + ) + + # Resolve the duration up-front so the + # ``wait_started`` event includes the parsed + # value (the dashboard renders a sleeping + # pill keyed off this). Failures here are + # preview-only — the canonical render+parse + # runs inside ``_execute_wait`` below and + # will surface the real error via + # ``wait_failed``. Log at debug so the + # preview path is still observable. + try: + rendered_duration = self.renderer.render( + str(agent.duration), agent_context + ) + preview_duration_seconds: float | None = parse_duration( + rendered_duration + ) + except Exception as exc: # noqa: BLE001 — defensive preview + logger.debug( + "wait_started preview duration render failed for %s: %s", + agent.name, + exc, + ) + preview_duration_seconds = None + preview_reason: str | None = None + if agent.reason is not None: + try: + preview_reason = self.renderer.render( + agent.reason, agent_context + ) + except Exception as exc: # noqa: BLE001 — defensive preview + # Do NOT fall back to the raw + # template string — the dashboard + # would then display literal + # ``{{ ... }}`` markup. ``None`` is + # the correct "absent" signal. + logger.debug( + "wait_started preview reason render failed for %s: %s", + agent.name, + exc, + ) + preview_reason = None + + self._emit( + "wait_started", + { + "agent_name": agent.name, + "iteration": wait_execution_count, + "duration_seconds": preview_duration_seconds, + "reason": preview_reason, + }, + ) + + try: + wait_output = await self._execute_wait(agent, agent_context) + except Exception as exc: + _wait_elapsed = _time.time() - _wait_start + self._emit( + "wait_failed", + { + "agent_name": agent.name, + "elapsed": _wait_elapsed, + "error_type": type(exc).__name__, + "message": str(exc), + }, + ) + raise + _wait_elapsed = _time.time() - _wait_start + + # Public output contract (per issue #218): + # only ``waited_seconds`` is exposed in the + # workflow context. Extra metadata lives in + # the event payload below for the dashboard. + output_content: dict[str, Any] = { + "waited_seconds": wait_output.waited_seconds, + } + + self._emit( + "wait_completed", + { + "agent_name": agent.name, + "elapsed": _wait_elapsed, + "waited_seconds": wait_output.waited_seconds, + "requested_seconds": wait_output.requested_seconds, + "reason": wait_output.reason, + "interrupted": wait_output.interrupted, + }, + ) + + self.context.store(agent.name, output_content) + self.limits.record_execution(agent.name) + self.limits.check_timeout() + + route_result = self._evaluate_routes(agent, output_content) + + self._emit( + "route_taken", + { + "from_agent": agent.name, + "to_agent": route_result.target, + }, + ) + + if route_result.target == "$end": + result = self._build_final_output(route_result.output_transform) + self._emit( + "workflow_completed", + { + "elapsed": _time.time() - _workflow_start, + "output": result, + }, + ) + self._execute_hook("on_complete", result=result) + return result + + current_agent_name = route_result.target + + # Check for interrupt after wait step. If the + # sleep was cut short by ``interrupt_event``, + # the flag is still set here and triggers the + # normal interrupt menu / web-mode handling. + interrupt_result = await self._check_interrupt(current_agent_name) + if interrupt_result is not None: + current_agent_name = await self._handle_interrupt_result( + interrupt_result, current_agent_name + ) + continue + # Handle set steps. Pure context transformations: # render, coerce, validate, emit, route. if agent.type == "set": diff --git a/src/conductor/executor/__init__.py b/src/conductor/executor/__init__.py index e33cd38a..03c30204 100644 --- a/src/conductor/executor/__init__.py +++ b/src/conductor/executor/__init__.py @@ -8,12 +8,15 @@ from conductor.executor.output import parse_json_output, validate_output from conductor.executor.script import ScriptExecutor, ScriptOutput from conductor.executor.template import TemplateRenderer +from conductor.executor.wait import WaitExecutor, WaitOutput __all__ = [ "AgentExecutor", "ScriptExecutor", "ScriptOutput", "TemplateRenderer", + "WaitExecutor", + "WaitOutput", "parse_json_output", "resolve_agent_tools", "validate_output", diff --git a/src/conductor/executor/wait.py b/src/conductor/executor/wait.py new file mode 100644 index 00000000..0e65e3f1 --- /dev/null +++ b/src/conductor/executor/wait.py @@ -0,0 +1,193 @@ +"""Wait step execution for Conductor workflow steps. + +This module provides the :class:`WaitExecutor` for ``type: wait`` agent +definitions. A wait step pauses workflow execution for a parsed duration +via :func:`asyncio.sleep`. The sleep races against an optional +``interrupt_event`` so Esc / Ctrl+G cancels an in-flight wait +immediately; workflow-level timeout enforcement is layered on top by +the engine via :meth:`LimitEnforcer.wait_for_with_timeout`. +""" + +from __future__ import annotations + +import asyncio +import contextlib +import time +from dataclasses import dataclass +from typing import TYPE_CHECKING, Any + +from conductor.config.schema import MAX_WAIT_DURATION_SECONDS +from conductor.duration import parse_duration +from conductor.exceptions import ValidationError +from conductor.executor.template import TemplateRenderer + + +def _verbose_log(message: str, style: str = "dim") -> None: + """Log a verbose message via the CLI run module. + + Uses a deferred import to avoid a circular import between + executor.wait and cli.run (cli.run imports WorkflowEngine which + imports executor modules). + """ + from conductor.cli.run import verbose_log + + verbose_log(message, style) + + +if TYPE_CHECKING: + from conductor.config.schema import AgentDef + + +@dataclass +class WaitOutput: + """Result of a wait step execution. + + Attributes: + waited_seconds: Wall-clock seconds actually slept. May be less + than ``requested_seconds`` if an interrupt cut the sleep short. + requested_seconds: Parsed duration value from the agent config. + reason: The rendered ``reason`` field, or ``None`` if not set. + interrupted: ``True`` if an interrupt signal cancelled the sleep + before ``requested_seconds`` elapsed. + """ + + waited_seconds: float + requested_seconds: float + reason: str | None + interrupted: bool + + +class WaitExecutor: + """Executes wait steps via :func:`asyncio.sleep`. + + Renders the agent's ``duration`` (and optional ``reason``) Jinja2 + templates, parses the duration string, then sleeps. If an + ``interrupt_event`` is provided, the sleep is raced against it so + the engine's Esc/Ctrl+G handler can cancel an in-flight wait + without waiting for the full duration. + + Example:: + + executor = WaitExecutor() + output = await executor.execute(agent, context, interrupt_event=ev) + print(output.waited_seconds, output.interrupted) + """ + + def __init__(self) -> None: + """Initialize the WaitExecutor with a template renderer.""" + self.renderer = TemplateRenderer() + + async def execute( + self, + agent: AgentDef, + context: dict[str, Any], + interrupt_event: asyncio.Event | None = None, + ) -> WaitOutput: + """Execute a wait step. + + Renders ``agent.duration`` and ``agent.reason`` with Jinja2, + parses the duration, then sleeps. Honors ``interrupt_event`` + for early cancellation. Does NOT clear ``interrupt_event`` — + the engine's between-step interrupt check consumes it after + the wait returns so the user gets the normal interrupt menu. + + Args: + agent: Agent definition with ``type='wait'``. + context: Workflow context for template rendering. + interrupt_event: Optional event signaling user interrupt. + + Returns: + :class:`WaitOutput` with elapsed time and interrupt flag. + + Raises: + ValidationError: If the rendered duration cannot be parsed + or falls outside ``(0, 24h]``. + """ + if agent.duration is None: + # Defensive: the schema validator forbids this, but keep a + # clear error in case of bypass. + raise ValidationError( + f"Wait '{agent.name}': duration is required", + ) + + # Render duration through Jinja2 (templated durations are common + # for poll-interval patterns). Coerce to str so int/float values + # render predictably. + rendered_duration = self.renderer.render(str(agent.duration), context) + rendered_reason: str | None = None + if agent.reason is not None: + rendered_reason = self.renderer.render(agent.reason, context) + + try: + seconds = parse_duration(rendered_duration) + except ValueError as exc: + raise ValidationError( + f"Wait '{agent.name}': {exc}", + suggestion=( + "Provide a number of seconds or a duration string " + "like '60s', '5m', '1h', '500ms'." + ), + ) from exc + + if seconds <= 0: + raise ValidationError( + f"Wait '{agent.name}': duration must be > 0 seconds (got {seconds!r})", + ) + if seconds > MAX_WAIT_DURATION_SECONDS: + raise ValidationError( + f"Wait '{agent.name}': duration {seconds!r}s exceeds the " + f"24h cap ({MAX_WAIT_DURATION_SECONDS}s)", + suggestion="Reconsider using 'limits.timeout_seconds' instead.", + ) + + _verbose_log(f" Wait: {seconds}s" + (f" — {rendered_reason}" if rendered_reason else "")) + + start = time.monotonic() + interrupted = await self._sleep_with_interrupt(seconds, interrupt_event) + elapsed = time.monotonic() - start + + return WaitOutput( + waited_seconds=elapsed, + requested_seconds=seconds, + reason=rendered_reason, + interrupted=interrupted, + ) + + @staticmethod + async def _sleep_with_interrupt(seconds: float, interrupt_event: asyncio.Event | None) -> bool: + """Sleep for ``seconds``, returning early on interrupt. + + Returns: + ``True`` if the sleep was cancelled by ``interrupt_event``, + ``False`` if the full duration elapsed. + """ + if interrupt_event is None: + await asyncio.sleep(seconds) + return False + + sleep_task = asyncio.create_task(asyncio.sleep(seconds)) + interrupt_task = asyncio.create_task(interrupt_event.wait()) + try: + done, pending = await asyncio.wait( + {sleep_task, interrupt_task}, + return_when=asyncio.FIRST_COMPLETED, + ) + for t in pending: + t.cancel() + with contextlib.suppress(asyncio.CancelledError): + await t + except BaseException: + # Cancellation from outside (e.g., workflow timeout) — clean + # up both tasks and re-raise so wait_for / outer cancellation + # handlers see the original exception. Only suppress + # CancelledError during cleanup (matches the success path + # above); a genuine exception from a future, non-trivial + # awaitable should not be silently swallowed. + for t in (sleep_task, interrupt_task): + if not t.done(): + t.cancel() + with contextlib.suppress(asyncio.CancelledError): + await t + raise + + return interrupt_task in done diff --git a/src/conductor/web/frontend/src/components/detail/DetailPanel.tsx b/src/conductor/web/frontend/src/components/detail/DetailPanel.tsx index a09b389c..fb72e088 100644 --- a/src/conductor/web/frontend/src/components/detail/DetailPanel.tsx +++ b/src/conductor/web/frontend/src/components/detail/DetailPanel.tsx @@ -9,6 +9,7 @@ import { GateDetail } from './GateDetail'; import { GroupDetail } from './GroupDetail'; import { DialogEngagementPrompt } from './DialogEngagementPrompt'; import { SubworkflowDetail } from './SubworkflowDetail'; +import { WaitDetail } from './WaitDetail'; import { cn } from '@/lib/utils'; export function DetailPanel() { @@ -48,6 +49,8 @@ export function DetailPanel() { switch (node.type) { case 'script': return ScriptDetail; + case 'wait': + return WaitDetail; case 'set': return SetDetail; case 'human_gate': diff --git a/src/conductor/web/frontend/src/components/detail/WaitDetail.tsx b/src/conductor/web/frontend/src/components/detail/WaitDetail.tsx new file mode 100644 index 00000000..d1ca5d51 --- /dev/null +++ b/src/conductor/web/frontend/src/components/detail/WaitDetail.tsx @@ -0,0 +1,46 @@ +import { MetadataGrid } from './MetadataGrid'; +import type { NodeData } from '@/stores/workflow-store'; +import { NODE_STATUS_HEX } from '@/lib/constants'; +import { formatElapsed } from '@/lib/utils'; +import type { NodeStatus } from '@/lib/constants'; + +interface WaitDetailProps { + node: NodeData; +} + +export function WaitDetail({ node }: WaitDetailProps) { + const status = node.status as NodeStatus; + const statusColor = NODE_STATUS_HEX[status] || NODE_STATUS_HEX.pending; + + const items: Array<{ label: string; value: string | number | null | undefined }> = []; + const requested = node.requested_seconds ?? node.duration_seconds; + if (requested != null) items.push({ label: 'Requested', value: formatElapsed(requested) }); + if (node.waited_seconds != null) { + items.push({ label: 'Waited', value: formatElapsed(node.waited_seconds) }); + } else if (node.elapsed != null) { + items.push({ label: 'Elapsed', value: formatElapsed(node.elapsed) }); + } + if (node.interrupted) items.push({ label: 'Interrupted', value: 'yes' }); + if (node.reason) items.push({ label: 'Reason', value: node.reason }); + if (node.error_type) items.push({ label: 'Error', value: node.error_type }); + if (node.error_message) items.push({ label: 'Message', value: node.error_message }); + + return ( +
+
+ + {status} + + Wait +
+ + +
+ ); +} diff --git a/src/conductor/web/frontend/src/components/graph/WaitNode.tsx b/src/conductor/web/frontend/src/components/graph/WaitNode.tsx new file mode 100644 index 00000000..4c25e24c --- /dev/null +++ b/src/conductor/web/frontend/src/components/graph/WaitNode.tsx @@ -0,0 +1,150 @@ +import { memo, useEffect, useRef, useState } from 'react'; +import { Handle, Position, type NodeProps } from '@xyflow/react'; +import { Clock } from 'lucide-react'; +import { cn, formatElapsed } from '@/lib/utils'; +import { NODE_STATUS_HEX } from '@/lib/constants'; +import { useWorkflowStore } from '@/stores/workflow-store'; +import { useViewedNodes } from '@/hooks/use-viewed-context'; +import { NodeTooltip } from './NodeTooltip'; +import type { GraphNodeData } from './graph-layout'; +import type { NodeStatus } from '@/lib/constants'; + +export const WaitNode = memo(function WaitNode({ 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 duration = nd?.duration_seconds ?? nd?.requested_seconds; + const waited = nd?.waited_seconds; + const elapsed = nd?.elapsed; + const interrupted = nd?.interrupted; + const errorType = nd?.error_type; + const errorMessage = nd?.error_message; + + const liveElapsed = useLiveElapsed(id, status); + const transitionClass = useStatusTransition(status); + + const statsLine = (() => { + if (status === 'failed' && errorMessage) { + const msg = errorMessage.length > 40 ? errorMessage.slice(0, 37) + '...' : errorMessage; + return { text: msg, className: 'text-red-400' }; + } + if (status === 'running') { + const target = typeof duration === 'number' ? ` / ${formatElapsed(duration)}` : ''; + return { text: `${liveElapsed}${target}`, className: 'text-[var(--text-muted)]' }; + } + if (status === 'completed') { + const parts: string[] = []; + if (waited != null) parts.push(formatElapsed(waited)); + else if (elapsed != null) parts.push(formatElapsed(elapsed)); + if (interrupted) parts.push('interrupted'); + return { text: parts.join(' · ') || null, className: 'text-[var(--text-muted)]' }; + } + if (status === 'pending' && typeof duration === 'number') { + return { text: formatElapsed(duration), className: 'text-[var(--text-muted)]' }; + } + return { text: null, className: '' }; + })(); + + return ( + <> + + +
+
+ +
+
+ {nodeData.label} + {statsLine.text && ( + + {statsLine.text} + + )} +
+
+
+ + + ); +}); + +function useLiveElapsed(id: string, status: NodeStatus): string { + const startedAt = useViewedNodes()[id]?.startedAt; + const replayMode = useWorkflowStore((s) => s.replayMode); + const lastEventTime = useWorkflowStore((s) => s.lastEventTime); + const [display, setDisplay] = useState('0.0s'); + const rafRef = useRef | null>(null); + + useEffect(() => { + if (status === 'running') { + if (replayMode) { + if (rafRef.current) clearInterval(rafRef.current); + const origin = startedAt ?? (lastEventTime ?? 0); + const now = lastEventTime ?? origin; + setDisplay(formatElapsed(now - origin)); + return; + } + const origin = startedAt != null ? startedAt * 1000 : Date.now(); + const tick = () => { + const sec = (Date.now() - origin) / 1000; + setDisplay(formatElapsed(sec)); + }; + tick(); + rafRef.current = setInterval(tick, 1000); + return () => { + if (rafRef.current) clearInterval(rafRef.current); + }; + } else { + if (rafRef.current) clearInterval(rafRef.current); + } + }, [status, startedAt, replayMode, lastEventTime]); + + return display; +} + +function useStatusTransition(status: NodeStatus): string { + const prevStatusRef = useRef(status); + const [transitionClass, setTransitionClass] = useState(''); + + useEffect(() => { + const prev = prevStatusRef.current; + prevStatusRef.current = status; + if (prev === status) return; + + if (status === 'running') { + setTransitionClass('node-activate'); + } else if (prev === 'running' && (status === 'completed' || status === 'failed')) { + setTransitionClass(status === 'completed' ? 'node-complete' : 'node-fail'); + } + + const timer = setTimeout(() => setTransitionClass(''), 400); + return () => clearTimeout(timer); + }, [status]); + + return transitionClass; +} diff --git a/src/conductor/web/frontend/src/components/graph/WorkflowGraph.tsx b/src/conductor/web/frontend/src/components/graph/WorkflowGraph.tsx index 296364cf..cc9515a5 100644 --- a/src/conductor/web/frontend/src/components/graph/WorkflowGraph.tsx +++ b/src/conductor/web/frontend/src/components/graph/WorkflowGraph.tsx @@ -25,6 +25,7 @@ import { SetNode } from './SetNode'; import { GateNode } from './GateNode'; import { GroupNode } from './GroupNode'; import { WorkflowNode } from './WorkflowNode'; +import { WaitNode } from './WaitNode'; import { EndNode } from './EndNode'; import { StartNode } from './StartNode'; import { IngressNode } from './IngressNode'; @@ -42,6 +43,7 @@ const nodeTypes: NodeTypes = { gateNode: GateNode, groupNode: GroupNode, workflowNode: WorkflowNode, + waitNode: WaitNode, 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 ea9857ec..7bde599e 100644 --- a/src/conductor/web/frontend/src/components/graph/graph-layout.ts +++ b/src/conductor/web/frontend/src/components/graph/graph-layout.ts @@ -120,6 +120,7 @@ export function buildGraphElements( else if (nodeType === 'set') flowNodeType = 'setNode'; else if (nodeType === 'human_gate') flowNodeType = 'gateNode'; else if (nodeType === 'workflow') flowNodeType = 'workflowNode'; + else if (nodeType === 'wait') flowNodeType = 'waitNode'; flowNodes.push({ id: a.name, diff --git a/src/conductor/web/frontend/src/lib/constants.ts b/src/conductor/web/frontend/src/lib/constants.ts index c1e5b2f7..28dd21c6 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' | 'start' | 'end' | 'ingress' | 'egress'; +export type NodeType = 'agent' | 'script' | 'set' | 'human_gate' | 'parallel_group' | 'for_each_group' | 'workflow' | 'wait' | '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 2b15bd5f..730620bd 100644 --- a/src/conductor/web/frontend/src/stores/workflow-store.ts +++ b/src/conductor/web/frontend/src/stores/workflow-store.ts @@ -14,6 +14,9 @@ import type { AgentMessageData, ScriptCompletedData, ScriptFailedData, + WaitStartedData, + WaitCompletedData, + WaitFailedData, SetCompletedData, SetFailedData, GatePresentedData, @@ -107,6 +110,12 @@ export interface NodeData { stdout?: string; stderr?: string; exit_code?: number; + // Wait-specific (issue #218) + duration_seconds?: number | null; + waited_seconds?: number; + requested_seconds?: number; + reason?: string | null; + interrupted?: boolean; // Set-step-specific (issue #221) set_output_type?: import('@/types/events').SetOutputType; set_output_keys?: string[]; @@ -1222,6 +1231,43 @@ const eventHandlers: Record { + const data = _data as unknown as WaitStartedData; + const t = activeTarget(state, _data); + const nd = ensureNode(t.nodes, data.agent_name); + nd.status = 'running'; + nd.startedAt = timestamp ?? Date.now() / 1000; + nd.duration_seconds = data.duration_seconds ?? null; + nd.reason = data.reason ?? null; + nd.iteration = data.iteration; + replaceNode(t.nodes, data.agent_name); + }, + + wait_completed: (state, _data) => { + const data = _data as unknown as WaitCompletedData; + const t = activeTarget(state, _data); + const nd = ensureNode(t.nodes, data.agent_name); + nd.status = 'completed'; + t.incrCompleted(); + nd.elapsed = data.elapsed; + nd.waited_seconds = data.waited_seconds; + nd.requested_seconds = data.requested_seconds; + nd.reason = data.reason ?? null; + nd.interrupted = data.interrupted; + replaceNode(t.nodes, data.agent_name); + }, + + wait_failed: (state, _data) => { + const data = _data as unknown as WaitFailedData; + const t = activeTarget(state, _data); + const nd = ensureNode(t.nodes, data.agent_name); + nd.status = 'failed'; + nd.elapsed = data.elapsed; + nd.error_type = data.error_type; + nd.error_message = data.message; + replaceNode(t.nodes, data.agent_name); + }, + set_started: (state, _data, timestamp) => { const data = _data as { agent_name: string }; const t = activeTarget(state, _data); @@ -1816,6 +1862,32 @@ function buildLogEntry(event: WorkflowEvent): LogEntry | null { case 'script_failed': return { timestamp: ts, level: 'error', source: String(d.agent_name), message: `Script failed: ${d.message || d.error_type || 'unknown error'}` }; + case 'wait_started': { + const dur = d.duration_seconds as number | null | undefined; + const reason = d.reason as string | null | undefined; + const durStr = typeof dur === 'number' ? formatSec(dur) : '?'; + return { + timestamp: ts, + level: 'info', + source: String(d.agent_name), + message: `Waiting ${durStr}${reason ? ` — ${reason}` : ''}`, + }; + } + + case 'wait_completed': { + const waited = d.waited_seconds as number | undefined; + const interrupted = d.interrupted as boolean | undefined; + return { + timestamp: ts, + level: 'success', + source: String(d.agent_name), + message: `Wait completed${waited != null ? ` (${formatSec(waited)})` : ''}${interrupted ? ' — interrupted' : ''}`, + }; + } + + case 'wait_failed': + return { timestamp: ts, level: 'error', source: String(d.agent_name), message: `Wait failed: ${d.message || d.error_type || 'unknown error'}` }; + case 'set_started': return { timestamp: ts, level: 'info', source: String(d.agent_name), message: 'Set started' }; @@ -1984,6 +2056,32 @@ function buildActivityLogEntry(event: WorkflowEvent): ActivityLogEntry | null { case 'script_failed': return { timestamp: ts, source: String(d.agent_name), type: 'turn', message: `Script failed: ${d.message || d.error_type || 'unknown'}` }; + case 'wait_started': { + const dur = d.duration_seconds as number | null | undefined; + const reason = d.reason as string | null | undefined; + const durStr = typeof dur === 'number' ? formatSec(dur) : '?'; + return { + timestamp: ts, + source: String(d.agent_name), + type: 'turn', + message: `Waiting ${durStr}${reason ? ` — ${reason}` : ''}`, + }; + } + + case 'wait_completed': { + const waited = d.waited_seconds as number | undefined; + const interrupted = d.interrupted as boolean | undefined; + return { + timestamp: ts, + source: String(d.agent_name), + type: 'tool-complete', + message: `Wait completed${waited != null ? ` (${formatSec(waited)})` : ''}${interrupted ? ' — interrupted' : ''}`, + }; + } + + case 'wait_failed': + return { timestamp: ts, source: String(d.agent_name), type: 'turn', message: `Wait failed: ${d.message || d.error_type || 'unknown'}` }; + case 'set_started': return { timestamp: ts, source: String(d.agent_name), type: 'turn', message: 'Set started' }; diff --git a/src/conductor/web/frontend/src/types/events.ts b/src/conductor/web/frontend/src/types/events.ts index c1ae1ac0..0378e187 100644 --- a/src/conductor/web/frontend/src/types/events.ts +++ b/src/conductor/web/frontend/src/types/events.ts @@ -20,6 +20,9 @@ export type EventType = | 'script_started' | 'script_completed' | 'script_failed' + | 'wait_started' + | 'wait_completed' + | 'wait_failed' | 'set_started' | 'set_completed' | 'set_failed' @@ -160,6 +163,35 @@ export interface ScriptFailedData { message?: string; } +// --- Wait lifecycle (issue #218) --- + +export interface WaitStartedData { + agent_name: string; + iteration?: number; + /** Parsed duration in seconds (null if the template could not be pre-rendered). */ + duration_seconds?: number | null; + reason?: string | null; +} + +export interface WaitCompletedData { + agent_name: string; + elapsed?: number; + /** Actual wall-clock seconds slept. */ + waited_seconds: number; + /** Parsed requested duration. */ + requested_seconds: number; + reason?: string | null; + /** True if an interrupt cut the wait short. */ + interrupted?: boolean; +} + +export interface WaitFailedData { + agent_name: string; + elapsed?: number; + error_type?: string; + message?: string; +} + // --- Set step lifecycle (issue #221) --- /** Effective output-type label used during coercion. Mirrors the schema's diff --git a/src/conductor/web/frontend/tsconfig.tsbuildinfo b/src/conductor/web/frontend/tsconfig.tsbuildinfo index fe4ed494..38ae2ef3 100644 --- a/src/conductor/web/frontend/tsconfig.tsbuildinfo +++ b/src/conductor/web/frontend/tsconfig.tsbuildinfo @@ -1 +1 @@ -{"root":["./src/app.tsx","./src/main.tsx","./src/components/detail/activitystream.tsx","./src/components/detail/agentdetail.tsx","./src/components/detail/detailpanel.tsx","./src/components/detail/dialogdetail.tsx","./src/components/detail/dialogengagementprompt.tsx","./src/components/detail/dialogoverlay.tsx","./src/components/detail/fileviewer.tsx","./src/components/detail/gatedetail.tsx","./src/components/detail/groupdetail.tsx","./src/components/detail/metadatagrid.tsx","./src/components/detail/outputviewer.tsx","./src/components/detail/scriptdetail.tsx","./src/components/detail/setdetail.tsx","./src/components/detail/subworkflowdetail.tsx","./src/components/dialogs/iterationlimitmodal.tsx","./src/components/graph/agentnode.tsx","./src/components/graph/animatededge.tsx","./src/components/graph/egressnode.tsx","./src/components/graph/endnode.tsx","./src/components/graph/gatenode.tsx","./src/components/graph/groupnode.tsx","./src/components/graph/ingressnode.tsx","./src/components/graph/nodetooltip.tsx","./src/components/graph/scriptnode.tsx","./src/components/graph/setnode.tsx","./src/components/graph/startnode.tsx","./src/components/graph/workflowgraph.tsx","./src/components/graph/workflownode.tsx","./src/components/graph/graph-layout.ts","./src/components/layout/breadcrumbbar.tsx","./src/components/layout/errorbanner.tsx","./src/components/layout/header.tsx","./src/components/layout/outputpane.tsx","./src/components/layout/replaybar.tsx","./src/components/layout/resizablelayout.tsx","./src/components/layout/statusbar.tsx","./src/components/layout/yamlviewer.tsx","./src/hooks/use-deep-link.ts","./src/hooks/use-elapsed-timer.ts","./src/hooks/use-replay.ts","./src/hooks/use-viewed-context.ts","./src/hooks/use-websocket.ts","./src/lib/constants.ts","./src/lib/utils.ts","./src/stores/workflow-store.ts","./src/types/events.ts"],"version":"5.9.3"} \ No newline at end of file +{"root":["./src/app.tsx","./src/main.tsx","./src/components/detail/activitystream.tsx","./src/components/detail/agentdetail.tsx","./src/components/detail/detailpanel.tsx","./src/components/detail/dialogdetail.tsx","./src/components/detail/dialogengagementprompt.tsx","./src/components/detail/dialogoverlay.tsx","./src/components/detail/fileviewer.tsx","./src/components/detail/gatedetail.tsx","./src/components/detail/groupdetail.tsx","./src/components/detail/metadatagrid.tsx","./src/components/detail/outputviewer.tsx","./src/components/detail/scriptdetail.tsx","./src/components/detail/setdetail.tsx","./src/components/detail/subworkflowdetail.tsx","./src/components/detail/waitdetail.tsx","./src/components/dialogs/iterationlimitmodal.tsx","./src/components/graph/agentnode.tsx","./src/components/graph/animatededge.tsx","./src/components/graph/egressnode.tsx","./src/components/graph/endnode.tsx","./src/components/graph/gatenode.tsx","./src/components/graph/groupnode.tsx","./src/components/graph/ingressnode.tsx","./src/components/graph/nodetooltip.tsx","./src/components/graph/scriptnode.tsx","./src/components/graph/setnode.tsx","./src/components/graph/startnode.tsx","./src/components/graph/waitnode.tsx","./src/components/graph/workflowgraph.tsx","./src/components/graph/workflownode.tsx","./src/components/graph/graph-layout.ts","./src/components/layout/breadcrumbbar.tsx","./src/components/layout/errorbanner.tsx","./src/components/layout/header.tsx","./src/components/layout/outputpane.tsx","./src/components/layout/replaybar.tsx","./src/components/layout/resizablelayout.tsx","./src/components/layout/statusbar.tsx","./src/components/layout/yamlviewer.tsx","./src/hooks/use-deep-link.ts","./src/hooks/use-elapsed-timer.ts","./src/hooks/use-replay.ts","./src/hooks/use-viewed-context.ts","./src/hooks/use-websocket.ts","./src/lib/constants.ts","./src/lib/utils.ts","./src/stores/workflow-store.ts","./src/types/events.ts"],"version":"5.9.3"} \ No newline at end of file diff --git a/src/conductor/web/server.py b/src/conductor/web/server.py index 80e31b6f..5dfa44b9 100644 --- a/src/conductor/web/server.py +++ b/src/conductor/web/server.py @@ -639,7 +639,7 @@ def _synth_for_each(name: str, output: Any) -> tuple[str, dict[str, Any], str, d def _synth_agent_or_script( name: str, agent_def: Any, output: Any ) -> tuple[str, dict[str, Any], str, dict[str, Any]]: - """Build synthetic (started, completed) event payloads for an agent/script.""" + """Build synthetic (started, completed) event payloads for an agent/script/wait.""" agent_type = getattr(agent_def, "type", None) or "agent" output_dict = output if isinstance(output, dict) else {} @@ -659,6 +659,26 @@ def _synth_agent_or_script( } return "script_started", started_data, "script_completed", completed_data + if agent_type == "wait": + waited = output_dict.get("waited_seconds", 0.0) + started_data = { + "agent_name": name, + "iteration": 1, + "duration_seconds": waited, + "reason": getattr(agent_def, "reason", None), + "synthetic": True, + } + completed_data = { + "agent_name": name, + "elapsed": waited, + "waited_seconds": waited, + "requested_seconds": waited, + "reason": getattr(agent_def, "reason", None), + "interrupted": False, + "synthetic": True, + } + return "wait_started", started_data, "wait_completed", completed_data + if agent_type == "set": # Mirror the live runtime's set_completed payload shape so # synthetic replays render identically to live runs. Reuse diff --git a/src/conductor/web/static/assets/index-ChYCas4r.js b/src/conductor/web/static/assets/index-ChYCas4r.js deleted file mode 100644 index 5d515b2e..00000000 --- a/src/conductor/web/static/assets/index-ChYCas4r.js +++ /dev/null @@ -1,356 +0,0 @@ -var GE=Object.defineProperty;var FE=(e,t,r)=>t in e?GE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Ct=(e,t,r)=>FE(e,typeof t!="symbol"?t+"":t,r);function YE(e,t){for(var r=0;rl[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))l(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&l(s)}).observe(document,{childList:!0,subtree:!0});function r(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function l(a){if(a.ep)return;a.ep=!0;const o=r(a);fetch(a.href,o)}})();function Zo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var oh={exports:{}},go={};/** - * @license React - * react-jsx-runtime.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * 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 XE(){if(Py)return go;Py=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(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 go.Fragment=t,go.jsx=r,go.jsxs=r,go}var Gy;function QE(){return Gy||(Gy=1,oh.exports=XE()),oh.exports}var y=QE(),sh={exports:{}},Te={};/** - * @license React - * react.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * 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 ZE(){if(Fy)return Te;Fy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),r=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"),d=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),x=Symbol.iterator;function b(q){return q===null||typeof q!="object"?null:(q=x&&q[x]||q["@@iterator"],typeof q=="function"?q:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,S={};function _(q,Y,C){this.props=q,this.context=Y,this.refs=S,this.updater=C||w}_.prototype.isReactComponent={},_.prototype.setState=function(q,Y){if(typeof q!="object"&&typeof q!="function"&&q!=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,q,Y,"setState")},_.prototype.forceUpdate=function(q){this.updater.enqueueForceUpdate(this,q,"forceUpdate")};function N(){}N.prototype=_.prototype;function k(q,Y,C){this.props=q,this.context=Y,this.refs=S,this.updater=C||w}var A=k.prototype=new N;A.constructor=k,E(A,_.prototype),A.isPureReactComponent=!0;var M=Array.isArray;function T(){}var L={H:null,A:null,T:null,S:null},R=Object.prototype.hasOwnProperty;function V(q,Y,C){var P=C.ref;return{$$typeof:e,type:q,key:Y,ref:P!==void 0?P:null,props:C}}function H(q,Y){return V(q.type,Y,q.props)}function B(q){return typeof q=="object"&&q!==null&&q.$$typeof===e}function $(q){var Y={"=":"=0",":":"=2"};return"$"+q.replace(/[=:]/g,function(C){return Y[C]})}var ee=/\/+/g;function I(q,Y){return typeof q=="object"&&q!==null&&q.key!=null?$(""+q.key):Y.toString(36)}function F(q){switch(q.status){case"fulfilled":return q.value;case"rejected":throw q.reason;default:switch(typeof q.status=="string"?q.then(T,T):(q.status="pending",q.then(function(Y){q.status==="pending"&&(q.status="fulfilled",q.value=Y)},function(Y){q.status==="pending"&&(q.status="rejected",q.reason=Y)})),q.status){case"fulfilled":return q.value;case"rejected":throw q.reason}}throw q}function z(q,Y,C,P,X){var J=typeof q;(J==="undefined"||J==="boolean")&&(q=null);var ne=!1;if(q===null)ne=!0;else switch(J){case"bigint":case"string":case"number":ne=!0;break;case"object":switch(q.$$typeof){case e:case t:ne=!0;break;case m:return ne=q._init,z(ne(q._payload),Y,C,P,X)}}if(ne)return X=X(q),ne=P===""?"."+I(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||q&&q.key===X.key?"":(""+X.key).replace(ee,"$&/")+"/")+ne)),Y.push(X)),1;ne=0;var re=P===""?".":P+":";if(M(q))for(var se=0;se>>1,D=z[K];if(0>>1;Ka(C,Q))Pa(X,C)?(z[K]=X,z[P]=Q,K=P):(z[K]=C,z[Y]=Q,K=Y);else if(Pa(X,Q))z[K]=X,z[P]=Q,K=P;else break e}}return G}function a(z,G){var Q=z.sortIndex-G.sortIndex;return Q!==0?Q:z.id-G.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var s=Date,c=s.now();e.unstable_now=function(){return s.now()-c}}var h=[],d=[],m=1,p=null,x=3,b=!1,w=!1,E=!1,S=!1,_=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function A(z){for(var G=r(d);G!==null;){if(G.callback===null)l(d);else if(G.startTime<=z)l(d),G.sortIndex=G.expirationTime,t(h,G);else break;G=r(d)}}function M(z){if(E=!1,A(z),!w)if(r(h)!==null)w=!0,T||(T=!0,$());else{var G=r(d);G!==null&&F(M,G.startTime-z)}}var T=!1,L=-1,R=5,V=-1;function H(){return S?!0:!(e.unstable_now()-Vz&&H());){var K=p.callback;if(typeof K=="function"){p.callback=null,x=p.priorityLevel;var D=K(p.expirationTime<=z);if(z=e.unstable_now(),typeof D=="function"){p.callback=D,A(z),G=!0;break t}p===r(h)&&l(h),A(z)}else l(h);p=r(h)}if(p!==null)G=!0;else{var q=r(d);q!==null&&F(M,q.startTime-z),G=!1}}break e}finally{p=null,x=Q,b=!1}G=void 0}}finally{G?$():T=!1}}}var $;if(typeof k=="function")$=function(){k(B)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,I=ee.port2;ee.port1.onmessage=B,$=function(){I.postMessage(null)}}else $=function(){_(B,0)};function F(z,G){L=_(function(){z(e.unstable_now())},G)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_forceFrameRate=function(z){0>z||125K?(z.sortIndex=Q,t(d,z),r(h)===null&&z===r(d)&&(E?(N(L),L=-1):E=!0,F(M,Q-K))):(z.sortIndex=D,t(h,z),w||b||(w=!0,T||(T=!0,$()))),z},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(z){var G=x;return function(){var Q=x;x=G;try{return z.apply(this,arguments)}finally{x=Q}}}})(fh)),fh}var Qy;function WE(){return Qy||(Qy=1,ch.exports=JE()),ch.exports}var dh={exports:{}},Yt={};/** - * @license React - * react-dom.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Zy;function eN(){if(Zy)return Yt;Zy=1;var e=Ko();function t(h){var d="https://react.dev/errors/"+h;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),dh.exports=eN(),dh.exports}/** - * @license React - * react-dom-client.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Jy;function tN(){if(Jy)return xo;Jy=1;var e=WE(),t=Ko(),r=pw();function l(n){var i="https://react.dev/errors/"+n;if(1D||(n.current=K[D],K[D]=null,D--)}function C(n,i){D++,K[D]=n.current,n.current=i}var P=q(null),X=q(null),J=q(null),ne=q(null);function re(n,i){switch(C(J,i),C(X,n),C(P,null),i.nodeType){case 9:case 11:n=(n=i.documentElement)&&(n=n.namespaceURI)?hy(n):0;break;default:if(n=i.tagName,i=i.namespaceURI)i=hy(i),n=py(i,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}Y(P),C(P,n)}function se(){Y(P),Y(X),Y(J)}function xe(n){n.memoizedState!==null&&C(ne,n);var i=P.current,u=py(i,n.type);i!==u&&(C(X,n),C(P,u))}function be(n){X.current===n&&(Y(P),Y(X)),ne.current===n&&(Y(ne),fo._currentValue=Q)}var ye,pe;function Se(n){if(ye===void 0)try{throw Error()}catch(u){var i=u.stack.trim().match(/\n( *(at )?)/);ye=i&&i[1]||"",pe=-1)":-1g||Z[f]!==le[g]){var fe=` -`+Z[f].replace(" at new "," at ");return n.displayName&&fe.includes("")&&(fe=fe.replace("",n.displayName)),fe}while(1<=f&&0<=g);break}}}finally{De=!1,Error.prepareStackTrace=u}return(u=n?n.displayName||n.name:"")?Se(u):""}function ct(n,i){switch(n.tag){case 26:case 27:case 5:return Se(n.type);case 16:return Se("Lazy");case 13:return n.child!==i&&i!==null?Se("Suspense Fallback"):Se("Suspense");case 19:return Se("SuspenseList");case 0:case 15:return je(n.type,!1);case 11:return je(n.type.render,!1);case 1:return je(n.type,!0);case 31:return Se("Activity");default:return""}}function nt(n){try{var i="",u=null;do i+=ct(n,u),u=n,n=n.return;while(n);return i}catch(f){return` -Error generating stack: `+f.message+` -`+f.stack}}var Mt=Object.prototype.hasOwnProperty,Pt=e.unstable_scheduleCallback,Bt=e.unstable_cancelCallback,kn=e.unstable_shouldYield,Rn=e.unstable_requestPaint,Dt=e.unstable_now,Br=e.unstable_getCurrentPriorityLevel,ce=e.unstable_ImmediatePriority,ge=e.unstable_UserBlockingPriority,Ne=e.unstable_NormalPriority,Be=e.unstable_LowPriority,Xe=e.unstable_IdlePriority,Zt=e.log,On=e.unstable_setDisableYieldValue,It=null,vt=null;function Gt(n){if(typeof Zt=="function"&&On(n),vt&&typeof vt.setStrictMode=="function")try{vt.setStrictMode(It,n)}catch{}}var We=Math.clz32?Math.clz32:Xc,Qn=Math.log,fn=Math.LN2;function Xc(n){return n>>>=0,n===0?32:31-(Qn(n)/fn|0)|0}var cl=256,fl=262144,dl=4194304;function sr(n){var i=n&42;if(i!==0)return i;switch(n&-n){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 n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function hl(n,i,u){var f=n.pendingLanes;if(f===0)return 0;var g=0,v=n.suspendedLanes,j=n.pingedLanes;n=n.warmLanes;var O=f&134217727;return O!==0?(f=O&~v,f!==0?g=sr(f):(j&=O,j!==0?g=sr(j):u||(u=O&~n,u!==0&&(g=sr(u))))):(O=f&~v,O!==0?g=sr(O):j!==0?g=sr(j):u||(u=f&~n,u!==0&&(g=sr(u)))),g===0?0:i!==0&&i!==g&&(i&v)===0&&(v=g&-g,u=i&-i,v>=u||v===32&&(u&4194048)!==0)?i:g}function Si(n,i){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&i)===0}function Qc(n,i){switch(n){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 n=dl;return dl<<=1,(dl&62914560)===0&&(dl=4194304),n}function _a(n){for(var i=[],u=0;31>u;u++)i.push(n);return i}function ki(n,i){n.pendingLanes|=i,i!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function Zc(n,i,u,f,g,v){var j=n.pendingLanes;n.pendingLanes=u,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=u,n.entangledLanes&=u,n.errorRecoveryDisabledLanes&=u,n.shellSuspendCounter=0;var O=n.entanglements,Z=n.expirationTimes,le=n.hiddenUpdates;for(u=j&~u;0"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var tf=/[\n"\\]/g;function en(n){return n.replace(tf,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function Ci(n,i,u,f,g,v,j,O){n.name="",j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?n.type=j:n.removeAttribute("type"),i!=null?j==="number"?(i===0&&n.value===""||n.value!=i)&&(n.value=""+Wt(i)):n.value!==""+Wt(i)&&(n.value=""+Wt(i)):j!=="submit"&&j!=="reset"||n.removeAttribute("value"),i!=null?Ca(n,j,Wt(i)):u!=null?Ca(n,j,Wt(u)):f!=null&&n.removeAttribute("value"),g==null&&v!=null&&(n.defaultChecked=!!v),g!=null&&(n.checked=g&&typeof g!="function"&&typeof g!="symbol"),O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?n.name=""+Wt(O):n.removeAttribute("name")}function Ss(n,i,u,f,g,v,j,O){if(v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(n.type=v),i!=null||u!=null){if(!(v!=="submit"&&v!=="reset"||i!=null)){Pr(n);return}u=u!=null?""+Wt(u):"",i=i!=null?""+Wt(i):u,O||i===n.value||(n.value=i),n.defaultValue=i}f=f??g,f=typeof f!="function"&&typeof f!="symbol"&&!!f,n.checked=O?n.checked:!!f,n.defaultChecked=!!f,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(n.name=j),Pr(n)}function Ca(n,i,u){i==="number"&&Ni(n.ownerDocument)===n||n.defaultValue===""+u||(n.defaultValue=""+u)}function fr(n,i,u,f){if(n=n.options,i){i={};for(var g=0;g"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),of=!1;if(hr)try{var Ta={};Object.defineProperty(Ta,"passive",{get:function(){of=!0}}),window.addEventListener("test",Ta,Ta),window.removeEventListener("test",Ta,Ta)}catch{of=!1}var Gr=null,sf=null,Es=null;function pg(){if(Es)return Es;var n,i=sf,u=i.length,f,g="value"in Gr?Gr.value:Gr.textContent,v=g.length;for(n=0;n=Ma),bg=" ",wg=!1;function _g(n,i){switch(n){case"keyup":return h2.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sg(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var bl=!1;function m2(n,i){switch(n){case"compositionend":return Sg(i);case"keypress":return i.which!==32?null:(wg=!0,bg);case"textInput":return n=i.data,n===bg&&wg?null:n;default:return null}}function g2(n,i){if(bl)return n==="compositionend"||!hf&&_g(n,i)?(n=pg(),Es=sf=Gr=null,bl=!1,n):null;switch(n){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-n};n=f}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=zg(u)}}function Dg(n,i){return n&&i?n===i?!0:n&&n.nodeType===3?!1:i&&i.nodeType===3?Dg(n,i.parentNode):"contains"in n?n.contains(i):n.compareDocumentPosition?!!(n.compareDocumentPosition(i)&16):!1:!1}function Rg(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var i=Ni(n.document);i instanceof n.HTMLIFrameElement;){try{var u=typeof i.contentWindow.location.href=="string"}catch{u=!1}if(u)n=i.contentWindow;else break;i=Ni(n.document)}return i}function gf(n){var i=n&&n.nodeName&&n.nodeName.toLowerCase();return i&&(i==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||i==="textarea"||n.contentEditable==="true")}var k2=hr&&"documentMode"in document&&11>=document.documentMode,wl=null,xf=null,La=null,yf=!1;function Og(n,i,u){var f=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;yf||wl==null||wl!==Ni(f)||(f=wl,"selectionStart"in f&&gf(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),La&&Oa(La,f)||(La=f,f=yu(xf,"onSelect"),0>=j,g-=j,Kn=1<<32-We(i)+g|u<Re?(Ge=_e,_e=null):Ge=_e.sibling;var Ke=ae(te,_e,ie[Re],de);if(Ke===null){_e===null&&(_e=Ge);break}n&&_e&&Ke.alternate===null&&i(te,_e),W=v(Ke,W,Re),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke,_e=Ge}if(Re===ie.length)return u(te,_e),Fe&&mr(te,Re),ke;if(_e===null){for(;ReRe?(Ge=_e,_e=null):Ge=_e.sibling;var hi=ae(te,_e,Ke.value,de);if(hi===null){_e===null&&(_e=Ge);break}n&&_e&&hi.alternate===null&&i(te,_e),W=v(hi,W,Re),Ze===null?ke=hi:Ze.sibling=hi,Ze=hi,_e=Ge}if(Ke.done)return u(te,_e),Fe&&mr(te,Re),ke;if(_e===null){for(;!Ke.done;Re++,Ke=ie.next())Ke=he(te,Ke.value,de),Ke!==null&&(W=v(Ke,W,Re),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke);return Fe&&mr(te,Re),ke}for(_e=f(_e);!Ke.done;Re++,Ke=ie.next())Ke=oe(_e,te,Re,Ke.value,de),Ke!==null&&(n&&Ke.alternate!==null&&_e.delete(Ke.key===null?Re:Ke.key),W=v(Ke,W,Re),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke);return n&&_e.forEach(function(PE){return i(te,PE)}),Fe&&mr(te,Re),ke}function lt(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=g(W,ie.props.children),de.return=te,te=de;break e}}else if(W.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===R&&Hi(ke)===W.type){u(te,W.sibling),de=g(W,ie.props),$a(de,ie),de.return=te,te=de;break e}u(te,W);break}else i(te,W);W=W.sibling}ie.type===E?(de=Mi(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),$a(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=g(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=Hi(ie),lt(te,W,ie,de)}if(F(ie))return we(te,W,ie,de);if($(ie)){if(ke=$(ie),typeof ke!="function")throw Error(l(150));return ie=ke.call(ie),Ce(te,W,ie,de)}if(typeof ie.then=="function")return lt(te,W,$s(ie),de);if(ie.$$typeof===k)return lt(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=g(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{Ua=0;var ke=lt(te,W,ie,de);return Ml=null,ke}catch(_e){if(_e===zl||_e===qs)throw _e;var Ze=hn(29,_e,null,te.mode);return Ze.lanes=de,Ze.return=te,Ze}finally{}}}var Ii=ix(!0),lx=ix(!1),Zr=!1;function Hf(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Bf(n,i){n=n.updateQueue,i.updateQueue===n&&(i.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function Kr(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function Jr(n,i,u){var f=n.updateQueue;if(f===null)return null;if(f=f.shared,(Je&2)!==0){var g=f.pending;return g===null?i.next=i:(i.next=g.next,g.next=i),f.pending=i,i=Rs(n),$g(n,null,u),i}return Ds(n,f,i,u),Rs(n)}function Va(n,i,u){if(i=i.updateQueue,i!==null&&(i=i.shared,(u&4194048)!==0)){var f=i.lanes;f&=n.pendingLanes,u|=f,i.lanes=u,ds(n,u)}}function If(n,i){var u=n.updateQueue,f=n.alternate;if(f!==null&&(f=f.updateQueue,u===f)){var g=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?g=v=j:v=v.next=j,u=u.next}while(u!==null);v===null?g=v=i:v=v.next=i}else g=v=i;u={baseState:f.baseState,firstBaseUpdate:g,lastBaseUpdate:v,shared:f.shared,callbacks:f.callbacks},n.updateQueue=u;return}n=u.lastBaseUpdate,n===null?u.firstBaseUpdate=i:n.next=i,u.lastBaseUpdate=i}var qf=!1;function Pa(){if(qf){var n=Al;if(n!==null)throw n}}function Ga(n,i,u,f){qf=!1;var g=n.updateQueue;Zr=!1;var v=g.firstBaseUpdate,j=g.lastBaseUpdate,O=g.shared.pending;if(O!==null){g.shared.pending=null;var Z=O,le=Z.next;Z.next=null,j===null?v=le:j.next=le,j=Z;var fe=n.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=g.baseState;j=0,fe=le=Z=null,O=v;do{var ae=O.lane&-536870913,oe=ae!==O.lane;if(oe?(Pe&ae)===ae:(f&ae)===ae){ae!==0&&ae===Tl&&(qf=!0),fe!==null&&(fe=fe.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var we=n,Ce=O;ae=i;var lt=u;switch(Ce.tag){case 1:if(we=Ce.payload,typeof we=="function"){he=we.call(lt,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(lt,he,ae):we,ae==null)break e;he=p({},he,ae);break e;case 2:Zr=!0}}ae=O.callback,ae!==null&&(n.flags|=64,oe&&(n.flags|=8192),oe=g.callbacks,oe===null?g.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=g.shared.pending,O===null)break;oe=O,O=oe.next,oe.next=null,g.lastBaseUpdate=oe,g.shared.pending=null}}while(!0);fe===null&&(Z=he),g.baseState=Z,g.firstBaseUpdate=le,g.lastBaseUpdate=fe,v===null&&(g.shared.lanes=0),ri|=j,n.lanes=j,n.memoizedState=he}}function ax(n,i){if(typeof n!="function")throw Error(l(191,n));n.call(i)}function ox(n,i){var u=n.callbacks;if(u!==null)for(n.callbacks=null,n=0;nv?v:8;var j=z.T,O={};z.T=O,ld(n,!1,i,u);try{var Z=g(),le=z.S;if(le!==null&&le(O,Z),Z!==null&&typeof Z=="object"&&typeof Z.then=="function"){var fe=D2(Z,f);Xa(n,i,fe,yn(n))}else Xa(n,i,f,yn(n))}catch(he){Xa(n,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 I2(){}function rd(n,i,u,f){if(n.tag!==5)throw Error(l(476));var g=Ix(n).queue;Bx(n,g,i,Q,u===null?I2:function(){return qx(n),u(f)})}function Ix(n){var i=n.memoizedState;if(i!==null)return i;i={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:Q},next:null};var u={};return i.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:u},next:null},n.memoizedState=i,n=n.alternate,n!==null&&(n.memoizedState=i),i}function qx(n){var i=Ix(n);i.next===null&&(i=n.alternate.memoizedState),Xa(n,i.next.queue,{},yn())}function id(){return Ut(fo)}function Ux(){return wt().memoizedState}function $x(){return wt().memoizedState}function q2(n){for(var i=n.return;i!==null;){switch(i.tag){case 24:case 3:var u=yn();n=Kr(u);var f=Jr(i,n,u);f!==null&&(on(f,i,u),Va(f,i,u)),i={cache:Df()},n.payload=i;return}i=i.return}}function U2(n,i,u){var f=yn();u={lane:f,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Ws(n)?Px(i,u):(u=_f(n,i,u,f),u!==null&&(on(u,n,f),Gx(u,i,f)))}function Vx(n,i,u){var f=yn();Xa(n,i,u,f)}function Xa(n,i,u,f){var g={lane:f,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(Ws(n))Px(i,g);else{var v=n.alternate;if(n.lanes===0&&(v===null||v.lanes===0)&&(v=i.lastRenderedReducer,v!==null))try{var j=i.lastRenderedState,O=v(j,u);if(g.hasEagerState=!0,g.eagerState=O,dn(O,j))return Ds(n,i,g,0),at===null&&Ms(),!1}catch{}finally{}if(u=_f(n,i,g,f),u!==null)return on(u,n,f),Gx(u,i,f),!0}return!1}function ld(n,i,u,f){if(f={lane:2,revertLane:Hd(),gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},Ws(n)){if(i)throw Error(l(479))}else i=_f(n,u,f,2),i!==null&&on(i,n,2)}function Ws(n){var i=n.alternate;return n===ze||i!==null&&i===ze}function Px(n,i){Rl=Fs=!0;var u=n.pending;u===null?i.next=i:(i.next=u.next,u.next=i),n.pending=i}function Gx(n,i,u){if((u&4194048)!==0){var f=i.lanes;f&=n.pendingLanes,u|=f,i.lanes=u,ds(n,u)}}var Qa={readContext:Ut,use:Qs,useCallback:gt,useContext:gt,useEffect:gt,useImperativeHandle:gt,useLayoutEffect:gt,useInsertionEffect:gt,useMemo:gt,useReducer:gt,useRef:gt,useState:gt,useDebugValue:gt,useDeferredValue:gt,useTransition:gt,useSyncExternalStore:gt,useId:gt,useHostTransitionStatus:gt,useFormState:gt,useActionState:gt,useOptimistic:gt,useMemoCache:gt,useCacheRefresh:gt};Qa.useEffectEvent=gt;var Fx={readContext:Ut,use:Qs,useCallback:function(n,i){return Kt().memoizedState=[n,i===void 0?null:i],n},useContext:Ut,useEffect:Tx,useImperativeHandle:function(n,i,u){u=u!=null?u.concat([n]):null,Ks(4194308,4,Dx.bind(null,i,n),u)},useLayoutEffect:function(n,i){return Ks(4194308,4,n,i)},useInsertionEffect:function(n,i){Ks(4,2,n,i)},useMemo:function(n,i){var u=Kt();i=i===void 0?null:i;var f=n();if(qi){Gt(!0);try{n()}finally{Gt(!1)}}return u.memoizedState=[f,i],f},useReducer:function(n,i,u){var f=Kt();if(u!==void 0){var g=u(i);if(qi){Gt(!0);try{u(i)}finally{Gt(!1)}}}else g=i;return f.memoizedState=f.baseState=g,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:g},f.queue=n,n=n.dispatch=U2.bind(null,ze,n),[f.memoizedState,n]},useRef:function(n){var i=Kt();return n={current:n},i.memoizedState=n},useState:function(n){n=Jf(n);var i=n.queue,u=Vx.bind(null,ze,i);return i.dispatch=u,[n.memoizedState,u]},useDebugValue:td,useDeferredValue:function(n,i){var u=Kt();return nd(u,n,i)},useTransition:function(){var n=Jf(!1);return n=Bx.bind(null,ze,n.queue,!0,!1),Kt().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,i,u){var f=ze,g=Kt();if(Fe){if(u===void 0)throw Error(l(407));u=u()}else{if(u=i(),at===null)throw Error(l(349));(Pe&127)!==0||hx(f,i,u)}g.memoizedState=u;var v={value:u,getSnapshot:i};return g.queue=v,Tx(mx.bind(null,f,v,n),[n]),f.flags|=2048,Ll(9,{destroy:void 0},px.bind(null,f,v,u,i),null),u},useId:function(){var n=Kt(),i=at.identifierPrefix;if(Fe){var u=Jn,f=Kn;u=(f&~(1<<32-We(f)-1)).toString(32)+u,i="_"+i+"R_"+u,u=Ys++,0<\/script>",v=v.removeChild(v.firstChild);break;case"select":v=typeof f.is=="string"?j.createElement("select",{is:f.is}):j.createElement("select"),f.multiple?v.multiple=!0:f.size&&(v.size=f.size);break;default:v=typeof f.is=="string"?j.createElement(g,{is:f.is}):j.createElement(g)}}v[Rt]=i,v[Ft]=f;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,g,f),g){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break e;case"img":f=!0;break e;default:f=!1}f&&wr(i)}}return dt(i),vd(i,i.type,n===null?null:n.memoizedProps,i.pendingProps,u),null;case 6:if(n&&i.stateNode!=null)n.memoizedProps!==f&&wr(i);else{if(typeof f!="string"&&i.stateNode===null)throw Error(l(166));if(n=J.current,Cl(i)){if(n=i.stateNode,u=i.memoizedProps,f=null,g=qt,g!==null)switch(g.tag){case 27:case 5:f=g.memoizedProps}n[Rt]=i,n=!!(n.nodeValue===u||f!==null&&f.suppressHydrationWarning===!0||fy(n.nodeValue,u)),n||Xr(i,!0)}else n=vu(n).createTextNode(f),n[Rt]=i,i.stateNode=n}return dt(i),null;case 31:if(u=i.memoizedState,n===null||n.memoizedState!==null){if(f=Cl(i),u!==null){if(n===null){if(!f)throw Error(l(318));if(n=i.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(l(557));n[Rt]=i}else Di(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;dt(i),n=!1}else u=Tf(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=u),n=!0;if(!n)return i.flags&256?(mn(i),i):(mn(i),null);if((i.flags&128)!==0)throw Error(l(558))}return dt(i),null;case 13:if(f=i.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(g=Cl(i),f!==null&&f.dehydrated!==null){if(n===null){if(!g)throw Error(l(318));if(g=i.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(l(317));g[Rt]=i}else Di(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;dt(i),g=!1}else g=Tf(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=g),g=!0;if(!g)return i.flags&256?(mn(i),i):(mn(i),null)}return mn(i),(i.flags&128)!==0?(i.lanes=u,i):(u=f!==null,n=n!==null&&n.memoizedState!==null,u&&(f=i.child,g=null,f.alternate!==null&&f.alternate.memoizedState!==null&&f.alternate.memoizedState.cachePool!==null&&(g=f.alternate.memoizedState.cachePool.pool),v=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(v=f.memoizedState.cachePool.pool),v!==g&&(f.flags|=2048)),u!==n&&u&&(i.child.flags|=8192),iu(i,i.updateQueue),dt(i),null);case 4:return se(),n===null&&Ud(i.stateNode.containerInfo),dt(i),null;case 10:return xr(i.type),dt(i),null;case 19:if(Y(bt),f=i.memoizedState,f===null)return dt(i),null;if(g=(i.flags&128)!==0,v=f.rendering,v===null)if(g)Ka(f,!1);else{if(xt!==0||n!==null&&(n.flags&128)!==0)for(n=i.child;n!==null;){if(v=Gs(n),v!==null){for(i.flags|=128,Ka(f,!1),n=v.updateQueue,i.updateQueue=n,iu(i,n),i.subtreeFlags=0,n=u,u=i.child;u!==null;)Vg(u,n),u=u.sibling;return C(bt,bt.current&1|2),Fe&&mr(i,f.treeForkCount),i.child}n=n.sibling}f.tail!==null&&Dt()>uu&&(i.flags|=128,g=!0,Ka(f,!1),i.lanes=4194304)}else{if(!g)if(n=Gs(v),n!==null){if(i.flags|=128,g=!0,n=n.updateQueue,i.updateQueue=n,iu(i,n),Ka(f,!0),f.tail===null&&f.tailMode==="hidden"&&!v.alternate&&!Fe)return dt(i),null}else 2*Dt()-f.renderingStartTime>uu&&u!==536870912&&(i.flags|=128,g=!0,Ka(f,!1),i.lanes=4194304);f.isBackwards?(v.sibling=i.child,i.child=v):(n=f.last,n!==null?n.sibling=v:i.child=v,f.last=v)}return f.tail!==null?(n=f.tail,f.rendering=n,f.tail=n.sibling,f.renderingStartTime=Dt(),n.sibling=null,u=bt.current,C(bt,g?u&1|2:u&1),Fe&&mr(i,f.treeForkCount),n):(dt(i),null);case 22:case 23:return mn(i),$f(),f=i.memoizedState!==null,n!==null?n.memoizedState!==null!==f&&(i.flags|=8192):f&&(i.flags|=8192),f?(u&536870912)!==0&&(i.flags&128)===0&&(dt(i),i.subtreeFlags&6&&(i.flags|=8192)):dt(i),u=i.updateQueue,u!==null&&iu(i,u.retryQueue),u=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(u=n.memoizedState.cachePool.pool),f=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(f=i.memoizedState.cachePool.pool),f!==u&&(i.flags|=2048),n!==null&&Y(Li),null;case 24:return u=null,n!==null&&(u=n.memoizedState.cache),i.memoizedState.cache!==u&&(i.flags|=2048),xr(St),dt(i),null;case 25:return null;case 30:return null}throw Error(l(156,i.tag))}function F2(n,i){switch(Cf(i),i.tag){case 1:return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 3:return xr(St),se(),n=i.flags,(n&65536)!==0&&(n&128)===0?(i.flags=n&-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));Di()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 13:if(mn(i),n=i.memoizedState,n!==null&&n.dehydrated!==null){if(i.alternate===null)throw Error(l(340));Di()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 19:return Y(bt),null;case 4:return se(),null;case 10:return xr(i.type),null;case 22:case 23:return mn(i),$f(),n!==null&&Y(Li),n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 24:return xr(St),null;case 25:return null;default:return null}}function g0(n,i){switch(Cf(i),i.tag){case 3:xr(St),se();break;case 26:case 27:case 5:be(i);break;case 4:se();break;case 31:i.memoizedState!==null&&mn(i);break;case 13:mn(i);break;case 19:Y(bt);break;case 10:xr(i.type);break;case 22:case 23:mn(i),$f(),n!==null&&Y(Li);break;case 24:xr(St)}}function Ja(n,i){try{var u=i.updateQueue,f=u!==null?u.lastEffect:null;if(f!==null){var g=f.next;u=g;do{if((u.tag&n)===n){f=void 0;var v=u.create,j=u.inst;f=v(),j.destroy=f}u=u.next}while(u!==g)}}catch(O){tt(i,i.return,O)}}function ti(n,i,u){try{var f=i.updateQueue,g=f!==null?f.lastEffect:null;if(g!==null){var v=g.next;f=v;do{if((f.tag&n)===n){var j=f.inst,O=j.destroy;if(O!==void 0){j.destroy=void 0,g=i;var Z=u,le=O;try{le()}catch(fe){tt(g,Z,fe)}}}f=f.next}while(f!==v)}}catch(fe){tt(i,i.return,fe)}}function x0(n){var i=n.updateQueue;if(i!==null){var u=n.stateNode;try{ox(i,u)}catch(f){tt(n,n.return,f)}}}function y0(n,i,u){u.props=Ui(n.type,n.memoizedProps),u.state=n.memoizedState;try{u.componentWillUnmount()}catch(f){tt(n,i,f)}}function Wa(n,i){try{var u=n.ref;if(u!==null){switch(n.tag){case 26:case 27:case 5:var f=n.stateNode;break;case 30:f=n.stateNode;break;default:f=n.stateNode}typeof u=="function"?n.refCleanup=u(f):u.current=f}}catch(g){tt(n,i,g)}}function Wn(n,i){var u=n.ref,f=n.refCleanup;if(u!==null)if(typeof f=="function")try{f()}catch(g){tt(n,i,g)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(g){tt(n,i,g)}else u.current=null}function v0(n){var i=n.type,u=n.memoizedProps,f=n.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":u.autoFocus&&f.focus();break e;case"img":u.src?f.src=u.src:u.srcSet&&(f.srcset=u.srcSet)}}catch(g){tt(n,n.return,g)}}function bd(n,i,u){try{var f=n.stateNode;pE(f,n.type,u,i),f[Ft]=i}catch(g){tt(n,n.return,g)}}function b0(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&si(n.type)||n.tag===4}function wd(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||b0(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&si(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function _d(n,i,u){var f=n.tag;if(f===5||f===6)n=n.stateNode,i?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(n,i):(i=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,i.appendChild(n),u=u._reactRootContainer,u!=null||i.onclick!==null||(i.onclick=dr));else if(f!==4&&(f===27&&si(n.type)&&(u=n.stateNode,i=null),n=n.child,n!==null))for(_d(n,i,u),n=n.sibling;n!==null;)_d(n,i,u),n=n.sibling}function lu(n,i,u){var f=n.tag;if(f===5||f===6)n=n.stateNode,i?u.insertBefore(n,i):u.appendChild(n);else if(f!==4&&(f===27&&si(n.type)&&(u=n.stateNode),n=n.child,n!==null))for(lu(n,i,u),n=n.sibling;n!==null;)lu(n,i,u),n=n.sibling}function w0(n){var i=n.stateNode,u=n.memoizedProps;try{for(var f=n.type,g=i.attributes;g.length;)i.removeAttributeNode(g[0]);Vt(i,f,u),i[Rt]=n,i[Ft]=u}catch(v){tt(n,n.return,v)}}var _r=!1,Nt=!1,Sd=!1,_0=typeof WeakSet=="function"?WeakSet:Set,Ht=null;function Y2(n,i){if(n=n.containerInfo,Pd=Nu,n=Rg(n),gf(n)){if("selectionStart"in n)var u={start:n.selectionStart,end:n.selectionEnd};else e:{u=(u=n.ownerDocument)&&u.defaultView||window;var f=u.getSelection&&u.getSelection();if(f&&f.rangeCount!==0){u=f.anchorNode;var g=f.anchorOffset,v=f.focusNode;f=f.focusOffset;try{u.nodeType,v.nodeType}catch{u=null;break e}var j=0,O=-1,Z=-1,le=0,fe=0,he=n,ae=null;t:for(;;){for(var oe;he!==u||g!==0&&he.nodeType!==3||(O=j+g),he!==v||f!==0&&he.nodeType!==3||(Z=j+f),he.nodeType===3&&(j+=he.nodeValue.length),(oe=he.firstChild)!==null;)ae=he,he=oe;for(;;){if(he===n)break t;if(ae===u&&++le===g&&(O=j),ae===v&&++fe===f&&(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:n,selectionRange:u},Nu=!1,Ht=i;Ht!==null;)if(i=Ht,n=i.child,(i.subtreeFlags&1028)!==0&&n!==null)n.return=i,Ht=n;else for(;Ht!==null;){switch(i=Ht,v=i.alternate,n=i.flags,i.tag){case 0:if((n&4)!==0&&(n=i.updateQueue,n=n!==null?n.events:null,n!==null))for(u=0;u title"))),Vt(v,f,u),v[Rt]=n,_t(v),f=v;break e;case"link":var j=jy("link","href",g).get(f+(u.href||""));if(j){for(var O=0;Olt&&(j=lt,lt=Ce,Ce=j);var te=Mg(O,Ce),W=Mg(O,lt);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>lt?(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=li,j=Cr;if(Ot=0,Ul=li=null,Cr=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,lo(0,!1),vt&&typeof vt.onPostCommitFiberRoot=="function")try{vt.onPostCommitFiberRoot(It,v)}catch{}return!0}finally{G.p=g,z.T=f,K0(n,i)}}function W0(n,i,u){i=Nn(u,i),i=ud(n.stateNode,i,2),n=Jr(n,i,2),n!==null&&(ki(n,2),er(n))}function tt(n,i,u){if(n.tag===3)W0(n,n,u);else for(;i!==null;){if(i.tag===3){W0(i,n,u);break}else if(i.tag===1){var f=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(ii===null||!ii.has(f))){n=Nn(u,n),u=e0(2),f=Jr(i,u,2),f!==null&&(t0(u,f,i,n),ki(f,2),er(f));break}}i=i.return}}function Rd(n,i,u){var f=n.pingCache;if(f===null){f=n.pingCache=new Z2;var g=new Set;f.set(i,g)}else g=f.get(i),g===void 0&&(g=new Set,f.set(i,g));g.has(u)||(Nd=!0,g.add(u),n=tE.bind(null,n,i,u),i.then(n,n))}function tE(n,i,u){var f=n.pingCache;f!==null&&f.delete(i),n.pingedLanes|=n.suspendedLanes&u,n.warmLanes&=~u,at===n&&(Pe&u)===u&&(xt===4||xt===3&&(Pe&62914560)===Pe&&300>Dt()-su?(Je&2)===0&&$l(n,0):Cd|=u,ql===Pe&&(ql=0)),er(n)}function ey(n,i){i===0&&(i=cs()),n=zi(n,i),n!==null&&(ki(n,i),er(n))}function nE(n){var i=n.memoizedState,u=0;i!==null&&(u=i.retryLane),ey(n,u)}function rE(n,i){var u=0;switch(n.tag){case 31:case 13:var f=n.stateNode,g=n.memoizedState;g!==null&&(u=g.retryLane);break;case 19:f=n.stateNode;break;case 22:f=n.stateNode._retryCache;break;default:throw Error(l(314))}f!==null&&f.delete(i),ey(n,u)}function iE(n,i){return Pt(n,i)}var mu=null,Pl=null,Od=!1,gu=!1,Ld=!1,oi=0;function er(n){n!==Pl&&n.next===null&&(Pl===null?mu=Pl=n:Pl=Pl.next=n),gu=!0,Od||(Od=!0,aE())}function lo(n,i){if(!Ld&&gu){Ld=!0;do for(var u=!1,f=mu;f!==null;){if(n!==0){var g=f.pendingLanes;if(g===0)var v=0;else{var j=f.suspendedLanes,O=f.pingedLanes;v=(1<<31-We(42|n)+1)-1,v&=g&~(j&~O),v=v&201326741?v&201326741|1:v?v|2:0}v!==0&&(u=!0,iy(f,v))}else v=Pe,v=hl(f,f===at?v:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),(v&3)===0||Si(f,v)||(u=!0,iy(f,v));f=f.next}while(u);Ld=!1}}function lE(){ty()}function ty(){gu=Od=!1;var n=0;oi!==0&&gE()&&(n=oi);for(var i=Dt(),u=null,f=mu;f!==null;){var g=f.next,v=ny(f,i);v===0?(f.next=null,u===null?mu=g:u.next=g,g===null&&(Pl=u)):(u=f,(n!==0||(v&3)!==0)&&(gu=!0)),f=g}Ot!==0&&Ot!==5||lo(n),oi!==0&&(oi=0)}function ny(n,i){for(var u=n.suspendedLanes,f=n.pingedLanes,g=n.expirationTimes,v=n.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(n,i,u){var f=Gl;if(f&&typeof i=="string"&&i){var g=en(i);g='link[rel="'+n+'"][href="'+g+'"]',typeof u=="string"&&(g+='[crossorigin="'+u+'"]'),Sy.has(g)||(Sy.add(g),n={rel:n,crossOrigin:u,href:i},f.querySelector(g)===null&&(i=f.createElement("link"),Vt(i,"link",n),_t(i),f.head.appendChild(i)))}}function EE(n){jr.D(n),ky("dns-prefetch",n,null)}function NE(n,i){jr.C(n,i),ky("preconnect",n,i)}function CE(n,i,u){jr.L(n,i,u);var f=Gl;if(f&&n&&i){var g='link[rel="preload"][as="'+en(i)+'"]';i==="image"&&u&&u.imageSrcSet?(g+='[imagesrcset="'+en(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(g+='[imagesizes="'+en(u.imageSizes)+'"]')):g+='[href="'+en(n)+'"]';var v=g;switch(i){case"style":v=Fl(n);break;case"script":v=Yl(n)}Mn.has(v)||(n=p({rel:"preload",href:i==="image"&&u&&u.imageSrcSet?void 0:n,as:i},u),Mn.set(v,n),f.querySelector(g)!==null||i==="style"&&f.querySelector(uo(v))||i==="script"&&f.querySelector(co(v))||(i=f.createElement("link"),Vt(i,"link",n),_t(i),f.head.appendChild(i)))}}function jE(n,i){jr.m(n,i);var u=Gl;if(u&&n){var f=i&&typeof i.as=="string"?i.as:"script",g='link[rel="modulepreload"][as="'+en(f)+'"][href="'+en(n)+'"]',v=g;switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":v=Yl(n)}if(!Mn.has(v)&&(n=p({rel:"modulepreload",href:n},i),Mn.set(v,n),u.querySelector(g)===null)){switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(co(v)))return}f=u.createElement("link"),Vt(f,"link",n),_t(f),u.head.appendChild(f)}}}function TE(n,i,u){jr.S(n,i,u);var f=Gl;if(f&&n){var g=$r(f).hoistableStyles,v=Fl(n);i=i||"default";var j=g.get(v);if(!j){var O={loading:0,preload:null};if(j=f.querySelector(uo(v)))O.loading=5;else{n=p({rel:"stylesheet",href:n,"data-precedence":i},u),(u=Mn.get(v))&&Jd(n,u);var Z=j=f.createElement("link");_t(Z),Vt(Z,"link",n),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,f)}j={type:"stylesheet",instance:j,count:1,state:O},g.set(v,j)}}}function AE(n,i){jr.X(n,i);var u=Gl;if(u&&n){var f=$r(u).hoistableScripts,g=Yl(n),v=f.get(g);v||(v=u.querySelector(co(g)),v||(n=p({src:n,async:!0},i),(i=Mn.get(g))&&Wd(n,i),v=u.createElement("script"),_t(v),Vt(v,"link",n),u.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function zE(n,i){jr.M(n,i);var u=Gl;if(u&&n){var f=$r(u).hoistableScripts,g=Yl(n),v=f.get(g);v||(v=u.querySelector(co(g)),v||(n=p({src:n,async:!0,type:"module"},i),(i=Mn.get(g))&&Wd(n,i),v=u.createElement("script"),_t(v),Vt(v,"link",n),u.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function Ey(n,i,u,f){var g=(g=J.current)?bu(g):null;if(!g)throw Error(l(446));switch(n){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(i=Fl(u.href),u=$r(g).hoistableStyles,f=u.get(i),f||(f={type:"style",instance:null,count:0,state:null},u.set(i,f)),f):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){n=Fl(u.href);var v=$r(g).hoistableStyles,j=v.get(n);if(j||(g=g.ownerDocument||g,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},v.set(n,j),(v=g.querySelector(uo(n)))&&!v._p&&(j.instance=v,j.state.loading=5),Mn.has(n)||(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(n,u),v||ME(g,n,u,j.state))),i&&f===null)throw Error(l(528,""));return j}if(i&&f!==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=Yl(u),u=$r(g).hoistableScripts,f=u.get(i),f||(f={type:"script",instance:null,count:0,state:null},u.set(i,f)),f):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,n))}}function Fl(n){return'href="'+en(n)+'"'}function uo(n){return'link[rel="stylesheet"]['+n+"]"}function Ny(n){return p({},n,{"data-precedence":n.precedence,precedence:null})}function ME(n,i,u,f){n.querySelector('link[rel="preload"][as="style"]['+i+"]")?f.loading=1:(i=n.createElement("link"),f.preload=i,i.addEventListener("load",function(){return f.loading|=1}),i.addEventListener("error",function(){return f.loading|=2}),Vt(i,"link",u),_t(i),n.head.appendChild(i))}function Yl(n){return'[src="'+en(n)+'"]'}function co(n){return"script[async]"+n}function Cy(n,i,u){if(i.count++,i.instance===null)switch(i.type){case"style":var f=n.querySelector('style[data-href~="'+en(u.href)+'"]');if(f)return i.instance=f,_t(f),f;var g=p({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return f=(n.ownerDocument||n).createElement("style"),_t(f),Vt(f,"style",g),wu(f,u.precedence,n),i.instance=f;case"stylesheet":g=Fl(u.href);var v=n.querySelector(uo(g));if(v)return i.state.loading|=4,i.instance=v,_t(v),v;f=Ny(u),(g=Mn.get(g))&&Jd(f,g),v=(n.ownerDocument||n).createElement("link"),_t(v);var j=v;return j._p=new Promise(function(O,Z){j.onload=O,j.onerror=Z}),Vt(v,"link",f),i.state.loading|=4,wu(v,u.precedence,n),i.instance=v;case"script":return v=Yl(u.src),(g=n.querySelector(co(v)))?(i.instance=g,_t(g),g):(f=u,(g=Mn.get(v))&&(f=p({},u),Wd(f,g)),n=n.ownerDocument||n,g=n.createElement("script"),_t(g),Vt(g,"link",f),n.head.appendChild(g),i.instance=g);case"void":return null;default:throw Error(l(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(f=i.instance,i.state.loading|=4,wu(f,u.precedence,n));return i.instance}function wu(n,i,u){for(var f=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),g=f.length?f[f.length-1]:null,v=g,j=0;j title"):null)}function DE(n,i,u){if(u===1||i.itemProp!=null)return!1;switch(n){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 n=i.disabled,typeof i.precedence=="string"&&n==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(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function RE(n,i,u,f){if(u.type==="stylesheet"&&(typeof f.media!="string"||matchMedia(f.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var g=Fl(f.href),v=i.querySelector(uo(g));if(v){i=v._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(n.count++,n=Su.bind(n),i.then(n,n)),u.state.loading|=4,u.instance=v,_t(v);return}v=i.ownerDocument||i,f=Ny(f),(g=Mn.get(g))&&Jd(f,g),v=v.createElement("link"),_t(v);var j=v;j._p=new Promise(function(O,Z){j.onload=O,j.onerror=Z}),Vt(v,"link",f),u.instance=v}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(u,i),(i=u.state.preload)&&(u.state.loading&3)===0&&(n.count++,u=Su.bind(n),i.addEventListener("load",u),i.addEventListener("error",u))}}var eh=0;function OE(n,i){return n.stylesheets&&n.count===0&&Eu(n,n.stylesheets),0eh?50:800)+i);return n.unsuspend=u,function(){n.unsuspend=null,clearTimeout(f),clearTimeout(g)}}: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 n=this.unsuspend;this.unsuspend=null,n()}}}var ku=null;function Eu(n,i){n.stylesheets=null,n.unsuspend!==null&&(n.count++,ku=new Map,i.forEach(LE,n),ku=null,Su.call(n))}function LE(n,i){if(!(i.state.loading&4)){var u=ku.get(n);if(u)var f=u.get(null);else{u=new Map,ku.set(n,u);for(var g=n.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=tN(),uh.exports}var rN=nN();/** - * @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 iN=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),mw=(...e)=>e.filter((t,r,l)=>!!t&&t.trim()!==""&&l.indexOf(t)===r).join(" ").trim();/** - * @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. - */var lN={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** - * @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 aN=U.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:l,className:a="",children:o,iconNode:s,...c},h)=>U.createElement("svg",{ref:h,...lN,width:t,height:t,stroke:e,strokeWidth:l?Number(r)*24/Number(t):r,className:mw("lucide",a),...c},[...s.map(([d,m])=>U.createElement(d,m)),...Array.isArray(o)?o:[o]]));/** - * @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 qe=(e,t)=>{const r=U.forwardRef(({className:l,...a},o)=>U.createElement(aN,{ref:o,iconNode:t,className:mw(`lucide-${iN(e)}`,l),...a}));return r.displayName=`${e}`,r};/** - * @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"}]]);/** - * @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 oN=qe("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 sN=qe("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 uN=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"}]]);/** - * @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 Zi=qe("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 al=qe("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 Rr=qe("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 cN=qe("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 fN=qe("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 dN=qe("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 hN=qe("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 xw=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"}]]);/** - * @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("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"}]]);/** - * @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"}]]);/** - * @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"}]]);/** - * @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"}]]);/** - * @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("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"}]]);/** - * @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("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"}]]);/** - * @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 fa=qe("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"}]]);/** - * @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"}]]);/** - * @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"}]]);/** - * @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"}]]);/** - * @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"}]]);/** - * @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"}]]);/** - * @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("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 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"}]]);/** - * @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"}]]);/** - * @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("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 kN=qe("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 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"}]]);/** - * @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"}]]);/** - * @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"}]]);/** - * @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"}]]);/** - * @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("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 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 r=new Set,l=(d,m)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const x=t;t=m??(typeof p!="object"||p===null)?p:Object.assign({},t,p),r.forEach(b=>b(t,x))}},a=()=>t,c={setState:l,getState:a,getInitialState:()=>h,subscribe:d=>(r.add(d),()=>r.delete(d))},h=t=e(l,a,c);return c},TN=(e=>e?tv(e):tv),AN=e=>e;function zN(e,t=AN){const r=na.useSyncExternalStore(e.subscribe,na.useCallback(()=>t(e.getState()),[e,t]),na.useCallback(()=>t(e.getInitialState()),[e,t]));return na.useDebugValue(r),r}const nv=e=>{const t=TN(e),r=l=>zN(t,l);return Object.assign(r,t),r},MN=(e=>e?nv(e):nv);function Le(e,t,r="agent"){return e[t]||(e[t]={name:t,status:"pending",type:r,activity:[]}),e[t].activity||(e[t].activity=[]),e[t]}function Du(e,t,r){Le(e,t).activity.push(r)}function Ae(e,t){e[t]&&(e[t]={...e[t]})}function yo(e,t,r,l){const a=e[t];if(!(a!=null&&a.for_each_items))return;const o=a.for_each_items.find(s=>s.key===r);o&&o.activity.push(l)}function DN(e,t,r,l){return{parentAgent:e,iteration:t,slotKey:l??e,workflowFile:r,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 tr(e,t){if(t.length===0)return null;let r=e[t[0]];for(let l=1;l=0;c--)if(l[c].slotKey===o){s=c;break}if(s===-1)return null;r.push(s),a=l[s],l=a.children}return{indexPath:r,ctx:a}}function RN(e,t){for(let r=e.length-1;r>=0;r--){const l=e[r];if(l.slotKey===t)return{ctx:l,index:r}}return null}const ue=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:r=>{e({_wsSend:r})},sendGateResponse:(r,l,a)=>{const o=ue.getState()._wsSend;o&&o({type:"gate_response",agent_name:r,selected_value:l,additional_input:a||{}})},activeDialog:null,dialogEngaged:!1,engageDialog:()=>{e({dialogEngaged:!0})},sendDialogMessage:(r,l,a)=>{const o=ue.getState()._wsSend;o&&o({type:"dialog_message",agent_name:r,dialog_id:l,content:a})},sendDialogDecline:(r,l)=>{const a=ue.getState()._wsSend;a&&a({type:"dialog_decline",agent_name:r,dialog_id:l})},sendIterationLimitResponse:(r,l,a)=>{const o=ue.getState()._wsSend;if(!o)return;const s=Math.max(0,Math.floor(Number(a)||0)),c="agent_name"in r?{agent_name:r.agent_name}:{group_name:r.group_name};o({type:"iteration_limit_response",gate_id:l,...c,additional_iterations:s})},processEvent:r=>{const l=Ru[r.type];e(a=>{const o={...a,nodes:{...a.nodes},groupProgress:{...a.groupProgress},eventLog:[...a.eventLog],activityLog:[...a.activityLog],lastEventTime:r.timestamp};l&&l(o,r.data,r.timestamp);const s=Ou(r);s&&o.eventLog.push(s);const c=Lu(r);return c&&o.activityLog.push(c),o})},replayState:r=>{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 r){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:r=>{e({selectedNode:r})},setReplayMode:r=>{e(l=>{const a={...l,replayMode:!0,replayEvents:r,replayTotalEvents:r.length,replayPosition:r.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 r){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:r=>{e(l=>{const a=l.replayEvents.slice(0,r),o={...l,replayPosition:r,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 d=Lu(s);d&&o.activityLog.push(d),o.lastEventTime=s.timestamp}return o})},setReplayPlaying:r=>{e({replayPlaying:r})},setReplaySpeed:r=>{e({replaySpeed:r})},setWsStatus:r=>{e({wsStatus:r})},setEdgeHighlight:(r,l,a)=>{e(o=>({highlightedEdges:[...o.highlightedEdges.filter(s=>!(s.from===r&&s.to===l)),{from:r,to:l,state:a}]}))},clearEdgeHighlight:(r,l)=>{e(a=>({highlightedEdges:a.highlightedEdges.filter(o=>!(o.from===r&&o.to===l))}))},navigateToContext:r=>{e({viewContextPath:r,selectedNode:null})},navigateUp:()=>{e(r=>({viewContextPath:r.viewContextPath.slice(0,-1),selectedNode:null}))},navigateIntoSubworkflow:r=>{const l=t(),a=l.viewContextPath;let o;if(a.length===0)o=l.subworkflowContexts;else{const c=tr(l.subworkflowContexts,a);if(!c)return;o=c.children}const s=RN(o,r);s&&e({viewContextPath:[...a,s.index],selectedNode:null})},getViewedContext:()=>{const r=t();if(r.viewContextPath.length===0)return{workflowName:r.workflowName,agents:r.agents,routes:r.routes,parallelGroups:r.parallelGroups,forEachGroups:r.forEachGroups,nodes:r.nodes,groupProgress:r.groupProgress,highlightedEdges:r.highlightedEdges,entryPoint:r.entryPoint,subworkflowContexts:r.subworkflowContexts};const l=tr(r.subworkflowContexts,r.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:r.workflowName,agents:r.agents,routes:r.routes,parallelGroups:r.parallelGroups,forEachGroups:r.forEachGroups,nodes:r.nodes,groupProgress:r.groupProgress,highlightedEdges:r.highlightedEdges,entryPoint:r.entryPoint,subworkflowContexts:r.subworkflowContexts}},getBreadcrumbs:()=>{const r=t(),l=[{label:r.workflowName||"Root",path:[]}];let a=r.subworkflowContexts;for(let o=0;o0&&(r=((a=Fi(e.subworkflowContexts,l))==null?void 0:a.ctx)??null),r){const o=r;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,r)=>{var a;const l=t;if(e.wfDepth===0){e.workflowStatus="running",e.workflowStartTime=r??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||[],Le(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),Le(e.nodes,c.name,"parallel_group"),e.groupProgress[c.name]={total:c.agents.length,completed:0,failed:0};for(const h of c.agents)Le(e.nodes,h,"agent")}for(const c of e.forEachGroups)s.add(c.name),Le(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";Le(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=Fi(e.subworkflowContexts,o))==null?void 0:a.ctx)??null:tr(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||[],Le(s.nodes,"$start","start"),s.nodes.$start.status="running";const c=new Set,h=new Set;for(const d of s.parallelGroups){for(const m of d.agents)c.add(m);h.add(d.name),Le(s.nodes,d.name,"parallel_group"),s.groupProgress[d.name]={total:d.agents.length,completed:0,failed:0};for(const m of d.agents)Le(s.nodes,m,"agent")}for(const d of s.forEachGroups)h.add(d.name),Le(s.nodes,d.name,"for_each_group"),s.groupProgress[d.name]={total:0,completed:0,failed:0};for(const d of s.agents)if(!h.has(d.name)&&!c.has(d.name)){const m=d.type||"agent";Le(s.nodes,d.name,m),d.model&&(s.nodes[d.name].model=d.model),d.reasoning_effort&&(s.nodes[d.name].reasoning_effort=d.reasoning_effort),h.add(d.name)}s.agentsTotal=h.size}}e.wfDepth++},agent_started:(e,t,r)=>{const l=t,a=ot(e,t),o=Le(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=r??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 r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=r.elapsed,a.model=r.model,a.tokens=r.tokens,a.input_tokens=r.input_tokens,a.output_tokens=r.output_tokens,a.cost_usd=r.cost_usd,a.output=r.output,a.output_keys=r.output_keys,a.context_window_used=r.context_window_used,a.context_window_max=r.context_window_max,r.context_window_used!=null&&r.context_window_max!=null&&r.context_window_max>0&&(a.context_pct=Math.round(r.context_window_used/r.context_window_max*100)),r.cost_usd&&l.addCost(r.cost_usd),r.tokens&&l.addTokens(r.tokens),Ae(l.nodes,r.agent_name)},agent_failed:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message;for(const o of l.routes)o.to===r.agent_name&&l.highlightedEdges.push({from:o.from,to:o.to,state:"failed"});Ae(l.nodes,r.agent_name)},agent_prompt_rendered:(e,t)=>{var s;const r=t,l=t.item_key,a=ot(e,t),o=Le(a.nodes,r.agent_name);if(o.prompt=r.rendered_prompt,o.context_keys=r.context_keys,l){yo(a.nodes,r.agent_name,l,{type:"prompt",icon:"📝",label:"prompt",text:"Prompt rendered",detail:((s=r.rendered_prompt)==null?void 0:s.slice(0,500))||null});const c=a.nodes[r.agent_name];if(c!=null&&c.for_each_items){const h=c.for_each_items.find(d=>d.key===l);h&&(h.prompt=r.rendered_prompt)}}Ae(a.nodes,r.agent_name)},agent_reasoning:(e,t)=>{const r=t,l=t.item_key,a=ot(e,t),o={type:"reasoning",icon:"💭",label:"thinking",text:r.content};Du(a.nodes,r.agent_name,o),l&&yo(a.nodes,r.agent_name,l,o),Ae(a.nodes,r.agent_name)},agent_tool_start:(e,t)=>{const r=t,l=t.item_key,a=ot(e,t),o={type:"tool-start",icon:"🔧",label:"tool",text:r.tool_name,detail:r.arguments||null};Du(a.nodes,r.agent_name,o),l&&yo(a.nodes,r.agent_name,l,o),Ae(a.nodes,r.agent_name)},agent_tool_complete:(e,t)=>{const r=t,l=t.item_key,a=ot(e,t),o={type:"tool-complete",icon:"✓",label:"result",text:r.tool_name||"done",detail:r.result||null};Du(a.nodes,r.agent_name,o),l&&yo(a.nodes,r.agent_name,l,o),Ae(a.nodes,r.agent_name)},agent_turn_start:(e,t)=>{const r=t,l=t.item_key,a=ot(e,t),o={type:"turn",icon:"⏳",label:"turn",text:`Turn ${r.turn??"?"}`};Du(a.nodes,r.agent_name,o),l&&yo(a.nodes,r.agent_name,l,o),Ae(a.nodes,r.agent_name)},agent_message:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.latest_message=r.content,Ae(l.nodes,r.agent_name)},script_started:(e,t,r)=>{const l=t,a=ot(e,t),o=Le(a.nodes,l.agent_name);o.status="running",o.startedAt=r??Date.now()/1e3,Ae(a.nodes,l.agent_name)},script_completed:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=r.elapsed,a.stdout=r.stdout,a.stderr=r.stderr,a.exit_code=r.exit_code,Ae(l.nodes,r.agent_name)},script_failed:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message,Ae(l.nodes,r.agent_name)},set_started:(e,t,r)=>{const l=t,a=ot(e,t),o=Le(a.nodes,l.agent_name);o.status="running",o.startedAt=r??Date.now()/1e3,Ae(a.nodes,l.agent_name)},set_completed:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=r.elapsed,a.set_output_type=r.output_type,a.set_output_keys=r.output_keys,a.set_value_repr=r.value_repr,Ae(l.nodes,r.agent_name)},set_failed:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message,Ae(l.nodes,r.agent_name)},gate_presented:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="waiting",a.options=r.options,a.option_details=r.option_details,a.prompt=r.prompt,Ae(l.nodes,r.agent_name)},gate_resolved:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.selected_option=r.selected_option,a.route=r.route,a.additional_input=r.additional_input,Ae(l.nodes,r.agent_name)},route_taken:(e,t)=>{const r=t;ot(e,t).highlightedEdges.push({from:r.from_agent,to:r.to_agent,state:"taken"})},parallel_started:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.group_name,"parallel_group");a.status="running",l.groupProgress[r.group_name]&&(l.groupProgress[r.group_name].total=r.agents.length,l.groupProgress[r.group_name].completed=0,l.groupProgress[r.group_name].failed=0),Ae(l.nodes,r.group_name)},parallel_agent_completed:(e,t)=>{const r=t,l=ot(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].completed++;const a=Le(l.nodes,r.agent_name);a.status="completed",a.elapsed=r.elapsed,a.model=r.model,a.tokens=r.tokens,a.cost_usd=r.cost_usd,a.context_window_used=r.context_window_used,a.context_window_max=r.context_window_max,r.context_window_used!=null&&r.context_window_max!=null&&r.context_window_max>0&&(a.context_pct=Math.round(r.context_window_used/r.context_window_max*100)),r.cost_usd&&l.addCost(r.cost_usd),r.tokens&&l.addTokens(r.tokens),Ae(l.nodes,r.agent_name),Ae(l.nodes,r.group_name)},parallel_agent_failed:(e,t)=>{const r=t,l=ot(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].failed++;const a=Le(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message,Ae(l.nodes,r.agent_name),Ae(l.nodes,r.group_name)},parallel_completed:(e,t)=>{const r=t,l=ot(e,t);l.incrCompleted();const a=Le(l.nodes,r.group_name,"parallel_group");a.status=r.failure_count===0?"completed":"failed",Ae(l.nodes,r.group_name)},for_each_started:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.group_name,"for_each_group");a.status="running",a.for_each_items=[],l.groupProgress[r.group_name]&&(l.groupProgress[r.group_name].total=r.item_count,l.groupProgress[r.group_name].completed=0,l.groupProgress[r.group_name].failed=0),Ae(l.nodes,r.group_name)},for_each_item_started:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.group_name,"for_each_group");a.for_each_items||(a.for_each_items=[]),a.for_each_items.push({key:r.item_key??String(r.index),index:r.index,status:"running",activity:[]}),Ae(l.nodes,r.group_name)},for_each_item_completed:(e,t)=>{const r=t,l=ot(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].completed++;const a=Le(l.nodes,r.group_name,"for_each_group");if(a.for_each_items){const o=r.item_key??String(r.index),s=a.for_each_items.find(c=>c.key===o);s&&(s.status="completed",s.elapsed=r.elapsed,s.tokens=r.tokens,s.cost_usd=r.cost_usd,s.output=r.output)}Ae(l.nodes,r.group_name)},for_each_item_failed:(e,t)=>{const r=t,l=ot(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].failed++;const a=Le(l.nodes,r.group_name,"for_each_group");if(a.for_each_items){const o=r.item_key??String(r.index),s=a.for_each_items.find(c=>c.key===o);s&&(s.status="failed",s.elapsed=r.elapsed,s.error_type=r.error_type,s.error_message=r.message)}Ae(l.nodes,r.group_name)},for_each_completed:(e,t)=>{const r=t,l=ot(e,t);l.incrCompleted();const a=Le(l.nodes,r.group_name,"for_each_group");a.status=(r.failure_count??0)===0?"completed":"failed",a.elapsed=r.elapsed,a.success_count=r.success_count,a.failure_count=r.failure_count,Ae(l.nodes,r.group_name)},workflow_completed:(e,t)=>{var r;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",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?(r=Fi(e.subworkflowContexts,l.subworkflow_path))==null?void 0:r.ctx:tr(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 r=t;if(e.wfDepth===0){if(e.workflowStatus="failed",e.isPaused=!1,e.iterationLimitGate=null,e.workflowFailedAgent=r.agent_name||null,r.agent_name&&e.nodes[r.agent_name]){e.nodes[r.agent_name].status="failed",Ae(e.nodes,r.agent_name);for(const a of e.routes)a.to===r.agent_name&&e.highlightedEdges.push({from:a.from,to:a.to,state:"failed"})}e.workflowFailure={error_type:r.error_type,message:r.message,elapsed_seconds:r.elapsed_seconds,timeout_seconds:r.timeout_seconds,current_agent:r.current_agent},e.nodes.$start&&(e.nodes.$start.status="completed",Ae(e.nodes,"$start"))}else{const a=r.subworkflow_path?(l=Fi(e.subworkflowContexts,r.subworkflow_path))==null?void 0:l.ctx:tr(e.subworkflowContexts,e.activeContextPath);a&&(a.status="failed",a.workflowFailure={error_type:r.error_type,message:r.message})}},subworkflow_started:(e,t)=>{const r=t,l=r.slot_key??(r.item_key!=null?`${r.agent_name}[${r.item_key}]`:r.agent_name),a=DN(r.agent_name,r.iteration??1,r.workflow,l);let o;if(r.parent_path!==void 0){const c=Fi(e.subworkflowContexts,r.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=tr(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[r.agent_name];c&&(c.status="running",Ae(e.nodes,r.agent_name))}else{const c=tr(e.subworkflowContexts,o);if(c){const h=c.nodes[r.agent_name];h&&(h.status="running",Ae(c.nodes,r.agent_name))}}},subworkflow_completed:(e,t)=>{var o;const r=t;let l;if(r.parent_path!==void 0){const s=Fi(e.subworkflowContexts,r.parent_path);if(!s)return;l=s.indexPath}else l=e.activeContextPath;const a=l.length===0?e.nodes:(o=tr(e.subworkflowContexts,l))==null?void 0:o.nodes;if(a){const s=a[r.agent_name];if(s){if(r.item_key==null)if(s.status="completed",s.elapsed=r.elapsed,l.length===0)e.agentsCompleted++;else{const c=tr(e.subworkflowContexts,l);c&&c.agentsCompleted++}Ae(a,r.agent_name)}}e.activeContextPath=l},subworkflow_failed:(e,t)=>{var o;const r=t;let l;if(r.parent_path!==void 0){const s=Fi(e.subworkflowContexts,r.parent_path);if(!s)return;l=s.indexPath}else l=e.activeContextPath;const a=l.length===0?e.nodes:(o=tr(e.subworkflowContexts,l))==null?void 0:o.nodes;if(a){const s=a[r.agent_name];s&&r.item_key==null&&(s.status="failed",s.elapsed=r.elapsed,s.error_type=r.error_type,s.error_message=r.message,Ae(a,r.agent_name))}e.activeContextPath=l},checkpoint_saved:(e,t)=>{const r=t;r.path&&e.workflowFailure&&(e.workflowFailure={...e.workflowFailure,checkpoint_path:r.path})},agent_paused:(e,t)=>{const r=t,l=Le(e.nodes,r.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,r.agent_name),e.isPaused=!0},agent_resumed:(e,t)=>{const r=t,l=Le(e.nodes,r.agent_name);l.status="running",l.activity.push({type:"agent_resumed",icon:"▶",label:"Resumed",text:"Agent resumed — re-executing"}),Ae(e.nodes,r.agent_name),e.isPaused=!1},iteration_limit_reached:(e,t)=>{const r=t;e.iterationLimitGate=r;const l=r.agent_name??r.group_name;l?(Le(e.nodes,l).activity.push({type:"iteration_limit_reached",icon:"⚠",label:"Iteration limit",text:`Reached ${r.current_iteration}/${r.max_iterations} iterations — ${r.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",r)},iteration_limit_resolved:(e,t)=>{const r=t;e.iterationLimitGate=null;const l=r.agent_name??r.group_name;l?(Le(e.nodes,l).activity.push({type:"iteration_limit_resolved",icon:r.continue_execution?"▶":"■",label:"Iteration limit",text:r.aborted?"Gate aborted unexpectedly — stopping workflow":r.continue_execution?`Continuing with ${r.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",r)},dialog_started:(e,t)=>{const r=t,l=Le(e.nodes,r.agent_name);l.dialog_id=r.dialog_id,l.dialog_messages=[],l.dialog_active=!0,l.dialog_awaiting_response=!1,e.activeDialog={agentName:r.agent_name,dialogId:r.dialog_id},e.dialogEngaged=!1,Ae(e.nodes,r.agent_name)},dialog_message:(e,t)=>{const r=t,l=Le(e.nodes,r.agent_name);l.dialog_messages||(l.dialog_messages=[]),l.dialog_messages.push({role:r.role,content:r.content}),r.role==="user"?l.dialog_awaiting_response=!0:r.role==="agent"&&(l.dialog_awaiting_response=!1),Ae(e.nodes,r.agent_name)},dialog_completed:(e,t)=>{const r=t,l=Le(e.nodes,r.agent_name);l.dialog_active=!1,l.dialog_awaiting_response=!1,e.activeDialog=null,e.dialogEngaged=!1,Ae(e.nodes,r.agent_name)}};function Ou(e){var l,a;const t=e.timestamp,r=e.data;switch(e.type){case"workflow_started":return{timestamp:t,level:"info",source:"workflow",message:`Workflow "${r.name||""}" started`};case"agent_started":return{timestamp:t,level:"info",source:String(r.agent_name),message:`Agent started${r.iteration!=null?` (iteration ${r.iteration})`:""}`};case"agent_completed":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Agent completed${r.elapsed!=null?` in ${Eo(r.elapsed)}`:""}${r.tokens!=null?` · ${r.tokens.toLocaleString()} tokens`:""}${r.cost_usd!=null?` · $${r.cost_usd.toFixed(4)}`:""}`};case"agent_failed":return{timestamp:t,level:"error",source:String(r.agent_name),message:`Agent failed: ${r.message||r.error_type||"unknown error"}`};case"script_started":return{timestamp:t,level:"info",source:String(r.agent_name),message:"Script started"};case"script_completed":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Script completed (exit ${r.exit_code??"?"})${r.elapsed!=null?` in ${Eo(r.elapsed)}`:""}`};case"script_failed":return{timestamp:t,level:"error",source:String(r.agent_name),message:`Script failed: ${r.message||r.error_type||"unknown error"}`};case"set_started":return{timestamp:t,level:"info",source:String(r.agent_name),message:"Set started"};case"set_completed":{const o=r.output_keys??[],s=o.length>0?` · ${o.join(", ")}`:"";return{timestamp:t,level:"success",source:String(r.agent_name),message:`Set completed${s}${r.elapsed!=null?` in ${Eo(r.elapsed)}`:""}`}}case"set_failed":return{timestamp:t,level:"error",source:String(r.agent_name),message:`Set failed: ${r.message||r.error_type||"unknown error"}`};case"gate_presented":return{timestamp:t,level:"warning",source:String(r.agent_name),message:"Waiting for human input…"};case"gate_resolved":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Gate resolved → ${r.selected_option||"continue"}`};case"route_taken":return{timestamp:t,level:"debug",source:"router",message:`${r.from_agent} → ${r.to_agent}`};case"parallel_started":return{timestamp:t,level:"info",source:String(r.group_name),message:`Parallel group started (${((l=r.agents)==null?void 0:l.length)||"?"} agents)`};case"parallel_completed":return{timestamp:t,level:r.failure_count===0?"success":"error",source:String(r.group_name),message:`Parallel group completed${r.failure_count>0?` with ${r.failure_count} failure(s)`:""}`};case"for_each_started":return{timestamp:t,level:"info",source:String(r.group_name),message:`For-each started (${r.item_count} items)`};case"for_each_completed":return{timestamp:t,level:(r.failure_count??0)===0?"success":"error",source:String(r.group_name),message:`For-each completed · ${r.success_count} succeeded${r.failure_count>0?` · ${r.failure_count} failed`:""}`};case"workflow_completed":return{timestamp:t,level:"success",source:"workflow",message:`Workflow completed${r.elapsed!=null?` in ${Eo(r.elapsed)}`:""}`};case"workflow_failed":return{timestamp:t,level:"error",source:"workflow",message:`Workflow failed: ${r.message||r.error_type||"unknown error"}`};case"checkpoint_saved":return{timestamp:t,level:"info",source:"workflow",message:`Checkpoint saved: ${((a=r.path)==null?void 0:a.split("/").pop())||"unknown"}`};case"agent_paused":return{timestamp:t,level:"warning",source:String(r.agent_name),message:"Agent paused — waiting for resume"};case"agent_resumed":return{timestamp:t,level:"info",source:String(r.agent_name),message:"Agent resumed — re-executing"};case"iteration_limit_reached":{const o=r.agent_name??r.group_name??"workflow",s=r.skip_gates?" — auto-stopping (--skip-gates)":" — awaiting decision";return{timestamp:t,level:"warning",source:String(o),message:`Iteration limit reached (${r.current_iteration}/${r.max_iterations})${s}`}}case"iteration_limit_resolved":{const o=r.agent_name??r.group_name??"workflow",s=!!r.continue_execution,c=r.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(r.agent_name),message:"Dialog started — waiting for user…"};case"dialog_completed":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Dialog completed (${r.turn_count||0} messages)`};default:return null}}function Eo(e){if(e<1)return`${(e*1e3).toFixed(0)}ms`;if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),r=(e%60).toFixed(0);return`${t}m ${r}s`}function Lu(e){const t=e.timestamp,r=e.data;switch(e.type){case"agent_started":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Agent started${r.iteration!=null?` (iteration ${r.iteration})`:""}`};case"agent_prompt_rendered":return{timestamp:t,source:String(r.agent_name),type:"prompt",message:"Prompt rendered",detail:Ql(String(r.rendered_prompt||""),500)};case"agent_reasoning":return{timestamp:t,source:String(r.agent_name),type:"reasoning",message:String(r.content||"")};case"agent_tool_start":return{timestamp:t,source:String(r.agent_name),type:"tool-start",message:`→ ${r.tool_name}`,detail:r.arguments?Ql(String(r.arguments),300):null};case"agent_tool_complete":return{timestamp:t,source:String(r.agent_name),type:"tool-complete",message:`← ${r.tool_name||"done"}`,detail:r.result?Ql(String(r.result),300):null};case"agent_turn_start":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Turn ${r.turn??"?"}`};case"agent_message":return{timestamp:t,source:String(r.agent_name),type:"message",message:Ql(String(r.content||""),500)};case"agent_completed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Completed${r.elapsed!=null?` in ${Eo(r.elapsed)}`:""}${r.tokens!=null?` · ${r.tokens.toLocaleString()} tokens`:""}`};case"agent_failed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Failed: ${r.message||r.error_type||"unknown"}`};case"script_started":return{timestamp:t,source:String(r.agent_name),type:"turn",message:"Script started"};case"script_completed":return{timestamp:t,source:String(r.agent_name),type:"tool-complete",message:`Script completed (exit ${r.exit_code??"?"})`,detail:r.stdout?Ql(String(r.stdout),300):null};case"script_failed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Script failed: ${r.message||r.error_type||"unknown"}`};case"set_started":return{timestamp:t,source:String(r.agent_name),type:"turn",message:"Set started"};case"set_completed":{const l=r.output_keys??[],a=l.length>0?` (${l.join(", ")})`:"";return{timestamp:t,source:String(r.agent_name),type:"tool-complete",message:`Set completed${a}`,detail:r.value_repr?Ql(String(r.value_repr),300):null}}case"set_failed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Set failed: ${r.message||r.error_type||"unknown"}`};default:return null}}function Ql(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 r=0;ra)o=s;else break}o>r&&t.set(r,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 r=e.match(/^(\s*)(- )(.*)/);if(r){const[,l,a,o]=r;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(" #"),r=t>=0?e.slice(0,t):e,l=t>=0?e.slice(t):"";let a=r;return/^(true|false|null|yes|no)$/i.test(r.trim())?a=y.jsx("span",{className:"text-amber-400",children:r}):/^\d+(\.\d+)?$/.test(r.trim())?a=y.jsx("span",{className:"text-amber-400",children:r}):/^["'].*["']$/.test(r.trim())?a=y.jsx("span",{className:"text-green-400",children:r}):(r.includes("|")||r.includes(">"))&&(a=y.jsx("span",{className:"text-[var(--text-secondary)]",children:r})),y.jsxs(y.Fragment,{children:[a,l&&y.jsx("span",{className:"text-emerald-500/70",children:l})]})}function HN({yaml:e,onClose:t}){const[r,l]=U.useState(new Set);U.useEffect(()=>{const h=d=>{d.key==="Escape"&&t()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t]);const a=U.useMemo(()=>e.split(` -`),[e]),o=U.useMemo(()=>ON(a),[a]),s=U.useCallback(h=>{l(d=>{const m=new Set(d);return m.has(h)?m.delete(h):m.add(h),m})},[]),c=U.useMemo(()=>{const h=[];let d=-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(Rr,{className:"w-3 h-3"}):y.jsx(al,{className:"w-3 h-3"})}):null}),y.jsxs("span",{className:"flex-1",children:[LN(d),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=ue(_=>_.workflowName),t=ue(_=>_.workflowStatus),r=ue(_=>_.isPaused),l=ue(_=>_.workflowYaml),a=ue(_=>_.conductorVersion),[o,s]=U.useState(!1),[c,h]=U.useState(!1),[d,m]=U.useState(!1),[p,x]=U.useState(!1),b=t==="running"||t==="pending";U.useEffect(()=>{r||(s(!1),h(!1),m(!1))},[r]);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:[r?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 - transition-colors`,title:"Re-execute the paused agent",children:[y.jsx(Ec,{className:"w-3 h-3"}),c?"Resuming...":"Resume"]}),y.jsxs("button",{onClick:S,disabled:d,className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded - bg-red-500/10 text-red-400 border border-red-500/20 - hover:bg-red-500/20 hover:border-red-500/30 - disabled:opacity-50 disabled:cursor-not-allowed - transition-colors`,title:"Stop workflow entirely (checkpoint saved for CLI resume)",children:[y.jsx(ol,{className:"w-3 h-3"}),d?"Killing...":"Kill"]})]}):b?y.jsxs("button",{onClick:w,disabled:o,className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded - bg-red-500/10 text-red-400 border border-red-500/20 - hover:bg-red-500/20 hover:border-red-500/30 - disabled:opacity-50 disabled:cursor-not-allowed - transition-colors`,children:[y.jsx(_w,{className:"w-3 h-3"}),o?"Stopping...":"Stop"]}):null,l&&y.jsxs("button",{onClick:()=>x(!0),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:"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:()=>x(!1)})]})}function IN(){const e=ue(o=>o.getBreadcrumbs),t=ue(o=>o.navigateToContext),r=ue(o=>o.viewContextPath);if(ue(o=>o.subworkflowContexts).length===0&&r.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(r);return y.jsxs("span",{className:"flex items-center gap-1",children:[s>0&&y.jsx(Rr,{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 Me(...e){return e.filter(Boolean).join(" ")}function Lt(e){if(e==null)return"";if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),r=(e%60).toFixed(0);return`${t}m ${r}s`}function Pn(e){return e==null?"":e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:`${e}`}function vi(e){return e==null?"":`$${e.toFixed(4)}`}function Sw(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 r=a=>a.toLocaleString(),l=(e/t*100).toFixed(1);return`${r(e)} / ${r(t)} (${l}%)`}function kw(){const e=ue(c=>c.workflowStatus),t=ue(c=>c.workflowStartTime),r=ue(c=>c.replayMode),l=ue(c=>c.lastEventTime),[a,o]=U.useState("—"),s=U.useRef(null);return U.useEffect(()=>{if(t!=null){if(r){s.current&&(clearInterval(s.current),s.current=null),o(Lt((l??t)-t));return}if(e==="running"){const c=()=>{const h=Date.now()/1e3-t;o(Lt(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,r,l]),a}function UN(){const e=ue(_=>_.workflowStatus),t=ue(_=>_.agentsCompleted),r=ue(_=>_.agentsTotal),l=ue(_=>_.totalCost),a=ue(_=>_.totalTokens),o=ue(_=>_.wsStatus),s=ue(_=>_.workflowFailure),c=ue(_=>_.lastEventTime),h=ue(_=>_.iterationLimitGate),d=kw(),[m,p]=U.useState(null);U.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 x=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(fa,{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(fa,{className:"w-3 h-3 animate-spin"}),y.jsx("span",{children:"Connecting\\u2026"})]})}})();return y.jsxs("footer",{className:Me("flex items-center gap-4 px-4 py-1.5 border-t text-xs flex-shrink-0 transition-colors duration-300",x?"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:Me("w-2 h-2 rounded-full flex-shrink-0",E)}),y.jsx("span",{className:Me(x?"text-red-300":w?"text-amber-200":"text-[var(--text)]"),children:b}),r>0&&y.jsxs("span",{className:Me(x?"text-red-400/60":"text-[var(--text-muted)]"),children:[t,"/",r," agents"]}),e!=="pending"&&y.jsx("span",{className:Me("font-mono",x?"text-red-400/60":"text-[var(--text-muted)]"),children:d}),a>0&&y.jsxs("span",{className:Me("flex items-center gap-1",x?"text-red-400/60":"text-[var(--text-muted)]"),title:"Total tokens used",children:[y.jsx(bw,{className:"w-3 h-3"}),y.jsx("span",{className:"font-mono",children:a.toLocaleString()})]}),l>0&&y.jsxs("span",{className:Me("flex items-center gap-1",x?"text-red-400/60":"text-[var(--text-muted)]"),title:"Total cost",children:[y.jsx(xw,{className:"w-3 h-3"}),y.jsxs("span",{className:"font-mono",children:["$",l.toFixed(4)]})]}),m!=null&&m>=5&&y.jsxs("span",{className:Me("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(hN,{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 $N=[1,5,10,20,50];function VN(e,t){if(t===0||e.length===0)return"+0.0s";const r=e[0].timestamp,a=e[Math.min(t,e.length)-1].timestamp-r;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=ue(p=>p.replayPosition),t=ue(p=>p.replayTotalEvents),r=ue(p=>p.replayPlaying),l=ue(p=>p.replaySpeed),a=ue(p=>p.replayEvents),o=ue(p=>p.setReplayPosition),s=ue(p=>p.setReplayPlaying),c=ue(p=>p.setReplaySpeed),h=p=>{const x=parseInt(p.target.value,10);o(x),r&&s(!1)},d=()=>{!r&&e>=t&&o(0),s(!r)},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:d,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:r?"Pause":"Play",children:r?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:` - footer input[type="range"]::-webkit-slider-thumb { - -webkit-appearance: none; - width: 12px; - height: 12px; - border-radius: 50%; - background: var(--accent); - border: 2px solid var(--surface); - cursor: pointer; - box-shadow: 0 0 4px rgba(99, 102, 241, 0.4); - } - footer input[type="range"]::-moz-range-thumb { - width: 12px; - height: 12px; - border-radius: 50%; - background: var(--accent); - border: 2px solid var(--surface); - 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:$N.map(p=>y.jsxs("button",{onClick:()=>c(p),className:Me("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=U.createContext(null);Nc.displayName="PanelGroupContext";const yt={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,Ki=U.useLayoutEffect,lv=KE.useId,GN=typeof lv=="function"?lv:()=>null;let FN=0;function bm(e=null){const t=GN(),r=U.useRef(e||t||null);return r.current===null&&(r.current=""+FN++),e??r.current}function Ew({children:e,className:t="",collapsedSize:r,collapsible:l,defaultSize:a,forwardedRef:o,id:s,maxSize:c,minSize:h,onCollapse:d,onExpand:m,onResize:p,order:x,style:b,tagName:w="div",...E}){const S=U.useContext(Nc);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:_,expandPanel:N,getPanelSize:k,getPanelStyle:A,groupId:M,isPanelCollapsed:T,reevaluatePanelConstraints:L,registerPanel:R,resizePanel:V,unregisterPanel:H}=S,B=bm(s),$=U.useRef({callbacks:{onCollapse:d,onExpand:m,onResize:p},constraints:{collapsedSize:r,collapsible:l,defaultSize:a,maxSize:c,minSize:h},id:B,idIsFromProps:s!==void 0,order:x});U.useRef({didLogMissingDefaultSizeWarning:!1}),Ki(()=>{const{callbacks:I,constraints:F}=$.current,z={...F};$.current.id=B,$.current.idIsFromProps=s!==void 0,$.current.order=x,I.onCollapse=d,I.onExpand=m,I.onResize=p,F.collapsedSize=r,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($.current,z)}),Ki(()=>{const I=$.current;return R(I),()=>{H(I)}},[x,B,R,H]),U.useImperativeHandle(o,()=>({collapse:()=>{_($.current)},expand:I=>{N($.current,I)},getId(){return B},getSize(){return k($.current)},isCollapsed(){return T($.current)},isExpanded(){return!T($.current)},resize:I=>{V($.current,I)}}),[_,N,k,T,B,V]);const ee=A($.current,a);return U.createElement(w,{...E,children:e,className:t,id:B,style:{...ee,...b},[yt.groupId]:M,[yt.panel]:"",[yt.panelCollapsible]:l||void 0,[yt.panelId]:B,[yt.panelSize]:parseFloat(""+ee.flexGrow).toFixed(1)})}const No=U.forwardRef((e,t)=>U.createElement(Ew,{...e,forwardedRef:t}));Ew.displayName="Panel";No.displayName="forwardRef(Panel)";let Vp=null,Ku=-1,xi=null;function YN(e,t){if(t){const r=(t&Aw)!==0,l=(t&zw)!==0,a=(t&Mw)!==0,o=(t&Dw)!==0;if(r)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(){xi!==null&&(document.head.removeChild(xi),Vp=null,xi=null,Ku=-1)}function hh(e,t){var r,l;const a=YN(e,t);if(Vp!==a){if(Vp=a,xi===null&&(xi=document.createElement("style"),document.head.appendChild(xi)),Ku>=0){var o;(o=xi.sheet)===null||o===void 0||o.removeRule(Ku)}Ku=(r=(l=xi.sheet)===null||l===void 0?void 0:l.insertRule(`*{cursor: ${a} !important;}`))!==null&&r!==void 0?r:-1}}function Nw(e){return e.type==="keydown"}function Cw(e){return e.type.startsWith("pointer")}function jw(e){return e.type.startsWith("mouse")}function Cc(e){if(Cw(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(jw(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,r){return e.xt.x&&e.yt.y}function KN(e,t){if(e===t)throw new Error("Cannot compare node with itself");const r={a:sv(e),b:sv(t)};let l;for(;r.a.at(-1)===r.b.at(-1);)e=r.a.pop(),t=r.b.pop(),l=e;He(l,"Stacking order can only be calculated for elements with a common ancestor");const a={a:ov(av(r.a)),b:ov(av(r.b))};if(a.a===a.b){const o=l.childNodes,s={a:r.a.at(-1),b:r.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 r=getComputedStyle((t=Tw(e))!==null&&t!==void 0?t:e).display;return r==="flex"||r==="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 r=e[t];if(He(r,"Missing node"),eC(r))return r}return null}function ov(e){return e&&Number(getComputedStyle(e).zIndex)||0}function sv(e){const t=[];for(;e;)t.push(e),e=Tw(e);return t}function Tw(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Aw=1,zw=2,Mw=4,Dw=8,tC=QN()==="coarse";let Gn=[],oa=!1,Xi=new Map,jc=new Map;const Ho=new Set;function nC(e,t,r,l,a){var o;const{ownerDocument:s}=t,c={direction:r,element:t,hitAreaMargins:l,setResizeHandlerState:a},h=(o=Xi.get(s))!==null&&o!==void 0?o:0;return Xi.set(s,h+1),Ho.add(c),ac(),function(){var m;jc.delete(e),Ho.delete(c);const p=(m=Xi.get(s))!==null&&m!==void 0?m:1;if(Xi.set(s,p-1),ac(),p===1&&Xi.delete(s),Gn.includes(c)){const x=Gn.indexOf(c);x>=0&&Gn.splice(x,1),_m(),a("up",!0,null)}}}function rC(e){const{target:t}=e,{x:r,y:l}=Cc(e);oa=!0,wm({target:t,x:r,y:l}),ac(),Gn.length>0&&(oc("down",e),e.preventDefault(),Rw(t)||e.stopImmediatePropagation())}function ph(e){const{x:t,y:r}=Cc(e);if(oa&&e.buttons===0&&(oa=!1,oc("up",e)),!oa){const{target:l}=e;wm({target:l,x:t,y:r})}oc("move",e),_m(),Gn.length>0&&e.preventDefault()}function mh(e){const{target:t}=e,{x:r,y:l}=Cc(e);jc.clear(),oa=!1,Gn.length>0&&(e.preventDefault(),Rw(t)||e.stopImmediatePropagation()),oc("up",e),wm({target:t,x:r,y:l}),_m(),ac()}function Rw(e){let t=e;for(;t;){if(t.hasAttribute(yt.resizeHandle))return!0;t=t.parentElement}return!1}function wm({target:e,x:t,y:r}){Gn.splice(0);let l=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(l=e),Ho.forEach(a=>{const{element:o,hitAreaMargins:s}=a,c=o.getBoundingClientRect(),{bottom:h,left:d,right:m,top:p}=c,x=tC?s.coarse:s.fine;if(t>=d-x&&t<=m+x&&r>=p-x&&r<=h+x){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 r=0;jc.forEach(l=>{r|=l}),e&&t?hh("intersection",r):e?hh("horizontal",r):t?hh("vertical",r):XN()}let xh=new AbortController;function ac(){xh.abort(),xh=new AbortController;const e={capture:!0,signal:xh.signal};Ho.size&&(oa?(Gn.length>0&&Xi.forEach((t,r)=>{const{body:l}=r;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)):Xi.forEach((t,r)=>{const{body:l}=r;t>0&&(l.addEventListener("pointerdown",rC,e),l.addEventListener("pointermove",ph,e))}))}function oc(e,t){Ho.forEach(r=>{const{setResizeHandlerState:l}=r,a=Gn.includes(r);l(e,a,t)})}function iC(){const[e,t]=U.useState(0);return U.useCallback(()=>t(r=>r+1),[])}function He(e,t){if(!e)throw console.error(t),Error(t)}function el(e,t,r=vm){return e.toFixed(r)===t.toFixed(r)?0:e>t?1:-1}function Ar(e,t,r=vm){return el(e,t,r)===0}function bn(e,t,r){return el(e,t,r)===0}function lC(e,t,r){if(e.length!==t.length)return!1;for(let l=0;l0&&(e=e<0?0-_:_)}}}{const p=e<0?c:h,x=r[p];He(x,`No panel constraints found for index ${p}`);const{collapsedSize:b=0,collapsible:w,minSize:E=0}=x;if(w){const S=t[p];if(He(S!=null,`Previous layout not found for panel index ${p}`),bn(S,E)){const _=S-b;el(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}}{const p=e<0?1:-1;let x=e<0?h:c,b=0;for(;;){const E=t[x];He(E!=null,`Previous layout not found for panel index ${x}`);const _=ra({panelConstraints:r,panelIndex:x,size:100})-E;if(b+=_,x+=p,x<0||x>=r.length)break}const w=Math.min(Math.abs(e),Math.abs(b));e=e<0?0-w:w}{let x=e<0?c:h;for(;x>=0&&x=0))break;e<0?x--:x++}}if(lC(a,s))return a;{const p=e<0?h:c,x=t[p];He(x!=null,`Previous layout not found for panel index ${p}`);const b=x+d,w=ra({panelConstraints:r,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,x)=>x+p,0);return bn(m,100)?s:a}function aC({layout:e,panelsArray:t,pivotIndices:r}){let l=0,a=100,o=0,s=0;const c=r[0];He(c!=null,"No pivot index found"),t.forEach((p,x)=>{const{constraints:b}=p,{maxSize:w=100,minSize:E=0}=b;x===c?(l=E,a=w):(o+=E,s+=w)});const h=Math.min(a,100-o),d=Math.max(l,100-s),m=e[c];return{valueMax:h,valueMin:d,valueNow:m}}function Bo(e,t=document){return Array.from(t.querySelectorAll(`[${yt.resizeHandleId}][data-panel-group-id="${e}"]`))}function Ow(e,t,r=document){const a=Bo(e,r).findIndex(o=>o.getAttribute(yt.resizeHandleId)===t);return a??null}function Lw(e,t,r){const l=Ow(e,t,r);return l!=null?[l,l+1]:[-1,-1]}function Hw(e,t=document){var r;if(t instanceof HTMLElement&&(t==null||(r=t.dataset)===null||r===void 0?void 0:r.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 r=t.querySelector(`[${yt.resizeHandleId}="${e}"]`);return r||null}function oC(e,t,r,l=document){var a,o,s,c;const h=Tc(t,l),d=Bo(e,l),m=h?d.indexOf(h):-1,p=(a=(o=r[m])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null,x=(s=(c=r[m+1])===null||c===void 0?void 0:c.id)!==null&&s!==void 0?s:null;return[p,x]}function sC({committedValuesRef:e,eagerValuesRef:t,groupId:r,layout:l,panelDataArray:a,panelGroupElement:o,setLayout:s}){U.useRef({didWarnAboutMissingResizeHandle:!1}),Ki(()=>{if(!o)return;const c=Bo(r,o);for(let h=0;h{c.forEach((h,d)=>{h.removeAttribute("aria-controls"),h.removeAttribute("aria-valuemax"),h.removeAttribute("aria-valuemin"),h.removeAttribute("aria-valuenow")})}},[r,l,a,o]),U.useEffect(()=>{if(!o)return;const c=t.current;He(c,"Eager values not found");const{panelDataArray:h}=c,d=Hw(r,o);He(d!=null,`No group found for id "${r}"`);const m=Bo(r,o);He(m,`No resize handles found for group id "${r}"`);const p=m.map(x=>{const b=x.getAttribute(yt.resizeHandleId);He(b,"Resize handle element has no handle id attribute");const[w,E]=oC(r,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];He(k,`No panel data found for index ${N}`);const A=l[N],{collapsedSize:M=0,collapsible:T,minSize:L=0}=k.constraints;if(A!=null&&T){const R=Co({delta:bn(A,M)?L-M:M-A,initialLayout:l,panelConstraints:h.map(V=>V.constraints),pivotIndices:Lw(r,b,o),prevLayout:l,trigger:"keyboard"});l!==R&&s(R)}}break}}};return x.addEventListener("keydown",S),()=>{x.removeEventListener("keydown",S)}});return()=>{p.forEach(x=>x())}},[o,e,t,r,l,a,s])}function uv(e,t){if(e.length!==t.length)return!1;for(let r=0;ro.constraints);let l=0,a=100;for(let o=0;o{const o=e[a];He(o,`Panel data not found for index ${a}`);const{callbacks:s,constraints:c,id:h}=o,{collapsedSize:d=0,collapsible:m}=c,p=r[h];if(p==null||l!==p){r[h]=l;const{onCollapse:x,onExpand:b,onResize:w}=s;w&&w(l,p),m&&(x||b)&&(b&&(p==null||Ar(p,d))&&!Ar(l,d)&&b(),x&&(p==null||!Ar(p,d))&&Ar(l,d)&&x())}})}function Hu(e,t){if(e.length!==t.length)return!1;for(let r=0;r{r!==null&&clearTimeout(r),r=setTimeout(()=>{e(...a)},t)}}function cv(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,r)=>{localStorage.setItem(t,r)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Iw(e){return`react-resizable-panels:${e}`}function qw(e){return e.map(t=>{const{constraints:r,id:l,idIsFromProps:a,order:o}=t;return a?l:o?`${o}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((t,r)=>t.localeCompare(r)).join(",")}function Uw(e,t){try{const r=Iw(e),l=t.getItem(r);if(l){const a=JSON.parse(l);if(typeof a=="object"&&a!=null)return a}}catch{}return null}function pC(e,t,r){var l,a;const o=(l=Uw(e,r))!==null&&l!==void 0?l:{},s=qw(t);return(a=o[s])!==null&&a!==void 0?a:null}function mC(e,t,r,l,a){var o;const s=Iw(e),c=qw(t),h=(o=Uw(e,a))!==null&&o!==void 0?o:{};h[c]={expandToSizes:Object.fromEntries(r.entries()),layout:l};try{a.setItem(s,JSON.stringify(h))}catch(d){console.error(d)}}function fv({layout:e,panelConstraints:t}){const r=[...e],l=r.reduce((o,s)=>o+s,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(o=>`${o}%`).join(", ")}`);if(!bn(l,100)&&r.length>0)for(let o=0;o(cv(jo),jo.getItem(e)),setItem:(e,t)=>{cv(jo),jo.setItem(e,t)}},dv={};function $w({autoSaveId:e=null,children:t,className:r="",direction:l,forwardedRef:a,id:o=null,onLayout:s=null,keyboardResizeBy:c=null,storage:h=jo,style:d,tagName:m="div",...p}){const x=bm(o),b=U.useRef(null),[w,E]=U.useState(null),[S,_]=U.useState([]),N=iC(),k=U.useRef({}),A=U.useRef(new Map),M=U.useRef(0),T=U.useRef({autoSaveId:e,direction:l,dragState:w,id:x,keyboardResizeBy:c,onLayout:s,storage:h}),L=U.useRef({layout:S,panelDataArray:[],panelDataArrayChanged:!1});U.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),U.useImperativeHandle(a,()=>({getId:()=>T.current.id,getLayout:()=>{const{layout:C}=L.current;return C},setLayout:C=>{const{onLayout:P}=T.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),Zl(J,ne,k.current))}}),[]),Ki(()=>{T.current.autoSaveId=e,T.current.direction=l,T.current.dragState=w,T.current.id=x,T.current.onLayout=s,T.current.storage=h}),sC({committedValuesRef:T,eagerValuesRef:L,groupId:x,layout:S,panelDataArray:L.current.panelDataArray,setLayout:_,panelGroupElement:b.current}),U.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(A.current);P(e,X,J,S,h)}},[e,S,h]),U.useEffect(()=>{});const R=U.useCallback(C=>{const{onLayout:P}=T.current,{layout:X,panelDataArray:J}=L.current;if(C.constraints.collapsible){const ne=J.map(be=>be.constraints),{collapsedSize:re=0,panelSize:se,pivotIndices:xe}=Pi(J,C,X);if(He(se!=null,`Panel size not found for panel "${C.id}"`),!Ar(se,re)){A.current.set(C.id,se);const ye=ea(J,C)===J.length-1?se-re:re-se,pe=Co({delta:ye,initialLayout:X,panelConstraints:ne,pivotIndices:xe,prevLayout:X,trigger:"imperative-api"});Hu(X,pe)||(_(pe),L.current.layout=pe,P&&P(pe),Zl(J,pe,k.current))}}},[]),V=U.useCallback((C,P)=>{const{onLayout:X}=T.current,{layout:J,panelDataArray:ne}=L.current;if(C.constraints.collapsible){const re=ne.map(Se=>Se.constraints),{collapsedSize:se=0,panelSize:xe=0,minSize:be=0,pivotIndices:ye}=Pi(ne,C,J),pe=P??be;if(Ar(xe,se)){const Se=A.current.get(C.id),De=Se!=null&&Se>=pe?Se:pe,ct=ea(ne,C)===ne.length-1?xe-De:De-xe,nt=Co({delta:ct,initialLayout:J,panelConstraints:re,pivotIndices:ye,prevLayout:J,trigger:"imperative-api"});Hu(J,nt)||(_(nt),L.current.layout=nt,X&&X(nt),Zl(ne,nt,k.current))}}},[]),H=U.useCallback(C=>{const{layout:P,panelDataArray:X}=L.current,{panelSize:J}=Pi(X,C,P);return He(J!=null,`Panel size not found for panel "${C.id}"`),J},[]),B=U.useCallback((C,P)=>{const{panelDataArray:X}=L.current,J=ea(X,C);return dC({defaultSize:P,dragState:w,layout:S,panelData:X,panelIndex:J})},[w,S]),$=U.useCallback(C=>{const{layout:P,panelDataArray:X}=L.current,{collapsedSize:J=0,collapsible:ne,panelSize:re}=Pi(X,C,P);return He(re!=null,`Panel size not found for panel "${C.id}"`),ne===!0&&Ar(re,J)},[]),ee=U.useCallback(C=>{const{layout:P,panelDataArray:X}=L.current,{collapsedSize:J=0,collapsible:ne,panelSize:re}=Pi(X,C,P);return He(re!=null,`Panel size not found for panel "${C.id}"`),!ne||el(re,J)>0},[]),I=U.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]);Ki(()=>{if(L.current.panelDataArrayChanged){L.current.panelDataArrayChanged=!1;const{autoSaveId:C,onLayout:P,storage:X}=T.current,{layout:J,panelDataArray:ne}=L.current;let re=null;if(C){const xe=pC(C,ne,X);xe&&(A.current=new Map(Object.entries(xe.expandToSizes)),re=xe.layout)}re==null&&(re=fC({panelDataArray:ne}));const se=fv({layout:re,panelConstraints:ne.map(xe=>xe.constraints)});uv(J,se)||(_(se),L.current.layout=se,P&&P(se),Zl(ne,se,k.current))}}),Ki(()=>{const C=L.current;return()=>{C.layout=[]}},[]);const F=U.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:se,dragState:xe,id:be,keyboardResizeBy:ye,onLayout:pe}=T.current,{layout:Se,panelDataArray:De}=L.current,{initialLayout:je}=xe??{},ct=Lw(be,C,re);let nt=cC(ne,C,se,xe,ye,re);const Mt=se==="horizontal";Mt&&P&&(nt=-nt);const Pt=De.map(Rn=>Rn.constraints),Bt=Co({delta:nt,initialLayout:je??Se,panelConstraints:Pt,pivotIndices:ct,prevLayout:Se,trigger:Nw(ne)?"keyboard":"mouse-or-touch"}),kn=!Hu(Se,Bt);(Cw(ne)||jw(ne))&&M.current!=nt&&(M.current=nt,!kn&&nt!==0?Mt?gh(C,nt<0?Aw:zw):gh(C,nt<0?Mw:Dw):gh(C,0)),kn&&(_(Bt),L.current.layout=Bt,pe&&pe(Bt),Zl(De,Bt,k.current))}},[]),z=U.useCallback((C,P)=>{const{onLayout:X}=T.current,{layout:J,panelDataArray:ne}=L.current,re=ne.map(Se=>Se.constraints),{panelSize:se,pivotIndices:xe}=Pi(ne,C,J);He(se!=null,`Panel size not found for panel "${C.id}"`);const ye=ea(ne,C)===ne.length-1?se-P:P-se,pe=Co({delta:ye,initialLayout:J,panelConstraints:re,pivotIndices:xe,prevLayout:J,trigger:"imperative-api"});Hu(J,pe)||(_(pe),L.current.layout=pe,X&&X(pe),Zl(ne,pe,k.current))},[]),G=U.useCallback((C,P)=>{const{layout:X,panelDataArray:J}=L.current,{collapsedSize:ne=0,collapsible:re}=P,{collapsedSize:se=0,collapsible:xe,maxSize:be=100,minSize:ye=0}=C.constraints,{panelSize:pe}=Pi(J,C,X);pe!=null&&(re&&xe&&Ar(pe,ne)?Ar(ne,se)||z(C,se):pebe&&z(C,be))},[z]),Q=U.useCallback((C,P)=>{const{direction:X}=T.current,{layout:J}=L.current;if(!b.current)return;const ne=Tc(C,b.current);He(ne,`Drag handle element not found for id "${C}"`);const re=Bw(X,P);E({dragHandleId:C,dragHandleRect:ne.getBoundingClientRect(),initialCursorPosition:re,initialLayout:J})},[]),K=U.useCallback(()=>{E(null)},[]),D=U.useCallback(C=>{const{panelDataArray:P}=L.current,X=ea(P,C);X>=0&&(P.splice(X,1),delete k.current[C.id],L.current.panelDataArrayChanged=!0,N())},[N]),q=U.useMemo(()=>({collapsePanel:R,direction:l,dragState:w,expandPanel:V,getPanelSize:H,getPanelStyle:B,groupId:x,isPanelCollapsed:$,isPanelExpanded:ee,reevaluatePanelConstraints:G,registerPanel:I,registerResizeHandle:F,resizePanel:z,startDragging:Q,stopDragging:K,unregisterPanel:D,panelGroupElement:b.current}),[R,w,l,V,H,B,x,$,ee,G,I,F,z,Q,K,D]),Y={display:"flex",flexDirection:l==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return U.createElement(Nc.Provider,{value:q},U.createElement(m,{...p,children:t,className:r,id:o,ref:b,style:{...Y,...d},[yt.group]:"",[yt.groupDirection]:l,[yt.groupId]:x}))}const Pp=U.forwardRef((e,t)=>U.createElement($w,{...e,forwardedRef:t}));$w.displayName="PanelGroup";Pp.displayName="forwardRef(PanelGroup)";function ea(e,t){return e.findIndex(r=>r===t||r.id===t.id)}function Pi(e,t,r){const l=ea(e,t),o=l===e.length-1?[l-1,l]:[l,l+1],s=r[l];return{...t.constraints,panelSize:s,pivotIndices:o}}function xC({disabled:e,handleId:t,resizeHandler:r,panelGroupElement:l}){U.useEffect(()=>{if(e||r==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(),r(s);break}case"F6":{s.preventDefault();const c=a.getAttribute(yt.groupId);He(c,`No group element found for id "${c}"`);const h=Bo(c,l),d=Ow(c,t,l);He(d!==null,`No resize element found for id "${t}"`);const m=s.shiftKey?d>0?d-1:h.length-1:d+1{a.removeEventListener("keydown",o)}},[l,e,t,r])}function Gp({children:e=null,className:t="",disabled:r=!1,hitAreaMargins:l,id:a,onBlur:o,onClick:s,onDragging:c,onFocus:h,onPointerDown:d,onPointerUp:m,style:p={},tabIndex:x=0,tagName:b="div",...w}){var E,S;const _=U.useRef(null),N=U.useRef({onClick:s,onDragging:c,onPointerDown:d,onPointerUp:m});U.useEffect(()=>{N.current.onClick=s,N.current.onDragging=c,N.current.onPointerDown=d,N.current.onPointerUp=m});const k=U.useContext(Nc);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:A,groupId:M,registerResizeHandle:T,startDragging:L,stopDragging:R,panelGroupElement:V}=k,H=bm(a),[B,$]=U.useState("inactive"),[ee,I]=U.useState(!1),[F,z]=U.useState(null),G=U.useRef({state:B});Ki(()=>{G.current.state=B}),U.useEffect(()=>{if(r)z(null);else{const q=T(H);z(()=>q)}},[r,H,T]);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;U.useEffect(()=>{if(r||F==null)return;const q=_.current;He(q,"Element ref not attached");let Y=!1;return nC(H,q,A,{coarse:Q,fine:K},(P,X,J)=>{if(!X){$("inactive");return}switch(P){case"down":{$("drag"),Y=!1,He(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"&&$("hover"),He(J,'Expected event to be defined for "move" action'),F(J);break}case"up":{$("hover"),R();const{onClick:ne,onDragging:re,onPointerUp:se}=N.current;re==null||re(!1),se==null||se(),Y||ne==null||ne();break}}})},[Q,A,r,K,T,H,F,L,R]),xC({disabled:r,handleId:H,resizeHandler:F,panelGroupElement:V});const D={touchAction:"none",userSelect:"none"};return U.createElement(b,{...w,children:e,className:t,id:a,onBlur:()=>{I(!1),o==null||o()},onFocus:()=>{I(!0),h==null||h()},ref:_,role:"separator",style:{...D,...p},tabIndex:x,[yt.groupDirection]:A,[yt.groupId]:M,[yt.resizeHandle]:"",[yt.resizeHandleActive]:B==="drag"?"pointer":ee?"keyboard":void 0,[yt.resizeHandleEnabled]:!r,[yt.resizeHandleId]:H,[yt.resizeHandleState]:B})}Gp.displayName="PanelResizeHandle";function zt(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let r=0,l;r{}};function Ac(){for(var e=0,t=arguments.length,r={},l;e=0&&(l=r.slice(a+1),r=r.slice(0,a)),r&&!t.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:l}})}Ju.prototype=Ac.prototype={constructor:Ju,on:function(e,t){var r=this._,l=vC(e+"",r),a,o=-1,s=l.length;if(arguments.length<2){for(;++o0)for(var r=new Array(a),l=0,a,o;l=0&&(t=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),pv.hasOwnProperty(t)?{space:pv[t],local:e}:e}function wC(e){return function(){var t=this.ownerDocument,r=this.namespaceURI;return r===Fp&&t.documentElement.namespaceURI===Fp?t.createElement(e):t.createElementNS(r,e)}}function _C(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Vw(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,r=t.length,l=new Array(r),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,x){return p&&x?e(p.__data__,x.__data__):!p-!x}for(var r=this._groups,l=r.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,r=e.length;t1?this.each((t==null?c3:typeof t=="function"?d3:f3)(e,t,r??"")):da(this.node(),e)}function da(e,t){return e.style.getPropertyValue(t)||Xw(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 r=t.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function x3(e,t){return arguments.length>1?this.each((t==null?p3:typeof t=="function"?g3:m3)(e,t)):this.node()[e]}function Qw(e){return e.trim().split(/^|\s+/)}function km(e){return e.classList||new Zw(e)}function Zw(e){this._node=e,this._names=Qw(e.getAttribute("class")||"")}Zw.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 Kw(e,t){for(var r=km(e),l=-1,a=t.length;++l=0&&(r=t.slice(l+1),t=t.slice(0,l)),{type:t,name:r}})}function G3(e){return function(){var t=this.__on;if(t){for(var r=0,l=-1,a=t.length,o;r()=>e;function Yp(e,{sourceEvent:t,subject:r,target:l,identifier:a,active:o,x:s,y:c,dx:h,dy:d,dispatch:m}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:r,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:d,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 r_(){var e=tj,t=nj,r=rj,l=ij,a={},o=Ac("start","drag","end"),s=0,c,h,d,m,p=0;function x(A){A.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(A,M){if(!(m||!e.call(this,A,M))){var T=k(this,t.call(this,A,M),A,M,"mouse");T&&(wn(A.view).on("mousemove.drag",w,Io).on("mouseup.drag",E,Io),t_(A.view),yh(A),d=!1,c=A.clientX,h=A.clientY,T("start",A))}}function w(A){if(sa(A),!d){var M=A.clientX-c,T=A.clientY-h;d=M*M+T*T>p}a.mouse("drag",A)}function E(A){wn(A.view).on("mousemove.drag mouseup.drag",null),n_(A.view,d),sa(A),a.mouse("end",A)}function S(A,M){if(e.call(this,A,M)){var T=A.changedTouches,L=t.call(this,A,M),R=T.length,V,H;for(V=0;V>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?Iu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===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,r,l){return l<=0&&(e=t=r=NaN),new un(e,t,r,l)}function pj(e){return e instanceof Wo||(e=tl(e)),e?(e=e.rgb(),new un(e.r,e.g,e.b,e.opacity)):new un}function Xp(e,t,r,l){return arguments.length===1?pj(e):new un(e,t,r,l??1)}function un(e,t,r,l){this.r=+e,this.g=+t,this.b=+r,this.opacity=+l}Em(un,Xp,i_(Wo,{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?qo:Math.pow(qo,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new un(Ji(this.r),Ji(this.g),Ji(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`#${Qi(this.r)}${Qi(this.g)}${Qi(this.b)}`}function mj(){return`#${Qi(this.r)}${Qi(this.g)}${Qi(this.b)}${Qi((isNaN(this.opacity)?1:this.opacity)*255)}`}function bv(){const e=cc(this.opacity);return`${e===1?"rgb(":"rgba("}${Ji(this.r)}, ${Ji(this.g)}, ${Ji(this.b)}${e===1?")":`, ${e})`}`}function cc(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ji(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Qi(e){return e=Ji(e),(e<16?"0":"")+e.toString(16)}function wv(e,t,r,l){return l<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new Un(e,t,r,l)}function l_(e){if(e instanceof Un)return new Un(e.h,e.s,e.l,e.opacity);if(e instanceof Wo||(e=tl(e)),!e)return new Un;if(e instanceof Un)return e;e=e.rgb();var t=e.r/255,r=e.g/255,l=e.b/255,a=Math.min(t,r,l),o=Math.max(t,r,l),s=NaN,c=o-a,h=(o+a)/2;return c?(t===o?s=(r-l)/c+(r0&&h<1?0:s,new Un(s,c,h,e.opacity)}function gj(e,t,r,l){return arguments.length===1?l_(e):new Un(e,t,r,l??1)}function Un(e,t,r,l){this.h=+e,this.s=+t,this.l=+r,this.opacity=+l}Em(Un,gj,i_(Wo,{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?qo:Math.pow(qo,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,r=this.l,l=r+(r<.5?r:1-r)*t,a=2*r-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,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const Nm=e=>()=>e;function xj(e,t){return function(r){return e+r*t}}function yj(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(l){return Math.pow(e+l*t,r)}}function vj(e){return(e=+e)==1?a_:function(t,r){return r-t?yj(t,r,e):Nm(isNaN(t)?r:t)}}function a_(e,t){var r=t-e;return r?xj(e,r):Nm(isNaN(e)?t:e)}const fc=(function e(t){var r=vj(t);function l(a,o){var s=r((a=Xp(a)).r,(o=Xp(o)).r),c=r(a.g,o.g),h=r(a.b,o.b),d=a_(a.opacity,o.opacity);return function(m){return a.r=s(m),a.g=c(m),a.b=h(m),a.opacity=d(m),a+""}}return l.gamma=e,l})(1);function bj(e,t){t||(t=[]);var r=e?Math.min(t.length,e.length):0,l=t.slice(),a;return function(o){for(a=0;ar&&(o=t.slice(r,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:rr(l,a)})),r=bh.lastIndex;return r180?m+=360:m-d>180&&(d+=360),x.push({i:p.push(a(p)+"rotate(",null,l)-2,x:rr(d,m)})):m&&p.push(a(p)+"rotate("+m+l)}function c(d,m,p,x){d!==m?x.push({i:p.push(a(p)+"skewX(",null,l)-2,x:rr(d,m)}):m&&p.push(a(p)+"skewX("+m+l)}function h(d,m,p,x,b,w){if(d!==p||m!==x){var E=b.push(a(b)+"scale(",null,",",null,")");w.push({i:E-4,x:rr(d,p)},{i:E-2,x:rr(m,x)})}else(p!==1||x!==1)&&b.push(a(b)+"scale("+p+","+x+")")}return function(d,m){var p=[],x=[];return d=e(d),m=e(m),o(d.translateX,d.translateY,m.translateX,m.translateY,p,x),s(d.rotate,m.rotate,p,x),c(d.skewX,m.skewX,p,x),h(d.scaleX,d.scaleY,m.scaleX,m.scaleY,p,x),d=m=null,function(b){for(var w=-1,E=x.length,S;++w=0&&e._call.call(void 0,t),e=e._next;--ha}function Ev(){nl=(hc=$o.now())+Mc,ha=To=0;try{Oj()}finally{ha=0,Hj(),nl=0}}function Lj(){var e=$o.now(),t=e-hc;t>c_&&(Mc-=t,hc=e)}function Hj(){for(var e,t=dc,r,l=1/0;t;)t._call?(l>t._time&&(l=t._time),e=t,t=t._next):(r=t._next,t._next=null,t=e?e._next=r:dc=r);Ao=e,Kp(l)}function Kp(e){if(!ha){To&&(To=clearTimeout(To));var t=e-nl;t>24?(e<1/0&&(To=setTimeout(Ev,e-$o.now()-Mc)),vo&&(vo=clearInterval(vo))):(vo||(hc=$o.now(),vo=setInterval(Lj,c_)),ha=1,f_(Ev))}}function Nv(e,t,r){var l=new pc;return t=t==null?0:+t,l.restart(a=>{l.stop(),e(a+t)},t,r),l}var Bj=Ac("start","end","cancel","interrupt"),Ij=[],h_=0,Cv=1,Jp=2,ec=3,jv=4,Wp=5,tc=6;function Dc(e,t,r,l,a,o){var s=e.__transition;if(!s)e.__transition={};else if(r in s)return;qj(e,r,{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:h_})}function jm(e,t){var r=Xn(e,t);if(r.state>h_)throw new Error("too late; already scheduled");return r}function ar(e,t){var r=Xn(e,t);if(r.state>ec)throw new Error("too late; already running");return r}function Xn(e,t){var r=e.__transition;if(!r||!(r=r[t]))throw new Error("transition not found");return r}function qj(e,t,r){var l=e.__transition,a;l[t]=r,r.timer=d_(o,0,r.time);function o(d){r.state=Cv,r.timer.restart(s,r.delay,r.time),r.delay<=d&&s(d-r.delay)}function s(d){var m,p,x,b;if(r.state!==Cv)return h();for(m in l)if(b=l[m],b.name===r.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,r)),!t||t==="start"})}function gT(e,t,r){var l,a,o=mT(t)?jm:ar;return function(){var s=o(this,e),c=s.on;c!==l&&(a=(l=c).copy()).on(t,r),s.on=a}}function xT(e,t){var r=this._id;return arguments.length<2?Xn(this.node(),r).on.on(e):this.each(gT(r,e,t))}function yT(e){return function(){var t=this.parentNode;for(var r in this.__transition)if(+r!==e)return;t&&t.removeChild(this)}}function vT(){return this.on("end.remove",yT(this._id))}function bT(e){var t=this._name,r=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:r,transform:l,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:a}})}function zr(e,t,r){this.k=e,this.x=t,this.y=r}zr.prototype={constructor:zr,scale:function(e){return e===1?this:new zr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new zr(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 zr(1,0,0);x_.prototype=zr.prototype;function x_(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Rc;return e.__zoom}function wh(e){e.stopImmediatePropagation()}function bo(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,r){var l=e.invertX(t[0][0])-r[0][0],a=e.invertX(t[1][0])-r[1][0],o=e.invertY(t[0][1])-r[0][1],s=e.invertY(t[1][1])-r[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 y_(){var e=FT,t=YT,r=ZT,l=XT,a=QT,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],c=250,h=Wu,d=Ac("start","zoom","end"),m,p,x,b=500,w=150,E=0,S=10;function _(I){I.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",$).on("touchend.zoom touchcancel.zoom",ee).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(I,F,z,G){var Q=I.selection?I.selection():I;Q.property("__zoom",Tv),I!==Q?M(I,F,z,G):Q.interrupt().each(function(){T(this,arguments).event(G).start().zoom(null,typeof F=="function"?F.apply(this,arguments):F).end()})},_.scaleBy=function(I,F,z,G){_.scaleTo(I,function(){var Q=this.__zoom.k,K=typeof F=="function"?F.apply(this,arguments):F;return Q*K},z,G)},_.scaleTo=function(I,F,z,G){_.transform(I,function(){var Q=t.apply(this,arguments),K=this.__zoom,D=z==null?A(Q):typeof z=="function"?z.apply(this,arguments):z,q=K.invert(D),Y=typeof F=="function"?F.apply(this,arguments):F;return r(k(N(K,Y),D,q),Q,s)},z,G)},_.translateBy=function(I,F,z,G){_.transform(I,function(){return r(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(I,F,z,G,Q){_.transform(I,function(){var K=t.apply(this,arguments),D=this.__zoom,q=G==null?A(K):typeof G=="function"?G.apply(this,arguments):G;return r(Rc.translate(q[0],q[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(I,F){return F=Math.max(o[0],Math.min(o[1],F)),F===I.k?I:new zr(F,I.x,I.y)}function k(I,F,z){var G=F[0]-z[0]*I.k,Q=F[1]-z[1]*I.k;return G===I.x&&Q===I.y?I:new zr(I.k,G,Q)}function A(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function M(I,F,z,G){I.on("start.zoom",function(){T(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(G).end()}).tween("zoom",function(){var Q=this,K=arguments,D=T(Q,K).event(G),q=t.apply(Q,K),Y=z==null?A(q):typeof z=="function"?z.apply(Q,K):z,C=Math.max(q[1][0]-q[0][0],q[1][1]-q[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),se=C/re[2];ne=new zr(se,Y[0]-re[0]*se,Y[1]-re[1]*se)}D.zoom(null,ne)}})}function T(I,F,z){return!z&&I.__zooming||new L(I,F)}function L(I,F){this.that=I,this.args=F,this.active=0,this.sourceEvent=null,this.extent=t.apply(I,F),this.taps=0}L.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,F){return this.mouse&&I!=="mouse"&&(this.mouse[1]=F.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=F.invert(this.touch0[0])),this.touch1&&I!=="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(I){var F=wn(this.that).datum();d.call(I,this.that,new GT(I,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:d}),F)}};function R(I,...F){if(!e.apply(this,arguments))return;var z=T(this,F).event(I),G=this.__zoom,Q=Math.max(o[0],Math.min(o[1],G.k*Math.pow(2,l.apply(this,arguments)))),K=qn(I);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()}bo(I),z.wheel=setTimeout(D,w),z.zoom("mouse",r(k(N(G,Q),z.mouse[0],z.mouse[1]),z.extent,s));function D(){z.wheel=null,z.end()}}function V(I,...F){if(x||!e.apply(this,arguments))return;var z=I.currentTarget,G=T(this,F,!0).event(I),Q=wn(I.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",C,!0),K=qn(I,z),D=I.clientX,q=I.clientY;t_(I.view),wh(I),G.mouse=[K,this.__zoom.invert(K)],nc(this),G.start();function Y(P){if(bo(P),!G.moved){var X=P.clientX-D,J=P.clientY-q;G.moved=X*X+J*J>E}G.event(P).zoom("mouse",r(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),n_(P.view,G.moved),bo(P),G.event(P).end()}}function H(I,...F){if(e.apply(this,arguments)){var z=this.__zoom,G=qn(I.changedTouches?I.changedTouches[0]:I,this),Q=z.invert(G),K=z.k*(I.shiftKey?.5:2),D=r(k(N(z,K),G,Q),t.apply(this,F),s);bo(I),c>0?wn(this).transition().duration(c).call(M,D,G,I):wn(this).call(_.transform,D,G,I)}}function B(I,...F){if(e.apply(this,arguments)){var z=I.touches,G=z.length,Q=T(this,F,I.changedTouches.length===G).event(I),K,D,q,Y;for(wh(I),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:r,targetHandle:l})=>`Couldn't create edge for ${e} handle id: "${e==="source"?r: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."},Vo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],v_=["Enter"," ","Escape"],b_={"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:r})=>`Moved selected node ${e}. New position, x: ${t}, y: ${r}`,"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 pa;(function(e){e.Strict="strict",e.Loose="loose"})(pa||(pa={}));var Wi;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Wi||(Wi={}));var Po;(function(e){e.Partial="partial",e.Full="full"})(Po||(Po={}));const w_={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var yi;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(yi||(yi={}));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 __(e){return e===null?null:e?"valid":"invalid"}const S_=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),es=(e,t=[0,0])=>{const{width:r,height:l}=Or(e),a=e.origin??t,o=r*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 r=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(r)},ts=(e,t={})=>{let r={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))&&(r=Oc(r,gc(a)),l=!0)}),l?Lc(r):{x:0,y:0,width:0,height:0}},zm=(e,t,[r,l,a]=[0,0,1],o=!1,s=!1)=>{const c={...rs(t,[r,l,a]),width:t.width/a,height:t.height/a},h=[];for(const d of e.values()){const{measured:m,selectable:p=!0,hidden:x=!1}=d;if(s&&!p||x)continue;const b=m.width??d.width??d.initialWidth??null,w=m.height??d.height??d.initialHeight??null,E=Go(c,ga(d)),S=(b??0)*(w??0),_=o&&E>0;(!d.internals.handleBounds||_||E>=S||d.dragging)&&h.push(d)}return h},WT=(e,t)=>{const r=new Set;return e.forEach(l=>{r.add(l.id)}),t.filter(l=>r.has(l.source)||r.has(l.target))};function eA(e,t){const r=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))&&r.set(a.id,a)}),r}async function tA({nodes:e,width:t,height:r,panZoom:l,minZoom:a,maxZoom:o},s){if(e.size===0)return Promise.resolve(!0);const c=eA(e,s),h=ts(c),d=Mm(h,t,r,(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(d,{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 k_({nodeId:e,nextPosition:t,nodeLookup:r,nodeOrigin:l=[0,0],nodeExtent:a,onError:o}){const s=r.get(e),c=s.parentId?r.get(s.parentId):void 0,{x:h,y:d}=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",lr.error005());else{const b=c.measured.width,w=c.measured.height;b&&w&&(p=[[h,d],[h+b,d+w]])}else c&&xa(s.extent)&&(p=[[s.extent[0][0]+h,s.extent[0][1]+d],[s.extent[1][0]+h,s.extent[1][1]+d]]);const x=xa(p)?rl(t,p,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(o==null||o("015",lr.error015())),{position:{x:x.x-h+(s.measured.width??0)*m[0],y:x.y-d+(s.measured.height??0)*m[1]},positionAbsolute:x}}async function nA({nodesToRemove:e=[],edgesToRemove:t=[],nodes:r,edges:l,onBeforeDelete:a}){const o=new Set(e.map(x=>x.id)),s=[];for(const x of r){if(x.deletable===!1)continue;const b=o.has(x.id),w=!b&&x.parentId&&s.find(E=>E.id===x.parentId);(b||w)&&s.push(x)}const c=new Set(t.map(x=>x.id)),h=l.filter(x=>x.deletable!==!1),m=WT(s,h);for(const x of h)c.has(x.id)&&!m.find(w=>w.id===x.id)&&m.push(x);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 ma=(e,t=0,r=1)=>Math.min(Math.max(e,t),r),rl=(e={x:0,y:0},t,r)=>({x:ma(e.x,t[0][0],t[1][0]-((r==null?void 0:r.width)??0)),y:ma(e.y,t[0][1],t[1][1]-((r==null?void 0:r.height)??0))});function E_(e,t,r){const{width:l,height:a}=Or(r),{x:o,y:s}=r.internals.positionAbsolute;return rl(e,[[o,s],[o+l,s+a]],t)}const zv=(e,t,r)=>er?-ma(Math.abs(e-r),1,t)/t:0,N_=(e,t,r=15,l=40)=>{const a=zv(e.x,l,t.width-l)*r,o=zv(e.y,l,t.height-l)*r;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:r,height:l})=>({x:e,y:t,x2:e+r,y2:t+l}),Lc=({x:e,y:t,x2:r,y2:l})=>({x:e,y:t,width:r-e,height:l-t}),ga=(e,t=[0,0])=>{var a,o;const{x:r,y:l}=Am(e)?e.internals.positionAbsolute:es(e,t);return{x:r,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:r,y:l}=Am(e)?e.internals.positionAbsolute:es(e,t);return{x:r,y:l,x2:r+(((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)}},C_=(e,t)=>Lc(Oc(em(e),em(t))),Go=(e,t)=>{const r=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(r*l)},Mv=e=>$n(e.width)&&$n(e.height)&&$n(e.x)&&$n(e.y),$n=e=>!isNaN(e)&&isFinite(e),rA=(e,t)=>{},ns=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),rs=({x:e,y:t},[r,l,a],o=!1,s=[1,1])=>{const c={x:(e-r)/a,y:(t-l)/a};return o?ns(c,s):c},xc=({x:e,y:t},[r,l,a])=>({x:e*a+r,y:t*a+l});function Kl(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const r=parseFloat(e);if(!Number.isNaN(r))return Math.floor(r)}if(typeof e=="string"&&e.endsWith("%")){const r=parseFloat(e);if(!Number.isNaN(r))return Math.floor(t*r*.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,r){if(typeof e=="string"||typeof e=="number"){const l=Kl(e,r),a=Kl(e,t);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof e=="object"){const l=Kl(e.top??e.y??0,r),a=Kl(e.bottom??e.y??0,r),o=Kl(e.left??e.x??0,t),s=Kl(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,r,l,a,o){const{x:s,y:c}=xc(e,[t,r,l]),{x:h,y:d}=xc({x:e.x+e.width,y:e.y+e.height},[t,r,l]),m=a-h,p=o-d;return{left:Math.floor(s),top:Math.floor(c),right:Math.floor(m),bottom:Math.floor(p)}}const Mm=(e,t,r,l,a,o)=>{const s=iA(o,t,r),c=(t-s.x)/e.width,h=(r-s.y)/e.height,d=Math.min(c,h),m=ma(d,l,a),p=e.x+e.width/2,x=e.y+e.height/2,b=t/2-p*m,w=r/2-x*m,E=lA(e,b,w,m,t,r),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}},Fo=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function xa(e){return e!=null&&e!=="parent"}function Or(e){var t,r;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight??0}}function j_(e){var t,r;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight)!==void 0}function T_(e,t={width:0,height:0},r,l,a){const o={...e},s=l.get(r);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 r of e)if(!t.has(r))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{...b_,...e||{}}}function Do(e,{snapGrid:t=[0,0],snapToGrid:r=!1,transform:l,containerBounds:a}){const{x:o,y:s}=Vn(e),c=rs({x:o-((a==null?void 0:a.left)??0),y:s-((a==null?void 0:a.top)??0)},l),{x:h,y:d}=r?ns(c,t):c;return{xSnapped:h,ySnapped:d,...c}}const Dm=e=>({width:e.offsetWidth,height:e.offsetHeight}),A_=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 z_(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 M_=e=>"clientX"in e,Vn=(e,t)=>{var o,s;const r=M_(e),l=r?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,a=r?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,r,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-r.left)/l,y:(c.top-r.top)/l,...Dm(s)}})};function D_({sourceX:e,sourceY:t,targetX:r,targetY:l,sourceControlX:a,sourceControlY:o,targetControlX:s,targetControlY:c}){const h=e*.125+a*.375+s*.375+r*.125,d=t*.125+o*.375+c*.375+l*.125,m=Math.abs(h-e),p=Math.abs(d-t);return[h,d,m,p]}function Vu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Ov({pos:e,x1:t,y1:r,x2:l,y2:a,c:o}){switch(e){case ve.Left:return[t-Vu(t-l,o),r];case ve.Right:return[t+Vu(l-t,o),r];case ve.Top:return[t,r-Vu(r-a,o)];case ve.Bottom:return[t,r+Vu(a-r,o)]}}function Rm({sourceX:e,sourceY:t,sourcePosition:r=ve.Bottom,targetX:l,targetY:a,targetPosition:o=ve.Top,curvature:s=.25}){const[c,h]=Ov({pos:r,x1:e,y1:t,x2:l,y2:a,c:s}),[d,m]=Ov({pos:o,x1:l,y1:a,x2:e,y2:t,c:s}),[p,x,b,w]=D_({sourceX:e,sourceY:t,targetX:l,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:d,targetControlY:m});return[`M${e},${t} C${c},${h} ${d},${m} ${l},${a}`,p,x,b,w]}function R_({sourceX:e,sourceY:t,targetX:r,targetY:l}){const a=Math.abs(r-e)/2,o=r0}const fA=({source:e,sourceHandle:t,target:r,targetHandle:l})=>`xy-edge__${e}${t||""}-${r}${l||""}`,dA=(e,t)=>t.some(r=>r.source===e.source&&r.target===e.target&&(r.sourceHandle===e.sourceHandle||!r.sourceHandle&&!e.sourceHandle)&&(r.targetHandle===e.targetHandle||!r.targetHandle&&!e.targetHandle)),hA=(e,t,r={})=>{if(!e.source||!e.target)return t;const l=r.getEdgeId||fA;let a;return S_(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 O_({sourceX:e,sourceY:t,targetX:r,targetY:l}){const[a,o,s,c]=R_({sourceX:e,sourceY:t,targetX:r,targetY:l});return[`M ${e},${t}L ${r},${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:r})=>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:r,targetPosition:l=ve.Top,center:a,offset:o,stepPosition:s}){const c=Lv[t],h=Lv[l],d={x:e.x+c.x*o,y:e.y+c.y*o},m={x:r.x+h.x*o,y:r.y+h.y*o},p=pA({source:d,sourcePosition:t,target:m}),x=p.x!==0?"x":"y",b=p[x];let w=[],E,S;const _={x:0,y:0},N={x:0,y:0},[,,k,A]=R_({sourceX:e.x,sourceY:e.y,targetX:r.x,targetY:r.y});if(c[x]*h[x]===-1){x==="x"?(E=a.x??d.x+(m.x-d.x)*s,S=a.y??(d.y+m.y)/2):(E=a.x??(d.x+m.x)/2,S=a.y??d.y+(m.y-d.y)*s);const T=[{x:E,y:d.y},{x:E,y:m.y}],L=[{x:d.x,y:S},{x:m.x,y:S}];c[x]===b?w=x==="x"?T:L:w=x==="x"?L:T}else{const T=[{x:d.x,y:m.y}],L=[{x:m.x,y:d.y}];if(x==="x"?w=c.x===b?L:T:w=c.y===b?T:L,t===l){const $=Math.abs(e[x]-r[x]);if($<=o){const ee=Math.min(o-1,o-$);c[x]===b?_[x]=(d[x]>e[x]?-1:1)*ee:N[x]=(m[x]>r[x]?-1:1)*ee}}if(t!==l){const $=x==="x"?"y":"x",ee=c[x]===h[$],I=d[$]>m[$],F=d[$]=B?(E=(R.x+V.x)/2,S=w[0].y):(E=w[0].x,S=(R.y+V.y)/2)}return[[e,{x:d.x+_.x,y:d.y+_.y},...w,{x:m.x+N.x,y:m.y+N.y},r],E,S,k,A]}function gA(e,t,r,l){const a=Math.min(Hv(e,t)/2,Hv(t,r)/2,l),{x:o,y:s}=t;if(e.x===o&&o===r.x||e.y===s&&s===r.y)return`L${o} ${s}`;if(e.y===s){const d=e.x{let A="";return k>0&&kr.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:r,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 d=nm(h,t);o.has(d)||(s.push({id:d,color:h.color||r,...h}),o.add(d))}}),s),[]).sort((s,c)=>s.id.localeCompare(c.id))}const L_=1e3,vA=10,Om={nodeOrigin:[0,0],nodeExtent:Vo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},bA={...Om,checkEquality:!0};function Lm(e,t){const r={...e};for(const l in t)t[l]!==void 0&&(r[l]=t[l]);return r}function wA(e,t,r){const l=Lm(Om,r);for(const a of e.values())if(a.parentId)Bm(a,e,t,l);else{const o=es(a,l.nodeOrigin),s=xa(a.extent)?a.extent:l.nodeExtent,c=rl(o,s,Or(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 r=[],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"?r.push(o):a.type==="target"&&l.push(o)}return{source:r,target:l}}function Hm(e){return e==="manual"}function rm(e,t,r,l={}){var d,m;const a=Lm(bA,l),o={i:0},s=new Map(t),c=a!=null&&a.elevateNodesOnSelect&&!Hm(a.zIndexMode)?L_:0;let h=e.length>0;t.clear(),r.clear();for(const p of e){let x=s.get(p.id);if(a.checkEquality&&p===(x==null?void 0:x.internals.userNode))t.set(p.id,x);else{const b=es(p,a.nodeOrigin),w=xa(p.extent)?p.extent:a.nodeExtent,E=rl(b,w,Or(p));x={...a.defaults,...p,measured:{width:(d=p.measured)==null?void 0:d.width,height:(m=p.measured)==null?void 0:m.height},internals:{positionAbsolute:E,handleBounds:_A(p,x),z:H_(p,c,a.zIndexMode),userNode:p}},t.set(p.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(h=!1),p.parentId&&Bm(x,t,r,l,o)}return h}function SA(e,t){if(!e.parentId)return;const r=t.get(e.parentId);r?r.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Bm(e,t,r,l,a){const{elevateNodesOnSelect:o,nodeOrigin:s,nodeExtent:c,zIndexMode:h}=Lm(Om,l),d=e.parentId,m=t.get(d);if(!m){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}SA(e,r),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)?L_:0,{x,y:b,z:w}=kA(e,m,s,c,p,h),{positionAbsolute:E}=e.internals,S=x!==E.x||b!==E.y;(S||w!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:S?{x,y:b}:E,z:w}})}function H_(e,t,r){const l=$n(e.zIndex)?e.zIndex:0;return Hm(r)?l:l+(e.selected?t:0)}function kA(e,t,r,l,a,o){const{x:s,y:c}=t.internals.positionAbsolute,h=Or(e),d=es(e,r),m=xa(e.extent)?rl(d,e.extent,h):d;let p=rl({x:s+m.x,y:c+m.y},l,h);e.extent==="parent"&&(p=E_(p,h,t));const x=H_(e,a,o),b=t.internals.z??0;return{x:p.x,y:p.y,z:b>=x?b+1:x}}function Im(e,t,r,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 d=((s=o.get(c.parentId))==null?void 0:s.expandedRect)??ga(h),m=C_(d,c.rect);o.set(c.parentId,{expandedRect:m,parent:h})}return o.size>0&&o.forEach(({expandedRect:c,parent:h},d)=>{var k;const m=h.internals.positionAbsolute,p=Or(h),x=h.origin??l,b=c.x0||w>0||_||N)&&(a.push({id:d,type:"position",position:{x:h.position.x-b+_,y:h.position.y-w+N}}),(k=r.get(d))==null||k.forEach(A=>{e.some(M=>M.id===A.id)||a.push({id:A.id,type:"position",position:{x:A.position.x+b,y:A.position.y+w}})})),(p.width0){const b=Im(x,t,r,a);d.push(...b)}return{changes:d,updatedInternals:h}}async function NA({delta:e,panZoom:t,transform:r,translateExtent:l,width:a,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:r[0]+e.x,y:r[1]+e.y,zoom:r[2]},[[0,0],[a,o]],l),c=!!s&&(s.x!==r[0]||s.y!==r[1]||s.k!==r[2]);return Promise.resolve(c)}function Uv(e,t,r,l,a,o){let s=a;const c=l.get(s)||new Map;l.set(s,c.set(r,t)),s=`${a}-${e}`;const h=l.get(s)||new Map;if(l.set(s,h.set(r,t)),o){s=`${a}-${e}-${o}`;const d=l.get(s)||new Map;l.set(s,d.set(r,t))}}function B_(e,t,r){e.clear(),t.clear();for(const l of r){const{source:a,target:o,sourceHandle:s=null,targetHandle:c=null}=l,h={edgeId:l.id,source:a,target:o,sourceHandle:s,targetHandle:c},d=`${a}-${s}--${o}-${c}`,m=`${o}-${c}--${a}-${s}`;Uv("source",h,m,e,a,s),Uv("target",h,d,e,o,c),t.set(l.id,l)}}function I_(e,t){if(!e.parentId)return!1;const r=t.get(e.parentId);return r?r.selected?!0:I_(r,t):!1}function $v(e,t,r){var a;let l=e;do{if((a=l==null?void 0:l.matches)!=null&&a.call(l,t))return!0;if(l===r)return!1;l=l==null?void 0:l.parentElement}while(l);return!1}function CA(e,t,r,l){const a=new Map;for(const[o,s]of e)if((s.selected||s.id===l)&&(!s.parentId||!I_(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:r.x-c.internals.positionAbsolute.x,y:r.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:r,dragging:l=!0}){var s,c,h;const a=[];for(const[d,m]of t){const p=(s=r.get(d))==null?void 0:s.internals.userNode;p&&a.push({...p,position:m.position,dragging:l})}if(!e)return[a[0],a];const o=(c=r.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:r,y:l}){const a=e.values().next().value;if(!a)return null;const o={x:r-a.distance.x,y:l-a.distance.y},s=ns(o,t);return{x:s.x-o.x,y:s.y-o.y}}function TA({onNodeMouseDown:e,getStoreItems:t,onDragStart:r,onDrag:l,onDragStop:a}){let o={x:null,y:null},s=0,c=new Map,h=!1,d={x:0,y:0},m=null,p=!1,x=null,b=!1,w=!1,E=null;function S({noDragClassName:N,handleSelector:k,domNode:A,isSelectable:M,nodeId:T,nodeClickDistance:L=0}){x=wn(A);function R({x:$,y:ee}){const{nodeLookup:I,nodeExtent:F,snapGrid:z,snapToGrid:G,nodeOrigin:Q,onNodeDrag:K,onSelectionDrag:D,onError:q,updateNodePositions:Y}=t();o={x:$,y:ee};let C=!1;const P=c.size>1,X=P&&F?em(ts(c)):null,J=P&&G?jA({dragItems:c,snapGrid:z,x:$,y:ee}):null;for(const[ne,re]of c){if(!I.has(ne))continue;let se={x:$-re.distance.x,y:ee-re.distance.y};G&&(se=J?{x:Math.round(se.x+J.x),y:Math.round(se.y+J.y)}:ns(se,z));let xe=null;if(P&&F&&!re.extent&&X){const{positionAbsolute:pe}=re.internals,Se=pe.x-X.x+F[0][0],De=pe.x+re.measured.width-X.x2+F[1][0],je=pe.y-X.y+F[0][1],ct=pe.y+re.measured.height-X.y2+F[1][1];xe=[[Se,je],[De,ct]]}const{position:be,positionAbsolute:ye}=k_({nodeId:ne,nextPosition:se,nodeLookup:I,nodeExtent:xe||F,nodeOrigin:Q,onError:q});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||!T&&D))){const[ne,re]=_h({nodeId:T,dragItems:c,nodeLookup:I});l==null||l(E,c,ne,re),K==null||K(E,ne,re),T||D==null||D(E,re)}}async function V(){if(!m)return;const{transform:$,panBy:ee,autoPanSpeed:I,autoPanOnNodeDrag:F}=t();if(!F){h=!1,cancelAnimationFrame(s);return}const[z,G]=N_(d,m,I);(z!==0||G!==0)&&(o.x=(o.x??0)-z/$[2],o.y=(o.y??0)-G/$[2],await ee({x:z,y:G})&&R(o)),s=requestAnimationFrame(V)}function H($){var P;const{nodeLookup:ee,multiSelectionActive:I,nodesDraggable:F,transform:z,snapGrid:G,snapToGrid:Q,selectNodesOnDrag:K,onNodeDragStart:D,onSelectionDragStart:q,unselectNodesAndEdges:Y}=t();p=!0,(!K||!M)&&!I&&T&&((P=ee.get(T))!=null&&P.selected||Y()),M&&K&&T&&(e==null||e(T));const C=Do($.sourceEvent,{transform:z,snapGrid:G,snapToGrid:Q,containerBounds:m});if(o=C,c=CA(ee,F,C,T),c.size>0&&(r||D||!T&&q)){const[X,J]=_h({nodeId:T,dragItems:c,nodeLookup:ee});r==null||r($.sourceEvent,c,X,J),D==null||D($.sourceEvent,X,J),T||q==null||q($.sourceEvent,J)}}const B=r_().clickDistance(L).on("start",$=>{const{domNode:ee,nodeDragThreshold:I,transform:F,snapGrid:z,snapToGrid:G}=t();m=(ee==null?void 0:ee.getBoundingClientRect())||null,b=!1,w=!1,E=$.sourceEvent,I===0&&H($),o=Do($.sourceEvent,{transform:F,snapGrid:z,snapToGrid:G,containerBounds:m}),d=Vn($.sourceEvent,m)}).on("drag",$=>{const{autoPanOnNodeDrag:ee,transform:I,snapGrid:F,snapToGrid:z,nodeDragThreshold:G,nodeLookup:Q}=t(),K=Do($.sourceEvent,{transform:I,snapGrid:F,snapToGrid:z,containerBounds:m});if(E=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||T&&!Q.has(T))&&(b=!0),!b){if(!h&&ee&&p&&(h=!0,V()),!p){const D=Vn($.sourceEvent,m),q=D.x-d.x,Y=D.y-d.y;Math.sqrt(q*q+Y*Y)>G&&H($)}(o.x!==K.xSnapped||o.y!==K.ySnapped)&&c&&p&&(d=Vn($.sourceEvent,m),R(K))}}).on("end",$=>{if(!(!p||b)&&(h=!1,p=!1,cancelAnimationFrame(s),c.size>0)){const{nodeLookup:ee,updateNodePositions:I,onNodeDragStop:F,onSelectionDragStop:z}=t();if(w&&(I(c,!1),w=!1),a||F||!T&&z){const[G,Q]=_h({nodeId:T,dragItems:c,nodeLookup:ee,dragging:!1});a==null||a($.sourceEvent,c,G,Q),F==null||F($.sourceEvent,G,Q),T||z==null||z($.sourceEvent,Q)}}}).filter($=>{const ee=$.target;return!$.button&&(!N||!$v(ee,`.${N}`,A))&&(!k||$v(ee,k,A))});x.call(B)}function _(){x==null||x.on(".drag",null)}return{update:S,destroy:_}}function AA(e,t,r){const l=[],a={x:e.x-r,y:e.y-r,width:r*2,height:r*2};for(const o of t.values())Go(a,ga(o))>0&&l.push(o);return l}const zA=250;function MA(e,t,r,l){var c,h;let a=[],o=1/0;const s=AA(e,r,t+zA);for(const d of s){const m=[...((c=d.internals.handleBounds)==null?void 0:c.source)??[],...((h=d.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,y:b}=il(d,p,p.position,!0),w=Math.sqrt(Math.pow(x-e.x,2)+Math.pow(b-e.y,2));w>t||(w1){const d=l.type==="source"?"target":"source";return a.find(m=>m.type===d)??a[0]}return a[0]}function q_(e,t,r,l,a,o=!1){var d,m,p;const s=l.get(e);if(!s)return null;const c=a==="strict"?(d=s.internals.handleBounds)==null?void 0:d[t]:[...((m=s.internals.handleBounds)==null?void 0:m.source)??[],...((p=s.internals.handleBounds)==null?void 0:p.target)??[]],h=(r?c==null?void 0:c.find(x=>x.id===r):c==null?void 0:c[0])??null;return h&&o?{...h,...il(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 r=null;return t?r=!0:e&&!t&&(r=!1),r}const $_=()=>!0;function RA(e,{connectionMode:t,connectionRadius:r,handleId:l,nodeId:a,edgeUpdaterType:o,isTarget:s,domNode:c,nodeLookup:h,lib:d,autoPanOnConnect:m,flowId:p,panBy:x,cancelConnection:b,onConnectStart:w,onConnect:E,onConnectEnd:S,isValidConnection:_=$_,onReconnectEnd:N,updateConnection:k,getTransform:A,getFromHandle:M,autoPanSpeed:T,dragThreshold:L=1,handleDomNode:R}){const V=A_(e.target);let H=0,B;const{x:$,y:ee}=Vn(e),I=U_(o,R),F=c==null?void 0:c.getBoundingClientRect();let z=!1;if(!F||!I)return;const G=q_(a,I,l,h,t);if(!G)return;let Q=Vn(e,F),K=!1,D=null,q=!1,Y=null;function C(){if(!m||!F)return;const[be,ye]=N_(Q,F,T);x({x:be,y:ye}),H=requestAnimationFrame(C)}const P={...G,nodeId:a,type:I,position:G.position},X=h.get(a);let ne={inProgress:!0,isValid:null,from:il(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:I})}L===0&&re();function se(be){if(!z){const{x:ct,y:nt}=Vn(be),Mt=ct-$,Pt=nt-ee;if(!(Mt*Mt+Pt*Pt>L*L))return;re()}if(!M()||!P){xe(be);return}const ye=A();Q=Vn(be,F),B=MA(rs(Q,ye,!1,[1,1]),r,h,P),K||(C(),K=!0);const pe=V_(be,{handle:B,connectionMode:t,fromNodeId:a,fromHandleId:l,fromType:s?"target":"source",isValidConnection:_,doc:V,lib:d,flowId:p,nodeLookup:h});Y=pe.handleDomNode,D=pe.connection,q=DA(!!B,pe.isValid);const Se=h.get(a),De=Se?il(Se,P,ve.Left,!0):ne.from,je={...ne,from:De,isValid:q,to:pe.toHandle&&q?xc({x:pe.toHandle.x,y:pe.toHandle.y},ye):Q,toHandle:pe.toHandle,toPosition:q&&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&&q&&(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,q=!1,D=null,Y=null,V.removeEventListener("mousemove",se),V.removeEventListener("mouseup",xe),V.removeEventListener("touchmove",se),V.removeEventListener("touchend",xe)}}V.addEventListener("mousemove",se),V.addEventListener("mouseup",xe),V.addEventListener("touchmove",se),V.addEventListener("touchend",xe)}function V_(e,{handle:t,connectionMode:r,fromNodeId:l,fromHandleId:a,fromType:o,doc:s,lib:c,flowId:h,isValidConnection:d=$_,nodeLookup:m}){const p=o==="target",x=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:x,_={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const N=U_(void 0,S),k=S.getAttribute("data-nodeid"),A=S.getAttribute("data-handleid"),M=S.classList.contains("connectable"),T=S.classList.contains("connectableend");if(!k||!N)return _;const L={source:p?k:l,sourceHandle:p?A:a,target:p?l:k,targetHandle:p?a:A};_.connection=L;const V=M&&T&&(r===pa.Strict?p&&N==="source"||!p&&N==="target":k!==l||A!==a);_.isValid=V&&d(L),_.toHandle=q_(k,N,A,m,r,!0)}return _}const im={onPointerDown:RA,isValid:V_};function OA({domNode:e,panZoom:t,getTransform:r,getViewScale:l}){const a=wn(e);function o({translateExtent:c,width:h,height:d,zoomStep:m=1,pannable:p=!0,zoomable:x=!0,inversePan:b=!1}){const w=k=>{if(k.sourceEvent.type!=="wheel"||!t)return;const A=r(),M=k.sourceEvent.ctrlKey&&Fo()?10:1,T=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*m,L=A[2]*Math.pow(2,T*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 A=r();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],T=[M[0]-E[0],M[1]-E[1]];E=M;const L=l()*Math.max(A[2],Math.log(A[2]))*(b?-1:1),R={x:A[0]-T[0]*L,y:A[1]-T[1]*L},V=[[0,0],[h,d]];t.setViewportConstrained({x:R.x,y:R.y,zoom:A[2]},V,c)},N=y_().on("start",S).on("zoom",p?_:null).on("zoom.wheel",x?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:r})=>Rc.translate(e,t).scale(r),ia=(e,t)=>e.target.closest(`.${t}`),P_=(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,r=LA,l=()=>{})=>{const a=typeof t=="number"&&t>0;return a||l(),a?e.transition().duration(t).ease(r).on("end",l):e},G_=e=>{const t=e.ctrlKey&&Fo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function HA({zoomPanValues:e,noWheelClassName:t,d3Selection:r,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:o,zoomOnPinch:s,onPanZoomStart:c,onPanZoom:h,onPanZoomEnd:d}){return m=>{if(ia(m,t))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const p=r.property("__zoom").k||1;if(m.ctrlKey&&s){const S=qn(m),_=G_(m),N=p*Math.pow(2,_);l.scaleTo(r,N,S,m);return}const x=m.deltaMode===1?20:1;let b=a===Wi.Vertical?0:m.deltaX*x,w=a===Wi.Horizontal?0:m.deltaY*x;!Fo()&&m.shiftKey&&a!==Wi.Vertical&&(b=m.deltaY*x,w=0),l.translateBy(r,-(b/p)*o,-(w/p)*o,{internal:!0});const E=Hc(r.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(h==null||h(m,E),e.panScrollTimeout=setTimeout(()=>{d==null||d(m,E),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c==null||c(m,E))}}function BA({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:r}){return function(l,a){const o=l.type==="wheel",s=!t&&o&&!l.ctrlKey,c=ia(l,e);if(l.ctrlKey&&o&&c&&l.preventDefault(),s||c)return null;l.preventDefault(),r.call(this,l,a)}}function IA({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:r}){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),r&&(r==null||r(l.sourceEvent,a))}}function qA({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:r,onTransformChange:l,onPanZoom:a}){return o=>{var s,c;e.usedRightMouseButton=!!(r&&P_(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:r,onDraggingChange:l,onPanZoomEnd:a,onPaneContextMenu:o}){return s=>{var c;if(!((c=s.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,o&&P_(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)},r?150:0)}}}function $A({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:r,panOnDrag:l,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:c,noPanClassName:h,lib:d,connectionInProgress:m}){return p=>{var S;const x=e||t,b=r&&p.ctrlKey,w=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(ia(p,`${d}-flow__node`)||ia(p,`${d}-flow__edge`)))return!0;if(!l&&!x&&!a&&!o&&!r||s||m&&!w||ia(p,c)&&w||ia(p,h)&&(!w||a&&w&&!e)||!r&&p.ctrlKey&&w)return!1;if(!r&&p.type==="touchstart"&&((S=p.touches)==null?void 0:S.length)>1)return p.preventDefault(),!1;if(!x&&!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:r,translateExtent:l,viewport:a,onPanZoom:o,onPanZoomStart:s,onPanZoomEnd:c,onDraggingChange:h}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=e.getBoundingClientRect(),p=y_().scaleExtent([t,r]).translateExtent(l),x=wn(e).call(p);N({x:a.x,y:a.y,zoom:ma(a.zoom,t,r)},[[0,0],[m.width,m.height]],l);const b=x.on("wheel.zoom"),w=x.on("dblclick.zoom");p.wheelDelta(G_);function E(B,$){return x?new Promise(ee=>{p==null||p.interpolate(($==null?void 0:$.interpolate)==="linear"?Mo:Wu).transform(kh(x,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function S({noWheelClassName:B,noPanClassName:$,onPaneContextMenu:ee,userSelectionActive:I,panOnScroll:F,panOnDrag:z,panOnScrollMode:G,panOnScrollSpeed:Q,preventScrolling:K,zoomOnPinch:D,zoomOnScroll:q,zoomOnDoubleClick:Y,zoomActivationKeyPressed:C,lib:P,onTransformChange:X,connectionInProgress:J,paneClickDistance:ne,selectionOnDrag:re}){I&&!d.isZoomingOrPanning&&_();const se=F&&!C&&!I;p.clickDistance(re?1/0:!$n(ne)||ne<0?0:ne);const xe=se?HA({zoomPanValues:d,noWheelClassName:B,d3Selection:x,d3Zoom:p,panOnScrollMode:G,panOnScrollSpeed:Q,zoomOnPinch:D,onPanZoomStart:s,onPanZoom:o,onPanZoomEnd:c}):BA({noWheelClassName:B,preventScrolling:K,d3ZoomHandler:b});if(x.on("wheel.zoom",xe,{passive:!1}),!I){const ye=IA({zoomPanValues:d,onDraggingChange:h,onPanZoomStart:s});p.on("start",ye);const pe=qA({zoomPanValues:d,panOnDrag:z,onPaneContextMenu:!!ee,onPanZoom:o,onTransformChange:X});p.on("zoom",pe);const Se=UA({zoomPanValues:d,panOnDrag:z,panOnScroll:F,onPaneContextMenu:ee,onPanZoomEnd:c,onDraggingChange:h});p.on("end",Se)}const be=$A({zoomActivationKeyPressed:C,panOnDrag:z,zoomOnScroll:q,panOnScroll:F,zoomOnDoubleClick:Y,zoomOnPinch:D,userSelectionActive:I,noPanClassName:$,noWheelClassName:B,lib:P,connectionInProgress:J});p.filter(be),Y?x.on("dblclick.zoom",w):x.on("dblclick.zoom",null)}function _(){p.on("zoom",null)}async function N(B,$,ee){const I=Sh(B),F=p==null?void 0:p.constrain()(I,$,ee);return F&&await E(F),new Promise(z=>z(F))}async function k(B,$){const ee=Sh(B);return await E(ee,$),new Promise(I=>I(ee))}function A(B){if(x){const $=Sh(B),ee=x.property("__zoom");(ee.k!==B.zoom||ee.x!==B.x||ee.y!==B.y)&&(p==null||p.transform(x,$,null,{sync:!0}))}}function M(){const B=x?x_(x.node()):{x:0,y:0,k:1};return{x:B.x,y:B.y,zoom:B.k}}function T(B,$){return x?new Promise(ee=>{p==null||p.interpolate(($==null?void 0:$.interpolate)==="linear"?Mo:Wu).scaleTo(kh(x,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function L(B,$){return x?new Promise(ee=>{p==null||p.interpolate(($==null?void 0:$.interpolate)==="linear"?Mo:Wu).scaleBy(kh(x,$==null?void 0:$.duration,$==null?void 0:$.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 $=!$n(B)||B<0?0:B;p==null||p.clickDistance($)}return{update:S,destroy:_,setViewport:k,setViewportConstrained:N,getViewport:M,scaleTo:T,scaleBy:L,setScaleExtent:R,setTranslateExtent:V,syncViewport:A,setClickDistance:H}}var ya;(function(e){e.Line="line",e.Handle="handle"})(ya||(ya={}));function PA({width:e,prevWidth:t,height:r,prevHeight:l,affectsX:a,affectsY:o}){const s=e-t,c=r-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"),r=e.includes("bottom")||e.includes("top"),l=e.includes("left"),a=e.includes("top");return{isHorizontal:t,isVertical:r,affectsX:l,affectsY:a}}function pi(e,t){return Math.max(0,t-e)}function mi(e,t){return Math.max(0,e-t)}function Pu(e,t,r){return Math.max(0,t-e,e-r)}function Pv(e,t){return e?!t:t}function GA(e,t,r,l,a,o,s,c){let{affectsX:h,affectsY:d}=t;const{isHorizontal:m,isVertical:p}=t,x=m&&p,{xSnapped:b,ySnapped:w}=r,{minWidth:E,maxWidth:S,minHeight:_,maxHeight:N}=l,{x:k,y:A,width:M,height:T,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=T+(d?-V:V),$=-o[0]*M,ee=-o[1]*T;let I=Pu(H,E,S),F=Pu(B,_,N);if(s){let Q=0,K=0;h&&R<0?Q=pi(k+R+$,s[0][0]):!h&&R>0&&(Q=mi(k+H+$,s[1][0])),d&&V<0?K=pi(A+V+ee,s[0][1]):!d&&V>0&&(K=mi(A+B+ee,s[1][1])),I=Math.max(I,Q),F=Math.max(F,K)}if(c){let Q=0,K=0;h&&R>0?Q=mi(k+R,c[0][0]):!h&&R<0&&(Q=pi(k+H,c[1][0])),d&&V>0?K=mi(A+V,c[0][1]):!d&&V<0&&(K=pi(A+B,c[1][1])),I=Math.max(I,Q),F=Math.max(F,K)}if(a){if(m){const Q=Pu(H/L,_,N)*L;if(I=Math.max(I,Q),s){let K=0;!h&&!d||h&&!d&&x?K=mi(A+ee+H/L,s[1][1])*L:K=pi(A+ee+(h?R:-R)/L,s[0][1])*L,I=Math.max(I,K)}if(c){let K=0;!h&&!d||h&&!d&&x?K=pi(A+H/L,c[1][1])*L:K=mi(A+(h?R:-R)/L,c[0][1])*L,I=Math.max(I,K)}}if(p){const Q=Pu(B*L,E,S)/L;if(F=Math.max(F,Q),s){let K=0;!h&&!d||d&&!h&&x?K=mi(k+B*L+$,s[1][0])/L:K=pi(k+(d?V:-V)*L+$,s[0][0])/L,F=Math.max(F,K)}if(c){let K=0;!h&&!d||d&&!h&&x?K=pi(k+B*L,c[1][0])/L:K=mi(k+(d?V:-V)*L,c[0][0])/L,F=Math.max(F,K)}}}V=V+(V<0?F:-F),R=R+(R<0?I:-I),a&&(x?H>B*L?V=(Pv(h,d)?-R:R)/L:R=(Pv(h,d)?-V:V)*L:m?(V=R/L,d=h):(R=V*L,h=d));const z=h?k+R:k,G=d?A+V:A;return{width:M+(h?-R:R),height:T+(d?-V:V),x:o[0]*R*(h?-1:1)+z,y:o[1]*V*(d?-1:1)+G}}const F_={width:0,height:0,x:0,y:0},FA={...F_,pointerX:0,pointerY:0,aspectRatio:1};function YA(e){return[[0,0],[e.measured.width,e.measured.height]]}function XA(e,t,r){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=r[0]*o,h=r[1]*s;return[[l-c,a-h],[l+o-c,a+s-h]]}function QA({domNode:e,nodeId:t,getStoreItems:r,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:d,boundaries:m,keepAspectRatio:p,resizeDirection:x,onResizeStart:b,onResize:w,onResizeEnd:E,shouldResize:S}){let _={...F_},N={...FA};s={boundaries:m,resizeDirection:x,keepAspectRatio:p,controlDirection:Vv(d)};let k,A=null,M=[],T,L,R,V=!1;const H=r_().on("start",B=>{const{nodeLookup:$,transform:ee,snapGrid:I,snapToGrid:F,nodeOrigin:z,paneDomNode:G}=r();if(k=$.get(t),!k)return;A=(G==null?void 0:G.getBoundingClientRect())??null;const{xSnapped:Q,ySnapped:K}=Do(B.sourceEvent,{transform:ee,snapGrid:I,snapToGrid:F,containerBounds:A});_={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},T=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(T=$.get(k.parentId),L=T&&k.extent==="parent"?YA(T):void 0),M=[],R=void 0;for(const[D,q]of $)if(q.parentId===t&&(M.push({id:D,position:{...q.position},extent:q.extent}),q.extent==="parent"||q.expandParent)){const Y=XA(q,k,q.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:$,snapGrid:ee,snapToGrid:I,nodeOrigin:F}=r(),z=Do(B.sourceEvent,{transform:$,snapGrid:ee,snapToGrid:I,containerBounds:A}),G=[];if(!k)return;const{x:Q,y:K,width:D,height:q}=_,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,se=X!==q,xe=J!==Q&&re,be=ne!==K&&se;if(!xe&&!be&&!re&&!se)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 De=J-Q,je=ne-K;for(const ct of M)ct.position={x:ct.position.x-De+C[0]*(P-D),y:ct.position.y-je+C[1]*(X-q)},G.push(ct)}if((re||se)&&(Y.width=re&&(!s.resizeDirection||s.resizeDirection==="horizontal")?P:_.width,Y.height=se&&(!s.resizeDirection||s.resizeDirection==="vertical")?X:_.height,_.width=Y.width,_.height=Y.height),T&&k.expandParent){const De=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 - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * 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=Ko();function t(p,x){return p===x&&(p!==0||1/p===1/x)||p!==p&&x!==x}var r=typeof Object.is=="function"?Object.is:t,l=e.useState,a=e.useEffect,o=e.useLayoutEffect,s=e.useDebugValue;function c(p,x){var b=x(),w=l({inst:{value:b,getSnapshot:x}}),E=w[0].inst,S=w[1];return o(function(){E.value=b,E.getSnapshot=x,h(E)&&S({inst:E})},[p,b,x]),a(function(){return h(E)&&S({inst:E}),p(function(){h(E)&&S({inst:E})})},[p]),s(b),b}function h(p){var x=p.getSnapshot;p=p.value;try{var b=x();return!r(p,b)}catch{return!0}}function d(p,x){return x()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d: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}/** - * @license React - * use-sync-external-store-shim/with-selector.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * 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=Ko(),t=KA();function r(d,m){return d===m&&(d!==0||1/d===1/m)||d!==d&&m!==m}var l=typeof Object.is=="function"?Object.is:r,a=t.useSyncExternalStore,o=e.useRef,s=e.useEffect,c=e.useMemo,h=e.useDebugValue;return Nh.useSyncExternalStoreWithSelector=function(d,m,p,x,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 _(T){if(!N){if(N=!0,k=T,T=x(T),b!==void 0&&E.hasValue){var L=E.value;if(b(L,T))return A=L}return A=T}if(L=A,l(k,T))return L;var R=x(T);return b!==void 0&&b(L,R)?(k=T,L):(k=T,A=R)}var N=!1,k,A,M=p===void 0?null:p;return[function(){return _(m())},M===null?void 0:function(){return _(M())}]},[m,p,x,b]);var S=a(d,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=Zo(ez),nz={},Qv=e=>{let t;const r=new Set,l=(m,p)=>{const x=typeof m=="function"?m(t):m;if(!Object.is(x,t)){const b=t;t=p??(typeof x!="object"||x===null)?x:Object.assign({},t,x),r.forEach(w=>w(t,b))}},a=()=>t,h={setState:l,getState:a,getInitialState:()=>d,subscribe:m=>(r.add(m),()=>r.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."),r.clear()}},d=t=e(l,a,h);return h},rz=e=>e?Qv(e):Qv,{useDebugValue:iz}=na,{useSyncExternalStoreWithSelector:lz}=tz,az=e=>e;function Y_(e,t=az,r){const l=lz(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return iz(l),l}const Zv=(e,t)=>{const r=rz(e),l=(a,o=t)=>Y_(r,a,o);return Object.assign(l,r),l},oz=(e,t)=>e?Zv(e,t):Zv;function pt(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 r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(const l of r)if(!Object.prototype.hasOwnProperty.call(t,l)||!Object.is(e[l],t[l]))return!1;return!0}var sz=pw();const Bc=U.createContext(null),uz=Bc.Provider,X_=lr.error001();function Ye(e,t){const r=U.useContext(Bc);if(r===null)throw new Error(X_);return Y_(r,e,t)}function mt(){const e=U.useContext(Bc);if(e===null)throw new Error(X_);return U.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%)"},Q_="react-flow__node-desc",Z_="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 r=Ye(hz);return y.jsxs(y.Fragment,{children:[y.jsx("div",{id:`${Q_}-${e}`,style:Kv,children:t?r["node.a11yDescription.default"]:r["node.a11yDescription.keyboardDisabled"]}),y.jsx("div",{id:`${Z_}-${e}`,style:Kv,children:r["edge.a11yDescription.default"]}),!t&&y.jsx(pz,{rfId:e})]})}const Ic=U.forwardRef(({position:e="top-left",children:t,className:r,style:l,...a},o)=>{const s=`${e}`.split("-");return y.jsx("div",{className:zt(["react-flow__panel",r,...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=[],r=[];for(const[,l]of e.nodeLookup)l.selected&&t.push(l.internals.userNode);for(const[,l]of e.edgeLookup)l.selected&&r.push(l);return{selectedNodes:t,selectedEdges:r}},Gu=e=>e.id;function yz(e,t){return pt(e.selectedNodes.map(Gu),t.selectedNodes.map(Gu))&&pt(e.selectedEdges.map(Gu),t.selectedEdges.map(Gu))}function vz({onSelectionChange:e}){const t=mt(),{selectedNodes:r,selectedEdges:l}=Ye(xz,yz);return U.useEffect(()=>{const a={nodes:r,edges:l};e==null||e(a),t.getState().onSelectionChangeHandlers.forEach(o=>o(a))},[r,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 K_=[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:Vo,nodeOrigin:K_,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Ez(e){const{setNodes:t,setEdges:r,setMinZoom:l,setMaxZoom:a,setTranslateExtent:o,setNodeExtent:s,reset:c,setDefaultNodesAndEdges:h}=Ye(kz,pt),d=mt();U.useEffect(()=>(h(e.defaultNodes,e.defaultEdges),()=>{m.current=Wv,c()}),[]);const m=U.useRef(Wv);return U.useEffect(()=>{for(const p of Jv){const x=e[p],b=m.current[p];x!==b&&(typeof e[p]>"u"||(p==="nodes"?t(x):p==="edges"?r(x):p==="minZoom"?l(x):p==="maxZoom"?a(x):p==="translateExtent"?o(x):p==="nodeExtent"?s(x):p==="ariaLabelConfig"?d.setState({ariaLabelConfig:oA(x)}):p==="fitView"?d.setState({fitViewQueued:x}):p==="fitViewOptions"?d.setState({fitViewOptions:x}):d.setState({[p]:x})))}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,r]=U.useState(e==="system"?null:e);return U.useEffect(()=>{if(e!=="system"){r(e);return}const a=eb(),o=()=>r(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 Yo(e=null,t={target:tb,actInsideInputWithModifier:!0}){const[r,l]=U.useState(!1),a=U.useRef(!1),o=U.useRef(new Set([])),[s,c]=U.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",` -`).replace(` - -`,` -+`).split(` -`)),m=d.reduce((p,x)=>p.concat(...x),[]);return[d,m]}return[[],[]]},[e]);return U.useEffect(()=>{const h=(t==null?void 0:t.target)??tb,d=(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&&!d)&&z_(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},x=()=>{o.current.clear(),l(!1)};return h==null||h.addEventListener("keydown",m),h==null||h.addEventListener("keyup",p),window.addEventListener("blur",x),window.addEventListener("contextmenu",x),()=>{h==null||h.removeEventListener("keydown",m),h==null||h.removeEventListener("keyup",p),window.removeEventListener("blur",x),window.removeEventListener("contextmenu",x)}}},[e,l]),r}function nb(e,t,r){return e.filter(l=>r||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=mt();return U.useMemo(()=>({zoomIn:t=>{const{panZoom:r}=e.getState();return r?r.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:r}=e.getState();return r?r.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,r)=>{const{panZoom:l}=e.getState();return l?l.scaleTo(t,{duration:r==null?void 0:r.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,r)=>{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},r),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,r,l]=e.getState().transform;return{x:t,y:r,zoom:l}},setCenter:async(t,r,l)=>e.getState().setCenter(t,r,l),fitBounds:async(t,r)=>{const{width:l,height:a,minZoom:o,maxZoom:s,panZoom:c}=e.getState(),h=Mm(t,l,a,o,s,(r==null?void 0:r.padding)??.1);return c?(await c.setViewport(h,{duration:r==null?void 0:r.duration,ease:r==null?void 0:r.ease,interpolate:r==null?void 0:r.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,r={})=>{const{transform:l,snapGrid:a,snapToGrid:o,domNode:s}=e.getState();if(!s)return t;const{x:c,y:h}=s.getBoundingClientRect(),d={x:t.x-c,y:t.y-h},m=r.snapGrid??a,p=r.snapToGrid??o;return rs(d,l,p,m)},flowToScreenPosition:t=>{const{transform:r,domNode:l}=e.getState();if(!l)return t;const{x:a,y:o}=l.getBoundingClientRect(),s=xc(t,r);return{x:s.x+a,y:s.y+o}}}),[])};function J_(e,t){const r=[],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){r.push(o);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){r.push({...s[0].item});continue}const c={...o};for(const h of s)jz(h,c);r.push(c)}return a.length&&a.forEach(o=>{o.index!==void 0?r.splice(o.index,0,{...o.item}):r.push({...o.item})}),r}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 W_(e,t){return J_(e,t)}function eS(e,t){return J_(e,t)}function Yi(e,t){return{id:e,type:"select",selected:t}}function la(e,t=new Set,r=!1){const l=[];for(const[a,o]of e){const s=t.has(a);!(o.selected===void 0&&!s)&&o.selected!==s&&(r&&(o.selected=s),l.push(Yi(o.id,s)))}return l}function ib({items:e=[],lookup:t}){var a;const r=[],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&&r.push({id:s.id,item:s,type:"replace"}),h===void 0&&r.push({item:s,type:"add",index:o})}for(const[o]of t)l.get(o)===void 0&&r.push({id:o,type:"remove"});return r}function lb(e){return{id:e.id,type:"remove"}}const ab=e=>KT(e),Tz=e=>S_(e);function tS(e){return U.forwardRef(e)}const Az=typeof window<"u"?U.useLayoutEffect:U.useEffect;function ob(e){const[t,r]=U.useState(BigInt(0)),[l]=U.useState(()=>zz(()=>r(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:r=>{t.push(r),e()}}}const nS=U.createContext(null);function Mz({children:e}){const t=mt(),r=U.useCallback(c=>{const{nodes:h=[],setNodes:d,hasDefaultNodes:m,onNodesChange:p,nodeLookup:x,fitViewQueued:b,onNodesChangeMiddlewareMap:w}=t.getState();let E=h;for(const _ of c)E=typeof _=="function"?_(E):_;let S=ib({items:E,lookup:x});for(const _ of w.values())S=_(S);m&&d(E),S.length>0?p==null||p(S):b&&window.requestAnimationFrame(()=>{const{fitViewQueued:_,nodes:N,setNodes:k}=t.getState();_&&k(N)})},[]),l=ob(r),a=U.useCallback(c=>{const{edges:h=[],setEdges:d,hasDefaultEdges:m,onEdgesChange:p,edgeLookup:x}=t.getState();let b=h;for(const w of c)b=typeof w=="function"?w(b):w;m?d(b):p&&p(ib({items:b,lookup:x}))},[]),o=ob(a),s=U.useMemo(()=>({nodeQueue:l,edgeQueue:o}),[]);return y.jsx(nS.Provider,{value:s,children:e})}function Dz(){const e=U.useContext(nS);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Rz=e=>!!e.panZoom;function sl(){const e=Cz(),t=mt(),r=Dz(),l=Ye(Rz),a=U.useMemo(()=>{const o=p=>t.getState().nodeLookup.get(p),s=p=>{r.nodeQueue.push(p)},c=p=>{r.edgeQueue.push(p)},h=p=>{var _,N;const{nodeLookup:x,nodeOrigin:b}=t.getState(),w=ab(p)?p:x.get(p.id),E=w.parentId?T_(w.position,w.measured,w.parentId,x,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 ga(S)},d=(p,x,b={replace:!1})=>{s(w=>w.map(E=>{if(E.id===p){const S=typeof x=="function"?x(E):x;return b.replace&&ab(S)?S:{...E,...S}}return E}))},m=(p,x,b={replace:!1})=>{c(w=>w.map(E=>{if(E.id===p){const S=typeof x=="function"?x(E):x;return b.replace&&Tz(S)?S:{...E,...S}}return E}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>{var x;return(x=o(p))==null?void 0:x.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(x=>({...x}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:s,setEdges:c,addNodes:p=>{const x=Array.isArray(p)?p:[p];r.nodeQueue.push(b=>[...b,...x])},addEdges:p=>{const x=Array.isArray(p)?p:[p];r.edgeQueue.push(b=>[...b,...x])},toObject:()=>{const{nodes:p=[],edges:x=[],transform:b}=t.getState(),[w,E,S]=b;return{nodes:p.map(_=>({..._})),edges:x.map(_=>({..._})),viewport:{x:w,y:E,zoom:S}}},deleteElements:async({nodes:p=[],edges:x=[]})=>{const{nodes:b,edges:w,onNodesDelete:E,onEdgesDelete:S,triggerNodeChanges:_,triggerEdgeChanges:N,onDelete:k,onBeforeDelete:A}=t.getState(),{nodes:M,edges:T}=await nA({nodesToRemove:p,edgesToRemove:x,nodes:b,edges:w,onBeforeDelete:A}),L=T.length>0,R=M.length>0;if(L){const V=T.map(lb);S==null||S(T),N(V)}if(R){const V=M.map(lb);E==null||E(M),_(V)}return(R||L)&&(k==null||k({nodes:M,edges:T})),{deletedNodes:M,deletedEdges:T}},getIntersectingNodes:(p,x=!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=ga(S?_:N),A=Go(k,E);return x&&A>0||A>=k.width*k.height||A>=E.width*E.height}):[]},isNodeIntersecting:(p,x,b=!0)=>{const E=Mv(p)?p:h(p);if(!E)return!1;const S=Go(E,x);return b&&S>0||S>=x.width*x.height||S>=E.width*E.height},updateNode:d,updateNodeData:(p,x,b={replace:!1})=>{d(p,w=>{const E=typeof x=="function"?x(w):x;return b.replace?{...w,data:E}:{...w,data:{...w.data,...E}}},b)},updateEdge:m,updateEdgeData:(p,x,b={replace:!1})=>{m(p,w=>{const E=typeof x=="function"?x(w):x;return b.replace?{...w,data:E}:{...w,data:{...w.data,...E}}},b)},getNodesBounds:p=>{const{nodeLookup:x,nodeOrigin:b}=t.getState();return JT(p,{nodeLookup:x,nodeOrigin:b})},getHandleConnections:({type:p,id:x,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}-${p}${x?`-${x}`:""}`))==null?void 0:w.values())??[])},getNodeConnections:({type:p,handleId:x,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}${p?x?`-${p}-${x}`:`-${p}`:""}`))==null?void 0:w.values())??[])},fitView:async p=>{const x=t.getState().fitViewResolver??aA();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:x}),r.nodeQueue.push(b=>[...b]),x.promise}}},[]);return U.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 r=mt(),{deleteElements:l}=sl(),a=Yo(e,{actInsideInputWithModifier:!1}),o=Yo(t,{target:Oz});U.useEffect(()=>{if(a){const{edges:s,nodes:c}=r.getState();l({nodes:c.filter(sb),edges:s.filter(sb)}),r.setState({nodesSelectionActive:!1})}},[a]),U.useEffect(()=>{r.setState({multiSelectionActive:o})},[o])}function Hz(e){const t=mt();U.useEffect(()=>{const r=()=>{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",lr.error004())),t.setState({width:l.width||500,height:l.height||500})};if(e.current){r(),window.addEventListener("resize",r);const l=new ResizeObserver(()=>r());return l.observe(e.current),()=>{window.removeEventListener("resize",r),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:r=!0,panOnScroll:l=!1,panOnScrollSpeed:a=.5,panOnScrollMode:o=Wi.Free,zoomOnDoubleClick:s=!0,panOnDrag:c=!0,defaultViewport:h,translateExtent:d,minZoom:m,maxZoom:p,zoomActivationKeyCode:x,preventScrolling:b=!0,children:w,noWheelClassName:E,noPanClassName:S,onViewportChange:_,isControlledViewport:N,paneClickDistance:k,selectionOnDrag:A}){const M=mt(),T=U.useRef(null),{userSelectionActive:L,lib:R,connectionInProgress:V}=Ye(Bz,pt),H=Yo(x),B=U.useRef();Hz(T);const $=U.useCallback(ee=>{_==null||_({x:ee[0],y:ee[1],zoom:ee[2]}),N||M.setState({transform:ee})},[_,N]);return U.useEffect(()=>{if(T.current){B.current=VA({domNode:T.current,minZoom:m,maxZoom:p,translateExtent:d,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:I,zoom:F}=B.current.getViewport();return M.setState({panZoom:B.current,transform:[ee,I,F],domNode:T.current.closest(".react-flow")}),()=>{var z;(z=B.current)==null||z.destroy()}}},[]),U.useEffect(()=>{var ee;(ee=B.current)==null||ee.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:r,panOnScroll:l,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:s,panOnDrag:c,zoomActivationKeyPressed:H,preventScrolling:b,noPanClassName:S,userSelectionActive:L,noWheelClassName:E,lib:R,onTransformChange:$,connectionInProgress:V,selectionOnDrag:A,paneClickDistance:k})},[e,t,r,l,a,o,s,c,H,b,S,L,E,R,$,V,A,k]),y.jsx("div",{className:"react-flow__renderer",ref:T,style:qc,children:w})}const qz=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Uz(){const{userSelectionActive:e,userSelectionRect:t}=Ye(qz,pt);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)=>r=>{r.target===t.current&&(e==null||e(r))},$z=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Vz({isSelecting:e,selectionKeyPressed:t,selectionMode:r=Po.Full,panOnDrag:l,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:h,onPaneContextMenu:d,onPaneScroll:m,onPaneMouseEnter:p,onPaneMouseMove:x,onPaneMouseLeave:b,children:w}){const E=mt(),{userSelectionActive:S,elementsSelectable:_,dragging:N,connectionInProgress:k}=Ye($z,pt),A=_&&(e||S),M=U.useRef(null),T=U.useRef(),L=U.useRef(new Set),R=U.useRef(new Set),V=U.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}d==null||d(Q)},$=m?Q=>m(Q):void 0,ee=Q=>{V.current&&(Q.stopPropagation(),V.current=!1)},I=Q=>{var X,J;const{domNode:K}=E.getState();if(T.current=K==null?void 0:K.getBoundingClientRect(),!T.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,T.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:q,edgeLookup:Y,connectionLookup:C,triggerNodeChanges:P,triggerEdgeChanges:X,defaultEdgeOptions:J,resetSelectedElements:ne}=E.getState();if(!T.current||!K)return;const{x:re,y:se}=Vn(Q.nativeEvent,T.current),{startX:xe,startY:be}=K;if(!V.current){const je=t?0:a;if(Math.hypot(re-xe,se-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 De=(J==null?void 0:J.selectable)??!0;for(const je of L.current){const ct=C.get(je);if(ct)for(const{edgeId:nt}of ct.values()){const Mt=Y.get(nt);Mt&&(Mt.selectable??De)&&R.current.add(nt)}}if(!Dv(pe,L.current)){const je=la(q,L.current,!0);P(je)}if(!Dv(Se,R.current)){const je=la(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:zt(["react-flow__pane",{draggable:G,dragging:N,selection:e}]),onClick:A?void 0:Th(H,M),onContextMenu:Th(B,M),onWheel:Th($,M),onPointerEnter:A?void 0:p,onPointerMove:A?F:x,onPointerUp:A?z:void 0,onPointerDownCapture:A?I:void 0,onClickCapture:A?ee:void 0,onPointerLeave:b,ref:M,style:qc,children:[w,y.jsx(Uz,{})]})}function lm({id:e,store:t,unselect:r=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:o,multiSelectionActive:s,nodeLookup:c,onError:h}=t.getState(),d=c.get(e);if(!d){h==null||h("012",lr.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(r||d.selected&&s)&&(o({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var m;return(m=l==null?void 0:l.current)==null?void 0:m.blur()})):a([e])}function rS({nodeRef:e,disabled:t=!1,noDragClassName:r,handleSelector:l,nodeId:a,isSelectable:o,nodeClickDistance:s}){const c=mt(),[h,d]=U.useState(!1),m=U.useRef();return U.useEffect(()=>{m.current=TA({getStoreItems:()=>c.getState(),onNodeMouseDown:p=>{lm({id:p,store:c,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),U.useEffect(()=>{if(!(t||!e.current||!m.current))return m.current.update({noDragClassName:r,handleSelector:l,domNode:e.current,isSelectable:o,nodeId:a,nodeClickDistance:s}),()=>{var p;(p=m.current)==null||p.destroy()}},[r,l,t,o,e,a,s]),h}const Pz=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function iS(){const e=mt();return U.useCallback(r=>{const{nodeExtent:l,snapToGrid:a,snapGrid:o,nodesDraggable:s,onError:c,updateNodePositions:h,nodeLookup:d,nodeOrigin:m}=e.getState(),p=new Map,x=Pz(s),b=a?o[0]:5,w=a?o[1]:5,E=r.direction.x*b*r.factor,S=r.direction.y*w*r.factor;for(const[,_]of d){if(!x(_))continue;let N={x:_.internals.positionAbsolute.x+E,y:_.internals.positionAbsolute.y+S};a&&(N=ns(N,o));const{position:k,positionAbsolute:A}=k_({nodeId:_.id,nextPosition:N,nodeLookup:d,nodeExtent:l,nodeOrigin:m,onError:c});_.position=k,_.internals.positionAbsolute=A,p.set(_.id,_)}h(p)},[])}const qm=U.createContext(null),Gz=qm.Provider;qm.Consumer;const lS=()=>U.useContext(qm),Fz=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Yz=(e,t,r)=>l=>{const{connectionClickStartHandle:a,connectionMode:o,connection:s}=l,{fromHandle:c,toHandle:h,isValid:d}=s,m=(h==null?void 0:h.nodeId)===e&&(h==null?void 0:h.id)===t&&(h==null?void 0:h.type)===r;return{connectingFrom:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===r,connectingTo:m,clickConnecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===r,isPossibleEndHandle:o===pa.Strict?(c==null?void 0:c.type)!==r:e!==(c==null?void 0:c.nodeId)||t!==(c==null?void 0:c.id),connectionInProcess:!!c,clickConnectionInProcess:!!a,valid:m&&d}};function Xz({type:e="source",position:t=ve.Top,isValidConnection:r,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:o=!0,id:s,onConnect:c,children:h,className:d,onMouseDown:m,onTouchStart:p,...x},b){var F,z;const w=s||null,E=e==="target",S=mt(),_=lS(),{connectOnClick:N,noPanClassName:k,rfId:A}=Ye(Fz,pt),{connectingFrom:M,connectingTo:T,clickConnecting:L,isPossibleEndHandle:R,connectionInProcess:V,clickConnectionInProcess:H,valid:B}=Ye(Yz(_,w,e),pt);_||(z=(F=S.getState()).onError)==null||z.call(F,"010",lr.error010());const $=G=>{const{defaultEdgeOptions:Q,onConnect:K,hasDefaultEdges:D}=S.getState(),q={...Q,...G};if(D){const{edges:Y,setEdges:C}=S.getState();C(hA(q,Y))}K==null||K(q),c==null||c(q)},ee=G=>{if(!_)return;const Q=M_(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 q,Y;return(Y=(q=S.getState()).onConnectEnd)==null?void 0:Y.call(q,...D)},updateConnection:K.updateConnection,onConnect:$,isValidConnection:r||((...D)=>{var q,Y;return((Y=(q=S.getState()).isValidConnection)==null?void 0:Y.call(q,...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)},I=G=>{const{onClickConnectStart:Q,onClickConnectEnd:K,connectionClickStartHandle:D,connectionMode:q,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=A_(G.target),re=r||Y,{connection:se,isValid:xe}=im.isValid(G.nativeEvent,{handle:{nodeId:_,id:w,type:e},connectionMode:q,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:re,flowId:P,doc:ne,lib:C,nodeLookup:X});xe&&se&&$(se);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":`${A}-${_}-${w}-${e}`,className:zt(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",k,d,{source:!E,target:E,connectable:l,connectablestart:a,connectableend:o,clickconnecting:L,connectingfrom:M,connectingto:T,valid:B,connectionindicator:l&&(!V||R)&&(V||H?o:a)}]),onMouseDown:ee,onTouchStart:ee,onClick:N?I:void 0,ref:b,...x,children:h})}const At=U.memo(tS(Xz));function Qz({data:e,isConnectable:t,sourcePosition:r=ve.Bottom}){return y.jsxs(y.Fragment,{children:[e==null?void 0:e.label,y.jsx(At,{type:"source",position:r,isConnectable:t})]})}function Zz({data:e,isConnectable:t,targetPosition:r=ve.Top,sourcePosition:l=ve.Bottom}){return y.jsxs(y.Fragment,{children:[y.jsx(At,{type:"target",position:r,isConnectable:t}),e==null?void 0:e.label,y.jsx(At,{type:"source",position:l,isConnectable:t})]})}function Kz(){return null}function Jz({data:e,isConnectable:t,targetPosition:r=ve.Top}){return y.jsxs(y.Fragment,{children:[y.jsx(At,{type:"target",position:r,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,r,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??((r=e.style)==null?void 0:r.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:r,x:l,y:a}=ts(e.nodeLookup,{filter:o=>!!o.selected});return{width:$n(t)?t:null,height:$n(r)?r: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:r}){const l=mt(),{width:a,height:o,transformString:s,userSelectionActive:c}=Ye(eM,pt),h=iS(),d=U.useRef(null);U.useEffect(()=>{var b;r||(b=d.current)==null||b.focus({preventScroll:!0})},[r]);const m=!c&&a!==null&&o!==null;if(rS({nodeRef:d,disabled:!m}),!m)return null;const p=e?b=>{const w=l.getState().nodes.filter(E=>E.selected);e(b,w)}:void 0,x=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:zt(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:y.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:r?void 0:-1,onKeyDown:r?void 0:x,style:{width:a,height:o}})})}const cb=typeof window<"u"?window:void 0,nM=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function aS({children:e,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:s,paneClickDistance:c,deleteKeyCode:h,selectionKeyCode:d,selectionOnDrag:m,selectionMode:p,onSelectionStart:x,onSelectionEnd:b,multiSelectionKeyCode:w,panActivationKeyCode:E,zoomActivationKeyCode:S,elementsSelectable:_,zoomOnScroll:N,zoomOnPinch:k,panOnScroll:A,panOnScrollSpeed:M,panOnScrollMode:T,zoomOnDoubleClick:L,panOnDrag:R,defaultViewport:V,translateExtent:H,minZoom:B,maxZoom:$,preventScrolling:ee,onSelectionContextMenu:I,noWheelClassName:F,noPanClassName:z,disableKeyboardA11y:G,onViewportChange:Q,isControlledViewport:K}){const{nodesSelectionActive:D,userSelectionActive:q}=Ye(nM,pt),Y=Yo(d,{target:cb}),C=Yo(E,{target:cb}),P=C||R,X=C||A,J=m&&P!==!0,ne=Y||q||J;return Lz({deleteKeyCode:h,multiSelectionKeyCode:w}),y.jsx(Iz,{onPaneContextMenu:o,elementsSelectable:_,zoomOnScroll:N,zoomOnPinch:k,panOnScroll:X,panOnScrollSpeed:M,panOnScrollMode:T,zoomOnDoubleClick:L,panOnDrag:!Y&&P,defaultViewport:V,translateExtent:H,minZoom:B,maxZoom:$,zoomActivationKeyCode:S,preventScrolling:ee,noWheelClassName:F,noPanClassName:z,onViewportChange:Q,isControlledViewport:K,paneClickDistance:c,selectionOnDrag:J,children:y.jsxs(Vz,{onSelectionStart:x,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:r,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:I,noPanClassName:z,disableKeyboardA11y:G})]})})}aS.displayName="FlowRenderer";const rM=U.memo(aS),iM=e=>t=>e?zm(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(r=>r.id):Array.from(t.nodeLookup.keys());function lM(e){return Ye(U.useCallback(iM(e),[e]),pt)}const aM=e=>e.updateNodeInternals;function oM(){const e=Ye(aM),[t]=U.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(r=>{const l=new Map;r.forEach(a=>{const o=a.target.getAttribute("data-id");l.set(o,{id:o,nodeElement:a.target,force:!0})}),e(l)}));return U.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function sM({node:e,nodeType:t,hasDimensions:r,resizeObserver:l}){const a=mt(),o=U.useRef(null),s=U.useRef(null),c=U.useRef(e.sourcePosition),h=U.useRef(e.targetPosition),d=U.useRef(t),m=r&&!!e.internals.handleBounds;return U.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]),U.useEffect(()=>()=>{s.current&&(l==null||l.unobserve(s.current),s.current=null)},[]),U.useEffect(()=>{if(o.current){const p=d.current!==t,x=c.current!==e.sourcePosition,b=h.current!==e.targetPosition;(p||x||b)&&(d.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:r,onMouseMove:l,onMouseLeave:a,onContextMenu:o,onDoubleClick:s,nodesDraggable:c,elementsSelectable:h,nodesConnectable:d,nodesFocusable:m,resizeObserver:p,noDragClassName:x,noPanClassName:b,disableKeyboardA11y:w,rfId:E,nodeTypes:S,nodeClickDistance:_,onError:N}){const{node:k,internals:A,isParent:M}=Ye(re=>{const se=re.nodeLookup.get(e),xe=re.parentLookup.has(e);return{node:se,internals:se.internals,isParent:xe}},pt);let T=k.type||"default",L=(S==null?void 0:S[T])||ub[T];L===void 0&&(N==null||N("003",lr.error003(T)),T="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||d&&typeof k.connectable>"u"),B=!!(k.focusable||m&&typeof k.focusable>"u"),$=mt(),ee=j_(k),I=sM({node:k,nodeType:T,hasDimensions:ee,resizeObserver:p}),F=rS({nodeRef:I,disabled:k.hidden||!R,noDragClassName:x,handleSelector:k.dragHandle,nodeId:e,isSelectable:V,nodeClickDistance:_}),z=iS();if(k.hidden)return null;const G=Or(k),Q=Wz(k),K=V||R||t||r||l||a,D=r?re=>r(re,{...A.userNode}):void 0,q=l?re=>l(re,{...A.userNode}):void 0,Y=a?re=>a(re,{...A.userNode}):void 0,C=o?re=>o(re,{...A.userNode}):void 0,P=s?re=>s(re,{...A.userNode}):void 0,X=re=>{const{selectNodesOnDrag:se,nodeDragThreshold:xe}=$.getState();V&&(!se||!R||xe>0)&&lm({id:e,store:$,nodeRef:I}),t&&t(re,{...A.userNode})},J=re=>{if(!(z_(re.nativeEvent)||w)){if(v_.includes(re.key)&&V){const se=re.key==="Escape";lm({id:e,store:$,unselect:se,nodeRef:I})}else if(R&&k.selected&&Object.prototype.hasOwnProperty.call(yc,re.key)){re.preventDefault();const{ariaLabelConfig:se}=$.getState();$.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:re.key.replace("Arrow","").toLowerCase(),x:~~A.positionAbsolute.x,y:~~A.positionAbsolute.y})}),z({direction:yc[re.key],factor:re.shiftKey?4:1})}}},ne=()=>{var Se;if(w||!((Se=I.current)!=null&&Se.matches(":focus-visible")))return;const{transform:re,width:se,height:xe,autoPanOnNodeFocus:be,setCenter:ye}=$.getState();if(!be)return;zm(new Map([[e,k]]),{x:0,y:0,width:se,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:zt(["react-flow__node",`react-flow__node-${T}`,{[b]:R},k.className,{selected:k.selected,selectable:V,parent:M,draggable:R,dragging:F}]),ref:I,style:{zIndex:A.z,transform:`translate(${A.positionAbsolute.x}px,${A.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:q,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:`${Q_}-${E}`,"aria-label":k.ariaLabel,...k.domAttributes,children:y.jsx(Gz,{value:e,children:y.jsx(L,{id:e,data:k.data,type:T,positionAbsoluteX:A.positionAbsolute.x,positionAbsoluteY:A.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:A.z,parentId:k.parentId,...G})})})}var cM=U.memo(uM);const fM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function oS(e){const{nodesDraggable:t,nodesConnectable:r,nodesFocusable:l,elementsSelectable:a,onError:o}=Ye(fM,pt),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:r,nodesFocusable:l,elementsSelectable:a,nodeClickDistance:e.nodeClickDistance,onError:o},h))})}oS.displayName="NodeRenderer";const dM=U.memo(oS);function hM(e){return Ye(U.useCallback(r=>{if(!e)return r.edges.map(a=>a.id);const l=[];if(r.width&&r.height)for(const a of r.edges){const o=r.nodeLookup.get(a.source),s=r.nodeLookup.get(a.target);o&&s&&cA({sourceNode:o,targetNode:s,width:r.width,height:r.height,transform:r.transform})&&l.push(a.id)}return l},[e]),pt)}const pM=({color:e="none",strokeWidth:t=1})=>{const r={strokeWidth:t,...e&&{stroke:e}};return y.jsx("polyline",{className:"arrow",style:r,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},mM=({color:e="none",strokeWidth:t=1})=>{const r={strokeWidth:t,...e&&{stroke:e,fill:e}};return y.jsx("polyline",{className:"arrowclosed",style:r,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=mt();return U.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(fb,e)?fb[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",lr.error009(e)),null)},[e])}const xM=({id:e,type:t,color:r,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:r,strokeWidth:s})}):null},sS=({defaultColor:e,rfId:t})=>{const r=Ye(o=>o.edges),l=Ye(o=>o.defaultEdgeOptions),a=U.useMemo(()=>yA(r,{id:t,defaultColor:e,defaultMarkerStart:l==null?void 0:l.markerStart,defaultMarkerEnd:l==null?void 0:l.markerEnd}),[r,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};sS.displayName="MarkerDefinitions";var yM=U.memo(sS);function uS({x:e,y:t,label:r,labelStyle:l,labelShowBg:a=!0,labelBgStyle:o,labelBgPadding:s=[2,4],labelBgBorderRadius:c=2,children:h,className:d,...m}){const[p,x]=U.useState({x:1,y:0,width:0,height:0}),b=zt(["react-flow__edge-textwrapper",d]),w=U.useRef(null);return U.useEffect(()=>{if(w.current){const E=w.current.getBBox();x({x:E.x,y:E.y,width:E.width,height:E.height})}},[r]),r?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:r}),h]}):null}uS.displayName="EdgeText";const vM=U.memo(uS);function is({path:e,labelX:t,labelY:r,label:l,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:h,interactionWidth:d=20,...m}){return y.jsxs(y.Fragment,{children:[y.jsx("path",{...m,d:e,fill:"none",className:zt(["react-flow__edge-path",m.className])}),d?y.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,l&&$n(t)&&$n(r)?y.jsx(vM,{x:t,y:r,label:l,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:h}):null]})}function db({pos:e,x1:t,y1:r,x2:l,y2:a}){return e===ve.Left||e===ve.Right?[.5*(t+l),r]:[t,.5*(r+a)]}function cS({sourceX:e,sourceY:t,sourcePosition:r=ve.Bottom,targetX:l,targetY:a,targetPosition:o=ve.Top}){const[s,c]=db({pos:r,x1:e,y1:t,x2:l,y2:a}),[h,d]=db({pos:o,x1:l,y1:a,x2:e,y2:t}),[m,p,x,b]=D_({sourceX:e,sourceY:t,targetX:l,targetY:a,sourceControlX:s,sourceControlY:c,targetControlX:h,targetControlY:d});return[`M${e},${t} C${s},${c} ${h},${d} ${l},${a}`,m,p,x,b]}function fS(e){return U.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,label:h,labelStyle:d,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,interactionWidth:_})=>{const[N,k,A]=cS({sourceX:r,sourceY:l,sourcePosition:s,targetX:a,targetY:o,targetPosition:c}),M=e.isInternal?void 0:t;return y.jsx(is,{id:M,path:N,labelX:k,labelY:A,label:h,labelStyle:d,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,interactionWidth:_})})}const bM=fS({isInternal:!1}),dS=fS({isInternal:!0});bM.displayName="SimpleBezierEdge";dS.displayName="SimpleBezierEdgeInternal";function hS(e){return U.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:d,labelBgPadding:m,labelBgBorderRadius:p,style:x,sourcePosition:b=ve.Bottom,targetPosition:w=ve.Top,markerEnd:E,markerStart:S,pathOptions:_,interactionWidth:N})=>{const[k,A,M]=tm({sourceX:r,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}),T=e.isInternal?void 0:t;return y.jsx(is,{id:T,path:k,labelX:A,labelY:M,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:d,labelBgPadding:m,labelBgBorderRadius:p,style:x,markerEnd:E,markerStart:S,interactionWidth:N})})}const pS=hS({isInternal:!1}),mS=hS({isInternal:!0});pS.displayName="SmoothStepEdge";mS.displayName="SmoothStepEdgeInternal";function gS(e){return U.memo(({id:t,...r})=>{var a;const l=e.isInternal?void 0:t;return y.jsx(pS,{...r,id:l,pathOptions:U.useMemo(()=>{var o;return{borderRadius:0,offset:(o=r.pathOptions)==null?void 0:o.offset}},[(a=r.pathOptions)==null?void 0:a.offset])})})}const wM=gS({isInternal:!1}),xS=gS({isInternal:!0});wM.displayName="StepEdge";xS.displayName="StepEdgeInternal";function yS(e){return U.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:d,labelBgPadding:m,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:w,interactionWidth:E})=>{const[S,_,N]=O_({sourceX:r,sourceY:l,targetX:a,targetY:o}),k=e.isInternal?void 0:t;return y.jsx(is,{id:k,path:S,labelX:_,labelY:N,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:d,labelBgPadding:m,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:w,interactionWidth:E})})}const _M=yS({isInternal:!1}),vS=yS({isInternal:!0});_M.displayName="StraightEdge";vS.displayName="StraightEdgeInternal";function bS(e){return U.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:s=ve.Bottom,targetPosition:c=ve.Top,label:h,labelStyle:d,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,pathOptions:_,interactionWidth:N})=>{const[k,A,M]=Rm({sourceX:r,sourceY:l,sourcePosition:s,targetX:a,targetY:o,targetPosition:c,curvature:_==null?void 0:_.curvature}),T=e.isInternal?void 0:t;return y.jsx(is,{id:T,path:k,labelX:A,labelY:M,label:h,labelStyle:d,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,interactionWidth:N})})}const SM=bS({isInternal:!1}),wS=bS({isInternal:!0});SM.displayName="BezierEdge";wS.displayName="BezierEdgeInternal";const hb={default:wS,straight:vS,step:xS,smoothstep:mS,simplebezier:dS},pb={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},kM=(e,t,r)=>r===ve.Left?e-t:r===ve.Right?e+t:e,EM=(e,t,r)=>r===ve.Top?e-t:r===ve.Bottom?e+t:e,mb="react-flow__edgeupdater";function gb({position:e,centerX:t,centerY:r,radius:l=10,onMouseDown:a,onMouseEnter:o,onMouseOut:s,type:c}){return y.jsx("circle",{onMouseDown:a,onMouseEnter:o,onMouseOut:s,className:zt([mb,`${mb}-${c}`]),cx:kM(t,l,e),cy:EM(r,l,e),r:l,stroke:"transparent",fill:"transparent"})}function NM({isReconnectable:e,reconnectRadius:t,edge:r,sourceX:l,sourceY:a,targetX:o,targetY:s,sourcePosition:c,targetPosition:h,onReconnect:d,onReconnectStart:m,onReconnectEnd:p,setReconnecting:x,setUpdateHover:b}){const w=mt(),E=(A,M)=>{if(A.button!==0)return;const{autoPanOnConnect:T,domNode:L,connectionMode:R,connectionRadius:V,lib:H,onConnectStart:B,cancelConnection:$,nodeLookup:ee,rfId:I,panBy:F,updateConnection:z}=w.getState(),G=M.type==="target",Q=(q,Y)=>{x(!1),p==null||p(q,r,M.type,Y)},K=q=>d==null?void 0:d(r,q),D=(q,Y)=>{x(!0),m==null||m(A,r,M.type),B==null||B(q,Y)};im.onPointerDown(A.nativeEvent,{autoPanOnConnect:T,connectionMode:R,connectionRadius:V,domNode:L,handleId:M.id,nodeId:M.nodeId,nodeLookup:ee,isTarget:G,edgeUpdaterType:M.type,lib:H,flowId:I,cancelConnection:$,panBy:F,isValidConnection:(...q)=>{var Y,C;return((C=(Y=w.getState()).isValidConnection)==null?void 0:C.call(Y,...q))??!0},onConnect:K,onConnectStart:D,onConnectEnd:(...q)=>{var Y,C;return(C=(Y=w.getState()).onConnectEnd)==null?void 0:C.call(Y,...q)},onReconnectEnd:Q,updateConnection:z,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:A.currentTarget})},S=A=>E(A,{nodeId:r.target,id:r.targetHandle??null,type:"target"}),_=A=>E(A,{nodeId:r.source,id:r.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:r,elementsSelectable:l,onClick:a,onDoubleClick:o,onContextMenu:s,onMouseEnter:c,onMouseMove:h,onMouseLeave:d,reconnectRadius:m,onReconnect:p,onReconnectStart:x,onReconnectEnd:b,rfId:w,edgeTypes:E,noPanClassName:S,onError:_,disableKeyboardA11y:N}){let k=Ye(ye=>ye.edgeLookup.get(e));const A=Ye(ye=>ye.defaultEdgeOptions);k=A?{...A,...k}:k;let M=k.type||"default",T=(E==null?void 0:E[M])||hb[M];T===void 0&&(_==null||_("011",lr.error011(M)),M="default",T=(E==null?void 0:E.default)||hb.default);const L=!!(k.focusable||t&&typeof k.focusable>"u"),R=typeof p<"u"&&(k.reconnectable||r&&typeof k.reconnectable>"u"),V=!!(k.selectable||l&&typeof k.selectable>"u"),H=U.useRef(null),[B,$]=U.useState(!1),[ee,I]=U.useState(!1),F=mt(),{zIndex:z,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:q,targetPosition:Y}=Ye(U.useCallback(ye=>{const pe=ye.nodeLookup.get(k.source),Se=ye.nodeLookup.get(k.target);if(!pe||!Se)return{zIndex:k.zIndex,...pb};const De=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}),...De||pb}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex]),pt),C=U.useMemo(()=>k.markerStart?`url('#${nm(k.markerStart,w)}')`:void 0,[k.markerStart,w]),P=U.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:De}=F.getState();V&&(F.setState({nodesSelectionActive:!1}),k.selected&&De?(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,se=h?ye=>{h(ye,{...k})}:void 0,xe=d?ye=>{d(ye,{...k})}:void 0,be=ye=>{var pe;if(!N&&v_.includes(ye.key)&&V){const{unselectNodesAndEdges:Se,addSelectedEdges:De}=F.getState();ye.key==="Escape"?((pe=H.current)==null||pe.blur(),Se({edges:[k]})):De([e])}};return y.jsx("svg",{style:{zIndex:z},children:y.jsxs("g",{className:zt(["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:se,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?`${Z_}-${w}`:void 0,ref:H,...k.domAttributes,children:[!ee&&y.jsx(T,{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:q,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:x,onReconnectEnd:b,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:q,targetPosition:Y,setUpdateHover:$,setReconnecting:I})]})})}var jM=U.memo(CM);const TM=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function _S({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:r,edgeTypes:l,noPanClassName:a,onReconnect:o,onEdgeContextMenu:s,onEdgeMouseEnter:c,onEdgeMouseMove:h,onEdgeMouseLeave:d,onEdgeClick:m,reconnectRadius:p,onEdgeDoubleClick:x,onReconnectStart:b,onReconnectEnd:w,disableKeyboardA11y:E}){const{edgesFocusable:S,edgesReconnectable:_,elementsSelectable:N,onError:k}=Ye(TM,pt),A=hM(t);return y.jsxs("div",{className:"react-flow__edges",children:[y.jsx(yM,{defaultColor:e,rfId:r}),A.map(M=>y.jsx(jM,{id:M,edgesFocusable:S,edgesReconnectable:_,elementsSelectable:N,noPanClassName:a,onReconnect:o,onContextMenu:s,onMouseEnter:c,onMouseMove:h,onMouseLeave:d,onClick:m,reconnectRadius:p,onDoubleClick:x,onReconnectStart:b,onReconnectEnd:w,rfId:r,onError:k,edgeTypes:l,disableKeyboardA11y:E},M))]})}_S.displayName="EdgeRenderer";const AM=U.memo(_S),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=sl(),r=U.useRef(!1);U.useEffect(()=>{!r.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),r.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),r=mt();return U.useEffect(()=>{e&&(t==null||t(e),r.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function LM(e){return e.connection.inProgress?{...e.connection,to:rs(e.connection.to,e.transform)}:{...e.connection}}function HM(e){return LM}function BM(e){const t=HM();return Ye(t,pt)}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:r,component:l}){const{nodesConnectable:a,width:o,height:s,isValid:c,inProgress:h}=Ye(IM,pt);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:zt(["react-flow__connection",__(c)]),children:y.jsx(SS,{style:t,type:r,CustomComponent:l,isValid:c})})})}const SS=({style:e,type:t=yi.Bezier,CustomComponent:r,isValid:l})=>{const{inProgress:a,from:o,fromNode:s,fromHandle:c,fromPosition:h,to:d,toNode:m,toHandle:p,toPosition:x,pointer:b}=BM();if(!a)return;if(r)return y.jsx(r,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:c,fromX:o.x,fromY:o.y,toX:d.x,toY:d.y,fromPosition:h,toPosition:x,connectionStatus:__(l),toNode:m,toHandle:p,pointer:b});let w="";const E={sourceX:o.x,sourceY:o.y,sourcePosition:h,targetX:d.x,targetY:d.y,targetPosition:x};switch(t){case yi.Bezier:[w]=Rm(E);break;case yi.SimpleBezier:[w]=cS(E);break;case yi.Step:[w]=tm({...E,borderRadius:0});break;case yi.SmoothStep:[w]=tm(E);break;default:[w]=O_(E)}return y.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};SS.displayName="ConnectionLine";const UM={};function xb(e=UM){U.useRef(e),mt(),U.useEffect(()=>{},[e])}function $M(){mt(),U.useRef(!1),U.useEffect(()=>{},[])}function kS({nodeTypes:e,edgeTypes:t,onInit:r,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:o,onEdgeDoubleClick:s,onNodeMouseEnter:c,onNodeMouseMove:h,onNodeMouseLeave:d,onNodeContextMenu:m,onSelectionContextMenu:p,onSelectionStart:x,onSelectionEnd:b,connectionLineType:w,connectionLineStyle:E,connectionLineComponent:S,connectionLineContainerStyle:_,selectionKeyCode:N,selectionOnDrag:k,selectionMode:A,multiSelectionKeyCode:M,panActivationKeyCode:T,zoomActivationKeyCode:L,deleteKeyCode:R,onlyRenderVisibleElements:V,elementsSelectable:H,defaultViewport:B,translateExtent:$,minZoom:ee,maxZoom:I,preventScrolling:F,defaultMarkerColor:z,zoomOnScroll:G,zoomOnPinch:Q,panOnScroll:K,panOnScrollSpeed:D,panOnScrollMode:q,zoomOnDoubleClick:Y,panOnDrag:C,onPaneClick:P,onPaneMouseEnter:X,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneScroll:re,onPaneContextMenu:se,paneClickDistance:xe,nodeClickDistance:be,onEdgeContextMenu:ye,onEdgeMouseEnter:pe,onEdgeMouseMove:Se,onEdgeMouseLeave:De,reconnectRadius:je,onReconnect:ct,onReconnectStart:nt,onReconnectEnd:Mt,noDragClassName:Pt,noWheelClassName:Bt,noPanClassName:kn,disableKeyboardA11y:Rn,nodeExtent:Dt,rfId:Br,viewport:ce,onViewportChange:ge}){return xb(e),xb(t),$M(),DM(r),OM(ce),y.jsx(rM,{onPaneClick:P,onPaneMouseEnter:X,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneContextMenu:se,onPaneScroll:re,paneClickDistance:xe,deleteKeyCode:R,selectionKeyCode:N,selectionOnDrag:k,selectionMode:A,onSelectionStart:x,onSelectionEnd:b,multiSelectionKeyCode:M,panActivationKeyCode:T,zoomActivationKeyCode:L,elementsSelectable:H,zoomOnScroll:G,zoomOnPinch:Q,zoomOnDoubleClick:Y,panOnScroll:K,panOnScrollSpeed:D,panOnScrollMode:q,panOnDrag:C,defaultViewport:B,translateExtent:$,minZoom:ee,maxZoom:I,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:ct,onReconnectStart:nt,onReconnectEnd:Mt,onlyRenderVisibleElements:V,onEdgeContextMenu:ye,onEdgeMouseEnter:pe,onEdgeMouseMove:Se,onEdgeMouseLeave:De,reconnectRadius:je,defaultMarkerColor:z,noPanClassName:kn,disableKeyboardA11y:Rn,rfId:Br}),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:d,onNodeContextMenu:m,nodeClickDistance:be,onlyRenderVisibleElements:V,noPanClassName:kn,noDragClassName:Pt,disableKeyboardA11y:Rn,nodeExtent:Dt,rfId:Br}),y.jsx("div",{className:"react-flow__viewport-portal"})]})})}kS.displayName="GraphView";const VM=U.memo(kS),yb=({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:h=.5,maxZoom:d=2,nodeOrigin:m,nodeExtent:p,zIndexMode:x="basic"}={})=>{const b=new Map,w=new Map,E=new Map,S=new Map,_=l??t??[],N=r??e??[],k=m??[0,0],A=p??Vo;B_(E,S,_);const M=rm(N,b,w,{nodeOrigin:k,nodeExtent:A,zIndexMode:x});let T=[0,0,1];if(s&&a&&o){const L=ts(b,{filter:B=>!!((B.width||B.initialWidth)&&(B.height||B.initialHeight))}),{x:R,y:V,zoom:H}=Mm(L,a,o,h,d,(c==null?void 0:c.padding)??.1);T=[R,V,H]}return{rfId:"1",width:a??0,height:o??0,transform:T,nodes:N,nodesInitialized:M,nodeLookup:b,parentLookup:w,edges:_,edgeLookup:S,connectionLookup:E,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:r!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:h,maxZoom:d,translateExtent:Vo,nodeExtent:A,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:pa.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:{...w_},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:b_,zIndexMode:x,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},PM=({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:h,maxZoom:d,nodeOrigin:m,nodeExtent:p,zIndexMode:x})=>oz((b,w)=>{async function E(){const{nodeLookup:S,panZoom:_,fitViewOptions:N,fitViewResolver:k,width:A,height:M,minZoom:T,maxZoom:L}=w();_&&(await tA({nodes:S,width:A,height:M,panZoom:_,minZoom:T,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:d,nodeOrigin:m,nodeExtent:p,defaultNodes:r,defaultEdges:l,zIndexMode:x}),setNodes:S=>{const{nodeLookup:_,parentLookup:N,nodeOrigin:k,elevateNodesOnSelect:A,fitViewQueued:M,zIndexMode:T}=w(),L=rm(S,_,N,{nodeOrigin:k,nodeExtent:p,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:T});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();B_(_,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:A,nodeOrigin:M,nodeExtent:T,debug:L,fitViewQueued:R,zIndexMode:V}=w(),{changes:H,updatedInternals:B}=EA(S,N,k,A,M,T,V);B&&(wA(N,k,{nodeOrigin:M,nodeExtent:T,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:A,triggerNodeChanges:M,connection:T,updateConnection:L,onNodesChangeMiddlewareMap:R}=w();for(const[V,H]of S){const B=A.get(V),$=!!(B!=null&&B.expandParent&&(B!=null&&B.parentId)&&(H!=null&&H.position)),ee={id:V,type:"position",position:$?{x:Math.max(0,H.position.x),y:Math.max(0,H.position.y)}:H.position,dragging:_};if(B&&T.inProgress&&T.fromNode.id===B.id){const I=il(B,T.fromHandle,ve.Left,!0);L({...T,from:I})}$&&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,A,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:A,debug:M}=w();if(S!=null&&S.length){if(A){const T=W_(S,k);N(T)}M&&console.log("React Flow: trigger node changes",S),_==null||_(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:_,setEdges:N,edges:k,hasDefaultEdges:A,debug:M}=w();if(S!=null&&S.length){if(A){const T=eS(S,k);N(T)}M&&console.log("React Flow: trigger edge changes",S),_==null||_(S)}},addSelectedNodes:S=>{const{multiSelectionActive:_,edgeLookup:N,nodeLookup:k,triggerNodeChanges:A,triggerEdgeChanges:M}=w();if(_){const T=S.map(L=>Yi(L,!0));A(T);return}A(la(k,new Set([...S]),!0)),M(la(N))},addSelectedEdges:S=>{const{multiSelectionActive:_,edgeLookup:N,nodeLookup:k,triggerNodeChanges:A,triggerEdgeChanges:M}=w();if(_){const T=S.map(L=>Yi(L,!0));M(T);return}M(la(N,new Set([...S]))),A(la(k,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:_}={})=>{const{edges:N,nodes:k,nodeLookup:A,triggerNodeChanges:M,triggerEdgeChanges:T}=w(),L=S||k,R=_||N,V=[];for(const B of L){if(!B.selected)continue;const $=A.get(B.id);$&&($.selected=!1),V.push(Yi(B.id,!1))}const H=[];for(const B of R)B.selected&&H.push(Yi(B.id,!1));M(V),T(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:A}=w();if(!A)return;const M=_.reduce((L,R)=>R.selected?[...L,Yi(R.id,!1)]:L,[]),T=S.reduce((L,R)=>R.selected?[...L,Yi(R.id,!1)]:L,[]);N(M),k(T)},setNodeExtent:S=>{const{nodes:_,nodeLookup:N,parentLookup:k,nodeOrigin:A,elevateNodesOnSelect:M,nodeExtent:T,zIndexMode:L}=w();S[0][0]===T[0][0]&&S[0][1]===T[0][1]&&S[1][0]===T[1][0]&&S[1][1]===T[1][1]||(rm(_,N,k,{nodeOrigin:A,nodeExtent:S,elevateNodesOnSelect:M,checkEquality:!1,zIndexMode:L}),b({nodeExtent:S}))},panBy:S=>{const{transform:_,width:N,height:k,panZoom:A,translateExtent:M}=w();return NA({delta:S,panZoom:A,transform:_,translateExtent:M,width:N,height:k})},setCenter:async(S,_,N)=>{const{width:k,height:A,maxZoom:M,panZoom:T}=w();if(!T)return Promise.resolve(!1);const L=typeof(N==null?void 0:N.zoom)<"u"?N.zoom:M;return await T.setViewport({x:k/2-S*L,y:A/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:{...w_}})},updateConnection:S=>{b({connection:S})},reset:()=>b({...yb()})}},Object.is);function GM({initialNodes:e,initialEdges:t,defaultNodes:r,defaultEdges:l,initialWidth:a,initialHeight:o,initialMinZoom:s,initialMaxZoom:c,initialFitViewOptions:h,fitView:d,nodeOrigin:m,nodeExtent:p,zIndexMode:x,children:b}){const[w]=U.useState(()=>PM({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,width:a,height:o,fitView:d,minZoom:s,maxZoom:c,fitViewOptions:h,nodeOrigin:m,nodeExtent:p,zIndexMode:x}));return y.jsx(uz,{value:w,children:y.jsx(Mz,{children:b})})}function FM({children:e,nodes:t,edges:r,defaultNodes:l,defaultEdges:a,width:o,height:s,fitView:c,fitViewOptions:h,minZoom:d,maxZoom:m,nodeOrigin:p,nodeExtent:x,zIndexMode:b}){return U.useContext(Bc)?y.jsx(y.Fragment,{children:e}):y.jsx(GM,{initialNodes:t,initialEdges:r,defaultNodes:l,defaultEdges:a,initialWidth:o,initialHeight:s,fitView:c,initialFitViewOptions:h,initialMinZoom:d,initialMaxZoom:m,nodeOrigin:p,nodeExtent:x,zIndexMode:b,children:e})}const YM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function XM({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,className:a,nodeTypes:o,edgeTypes:s,onNodeClick:c,onEdgeClick:h,onInit:d,onMove:m,onMoveStart:p,onMoveEnd:x,onConnect:b,onConnectStart:w,onConnectEnd:E,onClickConnectStart:S,onClickConnectEnd:_,onNodeMouseEnter:N,onNodeMouseMove:k,onNodeMouseLeave:A,onNodeContextMenu:M,onNodeDoubleClick:T,onNodeDragStart:L,onNodeDrag:R,onNodeDragStop:V,onNodesDelete:H,onEdgesDelete:B,onDelete:$,onSelectionChange:ee,onSelectionDragStart:I,onSelectionDrag:F,onSelectionDragStop:z,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onBeforeDelete:D,connectionMode:q,connectionLineType:Y=yi.Bezier,connectionLineStyle:C,connectionLineComponent:P,connectionLineContainerStyle:X,deleteKeyCode:J="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:re=!1,selectionMode:se=Po.Full,panActivationKeyCode:xe="Space",multiSelectionKeyCode:be=Fo()?"Meta":"Control",zoomActivationKeyCode:ye=Fo()?"Meta":"Control",snapToGrid:pe,snapGrid:Se,onlyRenderVisibleElements:De=!1,selectNodesOnDrag:je,nodesDraggable:ct,autoPanOnNodeFocus:nt,nodesConnectable:Mt,nodesFocusable:Pt,nodeOrigin:Bt=K_,edgesFocusable:kn,edgesReconnectable:Rn,elementsSelectable:Dt=!0,defaultViewport:Br=_z,minZoom:ce=.5,maxZoom:ge=2,translateExtent:Ne=Vo,preventScrolling:Be=!0,nodeExtent:Xe,defaultMarkerColor:Zt="#b1b1b7",zoomOnScroll:On=!0,zoomOnPinch:It=!0,panOnScroll:vt=!1,panOnScrollSpeed:Gt=.5,panOnScrollMode:We=Wi.Free,zoomOnDoubleClick:Qn=!0,panOnDrag:fn=!0,onPaneClick:Xc,onPaneMouseEnter:cl,onPaneMouseMove:fl,onPaneMouseLeave:dl,onPaneScroll:sr,onPaneContextMenu:hl,paneClickDistance:Si=1,nodeClickDistance:Qc=0,children:cs,onReconnect:_a,onReconnectStart:ki,onReconnectEnd:Zc,onEdgeContextMenu:fs,onEdgeDoubleClick:ds,onEdgeMouseEnter:hs,onEdgeMouseMove:Sa,onEdgeMouseLeave:ka,reconnectRadius:ps=10,onNodesChange:ms,onEdgesChange:Zn,noDragClassName:Rt="nodrag",noWheelClassName:Ft="nowheel",noPanClassName:ur="nopan",fitView:pl,fitViewOptions:gs,connectOnClick:Kc,attributionPosition:xs,proOptions:Ei,defaultEdgeOptions:Ea,elevateNodesOnSelect:Ir=!0,elevateEdgesOnSelect:qr=!1,disableKeyboardA11y:Ur=!1,autoPanOnConnect:$r,autoPanOnNodeDrag:_t,autoPanSpeed:ys,connectionRadius:vs,isValidConnection:cr,onError:Vr,style:Jc,id:Na,nodeDragThreshold:bs,connectionDragThreshold:Wc,viewport:ml,onViewportChange:gl,width:Ln,height:Wt,colorMode:ws="light",debug:ef,onScroll:Pr,ariaLabelConfig:_s,zIndexMode:Ni="basic",...tf},en){const Ci=Na||"1",Ss=Nz(ws),Ca=U.useCallback(fr=>{fr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Pr==null||Pr(fr)},[Pr]);return y.jsx("div",{"data-testid":"rf__wrapper",...tf,onScroll:Ca,style:{...Jc,...YM},ref:en,className:zt(["react-flow",a,Ss]),id:Na,role:"application",children:y.jsxs(FM,{nodes:e,edges:t,width:Ln,height:Wt,fitView:pl,fitViewOptions:gs,minZoom:ce,maxZoom:ge,nodeOrigin:Bt,nodeExtent:Xe,zIndexMode:Ni,children:[y.jsx(VM,{onInit:d,onNodeClick:c,onEdgeClick:h,onNodeMouseEnter:N,onNodeMouseMove:k,onNodeMouseLeave:A,onNodeContextMenu:M,onNodeDoubleClick:T,nodeTypes:o,edgeTypes:s,connectionLineType:Y,connectionLineStyle:C,connectionLineComponent:P,connectionLineContainerStyle:X,selectionKeyCode:ne,selectionOnDrag:re,selectionMode:se,deleteKeyCode:J,multiSelectionKeyCode:be,panActivationKeyCode:xe,zoomActivationKeyCode:ye,onlyRenderVisibleElements:De,defaultViewport:Br,translateExtent:Ne,minZoom:ce,maxZoom:ge,preventScrolling:Be,zoomOnScroll:On,zoomOnPinch:It,zoomOnDoubleClick:Qn,panOnScroll:vt,panOnScrollSpeed:Gt,panOnScrollMode:We,panOnDrag:fn,onPaneClick:Xc,onPaneMouseEnter:cl,onPaneMouseMove:fl,onPaneMouseLeave:dl,onPaneScroll:sr,onPaneContextMenu:hl,paneClickDistance:Si,nodeClickDistance:Qc,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onReconnect:_a,onReconnectStart:ki,onReconnectEnd:Zc,onEdgeContextMenu:fs,onEdgeDoubleClick:ds,onEdgeMouseEnter:hs,onEdgeMouseMove:Sa,onEdgeMouseLeave:ka,reconnectRadius:ps,defaultMarkerColor:Zt,noDragClassName:Rt,noWheelClassName:Ft,noPanClassName:ur,rfId:Ci,disableKeyboardA11y:Ur,nodeExtent:Xe,viewport:ml,onViewportChange:gl}),y.jsx(Ez,{nodes:e,edges:t,defaultNodes:r,defaultEdges:l,onConnect:b,onConnectStart:w,onConnectEnd:E,onClickConnectStart:S,onClickConnectEnd:_,nodesDraggable:ct,autoPanOnNodeFocus:nt,nodesConnectable:Mt,nodesFocusable:Pt,edgesFocusable:kn,edgesReconnectable:Rn,elementsSelectable:Dt,elevateNodesOnSelect:Ir,elevateEdgesOnSelect:qr,minZoom:ce,maxZoom:ge,nodeExtent:Xe,onNodesChange:ms,onEdgesChange:Zn,snapToGrid:pe,snapGrid:Se,connectionMode:q,translateExtent:Ne,connectOnClick:Kc,defaultEdgeOptions:Ea,fitView:pl,fitViewOptions:gs,onNodesDelete:H,onEdgesDelete:B,onDelete:$,onNodeDragStart:L,onNodeDrag:R,onNodeDragStop:V,onSelectionDrag:F,onSelectionDragStart:I,onSelectionDragStop:z,onMove:m,onMoveStart:p,onMoveEnd:x,noPanClassName:ur,nodeOrigin:Bt,rfId:Ci,autoPanOnConnect:$r,autoPanOnNodeDrag:_t,autoPanSpeed:ys,onError:Vr,connectionRadius:vs,isValidConnection:cr,selectNodesOnDrag:je,nodeDragThreshold:bs,connectionDragThreshold:Wc,onBeforeDelete:D,debug:ef,ariaLabelConfig:_s,zIndexMode:Ni}),y.jsx(wz,{onSelectionChange:ee}),cs,y.jsx(gz,{proOptions:Ei,position:xs}),y.jsx(mz,{rfId:Ci,disableKeyboardA11y:Ur})]})})}var QM=tS(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,r]=U.useState(e),l=U.useCallback(a=>r(o=>W_(a,o)),[]);return[t,r,l]}function WM(e){const[t,r]=U.useState(e),l=U.useCallback(a=>r(o=>eS(a,o)),[]);return[t,r,l]}function e5({dimensions:e,lineWidth:t,variant:r,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:zt(["react-flow__background-pattern",r,l])})}function t5({radius:e,className:t}){return y.jsx("circle",{cx:e,cy:e,r:e,className:zt(["react-flow__background-pattern","dots",t])})}var Mr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Mr||(Mr={}));const n5={[Mr.Dots]:1,[Mr.Lines]:1,[Mr.Cross]:6},r5=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function ES({id:e,variant:t=Mr.Dots,gap:r=20,size:l,lineWidth:a=1,offset:o=0,color:s,bgColor:c,style:h,className:d,patternClassName:m}){const p=U.useRef(null),{transform:x,patternId:b}=Ye(r5,pt),w=l||n5[t],E=t===Mr.Dots,S=t===Mr.Cross,_=Array.isArray(r)?r:[r,r],N=[_[0]*x[2]||1,_[1]*x[2]||1],k=w*x[2],A=Array.isArray(o)?o:[o,o],M=S?[k,k]:N,T=[A[0]*x[2]||1+M[0]/2,A[1]*x[2]||1+M[1]/2],L=`${b}${e||""}`;return y.jsxs("svg",{className:zt(["react-flow__background",d]),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:x[0]%N[0],y:x[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[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})`})]})}ES.displayName="Background";const i5=U.memo(ES);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,...r}){return y.jsx("button",{type:"button",className:zt(["react-flow__controls-button",t]),...r,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 NS({style:e,showZoom:t=!0,showFitView:r=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:o,onZoomOut:s,onFitView:c,onInteractiveChange:h,className:d,children:m,position:p="bottom-left",orientation:x="vertical","aria-label":b}){const w=mt(),{isInteractive:E,minZoomReached:S,maxZoomReached:_,ariaLabelConfig:N}=Ye(c5,pt),{zoomIn:k,zoomOut:A,fitView:M}=sl(),T=()=>{k(),o==null||o()},L=()=>{A(),s==null||s()},R=()=>{M(a),c==null||c()},V=()=>{w.setState({nodesDraggable:!E,nodesConnectable:!E,elementsSelectable:!E}),h==null||h(!E)},H=x==="horizontal"?"horizontal":"vertical";return y.jsxs(Ic,{className:zt(["react-flow__controls",H,d]),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:T,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,{})})]}),r&&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]})}NS.displayName="Controls";const f5=U.memo(NS);function d5({id:e,x:t,y:r,width:l,height:a,style:o,color:s,strokeColor:c,strokeWidth:h,className:d,borderRadius:m,shapeRendering:p,selected:x,onClick:b}){const{background:w,backgroundColor:E}=o||{},S=s||w||E;return y.jsx("rect",{className:zt(["react-flow__minimap-node",{selected:x},d]),x:t,y:r,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=U.memo(d5),p5=e=>e.nodes.map(t=>t.id),Ah=e=>e instanceof Function?e:()=>e;function m5({nodeStrokeColor:e,nodeColor:t,nodeClassName:r="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:o=h5,onClick:s}){const c=Ye(p5,pt),h=Ah(t),d=Ah(e),m=Ah(r),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return y.jsx(y.Fragment,{children:c.map(x=>y.jsx(x5,{id:x,nodeColorFunc:h,nodeStrokeColorFunc:d,nodeClassNameFunc:m,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:o,onClick:s,shapeRendering:p},x))})}function g5({id:e,nodeColorFunc:t,nodeStrokeColorFunc:r,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:o,shapeRendering:s,NodeComponent:c,onClick:h}){const{node:d,x:m,y:p,width:x,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:A}=Or(S);return{node:S,x:_,y:N,width:k,height:A}},pt);return!d||d.hidden||!j_(d)?null:y.jsx(c,{x:m,y:p,width:x,height:b,style:d.style,selected:!!d.selected,className:l(d),color:t(d),borderRadius:a,strokeColor:r(d),strokeWidth:o,shapeRendering:s,onClick:h,id:d.id})}const x5=U.memo(g5);var y5=U.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?C_(ts(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 CS({style:e,className:t,nodeStrokeColor:r,nodeColor:l,nodeClassName:a="",nodeBorderRadius:o=5,nodeStrokeWidth:s,nodeComponent:c,bgColor:h,maskColor:d,maskStrokeColor:m,maskStrokeWidth:p,position:x="bottom-right",onClick:b,onNodeClick:w,pannable:E=!1,zoomable:S=!1,ariaLabel:_,inversePan:N,zoomStep:k=1,offsetScale:A=5}){const M=mt(),T=U.useRef(null),{boundingRect:L,viewBB:R,rfId:V,panZoom:H,translateExtent:B,flowWidth:$,flowHeight:ee,ariaLabelConfig:I}=Ye(_5,pt),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,q=K*z,Y=A*K,C=L.x-(D-L.width)/2-Y,P=L.y-(q-L.height)/2-Y,X=D+Y*2,J=q+Y*2,ne=`${S5}-${V}`,re=U.useRef(0),se=U.useRef();re.current=K,U.useEffect(()=>{if(T.current&&H)return se.current=OA({domNode:T.current,panZoom:H,getTransform:()=>M.getState().transform,getViewScale:()=>re.current}),()=>{var pe;(pe=se.current)==null||pe.destroy()}},[H]),U.useEffect(()=>{var pe;(pe=se.current)==null||pe.update({translateExtent:B,width:$,height:ee,inversePan:N,pannable:E,zoomStep:k,zoomable:S})},[E,S,N,k,B,$,ee]);const xe=b?pe=>{var je;const[Se,De]=((je=se.current)==null?void 0:je.pointer(pe))||[0,0];b(pe,{x:Se,y:De})}:void 0,be=w?U.useCallback((pe,Se)=>{const De=M.getState().nodeLookup.get(Se).internals.userNode;w(pe,De)},[]):void 0,ye=_??I["minimap.ariaLabel"];return y.jsx(Ic,{position:x,style:{...e,"--xy-minimap-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d: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 r=="string"?r:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:zt(["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:T,onClick:xe,children:[ye&&y.jsx("title",{id:ne,children:ye}),y.jsx(y5,{onClick:be,nodeColor:l,nodeStrokeColor:r,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"})]})})}CS.displayName="MiniMap";const k5=U.memo(CS),E5=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,N5={[ya.Line]:"right",[ya.Handle]:"bottom-right"};function C5({nodeId:e,position:t,variant:r=ya.Handle,className:l,style:a=void 0,children:o,color:s,minWidth:c=10,minHeight:h=10,maxWidth:d=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:x,autoScale:b=!0,shouldResize:w,onResizeStart:E,onResize:S,onResizeEnd:_}){const N=lS(),k=typeof e=="string"?e:N,A=mt(),M=U.useRef(null),T=r===ya.Handle,L=Ye(U.useCallback(E5(T&&b),[T,b]),pt),R=U.useRef(null),V=t??N5[r];U.useEffect(()=>{if(!(!M.current||!k))return R.current||(R.current=QA({domNode:M.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:B,transform:$,snapGrid:ee,snapToGrid:I,nodeOrigin:F,domNode:z}=A.getState();return{nodeLookup:B,transform:$,snapGrid:ee,snapToGrid:I,nodeOrigin:F,paneDomNode:z}},onChange:(B,$)=>{const{triggerNodeChanges:ee,nodeLookup:I,parentLookup:F,nodeOrigin:z}=A.getState(),G=[],Q={x:B.x,y:B.y},K=I.get(k);if(K&&K.expandParent&&K.parentId){const D=K.origin??z,q=B.width??K.measured.width??0,Y=B.height??K.measured.height??0,C={id:K.id,parentId:K.parentId,rect:{width:q,height:Y,...T_({x:B.x??K.position.x,y:B.y??K.position.y},{width:q,height:Y},K.parentId,I,D)}},P=Im([C],I,F,z);G.push(...P),Q.x=B.x?Math.max(D[0]*q,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 q={id:k,type:"dimensions",resizing:!0,setAttributes:x?x==="horizontal"?"width":"height":!0,dimensions:{width:B.width,height:B.height}};G.push(q)}for(const D of $){const q={...D,type:"position"};G.push(q)}ee(G)},onEnd:({width:B,height:$})=>{const ee={id:k,type:"dimensions",resizing:!1,dimensions:{width:B,height:$}};A.getState().triggerNodeChanges([ee])}})),R.current.update({controlPosition:V,boundaries:{minWidth:c,minHeight:h,maxWidth:d,maxHeight:m},keepAspectRatio:p,resizeDirection:x,onResizeStart:E,onResize:S,onResizeEnd:_,shouldResize:w}),()=>{var B;(B=R.current)==null||B.destroy()}},[V,c,h,d,m,p,E,S,_,w]);const H=V.split("-");return y.jsx("div",{className:zt(["react-flow__resize-control","nodrag",...H,r,l]),ref:M,style:{...a,scale:L,...s&&{[T?"backgroundColor":"borderColor"]:s}},children:o})}U.memo(C5);function ls(e,t){if(t.length===0)return null;let r=e[t[0]];for(let l=1;ll.viewContextPath),t=ue(l=>l.nodes),r=ue(l=>l.subworkflowContexts);return U.useMemo(()=>{var l;return e.length===0?t:((l=ls(r,e))==null?void 0:l.nodes)??t},[e,t,r])}function j5(){const e=ue(l=>l.viewContextPath),t=ue(l=>l.groupProgress),r=ue(l=>l.subworkflowContexts);return U.useMemo(()=>{var l;return e.length===0?t:((l=ls(r,e))==null?void 0:l.groupProgress)??t},[e,t,r])}function T5(){const e=ue(l=>l.viewContextPath),t=ue(l=>l.highlightedEdges),r=ue(l=>l.subworkflowContexts);return U.useMemo(()=>{var l;return e.length===0?t:((l=ls(r,e))==null?void 0:l.highlightedEdges)??t},[e,t,r])}function Um(){const e=ue(r=>r.viewContextPath),t=ue(r=>r.subworkflowContexts);return U.useMemo(()=>{var r;return e.length===0?t:((r=ls(t,e))==null?void 0:r.children)??[]},[e,t])}function A5(){const e=ue(d=>d.viewContextPath),t=ue(d=>d.agents),r=ue(d=>d.routes),l=ue(d=>d.parallelGroups),a=ue(d=>d.forEachGroups),o=ue(d=>d.nodes),s=ue(d=>d.groupProgress),c=ue(d=>d.entryPoint),h=ue(d=>d.subworkflowContexts);return U.useMemo(()=>{if(e.length===0)return{agents:t,routes:r,parallelGroups:l,forEachGroups:a,nodes:o,groupProgress:s,entryPoint:c,subworkflowContexts:h,parentAgent:null};const d=ls(h,e);return d?{agents:d.agents,routes:d.routes,parallelGroups:d.parallelGroups,forEachGroups:d.forEachGroups,nodes:d.nodes,groupProgress:d.groupProgress,entryPoint:d.entryPoint,subworkflowContexts:d.children,parentAgent:d.parentAgent}:{agents:t,routes:r,parallelGroups:l,forEachGroups:a,nodes:o,groupProgress:s,entryPoint:c,subworkflowContexts:h,parentAgent:null}},[e,t,r,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 r=[];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:r,failedSegment:a};r.push(o),l=l[o].children}return{path:r,failedSegment:null}}function am(e,t,r=[]){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,r)=>{const l=t.ctx.status==="running"?1:0,a=r.ctx.status==="running"?1:0;if(l!==a)return a-l;if(t.path.length!==r.path.length)return r.path.length-t.path.length;for(let o=0;o{if(r.current||!s)return;let c=null,h=null,d=null;const m=()=>{if(r.current)return;r.current=!0,c&&clearTimeout(c),h&&clearTimeout(h),d&&d();const b=ue.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))ue.setState({viewContextPath:w,selectedNode:o});else{const S=am(b.subworkflowContexts,o);if(S.length===0){const N=a||"root workflow";ue.setState({viewContextPath:w,selectedNode:null}),t({message:`Agent "${o}" not found in ${N}.`});return}if(a){const N=S.slice(0,5).map(A=>D5(b.subworkflowContexts,A.path)).join(", "),k=S.length>5?`, and ${S.length-5} more`:"";ue.setState({viewContextPath:w,selectedNode:null}),t({message:`Agent "${o}" not found in ${a}. Found in: ${N}${k}`});return}const _=M5(S);ue.setState({viewContextPath:_.path,selectedNode:o})}setTimeout(()=>{l({nodes:[{id:o}],padding:.5,duration:400})},200)}else a&&ue.setState({viewContextPath:w,selectedNode:null})},p=()=>{const b=ue.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)},x=()=>{c&&clearTimeout(c),c=setTimeout(()=>{r.current||p()&&m()},200)};return d=ue.subscribe(x),h=setTimeout(()=>{r.current||m()},5e3),x(),()=>{c&&clearTimeout(c),h&&clearTimeout(h),d&&d()}},[s,a,o,l]),e}var zh,bb;function $m(){if(bb)return zh;bb=1;var e="\0",t="\0",r="";class l{constructor(m){Ct(this,"_isDirected",!0);Ct(this,"_isMultigraph",!1);Ct(this,"_isCompound",!1);Ct(this,"_label");Ct(this,"_defaultNodeLabelFn",()=>{});Ct(this,"_defaultEdgeLabelFn",()=>{});Ct(this,"_nodes",{});Ct(this,"_in",{});Ct(this,"_preds",{});Ct(this,"_out",{});Ct(this,"_sucs",{});Ct(this,"_edgeObjs",{});Ct(this,"_edgeLabels",{});Ct(this,"_nodeCount",0);Ct(this,"_edgeCount",0);Ct(this,"_parent");Ct(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 x=arguments,b=this;return m.forEach(function(w){x.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 x=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(x),delete this._in[m],delete this._preds[m],Object.keys(this._out[m]).forEach(x),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 x=p;x!==void 0;x=this.parent(x))if(x===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 x of this.successors(m))b.add(x);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 x=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,x.edge(E))});var b={};function w(E){var S=x.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 x=this,b=arguments;return m.reduce(function(w,E){return b.length>1?x.setEdge(w,E,p):x.setEdge(w,E),E}),this}setEdge(){var m,p,x,b,w=!1,E=arguments[0];typeof E=="object"&&E!==null&&"v"in E?(m=E.v,p=E.w,x=E.name,arguments.length===2&&(b=arguments[1],w=!0)):(m=E,p=arguments[1],x=arguments[3],arguments.length>2&&(b=arguments[2],w=!0)),m=""+m,p=""+p,x!==void 0&&(x=""+x);var S=s(this._isDirected,m,p,x);if(Object.hasOwn(this._edgeLabels,S))return w&&(this._edgeLabels[S]=b),this;if(x!==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,x);var _=c(this._isDirected,m,p,x);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,x){var b=arguments.length===1?h(this._isDirected,arguments[0]):s(this._isDirected,m,p,x);return this._edgeLabels[b]}edgeAsObj(){const m=this.edge(...arguments);return typeof m!="object"?{label:m}:m}hasEdge(m,p,x){var b=arguments.length===1?h(this._isDirected,arguments[0]):s(this._isDirected,m,p,x);return Object.hasOwn(this._edgeLabels,b)}removeEdge(m,p,x){var b=arguments.length===1?h(this._isDirected,arguments[0]):s(this._isDirected,m,p,x),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 x=this._in[m];if(x){var b=Object.values(x);return p?b.filter(w=>w.v===p):b}}outEdges(m,p){var x=this._out[m];if(x){var b=Object.values(x);return p?b.filter(w=>w.w===p):b}}nodeEdges(m,p){var x=this.inEdges(m,p);if(x)return x.concat(this.outEdges(m,p))}}function a(d,m){d[m]?d[m]++:d[m]=1}function o(d,m){--d[m]||delete d[m]}function s(d,m,p,x){var b=""+m,w=""+p;if(!d&&b>w){var E=b;b=w,w=E}return b+r+w+r+(x===void 0?e:x)}function c(d,m,p,x){var b=""+m,w=""+p;if(!d&&b>w){var E=b;b=w,w=E}var S={v:b,w};return x&&(S.name=x),S}function h(d,m){return s(d,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:$m(),version:O5()}),Dh}var Rh,Sb;function H5(){if(Sb)return Rh;Sb=1;var e=$m();Rh={write:t,read:a};function t(o){var s={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:r(o),edges:l(o)};return o.graph()!==void 0&&(s.value=structuredClone(o.graph())),s}function r(o){return o.nodes().map(function(s){var c=o.node(s),h=o.parent(s),d={v:s};return c!==void 0&&(d.value=c),h!==void 0&&(d.parent=h),d})}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 r={},l=[],a;function o(s){Object.hasOwn(r,s)||(r[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 jS(){if(Eb)return Lh;Eb=1;class e{constructor(){Ct(this,"_arr",[]);Ct(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(r){return r.key})}has(r){return Object.hasOwn(this._keyIndices,r)}priority(r){var l=this._keyIndices[r];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(r,l){var a=this._keyIndices;if(r=String(r),!Object.hasOwn(a,r)){var o=this._arr,s=o.length;return a[r]=s,o.push({key:r,priority:l}),this._decrease(s),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key}decrease(r,l){var a=this._keyIndices[r];if(l>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[a].priority+" New: "+l);this._arr[a].priority=l,this._decrease(a)}_heapify(r){var l=this._arr,a=2*r,o=a+1,s=r;a>1,!(l[o].priority1;function r(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={},d=new e,m,p,x=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=d.removeMin(),p=h[m],p.distance!==Number.POSITIVE_INFINITY);)c(m).forEach(x);return h}return Hh}var Bh,Cb;function I5(){if(Cb)return Bh;Cb=1;var e=TS();Bh=t;function t(r,l,a){return r.nodes().reduce(function(o,s){return o[s]=e(r,s,l,a),o},{})}return Bh}var Ih,jb;function AS(){if(jb)return Ih;jb=1,Ih=e;function e(t){var r=0,l=[],a={},o=[];function s(c){var h=a[c]={onStack:!0,lowlink:r,index:r++};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 d=[],m;do m=l.pop(),a[m].onStack=!1,d.push(m);while(c!==m);o.push(d)}}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=AS();qh=t;function t(r){return e(r).filter(function(l){return l.length>1||l.length===1&&r.hasEdge(l[0],l[0])})}return qh}var Uh,Ab;function U5(){if(Ab)return Uh;Ab=1,Uh=t;var e=()=>1;function t(l,a,o){return r(l,a||e,o||function(s){return l.outEdges(s)})}function r(l,a,o){var s={},c=l.nodes();return c.forEach(function(h){s[h]={},s[h][h]={distance:0},c.forEach(function(d){h!==d&&(s[h][d]={distance:Number.POSITIVE_INFINITY})}),o(h).forEach(function(d){var m=d.v===h?d.w:d.v,p=a(d);s[h][m]={distance:p,predecessor:h}})}),c.forEach(function(h){var d=s[h];c.forEach(function(m){var p=s[m];c.forEach(function(x){var b=p[h],w=d[x],E=p[x],S=b.distance+w.distance;Sa.successors(p):p=>a.neighbors(p),h=s==="post"?t:r,d=[],m={};return o.forEach(p=>{if(!a.hasNode(p))throw new Error("Graph does not have node: "+p);h(p,c,m,d)}),d}function t(a,o,s,c){for(var h=[[a,!1]];h.length>0;){var d=h.pop();d[1]?c.push(d[0]):Object.hasOwn(s,d[0])||(s[d[0]]=!0,h.push([d[0],!0]),l(o(d[0]),m=>h.push([m,!1])))}}function r(a,o,s,c){for(var h=[a];h.length>0;){var d=h.pop();Object.hasOwn(s,d)||(s[d]=!0,c.push(d),l(o(d),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=MS();Gh=t;function t(r,l){return e(r,l,"post")}return Gh}var Fh,Ob;function P5(){if(Ob)return Fh;Ob=1;var e=MS();Fh=t;function t(r,l){return e(r,l,"pre")}return Fh}var Yh,Lb;function G5(){if(Lb)return Yh;Lb=1;var e=$m(),t=jS();Yh=r;function r(l,a){var o=new e,s={},c=new t,h;function d(p){var x=p.v===h?p.w:p.v,b=c.priority(x);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(d)}return o}return Yh}var Xh,Hb;function F5(){return Hb||(Hb=1,Xh={components:B5(),dijkstra:TS(),dijkstraAll:I5(),findCycles:q5(),floydWarshall:U5(),isAcyclic:$5(),postorder:V5(),preorder:P5(),prim:G5(),tarjan:AS(),topsort:zS()}),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,r)),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 r(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 r=()=>1;function l(d,m){if(d.nodeCount()<=1)return[];let p=s(d,m||r);return a(p.graph,p.buckets,p.zeroIdx).flatMap(b=>d.outEdges(b.v,b.w))}function a(d,m,p){let x=[],b=m[m.length-1],w=m[0],E;for(;d.nodeCount();){for(;E=w.dequeue();)o(d,m,p,E);for(;E=b.dequeue();)o(d,m,p,E);if(d.nodeCount()){for(let S=m.length-2;S>0;--S)if(E=m[S].dequeue(),E){x=x.concat(o(d,m,p,E,!0));break}}}return x}function o(d,m,p,x,b){let w=b?[]:void 0;return d.inEdges(x.v).forEach(E=>{let S=d.edge(E),_=d.node(E.v);b&&w.push({v:E.v,w:E.w}),_.out-=S,c(m,p,_)}),d.outEdges(x.v).forEach(E=>{let S=d.edge(E),_=E.w,N=d.node(_);N.in-=S,c(m,p,N)}),d.removeNode(x.v),w}function s(d,m){let p=new e,x=0,b=0;d.nodes().forEach(S=>{p.setNode(S,{v:S,in:0,out:0})}),d.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),x=Math.max(x,p.node(S.w).in+=N)});let w=h(b+x+3).map(()=>new t),E=x+1;return p.nodes().forEach(S=>{c(w,E,p.node(S))}),{graph:p,buckets:w,zeroIdx:E}}function c(d,m,p){p.out?p.in?d[p.out-p.in+m].enqueue(p):d[d.length-1].enqueue(p):d[0].enqueue(p)}function h(d){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},$=R.edge(H);V.setEdge(H.v,H.w,{weight:B.weight+$.weight,minlen:Math.max(B.minlen,$.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($=>{B[$.w]=(B[$.w]||0)+R.edge($).weight}),B});return L(R.nodes(),V)}function o(R){let V=R.nodes().map(H=>{let B={};return R.inEdges(H).forEach($=>{B[$.v]=(B[$.v]||0)+R.edge($).weight}),B});return L(R.nodes(),V)}function s(R,V){let H=R.x,B=R.y,$=V.x-H,ee=V.y-B,I=R.width/2,F=R.height/2;if(!$&&!ee)throw new Error("Not possible to find intersection inside of the rectangle");let z,G;return Math.abs(ee)*I>Math.abs($)*F?(ee<0&&(F=-F),z=F*$/ee,G=F):($<0&&(I=-I),z=I,G=I*ee/$),{x:H+z,y:B+G}}function c(R){let V=A(w(R)+1).map(()=>[]);return R.nodes().forEach(H=>{let B=R.node(H),$=B.rank;$!==void 0&&(V[$][B.order]=H)}),V}function h(R){let V=R.nodes().map(B=>{let $=R.node(B).rank;return $===void 0?Number.MAX_VALUE:$}),H=b(Math.min,V);R.nodes().forEach(B=>{let $=R.node(B);Object.hasOwn($,"rank")&&($.rank-=H)})}function d(R){let V=R.nodes().map(I=>R.node(I).rank),H=b(Math.min,V),B=[];R.nodes().forEach(I=>{let F=R.node(I).rank-H;B[F]||(B[F]=[]),B[F].push(I)});let $=0,ee=R.graph().nodeRankFactor;Array.from(B).forEach((I,F)=>{I===void 0&&F%ee!==0?--$:I!==void 0&&$&&I.forEach(z=>R.node(z).rank+=$)})}function m(R,V,H,B){let $={width:0,height:0};return arguments.length>=4&&($.rank=H,$.order=B),t(R,"border",$,V)}function p(R,V=x){const H=[];for(let B=0;Bx){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 $=R.node(B).rank;return $===void 0?Number.MIN_VALUE:$});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 A(R,V,H=1){V==null&&(V=R,R=0);let B=ee=>eeVB[V]),Object.entries(R).reduce((B,[$,ee])=>(B[$]=H(ee,$),B),{})}function L(R,V){return R.reduce((H,B,$)=>(H[B]=V[$],H),{})}return Jh}var Wh,$b;function Q5(){if($b)return Wh;$b=1;let e=X5(),t=Tt().uniqueId;Wh={run:r,undo:a};function r(o){(o.graph().acyclicer==="greedy"?e(o,c(o)):l(o)).forEach(h=>{let d=o.edge(h);o.removeEdge(h),d.forwardName=h.name,d.reversed=!0,o.setEdge(h.w,h.v,d,t("rev"))});function c(h){return d=>h.edge(d).weight}}function l(o){let s=[],c={},h={};function d(m){Object.hasOwn(h,m)||(h[m]=!0,c[m]=!0,o.outEdges(m).forEach(p=>{Object.hasOwn(c,p.w)?s.push(p):d(p.w)}),delete c[m])}return o.nodes().forEach(d),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=Tt();ep={run:t,undo:l};function t(a){a.graph().dummyChains=[],a.edges().forEach(o=>r(a,o))}function r(a,o){let s=o.v,c=a.node(s).rank,h=o.w,d=a.node(h).rank,m=o.name,p=a.edge(o),x=p.labelRank;if(d===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}=Tt();tp={longestPath:t,slack:r};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 d=e(Math.min,h);return d===Number.POSITIVE_INFINITY&&(d=0),c.rank=d}l.sources().forEach(o)}function r(l,a){return l.node(a.w).rank-l.node(a.v).rank-l.edge(a).minlen}return tp}var np,Gb;function DS(){if(Gb)return np;Gb=1;var e=Yn().Graph,t=vc().slack;np=r;function r(s){var c=new e({directed:!1}),h=s.nodes()[0],d=s.nodeCount();c.setNode(h,{});for(var m,p;l(c,s){var p=m.v,x=d===p?m.w:p;!s.hasNode(x)&&!t(c,m)&&(s.setNode(x,{}),s.setEdge(d,x,{}),h(x))})}return s.nodes().forEach(h),s.nodeCount()}function a(s,c){return c.edges().reduce((d,m)=>{let p=Number.POSITIVE_INFINITY;return s.hasNode(m.v)!==s.hasNode(m.w)&&(p=t(c,m)),pc.node(d).rank+=h)}return np}var rp,Fb;function K5(){if(Fb)return rp;Fb=1;var e=DS(),t=vc().slack,r=vc().longestPath,l=Yn().alg.preorder,a=Yn().alg.postorder,o=Tt().simplify;rp=s,s.initLowLimValues=m,s.initCutValues=c,s.calcCutValue=d,s.leaveEdge=x,s.enterEdge=b,s.exchangeEdges=w;function s(N){N=o(N),r(N);var k=e(N);m(k),c(k,N);for(var A,M;A=x(k);)M=b(k,N,A),w(k,N,A,M)}function c(N,k){var A=a(N,N.nodes());A=A.slice(0,A.length-1),A.forEach(M=>h(N,k,M))}function h(N,k,A){var M=N.node(A),T=M.parent;N.edge(A,T).cutvalue=d(N,k,A)}function d(N,k,A){var M=N.node(A),T=M.parent,L=!0,R=k.edge(A,T),V=0;return R||(L=!1,R=k.edge(T,A)),V=R.weight,k.nodeEdges(A).forEach(H=>{var B=H.v===A,$=B?H.w:H.v;if($!==T){var ee=B===L,I=k.edge(H).weight;if(V+=ee?I:-I,S(N,A,$)){var F=N.edge(A,$).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,A,M,T){var L=A,R=N.node(M);return k[M]=!0,N.neighbors(M).forEach(V=>{Object.hasOwn(k,V)||(A=p(N,k,A,V,M))}),R.low=L,R.lim=A++,T?R.parent=T:delete R.parent,A}function x(N){return N.edges().find(k=>N.edge(k).cutvalue<0)}function b(N,k,A){var M=A.v,T=A.w;k.hasEdge(M,T)||(M=A.w,T=A.v);var L=N.node(M),R=N.node(T),V=L,H=!1;L.lim>R.lim&&(V=R,H=!0);var B=k.edges().filter($=>H===_(N,N.node($.v),V)&&H!==_(N,N.node($.w),V));return B.reduce(($,ee)=>t(k,ee)!k.node(T).parent),M=l(N,A);M=M.slice(1),M.forEach(T=>{var L=N.node(T).parent,R=k.edge(T,L),V=!1;R||(R=k.edge(L,T),V=!0),k.node(T).rank=k.node(L).rank+(V?R.minlen:-R.minlen)})}function S(N,k,A){return N.hasEdge(k,A)}function _(N,k,A){return A.low<=k.lim&&k.lim<=A.lim}return rp}var ip,Yb;function J5(){if(Yb)return ip;Yb=1;var e=vc(),t=e.longestPath,r=DS(),l=K5();ip=a;function a(h){var d=h.graph().ranker;if(d instanceof Function)return d(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),r(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=r(l);l.graph().dummyChains.forEach(o=>{let s=l.node(o),c=s.edgeObj,h=t(l,a,c.v,c.w),d=h.path,m=h.lca,p=0,x=d[p],b=!0;for(;o!==c.w;){if(s=l.node(o),b){for(;(x=d[p])!==m&&l.node(x).maxRankd||m>a[p].lim));for(x=p,p=s;(p=l.parent(p))!==x;)h.push(p);return{path:c.concat(h.reverse()),lca:x}}function r(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=Tt();ap={run:t,cleanup:o};function t(s){let c=e.addDummyNode(s,"root",{},"_root"),h=l(s),d=Object.values(h),m=e.applyWithChunking(Math.max,d)-1,p=2*m+1;s.graph().nestingRoot=c,s.edges().forEach(b=>s.edge(b).minlen*=p);let x=a(s)+1;s.children().forEach(b=>r(s,c,p,x,m,h,b)),s.graph().nodeRankFactor=p}function r(s,c,h,d,m,p,x){let b=s.children(x);if(!b.length){x!==c&&s.setEdge(c,x,{weight:0,minlen:h});return}let w=e.addBorderNode(s,"_bt"),E=e.addBorderNode(s,"_bb"),S=s.node(x);s.setParent(w,x),S.borderTop=w,s.setParent(E,x),S.borderBottom=E,b.forEach(_=>{r(s,c,h,d,m,p,_);let N=s.node(_),k=N.borderTop?N.borderTop:_,A=N.borderBottom?N.borderBottom:_,M=N.borderTop?d:2*d,T=k!==A?1:m-p[x]+1;s.setEdge(w,k,{weight:M,minlen:T,nestingEdge:!0}),s.setEdge(A,E,{weight:M,minlen:T,nestingEdge:!0})}),s.parent(x)||s.setEdge(c,w,{weight:0,minlen:m+p[x]})}function l(s){var c={};function h(d,m){var p=s.children(d);p&&p.length&&p.forEach(x=>h(x,m+1)),c[d]=m}return s.children().forEach(d=>h(d,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 d=s.edge(h);d.nestingEdge&&s.removeEdge(h)})}return ap}var op,Zb;function t4(){if(Zb)return op;Zb=1;let e=Tt();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,d=c.maxRank+1;hl(h.node(d))),h.edges().forEach(d=>l(h.edge(d)))}function l(h){let d=h.width;h.width=h.height,h.height=d}function a(h){h.nodes().forEach(d=>o(h.node(d))),h.edges().forEach(d=>{let m=h.edge(d);m.points.forEach(o),Object.hasOwn(m,"y")&&o(m)})}function o(h){h.y=-h.y}function s(h){h.nodes().forEach(d=>c(h.node(d))),h.edges().forEach(d=>{let m=h.edge(d);m.points.forEach(c),Object.hasOwn(m,"x")&&c(m)})}function c(h){let d=h.x;h.x=h.y,h.y=d}return sp}var up,Jb;function r4(){if(Jb)return up;Jb=1;let e=Tt();up=t;function t(r){let l={},a=r.nodes().filter(m=>!r.children(m).length),o=a.map(m=>r.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=r.node(m);c[p.rank].push(m),r.successors(m).forEach(h)}return a.sort((m,p)=>r.node(m).rank-r.node(p).rank).forEach(h),c}return up}var cp,Wb;function i4(){if(Wb)return cp;Wb=1;let e=Tt().zipObject;cp=t;function t(l,a){let o=0;for(let s=1;sb)),c=a.flatMap(x=>l.outEdges(x).map(b=>({pos:s[b.w],weight:l.edge(b).weight})).sort((b,w)=>b.pos-w.pos)),h=1;for(;h{let b=x.pos+h;m[b]+=x.weight;let w=0;for(;b>0;)b%2&&(w+=m[b+1]),b=b-1>>1,m[b]+=x.weight;p+=x.weight*w}),p}return cp}var fp,e1;function l4(){if(e1)return fp;e1=1,fp=e;function e(t,r=[]){return r.map(l=>{let a=t.inEdges(l);if(a.length){let o=a.reduce((s,c)=>{let h=t.edge(c),d=t.node(c.v);return{sum:s.sum+h.weight*d.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=Tt();dp=t;function t(a,o){let s={};a.forEach((h,d)=>{let m=s[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:d};h.barycenter!==void 0&&(m.barycenter=h.barycenter,m.weight=h.weight)}),o.edges().forEach(h=>{let d=s[h.v],m=s[h.w];d!==void 0&&m!==void 0&&(m.indegree++,d.out.push(s[h.w]))});let c=Object.values(s).filter(h=>!h.indegree);return r(c)}function r(a){let o=[];function s(h){return d=>{d.merged||(d.barycenter===void 0||h.barycenter===void 0||d.barycenter>=h.barycenter)&&l(h,d)}}function c(h){return d=>{d.in.push(h),--d.indegree===0&&a.push(d)}}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=Tt();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),d=[],m=0,p=0,x=0;c.sort(l(!!o)),x=r(d,h,x),c.forEach(w=>{x+=w.vs.length,d.push(w.vs),m+=w.barycenter*w.weight,p+=w.weight,x=r(d,h,x)});let b={vs:d.flat(!0)};return p&&(b.barycenter=m/p,b.weight=p),b}function r(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(),r=o4();pp=l;function l(s,c,h,d){let m=s.children(c),p=s.node(c),x=p?p.borderLeft:void 0,b=p?p.borderRight:void 0,w={};x&&(m=m.filter(N=>N!==x&&N!==b));let E=e(s,m);E.forEach(N=>{if(s.children(N.v).length){let k=l(s,N.v,h,d);w[N.v]=k,Object.hasOwn(k,"barycenter")&&o(N,k)}});let S=t(E,h);a(S,w);let _=r(S,d);if(x&&(_.vs=[x,_.vs,b].flat(!0),s.predecessors(x).length)){let N=s.node(s.predecessors(x)[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(d=>c[d]?c[d].vs:d)})}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=Tt();mp=r;function r(a,o,s,c){c||(c=a.nodes());let h=l(a),d=new e({compound:!0}).setGraph({root:h}).setDefaultNodeLabel(m=>a.node(m));return c.forEach(m=>{let p=a.node(m),x=a.parent(m);(p.rank===o||p.minRank<=o&&o<=p.maxRank)&&(d.setNode(m),d.setParent(m,x||h),a[s](m).forEach(b=>{let w=b.v===m?b.w:b.v,E=d.edge(w,m),S=E!==void 0?E.weight:0;d.setEdge(w,m,{weight:a.edge(b).weight+S})}),Object.hasOwn(p,"minRank")&&d.setNode(m,{borderLeft:p.borderLeft[o],borderRight:p.borderRight[o]}))}),d}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,r,l){let a={},o;l.forEach(s=>{let c=t.parent(s),h,d;for(;c;){if(h=t.parent(c),h?(d=a[h],a[h]=c):(d=o,o=c),d&&d!==c){r.setEdge(d,c);return}c=h}})}return gp}var xp,a1;function f4(){if(a1)return xp;a1=1;let e=r4(),t=i4(),r=s4(),l=u4(),a=c4(),o=Yn().Graph,s=Tt();xp=c;function c(p,x){if(x&&typeof x.customOrder=="function"){x.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),x&&x.disableOptimalOrderHeuristic)return;let _=Number.POSITIVE_INFINITY,N;for(let k=0,A=0;A<4;++k,++A){d(k%2?w:E,k%4>=2),S=s.buildLayerMatrix(p);let M=t(p,S);M<_&&(A=0,N=Object.assign({},S),_=M)}m(p,N)}function h(p,x,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 x.map(function(S){return l(p,S,b,w.get(S)||[])})}function d(p,x){let b=new o;p.forEach(function(w){let E=w.graph().root,S=r(w,E,b,x);S.vs.forEach((_,N)=>w.node(_).order=N),a(w,b,S.vs)})}function m(p,x){Object.values(x).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=Tt();yp={positionX:b,findType1Conflicts:r,findType2Conflicts:l,addConflict:o,hasConflict:s,verticalAlignment:c,horizontalCompaction:h,alignCoordinates:p,findSmallestWidthAlignment:m,balance:x};function r(S,_){let N={};function k(A,M){let T=0,L=0,R=A.length,V=M[M.length-1];return M.forEach((H,B)=>{let $=a(S,H),ee=$?S.node($).order:R;($||H===V)&&(M.slice(L,B+1).forEach(I=>{S.predecessors(I).forEach(F=>{let z=S.node(F),G=z.order;(G{H=M[B],S.node(H).dummy&&S.predecessors(H).forEach($=>{let ee=S.node($);ee.dummy&&(ee.orderV)&&o(N,$,H)})})}function A(M,T){let L=-1,R,V=0;return T.forEach((H,B)=>{if(S.node(H).dummy==="border"){let $=S.predecessors(H);$.length&&(R=S.node($[0]).order,k(T,V,B,L,R),V=B,L=R)}k(T,V,T.length,R,M.length)}),T}return _.length&&_.reduce(A),N}function a(S,_){if(S.node(_).dummy)return S.predecessors(_).find(N=>S.node(N).dummy)}function o(S,_,N){if(_>N){let A=_;_=N,N=A}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 A={},M={},T={};return _.forEach(L=>{L.forEach((R,V)=>{A[R]=R,M[R]=R,T[R]=V})}),_.forEach(L=>{let R=-1;L.forEach(V=>{let H=k(V);if(H.length){H=H.sort(($,ee)=>T[$]-T[ee]);let B=(H.length-1)/2;for(let $=Math.floor(B),ee=Math.ceil(B);$<=ee;++$){let I=H[$];M[V]===V&&RMath.max($,M[ee.v]+T.edge(ee)),0)}function H(B){let $=T.outEdges(B).reduce((I,F)=>Math.min(I,M[F.w]-T.edge(F)),Number.POSITIVE_INFINITY),ee=S.node(B);$!==Number.POSITIVE_INFINITY&&ee.borderType!==L&&(M[B]=Math.max(M[B],$))}return R(V,T.predecessors.bind(T)),R(H,T.successors.bind(T)),Object.keys(k).forEach(B=>M[B]=M[N[B]]),M}function d(S,_,N,k){let A=new e,M=S.graph(),T=w(M.nodesep,M.edgesep,k);return _.forEach(L=>{let R;L.forEach(V=>{let H=N[V];if(A.setNode(H),R){var B=N[R],$=A.edge(B,H);A.setEdge(B,H,Math.max(T(S,V,R),$||0))}R=V})}),A}function m(S,_){return Object.values(_).reduce((N,k)=>{let A=Number.NEGATIVE_INFINITY,M=Number.POSITIVE_INFINITY;Object.entries(k).forEach(([L,R])=>{let V=E(S,L)/2;A=Math.max(R+V,A),M=Math.min(R-V,M)});const T=A-M;return T{["l","r"].forEach(T=>{let L=M+T,R=S[L];if(R===_)return;let V=Object.values(R),H=k-t.applyWithChunking(Math.min,V);T!=="l"&&(H=A-t.applyWithChunking(Math.max,V)),H&&(S[L]=t.mapValues(R,B=>B+H))})})}function x(S,_){return t.mapValues(S.ul,(N,k)=>{if(_)return S[_.toLowerCase()][k];{let A=Object.values(S).map(M=>M[k]).sort((M,T)=>M-T);return(A[1]+A[2])/2}})}function b(S){let _=t.buildLayerMatrix(S),N=Object.assign(r(S,_),l(S,_)),k={},A;["u","d"].forEach(T=>{A=T==="u"?_:Object.values(_).reverse(),["l","r"].forEach(L=>{L==="r"&&(A=A.map(B=>Object.values(B).reverse()));let R=(T==="u"?S.predecessors:S.successors).bind(S),V=c(S,A,N,R),H=h(S,A,V.root,V.align,L==="r");L==="r"&&(H=t.mapValues(H,B=>-B)),k[T+L]=H})});let M=m(S,k);return p(k,M),x(k,S.graph().align)}function w(S,_,N){return(k,A,M)=>{let T=k.node(A),L=k.node(M),R=0,V;if(R+=T.width/2,Object.hasOwn(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":V=-T.width/2;break;case"r":V=T.width/2;break}if(V&&(R+=N?V:-V),V=0,R+=(T.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=Tt(),t=d4().positionX;vp=r;function r(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 d=h.reduce((m,p)=>{const x=a.node(p).height;return m>x?m:x},0);h.forEach(m=>a.node(m).y=c+d/2),c+=d+s})}return vp}var bp,u1;function p4(){if(u1)return bp;u1=1;let e=Q5(),t=Z5(),r=J5(),l=Tt().normalizeRanks,a=W5(),o=Tt().removeEmptyRanks,s=e4(),c=t4(),h=n4(),d=f4(),m=h4(),p=Tt(),x=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",()=>r(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",()=>$(C)),P(" normalize.run",()=>t.run(C)),P(" parentDummyChains",()=>a(C)),P(" addBorderSegments",()=>c(C)),P(" order",()=>d(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",()=>I(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"],A={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],T={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},L=["labelpos"];function R(C){let P=new x({multigraph:!0,compound:!0}),X=Y(C.graph());return P.setGraph(Object.assign({},_,q(X,S),p.pick(X,N))),C.nodes().forEach(J=>{let ne=Y(C.node(J));const re=q(ne,k);Object.keys(A).forEach(se=>{re[se]===void 0&&(re[se]=A[se])}),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({},T,q(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 $(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(),se=re.marginx||0,xe=re.marginy||0;function be(ye){let pe=ye.x,Se=ye.y,De=ye.width,je=ye.height;P=Math.min(P,pe-De/2),X=Math.max(X,pe+De/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-=se,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+se,re.height=ne-J+xe}function I(C){C.edges().forEach(P=>{let X=C.edge(P),J=C.node(P.v),ne=C.node(P.w),re,se;X.points?(re=X.points[0],se=X.points[X.points.length-1]):(X.points=[],re=ne,se=J),X.points.unshift(p.intersectRect(J,re)),X.points.push(p.intersectRect(ne,se))})}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]),se=C.node(X.borderRight[X.borderRight.length-1]);X.width=Math.abs(se.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 se=C.node(ne);se.order=re+J,(se.selfEdges||[]).forEach(xe=>{p.addDummyNode(C,"selfedge",{width:xe.label.width,height:xe.label.height,rank:se.rank,order:re+ ++J,e:xe.e,label:xe.label},"_se")}),delete se.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,se=X.x-ne,xe=J.height/2;C.setEdge(X.e,X.label),C.removeNode(P),X.label.points=[{x:ne+2*se/3,y:re-xe},{x:ne+5*se/6,y:re-xe},{x:ne+se,y:re},{x:ne+5*se/6,y:re+xe},{x:ne+2*se/3,y:re+xe}],X.label.x=X.x,X.label.y=X.y}})}function q(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=Tt(),t=Yn().Graph;wp={debugOrdering:r};function r(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((d,m)=>(o.setEdge(d,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:Tt().time,notime:Tt().notime},version:g4()}),Sp}var y4=x4();const h1=Zo(y4),zo=200,aa=56,p1=20,m1=40,v4=20,g1=12;function b4(e,t,r,l,a,o,s,c){const h=[],d=[],m=new Set,p=new Set,x=new Map;for(const N of r)for(const k of N.agents)p.add(k),x.set(k,N.name);for(const N of r){const k=a[N.name],A=N.agents.length,M=zo+p1*2,T=m1+A*aa+(A-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:T}});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,A=E.get(N.to)??N.to;if(!w.has(k)||!w.has(A)||k===A)continue;const M=`${k}->${A}`,T=S.get(M);if(T){T.when!==N.when&&(d[T.idx].data={when:void 0});continue}const L=d.length;S.set(M,{when:N.when,idx:L});const R=`${M}${N.when?`[${N.when}]`:""}`;d.push({id:R,source:k,target:A,type:"animatedEdge",data:{when:N.when},animated:!1})}const _=w4(h,d,"$start");return _4(h,d,_),{nodes:h,edges:d}}function w4(e,t,r){const l=new Set(e.filter(d=>!d.parentId).map(d=>d.id)),a=new Map;for(const d of t)!l.has(d.source)||!l.has(d.target)||(a.has(d.source)||a.set(d.source,[]),a.get(d.source).push({target:d.target,edgeId:d.id}));for(const d of a.values())d.sort((m,p)=>m.targetp.target?1:0);const o=new Set,s=new Set,c=new Set,h=d=>{c.add(d),s.add(d);for(const{target:m,edgeId:p}of a.get(d)??[])s.has(m)?o.add(p):c.has(m)||h(m);s.delete(d)};l.has(r)&&h(r);for(const d of[...a.keys()].sort())c.has(d)||h(d);return o}function _4(e,t,r){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 d=h.type==="groupNode",m=d&&((a=h.style)==null?void 0:a.width)||zo,p=d&&((o=h.style)==null?void 0:o.height)||aa;l.setNode(h.id,{width:m,height:p})}for(const h of t)!l.hasNode(h.source)||!l.hasNode(h.target)||(r.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 d=l.node(h.id);if(!d)continue;const m=h.type==="groupNode",p=m&&((s=h.style)==null?void 0:s.width)||zo,x=m&&((c=h.style)==null?void 0:c.height)||aa;h.position={x:d.x-p/2,y:d.y-x/2}}}const Ie={pending:"#6b7280",running:"#3b82f6",completed:"#22c55e",failed:"#ef4444",paused:"#f59e0b",idle:"#6b7280",waiting:"#a855f7"},S4=70,x1=90;function as({data:e,children:t}){const[r,l]=U.useState(!1),a=U.useRef(null),o=U.useCallback(()=>{a.current=setTimeout(()=>l(!0),200)},[]),s=U.useCallback(()=>{a.current&&clearTimeout(a.current),l(!1)},[]),c=Ie[e.status]||Ie.pending;return y.jsxs("div",{className:"relative",onMouseEnter:o,onMouseLeave:s,children:[t,r&&y.jsxs("div",{className:Me("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:Lt(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:vi(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:Me("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=U.memo(function({data:t,id:r,selected:l}){var L;const a=t,o=Lr(),c=((L=o[r])==null?void 0:L.status)||a.status||"pending",h=Ie[c]||Ie.pending,d=o[r],m=d==null?void 0:d.elapsed,p=d==null?void 0:d.model,x=d==null?void 0:d.tokens,b=d==null?void 0:d.input_tokens,w=d==null?void 0:d.output_tokens,E=d==null?void 0:d.cost_usd,S=d==null?void 0:d.iteration,_=d==null?void 0:d.error_type,N=d==null?void 0:d.error_message,k=d==null?void 0:d.context_pct,A=E4(r,c),M=N4(c),T=(()=>{if(c==="failed"&&N)return{text:N.length>40?N.slice(0,37)+"...":N,className:"text-red-400"};if(c==="running")return{text:A,className:"text-[var(--text-muted)]"};if(c==="completed"){const R=[];return m!=null&&R.push(Lt(m)),x!=null&&R.push(`${Pn(x)} tok`),E!=null&&R.push(vi(E)),{text:R.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(At,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(as,{data:{status:c,elapsed:m,model:p,tokens:x,inputTokens:b,outputTokens:w,costUsd:E,iteration:S,errorType:_,errorMessage:N},children:y.jsxs("div",{className:Me("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:Me("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(uN,{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]})]}),T.text&&y.jsx("span",{className:Me("text-[10px] truncate leading-tight",T.className),children:T.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:Me("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(At,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function E4(e,t){var h;const r=(h=Lr()[e])==null?void 0:h.startedAt,l=ue(d=>d.replayMode),a=ue(d=>d.lastEventTime),[o,s]=U.useState("0.0s"),c=U.useRef(null);return U.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=r??a??0;s(Lt((a??p)-p));return}const d=r!=null?r*1e3:Date.now(),m=()=>{const p=(Date.now()-d)/1e3;s(Lt(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,r,l,a]),o}function N4(e){const t=U.useRef(e),[r,l]=U.useState("");return U.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]),r}const C4=U.memo(function({data:t,id:r,selected:l}){var _;const a=t,o=Lr(),c=((_=o[r])==null?void 0:_.status)||a.status||"pending",h=Ie[c]||Ie.pending,d=o[r],m=d==null?void 0:d.elapsed,p=d==null?void 0:d.exit_code,x=d==null?void 0:d.error_type,b=d==null?void 0:d.error_message,w=j4(r,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(Lt(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(At,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(as,{data:{status:c,elapsed:m,exitCode:p,errorType:x,errorMessage:b},children:y.jsxs("div",{className:Me("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:Me("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:Me("text-[10px] truncate leading-tight",S.className),children:S.text})]})]})}),y.jsx(At,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function j4(e,t){var h;const r=(h=Lr()[e])==null?void 0:h.startedAt,l=ue(d=>d.replayMode),a=ue(d=>d.lastEventTime),[o,s]=U.useState("0.0s"),c=U.useRef(null);return U.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=r??a??0;s(Lt((a??p)-p));return}const d=r!=null?r*1e3:Date.now(),m=()=>{const p=(Date.now()-d)/1e3;s(Lt(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,r,l,a]),o}function T4(e){const t=U.useRef(e),[r,l]=U.useState("");return U.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]),r}const A4=U.memo(function({data:t,id:r,selected:l}){var N;const a=t,o=Lr(),c=((N=o[r])==null?void 0:N.status)||a.status||"pending",h=Ie[c]||Ie.pending,d=o[r],m=d==null?void 0:d.elapsed,p=d==null?void 0:d.set_output_keys,x=d==null?void 0:d.set_value_repr,b=d==null?void 0:d.error_type,w=d==null?void 0:d.error_message,E=z4(r,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(Lt(m)),p&&p.length>0)k.push(`${p.length} key${p.length===1?"":"s"}`);else if(x){const A=x.length>24?x.slice(0,21)+"…":x;k.push(A)}return{text:k.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(At,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(as,{data:{status:c,elapsed:m,errorType:b,errorMessage:w},children:y.jsxs("div",{className:Me("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:Me("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:Me("text-[10px] truncate leading-tight",_.className),children:_.text})]})]})}),y.jsx(At,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function z4(e,t){var h;const r=(h=Lr()[e])==null?void 0:h.startedAt,l=ue(d=>d.replayMode),a=ue(d=>d.lastEventTime),[o,s]=U.useState("0.0s"),c=U.useRef(null);return U.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=r??a??0;s(Lt((a??p)-p));return}const d=r!=null?r*1e3:Date.now(),m=()=>{const p=(Date.now()-d)/1e3;s(Lt(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,r,l,a]),o}function M4(e){const t=U.useRef(e),[r,l]=U.useState("");return U.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]),r}const D4=U.memo(function({data:t,id:r,selected:l}){var p,x;const a=t,o=Lr(),c=((p=o[r])==null?void 0:p.status)||a.status||"pending",h=Ie[c]||Ie.pending,d=(x=o[r])==null?void 0:x.selected_option,m=R4(c);return y.jsxs(y.Fragment,{children:[y.jsx(At,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(as,{data:{status:c,selectedOption:d},children:y.jsxs("div",{className:Me("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:Me("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"&&d&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] truncate leading-tight",children:d})]})]})}),y.jsx(At,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function R4(e){const t=U.useRef(e),[r,l]=U.useState("");return U.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]),r}const O4=U.memo(function({data:t,id:r,selected:l}){var S;const a=t,s=a.type==="for_each_group"?wN:yN,c=a.progress,m=((S=Lr()[r])==null?void 0:S.status)||a.status||"pending",p=Ie[m]||Ie.pending,x=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(At,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsxs("div",{className:Me("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)]",x),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(At,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function L4(e){const t=U.useRef(e),[r,l]=U.useState("");return U.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]),r}const H4=U.memo(function({data:t,id:r,selected:l}){const a=t,s=ue(S=>{var _;return(_=S.nodes[r])==null?void 0:_.status})||a.status||"pending",c=Ie[s]||Ie.pending,h=ue(S=>{var _;return(_=S.nodes[r])==null?void 0:_.elapsed}),d=ue(S=>{var _;return(_=S.nodes[r])==null?void 0:_.error_message}),m=ue(S=>S.navigateIntoSubworkflow),p=Um(),x=p.some(S=>S.parentAgent===r),b=p.find(S=>S.parentAgent===r),w=b==null?void 0:b.workflowName,E=(()=>{if(s==="failed"&&d)return{text:d.length>35?d.slice(0,32)+"...":d,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(At,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(as,{data:{status:s,elapsed:h,errorType:void 0,errorMessage:d,iteration:void 0},children:y.jsxs("div",{className:Me("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=>{x&&(S.stopPropagation(),m(r))},children:[y.jsx("div",{className:Me("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:Me("text-[10px] truncate leading-tight",E.className),children:E.text})]}),x&&y.jsx(Rr,{className:"w-3.5 h-3.5 flex-shrink-0 text-[var(--text-muted)]"})]})}),y.jsx(At,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),B4=U.memo(function({data:t,selected:r}){const a=t.status||"pending",o=a==="completed",s=a==="failed",c=!o&&!s,h=o?Ie.completed:s?Ie.failed:Ie.pending;return y.jsxs(y.Fragment,{children:[y.jsx(At,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx("div",{className:Me("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)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]"),style:{borderColor:h},children:o?y.jsx(Zi,{className:"w-5 h-5 text-white",strokeWidth:3}):s?y.jsx(_w,{className:"w-3.5 h-3.5 text-white",fill:"white"}):y.jsx(Zi,{className:"w-5 h-5",strokeWidth:2.5,style:{color:c?Ie.pending:h}})})]})}),I4=U.memo(function({data:t,selected:r}){const a=t.status||"pending",o=Ie[a]||Ie.pending,s=a==="running"||a==="completed";return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:Me("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)]",r&&"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(At,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),y1="#a78bfa",q4=U.memo(function({data:t,selected:r}){const l=t,a=l.status||"pending",o=a==="running"||a==="completed",s=o?y1:Ie[a]||y1,c=l.parentAgent,h=ue(d=>d.navigateUp);return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex flex-col items-center gap-1",children:[y.jsx("div",{className:Me("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)]",r&&"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:d=>{d.stopPropagation(),h()},children:y.jsx(oN,{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(At,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),v1="#a78bfa",U4=U.memo(function({data:t,selected:r}){const l=t,a=l.status||"pending",o=a==="completed",s=a==="failed",c=o?v1:s?Ie.failed:v1,h=l.parentAgent,d=ue(m=>m.navigateUp);return y.jsxs(y.Fragment,{children:[y.jsx(At,{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:Me("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)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]"),style:{borderColor:c},onDoubleClick:m=>{m.stopPropagation(),d()},children:y.jsx(sN,{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})]})]})]})}),$4=U.memo(function({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,source:h,target:d,data:m}){const p=T5(),x=U.useMemo(()=>p.find(V=>V.from===h&&V.to===d),[p,h,d]),[b,w,E]=Rm({sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:s,targetPosition:c}),S=m==null?void 0:m.when,_=!!S,N=(x==null?void 0:x.state)==="taken",k=(x==null?void 0:x.state)==="highlighted",A=(x==null?void 0:x.state)==="failed";let M="var(--edge-color)",T=2,L;A?(M="var(--failed)",T=3):N?(M="var(--edge-taken)",T=3):k&&(M="var(--edge-active)",T=3),_&&!N&&!k&&!A&&(L="6 3");const R=A?"failed":N?"taken":k?"active":"default";return y.jsxs(y.Fragment,{children:[y.jsx(is,{id:t,path:b,style:{stroke:M,strokeWidth:T,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:A?"var(--failed)":N?"var(--edge-taken)":"var(--surface)",color:A||N?"var(--bg)":"var(--text-muted)",border:`1px solid ${A?"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})}),A&&y.jsx("circle",{r:"3",fill:"var(--failed)",opacity:"0.8",children:y.jsx("animateMotion",{dur:"1.5s",repeatCount:"indefinite",path:b})})]})});function V4(){const e=ue(s=>s.workflowStatus),t=ue(s=>s.workflowFailure),r=ue(s=>s.workflowFailedAgent),l=ue(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:Me("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()]})]}),r&&y.jsxs("button",{onClick:()=>l(r),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 P4(){const[e,t]=U.useState(!1),r=ue(h=>h.workflowStatus),l=ue(h=>h.totalCost),a=ue(h=>h.totalTokens),o=ue(h=>h.agentsCompleted),s=ue(h=>h.agentsTotal),c=kw();return r!=="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:Me("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(fN,{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:vi(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(ol,{className:"w-3.5 h-3.5"})})]})})}const G4={agentNode:k4,scriptNode:C4,setNode:A4,gateNode:D4,groupNode:O4,workflowNode:H4,endNode:B4,startNode:I4,ingressNode:q4,egressNode:U4},F4={animatedEdge:$4},Y4={type:"animatedEdge"};function X4(){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 Q4(){const e=A5(),t=ue(z=>z.viewContextPath),r=ue(z=>z.selectNode),l=ue(z=>z.selectedNode),a=ue(z=>z.workflowStatus),o=ue(z=>z.wsStatus),s=ue(z=>z.workflowFailedAgent),c=ue(z=>z.navigateIntoSubworkflow),{agents:h,routes:d,parallelGroups:m,forEachGroups:p,nodes:x,groupProgress:b,entryPoint:w,subworkflowContexts:E,parentAgent:S}=e,[_,N,k]=JM([]),[A,M,T]=WM([]),L=U.useRef(!1),R=U.useRef(""),V=JSON.stringify(t);U.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,d,m,p,x,b,w,S);N(z),M(G)},[h,d,m,p,x,b,w,N,M,V,S]),U.useEffect(()=>{L.current&&N(z=>z.map(G=>{const Q=x[G.id];if(!Q)return G;const K=Q.status||"pending",D=G.data.status;if(K!==D){const q={...G.data,status:K};return G.data.groupName&&b[G.data.groupName]&&(q.progress=b[G.data.groupName]),{...G,data:q}}if(G.data.groupName&&b[G.data.groupName]){const q=G.data.progress,Y=b[G.data.groupName];if(Y&&(!q||q.completed!==Y.completed||q.failed!==Y.failed))return{...G,data:{...G.data,progress:Y}}}return G}))},[x,b,N]);const H=U.useCallback((z,G)=>{G.type==="groupNode"&&G.data.type!=="for_each_group"||r(G.id)},[r]),B=U.useCallback((z,G)=>{E.some(K=>K.parentAgent===G.id)&&c(G.id)},[E,c]),$=U.useCallback(()=>{r(null)},[r]),ee=U.useCallback(z=>{var Q;const G=((Q=z.data)==null?void 0:Q.status)||"pending";return Ie[G]??Ie.pending??"#6b7280"},[]);U.useEffect(()=>{N(z=>z.map(G=>({...G,selected:G.id===l})))},[l,N]),U.useEffect(()=>{a==="failed"&&s&&r(s)},[a,s,r]);const I=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(X4,{}),y.jsx(V4,{}),y.jsx(P4,{}),I&&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(fa,{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:A,onNodesChange:k,onEdgesChange:T,onNodeClick:H,onNodeDoubleClick:B,onPaneClick:$,nodeTypes:G4,edgeTypes:F4,defaultEdgeOptions:Y4,fitView:!0,fitViewOptions:{padding:.2},minZoom:.2,maxZoom:2,proOptions:{hideAttribution:!0},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,children:[y.jsx(i5,{variant:Mr.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(Z4,{})}),y.jsx(K4,{}),y.jsx(J4,{viewPathKey:V}),y.jsx(W4,{})]})]})}function Z4(){const{fitView:e}=sl(),t=U.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 K4(){const{fitView:e}=sl();return U.useEffect(()=>{const t=r=>{var a;const l=(a=r.target)==null?void 0:a.tagName;l==="INPUT"||l==="TEXTAREA"||l==="SELECT"||r.key==="f"&&!r.ctrlKey&&!r.metaKey&&!r.altKey&&e({padding:.2,duration:300})};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),null}function J4({viewPathKey:e}){const{fitView:t}=sl(),r=U.useRef(e);return U.useEffect(()=>{r.current!==e&&(r.current=e,setTimeout(()=>t({padding:.2,duration:300}),50))},[e,t]),null}function W4(){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 wi({items:e}){const t=e.filter(r=>r.value!=null&&r.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:r,value:l})=>y.jsxs("div",{className:"contents",children:[y.jsx("dt",{className:"text-[var(--text-muted)] whitespace-nowrap",children:r}),y.jsx("dd",{className:"text-[var(--text)] break-words",children:typeof l=="object"?JSON.stringify(l):String(l)})]},r))})}function RS(e){const t=[];return e.elapsed!=null&&t.push({label:"Elapsed",value:Lt(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:vi(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 bi({output:e,title:t="Output",defaultExpanded:r=!0,maxHeight:l="300px"}){const[a,o]=U.useState(r),[s,c]=U.useState(!1),h=Sw(e);if(!h)return null;const d=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(al,{className:"w-3 h-3"}):y.jsx(Rr,{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(Zi,{className:"w-3 h-3 text-[var(--completed)]"}):y.jsx(yw,{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:d?y.jsx(eD,{text:h}):h})]})}function eD({text:e}){const t=e.split(/("(?:[^"\\]|\\.)*")/g);return y.jsx(y.Fragment,{children:t.map((r,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:r},l)}const a=r.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[r,l]=U.useState(t),a=U.useRef(null);return U.useEffect(()=>{a.current&&r&&(a.current.scrollTop=a.current.scrollHeight)},[e.length,r]),e.length===0?null:y.jsxs("div",{className:"space-y-1.5",children:[y.jsxs("button",{onClick:()=>l(!r),className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold",children:[r?y.jsx(al,{className:"w-3 h-3"}):y.jsx(Rr,{className:"w-3 h-3"}),"Activity (",e.length,")"]}),r&&y.jsx("div",{ref:a,className:"max-h-[400px] overflow-y-auto space-y-0.5",children:e.map((o,s)=>y.jsx(tD,{entry:o},s))})]})}function tD({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:Me("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:Me("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,r=Ie[t]||Ie.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:`${r}20`,color:r},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(wi,{items:RS(e)}),e.prompt&&y.jsx(bi,{output:e.prompt,title:"Input / Prompt",defaultExpanded:!0}),y.jsx(Vm,{activity:e.activity,defaultExpanded:t!=="completed"}),e.output!=null&&y.jsx(bi,{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:r,status:l}){const[a,o]=U.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(al,{className:"w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0"}):y.jsx(Rr,{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}),r.elapsed!=null&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] ml-auto",children:nD(r.elapsed)})]}),a&&y.jsxs("div",{className:"px-3 py-3 space-y-3 border-t border-[var(--border)]",children:[y.jsx(wi,{items:RS(r)}),r.prompt&&y.jsx(bi,{output:r.prompt,title:"Input / Prompt",defaultExpanded:!1}),y.jsx(Vm,{activity:r.activity,defaultExpanded:t&&l!=="completed"}),r.output!=null&&y.jsx(bi,{output:r.output,title:"Output",defaultExpanded:!0}),r.error_type&&y.jsxs("div",{className:"text-xs text-red-400",children:[y.jsx("span",{className:"font-semibold",children:r.error_type}),r.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",r.error_message]})]})]})]})}function nD(e){if(e<1)return`${(e*1e3).toFixed(0)}ms`;if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),r=(e%60).toFixed(0);return`${t}m ${r}s`}function rD({node:e}){const t=e.status,r=Ie[t]||Ie.pending,l=[];e.elapsed!=null&&l.push({label:"Elapsed",value:Lt(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:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Script"})]}),y.jsx(wi,{items:l}),a&&y.jsx(bi,{output:a,title:"Output"})]})}function iD({node:e}){const t=e.status,r=Ie[t]||Ie.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:Lt(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:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Set"})]}),y.jsx(wi,{items:c}),o&&y.jsx(bi,{output:o,title:"Value preview"})]})}function lD(e,t){const r={};return(e[e.length-1]===""?[...e,""]:e).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const aD=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,oD=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,sD={};function _1(e,t){return(sD.jsx?oD:aD).test(e)}const uD=/[ \t\n\f\r]/g;function cD(e){return typeof e=="object"?e.type==="text"?S1(e.value):!1:S1(e)}function S1(e){return e.replace(uD,"")===""}class os{constructor(t,r,l){this.normal=r,this.property=t,l&&(this.space=l)}}os.prototype.normal={};os.prototype.property={};os.prototype.space=void 0;function OS(e,t){const r={},l={};for(const a of e)Object.assign(r,a.property),Object.assign(l,a.normal);return new os(r,l,t)}function om(e){return e.toLowerCase()}class cn{constructor(t,r){this.attribute=r,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 fD=0;const Oe=ul(),jt=ul(),sm=ul(),me=ul(),ut=ul(),ca=ul(),vn=ul();function ul(){return 2**++fD}const um=Object.freeze(Object.defineProperty({__proto__:null,boolean:Oe,booleanish:jt,commaOrSpaceSeparated:vn,commaSeparated:ca,number:me,overloadedBoolean:sm,spaceSeparated:ut},Symbol.toStringTag,{value:"Module"})),kp=Object.keys(um);class Pm extends cn{constructor(t,r,l,a){let o=-1;if(super(t,r),k1(this,"space",a),typeof l=="number")for(;++o4&&r.slice(0,4)==="data"&&gD.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(E1,vD);l="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!E1.test(o)){let s=o.replace(mD,yD);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}a=Pm}return new a(l,t)}function yD(e){return"-"+e.toLowerCase()}function vD(e){return e.charAt(1).toUpperCase()}const bD=OS([LS,dD,IS,qS,US],"html"),Gm=OS([LS,hD,IS,qS,US],"svg");function wD(e){return e.join(" ").trim()}var Jl={},Ep,N1;function _D(){if(N1)return Ep;N1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,r=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,s=/^[;\s]*/,c=/^\s+|\s+$/g,h=` -`,d="/",m="*",p="",x="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 A(I){var F=I.match(t);F&&(N+=F.length);var z=I.lastIndexOf(h);k=~z?I.length-z:k+I.length}function M(){var I={line:N,column:k};return function(F){return F.position=new T(I),V(),F}}function T(I){this.start=I,this.end={line:N,column:k},this.source=_.source}T.prototype.content=S;function L(I){var F=new Error(_.source+":"+N+":"+k+": "+I);if(F.reason=I,F.filename=_.source,F.line=N,F.column=k,F.source=S,!_.silent)throw F}function R(I){var F=I.exec(S);if(F){var z=F[0];return A(z),S=S.slice(z.length),F}}function V(){R(r)}function H(I){var F;for(I=I||[];F=B();)F!==!1&&I.push(F);return I}function B(){var I=M();if(!(d!=S.charAt(0)||m!=S.charAt(1))){for(var F=2;p!=S.charAt(F)&&(m!=S.charAt(F)||d!=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,A(z),S=S.slice(F),k+=2,I({type:x,comment:z})}}function $(){var I=M(),F=R(l);if(F){if(B(),!R(a))return L("property missing ':'");var z=R(o),G=I({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 I=[];H(I);for(var F;F=$();)F!==!1&&(I.push(F),H(I));return I}return V(),ee()}function E(S){return S?S.replace(c,p):p}return Ep=w,Ep}var C1;function SD(){if(C1)return Jl;C1=1;var e=Jl&&Jl.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Jl,"__esModule",{value:!0}),Jl.default=r;const t=e(_D());function r(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:d,value:m}=h;c?a(d,m,h):m&&(o=o||{},o[d]=m)}),o}return Jl}var wo={},j1;function kD(){if(j1)return wo;j1=1,Object.defineProperty(wo,"__esModule",{value:!0}),wo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,r=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(d){return!d||r.test(d)||e.test(d)},s=function(d,m){return m.toUpperCase()},c=function(d,m){return"".concat(m,"-")},h=function(d,m){return m===void 0&&(m={}),o(d)?d:(d=d.toLowerCase(),m.reactCompat?d=d.replace(a,c):d=d.replace(l,c),d.replace(t,s))};return wo.camelCase=h,wo}var _o,T1;function ED(){if(T1)return _o;T1=1;var e=_o&&_o.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(SD()),r=kD();function l(a,o){var s={};return!a||typeof a!="string"||(0,t.default)(a,function(c,h){c&&h&&(s[(0,r.camelCase)(c,o)]=h)}),s}return l.default=l,_o=l,_o}var ND=ED();const CD=Zo(ND),$S=VS("end"),Fm=VS("start");function VS(e){return t;function t(r){const l=r&&r.position&&r.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 jD(e){const t=Fm(e),r=$S(e);if(t&&r)return{start:t,end:r}}function Ro(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,r,l){super(),typeof r=="string"&&(l=r,r=void 0);let a="",o={},s=!1;if(r&&("line"in r&&"column"in r?o={place:r}:"start"in r&&"end"in r?o={place:r}:"type"in r?o={ancestors:[r],place:r.position}:o={...r}),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=Ro(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,TD=new Map,AD=/[A-Z]/g,zD=new Set(["table","tbody","thead","tfoot","tr"]),MD=new Set(["td","th"]),PS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function DD(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=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=UD(r,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=qD(r,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:r,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Gm:bD,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=GS(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function GS(e,t,r){if(t.type==="element")return RD(e,t,r);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return OD(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return HD(e,t,r);if(t.type==="mdxjsEsm")return LD(e,t);if(t.type==="root")return BD(e,t,r);if(t.type==="text")return ID(e,t)}function RD(e,t,r){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=YS(e,t.tagName,!1),s=$D(e,t);let c=Qm(e,t);return zD.has(t.tagName)&&(c=c.filter(function(h){return typeof h=="string"?!cD(h):!0})),FS(e,s,o,t),Xm(s,c),e.ancestors.pop(),e.schema=l,e.create(t,o,s,r)}function OD(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)}Xo(e,t.position)}function LD(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Xo(e,t.position)}function HD(e,t,r){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:YS(e,t.name,!0),s=VD(e,t),c=Qm(e,t);return FS(e,s,o,t),Xm(s,c),e.ancestors.pop(),e.schema=l,e.create(t,o,s,r)}function BD(e,t,r){const l={};return Xm(l,Qm(e,t)),e.create(t,e.Fragment,l,r)}function ID(e,t){return t.value}function FS(e,t,r,l){typeof r!="string"&&r!==e.Fragment&&e.passNode&&(t.node=l)}function Xm(e,t){if(t.length>0){const r=t.length>1?t:t[0];r&&(e.children=r)}}function qD(e,t,r){return l;function l(a,o,s,c){const d=Array.isArray(s.children)?r:t;return c?d(o,s,c):d(o,s)}}function UD(e,t){return r;function r(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 $D(e,t){const r={};let l,a;for(a in t.properties)if(a!=="children"&&Ym.call(t.properties,a)){const o=PD(e,a,t.properties[a]);if(o){const[s,c]=o;e.tableCellAlignToStyle&&s==="align"&&typeof c=="string"&&MD.has(t.tagName)?l=c:r[s]=c}}if(l){const o=r.style||(r.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=l}return r}function VD(e,t){const r={};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(r,e.evaluater.evaluateExpression(c.argument))}else Xo(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 Xo(e,t.position);else o=l.value===null?!0:l.value;r[a]=o}return r}function Qm(e,t){const r=[];let l=-1;const a=e.passKeys?new Map:TD;for(;++la?0:a+t:t=t>a?a:t,r=r>0?r:0,l.length<1e4)s=Array.from(l),s.unshift(t,r),e.splice(...s);else for(r&&e.splice(t,r);o0?(_n(e,e.length,0,t),e):t}const R1={}.hasOwnProperty;function QS(e){const t={};let r=-1;for(;++r13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function Fn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Jt=_i(/[A-Za-z]/),Xt=_i(/[\dA-Za-z]/),WD=_i(/[#-'*+\--9=?A-Z^-~]/);function bc(e){return e!==null&&(e<32||e===127)}const fm=_i(/\d/),eR=_i(/[\dA-Fa-f]/),tR=_i(/[!-/:-@[-`{-~]/);function Ee(e){return e!==null&&e<-2}function st(e){return e!==null&&(e<0||e===32)}function Ve(e){return e===-2||e===-1||e===32}const Uc=_i(new RegExp("\\p{P}|\\p{S}","u")),ll=_i(/\s/);function _i(e){return t;function t(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}function wa(e){const t=[];let r=-1,l=0,a=0;for(;++r55295&&o<57344){const c=e.charCodeAt(r+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,r),encodeURIComponent(s)),l=r+a+1,s=""),a&&(r+=a,a=0)}return t.join("")+e.slice(l)}function Qe(e,t,r,l){const a=l?l-1:Number.POSITIVE_INFINITY;let o=0;return s;function s(h){return Ve(h)?(e.enter(r),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),T=L;Tk;){const M=r[A];t.containerState=M[1],M[0].exit.call(t,e)}r.length=k}function N(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function aR(e,t,r){return Qe(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function va(e){if(e===null||st(e)||ll(e))return 1;if(Uc(e))return 2}function $c(e,t,r){const l=[];let a=-1;for(;++a1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;const p={...e[l][1].end},x={...e[r][1].start};L1(p,-h),L1(x,h),s={type:h>1?"strongSequence":"emphasisSequence",start:p,end:{...e[l][1].end}},c={type:h>1?"strongSequence":"emphasisSequence",start:{...e[r][1].start},end:x},o={type:h>1?"strongText":"emphasisText",start:{...e[l][1].end},end:{...e[r][1].start}},a={type:h>1?"strong":"emphasis",start:{...s.start},end:{...c.end}},e[l][1].end={...s.start},e[r][1].start={...c.end},d=[],e[l][1].end.offset-e[l][1].start.offset&&(d=Dn(d,[["enter",e[l][1],t],["exit",e[l][1],t]])),d=Dn(d,[["enter",a,t],["enter",s,t],["exit",s,t],["enter",o,t]]),d=Dn(d,$c(t.parser.constructs.insideSpan.null,e.slice(l+1,r),t)),d=Dn(d,[["exit",o,t],["enter",c,t],["exit",c,t],["exit",a,t]]),e[r][1].end.offset-e[r][1].start.offset?(m=2,d=Dn(d,[["enter",e[r][1],t],["exit",e[r][1],t]])):m=0,_n(e,l-1,r-l+3,d),r=l+d.length-m-2;break}}for(r=-1;++r0&&Ve(T)?Qe(e,N,"linePrefix",o+1)(T):N(T)}function N(T){return T===null||Ee(T)?e.check(H1,E,A)(T):(e.enter("codeFlowValue"),k(T))}function k(T){return T===null||Ee(T)?(e.exit("codeFlowValue"),N(T)):(e.consume(T),k)}function A(T){return e.exit("codeFenced"),t(T)}function M(T,L,R){let V=0;return H;function H(F){return T.enter("lineEnding"),T.consume(F),T.exit("lineEnding"),B}function B(F){return T.enter("codeFencedFence"),Ve(F)?Qe(T,$,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):$(F)}function $(F){return F===c?(T.enter("codeFencedFenceSequence"),ee(F)):R(F)}function ee(F){return F===c?(V++,T.consume(F),ee):V>=s?(T.exit("codeFencedFenceSequence"),Ve(F)?Qe(T,I,"whitespace")(F):I(F)):R(F)}function I(F){return F===null||Ee(F)?(T.exit("codeFencedFence"),L(F)):R(F)}}}function yR(e,t,r){const l=this;return a;function a(s){return s===null?r(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o)}function o(s){return l.parser.lazy[l.now().line]?r(s):t(s)}}const Cp={name:"codeIndented",tokenize:bR},vR={partial:!0,tokenize:wR};function bR(e,t,r){const l=this;return a;function a(d){return e.enter("codeIndented"),Qe(e,o,"linePrefix",5)(d)}function o(d){const m=l.events[l.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?s(d):r(d)}function s(d){return d===null?h(d):Ee(d)?e.attempt(vR,s,h)(d):(e.enter("codeFlowValue"),c(d))}function c(d){return d===null||Ee(d)?(e.exit("codeFlowValue"),s(d)):(e.consume(d),c)}function h(d){return e.exit("codeIndented"),t(d)}}function wR(e,t,r){const l=this;return a;function a(s){return l.parser.lazy[l.now().line]?r(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):r(s)}}const _R={name:"codeText",previous:kR,resolve:SR,tokenize:ER};function SR(e){let t=e.length-4,r=3,l,a;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(l=r;++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,r,l){const a=r||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return l&&So(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),So(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),So(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,r,t)(s)}}function tk(e,t,r,l,a,o,s,c,h){const d=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),x):_===null||_===32||_===41||bc(_)?r(_):(e.enter(l),e.enter(s),e.enter(c),e.enter("chunkString",{contentType:"string"}),E(_))}function x(_){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),x(_)):_===null||_===60||Ee(_)?r(_):(e.consume(_),_===92?w:b)}function w(_){return _===60||_===62||_===92?(e.consume(_),b):b(_)}function E(_){return!m&&(_===null||_===41||st(_))?(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?r(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?x:p)}function x(b){return b===91||b===92||b===93?(e.consume(b),c++,p):p(b)}}function rk(e,t,r,l,a,o){let s;return c;function c(x){return x===34||x===39||x===40?(e.enter(l),e.enter(a),e.consume(x),e.exit(a),s=x===40?41:x,h):r(x)}function h(x){return x===s?(e.enter(a),e.consume(x),e.exit(a),e.exit(l),t):(e.enter(o),d(x))}function d(x){return x===s?(e.exit(o),h(s)):x===null?r(x):Ee(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),Qe(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(x))}function m(x){return x===s||x===null||Ee(x)?(e.exit("chunkString"),d(x)):(e.consume(x),x===92?p:m)}function p(x){return x===s||x===92?(e.consume(x),m):m(x)}}function Oo(e,t){let r;return l;function l(a){return Ee(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),r=!0,l):Ve(a)?Qe(e,l,r?"linePrefix":"lineSuffix")(a):t(a)}}const DR={name:"definition",tokenize:OR},RR={partial:!0,tokenize:LR};function OR(e,t,r){const l=this;let a;return o;function o(b){return e.enter("definition"),s(b)}function s(b){return nk.call(l,e,c,r,"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):r(b)}function h(b){return st(b)?Oo(e,d)(b):d(b)}function d(b){return tk(e,m,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function m(b){return e.attempt(RR,p,p)(b)}function p(b){return Ve(b)?Qe(e,x,"whitespace")(b):x(b)}function x(b){return b===null||Ee(b)?(e.exit("definition"),l.parser.defined.push(a),t(b)):r(b)}}function LR(e,t,r){return l;function l(c){return st(c)?Oo(e,a)(c):r(c)}function a(c){return rk(e,o,r,"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):r(c)}}const HR={name:"hardBreakEscape",tokenize:BR};function BR(e,t,r){return l;function l(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return Ee(o)?(e.exit("hardBreakEscape"),t(o)):r(o)}}const IR={name:"headingAtx",resolve:qR,tokenize:UR};function qR(e,t){let r=e.length-2,l=3,a,o;return e[l][1].type==="whitespace"&&(l+=2),r-2>l&&e[r][1].type==="whitespace"&&(r-=2),e[r][1].type==="atxHeadingSequence"&&(l===r-1||r-4>l&&e[r-2][1].type==="whitespace")&&(r-=l+1===r?2:4),r>l&&(a={type:"atxHeadingText",start:e[l][1].start,end:e[r][1].end},o={type:"chunkText",start:e[l][1].start,end:e[r][1].end,contentType:"text"},_n(e,l,r-l+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function UR(e,t,r){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||st(m)?(e.exit("atxHeadingSequence"),c(m)):r(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"),d(m))}function h(m){return m===35?(e.consume(m),h):(e.exit("atxHeadingSequence"),c(m))}function d(m){return m===null||m===35||st(m)?(e.exit("atxHeadingText"),c(m)):(e.consume(m),d)}}const $R=["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"],VR={concrete:!0,name:"htmlFlow",resolveTo:FR,tokenize:YR},PR={partial:!0,tokenize:QR},GR={partial:!0,tokenize:XR};function FR(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 YR(e,t,r){const l=this;let a,o,s,c,h;return d;function d(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),x):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):r(C)}function x(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):r(C)}function b(C){return C===45?(e.consume(C),l.interrupt?t:D):r(C)}function w(C){const P="CDATA[";return C===P.charCodeAt(c++)?(e.consume(C),c===P.length?l.interrupt?t:$:w):r(C)}function E(C){return Jt(C)?(e.consume(C),s=String.fromCharCode(C),S):r(C)}function S(C){if(C===null||C===47||C===62||st(C)){const P=C===47,X=s.toLowerCase();return!P&&!o&&I1.includes(X)?(a=1,l.interrupt?t(C):$(C)):$R.includes(s.toLowerCase())?(a=6,P?(e.consume(C),_):l.interrupt?t(C):$(C)):(a=7,l.interrupt&&!l.parser.lazy[l.now().line]?r(C):o?N(C):k(C))}return C===45||Xt(C)?(e.consume(C),s+=String.fromCharCode(C),S):r(C)}function _(C){return C===62?(e.consume(C),l.interrupt?t:$):r(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),A):Ve(C)?(e.consume(C),k):H(C)}function A(C){return C===45||C===46||C===58||C===95||Xt(C)?(e.consume(C),A):M(C)}function M(C){return C===61?(e.consume(C),T):Ve(C)?(e.consume(C),M):k(C)}function T(C){return C===null||C===60||C===61||C===62||C===96?r(C):C===34||C===39?(e.consume(C),h=C,L):Ve(C)?(e.consume(C),T):R(C)}function L(C){return C===h?(e.consume(C),h=null,V):C===null||Ee(C)?r(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||st(C)?M(C):(e.consume(C),R)}function V(C){return C===47||C===62||Ve(C)?k(C):r(C)}function H(C){return C===62?(e.consume(C),B):r(C)}function B(C){return C===null||Ee(C)?$(C):Ve(C)?(e.consume(C),B):r(C)}function $(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),q):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(PR,Y,ee)(C)):C===null||Ee(C)?(e.exit("htmlFlowData"),ee(C)):(e.consume(C),$)}function ee(C){return e.check(GR,I,Y)(C)}function I(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"),$(C))}function z(C){return C===45?(e.consume(C),D):$(C)}function G(C){return C===47?(e.consume(C),s="",Q):$(C)}function Q(C){if(C===62){const P=s.toLowerCase();return I1.includes(P)?(e.consume(C),q):$(C)}return Jt(C)&&s.length<8?(e.consume(C),s+=String.fromCharCode(C),Q):$(C)}function K(C){return C===93?(e.consume(C),D):$(C)}function D(C){return C===62?(e.consume(C),q):C===45&&a===2?(e.consume(C),D):$(C)}function q(C){return C===null||Ee(C)?(e.exit("htmlFlowData"),Y(C)):(e.consume(C),q)}function Y(C){return e.exit("htmlFlow"),t(C)}}function XR(e,t,r){const l=this;return a;function a(s){return Ee(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o):r(s)}function o(s){return l.parser.lazy[l.now().line]?r(s):t(s)}}function QR(e,t,r){return l;function l(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(ss,t,r)}}const ZR={name:"htmlText",tokenize:KR};function KR(e,t,r){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),d):D===47?(e.consume(D),M):D===63?(e.consume(D),k):Jt(D)?(e.consume(D),R):r(D)}function d(D){return D===45?(e.consume(D),m):D===91?(e.consume(D),o=0,w):Jt(D)?(e.consume(D),N):r(D)}function m(D){return D===45?(e.consume(D),b):r(D)}function p(D){return D===null?r(D):D===45?(e.consume(D),x):Ee(D)?(s=p,G(D)):(e.consume(D),p)}function x(D){return D===45?(e.consume(D),b):p(D)}function b(D){return D===62?z(D):D===45?x(D):p(D)}function w(D){const q="CDATA[";return D===q.charCodeAt(o++)?(e.consume(D),o===q.length?E:w):r(D)}function E(D){return D===null?r(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?r(D):D===63?(e.consume(D),A):Ee(D)?(s=k,G(D)):(e.consume(D),k)}function A(D){return D===62?z(D):k(D)}function M(D){return Jt(D)?(e.consume(D),T):r(D)}function T(D){return D===45||Xt(D)?(e.consume(D),T):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||st(D)?V(D):r(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),$):Ee(D)?(s=B,G(D)):Ve(D)?(e.consume(D),B):V(D)}function $(D){return D===null||D===60||D===61||D===62||D===96?r(D):D===34||D===39?(e.consume(D),a=D,ee):Ee(D)?(s=$,G(D)):Ve(D)?(e.consume(D),$):(e.consume(D),I)}function ee(D){return D===a?(e.consume(D),a=void 0,F):D===null?r(D):Ee(D)?(s=ee,G(D)):(e.consume(D),ee)}function I(D){return D===null||D===34||D===39||D===60||D===61||D===96?r(D):D===47||D===62||st(D)?V(D):(e.consume(D),I)}function F(D){return D===47||D===62||st(D)?V(D):r(D)}function z(D){return D===62?(e.consume(D),e.exit("htmlTextData"),e.exit("htmlText"),t):r(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:tO,resolveTo:nO,tokenize:rO},JR={tokenize:iO},WR={tokenize:lO},eO={tokenize:aO};function tO(e){let t=-1;const r=[];for(;++t=3&&(d===null||Ee(d))?(e.exit("thematicBreak"),t(d)):r(d)}function h(d){return d===a?(e.consume(d),l++,h):(e.exit("thematicBreakSequence"),Ve(d)?Qe(e,c,"whitespace")(d):c(d))}}const sn={continuation:{tokenize:gO},exit:yO,name:"list",tokenize:mO},hO={partial:!0,tokenize:vO},pO={partial:!0,tokenize:xO};function mO(e,t,r){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,r,d)(b):d(b);if(!l.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),h(b)}return r(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"),d(b)):r(b)}function d(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),l.containerState.marker=l.containerState.marker||b,e.check(ss,l.interrupt?r:m,e.attempt(hO,x,p))}function m(b){return l.containerState.initialBlankLine=!0,o++,x(b)}function p(b){return Ve(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),x):r(b)}function x(b){return l.containerState.size=o+l.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(b)}}function gO(e,t,r){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(pO,t,s)(c))}function s(c){return l.containerState._closeFlow=!0,l.interrupt=void 0,Qe(e,e.attempt(sn,t,r),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function xO(e,t,r){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):r(o)}}function yO(e){e.exit(this.containerState.type)}function vO(e,t,r){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):r(o)}}const q1={name:"setextUnderline",resolveTo:bO,tokenize:wO};function bO(e,t){let r=e.length,l,a,o;for(;r--;)if(e[r][0]==="enter"){if(e[r][1].type==="content"){l=r;break}e[r][1].type==="paragraph"&&(a=r)}else e[r][1].type==="content"&&e.splice(r,1),!o&&e[r][1].type==="definition"&&(o=r);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 wO(e,t,r){const l=this;let a;return o;function o(d){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=d,s(d)):r(d)}function s(d){return e.enter("setextHeadingLineSequence"),c(d)}function c(d){return d===a?(e.consume(d),c):(e.exit("setextHeadingLineSequence"),Ve(d)?Qe(e,h,"lineSuffix")(d):h(d))}function h(d){return d===null||Ee(d)?(e.exit("setextHeadingLine"),t(d)):r(d)}}const _O={tokenize:SO};function SO(e){const t=this,r=e.attempt(ss,l,e.attempt(this.parser.constructs.flowInitial,a,Qe(e,e.attempt(this.parser.constructs.flow,a,e.attempt(jR,a)),"linePrefix")));return r;function l(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,r}}const kO={resolveAll:lk()},EO=ik("string"),NO=ik("text");function ik(e){return{resolveAll:lk(e==="text"?CO:void 0),tokenize:t};function t(r){const l=this,a=this.parser.constructs[e],o=r.attempt(a,s,c);return s;function s(m){return d(m)?o(m):c(m)}function c(m){if(m===null){r.consume(m);return}return r.enter("data"),r.consume(m),h}function h(m){return d(m)?(r.exit("data"),o(m)):(r.consume(m),h)}function d(m){if(m===null)return!0;const p=a[m];let x=-1;if(p)for(;++x-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 qO(e,t){let r=-1;const l=[];let a;for(;++r0){const Zt=Ne.tokenStack[Ne.tokenStack.length-1];(Zt[1]||$1).call(Ne,void 0,Zt[0])}for(ge.position={start:gi(ce.length>0?ce[0][1].start:{line:1,column:1,offset:0}),end:gi(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:r}]};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 e6(e,t){const r={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function t6(e,t){const r={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function n6(e,t){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",l=String(t.identifier).toUpperCase(),a=wa(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:"#"+r+"fn-"+a,id:r+"fnref-"+a+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(s)}]};e.patch(t,h);const d={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(t,d),e.applyData(t,d)}function r6(e,t){const r={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function i6(e,t){if(e.options.allowDangerousHtml){const r={type:"raw",value:t.value};return e.patch(t,r),e.applyData(t,r)}}function sk(e,t){const r=t.referenceType;let l="]";if(r==="collapsed"?l+="[]":r==="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 l6(e,t){const r=String(t.identifier).toUpperCase(),l=e.definitionById.get(r);if(!l)return sk(e,t);const a={src:wa(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 a6(e,t){const r={src:wa(t.url)};t.alt!==null&&t.alt!==void 0&&(r.alt=t.alt),t.title!==null&&t.title!==void 0&&(r.title=t.title);const l={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,l),e.applyData(t,l)}function o6(e,t){const r={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,r);const l={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(t,l),e.applyData(t,l)}function s6(e,t){const r=String(t.identifier).toUpperCase(),l=e.definitionById.get(r);if(!l)return sk(e,t);const a={href:wa(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 u6(e,t){const r={href:wa(t.url)};t.title!==null&&t.title!==void 0&&(r.title=t.title);const l={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function c6(e,t,r){const l=e.all(t),a=r?f6(r):uk(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 d6(e,t){const r={},l=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(r.start=t.start);++a0){const s={type:"element",tagName:"tbody",properties:{},children:e.wrap(r,!0)},c=Fm(t.children[1]),h=$S(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 x6(e,t,r){const l=r?r.children:void 0,o=(l?l.indexOf(t):1)===0?"th":"td",s=r&&r.type==="table"?r.align:void 0,c=s?s.length:t.children.length;let h=-1;const d=[];for(;++h0,!0),l[0]),a=l.index+l[0].length,l=r.exec(t);return o.push(G1(t.slice(a),a>0,!1)),o.join("")}function G1(e,t,r){let l=0,a=e.length;if(t){let o=e.codePointAt(l);for(;o===V1||o===P1;)l++,o=e.codePointAt(l)}if(r){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 b6(e,t){const r={type:"text",value:v6(String(t.value))};return e.patch(t,r),e.applyData(t,r)}function w6(e,t){const r={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,r),e.applyData(t,r)}const _6={blockquote:KO,break:JO,code:WO,delete:e6,emphasis:t6,footnoteReference:n6,heading:r6,html:i6,imageReference:l6,image:a6,inlineCode:o6,linkReference:s6,link:u6,listItem:c6,list:d6,paragraph:h6,root:p6,strong:m6,table:g6,tableCell:y6,tableRow:x6,text:b6,thematicBreak:w6,toml:Yu,yaml:Yu,definition:Yu,footnoteDefinition:Yu};function Yu(){}const ck=-1,Vc=0,Lo=1,wc=2,Wm=3,eg=4,tg=5,ng=6,fk=7,dk=8,F1=typeof self=="object"?self:globalThis,S6=(e,t)=>{const r=(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 ck:return r(s,a);case Lo:{const c=r([],a);for(const h of s)c.push(l(h));return c}case wc:{const c=r({},a);for(const[h,d]of s)c[l(h)]=l(d);return c}case Wm:return r(new Date(s),a);case eg:{const{source:c,flags:h}=s;return r(new RegExp(c,h),a)}case tg:{const c=r(new Map,a);for(const[h,d]of s)c.set(l(h),l(d));return c}case ng:{const c=r(new Set,a);for(const h of s)c.add(l(h));return c}case fk:{const{name:c,message:h}=s;return r(new F1[c](h),a)}case dk:return r(BigInt(s),a);case"BigInt":return r(Object(BigInt(s)),a);case"ArrayBuffer":return r(new Uint8Array(s).buffer,s);case"DataView":{const{buffer:c}=new Uint8Array(s);return r(new DataView(c),s)}}return r(new F1[o](s),a)};return l},Y1=e=>S6(new Map,e)(0),Wl="",{toString:k6}={},{keys:E6}=Object,ko=e=>{const t=typeof e;if(t!=="object"||!e)return[Vc,t];const r=k6.call(e).slice(8,-1);switch(r){case"Array":return[Lo,Wl];case"Object":return[wc,Wl];case"Date":return[Wm,Wl];case"RegExp":return[eg,Wl];case"Map":return[tg,Wl];case"Set":return[ng,Wl];case"DataView":return[Lo,r]}return r.includes("Array")?[Lo,r]:r.includes("Error")?[fk,r]:[wc,r]},Xu=([e,t])=>e===Vc&&(t==="function"||t==="symbol"),N6=(e,t,r,l)=>{const a=(s,c)=>{const h=l.push(s)-1;return r.set(c,h),h},o=s=>{if(r.has(s))return r.get(s);let[c,h]=ko(s);switch(c){case Vc:{let m=s;switch(h){case"bigint":c=dk,m=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+h);m=null;break;case"undefined":return a([ck],s)}return a([c,m],s)}case Lo:{if(h){let x=s;return h==="DataView"?x=new Uint8Array(s.buffer):h==="ArrayBuffer"&&(x=new Uint8Array(s)),a([h,[...x]],s)}const m=[],p=a([c,m],s);for(const x of s)m.push(o(x));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 x of E6(s))(e||!Xu(ko(s[x])))&&m.push([o(x),o(s[x])]);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[x,b]of s)(e||!(Xu(ko(x))||Xu(ko(b))))&&m.push([o(x),o(b)]);return p}case ng:{const m=[],p=a([c,m],s);for(const x of s)(e||!Xu(ko(x)))&&m.push(o(x));return p}}const{message:d}=s;return a([c,{name:h,message:d}],s)};return o},X1=(e,{json:t,lossy:r}={})=>{const l=[];return N6(!(t||r),!!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 C6(e,t){const r=[{type:"text",value:"↩"}];return t>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),r}function j6(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function T6(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=e.options.footnoteBackContent||C6,l=e.options.footnoteBackLabel||j6,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 r=="string"?r:r(h,b);typeof N=="string"&&(N={type:"text",value:N}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+x+(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-"+x},children:e.wrap(m,!0)};e.patch(d,_),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 D6;if(typeof e=="function")return Gc(e);if(typeof e=="object")return Array.isArray(e)?A6(e):z6(e);if(typeof e=="string")return M6(e);throw new Error("Expected function, string, or object as test")});function A6(e){const t=[];let r=-1;for(;++r":""))+")"})}return x;function x(){let b=hk,w,E,S;if((!t||o(h,d,m[m.length-1]||void 0))&&(b=H6(r(h,m)),b[0]===hm))return b;if("children"in h&&h.children){const _=h;if(_.children&&b[0]!==L6)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 H6(e){return Array.isArray(e)?e:typeof e=="number"?[O6,e]:e==null?hk:[e]}function rg(e,t,r,l){let a,o,s;typeof t=="function"&&typeof r!="function"?(o=void 0,s=t,a=r):(o=t,s=r,a=l),pk(e,o,c,a);function c(h,d){const m=d[d.length-1],p=m?m.children.indexOf(h):void 0;return s(h,p,m)}}const pm={}.hasOwnProperty,B6={};function I6(e,t){const r=t||B6,l=new Map,a=new Map,o=new Map,s={..._6,...r.handlers},c={all:d,applyData:U6,definitionById:l,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:s,one:h,options:r,patch:q6,wrap:V6};return rg(e,function(m){if(m.type==="definition"||m.type==="footnoteDefinition"){const p=m.type==="definition"?l:a,x=String(m.identifier).toUpperCase();p.has(x)||p.set(x,m)}}),c;function h(m,p){const x=m.type,b=c.handlers[x];if(pm.call(c.handlers,x)&&b)return b(c,m,p);if(c.options.passThrough&&c.options.passThrough.includes(x)){if("children"in m){const{children:E,...S}=m,_=_c(S);return _.children=c.all(m),_}return _c(m)}return(c.options.unknownHandler||$6)(c,m,p)}function d(m){const p=[];if("children"in m){const x=m.children;let b=-1;for(;++b0&&r.push({type:"text",value:` -`}),r}function Q1(e){let t=0,r=e.charCodeAt(t);for(;r===9||r===32;)t++,r=e.charCodeAt(t);return e.slice(t)}function Z1(e,t){const r=I6(e,t),l=r.one(e,void 0),a=T6(r),o=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return a&&o.children.push({type:"text",value:` -`},a),o}function P6(e,t){return e&&"run"in e?async function(r,l){const a=Z1(r,{file:l,...t});await e.run(a,l)}:function(r,l){return Z1(r,{file:l,...e||t})}}function K1(e){if(e)throw e}var Tp,J1;function G6(){if(J1)return Tp;J1=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=Object.defineProperty,l=Object.getOwnPropertyDescriptor,a=function(d){return typeof Array.isArray=="function"?Array.isArray(d):t.call(d)==="[object Array]"},o=function(d){if(!d||t.call(d)!=="[object Object]")return!1;var m=e.call(d,"constructor"),p=d.constructor&&d.constructor.prototype&&e.call(d.constructor.prototype,"isPrototypeOf");if(d.constructor&&!m&&!p)return!1;var x;for(x in d);return typeof x>"u"||e.call(d,x)},s=function(d,m){r&&m.name==="__proto__"?r(d,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):d[m.name]=m.newValue},c=function(d,m){if(m==="__proto__")if(e.call(d,m)){if(l)return l(d,m).value}else return;return d[m]};return Tp=function h(){var d,m,p,x,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(d=arguments[S],d!=null)for(m in d)p=c(E,m),x=c(d,m),E!==x&&(N&&x&&(o(x)||(b=a(x)))?(b?(b=!1,w=p&&a(p)?p:[]):w=p&&o(p)?p:{},s(E,{name:m,newValue:h(N,w,x)})):typeof x<"u"&&s(E,{name:m,newValue:x}));return E},Tp}var F6=G6();const Ap=Zo(F6);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 Y6(){const e=[],t={run:r,use:l};return t;function r(...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,...d){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(d){const m=d;if(c&&r)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){r||(r=!0,t(s,...c))}function o(s){a(null,s)}}const nr={basename:Q6,dirname:Z6,extname:K6,join:J6,sep:"/"};function Q6(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');us(e);let r=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){r=a+1;break}}else l<0&&(o=!0,l=a+1);return l<0?"":e.slice(r,l)}if(t===e)return"";let s=-1,c=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){r=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 r===l?l=s:l<0&&(l=e.length),e.slice(r,l)}function Z6(e){if(us(e),e.length===0)return".";let t=-1,r=e.length,l;for(;--r;)if(e.codePointAt(r)===47){if(l){t=r;break}}else l||(l=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function K6(e){us(e);let t=e.length,r=-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}r<0&&(s=!0,r=t+1),c===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||r<0||o===0||o===1&&a===r-1&&a===l+1?"":e.slice(a,r)}function J6(...e){let t=-1,r;for(;++t0&&e.codePointAt(e.length-1)===47&&(r+="/"),t?"/"+r:r}function eL(e,t){let r="",l=0,a=-1,o=0,s=-1,c,h;for(;++s<=e.length;){if(s2){if(h=r.lastIndexOf("/"),h!==r.length-1){h<0?(r="",l=0):(r=r.slice(0,h),l=r.length-1-r.lastIndexOf("/")),a=s,o=0;continue}}else if(r.length>0){r="",l=0,a=s,o=0;continue}}t&&(r=r.length>0?r+"/..":"..",l=2)}else r.length>0?r+="/"+e.slice(a+1,s):r=e.slice(a+1,s),l=s-a-1;a=s,o=0}else c===46&&o>-1?o++:o=-1}return r}function us(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const tL={cwd:nL};function nL(){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 rL(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 iL(e)}function iL(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 r=-1;for(;++r0){let[b,...w]=m;const E=l[x][1];mm(E)&&mm(b)&&(b=Ap(!0,E,b)),l[x]=[d,b,...w]}}}}const sL=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,r){if(!r)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Qu(e){return uL(e)?e:new mk(e)}function uL(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function cL(e){return typeof e=="string"||fL(e)}function fL(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const dL="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",nw=[],rw={allowDangerousHtml:!0},hL=/^(https?|ircs?|mailto|xmpp)$/i,pL=[{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=mL(e),r=gL(e);return xL(t.runSync(t.parse(r),r),e)}function mL(e){const t=e.rehypePlugins||nw,r=e.remarkPlugins||nw,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...rw}:rw;return sL().use(ZO).use(r).use(P6,l).use(t)}function gL(e){const t=e.children||"",r=new mk;return typeof t=="string"&&(r.value=t),r}function xL(e,t){const r=t.allowedElements,l=t.allowElement,a=t.components,o=t.disallowedElements,s=t.skipHtml,c=t.unwrapDisallowed,h=t.urlTransform||yL;for(const m of pL)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+dL+m.id,void 0);return rg(e,d),DD(e,{Fragment:y.Fragment,components:a,ignoreInvalidStyle:!0,jsx:y.jsx,jsxs:y.jsxs,passKeys:!0,passNode:!0});function d(m,p,x){if(m.type==="raw"&&x&&typeof p=="number")return s?x.children.splice(p,1):x.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=r?!r.includes(m.tagName):o?o.includes(m.tagName):!1;if(!b&&l&&typeof p=="number"&&(b=!l(m,p,x)),b&&x&&typeof p=="number")return c&&m.children?x.children.splice(p,1,...m.children):x.children.splice(p,1),p}}}function yL(e){const t=e.indexOf(":"),r=e.indexOf("?"),l=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||r!==-1&&t>r||l!==-1&&t>l||hL.test(e.slice(0,t))?e:""}function iw(e,t){const r=String(e);if(typeof t!="string")throw new TypeError("Expected character");let l=0,a=r.indexOf(t);for(;a!==-1;)l++,a=r.indexOf(t,a+t.length);return l}function vL(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function bL(e,t,r){const a=Pc((r||{}).ignore||[]),o=wL(t);let s=-1;for(;++s0?{type:"text",value:T}:void 0),T===!1?x.lastIndex=A+1:(w!==A&&N.push({type:"text",value:d.value.slice(w,A)}),Array.isArray(T)?N.push(...T):T&&N.push(T),w=A+k[0].length,_=!0),!x.global)break;k=x.exec(d.value)}return _?(w?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let r=t[0],l=r.indexOf(")");const a=iw(e,"(");let o=iw(e,")");for(;l!==-1&&a>o;)e+=r.slice(0,l+1),r=r.slice(l+1),l=r.indexOf(")"),o++;return[e,r]}function gk(e,t){const r=e.input.charCodeAt(e.index-1);return(e.index===0||ll(r)||Uc(r))&&(!t||r!==47)}xk.peek=PL;function LL(){this.buffer()}function HL(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function BL(){this.buffer()}function IL(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function qL(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Fn(this.sliceSerialize(e)).toLowerCase(),r.label=t}function UL(e){this.exit(e)}function $L(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Fn(this.sliceSerialize(e)).toLowerCase(),r.label=t}function VL(e){this.exit(e)}function PL(){return"["}function xk(e,t,r,l){const a=r.createTracker(l);let o=a.move("[^");const s=r.enter("footnoteReference"),c=r.enter("reference");return o+=a.move(r.safe(r.associationId(e),{after:"]",before:o})),c(),s(),o+=a.move("]"),o}function GL(){return{enter:{gfmFootnoteCallString:LL,gfmFootnoteCall:HL,gfmFootnoteDefinitionLabelString:BL,gfmFootnoteDefinition:IL},exit:{gfmFootnoteCallString:qL,gfmFootnoteCall:UL,gfmFootnoteDefinitionLabelString:$L,gfmFootnoteDefinition:VL}}}function FL(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:r,footnoteReference:xk},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function r(l,a,o,s){const c=o.createTracker(s);let h=c.move("[^");const d=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?yk:YL))),d(),h}}function YL(e,t,r){return t===0?e:yk(e,t,r)}function yk(e,t,r){return(r?"":" ")+e}const XL=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];vk.peek=WL;function QL(){return{canContainEols:["delete"],enter:{strikethrough:KL},exit:{strikethrough:JL}}}function ZL(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:XL}],handlers:{delete:vk}}}function KL(e){this.enter({type:"delete",children:[]},e)}function JL(e){this.exit(e)}function vk(e,t,r,l){const a=r.createTracker(l),o=r.enter("strikethrough");let s=a.move("~~");return s+=r.containerPhrasing(e,{...a.current(),before:s,after:"~"}),s+=a.move("~~"),o(),s}function WL(){return"~"}function e8(e){return e.length}function t8(e,t){const r=t||{},l=(r.align||[]).concat(),a=r.stringLength||e8,o=[],s=[],c=[],h=[];let d=0,m=-1;for(;++md&&(d=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),x[p]=k}s.splice(1,0,x),c.splice(1,0,b),m=-1;const w=[];for(;++m "),o.shift(2);const s=r.indentLines(r.containerFlow(e,o.current()),i8);return a(),s}function i8(e,t,r){return">"+(r?"":" ")+e}function l8(e,t){return aw(e,t.inConstruct,!0)&&!aw(e,t.notInConstruct,!1)}function aw(e,t,r){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return r;let l=-1;for(;++ls&&(s=o):o=1,a=l+t.length,l=r.indexOf(t,a);return s}function o8(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 s8(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 u8(e,t,r,l){const a=s8(r),o=e.value||"",s=a==="`"?"GraveAccent":"Tilde";if(o8(e,r)){const p=r.enter("codeIndented"),x=r.indentLines(o,c8);return p(),x}const c=r.createTracker(l),h=a.repeat(Math.max(a8(o,a)+1,3)),d=r.enter("codeFenced");let m=c.move(h);if(e.lang){const p=r.enter(`codeFencedLang${s}`);m+=c.move(r.safe(e.lang,{before:m,after:" ",encode:["`"],...c.current()})),p()}if(e.lang&&e.meta){const p=r.enter(`codeFencedMeta${s}`);m+=c.move(" "),m+=c.move(r.safe(e.meta,{before:m,after:` -`,encode:["`"],...c.current()})),p()}return m+=c.move(` -`),o&&(m+=c.move(o+` -`)),m+=c.move(h),d(),m}function c8(e,t,r){return(r?"":" ")+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 f8(e,t,r,l){const a=lg(r),o=a==='"'?"Quote":"Apostrophe",s=r.enter("definition");let c=r.enter("label");const h=r.createTracker(l);let d=h.move("[");return d+=h.move(r.safe(r.associationId(e),{before:d,after:"]",...h.current()})),d+=h.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=r.enter("destinationLiteral"),d+=h.move("<"),d+=h.move(r.safe(e.url,{before:d,after:">",...h.current()})),d+=h.move(">")):(c=r.enter("destinationRaw"),d+=h.move(r.safe(e.url,{before:d,after:e.title?" ":` -`,...h.current()}))),c(),e.title&&(c=r.enter(`title${o}`),d+=h.move(" "+a),d+=h.move(r.safe(e.title,{before:d,after:a,...h.current()})),d+=h.move(a),c()),s(),d}function d8(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 Qo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Sc(e,t,r){const l=va(e),a=va(t);return l===void 0?a===void 0?r==="_"?{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}}bk.peek=h8;function bk(e,t,r,l){const a=d8(r),o=r.enter("emphasis"),s=r.createTracker(l),c=s.move(a);let h=s.move(r.containerPhrasing(e,{after:a,before:c,...s.current()}));const d=h.charCodeAt(0),m=Sc(l.before.charCodeAt(l.before.length-1),d,a);m.inside&&(h=Qo(d)+h.slice(1));const p=h.charCodeAt(h.length-1),x=Sc(l.after.charCodeAt(0),p,a);x.inside&&(h=h.slice(0,-1)+Qo(p));const b=s.move(a);return o(),r.attentionEncodeSurroundingInfo={after:x.outside,before:m.outside},c+h+b}function h8(e,t,r){return r.options.emphasis||"*"}function p8(e,t){let r=!1;return rg(e,function(l){if("value"in l&&/\r?\n|\r/.test(l.value)||l.type==="break")return r=!0,hm}),!!((!e.depth||e.depth<3)&&Zm(e)&&(t.options.setext||r))}function m8(e,t,r,l){const a=Math.max(Math.min(6,e.depth||1),1),o=r.createTracker(l);if(p8(e,r)){const m=r.enter("headingSetext"),p=r.enter("phrasing"),x=r.containerPhrasing(e,{...o.current(),before:` -`,after:` -`});return p(),m(),x+` -`+(a===1?"=":"-").repeat(x.length-(Math.max(x.lastIndexOf("\r"),x.lastIndexOf(` -`))+1))}const s="#".repeat(a),c=r.enter("headingAtx"),h=r.enter("phrasing");o.move(s+" ");let d=r.containerPhrasing(e,{before:"# ",after:` -`,...o.current()});return/^[\t ]/.test(d)&&(d=Qo(d.charCodeAt(0))+d.slice(1)),d=d?s+" "+d:s,r.options.closeAtx&&(d+=" "+s),h(),c(),d}wk.peek=g8;function wk(e){return e.value||""}function g8(){return"<"}_k.peek=x8;function _k(e,t,r,l){const a=lg(r),o=a==='"'?"Quote":"Apostrophe",s=r.enter("image");let c=r.enter("label");const h=r.createTracker(l);let d=h.move("![");return d+=h.move(r.safe(e.alt,{before:d,after:"]",...h.current()})),d+=h.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=r.enter("destinationLiteral"),d+=h.move("<"),d+=h.move(r.safe(e.url,{before:d,after:">",...h.current()})),d+=h.move(">")):(c=r.enter("destinationRaw"),d+=h.move(r.safe(e.url,{before:d,after:e.title?" ":")",...h.current()}))),c(),e.title&&(c=r.enter(`title${o}`),d+=h.move(" "+a),d+=h.move(r.safe(e.title,{before:d,after:a,...h.current()})),d+=h.move(a),c()),d+=h.move(")"),s(),d}function x8(){return"!"}Sk.peek=y8;function Sk(e,t,r,l){const a=e.referenceType,o=r.enter("imageReference");let s=r.enter("label");const c=r.createTracker(l);let h=c.move("![");const d=r.safe(e.alt,{before:h,after:"]",...c.current()});h+=c.move(d+"]["),s();const m=r.stack;r.stack=[],s=r.enter("reference");const p=r.safe(r.associationId(e),{before:h,after:"]",...c.current()});return s(),r.stack=m,o(),a==="full"||!d||d!==p?h+=c.move(p+"]"):a==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function y8(){return"!"}kk.peek=v8;function kk(e,t,r){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))}Nk.peek=b8;function Nk(e,t,r,l){const a=lg(r),o=a==='"'?"Quote":"Apostrophe",s=r.createTracker(l);let c,h;if(Ek(e,r)){const m=r.stack;r.stack=[],c=r.enter("autolink");let p=s.move("<");return p+=s.move(r.containerPhrasing(e,{before:p,after:">",...s.current()})),p+=s.move(">"),c(),r.stack=m,p}c=r.enter("link"),h=r.enter("label");let d=s.move("[");return d+=s.move(r.containerPhrasing(e,{before:d,after:"](",...s.current()})),d+=s.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=r.enter("destinationLiteral"),d+=s.move("<"),d+=s.move(r.safe(e.url,{before:d,after:">",...s.current()})),d+=s.move(">")):(h=r.enter("destinationRaw"),d+=s.move(r.safe(e.url,{before:d,after:e.title?" ":")",...s.current()}))),h(),e.title&&(h=r.enter(`title${o}`),d+=s.move(" "+a),d+=s.move(r.safe(e.title,{before:d,after:a,...s.current()})),d+=s.move(a),h()),d+=s.move(")"),c(),d}function b8(e,t,r){return Ek(e,r)?"<":"["}Ck.peek=w8;function Ck(e,t,r,l){const a=e.referenceType,o=r.enter("linkReference");let s=r.enter("label");const c=r.createTracker(l);let h=c.move("[");const d=r.containerPhrasing(e,{before:h,after:"]",...c.current()});h+=c.move(d+"]["),s();const m=r.stack;r.stack=[],s=r.enter("reference");const p=r.safe(r.associationId(e),{before:h,after:"]",...c.current()});return s(),r.stack=m,o(),a==="full"||!d||d!==p?h+=c.move(p+"]"):a==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function w8(){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 _8(e){const t=ag(e),r=e.options.bulletOther;if(!r)return t==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+r+"`) to be different");return r}function S8(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 jk(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 k8(e,t,r,l){const a=r.enter("list"),o=r.bulletCurrent;let s=e.ordered?S8(r):ag(r);const c=e.ordered?s==="."?")":".":_8(r);let h=t&&r.bulletLastUsed?s===r.bulletLastUsed:!1;if(!e.ordered){const m=e.children?e.children[0]:void 0;if((s==="*"||s==="-")&&m&&(!m.children||!m.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0&&(h=!0),jk(r)===s&&m){let p=-1;for(;++p-1?t.start:1)+(r.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=r.createTracker(l);c.move(o+" ".repeat(s-o.length)),c.shift(s);const h=r.enter("listItem"),d=r.indentLines(r.containerFlow(e,c.current()),m);return h(),d;function m(p,x,b){return x?(b?"":" ".repeat(s))+p:(b?o:o+" ".repeat(s-o.length))+p}}function C8(e,t,r,l){const a=r.enter("paragraph"),o=r.enter("phrasing"),s=r.containerPhrasing(e,l);return o(),a(),s}const j8=Pc(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function T8(e,t,r,l){return(e.children.some(function(s){return j8(s)})?r.containerPhrasing:r.containerFlow).call(r,e,l)}function A8(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Tk.peek=z8;function Tk(e,t,r,l){const a=A8(r),o=r.enter("strong"),s=r.createTracker(l),c=s.move(a+a);let h=s.move(r.containerPhrasing(e,{after:a,before:c,...s.current()}));const d=h.charCodeAt(0),m=Sc(l.before.charCodeAt(l.before.length-1),d,a);m.inside&&(h=Qo(d)+h.slice(1));const p=h.charCodeAt(h.length-1),x=Sc(l.after.charCodeAt(0),p,a);x.inside&&(h=h.slice(0,-1)+Qo(p));const b=s.move(a+a);return o(),r.attentionEncodeSurroundingInfo={after:x.outside,before:m.outside},c+h+b}function z8(e,t,r){return r.options.strong||"*"}function M8(e,t,r,l){return r.safe(e.value,l)}function D8(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 R8(e,t,r){const l=(jk(r)+(r.options.ruleSpaces?" ":"")).repeat(D8(r));return r.options.ruleSpaces?l.slice(0,-1):l}const Ak={blockquote:r8,break:ow,code:u8,definition:f8,emphasis:bk,hardBreak:ow,heading:m8,html:wk,image:_k,imageReference:Sk,inlineCode:kk,link:Nk,linkReference:Ck,list:k8,listItem:N8,paragraph:C8,root:T8,strong:Tk,text:M8,thematicBreak:R8};function O8(){return{enter:{table:L8,tableData:sw,tableHeader:sw,tableRow:B8},exit:{codeText:I8,table:H8,tableData:qp,tableHeader:qp,tableRow:qp}}}function L8(e){const t=e._align;this.enter({type:"table",align:t.map(function(r){return r==="none"?null:r}),children:[]},e),this.data.inTable=!0}function H8(e){this.exit(e),this.data.inTable=void 0}function B8(e){this.enter({type:"tableRow",children:[]},e)}function qp(e){this.exit(e)}function sw(e){this.enter({type:"tableCell",children:[]},e)}function I8(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,q8));const r=this.stack[this.stack.length-1];r.type,r.value=t,this.exit(e)}function q8(e,t){return t==="|"?t:e}function U8(e){const t=e||{},r=t.tableCellPadding,l=t.tablePipeAlign,a=t.stringLength,o=r?" ":"|";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:x,table:s,tableCell:h,tableRow:c}};function s(b,w,E,S){return d(m(b,E,S),b.align)}function c(b,w,E,S){const _=p(b,E,S),N=d([_]);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 d(b,w){return t8(b,{align:w,alignDelimiters:l,padding:r,stringLength:a})}function m(b,w,E){const S=b.children;let _=-1;const N=[],k=w.enter("table");for(;++_0&&!r&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const l9={tokenize:h9,partial:!0};function a9(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:c9,continuation:{tokenize:f9},exit:d9}},text:{91:{name:"gfmFootnoteCall",tokenize:u9},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:o9,resolveTo:s9}}}}function o9(e,t,r){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 r(h);const d=Fn(l.sliceSerialize({start:s.end,end:l.now()}));return d.codePointAt(0)!==94||!o.includes(d.slice(1))?r(h):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),t(h))}}function s9(e,t){let r=e.length;for(;r--;)if(e[r][1].type==="labelImage"&&e[r][0]==="enter"){e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+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[r+1],e[r+2],["enter",l,t],e[r+3],e[r+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(r,e.length-r+1,...c),e}function u9(e,t,r){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?r(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(p){if(o>999||p===93&&!s||p===null||p===91||st(p))return r(p);if(p===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return a.includes(Fn(l.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):r(p)}return st(p)||(s=!0),o++,e.consume(p),p===92?m:d}function m(p){return p===91||p===92||p===93?(e.consume(p),o++,d):d(p)}}function c9(e,t,r){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"),d}function d(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",m):r(w)}function m(w){if(s>999||w===93&&!c||w===null||w===91||st(w))return r(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"),x}return st(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 x(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(o)||a.push(o),Qe(e,b,"gfmFootnoteDefinitionWhitespace")):r(w)}function b(w){return t(w)}}function f9(e,t,r){return e.check(ss,t,e.attempt(l9,t,r))}function d9(e){e.exit("gfmFootnoteDefinition")}function h9(e,t,r){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):r(o)}}function p9(e){let r=(e||{}).singleTilde;const l={name:"strikethrough",tokenize:o,resolveAll:a};return r==null&&(r=!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&&!r)return h(w);const S=s.exit("strikethroughSequenceTemporary"),_=va(w);return S._open=!_||_===2&&!!E,S._close=!E||E===2&&!!_,c(w)}}}class m9{constructor(){this.map=[]}add(t,r,l){g9(this,t,r,l)}consume(t){if(this.map.sort(function(o,s){return o[0]-s[0]}),this.map.length===0)return;let r=this.map.length;const l=[];for(;r>0;)r-=1,l.push(t.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),t.length=this.map[r][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 g9(e,t,r,l){let a=0;if(!(r===0&&l.length===0)){for(;a-1;){const I=l.events[B][1].type;if(I==="lineEnding"||I==="linePrefix")B--;else break}const $=B>-1?l.events[B][1].type:null,ee=$==="tableHead"||$==="tableRow"?T:h;return ee===T&&l.parser.lazy[l.now().line]?r(H):ee(H)}function h(H){return e.enter("tableHead"),e.enter("tableRow"),d(H)}function d(H){return H===124||(s=!0,o+=1),m(H)}function m(H){return H===null?r(H):Ee(H)?o>1?(o=0,l.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(H),e.exit("lineEnding"),b):r(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||st(H)?(e.exit("data"),m(H)):(e.consume(H),H===92?x:p)}function x(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]?r(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)?A(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,A,"whitespace")(H):A(H)}function A(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 r(H)}function T(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||st(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 b9(e,t){let r=-1,l=!0,a=0,o=[0,0,0,0],s=[0,0,0,0],c=!1,h=0,d,m,p;const x=new m9;for(;++rr[2]+1){const w=r[2]+1,E=r[3]-r[2]-1;e.add(w,E,[])}}e.add(r[3]+1,0,[["exit",p,t]])}return a!==void 0&&(o.end=Object.assign({},ta(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function cw(e,t,r,l,a){const o=[],s=ta(t.events,r);a&&(a.end=Object.assign({},s),o.push(["exit",a,t])),l.end=Object.assign({},s),o.push(["exit",l,t]),e.add(r+1,0,o)}function ta(e,t){const r=e[t],l=r[0]==="enter"?"start":"end";return r[1][l]}const w9={name:"tasklistCheck",tokenize:S9};function _9(){return{text:{91:w9}}}function S9(e,t,r){const l=this;return a;function a(h){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?r(h):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),o)}function o(h){return st(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):r(h)}function s(h){return h===93?(e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):r(h)}function c(h){return Ee(h)?t(h):Ve(h)?e.check({tokenize:k9},t,r)(h):r(h)}}function k9(e,t,r){return Qe(e,l,"whitespace");function l(a){return a===null?r(a):t(a)}}function E9(e){return QS([Z8(),a9(),p9(e),y9(),_9()])}const N9={};function Yc(e){const t=this,r=e||N9,l=t.data(),a=l.micromarkExtensions||(l.micromarkExtensions=[]),o=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),s=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);a.push(E9(r)),o.push(F8()),s.push(Y8(r))}const C9=new Set([".md",".markdown",".mdx"]);function j9({filePath:e,onClose:t}){const[r,l]=U.useState(null),[a,o]=U.useState(null),[s,c]=U.useState(!0),h=U.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 x=await p.json();l(x)}catch(m){o(m instanceof Error?m.message:"Failed to load file")}finally{c(!1)}},[e]);U.useEffect(()=>{h()},[h]),U.useEffect(()=>{const m=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const d=r?C9.has(r.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(vw,{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}),r&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] flex-shrink-0 tabular-nums",children:A9(r.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(ol,{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(fa,{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})]}),r&&!a&&(d?y.jsx("div",{className:"file-viewer-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx(T9,{content:r.content})}):y.jsx("pre",{className:"font-mono text-[11px] leading-[1.6] text-[var(--text)] whitespace-pre-wrap break-words",children:r.content}))]})]})})}function T9({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:r})=>(r==null?void 0:r.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:r})=>y.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:r}),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 A9(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function z9({node:e}){const t=ue(M=>M.sendGateResponse),r=ue(M=>M.wsStatus),[l,a]=U.useState(null),[o,s]=U.useState(""),[c,h]=U.useState(null),[d,m]=U.useState(!1),[p,x]=U.useState(null),b=e.status==="waiting",w=e.status==="completed";U.useEffect(()=>{b&&(a(null),s(""),h(null),m(!1))},[b]);const E=b&&r==="connected"&&l===null,S=(M,T)=>{if(E){if(T){a(M),h(T);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),A=(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(Up,{text:e.prompt,muted:!1,onFileClick:x})}),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 T=l===M.value,L=l!==null&&!T;return y.jsx("button",{disabled:!E&&!T,onClick:()=>S(M.value,M.prompt_for),className:`w-full text-left px-3 py-2.5 rounded-lg border transition-all duration-150 ${T?"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:T?y.jsx("div",{className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center",children:y.jsx(Zi,{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 ${T?"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)})}),d&&!c&&y.jsxs("div",{className:"flex items-center gap-2 px-1",children:[y.jsx(fa,{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(ww,{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(Zi,{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(Up,{text:e.prompt,muted:!0,onFileClick:x})}),A&&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(Zi,{className:"w-2.5 h-2.5 text-white",strokeWidth:3})}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)]",children:A}),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(D9,{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(Up,{text:e.prompt,muted:!0,onFileClick:x})})]}),p&&y.jsx(j9,{filePath:p,onClose:()=>x(null)})]})}function M9(e){return!(!e||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("//")||e.startsWith("#")||e.startsWith("/")||e.startsWith("\\"))}function Up({text:e,muted:t,onFileClick:r}){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})=>r&&M9(a)?y.jsxs("button",{onClick:s=>{s.preventDefault(),r(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(vw,{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 D9({node:e}){const t=[];if(e.route&&t.push({label:"Route",value:`→ ${e.route}`}),e.additional_input){const r=typeof e.additional_input=="object"?JSON.stringify(e.additional_input):e.additional_input;t.push({label:"Additional Input",value:r})}return t.length===0?null:y.jsx(wi,{items:t})}function R9({node:e}){const t=e.status,r=Ie[t]||Ie.pending,a=j5()[e.name],o=e.type==="for_each_group",[s,c]=U.useState(!0),h=[];e.elapsed!=null&&h.push({label:"Elapsed",value:Lt(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 d=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:`${r}20`,color:r},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(wi,{items:h}),o&&d&&d.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(al,{className:"w-3 h-3"}):y.jsx(Rr,{className:"w-3 h-3"}),"Items (",d.length,")"]}),s&&y.jsx("div",{className:"space-y-1",children:d.map(m=>y.jsx(L9,{groupName:e.name,item:m},`${m.key}-${m.index}`))})]})]})}const O9={running:Ie.running,completed:Ie.completed,failed:Ie.failed};function L9({groupName:e,item:t}){const[r,l]=U.useState(t.status==="running"),a=O9[t.status],o=Um(),s=ue(x=>x.navigateIntoSubworkflow),c=`${e}[${t.key}]`,h=o.find(x=>x.slotKey===c),d=!!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:Lt(t.elapsed)}),t.tokens!=null&&p.push({label:"Tokens",value:Pn(t.tokens)}),t.cost_usd!=null&&p.push({label:"Cost",value:vi(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(!r),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?r?y.jsx(al,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}):y.jsx(Rr,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}):t.status==="running"?y.jsx(fa,{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}),!r&&(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:Lt(t.elapsed)}),t.tokens!=null&&y.jsx("span",{children:Pn(t.tokens)}),t.cost_usd!=null&&y.jsx("span",{children:vi(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}),d&&y.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),s(c)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.stopPropagation(),x.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"})})]}),r&&m&&y.jsxs("div",{className:"px-3 py-3 space-y-3 border-t border-[var(--border)]",children:[p.length>0&&y.jsx(wi,{items:p}),t.prompt&&y.jsx(bi,{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(bi,{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 H9({node:e}){const t=ue(d=>d.engageDialog),r=ue(d=>d.sendDialogDecline),l=ue(d=>d.wsStatus),a=e.dialog_id||"",o=e.dialog_messages||[],s=l==="connected",c=o.find(d=>d.role==="agent"),h=()=>{s&&r(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(ol,{className:"w-3 h-3"}),"✕ Skip & continue"]})]})]})]})}function B9({node:e}){const t=e.status,r=Ie[t]||Ie.pending,l=ue(c=>c.navigateIntoSubworkflow),o=Um().filter(c=>c.parentAgent===e.name),s=[];return e.elapsed!=null&&s.push({label:"Elapsed",value:Lt(e.elapsed)}),e.cost_usd!=null&&s.push({label:"Cost",value:vi(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:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Subworkflow Agent"})]}),y.jsx(wi,{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(I9,{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 I9({ctx:e,onClick:t}){const r=Ie[e.status]||Ie.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:r}}),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(bw,{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(xw,{className:"w-2.5 h-2.5"}),vi(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:`${r}20`,color:r},children:e.status}),y.jsx(Rr,{className:"w-3.5 h-3.5 flex-shrink-0 text-[var(--text-muted)]"})]})}function q9(){const e=ue(h=>h.selectedNode),t=Lr(),r=ue(h=>h.selectNode),l=ue(h=>h.dialogEngaged),[a,o]=U.useState(!1);U.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 H9;if(s.dialog_active&&l)return b1;switch(s.type){case"script":return rD;case"set":return iD;case"human_gate":return z9;case"parallel_group":case"for_each_group":return R9;case"workflow":return B9;default:return b1}})();return y.jsxs("div",{className:Me("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:()=>r(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(ol,{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 U9(){const e=ue(S=>S.eventLog),t=ue(S=>S.activityLog),r=ue(S=>S.workflowOutput),l=ue(S=>S.workflowStatus),[a,o]=U.useState("log"),[s,c]=U.useState(!1),[h,d]=U.useState(0),[m,p]=U.useState(0),x=U.useCallback(S=>{o(S),S==="log"&&d(e.length),S==="activity"&&p(t.length)},[e.length,t.length]);U.useEffect(()=>{a==="log"&&d(e.length)},[a,e.length]),U.useEffect(()=>{a==="activity"&&p(t.length)},[a,t.length]),U.useEffect(()=>{l==="completed"&&r!=null&&o("output")},[l,r]);const b=r!=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(cN,{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($p,{active:a==="log",onClick:()=>x("log"),icon:y.jsx(ev,{className:"w-3 h-3"}),label:"Log",count:e.length,unread:w}),y.jsx($p,{active:a==="activity",onClick:()=>x("activity"),icon:y.jsx(gw,{className:"w-3 h-3"}),label:"Activity",count:t.length,unread:E}),y.jsx($p,{active:a==="output",onClick:()=>x("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(al,{className:"w-3.5 h-3.5"})})]}),y.jsx("div",{className:"flex-1 overflow-hidden",children:a==="activity"?y.jsx($9,{entries:t}):a==="log"?y.jsx(V9,{entries:e}):y.jsx(P9,{output:r,status:l})})]})}function $p({active:e,onClick:t,icon:r,label:l,count:a,badge:o,unread:s}){return y.jsxs("button",{onClick:t,className:Me("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:[r,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:Me("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 $9({entries:e}){const t=U.useRef(null),r=U.useRef(!0),l=ue(h=>h.selectNode),[a,o]=U.useState(""),s=U.useCallback(()=>{const h=t.current;if(!h)return;const d=h.scrollHeight-h.scrollTop-h.clientHeight<30;r.current=d},[]),c=U.useMemo(()=>{if(!a)return e;const h=a.toLowerCase();return e.filter(d=>d.source.toLowerCase().includes(h)||ic(d.message).toLowerCase().includes(h))},[e,a]);return U.useEffect(()=>{t.current&&r.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(ol,{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,d)=>{const m=fw[h.type]||fw.message,p=Ik(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:Me("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:Me("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)})]},d)}),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 V9({entries:e}){const t=U.useRef(null),r=U.useRef(!0),l=ue(o=>o.selectNode),a=U.useCallback(()=>{const o=t.current;if(!o)return;const s=o.scrollHeight-o.scrollTop-o.clientHeight<30;r.current=s},[]);return U.useEffect(()=>{t.current&&r.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=Ik(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:Me("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:Me("break-words",o.level==="error"?"text-red-400":o.level==="success"?"text-green-400":"text-[var(--text)]"),children:ic(o.message)})]},s)})})}function Ik(e){const t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),l=t.getMinutes().toString().padStart(2,"0"),a=t.getSeconds().toString().padStart(2,"0");return`${r}:${l}:${a}`}function P9({output:e,status:t}){const[r,l]=U.useState(!1),a=Sw(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:r?y.jsxs(y.Fragment,{children:[y.jsx(Zi,{className:"w-3 h-3 text-[var(--completed)]"}),y.jsx("span",{className:"text-[var(--completed)]",children:"Copied"})]}):y.jsxs(y.Fragment,{children:[y.jsx(yw,{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(G9,{text:a}):a})})]})}function G9({text:e}){const t=e.split(/("(?:[^"\\]|\\.)*")/g);return y.jsx(y.Fragment,{children:t.map((r,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:r},l)}const a=r.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 F9({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:r})=>(r==null?void 0:r.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:r})=>y.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:r}),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 Y9({node:e}){const t=ue(x=>x.sendDialogMessage),r=ue(x=>x.wsStatus),[l,a]=U.useState(""),o=U.useRef(null),s=e.dialog_active===!0,c=e.dialog_id||"",h=e.dialog_messages||[],d=s&&r==="connected";U.useEffect(()=>{var x;(x=o.current)==null||x.scrollIntoView({behavior:"smooth"})},[h.length,e.dialog_awaiting_response]);const m=()=>{!l.trim()||!d||(t(e.name,c,l.trim()),a(""))},p=x=>{x.key==="Enter"&&!x.shiftKey&&(x.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((x,b)=>y.jsx("div",{className:`flex ${x.role==="user"?"justify-end":"justify-start"}`,children:y.jsxs("div",{className:`max-w-[85%] rounded-lg px-3 py-2 ${x.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:x.role==="agent"?e.name:"You"}),y.jsx(F9,{text:x.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:x=>a(x.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:!d,autoFocus:!0}),y.jsxs("button",{onClick:m,disabled:!d||!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(ww,{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 X9(){const e=ue(l=>l.activeDialog),t=ue(l=>l.nodes);if(!e)return null;const r=t[e.agentName];return r?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(Y9,{node:r})})]}):null}function Q9(){const e=ue(l=>l.selectedNode),t=ue(l=>l.activeDialog),r=ue(l=>l.dialogEngaged);return y.jsxs(Pp,{direction:"vertical",className:"flex-1 overflow-hidden",children:[y.jsx(No,{defaultSize:70,minSize:30,children:y.jsxs(Pp,{direction:"horizontal",className:"h-full",children:[y.jsx(No,{defaultSize:e?65:100,minSize:40,children:t&&r?y.jsx(X9,{}):y.jsx(Q4,{})}),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(No,{defaultSize:35,minSize:20,maxSize:60,children:y.jsx(q9,{})})]})]})}),y.jsx(Gp,{className:"h-[3px] bg-[var(--border)] hover:bg-[var(--text-muted)] transition-colors cursor-row-resize"}),y.jsx(No,{defaultSize:30,minSize:5,maxSize:70,collapsible:!0,children:y.jsx(U9,{})})]})}const hw=10;function Z9(){const e=ue(E=>E.iterationLimitGate),t=ue(E=>E.wsStatus),r=ue(E=>E.sendIterationLimitResponse),[l,a]=U.useState(String(hw)),[o,s]=U.useState(!1);U.useEffect(()=>{e!=null&&e.gate_id&&(a(String(hw)),s(!1))},[e==null?void 0:e.gate_id]);const c=U.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",d=t==="connected"&&!o,m=!d||c==null||c<=0,p=()=>e.agent_name!==void 0?{agent_name:e.agent_name}:{group_name:e.group_name},x=()=>{m||c==null||(s(!0),r(p(),e.gate_id,c))},b=()=>{d&&(s(!0),r(p(),e.gate_id,0))},w=E=>{E.key==="Enter"&&(E.preventDefault(),x())};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:!d,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:!d,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(dN,{className:"w-3.5 h-3.5"}),"Stop"]}),y.jsxs("button",{type:"button","data-testid":"iteration-limit-continue",onClick:x,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 K9=3e4;function J9(){const e=ue(p=>p.processEvent),t=ue(p=>p.replayState),r=ue(p=>p.setWsStatus),l=ue(p=>p.setWsSend),a=U.useRef(null),o=U.useRef(1e3),s=U.useRef(null),c=U.useRef(null),h=U.useRef(()=>{}),d=U.useCallback(()=>{r("reconnecting"),s.current=setTimeout(()=>{o.current=Math.min(o.current*2,K9),h.current()},o.current)},[r]),m=U.useCallback(()=>{r("connecting"),c.current&&c.current.abort();const p=new AbortController;c.current=p,fetch("/api/state",{signal:p.signal}).then(x=>x.json()).then(x=>{x&&x.length>0&&t(x);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,r("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=()=>{r("disconnected"),l(null),a.current=null,d()},E.onerror=()=>{}}catch{d()}}).catch(x=>{p.signal.aborted||(console.error("Failed to fetch state:",x),d())})},[e,t,r,l,d]);h.current=m,U.useEffect(()=>(m(),()=>{c.current&&c.current.abort(),s.current&&clearTimeout(s.current),a.current&&a.current.close(),l(null)}),[m,l])}function W9(){const e=ue(d=>d.setReplayMode),t=ue(d=>d.setWsStatus),r=ue(d=>d.replayPlaying),l=ue(d=>d.replayPosition),a=ue(d=>d.replayTotalEvents),o=ue(d=>d.replaySpeed),s=ue(d=>d.replayEvents),c=ue(d=>d.setReplayPosition);U.useEffect(()=>{t("connecting"),fetch("/api/state").then(d=>d.json()).then(d=>{e(d),t("connected")}).catch(d=>{console.error("Failed to load replay events:",d),t("disconnected")})},[e,t]);const h=U.useRef(null);U.useEffect(()=>{if(!r||l>=a){h.current&&clearTimeout(h.current),r&&l>=a&&ue.getState().setReplayPlaying(!1);return}const d=s[l-1],m=s[l];let p=100;if(d&&m){const x=(m.timestamp-d.timestamp)*1e3;p=Math.max(16,Math.min(x/o,2e3))}return h.current=setTimeout(()=>{c(l+1)},p),()=>{h.current&&clearTimeout(h.current)}},[r,l,a,o,s,c])}function eH(){return J9(),null}function tH(){return W9(),null}function nH(){const[e,t]=U.useState(null),r=ue(o=>o.replayMode),l=ue(o=>o.selectNode),a=ue(o=>o.workflowName);return U.useEffect(()=>{fetch("/api/replay/info").then(o=>{o.ok?t(!0):t(!1)}).catch(()=>t(!1))},[]),U.useEffect(()=>{document.title=a?`Conductor — ${a}`:"Conductor Dashboard"},[a]),U.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(tH,{}):y.jsx(eH,{}),y.jsx(BN,{}),y.jsx(IN,{}),y.jsx(Q9,{}),r?y.jsx(PN,{}):y.jsx(UN,{}),!r&&y.jsx(Z9,{})]})}rN.createRoot(document.getElementById("root")).render(y.jsx(U.StrictMode,{children:y.jsx(nH,{})})); diff --git a/src/conductor/web/static/assets/index-hDSiT313.js b/src/conductor/web/static/assets/index-hDSiT313.js new file mode 100644 index 00000000..71ee6cae --- /dev/null +++ b/src/conductor/web/static/assets/index-hDSiT313.js @@ -0,0 +1,356 @@ +var FE=Object.defineProperty;var YE=(e,t,n)=>t in e?FE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Tt=(e,t,n)=>YE(e,typeof t!="symbol"?t+"":t,n);function XE(e,t){for(var n=0;nl[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))l(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&l(s)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function l(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function Ko(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var oh={exports:{}},yo={};/** + * @license React + * react-jsx-runtime.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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={};/** + * @license React + * react.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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(1>>1,D=z[K];if(0>>1;K<$;){var Y=2*(K+1)-1,C=z[Y],P=Y+1,X=z[P];if(0>a(C,Q))Pa(X,C)?(z[K]=X,z[P]=Q,K=P):(z[K]=C,z[Y]=Q,K=Y);else if(Pa(X,Q))z[K]=X,z[P]=Q,K=P;else break e}}return G}function a(z,G){var Q=z.sortIndex-G.sortIndex;return Q!==0?Q:z.id-G.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var s=Date,c=s.now();e.unstable_now=function(){return s.now()-c}}var h=[],f=[],m=1,p=null,g=3,b=!1,w=!1,E=!1,S=!1,_=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function T(z){for(var G=n(f);G!==null;){if(G.callback===null)l(f);else if(G.startTime<=z)l(f),G.sortIndex=G.expirationTime,t(h,G);else break;G=n(f)}}function M(z){if(E=!1,T(z),!w)if(n(h)!==null)w=!0,A||(A=!0,U());else{var G=n(f);G!==null&&F(M,G.startTime-z)}}var A=!1,L=-1,R=5,V=-1;function H(){return S?!0:!(e.unstable_now()-Vz&&H());){var K=p.callback;if(typeof K=="function"){p.callback=null,g=p.priorityLevel;var D=K(p.expirationTime<=z);if(z=e.unstable_now(),typeof D=="function"){p.callback=D,T(z),G=!0;break t}p===n(h)&&l(h),T(z)}else l(h);p=n(h)}if(p!==null)G=!0;else{var $=n(f);$!==null&&F(M,$.startTime-z),G=!1}}break e}finally{p=null,g=Q,b=!1}G=void 0}}finally{G?U():A=!1}}}var U;if(typeof k=="function")U=function(){k(B)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,q=ee.port2;ee.port1.onmessage=B,U=function(){q.postMessage(null)}}else U=function(){_(B,0)};function F(z,G){L=_(function(){z(e.unstable_now())},G)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_forceFrameRate=function(z){0>z||125K?(z.sortIndex=Q,t(f,z),n(h)===null&&z===n(f)&&(E?(N(L),L=-1):E=!0,F(M,Q-K))):(z.sortIndex=D,t(h,z),w||b||(w=!0,A||(A=!0,U()))),z},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(z){var G=g;return function(){var Q=g;g=G;try{return z.apply(this,arguments)}finally{g=Q}}}})(fh)),fh}var Qy;function eN(){return Qy||(Qy=1,ch.exports=WE()),ch.exports}var dh={exports:{}},Yt={};/** + * @license React + * react-dom.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Zy;function tN(){if(Zy)return Yt;Zy=1;var e=Jo();function t(h){var f="https://react.dev/errors/"+h;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),dh.exports=tN(),dh.exports}/** + * @license React + * react-dom-client.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * 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` +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();/** + * @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 lN=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),mw=(...e)=>e.filter((t,n,l)=>!!t&&t.trim()!==""&&l.indexOf(t)===n).join(" ").trim();/** + * @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. + */var aN={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @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 oN=I.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:l,className:a="",children:o,iconNode:s,...c},h)=>I.createElement("svg",{ref:h,...aN,width:t,height:t,stroke:e,strokeWidth:l?Number(n)*24/Number(t):n,className:mw("lucide",a),...c},[...s.map(([f,m])=>I.createElement(f,m)),...Array.isArray(o)?o:[o]]));/** + * @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 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};/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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"}]]);/** + * @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 + 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 + transition-colors`,title:"Re-execute the paused agent",children:[y.jsx(Ec,{className:"w-3 h-3"}),c?"Resuming...":"Resume"]}),y.jsxs("button",{onClick:S,disabled:f,className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded + bg-red-500/10 text-red-400 border border-red-500/20 + hover:bg-red-500/20 hover:border-red-500/30 + disabled:opacity-50 disabled:cursor-not-allowed + transition-colors`,title:"Stop workflow entirely (checkpoint saved for CLI resume)",children:[y.jsx(sl,{className:"w-3 h-3"}),f?"Killing...":"Kill"]})]}):b?y.jsxs("button",{onClick:w,disabled:o,className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded + bg-red-500/10 text-red-400 border border-red-500/20 + hover:bg-red-500/20 hover:border-red-500/30 + disabled:opacity-50 disabled:cursor-not-allowed + transition-colors`,children:[y.jsx(Sw,{className:"w-3 h-3"}),o?"Stopping...":"Stop"]}):null,l&&y.jsxs("button",{onClick:()=>g(!0),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:"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:` + footer input[type="range"]::-webkit-slider-thumb { + -webkit-appearance: none; + width: 12px; + height: 12px; + border-radius: 50%; + background: var(--accent); + border: 2px solid var(--surface); + cursor: pointer; + box-shadow: 0 0 4px rgba(99, 102, 241, 0.4); + } + footer input[type="range"]::-moz-range-thumb { + width: 12px; + height: 12px; + border-radius: 50%; + background: var(--accent); + border: 2px solid var(--surface); + 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={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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}/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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("+",` +`).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?` + +--- 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){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(;++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:` +`},{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(;++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:` +`,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:` +`,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:` +`,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,{})})); diff --git a/src/conductor/web/static/index.html b/src/conductor/web/static/index.html index d7ac5e55..bd9b71df 100644 --- a/src/conductor/web/static/index.html +++ b/src/conductor/web/static/index.html @@ -5,7 +5,7 @@ Conductor Dashboard - + diff --git a/tests/test_config/test_wait_schema.py b/tests/test_config/test_wait_schema.py new file mode 100644 index 00000000..400f037b --- /dev/null +++ b/tests/test_config/test_wait_schema.py @@ -0,0 +1,256 @@ +"""Tests for ``type: wait`` schema validation. + +Covers: +- Valid wait agent definitions (literal and templated durations). +- Required ``duration`` field. +- Forbidden fields on wait agents. +- Duration bounds (> 0 and <= 24h). +- Boolean duration rejection (pre-coercion). +- Reject wait inside parallel groups and as for-each inline agents. +- Reject ``duration`` and ``reason`` on non-wait agents. +""" + +from __future__ import annotations + +import pytest +from pydantic import ValidationError as PydanticValidationError + +from conductor.config.schema import ( + AgentDef, + ForEachDef, + GateOption, + OutputField, + ParallelGroup, + RouteDef, + RuntimeConfig, + WorkflowConfig, + WorkflowDef, +) +from conductor.config.validator import validate_workflow_config +from conductor.exceptions import ConfigurationError + + +def _make_workflow( + *agents: AgentDef, + parallel: list[ParallelGroup] | None = None, + for_each: list[ForEachDef] | None = None, +) -> WorkflowConfig: + """Build a minimal WorkflowConfig for validator tests.""" + return WorkflowConfig( + workflow=WorkflowDef( + name="wait-test", + description="test", + version="1.0.0", + entry_point=agents[0].name, + runtime=RuntimeConfig(provider="copilot"), + ), + agents=list(agents), + parallel=parallel or [], + for_each=for_each or [], + ) + + +class TestValidWait: + """Wait agents accept duration as int/float/string or Jinja template.""" + + def test_int_seconds(self) -> None: + a = AgentDef(name="w", type="wait", duration=60) + assert a.type == "wait" + assert a.duration == 60 + + def test_float_seconds(self) -> None: + a = AgentDef(name="w", type="wait", duration=1.5) + assert a.duration == 1.5 + + def test_string_seconds(self) -> None: + a = AgentDef(name="w", type="wait", duration="60s") + assert a.duration == "60s" + + def test_string_minutes(self) -> None: + AgentDef(name="w", type="wait", duration="5m") + + def test_string_milliseconds(self) -> None: + AgentDef(name="w", type="wait", duration="500ms") + + def test_string_hours(self) -> None: + AgentDef(name="w", type="wait", duration="1h") + + def test_24h_cap_inclusive(self) -> None: + # Exactly 24h is allowed. + AgentDef(name="w", type="wait", duration="24h") + + def test_templated_duration_deferred(self) -> None: + # Templates are not parsed at schema time. + a = AgentDef(name="w", type="wait", duration="{{ workflow.input.x }}s") + assert a.duration == "{{ workflow.input.x }}s" + + def test_templated_garbage_deferred(self) -> None: + # Even nonsense after the template is OK at schema time. + AgentDef(name="w", type="wait", duration="{{ x }}-not-a-duration") + + def test_optional_reason(self) -> None: + a = AgentDef(name="w", type="wait", duration="1s", reason="hello") + assert a.reason == "hello" + + +class TestWaitRequiresDuration: + def test_missing_duration(self) -> None: + with pytest.raises(PydanticValidationError, match="require 'duration'"): + AgentDef(name="w", type="wait") + + +class TestWaitDurationBounds: + def test_zero_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="must be > 0"): + AgentDef(name="w", type="wait", duration=0) + + def test_negative_rejected(self) -> None: + with pytest.raises(PydanticValidationError): + AgentDef(name="w", type="wait", duration=-1) + + def test_over_24h_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="24h cap"): + AgentDef(name="w", type="wait", duration="25h") + + def test_just_over_24h_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="24h cap"): + AgentDef(name="w", type="wait", duration=86401) + + +class TestWaitDurationBool: + def test_true_rejected(self) -> None: + # Booleans must be rejected pre-coercion. Pydantic v2 would + # otherwise accept True as int 1. + with pytest.raises(PydanticValidationError, match="boolean"): + AgentDef(name="w", type="wait", duration=True) + + def test_false_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="boolean"): + AgentDef(name="w", type="wait", duration=False) + + +class TestWaitForbiddenFields: + """Fields that don't make sense for wait must be rejected.""" + + @pytest.mark.parametrize( + "field,value,match", + [ + ("prompt", "x", "'prompt'"), + ("provider", "copilot", "'provider'"), + ("model", "claude-haiku-4.5", "'model'"), + ("system_prompt", "x", "'system_prompt'"), + ("command", "ls", "'command'"), + ("working_dir", "/tmp", "'working_dir'"), + ("timeout", 5, "'timeout'"), + ("workflow", "./sub.yaml", "'workflow'"), + ("max_session_seconds", 30.0, "'max_session_seconds'"), + ("max_agent_iterations", 5, "'max_agent_iterations'"), + ("timeout_seconds", 10.0, "'timeout_seconds'"), + ], + ) + def test_forbidden(self, field: str, value: object, match: str) -> None: + kwargs = {"name": "w", "type": "wait", "duration": "1s", field: value} + with pytest.raises(PydanticValidationError, match=match): + AgentDef(**kwargs) # type: ignore[arg-type] + + def test_tools_list_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="'tools'"): + AgentDef(name="w", type="wait", duration="1s", tools=["foo"]) + + def test_options_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="'options'"): + AgentDef( + name="w", + type="wait", + duration="1s", + options=[GateOption(label="x", value="x", route="$end")], + ) + + def test_args_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="'args'"): + AgentDef(name="w", type="wait", duration="1s", args=["x"]) + + def test_env_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="'env'"): + AgentDef(name="w", type="wait", duration="1s", env={"FOO": "bar"}) + + def test_input_mapping_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="'input_mapping'"): + AgentDef(name="w", type="wait", duration="1s", input_mapping={"x": "y"}) + + def test_max_depth_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="'max_depth'"): + AgentDef(name="w", type="wait", duration="1s", max_depth=2) + + def test_output_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="'output'"): + AgentDef( + name="w", + type="wait", + duration="1s", + output={"x": {"type": "string"}}, + ) + + +class TestWaitFieldsOnOtherTypes: + """duration/reason are wait-only — other types must reject them.""" + + def test_duration_on_plain_agent(self) -> None: + with pytest.raises(PydanticValidationError, match="'duration'"): + AgentDef(name="a", duration="1s", prompt="hi", model="x") + + def test_reason_on_plain_agent(self) -> None: + with pytest.raises(PydanticValidationError, match="'reason'"): + AgentDef(name="a", reason="x", prompt="hi", model="x") + + def test_duration_on_script(self) -> None: + with pytest.raises(PydanticValidationError, match="'duration'"): + AgentDef(name="s", type="script", command="ls", duration="1s") + + +class TestWaitInParallelOrForEach: + """Wait steps cannot be used in parallel groups or for-each groups.""" + + def test_reject_wait_in_parallel(self) -> None: + wait = AgentDef(name="w", type="wait", duration="1s", routes=[RouteDef(to="$end")]) + other = AgentDef(name="o", type="wait", duration="1s", routes=[RouteDef(to="$end")]) + config = _make_workflow( + wait, + other, + parallel=[ParallelGroup(name="pg", agents=["w", "o"], routes=[RouteDef(to="$end")])], + ) + with pytest.raises(ConfigurationError, match="Wait steps cannot be used in parallel"): + validate_workflow_config(config) + + def test_reject_wait_in_for_each(self) -> None: + wait = AgentDef(name="w", type="wait", duration="1s", routes=[RouteDef(to="$end")]) + # An entry-point agent + a producer agent (so the for-each + # source resolves to a real agent reference). + entry = AgentDef( + name="entry", + prompt="x", + model="m", + output={"items": OutputField(type="array", items={"type": "string"})}, + routes=[RouteDef(to="fe")], + ) + for_each = ForEachDef( + name="fe", + type="for_each", + source="entry.output.items", + **{"as": "item"}, + agent=wait, + routes=[RouteDef(to="$end")], + ) + config = _make_workflow(entry, for_each=[for_each]) + with pytest.raises(ConfigurationError, match="Wait steps cannot be used in for_each"): + validate_workflow_config(config) + + +class TestWaitValidationViaWorkflow: + """Smoke test: a workflow containing only a wait step validates.""" + + def test_minimal_wait_workflow(self) -> None: + wait = AgentDef(name="w", type="wait", duration="100ms", routes=[RouteDef(to="$end")]) + config = _make_workflow(wait) + # Should not raise. + validate_workflow_config(config) diff --git a/tests/test_engine/test_duration.py b/tests/test_engine/test_duration.py new file mode 100644 index 00000000..ce0038c8 --- /dev/null +++ b/tests/test_engine/test_duration.py @@ -0,0 +1,120 @@ +"""Tests for the duration parser used by the wait step. + +Covers plain numeric inputs, all supported unit suffixes, whitespace +tolerance, and rejection of malformed / unsupported values. +""" + +from __future__ import annotations + +import pytest + +from conductor.duration import parse_duration + + +class TestParseDurationNumeric: + """Plain numeric durations are interpreted as seconds.""" + + def test_int(self) -> None: + assert parse_duration(60) == 60.0 + + def test_zero(self) -> None: + assert parse_duration(0) == 0.0 + + def test_float(self) -> None: + assert parse_duration(1.5) == 1.5 + + def test_returns_float(self) -> None: + assert isinstance(parse_duration(1), float) + + +class TestParseDurationStrings: + """String durations support ms/s/m/h suffixes and bare numbers.""" + + def test_bare_number(self) -> None: + assert parse_duration("60") == 60.0 + + def test_bare_float(self) -> None: + assert parse_duration("2.5") == 2.5 + + def test_seconds_suffix(self) -> None: + assert parse_duration("60s") == 60.0 + + def test_milliseconds(self) -> None: + assert parse_duration("500ms") == 0.5 + + def test_minutes(self) -> None: + assert parse_duration("5m") == 300.0 + + def test_fractional_minutes(self) -> None: + assert parse_duration("2.5m") == 150.0 + + def test_hours(self) -> None: + assert parse_duration("1h") == 3600.0 + + def test_fractional_hours(self) -> None: + assert parse_duration("0.5h") == 1800.0 + + +class TestParseDurationWhitespace: + """Surrounding and intra-token whitespace is tolerated.""" + + def test_leading_trailing(self) -> None: + assert parse_duration(" 60s ") == 60.0 + + def test_between_value_and_unit(self) -> None: + assert parse_duration("60 s") == 60.0 + + def test_lots_of_whitespace(self) -> None: + assert parse_duration("\t 5 m \n") == 300.0 + + +class TestParseDurationRejects: + """Malformed and unsupported inputs raise ValueError.""" + + def test_bool_true(self) -> None: + with pytest.raises(ValueError, match="boolean"): + parse_duration(True) # type: ignore[arg-type] + + def test_bool_false(self) -> None: + with pytest.raises(ValueError, match="boolean"): + parse_duration(False) # type: ignore[arg-type] + + def test_empty_string(self) -> None: + with pytest.raises(ValueError): + parse_duration("") + + def test_whitespace_only(self) -> None: + with pytest.raises(ValueError): + parse_duration(" ") + + def test_unsupported_unit_d(self) -> None: + with pytest.raises(ValueError): + parse_duration("1d") + + def test_unsupported_unit_us(self) -> None: + with pytest.raises(ValueError): + parse_duration("100us") + + def test_garbage(self) -> None: + with pytest.raises(ValueError): + parse_duration("forever") + + def test_negative_number(self) -> None: + # Bare negatives are not matched by the parser. (Out-of-range + # checks are the caller's responsibility, but we don't accept + # negative literals because the grammar reads as "[unit]" + # with non-negative numbers.) + with pytest.raises(ValueError): + parse_duration("-5s") + + def test_none(self) -> None: + with pytest.raises(ValueError): + parse_duration(None) # type: ignore[arg-type] + + def test_list(self) -> None: + with pytest.raises(ValueError): + parse_duration([60]) # type: ignore[arg-type] + + def test_number_then_garbage(self) -> None: + with pytest.raises(ValueError): + parse_duration("5 minutes") diff --git a/tests/test_engine/test_wait_workflow.py b/tests/test_engine/test_wait_workflow.py new file mode 100644 index 00000000..3bb2eac7 --- /dev/null +++ b/tests/test_engine/test_wait_workflow.py @@ -0,0 +1,300 @@ +"""Integration tests for ``type: wait`` steps in :class:`WorkflowEngine`. + +Tests cover: +- Linear workflow with a wait step that routes to ``$end``. +- Wait output (``{"waited_seconds": float}``) accessible in downstream + agent context. +- Workflow-level ``limits.timeout_seconds`` cancels an in-flight wait + via :class:`ConductorTimeoutError`. +- Interrupt event during a wait surfaces in events and stops execution. +- Emits expected ``agent_started`` (with ``agent_type: "wait"``), + ``wait_started``, and ``wait_completed`` events. +""" + +from __future__ import annotations + +import asyncio +import contextlib +from unittest.mock import MagicMock + +import pytest + +from conductor.config.schema import ( + AgentDef, + ContextConfig, + LimitsConfig, + RouteDef, + RuntimeConfig, + WorkflowConfig, + WorkflowDef, +) +from conductor.engine.workflow import WorkflowEngine +from conductor.events import WorkflowEvent, WorkflowEventEmitter +from conductor.exceptions import TimeoutError as ConductorTimeoutError + + +def _make_config( + agents: list[AgentDef], + *, + entry: str, + timeout_seconds: int | None = None, + output: dict[str, str] | None = None, +) -> WorkflowConfig: + return WorkflowConfig( + workflow=WorkflowDef( + name="wait-test", + description="wait test", + version="1.0.0", + entry_point=entry, + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=10, timeout_seconds=timeout_seconds), + ), + agents=agents, + output=output or {}, + ) + + +class TestWaitWorkflowLinear: + @pytest.mark.asyncio + async def test_wait_runs_to_end(self) -> None: + config = _make_config( + [ + AgentDef( + name="pause", + type="wait", + duration="50ms", + routes=[RouteDef(to="$end")], + ), + ], + entry="pause", + output={"slept": "{{ pause.output.waited_seconds }}"}, + ) + engine = WorkflowEngine(config, MagicMock()) + result = await engine.run({}) + assert "slept" in result + # Output is rendered to a string by the workflow output template. + # Avoid a tight lower bound — CI scheduling jitter can land the + # measured value slightly under the requested duration. + assert float(result["slept"]) >= 0.0 + assert float(result["slept"]) < 5.0 + + @pytest.mark.asyncio + async def test_wait_output_only_has_waited_seconds(self) -> None: + """Per issue #218, the wait output contract is strict: only + ``waited_seconds`` is exposed in workflow context.""" + config = _make_config( + [ + AgentDef( + name="pause", + type="wait", + duration="20ms", + reason="should not leak into context", + routes=[RouteDef(to="$end")], + ), + ], + entry="pause", + ) + engine = WorkflowEngine(config, MagicMock()) + await engine.run({}) + # Stored under pause.output — must contain ONLY waited_seconds. + stored = engine.context.get_for_template().get("pause", {}).get("output", {}) + assert set(stored.keys()) == {"waited_seconds"} + assert stored["waited_seconds"] >= 0.0 + + +class TestWaitWorkflowTimeout: + @pytest.mark.asyncio + async def test_workflow_timeout_cancels_wait(self) -> None: + """A long wait must be cancelled by the workflow-level timeout.""" + config = _make_config( + [ + AgentDef( + name="long_pause", + type="wait", + duration="60s", + routes=[RouteDef(to="$end")], + ), + ], + entry="long_pause", + timeout_seconds=1, + ) + engine = WorkflowEngine(config, MagicMock()) + with pytest.raises(ConductorTimeoutError): + await engine.run({}) + + +class TestWaitWorkflowEvents: + @pytest.mark.asyncio + async def test_emits_wait_lifecycle(self) -> None: + emitter = WorkflowEventEmitter() + events: list[WorkflowEvent] = [] + emitter.subscribe(events.append) + + config = _make_config( + [ + AgentDef( + name="pause", + type="wait", + duration="20ms", + reason="quick", + routes=[RouteDef(to="$end")], + ), + ], + entry="pause", + ) + engine = WorkflowEngine(config, MagicMock(), event_emitter=emitter) + await engine.run({}) + + types = [e.type for e in events] + assert "agent_started" in types + assert "wait_started" in types + assert "wait_completed" in types + + # agent_started carries the agent_type discriminator. + started = next(e for e in events if e.type == "agent_started") + assert started.data.get("agent_type") == "wait" + + ws = next(e for e in events if e.type == "wait_started") + assert ws.data["agent_name"] == "pause" + assert ws.data["duration_seconds"] == pytest.approx(0.02) + assert ws.data["reason"] == "quick" + + wc = next(e for e in events if e.type == "wait_completed") + assert wc.data["agent_name"] == "pause" + assert wc.data["waited_seconds"] >= 0.0 + assert wc.data["requested_seconds"] == pytest.approx(0.02) + assert wc.data["interrupted"] is False + + @pytest.mark.asyncio + async def test_emits_wait_failed_on_runtime_validation(self) -> None: + """Runtime validation errors (e.g. a templated duration that + evaluates to a value over the 24h cap) must emit a + ``wait_failed`` event before the exception unwinds. Without + this, the dashboard would show a hanging "started but never + completed" wait node on any failure.""" + from conductor.exceptions import ValidationError + + emitter = WorkflowEventEmitter() + events: list[WorkflowEvent] = [] + emitter.subscribe(events.append) + + config = WorkflowConfig( + workflow=WorkflowDef( + name="wait-failed", + entry_point="pause", + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=5), + input={ + "hours": { # type: ignore[dict-item] + "type": "number", + "default": 25, + } + }, + ), + agents=[ + AgentDef( + name="pause", + type="wait", + duration="{{ workflow.input.hours }}h", + routes=[RouteDef(to="$end")], + ), + ], + ) + engine = WorkflowEngine(config, MagicMock(), event_emitter=emitter) + with pytest.raises(ValidationError): + await engine.run({"hours": 25}) + + failed = [e for e in events if e.type == "wait_failed"] + assert failed, "expected a wait_failed event" + data = failed[0].data + assert data["agent_name"] == "pause" + assert data["error_type"] == "ValidationError" + assert "24h cap" in data["message"] + assert "elapsed" in data + + +class TestWaitWorkflowTemplatedDuration: + @pytest.mark.asyncio + async def test_templated_duration_from_workflow_input(self) -> None: + config = WorkflowConfig( + workflow=WorkflowDef( + name="wait-templated", + entry_point="pause", + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=5), + input={ + "interval_ms": { # type: ignore[dict-item] + "type": "number", + "default": 30, + } + }, + ), + agents=[ + AgentDef( + name="pause", + type="wait", + duration="{{ workflow.input.interval_ms }}ms", + routes=[RouteDef(to="$end")], + ), + ], + ) + engine = WorkflowEngine(config, MagicMock()) + await engine.run({"interval_ms": 25}) + stored = engine.context.get_for_template().get("pause", {}).get("output", {}) + assert stored["waited_seconds"] >= 0.0 + + +class TestWaitWorkflowInterrupt: + @pytest.mark.asyncio + async def test_interrupt_event_cuts_wait_short(self) -> None: + """When the interrupt event fires mid-wait, the wait completes + early with ``interrupted=True`` and the next agent receives + control as soon as the between-step interrupt check returns. + + We use ``skip_gates=True`` so the interrupt handler auto-stops + without trying to prompt the user, and assert on the emitted + ``wait_completed`` payload rather than the engine's outcome + (which is governed by the generic interrupt path, not by wait). + """ + emitter = WorkflowEventEmitter() + events: list[WorkflowEvent] = [] + emitter.subscribe(events.append) + + interrupt_event = asyncio.Event() + config = _make_config( + [ + AgentDef( + name="long_pause", + type="wait", + duration="30s", + routes=[RouteDef(to="$end")], + ), + ], + entry="long_pause", + ) + engine = WorkflowEngine( + config, + MagicMock(), + event_emitter=emitter, + interrupt_event=interrupt_event, + skip_gates=True, + ) + + async def kick() -> None: + await asyncio.sleep(0.1) + interrupt_event.set() + + # We don't care what the engine ultimately raises — it depends + # on the interactive interrupt path. We only care that the wait + # itself was cut short. + with contextlib.suppress(BaseException): + await asyncio.gather(engine.run({}), kick()) + + wait_completed = [e for e in events if e.type == "wait_completed"] + assert wait_completed, "expected a wait_completed event" + payload = wait_completed[0].data + assert payload["interrupted"] is True + assert payload["waited_seconds"] < 5.0 # nowhere near 30s diff --git a/tests/test_executor/test_wait.py b/tests/test_executor/test_wait.py new file mode 100644 index 00000000..952d2951 --- /dev/null +++ b/tests/test_executor/test_wait.py @@ -0,0 +1,137 @@ +"""Tests for :class:`WaitExecutor`. + +Covers: +- Plain numeric and suffixed-string durations. +- Templated durations rendered from context. +- Interrupt event cancels sleep early; ``interrupted=True`` and + elapsed < requested. +- Runtime validation errors for unparseable / out-of-range durations. +""" + +from __future__ import annotations + +import asyncio + +import pytest + +from conductor.config.schema import AgentDef +from conductor.exceptions import ValidationError +from conductor.executor.wait import WaitExecutor, WaitOutput + + +@pytest.fixture +def executor() -> WaitExecutor: + return WaitExecutor() + + +class TestWaitOutput: + def test_fields(self) -> None: + out = WaitOutput(waited_seconds=0.1, requested_seconds=0.1, reason=None, interrupted=False) + assert out.waited_seconds == 0.1 + assert out.interrupted is False + + +class TestWaitExecutorBasic: + @pytest.mark.asyncio + async def test_short_sleep(self, executor: WaitExecutor) -> None: + agent = AgentDef(name="w", type="wait", duration="100ms") + out = await executor.execute(agent, {}) + # Don't assert a tight lower bound — event-loop scheduling jitter + # on loaded CI can make the monotonic elapsed slightly under the + # requested duration. The contract is "sleep at least roughly + # this long unless interrupted", and ``not interrupted`` is the + # actual invariant. + assert out.waited_seconds < 1.0 + assert out.requested_seconds == 0.1 + assert out.interrupted is False + assert out.reason is None + + @pytest.mark.asyncio + async def test_numeric_duration(self, executor: WaitExecutor) -> None: + agent = AgentDef(name="w", type="wait", duration=0.05) + out = await executor.execute(agent, {}) + assert out.requested_seconds == 0.05 + assert out.waited_seconds < 1.0 + assert out.interrupted is False + + @pytest.mark.asyncio + async def test_reason_rendered(self, executor: WaitExecutor) -> None: + agent = AgentDef(name="w", type="wait", duration="50ms", reason="hi {{ name }}") + out = await executor.execute(agent, {"name": "there"}) + assert out.reason == "hi there" + + @pytest.mark.asyncio + async def test_templated_duration(self, executor: WaitExecutor) -> None: + agent = AgentDef( + name="w", + type="wait", + duration="{{ workflow.input.interval }}ms", + ) + out = await executor.execute(agent, {"workflow": {"input": {"interval": 50}}}) + assert out.requested_seconds == 0.05 + + +class TestWaitExecutorInterrupt: + @pytest.mark.asyncio + async def test_interrupt_cancels_early(self, executor: WaitExecutor) -> None: + agent = AgentDef(name="w", type="wait", duration="10s") + ev = asyncio.Event() + task = asyncio.create_task(executor.execute(agent, {}, interrupt_event=ev)) + await asyncio.sleep(0.05) + ev.set() + out = await task + assert out.interrupted is True + assert out.waited_seconds < 1.0 + # The event MUST remain set so the engine's between-step + # _check_interrupt can consume it and trigger the user menu. + assert ev.is_set() + + @pytest.mark.asyncio + async def test_no_interrupt_runs_to_completion(self, executor: WaitExecutor) -> None: + agent = AgentDef(name="w", type="wait", duration="50ms") + ev = asyncio.Event() + out = await executor.execute(agent, {}, interrupt_event=ev) + assert out.interrupted is False + assert out.waited_seconds >= 0.04 + + @pytest.mark.asyncio + async def test_outer_cancellation_propagates(self, executor: WaitExecutor) -> None: + agent = AgentDef(name="w", type="wait", duration="10s") + ev = asyncio.Event() + task = asyncio.create_task(executor.execute(agent, {}, interrupt_event=ev)) + await asyncio.sleep(0.05) + task.cancel() + with pytest.raises(asyncio.CancelledError): + await task + + +class TestWaitExecutorRuntimeValidation: + """Bounds and parse errors that can arise from templated durations.""" + + @pytest.mark.asyncio + async def test_unparseable_duration(self, executor: WaitExecutor) -> None: + # Bypass the schema by constructing via model_construct (skips + # validation), then trip the runtime parser. + agent = AgentDef.model_construct(name="w", type="wait", duration="forever") + with pytest.raises(ValidationError, match="Wait 'w'"): + await executor.execute(agent, {}) + + @pytest.mark.asyncio + async def test_zero_duration_via_template(self, executor: WaitExecutor) -> None: + agent = AgentDef( + name="w", + type="wait", + duration="{{ workflow.input.interval }}s", + ) + with pytest.raises(ValidationError, match="must be > 0"): + await executor.execute(agent, {"workflow": {"input": {"interval": 0}}}) + + @pytest.mark.asyncio + async def test_over_cap_via_template(self, executor: WaitExecutor) -> None: + agent = AgentDef( + name="w", + type="wait", + duration="{{ workflow.input.interval }}h", + ) + with pytest.raises(ValidationError, match="24h cap"): + await executor.execute(agent, {"workflow": {"input": {"interval": 25}}}) diff --git a/tests/test_web/test_server.py b/tests/test_web/test_server.py index d77f56cb..a9c3f20d 100644 --- a/tests/test_web/test_server.py +++ b/tests/test_web/test_server.py @@ -1110,7 +1110,7 @@ class TestReplaySyntheticFromContext: """Tests for WebDashboard.replay_synthetic_from_context (issue #167 fallback).""" def _build_config(self): - """Build a minimal WorkflowConfig with one agent + one script for tests.""" + """Build a minimal WorkflowConfig with one agent + one script + one wait for tests.""" from conductor.config.schema import AgentDef, RuntimeConfig, WorkflowConfig, WorkflowDef return WorkflowConfig( @@ -1122,6 +1122,7 @@ def _build_config(self): agents=[ AgentDef(name="a", prompt="x", routes=[]), AgentDef(name="s", type="script", command="echo hi", routes=[]), + AgentDef(name="w", type="wait", duration="5s", reason="cooldown", routes=[]), ], ) @@ -1156,6 +1157,36 @@ def test_emits_script_events_for_script_type(self) -> None: assert types == ["script_started", "script_completed"] assert dashboard._event_history[1]["data"]["stdout"] == "hi" + def test_emits_wait_events_for_wait_type(self) -> None: + """Wait steps replay via _synth_agent_or_script's wait branch + (issue #218). The synthetic event pair must use the + wait_started/wait_completed names, propagate the persisted + waited_seconds, carry the AgentDef's reason, and mark + ``synthetic: True`` so the UI can identify replayed state.""" + from conductor.engine.context import WorkflowContext + + emitter, dashboard = _make_dashboard() + ctx = WorkflowContext() + ctx.store("w", {"waited_seconds": 3.5}) + + count = dashboard.replay_synthetic_from_context(ctx, self._build_config()) + + assert count == 2 + types = [ev["type"] for ev in dashboard._event_history] + assert types == ["wait_started", "wait_completed"] + started = dashboard._event_history[0]["data"] + completed = dashboard._event_history[1]["data"] + assert started["agent_name"] == "w" + assert started["duration_seconds"] == 3.5 + assert started["reason"] == "cooldown" + assert started["synthetic"] is True + assert completed["agent_name"] == "w" + assert completed["waited_seconds"] == 3.5 + assert completed["requested_seconds"] == 3.5 + assert completed["reason"] == "cooldown" + assert completed["interrupted"] is False + assert completed["synthetic"] is True + def test_empty_history_returns_zero(self) -> None: from conductor.engine.context import WorkflowContext