From 9cd79abf8e897bfbdd4bcd06bbbd6dcc4b8ae691 Mon Sep 17 00:00:00 2001 From: Daniel Kim <79390398+sox8502@users.noreply.github.com> Date: Fri, 10 Jul 2026 11:26:06 -0700 Subject: [PATCH] Retire eager baseline: projects start with an empty experiment tree (#42) * Retire eager baseline: projects start with an empty experiment tree Creating/importing a project no longer auto-creates the baseline. The first no-parent create-experiment becomes the baseline (the control); a partial unique index (SQLite) hardens one-root-per-project against races. The hosted client now calls POST /projects/{id}/baseline-experiment (renamed from import-baseline; server keeps a deprecated alias) and can seed --run-command. Playbooks, SKILL.md, --help text, and the dashboard empty states now teach the create-the-baseline-first flow. * Allow multiple baselines per project Drop the one-root-per-project unique index (plus a DROP INDEX guard for dbs that ran earlier builds of this branch) and the create_experiment pre-check. New --baseline flag on orx create-experiment (and a baseline field on the local HTTP body) forces another root when one already exists; plain no-parent creates keep attaching under the oldest root. Playbooks/SKILL.md now describe multi-root trees (each root is the control for its own subtree). --- SKILL.md | 65 +++++++++-------- src/client.rs | 24 ++++--- src/commands/create_experiment.rs | 41 +++++++---- src/commands/create_project.rs | 69 ++++++------------- src/commands/up.rs | 8 ++- src/local/experiments.rs | 8 ++- src/local/harness/mod.rs | 13 ++-- src/local/opencode.rs | 15 +++- src/local/projects.rs | 34 ++++----- src/main.rs | 17 +++-- src/store.rs | 6 ++ .../{index-kEYVZ_Rj.js => index-DTKGATIK.js} | 6 +- ui/dist/index.html | 2 +- ui/src/api.ts | 8 ++- ui/src/components/ChatPanel.tsx | 5 +- ui/src/components/NewProjectForm.tsx | 2 +- ui/src/components/TreeView.tsx | 2 +- 17 files changed, 176 insertions(+), 149 deletions(-) rename ui/dist/assets/{index-kEYVZ_Rj.js => index-DTKGATIK.js} (98%) diff --git a/SKILL.md b/SKILL.md index 06889c07..a068c3fc 100644 --- a/SKILL.md +++ b/SKILL.md @@ -21,12 +21,15 @@ These four govern everything below. Breaking any one silently invalidates your results — they are not style preferences. The detailed "experiment-tree model" section expands on the why; these are the non-negotiables. -1. **Never edit the baseline (the root).** The root is the control every variant - is measured against. To try an idea, **branch a child** and edit the child. - Editing the root moves the goalposts and destroys every comparison. (One - exception, like rule 2's single legitimate `--set`: **seeding an *empty* - baseline** with starting code when it has none yet — see "Seeding an empty - baseline." Once the root holds real code, this rule is absolute.) +1. **Never edit a baseline (root) once it holds real code.** A root is the + control its variants are measured against. Projects start with an empty + tree — **you create the baseline** (the first `orx create-experiment`, no + `--parent`) and, on a blank repo, seed it with starting code before its first + run (see "Seeding an empty baseline"). That setup window is the one + exception, like rule 2's single legitimate `--set`. From the moment a root + holds real code this rule is absolute: to try an idea, **branch a child** + and edit the child. Editing a root moves the goalposts and destroys every + comparison under it. 2. **The run command *and* the environment are a fixed contract — identical on every node.** A child inherits its parent's run command verbatim; leave it alone. Do **not** give nodes different start commands, and do **not** vary @@ -90,7 +93,7 @@ orx logout # remove the stored token ### Create and run experiments (write) | Command | What it does | |---|---| -| `orx create-project --name "" [--repo ]` | Create a project **and its baseline (root node)**: bound to a GitHub repo, or on a fresh blank repo when `--repo` is omitted. See below. | +| `orx create-project --name "" [--repo ]` | Create a project bound to a GitHub repo (or a fresh blank repo when `--repo` is omitted). Starts with an **empty experiment tree** — create the baseline next. See below. | | `orx project edit [--name ""] [--description "" \| --description-stdin]` | Edit a project's name and/or description (pass at least one). `--description-stdin` overwrites the description from stdin (long markdown). | | `orx create-experiment --title "" [...]` | Add an experiment node; prints its git branch. See below. | | `orx compute [--gpu ] [--count ] [--provider ] \| --cpu]` | List the GPU compute catalog across all providers, or CPU-only offers with `--cpu` (price-sorted). See below. | @@ -295,9 +298,9 @@ references images by relative path (`![](images/foo.png)`). ## `orx create-project` — start a new project Creates a project in an organization (org ids are printed next to the org names -in `orx projects`), then its **baseline (root node)** on the project's repo — -one command yields a project ready to hang child experiments off. Every project -is backed by exactly one git repo; `--repo` picks where that repo comes from: +in `orx projects`), bound to a git repo. The project starts with an **empty +experiment tree** — no baseline yet. Every project is backed by exactly one git +repo; `--repo` picks where that repo comes from: ```sh # From an existing repo — yours (bound directly) or any readable repo @@ -309,23 +312,24 @@ orx create-project --name "My new idea" ``` - `--repo` takes `owner/repo` or a github.com URL. `--branch` (only with - `--repo`) imports from a non-default branch. `--description` is optional. -- The command prints the project id, repo, and the baseline's id + git branch. - Next steps: hang children off the baseline with + `--repo`) binds a non-default branch — the baseline will branch off it. + `--description` is optional. +- The command prints the project id + repo. **Next step: create the baseline** + (the root node, the control every variant is measured against): + `orx create-experiment --title "Baseline"` (no `--parent`). + Run it once for reference numbers, then hang children off it with `orx create-experiment --title "" --parent `. -- For a **blank** project the baseline starts empty (a stub README): seed it - from existing code before launching runs — for a paper or a known idea there is - almost always a repo that implements it, and starting from that is faster and a - far better control than code written from scratch. See "Seeding an empty - baseline" below. -- If the baseline step fails after the project was created, the command prints - the `orx create-experiment --title ""` recovery — run that - rather than re-running `create-project` (which would mint a second project). +- For a **blank** project the baseline you create starts empty (a stub README): + seed it from existing code before launching runs — for a paper or a known idea + there is almost always a repo that implements it, and starting from that is + faster and a far better control than code written from scratch. See "Seeding + an empty baseline" below. ## Seeding an empty baseline — start from existing code, not from scratch -A **blank** project's baseline is an empty stub (just a `README.md`) — there's no -code to run yet. The right move is almost never to **write the implementation by +On a **blank** project, the baseline you create (`orx create-experiment`, no +`--parent`) starts as an empty stub (just a `README.md`) — there's no code to +run yet. The right move is almost never to **write the implementation by hand.** For nearly any paper or idea there is already a repo that implements it, and seeding the baseline from that repo is faster, more faithful, and a far better control than something typed from memory. Reproductions should start from @@ -397,12 +401,19 @@ orx create-experiment --title "Larger batch size" --parent --title "Baseline" + +# Additional baseline (another root) when the project already has one: +orx create-experiment --title "Baseline v2" --baseline ``` -- `--parent` selects the shape: with `--parent` ⇒ child; without it ⇒ baseline - (root) on the repo the project is already bound to. The repo a project works on - is chosen when the **project** is created (`orx create-project` or the web), so - there is no `--repo` flag here. +- `--parent` selects the shape: with `--parent` ⇒ child; without it, on an + **empty project**, ⇒ the baseline (root) on the repo the project is already + bound to. Once a root exists, a parentless create attaches under the oldest + root on local projects (server projects create another baseline); pass + `--baseline` to explicitly add another root — projects may hold multiple + baselines, each the control for its own subtree. The repo a project works + on is chosen when the **project** is created (`orx create-project` or the + web), so there is no `--repo` flag here. - **A `--parent` child inherits the parent's run command** (and branches off its code). You do **not** set a run command on the child — keep it and vary the code on the child's git branch (see "the experiment-tree model" above). diff --git a/src/client.rs b/src/client.rs index ee9ab69e..8934ff4d 100644 --- a/src/client.rs +++ b/src/client.rs @@ -482,15 +482,15 @@ pub struct CreateChildBody { #[derive(Debug, Clone, Serialize)] #[serde(rename_all = "camelCase")] -pub struct ImportBaselineBody { +pub struct CreateBaselineExperimentBody { #[serde(skip_serializing_if = "Option::is_none")] pub title: Option, #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, - /// Auto-generate suggested first experiments off the baseline. Defaults to - /// true server-side when omitted. + /// Run command seeded onto the baseline so it's launchable immediately. + /// Omit to set it later (`orx exp cmd`). #[serde(skip_serializing_if = "Option::is_none")] - pub generate_suggestions: Option, + pub run_command: Option, } #[derive(Debug, Clone, Serialize)] @@ -504,8 +504,8 @@ pub struct CreateProjectBody { /// project on a fresh blank repo (a stub root commit on `main`). #[serde(skip_serializing_if = "Option::is_none")] pub repo_full_name: Option, - /// Branch the baseline imports from (only with `repo_full_name`). Omit for - /// the repo's default branch. + /// Branch of the repo the project binds to (only with `repo_full_name`) — + /// the baseline experiment branches off it. Omit for the repo's default. #[serde(skip_serializing_if = "Option::is_none")] pub branch: Option, } @@ -877,17 +877,19 @@ pub async fn create_child_experiment( .await } -pub async fn import_baseline( +pub async fn create_baseline_experiment( creds: &Credentials, project_id: &str, - body: &ImportBaselineBody, + body: &CreateBaselineExperimentBody, ) -> Result { - // Repo is bound at project creation; this just materializes the baseline on - // it. `None` fields are omitted so the server applies its defaults. + // Repo is bound at project creation; this materializes a baseline (root + // node) on it. `None` fields are omitted so the server applies its + // defaults. Repeat calls create additional roots — projects may hold + // multiple baselines. let json = serde_json::to_value(body)?; api_post( creds, - &format!("/projects/{}/import-baseline", project_id), + &format!("/projects/{}/baseline-experiment", project_id), json, ) .await diff --git a/src/commands/create_experiment.rs b/src/commands/create_experiment.rs index 3d23b451..706e0828 100644 --- a/src/commands/create_experiment.rs +++ b/src/commands/create_experiment.rs @@ -1,7 +1,13 @@ //! -//! Creates an experiment node. Two shapes, picked by flags: +//! Creates an experiment node. Shapes, picked by flags: //! --parent -> child experiment branched off that parent -//! (no parent) -> baseline (root) experiment on the project's bound repo +//! --baseline -> a new baseline (root), even when roots already exist — +//! projects may hold multiple baselines +//! (no flags) -> the oldest project root when one exists (local +//! projects), or the baseline (root) when the tree is +//! empty — projects start with no experiments, so the +//! first create is the baseline: the control its +//! variants are measured against //! A title is always required. //! //! Note: the repo a project works on is chosen when the PROJECT is created @@ -9,7 +15,8 @@ //! The baseline is materialized on whatever repo the project is already bound to. use crate::client::{ - create_child_experiment, import_baseline, CreateChildBody, Experiment, ImportBaselineBody, + create_baseline_experiment, create_child_experiment, CreateBaselineExperimentBody, + CreateChildBody, Experiment, }; use crate::error::{anyhow, require_credentials, Result}; use crate::store::Store; @@ -33,17 +40,19 @@ pub async fn run(args: crate::CreateExperimentArgs) -> Result<()> { &project, title, args.parent, + args.baseline, args.description, args.run_command, ); } - // The server create APIs carry no run command field — refuse rather than - // silently drop it. - if args.run_command.is_some() { + // The server child-create API carries no run command field — refuse rather + // than silently drop it. (The baseline create below does accept one.) + if args.run_command.is_some() && args.parent.is_some() { return Err(anyhow!( - "--run-command is supported for local projects only. For server \ - projects, set it after creation with `orx exp cmd --set ''`." + "--run-command is supported for local projects and server baselines \ + only. For server child experiments, set it after creation with \ + `orx exp cmd --set ''`." )); } @@ -67,14 +76,15 @@ pub async fn run(args: crate::CreateExperimentArgs) -> Result<()> { kind = "child".to_string(); } else { // Baseline on the project's already-bound GitHub repo. The server - // branches `orx/` off the repo's default branch. - let envelope = import_baseline( + // branches `orx/` off the branch picked at project creation + // (the repo's default unless one was chosen). + let envelope = create_baseline_experiment( &creds, &args.project_id, - &ImportBaselineBody { + &CreateBaselineExperimentBody { title: Some(title), description, - generate_suggestions: None, + run_command: args.run_command, }, ) .await?; @@ -102,13 +112,15 @@ pub async fn run(args: crate::CreateExperimentArgs) -> Result<()> { } /// Local-mode create: child = branch `orx/` off the parent (pushed to -/// origin so HF jobs can clone it). No parent = child of the project's root -/// experiment — a second root is never created here. +/// origin so HF jobs can clone it). No parent = child of the project's oldest +/// root when one exists; on an empty project (or with `--baseline`) the new +/// row becomes a baseline root. Projects may hold multiple baselines. fn run_local( store: &Store, project: &crate::local::model::LocalProject, title: String, parent: Option, + baseline: bool, description: Option, run_command: Option, ) -> Result<()> { @@ -121,6 +133,7 @@ fn run_local( parent_id ) })?), + None if baseline => None, None => { let root = crate::local::experiments::project_root(store, &project.id)?; defaulted_to_root = root.is_some(); diff --git a/src/commands/create_project.rs b/src/commands/create_project.rs index 43a6701f..a7fb04a3 100644 --- a/src/commands/create_project.rs +++ b/src/commands/create_project.rs @@ -1,18 +1,18 @@ //! -//! Creates a project in an organization, then its baseline (root node) on the -//! bound repo — one command yields a project ready to hang experiments off. -//! Two shapes, picked by flags: +//! Creates a project in an organization, bound to a GitHub repo. Two shapes, +//! picked by flags: //! --repo -> bound to that GitHub repo (your own repo, or a //! fresh copy when it's only readable) //! (no repo) -> a fresh blank repo (stub root commit on `main`), //! for projects that start from scratch //! A name is always required. //! -//! The baseline import is a separate API call; if it fails after the project -//! was created, we print the `orx create-experiment` retry instead of failing -//! the whole command (so a re-run doesn't mint a duplicate project). +//! The project starts with an empty experiment tree. The first experiment — +//! created with `orx create-experiment --title ""` (no +//! `--parent`), by you or by the agent — is the baseline: the control every +//! variant is measured against. -use crate::client::{create_project, import_baseline, CreateProjectBody, ImportBaselineBody}; +use crate::client::{create_project, CreateProjectBody}; use crate::error::{require_credentials, Result}; const USAGE: &str = "Usage: orx create-project <orgId> --name \"<name>\" [--repo <owner/repo|url>] [--branch <branch>] [--description \"<text>\"]"; @@ -57,53 +57,28 @@ pub async fn run(args: crate::CreateProjectArgs) -> Result<()> { println!(" name: {}", project.name); println!(" repo: {}/{}", project.github_owner, project.github_repo); - // The root node: a baseline experiment on the repo we just bound. - let baseline = import_baseline( - &creds, - &project.id, - &ImportBaselineBody { - title: None, - description: None, - generate_suggestions: None, - }, - ) - .await; - let experiment = match baseline { - Ok(envelope) => envelope.experiment, - Err(err) => { - // The project exists; failing here would invite a duplicate-project - // retry. Surface the recovery command instead. - eprintln!(); - eprintln!( - "Project created, but its baseline (root node) failed: {}", - err - ); - eprintln!("Create it with:"); - eprintln!(" orx create-experiment {} --title \"<title>\"", project.id); - return Ok(()); - } - }; - - println!(); - println!("\u{2713} Created baseline (root node)"); - println!(" id: {}", experiment.id); - println!(" title: {}", experiment.title); - println!(" branch: {}", experiment.branch_name); println!(); if from_repo { - println!("Add child experiments off the baseline with:"); + println!("The project starts with an empty experiment tree. Create the baseline"); + println!("experiment (the root node — the control variants are measured against) with:"); println!( - " orx create-experiment {} --title \"<title>\" --parent {}", - project.id, experiment.id + " orx create-experiment {} --title \"Baseline\"", + project.id ); + println!("or ask the agent to create and run it."); } else { - println!("The baseline starts empty (a stub README). Push your starting code to it:"); + println!("The repo starts empty (a stub README on its default branch). Push your"); + println!("starting code first:"); println!( - " git clone https://github.com/{}/{} && git checkout {}", - project.github_owner, project.github_repo, experiment.branch_name + " git clone https://github.com/{}/{}", + project.github_owner, project.github_repo + ); + println!(" # …add code, commit, push…"); + println!("then create the baseline experiment (the root node) with:"); + println!( + " orx create-experiment {} --title \"Baseline\"", + project.id ); - println!(" # …add code, commit, then…"); - println!(" git push -u origin {}", experiment.branch_name); } Ok(()) } diff --git a/src/commands/up.rs b/src/commands/up.rs index 746d2698..abee5fbb 100644 --- a/src/commands/up.rs +++ b/src/commands/up.rs @@ -319,7 +319,6 @@ async fn create_project(Json(req): Json<CreateProjectReq>) -> ApiResult { let clone = move || { let store = Store::open()?; local::projects::create_project(&store, &name, &owner, &repo, baseline_branch, run_command) - .map(|(project, _baseline)| project) }; let mut result = tokio::task::spawn_blocking(clone.clone()) .await @@ -472,6 +471,9 @@ async fn list_instances() -> ApiResult { #[serde(rename_all = "camelCase")] struct CreateExperimentReq { parent_experiment_id: Option<String>, + /// Force a new baseline root even when the project already has one. + #[serde(default)] + baseline: bool, slug: Option<String>, title: Option<String>, description: Option<String>, @@ -494,7 +496,9 @@ async fn create_experiment( .get_local_experiment(pid)? .ok_or_else(|| not_found("parent experiment"))?, ), - // No parent -> the project root; never a second root. + // `baseline` forces a new root; otherwise no parent -> the oldest + // project root when one exists (empty project: a new baseline). + None if req.baseline => None, None => local::experiments::project_root(&store, &project.id)?, }; local::experiments::create_experiment( diff --git a/src/local/experiments.rs b/src/local/experiments.rs index bd321259..c5911a19 100644 --- a/src/local/experiments.rs +++ b/src/local/experiments.rs @@ -32,7 +32,9 @@ fn unique_slug(store: &Store, project_id: &str, base: &str) -> Result<String> { } /// The project's root experiment (parent NULL) — oldest first when several -/// exist. CLI/API creates without a parent attach here instead of adding roots. +/// exist. `None` on a fresh project: the tree starts empty and the first +/// no-parent create becomes the baseline. CLI/API creates without a parent +/// attach here once a root exists (pass `--baseline` to add another root). pub fn project_root(store: &Store, project_id: &str) -> Result<Option<LocalExperiment>> { // list is ordered created_at ASC, so `find` picks the oldest root. Ok(store @@ -67,8 +69,8 @@ pub fn create_experiment( }; let slug = unique_slug(store, &project.id, &base)?; - // Git only on the parented path: a baseline row needs no branch, and - // create_project calls this inside a store transaction (keep it network-free). + // Git only on the parented path: a baseline row needs no branch — it rides + // the project's baseline branch, which was validated at clone time. let branch_name = match parent { Some(p) => { let repo = git::ensure_clone( diff --git a/src/local/harness/mod.rs b/src/local/harness/mod.rs index 87106cda..f8957ef8 100644 --- a/src/local/harness/mod.rs +++ b/src/local/harness/mod.rs @@ -244,9 +244,10 @@ the paths listed at the end of that output. ## 2. Carry out the user's research goal -Follow the auto-research loop from the guide: branch experiments off the baseline, -launch runs within the user's GPU budget, wait on completions, and analyze each -result before deciding to refill, promote, or stop. +Follow the auto-research loop from the guide: create the baseline experiment +first when the project is empty, branch variants off it, launch runs within the +user's GPU budget, wait on completions, and analyze each result before deciding +to refill, promote, or stop. ## Prerequisite @@ -265,9 +266,9 @@ auto-research loop. It changes often, so always read it fresh rather than relyin on memory or a cached copy. Then carry out the user's research goal, following the auto-research loop from that -guide: branch experiments off the baseline, launch runs within the GPU budget, -wait on completions, and analyze each result before deciding to refill, promote, -or stop. +guide: create the baseline experiment first when the project is empty, branch +variants off it, launch runs within the GPU budget, wait on completions, and +analyze each result before deciding to refill, promote, or stop. If any command reports `Not logged in`, ask the user to run `orx login` first. diff --git a/src/local/opencode.rs b/src/local/opencode.rs index b0515648..f9b78891 100644 --- a/src/local/opencode.rs +++ b/src/local/opencode.rs @@ -133,13 +133,19 @@ only the commands listed below exist; use this project id (`{id}`) for every Orient with `orx projects` and `orx runs {id}`. +**If the experiment tree is empty** (a fresh project), create the baseline +first: `orx create-experiment {id} --title "Baseline"` (no `--parent`). Give it +the run command, run it once for reference numbers, then branch children off it. + ## Cardinal rules Breaking any of these silently invalidates results — they are not style preferences. -1. **Never edit the baseline (the root experiment).** The root is the control - every variant is measured against. To try an idea, **branch a child** +1. **Never edit a baseline (root experiment) once it exists.** A root is the + control its variants are measured against — on a fresh project you create + it (first `orx create-experiment`, no `--parent`), and from then on it is + frozen. To try an idea, **branch a child** (`orx create-experiment … --parent <expId>`) and edit the child's branch. 2. **The run command and the environment are a fixed contract — identical on every node.** Children inherit it verbatim. If the project has no run @@ -160,7 +166,7 @@ preferences. | Command | What it does | |---|---| | `orx projects` | List projects; local ones are tagged `(local)`. | -| `orx create-experiment {id} --title "<t>" [--description "<d>"] [--parent <expId>] [--run-command "<cmd>"]` | New node, branched `orx/<slug>` off the parent's tip (project root when `--parent` is omitted) and pushed to GitHub. | +| `orx create-experiment {id} --title "<t>" [--description "<d>"] [--parent <expId> \| --baseline] [--run-command "<cmd>"]` | New node, branched `orx/<slug>` off the parent's tip and pushed to GitHub. Omit `--parent`: attaches under the oldest project root — or, on an empty project, becomes the baseline root itself. `--baseline` forces another root (multiple baselines are allowed). | | `orx project view {id}` / `orx project edit {id} --run-command "<cmd>"` | Inspect the project / set its default run command. | | `orx exp status <expId>` | Node's branch, command, and latest run. | | `orx exp desc <expId> [--set "<text>" \| --stdin]` | Read/overwrite the node's notes. Record findings here. | @@ -183,6 +189,9 @@ they hit public hosts and need no login. Carry one goal across many runs: +0. **Round 0 — the baseline** (empty project only): `orx create-experiment {id} + --title "Baseline"` (no `--parent`), set the run command, launch it once. + Its numbers are the reference every variant is judged against. 1. **Branch**: `orx create-experiment {id} --title "<idea>" --parent <parentId>` — one child per distinct thing you try. 2. **Edit** in this clone: `git fetch origin && git checkout <branch>`, change diff --git a/src/local/projects.rs b/src/local/projects.rs index 7ffe41ea..838b97b2 100644 --- a/src/local/projects.rs +++ b/src/local/projects.rs @@ -1,13 +1,17 @@ -//! Local project creation — clone the repo, insert the project row and its -//! baseline root experiment. Used by the `orx up` HTTP API (`POST /api/projects`). +//! Local project creation — clone the repo and insert the project row. Used by +//! the `orx up` HTTP API (`POST /api/projects`). +//! +//! The project starts with an empty experiment tree. The first experiment +//! created without a parent (via `orx create-experiment` or the HTTP API) +//! becomes the baseline root — the control every variant is measured against. use std::collections::HashSet; use crate::error::Result; use crate::store::{now_ms, Store}; -use super::model::{LocalExperiment, LocalProject}; -use super::{experiments, git, slugify}; +use super::model::LocalProject; +use super::{git, slugify}; fn unique_project_slug(store: &Store, base: &str) -> Result<String> { let taken: HashSet<String> = store @@ -28,8 +32,9 @@ fn unique_project_slug(store: &Store, base: &str) -> Result<String> { } } -/// Clone the repo and create the project plus its root "baseline" experiment -/// (parent NULL, branch = baseline branch, command = the project default). +/// Clone the repo and create the project row. No experiments are created — +/// the tree starts empty and the baseline is created lazily (first no-parent +/// `create_experiment`). pub fn create_project( store: &Store, name: &str, @@ -37,7 +42,7 @@ pub fn create_project( github_repo: &str, baseline_branch: Option<String>, run_command: Option<String>, -) -> Result<(LocalProject, LocalExperiment)> { +) -> Result<LocalProject> { let baseline_branch = baseline_branch .filter(|b| !b.trim().is_empty()) .unwrap_or_else(|| "main".to_string()); @@ -57,19 +62,6 @@ pub fn create_project( created_at: now, updated_at: now, }; - // One transaction: a project without its baseline root must never persist - // (a failed baseline insert would orphan the project and burn its slug). - let tx = store.begin()?; store.create_local_project(&project)?; - let baseline = experiments::create_experiment( - store, - &project, - None, - Some("baseline"), - Some("Baseline".to_string()), - None, - project.run_command.clone(), - )?; - tx.commit()?; - Ok((project, baseline)) + Ok(project) } diff --git a/src/main.rs b/src/main.rs index 844f9cb6..e74e96db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -308,8 +308,8 @@ pub struct CreateProjectArgs { /// Omit to start the project on a fresh blank repo. #[arg(long)] pub repo: Option<String>, - /// Branch the baseline imports from (with `--repo`; defaults to the repo's - /// default branch). + /// Branch of the repo the project binds to (with `--repo`; defaults to the + /// repo's default branch). The baseline experiment branches off it. #[arg(long)] pub branch: Option<String>, /// Project description. @@ -326,12 +326,17 @@ pub struct CreateExperimentArgs { /// Experiment description. #[arg(long)] pub description: Option<String>, - /// Parent experiment id -> create a child. Omit to create a baseline on the - /// project's bound repo (local projects: a child of the project root). + /// Parent experiment id -> create a child. Omit on an empty project to + /// create the baseline (root); once a root exists, local projects attach + /// under the oldest root (server projects create another baseline). #[arg(long)] pub parent: Option<String>, - /// Run command for the node (local projects only). Omit to inherit from - /// the parent / project default. + /// Create a new baseline (root) even when the project already has one. + /// Conflicts with --parent. Projects may hold multiple baselines. + #[arg(long, conflicts_with = "parent")] + pub baseline: bool, + /// Run command for the node (local projects and server baselines). Omit to + /// inherit from the parent / project default. #[arg(long = "run-command")] pub run_command: Option<String>, } diff --git a/src/store.rs b/src/store.rs index 7d3b9e37..2452be81 100644 --- a/src/store.rs +++ b/src/store.rs @@ -160,6 +160,12 @@ impl Store { ] { let _ = conn.execute(ddl, []); } + // Older builds of this branch created a one-root-per-project unique + // index; multiple baselines are allowed, so make sure it's gone. + let _ = conn.execute( + "DROP INDEX IF EXISTS uidx_local_experiments_project_baseline", + [], + ); // Data migration: the chat_sessions.permission_mode wire ids were // neutralized off Claude Code's `--permission-mode` spelling (`default`, // `acceptEdits`, `bypassPermissions`) onto harness-agnostic ids (`ask`, diff --git a/ui/dist/assets/index-kEYVZ_Rj.js b/ui/dist/assets/index-DTKGATIK.js similarity index 98% rename from ui/dist/assets/index-kEYVZ_Rj.js rename to ui/dist/assets/index-DTKGATIK.js index 5ee5d902..8f519577 100644 --- a/ui/dist/assets/index-kEYVZ_Rj.js +++ b/ui/dist/assets/index-DTKGATIK.js @@ -274,7 +274,7 @@ Error generating stack: `+p.message+` ?| |(?![\\s\\S])))+`,"m"),alias:l,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(r)[0]}}}}),Object.defineProperty(t.languages.diff,"PREFIXES",{value:n})})(e)}Og.displayName="go";Og.aliases=[];function Og(e){e.register(ri),e.languages.go=e.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),e.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete e.languages.go["class-name"]}jg.displayName="ini";jg.aliases=[];function jg(e){e.languages.ini={comment:{pattern:/(^[ \f\t\v]*)[#;][^\n\r]*/m,lookbehind:!0},section:{pattern:/(^[ \f\t\v]*)\[[^\n\r\]]*\]?/m,lookbehind:!0,inside:{"section-name":{pattern:/(^\[[ \f\t\v]*)[^ \f\t\v\]]+(?:[ \f\t\v]+[^ \f\t\v\]]+)*/,lookbehind:!0,alias:"selector"},punctuation:/\[|\]/}},key:{pattern:/(^[ \f\t\v]*)[^ \f\n\r\t\v=]+(?:[ \f\t\v]+[^ \f\n\r\t\v=]+)*(?=[ \f\t\v]*=)/m,lookbehind:!0,alias:"attr-name"},value:{pattern:/(=[ \f\t\v]*)[^ \f\n\r\t\v]+(?:[ \f\t\v]+[^ \f\n\r\t\v]+)*/,lookbehind:!0,alias:"attr-value",inside:{"inner-value":{pattern:/^("|').+(?=\1$)/,lookbehind:!0}}},punctuation:/=/}}Bg.displayName="java";Bg.aliases=[];function Bg(e){e.register(ri),(function(t){var n=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,r=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,a={pattern:RegExp(/(^|[^\w.])/.source+r+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[a,{pattern:RegExp(/(^|[^\w.])/.source+r+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:a.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+r+/[A-Z]\w*\b/.source),lookbehind:!0,inside:a.inside}],keyword:n,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":a,keyword:n,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+r+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:a.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+r+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:a.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(/<keyword>/g,function(){return n.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(e)}Ig.displayName="regex";Ig.aliases=[];function Ig(e){(function(t){var n={pattern:/\\[\\(){}[\]^$+*?|.]/,alias:"escape"},r=/\\(?:x[\da-fA-F]{2}|u[\da-fA-F]{4}|u\{[\da-fA-F]+\}|0[0-7]{0,2}|[123][0-7]{2}|c[a-zA-Z]|.)/,a={pattern:/\.|\\[wsd]|\\p\{[^{}]+\}/i,alias:"class-name"},l={pattern:/\\[wsd]|\\p\{[^{}]+\}/i,alias:"class-name"},c="(?:[^\\\\-]|"+r.source+")",o=RegExp(c+"-"+c),u={pattern:/(<|')[^<>']+(?=[>']$)/,lookbehind:!0,alias:"variable"};t.languages.regex={"char-class":{pattern:/((?:^|[^\\])(?:\\\\)*)\[(?:[^\\\]]|\\[\s\S])*\]/,lookbehind:!0,inside:{"char-class-negation":{pattern:/(^\[)\^/,lookbehind:!0,alias:"operator"},"char-class-punctuation":{pattern:/^\[|\]$/,alias:"punctuation"},range:{pattern:o,inside:{escape:r,"range-punctuation":{pattern:/-/,alias:"operator"}}},"special-escape":n,"char-set":l,escape:r}},"special-escape":n,"char-set":a,backreference:[{pattern:/\\(?![123][0-7]{2})[1-9]/,alias:"keyword"},{pattern:/\\k<[^<>']+>/,alias:"keyword",inside:{"group-name":u}}],anchor:{pattern:/[$^]|\\[ABbGZz]/,alias:"function"},escape:r,group:[{pattern:/\((?:\?(?:<[^<>']+>|'[^<>']+'|[>:]|<?[=!]|[idmnsuxU]+(?:-[idmnsuxU]+)?:?))?/,alias:"punctuation",inside:{"group-name":u}},{pattern:/\)/,alias:"punctuation"}],quantifier:{pattern:/(?:[+*?]|\{\d+(?:,\d*)?\})[?+]?/,alias:"number"},alternation:{pattern:/\|/,alias:"keyword"}}})(e)}Fu.displayName="javascript";Fu.aliases=["js"];function Fu(e){e.register(ri),e.languages.javascript=e.languages.extend("clike",{"class-name":[e.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),e.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,e.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:e.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:e.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:e.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:e.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:e.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),e.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:e.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),e.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),e.languages.markup&&(e.languages.markup.tag.addInlined("script","javascript"),e.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),e.languages.js=e.languages.javascript}zg.displayName="json";zg.aliases=["webmanifest"];function zg(e){e.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},e.languages.webmanifest=e.languages.json}Hg.displayName="kotlin";Hg.aliases=["kt","kts"];function Hg(e){e.register(ri),(function(t){t.languages.kotlin=t.languages.extend("clike",{keyword:{pattern:/(^|[^.])\b(?:abstract|actual|annotation|as|break|by|catch|class|companion|const|constructor|continue|crossinline|data|do|dynamic|else|enum|expect|external|final|finally|for|fun|get|if|import|in|infix|init|inline|inner|interface|internal|is|lateinit|noinline|null|object|open|operator|out|override|package|private|protected|public|reified|return|sealed|set|super|suspend|tailrec|this|throw|to|try|typealias|val|var|vararg|when|where|while)\b/,lookbehind:!0},function:[{pattern:/(?:`[^\r\n`]+`|\b\w+)(?=\s*\()/,greedy:!0},{pattern:/(\.)(?:`[^\r\n`]+`|\w+)(?=\s*\{)/,lookbehind:!0,greedy:!0}],number:/\b(?:0[xX][\da-fA-F]+(?:_[\da-fA-F]+)*|0[bB][01]+(?:_[01]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?[fFL]?)\b/,operator:/\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/}),delete t.languages.kotlin["class-name"];var n={"interpolation-punctuation":{pattern:/^\$\{?|\}$/,alias:"punctuation"},expression:{pattern:/[\s\S]+/,inside:t.languages.kotlin}};t.languages.insertBefore("kotlin","string",{"string-literal":[{pattern:/"""(?:[^$]|\$(?:(?!\{)|\{[^{}]*\}))*?"""/,alias:"multiline",inside:{interpolation:{pattern:/\$(?:[a-z_]\w*|\{[^{}]*\})/i,inside:n},string:/[\s\S]+/}},{pattern:/"(?:[^"\\\r\n$]|\\.|\$(?:(?!\{)|\{[^{}]*\}))*"/,alias:"singleline",inside:{interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$(?:[a-z_]\w*|\{[^{}]*\})/i,lookbehind:!0,inside:n},string:/[\s\S]+/}}],char:{pattern:/'(?:[^'\\\r\n]|\\(?:.|u[a-fA-F0-9]{0,4}))'/,greedy:!0}}),delete t.languages.kotlin.string,t.languages.insertBefore("kotlin","keyword",{annotation:{pattern:/\B@(?:\w+:)?(?:[A-Z]\w*|\[[^\]]+\])/,alias:"builtin"}}),t.languages.insertBefore("kotlin","function",{label:{pattern:/\b\w+@|@\w+\b/,alias:"symbol"}}),t.languages.kt=t.languages.kotlin,t.languages.kts=t.languages.kotlin})(e)}Fg.displayName="less";Fg.aliases=[];function Fg(e){e.register(da),e.languages.less=e.languages.extend("css",{comment:[/\/\*[\s\S]*?\*\//,{pattern:/(^|[^\\])\/\/.*/,lookbehind:!0}],atrule:{pattern:/@[\w-](?:\((?:[^(){}]|\([^(){}]*\))*\)|[^(){};\s]|\s+(?!\s))*?(?=\s*\{)/,inside:{punctuation:/[:()]/}},selector:{pattern:/(?:@\{[\w-]+\}|[^{};\s@])(?:@\{[\w-]+\}|\((?:[^(){}]|\([^(){}]*\))*\)|[^(){};@\s]|\s+(?!\s))*?(?=\s*\{)/,inside:{variable:/@+[\w-]+/}},property:/(?:@\{[\w-]+\}|[\w-])+(?:\+_?)?(?=\s*:)/,operator:/[+\-*\/]/}),e.languages.insertBefore("less","property",{variable:[{pattern:/@[\w-]+\s*:/,inside:{punctuation:/:/}},/@@?[\w-]+/],"mixin-usage":{pattern:/([{;]\s*)[.#](?!\d)[\w-].*?(?=[(;])/,lookbehind:!0,alias:"function"}})}Pg.displayName="lua";Pg.aliases=[];function Pg(e){e.languages.lua={comment:/^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,string:{pattern:/(["'])(?:(?!\1)[^\\\r\n]|\\z(?:\r\n|\s)|\\(?:\r\n|[^z]))*\1|\[(=*)\[[\s\S]*?\]\2\]/,greedy:!0},number:/\b0x[a-f\d]+(?:\.[a-f\d]*)?(?:p[+-]?\d+)?\b|\b\d+(?:\.\B|(?:\.\d*)?(?:e[+-]?\d+)?\b)|\B\.\d+(?:e[+-]?\d+)?\b/i,keyword:/\b(?:and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,function:/(?!\d)\w+(?=\s*(?:[({]))/,operator:[/[-+*%^&|#]|\/\/?|<[<=]?|>[>=]?|[=~]=?/,{pattern:/(^|[^.])\.\.(?!\.)/,lookbehind:!0}],punctuation:/[\[\](){},;]|\.+|:+/}}Ug.displayName="makefile";Ug.aliases=[];function Ug(e){e.languages.makefile={comment:{pattern:/(^|[^\\])#(?:\\(?:\r\n|[\s\S])|[^\\\r\n])*/,lookbehind:!0},string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"builtin-target":{pattern:/\.[A-Z][^:#=\s]+(?=\s*:(?!=))/,alias:"builtin"},target:{pattern:/^(?:[^:=\s]|[ \t]+(?![\s:]))+(?=\s*:(?!=))/m,alias:"symbol",inside:{variable:/\$+(?:(?!\$)[^(){}:#=\s]+|(?=[({]))/}},variable:/\$+(?:(?!\$)[^(){}:#=\s]+|\([@*%<^+?][DF]\)|(?=[({]))/,keyword:/-include\b|\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|include|override|private|sinclude|undefine|unexport|vpath)\b/,function:{pattern:/(\()(?:abspath|addsuffix|and|basename|call|dir|error|eval|file|filter(?:-out)?|findstring|firstword|flavor|foreach|guile|if|info|join|lastword|load|notdir|or|origin|patsubst|realpath|shell|sort|strip|subst|suffix|value|warning|wildcard|word(?:list|s)?)(?=[ \t])/,lookbehind:!0},operator:/(?:::|[?:+!])?=|[|@]/,punctuation:/[:;(){}]/}}$g.displayName="yaml";$g.aliases=["yml"];function $g(e){(function(t){var n=/[*&][^\s[\]{},]+/,r=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,a="(?:"+r.source+"(?:[ ]+"+n.source+")?|"+n.source+"(?:[ ]+"+r.source+")?)",l=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source.replace(/<PLAIN>/g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),c=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function o(u,f){f=(f||"").replace(/m/g,"")+"m";var g=/([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g,function(){return a}).replace(/<<value>>/g,function(){return u});return RegExp(g,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<<prop>>/g,function(){return a})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g,function(){return a}).replace(/<<key>>/g,function(){return"(?:"+l+"|"+c+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:o(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:o(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:o(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:o(c),lookbehind:!0,greedy:!0},number:{pattern:o(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:r,important:n,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(e)}Gg.displayName="markdown";Gg.aliases=["md"];function Gg(e){e.register(el),(function(t){var n=/(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;function r(o){return o=o.replace(/<inner>/g,function(){return n}),RegExp(/((?:^|[^\\])(?:\\{2})*)/.source+"(?:"+o+")")}var a=/(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source,l=/\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g,function(){return a}),c=/\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;t.languages.markdown=t.languages.extend("markup",{}),t.languages.insertBefore("markdown","prolog",{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:["yaml","language-yaml"],inside:t.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:"punctuation"},table:{pattern:RegExp("^"+l+c+"(?:"+l+")*","m"),inside:{"table-data-rows":{pattern:RegExp("^("+l+c+")(?:"+l+")*$"),lookbehind:!0,inside:{"table-data":{pattern:RegExp(a),inside:t.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp("^("+l+")"+c+"$"),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp("^"+l+"$"),inside:{"table-header":{pattern:RegExp(a),alias:"important",inside:t.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:"keyword"},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:"important",inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:"important",inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:"punctuation"},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:"punctuation"},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:"url"},bold:{pattern:r(/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:r(/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:r(/(~~?)(?:(?!~)<inner>)+\2/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:["code","keyword"]},url:{pattern:r(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/.source),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),["url","bold","italic","strike"].forEach(function(o){["url","bold","italic","strike","code-snippet"].forEach(function(u){o!==u&&(t.languages.markdown[o].inside.content.inside[u]=t.languages.markdown[u])})}),t.hooks.add("after-tokenize",function(o){if(o.language!=="markdown"&&o.language!=="md")return;function u(f){if(!(!f||typeof f=="string"))for(var g=0,d=f.length;g<d;g++){var m=f[g];if(m.type!=="code"){u(m.content);continue}var b=m.content[1],w=m.content[3];if(b&&w&&b.type==="code-language"&&w.type==="code-block"&&typeof b.content=="string"){var C=b.content.replace(/\b#/g,"sharp").replace(/\b\+\+/g,"pp");C=(/[a-z][\w-]*/i.exec(C)||[""])[0].toLowerCase();var v="language-"+C;w.alias?typeof w.alias=="string"?w.alias=[w.alias,v]:w.alias.push(v):w.alias=[v]}}}u(o.tokens)}),t.hooks.add("wrap",function(o){if(o.type==="code-block"){for(var u="",f=0,g=o.classes.length;f<g;f++){var d=o.classes[f],m=/language-(.+)/.exec(d);if(m){u=m[1];break}}var b=t.languages[u];if(b)o.content=t.highlight(o.content.value,b,u);else if(u&&u!=="none"&&t.plugins.autoloader){var w="md-"+new Date().valueOf()+"-"+Math.floor(Math.random()*1e16);o.attributes.id=w,t.plugins.autoloader.loadLanguages(u,function(){var C=document.getElementById(w);C&&(C.innerHTML=t.highlight(C.textContent,t.languages[u],u))})}}}),RegExp(t.languages.markup.tag.pattern.source,"gi"),t.languages.md=t.languages.markdown})(e)}qg.displayName="objectivec";qg.aliases=["objc"];function qg(e){e.register(Jo),e.languages.objectivec=e.languages.extend("c",{string:{pattern:/@?"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},keyword:/\b(?:asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|in|inline|int|long|register|return|self|short|signed|sizeof|static|struct|super|switch|typedef|typeof|union|unsigned|void|volatile|while)\b|(?:@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector)\b/,operator:/-[->]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/@]/}),delete e.languages.objectivec["class-name"],e.languages.objc=e.languages.objectivec}Vg.displayName="perl";Vg.aliases=[];function Vg(e){(function(t){var n=/(?:\((?:[^()\\]|\\[\s\S])*\)|\{(?:[^{}\\]|\\[\s\S])*\}|\[(?:[^[\]\\]|\\[\s\S])*\]|<(?:[^<>\\]|\\[\s\S])*>)/.source;t.languages.perl={comment:[{pattern:/(^\s*)=\w[\s\S]*?=cut.*/m,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\$])#.*/,lookbehind:!0,greedy:!0}],string:[{pattern:RegExp(/\b(?:q|qq|qw|qx)(?![a-zA-Z0-9])\s*/.source+"(?:"+[/([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,/([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2/.source,n].join("|")+")"),greedy:!0},{pattern:/("|`)(?:(?!\1)[^\\]|\\[\s\S])*\1/,greedy:!0},{pattern:/'(?:[^'\\\r\n]|\\.)*'/,greedy:!0}],regex:[{pattern:RegExp(/\b(?:m|qr)(?![a-zA-Z0-9])\s*/.source+"(?:"+[/([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,/([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2/.source,n].join("|")+")"+/[msixpodualngc]*/.source),greedy:!0},{pattern:RegExp(/(^|[^-])\b(?:s|tr|y)(?![a-zA-Z0-9])\s*/.source+"(?:"+[/([^a-zA-Z0-9\s{(\[<])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2/.source,/([a-zA-Z0-9])(?:(?!\3)[^\\]|\\[\s\S])*\3(?:(?!\3)[^\\]|\\[\s\S])*\3/.source,n+/\s*/.source+n].join("|")+")"+/[msixpodualngcer]*/.source),lookbehind:!0,greedy:!0},{pattern:/\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|x|xor)\b))/,greedy:!0}],variable:[/[&*$@%]\{\^[A-Z]+\}/,/[&*$@%]\^[A-Z_]/,/[&*$@%]#?(?=\{)/,/[&*$@%]#?(?:(?:::)*'?(?!\d)[\w$]+(?![\w$]))+(?:::)*/,/[&*$@%]\d+/,/(?!%=)[$@%][!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/],filehandle:{pattern:/<(?![<=])\S*?>|\b_\b/,alias:"symbol"},"v-string":{pattern:/v\d+(?:\.\d+)*|\d+(?:\.\d+){2,}/,alias:"string"},function:{pattern:/(\bsub[ \t]+)\w+/,lookbehind:!0},keyword:/\b(?:any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|return|say|state|sub|switch|undef|unless|until|use|when|while)\b/,number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/,operator:/-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|xor)\b/,punctuation:/[{}[\];(),:]/}})(e)}Pu.displayName="markup-templating";Pu.aliases=[];function Pu(e){e.register(el),(function(t){function n(r,a){return"___"+r.toUpperCase()+a+"___"}Object.defineProperties(t.languages["markup-templating"]={},{buildPlaceholders:{value:function(r,a,l,c){if(r.language===a){var o=r.tokenStack=[];r.code=r.code.replace(l,function(u){if(typeof c=="function"&&!c(u))return u;for(var f=o.length,g;r.code.indexOf(g=n(a,f))!==-1;)++f;return o[f]=u,g}),r.grammar=t.languages.markup}}},tokenizePlaceholders:{value:function(r,a){if(r.language!==a||!r.tokenStack)return;r.grammar=t.languages[a];var l=0,c=Object.keys(r.tokenStack);function o(u){for(var f=0;f<u.length&&!(l>=c.length);f++){var g=u[f];if(typeof g=="string"||g.content&&typeof g.content=="string"){var d=c[l],m=r.tokenStack[d],b=typeof g=="string"?g:g.content,w=n(a,d),C=b.indexOf(w);if(C>-1){++l;var v=b.substring(0,C),y=new t.Token(a,t.tokenize(m,r.grammar),"language-"+a,m),S=b.substring(C+w.length),_=[];v&&_.push.apply(_,o([v])),_.push(y),S&&_.push.apply(_,o([S])),typeof g=="string"?u.splice.apply(u,[f,1].concat(_)):g.content=_}}else g.content&&o(g.content)}return u}o(r.tokens)}}})})(e)}Yg.displayName="php";Yg.aliases=[];function Yg(e){e.register(Pu),(function(t){var n=/\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/,r=[{pattern:/\b(?:false|true)\b/i,alias:"boolean"},{pattern:/(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,greedy:!0,lookbehind:!0},{pattern:/(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,greedy:!0,lookbehind:!0},/\b(?:null)\b/i,/\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/],a=/\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i,l=/<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,c=/[{}\[\](),:;]/;t.languages.php={delimiter:{pattern:/\?>$|^<\?(?:php(?=\s)|=)?/i,alias:"important"},comment:n,variable:/\$+(?:\w+\b|(?=\{))/,package:{pattern:/(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,lookbehind:!0,inside:{punctuation:/\\/}},"class-name-definition":{pattern:/(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,lookbehind:!0,alias:"class-name"},"function-definition":{pattern:/(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,lookbehind:!0,alias:"function"},keyword:[{pattern:/(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,alias:"type-casting",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,alias:"type-declaration",greedy:!0},{pattern:/(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,alias:"type-declaration",greedy:!0,lookbehind:!0},{pattern:/\b(?:parent|self|static)(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(\byield\s+)from\b/i,lookbehind:!0},/\bclass\b/i,{pattern:/((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,lookbehind:!0}],"argument-name":{pattern:/([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,lookbehind:!0},"class-name":[{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/(\|\s*)\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,greedy:!0},{pattern:/(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,alias:"class-name-fully-qualified",greedy:!0,inside:{punctuation:/\\/}},{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*\$)/i,alias:"type-declaration",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-declaration"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,alias:["class-name-fully-qualified","static-context"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-hint"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:["class-name-fully-qualified","return-type"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:r,function:{pattern:/(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,lookbehind:!0,inside:{punctuation:/\\/}},property:{pattern:/(->\s*)\w+/,lookbehind:!0},number:a,operator:l,punctuation:c};var o={pattern:/\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,lookbehind:!0,inside:t.languages.php},u=[{pattern:/<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,alias:"nowdoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<'[^']+'|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<'?|[';]$/}}}},{pattern:/<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<"?|[";]$/}},interpolation:o}},{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/'(?:\\[\s\S]|[^\\'])*'/,alias:"single-quoted-string",greedy:!0},{pattern:/"(?:\\[\s\S]|[^\\"])*"/,alias:"double-quoted-string",greedy:!0,inside:{interpolation:o}}];t.languages.insertBefore("php","variable",{string:u,attribute:{pattern:/#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,greedy:!0,inside:{"attribute-content":{pattern:/^(#\[)[\s\S]+(?=\]$)/,lookbehind:!0,inside:{comment:n,string:u,"attribute-class-name":[{pattern:/([^:]|^)\b[a-z_]\w*(?!\\)\b/i,alias:"class-name",greedy:!0,lookbehind:!0},{pattern:/([^:]|^)(?:\\?\b[a-z_]\w*)+/i,alias:["class-name","class-name-fully-qualified"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:r,number:a,operator:l,punctuation:c}},delimiter:{pattern:/^#\[|\]$/,alias:"punctuation"}}}}),t.hooks.add("before-tokenize",function(f){if(/<\?/.test(f.code)){var g=/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;t.languages["markup-templating"].buildPlaceholders(f,"php",g)}}),t.hooks.add("after-tokenize",function(f){t.languages["markup-templating"].tokenizePlaceholders(f,"php")})})(e)}Wg.displayName="python";Wg.aliases=["py"];function Wg(e){e.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern:/![sra](?=[:}]$)/,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},e.languages.python["string-interpolation"].inside.interpolation.inside.rest=e.languages.python,e.languages.py=e.languages.python}Xg.displayName="r";Xg.aliases=[];function Xg(e){e.languages.r={comment:/#.*/,string:{pattern:/(['"])(?:\\.|(?!\1)[^\\\r\n])*\1/,greedy:!0},"percent-operator":{pattern:/%[^%\s]*%/,alias:"operator"},boolean:/\b(?:FALSE|TRUE)\b/,ellipsis:/\.\.(?:\.|\d+)/,number:[/\b(?:Inf|NaN)\b/,/(?:\b0x[\dA-Fa-f]+(?:\.\d*)?|\b\d+(?:\.\d*)?|\B\.\d+)(?:[EePp][+-]?\d+)?[iL]?/],keyword:/\b(?:NA|NA_character_|NA_complex_|NA_integer_|NA_real_|NULL|break|else|for|function|if|in|next|repeat|while)\b/,operator:/->?>?|<(?:=|<?-)?|[>=!]=?|::?|&&?|\|\|?|[+*\/^$@~]/,punctuation:/[(){}\[\],;]/}}Kg.displayName="ruby";Kg.aliases=["rb"];function Kg(e){e.register(ri),(function(t){t.languages.ruby=t.languages.extend("clike",{comment:{pattern:/#.*|^=begin\s[\s\S]*?^=end/m,greedy:!0},"class-name":{pattern:/(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,operator:/\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,punctuation:/[(){}[\].,;]/}),t.languages.insertBefore("ruby","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}});var n={pattern:/((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,lookbehind:!0,inside:{content:{pattern:/^(#\{)[\s\S]+(?=\}$)/,lookbehind:!0,inside:t.languages.ruby},delimiter:{pattern:/^#\{|\}$/,alias:"punctuation"}}};delete t.languages.ruby.function;var r="(?:"+[/([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,/\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,/\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,/\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,/<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source].join("|")+")",a=/(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;t.languages.insertBefore("ruby","keyword",{"regex-literal":[{pattern:RegExp(/%r/.source+r+/[egimnosux]{0,6}/.source),greedy:!0,inside:{interpolation:n,regex:/[\s\S]+/}},{pattern:/(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,lookbehind:!0,greedy:!0,inside:{interpolation:n,regex:/[\s\S]+/}}],variable:/[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,symbol:[{pattern:RegExp(/(^|[^:]):/.source+a),lookbehind:!0,greedy:!0},{pattern:RegExp(/([\r\n{(,][ \t]*)/.source+a+/(?=:(?!:))/.source),lookbehind:!0,greedy:!0}],"method-definition":{pattern:/(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,lookbehind:!0,inside:{function:/\b\w+$/,keyword:/^self\b/,"class-name":/^\w+/,punctuation:/\./}}}),t.languages.insertBefore("ruby","string",{"string-literal":[{pattern:RegExp(/%[qQiIwWs]?/.source+r),greedy:!0,inside:{interpolation:n,string:/[\s\S]+/}},{pattern:/("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,greedy:!0,inside:{interpolation:n,string:/[\s\S]+/}},{pattern:/<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?/}},interpolation:n,string:/[\s\S]+/}},{pattern:/<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?'|'$/}},string:/[\s\S]+/}}],"command-literal":[{pattern:RegExp(/%x/.source+r),greedy:!0,inside:{interpolation:n,command:{pattern:/[\s\S]+/,alias:"string"}}},{pattern:/`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,greedy:!0,inside:{interpolation:n,command:{pattern:/[\s\S]+/,alias:"string"}}}]}),delete t.languages.ruby.string,t.languages.insertBefore("ruby","number",{builtin:/\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,constant:/\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/}),t.languages.rb=t.languages.ruby})(e)}Zg.displayName="rust";Zg.aliases=[];function Zg(e){(function(t){for(var n=/\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source,r=0;r<2;r++)n=n.replace(/<self>/g,function(){return n});n=n.replace(/<self>/g,function(){return/[^\s\S]/.source}),t.languages.rust={comment:[{pattern:RegExp(/(^|[^\\])/.source+n),lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,greedy:!0},char:{pattern:/b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,greedy:!0},attribute:{pattern:/#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,greedy:!0,alias:"attr-name",inside:{string:null}},"closure-params":{pattern:/([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,lookbehind:!0,greedy:!0,inside:{"closure-punctuation":{pattern:/^\||\|$/,alias:"punctuation"},rest:null}},"lifetime-annotation":{pattern:/'\w+/,alias:"symbol"},"fragment-specifier":{pattern:/(\$\w+:)[a-z]+/,lookbehind:!0,alias:"punctuation"},variable:/\$\w+/,"function-definition":{pattern:/(\bfn\s+)\w+/,lookbehind:!0,alias:"function"},"type-definition":{pattern:/(\b(?:enum|struct|trait|type|union)\s+)\w+/,lookbehind:!0,alias:"class-name"},"module-declaration":[{pattern:/(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,lookbehind:!0,alias:"namespace"},{pattern:/(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,lookbehind:!0,alias:"namespace",inside:{punctuation:/::/}}],keyword:[/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/],function:/\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,macro:{pattern:/\b\w+!/,alias:"property"},constant:/\b[A-Z_][A-Z_\d]+\b/,"class-name":/\b[A-Z]\w*\b/,namespace:{pattern:/(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,inside:{punctuation:/::/}},number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,boolean:/\b(?:false|true)\b/,punctuation:/->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,operator:/[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/},t.languages.rust["closure-params"].inside.rest=t.languages.rust,t.languages.rust.attribute.inside.string=t.languages.rust.string})(e)}Qg.displayName="sass";Qg.aliases=[];function Qg(e){e.register(da),(function(t){t.languages.sass=t.languages.extend("css",{comment:{pattern:/^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t].+)*/m,lookbehind:!0,greedy:!0}}),t.languages.insertBefore("sass","atrule",{"atrule-line":{pattern:/^(?:[ \t]*)[@+=].+/m,greedy:!0,inside:{atrule:/(?:@[\w-]+|[+=])/}}}),delete t.languages.sass.atrule;var n=/\$[-\w]+|#\{\$[-\w]+\}/,r=[/[+*\/%]|[=!]=|<=?|>=?|\b(?:and|not|or)\b/,{pattern:/(\s)-(?=\s)/,lookbehind:!0}];t.languages.insertBefore("sass","property",{"variable-line":{pattern:/^[ \t]*\$.+/m,greedy:!0,inside:{punctuation:/:/,variable:n,operator:r}},"property-line":{pattern:/^[ \t]*(?:[^:\s]+ *:.*|:[^:\s].*)/m,greedy:!0,inside:{property:[/[^:\s]+(?=\s*:)/,{pattern:/(:)[^:\s]+/,lookbehind:!0}],punctuation:/:/,variable:n,operator:r,important:t.languages.sass.important}}}),delete t.languages.sass.property,delete t.languages.sass.important,t.languages.insertBefore("sass","punctuation",{selector:{pattern:/^([ \t]*)\S(?:,[^,\r\n]+|[^,\r\n]*)(?:,[^,\r\n]+)*(?:,(?:\r?\n|\r)\1[ \t]+\S(?:,[^,\r\n]+|[^,\r\n]*)(?:,[^,\r\n]+)*)*/m,lookbehind:!0,greedy:!0}})})(e)}Jg.displayName="scss";Jg.aliases=[];function Jg(e){e.register(da),e.languages.scss=e.languages.extend("css",{comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,lookbehind:!0},atrule:{pattern:/@[\w-](?:\([^()]+\)|[^()\s]|\s+(?!\s))*?(?=\s+[{;])/,inside:{rule:/@[\w-]+/}},url:/(?:[-a-z]+-)?url(?=\()/i,selector:{pattern:/(?=\S)[^@;{}()]?(?:[^@;{}()\s]|\s+(?!\s)|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}][^:{}]*[:{][^}]))/,inside:{parent:{pattern:/&/,alias:"important"},placeholder:/%[-\w]+/,variable:/\$[-\w]+|#\{\$[-\w]+\}/}},property:{pattern:/(?:[-\w]|\$[-\w]|#\{\$[-\w]+\})+(?=\s*:)/,inside:{variable:/\$[-\w]+|#\{\$[-\w]+\}/}}}),e.languages.insertBefore("scss","atrule",{keyword:[/@(?:content|debug|each|else(?: if)?|extend|for|forward|function|if|import|include|mixin|return|use|warn|while)\b/i,{pattern:/( )(?:from|through)(?= )/,lookbehind:!0}]}),e.languages.insertBefore("scss","important",{variable:/\$[-\w]+|#\{\$[-\w]+\}/}),e.languages.insertBefore("scss","function",{"module-modifier":{pattern:/\b(?:as|hide|show|with)\b/i,alias:"keyword"},placeholder:{pattern:/%[-\w]+/,alias:"selector"},statement:{pattern:/\B!(?:default|optional)\b/i,alias:"keyword"},boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"},operator:{pattern:/(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|not|or)(?=\s)/,lookbehind:!0}}),e.languages.scss.atrule.inside.rest=e.languages.scss}em.displayName="sql";em.aliases=[];function em(e){e.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},identifier:{pattern:/(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,greedy:!0,lookbehind:!0,inside:{punctuation:/^`|`$/}},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:FALSE|NULL|TRUE)\b/i,number:/\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/}}tm.displayName="swift";tm.aliases=[];function tm(e){e.languages.swift={comment:{pattern:/(^|[^\\:])(?:\/\/.*|\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:[^*]|\*(?!\/))*\*\/)*\*\/)/,lookbehind:!0,greedy:!0},"string-literal":[{pattern:RegExp(/(^|[^"#])/.source+"(?:"+/"(?:\\(?:\((?:[^()]|\([^()]*\))*\)|\r\n|[^(])|[^\\\r\n"])*"/.source+"|"+/"""(?:\\(?:\((?:[^()]|\([^()]*\))*\)|[^(])|[^\\"]|"(?!""))*"""/.source+")"+/(?!["#])/.source),lookbehind:!0,greedy:!0,inside:{interpolation:{pattern:/(\\\()(?:[^()]|\([^()]*\))*(?=\))/,lookbehind:!0,inside:null},"interpolation-punctuation":{pattern:/^\)|\\\($/,alias:"punctuation"},punctuation:/\\(?=[\r\n])/,string:/[\s\S]+/}},{pattern:RegExp(/(^|[^"#])(#+)/.source+"(?:"+/"(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|\r\n|[^#])|[^\\\r\n])*?"/.source+"|"+/"""(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|[^#])|[^\\])*?"""/.source+")\\2"),lookbehind:!0,greedy:!0,inside:{interpolation:{pattern:/(\\#+\()(?:[^()]|\([^()]*\))*(?=\))/,lookbehind:!0,inside:null},"interpolation-punctuation":{pattern:/^\)|\\#+\($/,alias:"punctuation"},string:/[\s\S]+/}}],directive:{pattern:RegExp(/#/.source+"(?:"+(/(?:elseif|if)\b/.source+"(?:[ ]*"+/(?:![ \t]*)?(?:\b\w+\b(?:[ \t]*\((?:[^()]|\([^()]*\))*\))?|\((?:[^()]|\([^()]*\))*\))(?:[ \t]*(?:&&|\|\|))?/.source+")+")+"|"+/(?:else|endif)\b/.source+")"),alias:"property",inside:{"directive-name":/^#\w+/,boolean:/\b(?:false|true)\b/,number:/\b\d+(?:\.\d+)*\b/,operator:/!|&&|\|\||[<>]=?/,punctuation:/[(),]/}},literal:{pattern:/#(?:colorLiteral|column|dsohandle|file(?:ID|Literal|Path)?|function|imageLiteral|line)\b/,alias:"constant"},"other-directive":{pattern:/#\w+\b/,alias:"property"},attribute:{pattern:/@\w+/,alias:"atrule"},"function-definition":{pattern:/(\bfunc\s+)\w+/,lookbehind:!0,alias:"function"},label:{pattern:/\b(break|continue)\s+\w+|\b[a-zA-Z_]\w*(?=\s*:\s*(?:for|repeat|while)\b)/,lookbehind:!0,alias:"important"},keyword:/\b(?:Any|Protocol|Self|Type|actor|as|assignment|associatedtype|associativity|async|await|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|else|enum|extension|fallthrough|fileprivate|final|for|func|get|guard|higherThan|if|import|in|indirect|infix|init|inout|internal|is|isolated|lazy|left|let|lowerThan|mutating|none|nonisolated|nonmutating|open|operator|optional|override|postfix|precedencegroup|prefix|private|protocol|public|repeat|required|rethrows|return|right|safe|self|set|some|static|struct|subscript|super|switch|throw|throws|try|typealias|unowned|unsafe|var|weak|where|while|willSet)\b/,boolean:/\b(?:false|true)\b/,nil:{pattern:/\bnil\b/,alias:"constant"},"short-argument":/\$\d+\b/,omit:{pattern:/\b_\b/,alias:"keyword"},number:/\b(?:[\d_]+(?:\.[\de_]+)?|0x[a-f0-9_]+(?:\.[a-f0-9p_]+)?|0b[01_]+|0o[0-7_]+)\b/i,"class-name":/\b[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/,function:/\b[a-z_]\w*(?=\s*\()/i,constant:/\b(?:[A-Z_]{2,}|k[A-Z][A-Za-z_]+)\b/,operator:/[-+*/%=!<>&|^~?]+|\.[.\-+*/%=!<>&|^~?]+/,punctuation:/[{}[\]();,.:\\]/},e.languages.swift["string-literal"].forEach(function(t){t.inside.interpolation.inside=e.languages.swift})}nm.displayName="typescript";nm.aliases=["ts"];function nm(e){e.register(Fu),(function(t){t.languages.typescript=t.languages.extend("javascript",{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),t.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete t.languages.typescript.parameter,delete t.languages.typescript["literal-property"];var n=t.languages.extend("typescript",{});delete n["class-name"],t.languages.typescript["class-name"].inside=n,t.languages.insertBefore("typescript","function",{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:"operator"},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:n}}}}),t.languages.ts=t.languages.typescript})(e)}Uu.displayName="basic";Uu.aliases=[];function Uu(e){e.languages.basic={comment:{pattern:/(?:!|REM\b).+/i,inside:{keyword:/^REM/i}},string:{pattern:/"(?:""|[!#$%&'()*,\/:;<=>?^\w +\-.])*"/,greedy:!0},number:/(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i,keyword:/\b(?:AS|BEEP|BLOAD|BSAVE|CALL(?: ABSOLUTE)?|CASE|CHAIN|CHDIR|CLEAR|CLOSE|CLS|COM|COMMON|CONST|DATA|DECLARE|DEF(?: FN| SEG|DBL|INT|LNG|SNG|STR)|DIM|DO|DOUBLE|ELSE|ELSEIF|END|ENVIRON|ERASE|ERROR|EXIT|FIELD|FILES|FOR|FUNCTION|GET|GOSUB|GOTO|IF|INPUT|INTEGER|IOCTL|KEY|KILL|LINE INPUT|LOCATE|LOCK|LONG|LOOP|LSET|MKDIR|NAME|NEXT|OFF|ON(?: COM| ERROR| KEY| TIMER)?|OPEN|OPTION BASE|OUT|POKE|PUT|READ|REDIM|REM|RESTORE|RESUME|RETURN|RMDIR|RSET|RUN|SELECT CASE|SHARED|SHELL|SINGLE|SLEEP|STATIC|STEP|STOP|STRING|SUB|SWAP|SYSTEM|THEN|TIMER|TO|TROFF|TRON|TYPE|UNLOCK|UNTIL|USING|VIEW PRINT|WAIT|WEND|WHILE|WRITE)(?:\$|\b)/i,function:/\b(?:ABS|ACCESS|ACOS|ANGLE|AREA|ARITHMETIC|ARRAY|ASIN|ASK|AT|ATN|BASE|BEGIN|BREAK|CAUSE|CEIL|CHR|CLIP|COLLATE|COLOR|CON|COS|COSH|COT|CSC|DATE|DATUM|DEBUG|DECIMAL|DEF|DEG|DEGREES|DELETE|DET|DEVICE|DISPLAY|DOT|ELAPSED|EPS|ERASABLE|EXLINE|EXP|EXTERNAL|EXTYPE|FILETYPE|FIXED|FP|GO|GRAPH|HANDLER|IDN|IMAGE|IN|INT|INTERNAL|IP|IS|KEYED|LBOUND|LCASE|LEFT|LEN|LENGTH|LET|LINE|LINES|LOG|LOG10|LOG2|LTRIM|MARGIN|MAT|MAX|MAXNUM|MID|MIN|MISSING|MOD|NATIVE|NUL|NUMERIC|OF|OPTION|ORD|ORGANIZATION|OUTIN|OUTPUT|PI|POINT|POINTER|POINTS|POS|PRINT|PROGRAM|PROMPT|RAD|RADIANS|RANDOMIZE|RECORD|RECSIZE|RECTYPE|RELATIVE|REMAINDER|REPEAT|REST|RETRY|REWRITE|RIGHT|RND|ROUND|RTRIM|SAME|SEC|SELECT|SEQUENTIAL|SET|SETTER|SGN|SIN|SINH|SIZE|SKIP|SQR|STANDARD|STATUS|STR|STREAM|STYLE|TAB|TAN|TANH|TEMPLATE|TEXT|THERE|TIME|TIMEOUT|TRACE|TRANSFORM|TRUNCATE|UBOUND|UCASE|USE|VAL|VARIABLE|VIEWPORT|WHEN|WINDOW|WITH|ZER|ZONEWIDTH)(?:\$|\b)/i,operator:/<[=>]?|>=?|[+\-*\/^=&]|\b(?:AND|EQV|IMP|NOT|OR|XOR)\b/i,punctuation:/[,;:()]/}}im.displayName="vbnet";im.aliases=[];function im(e){e.register(Uu),e.languages.vbnet=e.languages.extend("basic",{comment:[{pattern:/(?:!|REM\b).+/i,inside:{keyword:/^REM/i}},{pattern:/(^|[^\\:])'.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(^|[^"])"(?:""|[^"])*"(?!")/,lookbehind:!0,greedy:!0},keyword:/(?:\b(?:ADDHANDLER|ADDRESSOF|ALIAS|AND|ANDALSO|AS|BEEP|BLOAD|BOOLEAN|BSAVE|BYREF|BYTE|BYVAL|CALL(?: ABSOLUTE)?|CASE|CATCH|CBOOL|CBYTE|CCHAR|CDATE|CDBL|CDEC|CHAIN|CHAR|CHDIR|CINT|CLASS|CLEAR|CLNG|CLOSE|CLS|COBJ|COM|COMMON|CONST|CONTINUE|CSBYTE|CSHORT|CSNG|CSTR|CTYPE|CUINT|CULNG|CUSHORT|DATA|DATE|DECIMAL|DECLARE|DEF(?: FN| SEG|DBL|INT|LNG|SNG|STR)|DEFAULT|DELEGATE|DIM|DIRECTCAST|DO|DOUBLE|ELSE|ELSEIF|END|ENUM|ENVIRON|ERASE|ERROR|EVENT|EXIT|FALSE|FIELD|FILES|FINALLY|FOR(?: EACH)?|FRIEND|FUNCTION|GET|GETTYPE|GETXMLNAMESPACE|GLOBAL|GOSUB|GOTO|HANDLES|IF|IMPLEMENTS|IMPORTS|IN|INHERITS|INPUT|INTEGER|INTERFACE|IOCTL|IS|ISNOT|KEY|KILL|LET|LIB|LIKE|LINE INPUT|LOCATE|LOCK|LONG|LOOP|LSET|ME|MKDIR|MOD|MODULE|MUSTINHERIT|MUSTOVERRIDE|MYBASE|MYCLASS|NAME|NAMESPACE|NARROWING|NEW|NEXT|NOT|NOTHING|NOTINHERITABLE|NOTOVERRIDABLE|OBJECT|OF|OFF|ON(?: COM| ERROR| KEY| TIMER)?|OPEN|OPERATOR|OPTION(?: BASE)?|OPTIONAL|OR|ORELSE|OUT|OVERLOADS|OVERRIDABLE|OVERRIDES|PARAMARRAY|PARTIAL|POKE|PRIVATE|PROPERTY|PROTECTED|PUBLIC|PUT|RAISEEVENT|READ|READONLY|REDIM|REM|REMOVEHANDLER|RESTORE|RESUME|RETURN|RMDIR|RSET|RUN|SBYTE|SELECT(?: CASE)?|SET|SHADOWS|SHARED|SHELL|SHORT|SINGLE|SLEEP|STATIC|STEP|STOP|STRING|STRUCTURE|SUB|SWAP|SYNCLOCK|SYSTEM|THEN|THROW|TIMER|TO|TROFF|TRON|TRUE|TRY|TRYCAST|TYPE|TYPEOF|UINTEGER|ULONG|UNLOCK|UNTIL|USHORT|USING|VIEW PRINT|WAIT|WEND|WHEN|WHILE|WIDENING|WITH|WITHEVENTS|WRITE|WRITEONLY|XOR)|\B(?:#CONST|#ELSE|#ELSEIF|#END|#IF))(?:\$|\b)/i,punctuation:/[,;:(){}]/})}const S1=/[#.]/g;function iM(e,t){const n=e||"",r={};let a=0,l,c;for(;a<n.length;){S1.lastIndex=a;const o=S1.exec(n),u=n.slice(a,o?o.index:n.length);u&&(l?l==="#"?r.id=u:Array.isArray(r.className)?r.className.push(u):r.className=[u]:c=u,a+=u.length),o&&(l=o[0],a++)}return{type:"element",tagName:c||t||"div",properties:r,children:[]}}function Vx(e,t,n){const r=n?oM(n):void 0;function a(l,c,...o){let u;if(l==null){u={type:"root",children:[]};const f=c;o.unshift(f)}else{u=iM(l,t);const f=u.tagName.toLowerCase(),g=r?r.get(f):void 0;if(u.tagName=g||f,rM(c))o.unshift(c);else for(const[d,m]of Object.entries(c))sM(e,u.properties,d,m)}for(const f of o)Op(u.children,f);return u.type==="element"&&u.tagName==="template"&&(u.content={type:"root",children:u.children},u.children=[]),u}return a}function rM(e){if(e===null||typeof e!="object"||Array.isArray(e))return!0;if(typeof e.type!="string")return!1;const t=e,n=Object.keys(e);for(const r of n){const a=t[r];if(a&&typeof a=="object"){if(!Array.isArray(a))return!0;const l=a;for(const c of l)if(typeof c!="number"&&typeof c!="string")return!0}}return!!("children"in e&&Array.isArray(e.children))}function sM(e,t,n,r){const a=GS(e,n);let l;if(r!=null){if(typeof r=="number"){if(Number.isNaN(r))return;l=r}else typeof r=="boolean"?l=r:typeof r=="string"?a.spaceSeparated?l=jy(r):a.commaSeparated?l=Dy(r):a.commaOrSpaceSeparated?l=jy(Dy(r).join(" ")):l=x1(a,a.property,r):Array.isArray(r)?l=[...r]:l=a.property==="style"?aM(r):String(r);if(Array.isArray(l)){const c=[];for(const o of l)c.push(x1(a,a.property,o));l=c}a.property==="className"&&Array.isArray(t.className)&&(l=t.className.concat(l)),t[a.property]=l}}function Op(e,t){if(t!=null)if(typeof t=="number"||typeof t=="string")e.push({type:"text",value:String(t)});else if(Array.isArray(t))for(const n of t)Op(e,n);else if(typeof t=="object"&&"type"in t)t.type==="root"?Op(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function x1(e,t,n){if(typeof n=="string"){if(e.number&&n&&!Number.isNaN(Number(n)))return Number(n);if((e.boolean||e.overloadedBoolean)&&(n===""||Do(n)===Do(t)))return!0}return n}function aM(e){const t=[];for(const[n,r]of Object.entries(e))t.push([n,r].join(": "));return t.join("; ")}function oM(e){const t=new Map;for(const n of e)t.set(n.toLowerCase(),n);return t}const lM=["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","solidColor","textArea","textPath"],cM=Vx(qS,"div");Vx(Lu,"g",lM);const uM=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],w1={0:"�",128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"};function Yx(e){const t=typeof e=="string"?e.charCodeAt(0):e;return t>=48&&t<=57}function hM(e){const t=typeof e=="string"?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}function fM(e){const t=typeof e=="string"?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}function C1(e){return fM(e)||Yx(e)}const dM=["","Named character references must be terminated by a semicolon","Numeric character references must be terminated by a semicolon","Named character references cannot be empty","Numeric character references cannot be empty","Named character references must be known","Numeric character references cannot be disallowed","Numeric character references cannot be outside the permissible Unicode range"];function pM(e,t){const n={},r=typeof n.additional=="string"?n.additional.charCodeAt(0):n.additional,a=[];let l=0,c=-1,o="",u,f;n.position&&("start"in n.position||"indent"in n.position?(f=n.position.indent,u=n.position.start):u=n.position);let g=(u?u.line:0)||1,d=(u?u.column:0)||1,m=w(),b;for(l--;++l<=e.length;)if(b===10&&(d=(f?f[c]:0)||1),b=e.charCodeAt(l),b===38){const y=e.charCodeAt(l+1);if(y===9||y===10||y===12||y===32||y===38||y===60||Number.isNaN(y)||r&&y===r){o+=String.fromCharCode(b),d++;continue}const S=l+1;let _=S,k=S,D;if(y===35){k=++_;const P=e.charCodeAt(k);P===88||P===120?(D="hexadecimal",k=++_):D="decimal"}else D="named";let T="",R="",N="";const L=D==="named"?C1:D==="decimal"?Yx:hM;for(k--;++k<=e.length;){const P=e.charCodeAt(k);if(!L(P))break;N+=String.fromCharCode(P),D==="named"&&uM.includes(N)&&(T=N,R=Mo(N))}let I=e.charCodeAt(k)===59;if(I){k++;const P=D==="named"?Mo(N):!1;P&&(T=N,R=P)}let z=1+k-S,q="";if(!(!I&&n.nonTerminated===!1))if(!N)D!=="named"&&C(4,z);else if(D==="named"){if(I&&!R)C(5,1);else if(T!==N&&(k=_+T.length,z=1+k-_,I=!1),!I){const P=T?1:3;if(n.attribute){const U=e.charCodeAt(k);U===61?(C(P,z),R=""):C1(U)?R="":C(P,z)}else C(P,z)}q=R}else{I||C(2,z);let P=Number.parseInt(N,D==="hexadecimal"?16:10);if(gM(P))C(7,z),q="�";else if(P in w1)C(6,z),q=w1[P];else{let U="";mM(P)&&C(6,z),P>65535&&(P-=65536,U+=String.fromCharCode(P>>>10|55296),P=56320|P&1023),q=U+String.fromCharCode(P)}}if(q){v(),m=w(),l=k-1,d+=k-S+1,a.push(q);const P=w();P.offset++,n.reference&&n.reference.call(n.referenceContext||void 0,q,{start:m,end:P},e.slice(S-1,k)),m=P}else N=e.slice(S-1,k),o+=N,d+=N.length,l=k-1}else b===10&&(g++,c++,d=0),Number.isNaN(b)?v():(o+=String.fromCharCode(b),d++);return a.join("");function w(){return{line:g,column:d,offset:l+((u?u.offset:0)||0)}}function C(y,S){let _;n.warning&&(_=w(),_.column+=S,_.offset+=S,n.warning.call(n.warningContext||void 0,dM[y],_,y))}function v(){o&&(a.push(o),n.text&&n.text.call(n.textContext||void 0,o,{start:m,end:w()}),o="")}}function gM(e){return e>=55296&&e<=57343||e>1114111}function mM(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)===65535||(e&65535)===65534}var _M=0,Oc={},zt={util:{type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,"__id",{value:++_M}),e.__id},clone:function e(t,n){n=n||{};var r,a;switch(zt.util.type(t)){case"Object":if(a=zt.util.objId(t),n[a])return n[a];r={},n[a]=r;for(var l in t)t.hasOwnProperty(l)&&(r[l]=e(t[l],n));return r;case"Array":return a=zt.util.objId(t),n[a]?n[a]:(r=[],n[a]=r,t.forEach(function(c,o){r[o]=e(c,n)}),r);default:return t}}},languages:{plain:Oc,plaintext:Oc,text:Oc,txt:Oc,extend:function(e,t){var n=zt.util.clone(zt.languages[e]);for(var r in t)n[r]=t[r];return n},insertBefore:function(e,t,n,r){r=r||zt.languages;var a=r[e],l={};for(var c in a)if(a.hasOwnProperty(c)){if(c==t)for(var o in n)n.hasOwnProperty(o)&&(l[o]=n[o]);n.hasOwnProperty(c)||(l[c]=a[c])}var u=r[e];return r[e]=l,zt.languages.DFS(zt.languages,function(f,g){g===u&&f!=e&&(this[f]=l)}),l},DFS:function e(t,n,r,a){a=a||{};var l=zt.util.objId;for(var c in t)if(t.hasOwnProperty(c)){n.call(t,c,t[c],r||c);var o=t[c],u=zt.util.type(o);u==="Object"&&!a[l(o)]?(a[l(o)]=!0,e(o,n,null,a)):u==="Array"&&!a[l(o)]&&(a[l(o)]=!0,e(o,n,c,a))}}},plugins:{},highlight:function(e,t,n){var r={code:e,grammar:t,language:n};if(zt.hooks.run("before-tokenize",r),!r.grammar)throw new Error('The language "'+r.language+'" has no grammar.');return r.tokens=zt.tokenize(r.code,r.grammar),zt.hooks.run("after-tokenize",r),ko.stringify(zt.util.encode(r.tokens),r.language)},tokenize:function(e,t){var n=t.rest;if(n){for(var r in n)t[r]=n[r];delete t.rest}var a=new vM;return Jc(a,a.head,e),Wx(e,a,t,a.head,0),bM(a)},hooks:{all:{},add:function(e,t){var n=zt.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=zt.hooks.all[e];if(!(!n||!n.length))for(var r=0,a;a=n[r++];)a(t)}},Token:ko};function ko(e,t,n,r){this.type=e,this.content=t,this.alias=n,this.length=(r||"").length|0}function E1(e,t,n,r){e.lastIndex=t;var a=e.exec(n);if(a&&r&&a[1]){var l=a[1].length;a.index+=l,a[0]=a[0].slice(l)}return a}function Wx(e,t,n,r,a,l){for(var c in n)if(!(!n.hasOwnProperty(c)||!n[c])){var o=n[c];o=Array.isArray(o)?o:[o];for(var u=0;u<o.length;++u){if(l&&l.cause==c+","+u)return;var f=o[u],g=f.inside,d=!!f.lookbehind,m=!!f.greedy,b=f.alias;if(m&&!f.pattern.global){var w=f.pattern.toString().match(/[imsuy]*$/)[0];f.pattern=RegExp(f.pattern.source,w+"g")}for(var C=f.pattern||f,v=r.next,y=a;v!==t.tail&&!(l&&y>=l.reach);y+=v.value.length,v=v.next){var S=v.value;if(t.length>e.length)return;if(!(S instanceof ko)){var _=1,k;if(m){if(k=E1(C,y,e,d),!k||k.index>=e.length)break;var N=k.index,D=k.index+k[0].length,T=y;for(T+=v.value.length;N>=T;)v=v.next,T+=v.value.length;if(T-=v.value.length,y=T,v.value instanceof ko)continue;for(var R=v;R!==t.tail&&(T<D||typeof R.value=="string");R=R.next)_++,T+=R.value.length;_--,S=e.slice(y,T),k.index-=y}else if(k=E1(C,0,S,d),!k)continue;var N=k.index,L=k[0],I=S.slice(0,N),z=S.slice(N+L.length),q=y+S.length;l&&q>l.reach&&(l.reach=q);var P=v.prev;I&&(P=Jc(t,P,I),y+=I.length),yM(t,P,_);var U=new ko(c,g?zt.tokenize(L,g):L,b,L);if(v=Jc(t,P,U),z&&Jc(t,v,z),_>1){var V={cause:c+","+u,reach:q};Wx(e,t,n,v.prev,y,V),l&&V.reach>l.reach&&(l.reach=V.reach)}}}}}}function vM(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function Jc(e,t,n){var r=t.next,a={value:n,prev:t,next:r};return t.next=a,r.prev=a,e.length++,a}function yM(e,t,n){for(var r=t.next,a=0;a<n&&r!==e.tail;a++)r=r.next;t.next=r,r.prev=t,e.length-=a}function bM(e){for(var t=[],n=e.head.next;n!==e.tail;)t.push(n.value),n=n.next;return t}const Xx=zt;function Kx(){}Kx.prototype=Xx;const Ne=new Kx;Ne.highlight=SM;Ne.register=xM;Ne.alias=wM;Ne.registered=CM;Ne.listLanguages=EM;Ne.util.encode=kM;Ne.Token.stringify=jp;function SM(e,t){if(typeof e!="string")throw new TypeError("Expected `string` for `value`, got `"+e+"`");let n,r;if(t&&typeof t=="object")n=t;else{if(r=t,typeof r!="string")throw new TypeError("Expected `string` for `name`, got `"+r+"`");if(Object.hasOwn(Ne.languages,r))n=Ne.languages[r];else throw new Error("Unknown language: `"+r+"` is not registered")}return{type:"root",children:Xx.highlight.call(Ne,e,n,r)}}function xM(e){if(typeof e!="function"||!e.displayName)throw new Error("Expected `function` for `syntax`, got `"+e+"`");Object.hasOwn(Ne.languages,e.displayName)||e(Ne)}function wM(e,t){const n=Ne.languages;let r={};typeof e=="string"?t&&(r[e]=t):r=e;let a;for(a in r)if(Object.hasOwn(r,a)){const l=r[a],c=typeof l=="string"?[l]:l;let o=-1;for(;++o<c.length;)n[c[o]]=n[a]}}function CM(e){if(typeof e!="string")throw new TypeError("Expected `string` for `aliasOrLanguage`, got `"+e+"`");return Object.hasOwn(Ne.languages,e)}function EM(){const e=Ne.languages,t=[];let n;for(n in e)Object.hasOwn(e,n)&&typeof e[n]=="object"&&t.push(n);return t}function jp(e,t){if(typeof e=="string")return{type:"text",value:e};if(Array.isArray(e)){const r=[];let a=-1;for(;++a<e.length;)e[a]!==null&&e[a]!==void 0&&e[a]!==""&&r.push(jp(e[a],t));return r}const n={attributes:{},classes:["token",e.type],content:jp(e.content,t),language:t,tag:"span",type:e.type};return e.alias&&n.classes.push(...typeof e.alias=="string"?[e.alias]:e.alias),Ne.hooks.run("wrap",n),cM(n.tag+"."+n.classes.join("."),AM(n.attributes),n.content)}function kM(e){return e}function AM(e){let t;for(t in e)Object.hasOwn(e,t)&&(e[t]=pM(e[t]));return e}Ne.register(ri);Ne.register(Jo);Ne.register(Hu);Ne.register(Dg);Ne.register(Rg);Ne.register(Mg);Ne.register(el);Ne.register(da);Ne.register(Lg);Ne.register(Og);Ne.register(jg);Ne.register(Bg);Ne.register(Ig);Ne.register(Fu);Ne.register(zg);Ne.register(Hg);Ne.register(Fg);Ne.register(Pg);Ne.register(Ug);Ne.register($g);Ne.register(Gg);Ne.register(qg);Ne.register(Vg);Ne.register(Pu);Ne.register(Yg);Ne.register(Wg);Ne.register(Xg);Ne.register(Kg);Ne.register(Zg);Ne.register(Qg);Ne.register(Jg);Ne.register(em);Ne.register(tm);Ne.register(nm);Ne.register(Uu);Ne.register(im);function Zx(e,t){var n;return e.type==="text"?e.value??"":e.type!=="element"?null:x.jsx("span",{className:(((n=e.properties)==null?void 0:n.className)??[]).join(" "),children:(e.children??[]).map(Zx)},t)}function Qx(e,t,n=3e5){if(!t||!Ne.registered(t)||e.length>n)return e;try{return Ne.highlight(e,t).children.map(Zx)}catch{return e}}const TM=1e5;function NM({code:e,lang:t}){const[n,r]=X.useState(!1),a=()=>{var l;(l=navigator.clipboard)==null||l.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};return x.jsxs("div",{className:"md-code",children:[x.jsx("button",{className:"md-code-copy",title:"Copy","aria-label":"Copy code",onClick:a,children:n?x.jsx(Ti,{size:13}):x.jsx(hg,{size:13})}),x.jsx("pre",{children:x.jsx("code",{children:Qx(e,t,TM)})})]})}function DM(e){const t={};for(const n of e.matchAll(/([\w-]+)=(["'])(.*?)\2/g)){const r=n[1];r&&(t[r.toLowerCase()]=n[3]??"")}return t}function RM(e){const t=/<file\b([^>]*?)\/?>/gi,n=[];let r=0,a=!1;for(const l of e.matchAll(t)){const c=DM(l[1]??"");c.path&&(a=!0,l.index>r&&n.push({type:"text",value:e.slice(r,l.index)}),n.push({children:[],data:{hName:"file-mention",hProperties:c},type:"fileMention"}),r=l.index+l[0].length)}return a?(r<e.length&&n.push({type:"text",value:e.slice(r)}),n):null}function Jx(e){const t=e.children;if(t)for(let n=0;n<t.length;n+=1){const r=t[n];if(r){if(r.type==="html"&&typeof r.value=="string"){const a=RM(r.value);if(a){t.splice(n,1,...a),n+=a.length-1;continue}}Jx(r)}}}function MM(){return e=>Jx(e)}function k1({path:e,lines:t,onOpenFile:n}){const r=e.split("/").pop()||e,a=t&&Number.parseInt(t,10)||void 0,l=a!=null?`${r}:${a}`:r;return x.jsxs("button",{className:"file-chip",title:`Open ${e}`,onClick:()=>n==null?void 0:n(e),disabled:!n,children:[x.jsx(AS,{size:12}),x.jsx("span",{className:"file-chip-label",children:l})]})}function LM(e){return!(/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("#")||e.startsWith("//"))}function rm({text:e,onOpenFile:t}){const n={"file-mention":r=>x.jsx(k1,{path:r.path,lines:r.lines,onOpenFile:t}),a:({node:r,href:a,children:l,...c})=>a&&LM(a)&&t?x.jsx(k1,{path:decodeURI(a),onOpenFile:t}):x.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",...c,children:l}),code:({node:r,className:a,children:l,...c})=>{const o=a??"",u=/language-(\w+)/.exec(o),f=String(l??"").replace(/\n$/,"");if(!(u!=null||f.includes(` `)))return x.jsx("code",{className:o,...c,children:l});const d=u?Lp(u[1]):null;return x.jsx(NM,{code:f,lang:d})},pre:({children:r})=>x.jsx(x.Fragment,{children:r})};return x.jsx("div",{className:"md",children:x.jsx(bx,{remarkPlugins:[eM,MM],components:n,children:e})})}function ew({onSaved:e}){const[t,n]=X.useState(""),[r,a]=X.useState(!1),[l,c]=X.useState(null);async function o(u){if(u.preventDefault(),!(r||!t.trim())){a(!0),c(null);try{e(await hT(t.trim())),n("")}catch(f){c(f instanceof Error?f.message:String(f))}finally{a(!1)}}}return x.jsxs("form",{className:"onb-token-form",onSubmit:o,children:[x.jsx("input",{type:"password",value:t,onChange:u=>n(u.target.value),placeholder:"ghp_… personal access token",autoComplete:"off"}),x.jsx("button",{type:"submit",className:"btn",disabled:r||!t.trim(),children:r?"Checking…":"Save"}),x.jsx("a",{href:"https://github.com/settings/tokens/new?scopes=repo,workflow&description=orx",target:"_blank",rel:"noreferrer",children:"Create a token ↗"}),l&&x.jsx("div",{className:"error",children:l})]})}function OM(e){switch(e){case"modal_job":return"Modal";case"hf_job":return"Hugging Face";case"k8s_job":return"Kubernetes";case"ssh_job":return"SSH";default:return e||"—"}}function jM({size:e=16}){return x.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[x.jsx("path",{d:"M2.25 11.535c0-3.407 1.847-6.554 4.844-8.258a9.822 9.822 0 019.687 0c2.997 1.704 4.844 4.851 4.844 8.258 0 5.266-4.337 9.535-9.687 9.535S2.25 16.8 2.25 11.535z",fill:"#FF9D0B"}),x.jsx("path",{d:"M11.938 20.086c4.797 0 8.687-3.829 8.687-8.551 0-4.722-3.89-8.55-8.687-8.55-4.798 0-8.688 3.828-8.688 8.55 0 4.722 3.89 8.55 8.688 8.55z",fill:"#FFD21E"}),x.jsx("path",{d:"M11.875 15.113c2.457 0 3.25-2.156 3.25-3.263 0-.576-.393-.394-1.023-.089-.582.283-1.365.675-2.224.675-1.798 0-3.25-1.693-3.25-.586 0 1.107.79 3.263 3.25 3.263h-.003z",fill:"#FF323D"}),x.jsx("path",{d:"M14.76 9.21c.32.108.445.753.767.585.447-.233.707-.708.659-1.204a1.235 1.235 0 00-.879-1.059 1.262 1.262 0 00-1.33.394c-.322.384-.377.92-.14 1.36.153.283.638-.177.925-.079l-.002.003zm-5.887 0c-.32.108-.448.753-.768.585a1.226 1.226 0 01-.658-1.204c.048-.495.395-.913.878-1.059a1.262 1.262 0 011.33.394c.322.384.377.92.14 1.36-.152.283-.64-.177-.925-.079l.003.003z",fill:"#3A3B45"}),x.jsx("path",{d:"M17.812 10.366a.806.806 0 00.813-.8c0-.441-.364-.8-.813-.8a.806.806 0 00-.812.8c0 .442.364.8.812.8zm-11.624 0a.806.806 0 00.812-.8c0-.441-.364-.8-.812-.8a.806.806 0 00-.813.8c0 .442.364.8.813.8z",fill:"#3A3B45"}),x.jsx("path",{d:"M4.515 13.073c-.405 0-.765.162-1.017.46a1.455 1.455 0 00-.333.925 1.801 1.801 0 00-.485-.074c-.387 0-.737.146-.985.409a1.41 1.41 0 00-.2 1.722 1.302 1.302 0 00-.447.694c-.06.222-.12.69.2 1.166a1.267 1.267 0 00-.093 1.236c.238.533.81.958 1.89 1.405l.24.096c.768.3 1.473.492 1.478.494.89.243 1.808.375 2.732.394 1.465 0 2.513-.443 3.115-1.314.93-1.342.842-2.575-.274-3.763l-.151-.154c-.692-.684-1.155-1.69-1.25-1.912-.195-.655-.71-1.383-1.562-1.383-.46.007-.889.233-1.15.605-.25-.31-.495-.553-.715-.694a1.87 1.87 0 00-.993-.312zm14.97 0c.405 0 .767.162 1.017.46.216.262.333.588.333.925.158-.047.322-.071.487-.074.388 0 .738.146.985.409a1.41 1.41 0 01.2 1.722c.22.178.377.422.445.694.06.222.12.69-.2 1.166.244.37.279.836.093 1.236-.238.533-.81.958-1.889 1.405l-.239.096c-.77.3-1.475.492-1.48.494-.89.243-1.808.375-2.732.394-1.465 0-2.513-.443-3.115-1.314-.93-1.342-.842-2.575.274-3.763l.151-.154c.695-.684 1.157-1.69 1.252-1.912.195-.655.708-1.383 1.56-1.383.46.007.889.233 1.15.605.25-.31.495-.553.718-.694.244-.162.523-.265.814-.3l.176-.012z",fill:"#FF9D0B"}),x.jsx("path",{d:"M9.785 20.132c.688-.994.638-1.74-.305-2.667-.945-.928-1.495-2.288-1.495-2.288s-.205-.788-.672-.714c-.468.074-.81 1.25.17 1.971.977.721-.195 1.21-.573.534-.375-.677-1.405-2.416-1.94-2.751-.532-.332-.907-.148-.782.541.125.687 2.357 2.35 2.14 2.707-.218.362-.983-.42-.983-.42S2.953 14.9 2.43 15.46c-.52.558.398 1.026 1.7 1.803 1.308.778 1.41.985 1.225 1.28-.187.295-3.07-2.1-3.34-1.083-.27 1.011 2.943 1.304 2.745 2.006-.2.7-2.265-1.324-2.685-.537-.425.79 2.913 1.718 2.94 1.725 1.075.276 3.813.859 4.77-.522zm4.432 0c-.687-.994-.64-1.74.305-2.667.943-.928 1.493-2.288 1.493-2.288s.205-.788.675-.714c.465.074.807 1.25-.17 1.971-.98.721.195 1.21.57.534.377-.677 1.407-2.416 1.94-2.751.532-.332.91-.148.782.541-.125.687-2.355 2.35-2.137 2.707.215.362.98-.42.98-.42S21.05 14.9 21.57 15.46c.52.558-.395 1.026-1.7 1.803-1.308.778-1.408.985-1.225 1.28.187.295 3.07-2.1 3.34-1.083.27 1.011-2.94 1.304-2.743 2.006.2.7 2.263-1.324 2.685-.537.423.79-2.912 1.718-2.94 1.725-1.077.276-3.815.859-4.77-.522z",fill:"#FFD21E"})]})}function BM({size:e=16}){return x.jsxs("svg",{width:e,height:e,viewBox:"0 0 300 300",fill:"none","aria-hidden":"true",children:[x.jsx("path",{d:"M121.683 75.25L149.997 124L91.4816 224.75C90.3128 226.757 88.155 228 85.8174 228H32.9664C31.7976 228 30.6778 227.691 29.697 227.131C28.7161 226.57 27.8906 225.758 27.3021 224.75L0.876625 179.25C-0.292208 177.243 -0.292208 174.765 0.876625 172.75L57.512 75.25C58.0923 74.2425 58.9259 73.43 59.9068 72.8694C60.8876 72.3088 62.0074 72 63.1762 72H116.027C118.365 72 120.523 73.2431 121.692 75.25H121.683ZM299.125 172.75L242.49 75.25C241.91 74.2425 241.076 73.43 240.095 72.8694C239.114 72.3088 237.995 72 236.826 72H183.975C181.637 72 179.479 73.2431 178.311 75.25L149.997 124L208.512 224.75C209.681 226.757 211.839 228 214.177 228H267.027C268.196 228 269.316 227.691 270.297 227.131C271.278 226.57 272.103 225.758 272.692 224.75L299.117 179.25C300.286 177.243 300.286 174.765 299.117 172.75H299.125Z",fill:"#62DE61"}),x.jsx("path",{d:"M89.6018 124H150.005L121.692 75.25C120.523 73.2431 118.365 72 116.027 72H63.1763C62.0074 72 60.8876 72.3088 59.9068 72.8694L89.6018 124Z",fill:"url(#orxModalA)"}),x.jsx("path",{d:"M89.6018 124L59.9068 72.8694C58.9259 73.43 58.1005 74.2425 57.512 75.25L0.876625 172.75C-0.292208 174.765 -0.292208 177.235 0.876625 179.25L27.3021 224.75C27.8825 225.758 28.7161 226.57 29.697 227.131L89.5936 124H89.6018Z",fill:"url(#orxModalB)"}),x.jsx("path",{d:"M149.997 124H89.5936L29.697 227.131C30.6778 227.691 31.7976 228 32.9664 228H85.8174C88.155 228 90.3128 226.757 91.4816 224.75L149.997 124Z",fill:"#09AF58"}),x.jsx("path",{d:"M299.125 179.25C299.706 178.243 300 177.121 300 176H240.61L210.915 227.131C211.896 227.691 213.016 228 214.185 228H267.036C269.373 228 271.531 226.757 272.7 224.75L299.125 179.25Z",fill:"#09AF58"}),x.jsx("path",{d:"M183.975 72C182.806 72 181.686 72.3088 180.705 72.8694L240.602 176H299.992C299.992 174.879 299.698 173.758 299.117 172.75L242.49 75.25C241.321 73.2431 239.163 72 236.826 72H183.967H183.975Z",fill:"url(#orxModalC)"}),x.jsx("path",{d:"M210.907 227.131L240.602 176L180.705 72.8694C179.725 73.43 178.899 74.2425 178.311 75.25L149.997 124L208.512 224.75C209.093 225.758 209.926 226.57 210.907 227.131Z",fill:"url(#orxModalD)"}),x.jsxs("defs",{children:[x.jsxs("linearGradient",{id:"orxModalA",x1:"127.348",y1:"137",x2:"82.9561",y2:"59.6398",gradientUnits:"userSpaceOnUse",children:[x.jsx("stop",{stopColor:"#BFF9B4"}),x.jsx("stop",{offset:"1",stopColor:"#80EE64"})]}),x.jsxs("linearGradient",{id:"orxModalB",x1:"7.04774",y1:"214.131",x2:"81.1284",y2:"85.0556",gradientUnits:"userSpaceOnUse",children:[x.jsx("stop",{stopColor:"#80EE64"}),x.jsx("stop",{offset:"0.18",stopColor:"#7BEB63"}),x.jsx("stop",{offset:"0.36",stopColor:"#6FE562"}),x.jsx("stop",{offset:"0.55",stopColor:"#5ADA60"}),x.jsx("stop",{offset:"0.74",stopColor:"#3DCA5D"}),x.jsx("stop",{offset:"0.93",stopColor:"#18B759"}),x.jsx("stop",{offset:"1",stopColor:"#09AF58"})]}),x.jsxs("linearGradient",{id:"orxModalC",x1:"278.103",y1:"188.561",x2:"204.022",y2:"59.4863",gradientUnits:"userSpaceOnUse",children:[x.jsx("stop",{stopColor:"#BFF9B4"}),x.jsx("stop",{offset:"1",stopColor:"#80EE64"})]}),x.jsxs("linearGradient",{id:"orxModalD",x1:"232.804",y1:"214.569",x2:"158.724",y2:"85.4864",gradientUnits:"userSpaceOnUse",children:[x.jsx("stop",{stopColor:"#80EE64"}),x.jsx("stop",{offset:"0.18",stopColor:"#7BEB63"}),x.jsx("stop",{offset:"0.36",stopColor:"#6FE562"}),x.jsx("stop",{offset:"0.55",stopColor:"#5ADA60"}),x.jsx("stop",{offset:"0.74",stopColor:"#3DCA5D"}),x.jsx("stop",{offset:"0.93",stopColor:"#18B759"}),x.jsx("stop",{offset:"1",stopColor:"#09AF58"})]})]})]})}function IM({size:e=16}){return x.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"#326CE5","aria-hidden":"true",children:x.jsx("path",{d:"M10.204 14.35l.007.01-.999 2.413a5.171 5.171 0 0 1-2.075-2.597l2.578-.437.004.005a.44.44 0 0 1 .484.606zm-.833-2.129a.44.44 0 0 0 .173-.756l.002-.011L7.585 9.7a5.143 5.143 0 0 0-.73 3.255l2.514-.725.002-.009zm1.145-1.98a.44.44 0 0 0 .699-.337l.01-.005.15-2.62a5.144 5.144 0 0 0-3.01 1.442l2.147 1.523.004-.002zm.76 2.75l.723.349.722-.347.18-.78-.5-.623h-.804l-.5.623.179.779zm1.5-3.095a.44.44 0 0 0 .7.336l.008.003 2.134-1.513a5.188 5.188 0 0 0-2.992-1.442l.148 2.615.002.001zm10.876 5.97l-5.773 7.181a1.6 1.6 0 0 1-1.248.594l-9.261.003a1.6 1.6 0 0 1-1.247-.596l-5.776-7.18a1.583 1.583 0 0 1-.307-1.34L2.1 5.573c.108-.47.425-.864.863-1.073L11.305.513a1.606 1.606 0 0 1 1.385 0l8.345 3.985c.438.209.755.604.863 1.073l2.062 8.955c.108.47-.005.963-.308 1.34zm-3.289-2.057c-.042-.01-.103-.026-.145-.034-.174-.033-.315-.025-.479-.038-.35-.037-.638-.067-.895-.148-.105-.04-.18-.165-.216-.216l-.201-.059a6.45 6.45 0 0 0-.105-2.332 6.465 6.465 0 0 0-.936-2.163c.052-.047.15-.133.177-.159.008-.09.001-.183.094-.282.197-.185.444-.338.743-.522.142-.084.273-.137.415-.242.032-.024.076-.062.11-.089.24-.191.295-.52.123-.736-.172-.216-.506-.236-.745-.045-.034.027-.08.062-.111.088-.134.116-.217.23-.33.35-.246.25-.45.458-.673.609-.097.056-.239.037-.303.033l-.19.135a6.545 6.545 0 0 0-4.146-2.003l-.012-.223c-.065-.062-.143-.115-.163-.25-.022-.268.015-.557.057-.905.023-.163.061-.298.068-.475.001-.04-.001-.099-.001-.142 0-.306-.224-.555-.5-.555-.275 0-.499.249-.499.555l.001.014c0 .041-.002.092 0 .128.006.177.044.312.067.475.042.348.078.637.056.906a.545.545 0 0 1-.162.258l-.012.211a6.424 6.424 0 0 0-4.166 2.003 8.373 8.373 0 0 1-.18-.128c-.09.012-.18.04-.297-.029-.223-.15-.427-.358-.673-.608-.113-.12-.195-.234-.329-.349-.03-.026-.077-.062-.111-.088a.594.594 0 0 0-.348-.132.481.481 0 0 0-.398.176c-.172.216-.117.546.123.737l.007.005.104.083c.142.105.272.159.414.242.299.185.546.338.743.522.076.082.09.226.1.288l.16.143a6.462 6.462 0 0 0-1.02 4.506l-.208.06c-.055.072-.133.184-.215.217-.257.081-.546.11-.895.147-.164.014-.305.006-.48.039-.037.007-.09.02-.133.03l-.004.002-.007.002c-.295.071-.484.342-.423.608.061.267.349.429.645.365l.007-.001.01-.003.129-.029c.17-.046.294-.113.448-.172.33-.118.604-.217.87-.256.112-.009.23.069.288.101l.217-.037a6.5 6.5 0 0 0 2.88 3.596l-.09.218c.033.084.069.199.044.282-.097.252-.263.517-.452.813-.091.136-.185.242-.268.399-.02.037-.045.095-.064.134-.128.275-.034.591.213.71.248.12.556-.007.69-.282v-.002c.02-.039.046-.09.062-.127.07-.162.094-.301.144-.458.132-.332.205-.68.387-.897.05-.06.13-.082.215-.105l.113-.205a6.453 6.453 0 0 0 4.609.012l.106.192c.086.028.18.042.256.155.136.232.229.507.342.84.05.156.074.295.145.457.016.037.043.09.062.129.133.276.442.402.69.282.247-.118.341-.435.213-.71-.02-.039-.045-.096-.065-.134-.083-.156-.177-.261-.268-.398-.19-.296-.346-.541-.443-.793-.04-.13.007-.21.038-.294-.018-.022-.059-.144-.083-.202a6.499 6.499 0 0 0 2.88-3.622c.064.01.176.03.213.038.075-.05.144-.114.28-.104.266.039.54.138.87.256.154.06.277.128.448.173.036.01.088.019.13.028l.009.003.007.001c.297.064.584-.098.645-.365.06-.266-.128-.537-.423-.608zM16.4 9.701l-1.95 1.746v.005a.44.44 0 0 0 .173.757l.003.01 2.526.728a5.199 5.199 0 0 0-.108-1.674A5.208 5.208 0 0 0 16.4 9.7zm-4.013 5.325a.437.437 0 0 0-.404-.232.44.44 0 0 0-.372.233h-.002l-1.268 2.292a5.164 5.164 0 0 0 3.326.003l-1.27-2.296h-.01zm1.888-1.293a.44.44 0 0 0-.27.036.44.44 0 0 0-.214.572l-.003.004 1.01 2.438a5.15 5.15 0 0 0 2.081-2.615l-2.6-.44-.004.005z"})})}function zM({kind:e,size:t=16}){switch(e){case"modal_job":return x.jsx(BM,{size:t});case"hf_job":return x.jsx(jM,{size:t});case"k8s_job":return x.jsx(IM,{size:t});case"ssh_job":return x.jsx(vp,{size:t});default:return x.jsx(vp,{size:t})}}function HM({backend:e}){const t=jS(e),n=BS(e);return t?x.jsxs("span",{className:"backend-badge",children:[x.jsx(zM,{kind:t}),x.jsx("span",{className:"backend-name",children:OM(t)}),n&&x.jsx("span",{className:"backend-detail mono",children:n})]}):x.jsx("span",{className:"backend-badge muted",children:"—"})}const A1={done:{className:"st-done",live:!1},failed:{className:"st-failed",live:!1},running:{className:"st-running",live:!0},starting:{className:"st-starting",live:!0},cancelled:{className:"st-cancelled",live:!1},editing:{className:"st-editing",live:!0},idle:{className:"st-idle",live:!1}};function FM(e){return A1[e]??A1.idle}function Oo({status:e,label:t}){const n=FM(e);return x.jsxs("span",{className:`status-badge ${n.className}${n.live?" live":""}`,children:[x.jsx("span",{className:"dot"}),t??e]})}function Qd(e){return e.installed&&e.authenticated?{cls:"ok",label:"Connected"}:e.installed?{cls:"warn",label:"Not signed in"}:{cls:"warn",label:"Not installed"}}function PM({h:e}){return e.authMethod?x.jsx(x.Fragment,{children:e.authMethod==="oauth"?"OAuth (subscription login)":"API key"}):x.jsx(x.Fragment,{children:"—"})}function UM(){const[e,t]=X.useState(null),[n,r]=X.useState("claude-code"),[a,l]=X.useState(!1),c=u=>{l(!0),dg(u).then(t).catch(()=>{}).finally(()=>l(!1))};X.useEffect(()=>c(!1),[]);const o=e==null?void 0:e.find(u=>u.id===n);return x.jsxs(x.Fragment,{children:[x.jsx("h1",{children:"Harnesses"}),x.jsx("p",{className:"settings-sub",children:"Coding-agent setups detected on this machine. The research agent chat is served by OpenCode; Claude Code and Codex accounts surface their models in the composer's model picker."}),x.jsx("div",{className:"harness-tabs",children:(e??[]).map(u=>x.jsxs("button",{className:u.id===n?"active":"",onClick:()=>r(u.id),children:[u.name,x.jsx("span",{className:`harness-dot ${Qd(u).cls}`})]},u.id))}),e?o?x.jsxs("div",{className:"settings-card",children:[x.jsxs("div",{className:"settings-card-head",children:[x.jsx("span",{className:`badge ${Qd(o).cls}`,children:Qd(o).label}),x.jsx("div",{className:"spacer",style:{flex:1}}),x.jsxs("button",{className:"btn sm",onClick:()=>c(!0),disabled:a,children:[x.jsx(cu,{size:12,className:a?"spin":""})," Refresh"]})]}),x.jsxs("div",{className:"kv",children:[x.jsx("span",{className:"k",children:"Binary"}),x.jsx("span",{className:"v",children:o.binPath??"not found on PATH"}),x.jsx("span",{className:"k",children:"Version"}),x.jsx("span",{className:"v",children:o.version??"—"}),x.jsx("span",{className:"k",children:"Auth"}),x.jsx("span",{className:"v",children:x.jsx(PM,{h:o})}),o.account&&x.jsxs(x.Fragment,{children:[x.jsx("span",{className:"k",children:o.id==="opencode"?"Providers":"Account"}),x.jsx("span",{className:"v",children:o.account})]}),o.org&&x.jsxs(x.Fragment,{children:[x.jsx("span",{className:"k",children:"Org"}),x.jsx("span",{className:"v",children:o.org})]}),o.plan&&x.jsxs(x.Fragment,{children:[x.jsx("span",{className:"k",children:"Plan"}),x.jsx("span",{className:"v",children:o.plan})]}),x.jsx("span",{className:"k",children:"Agent models"}),x.jsx("span",{className:"v",children:o.models.length>0?`${o.models.length} available — ${o.models.slice(0,4).map(u=>uu(u.id)).join(", ")}${o.models.length>4?", …":""}`:"none"})]}),!o.agentReady&&o.agentNote&&x.jsx("p",{className:"settings-note",children:o.agentNote})]}):null:x.jsxs("div",{className:"settings-loading",children:[x.jsx("span",{className:"spinner"})," Detecting harnesses…"]})]})}function $M({s:e}){if(!e.configured)return x.jsx("span",{className:"badge",children:"not configured"});const t=e.preflight;return t.kubectlFound?t.reachable?t.canCreateJobs?x.jsx("span",{className:"badge ok",children:"connected"}):x.jsx("span",{className:"badge err",children:"no job-create permission"}):x.jsx("span",{className:"badge err",children:"cluster unreachable"}):x.jsx("span",{className:"badge err",children:"kubectl not found"})}function GM(){const[e,t]=X.useState(null),[n,r]=X.useState(null),[a,l]=X.useState(""),[c,o]=X.useState(""),[u,f]=X.useState(!1),[g,d]=X.useState(null),m=C=>{t(C),l(C.context??""),o(C.namespace)};X.useEffect(()=>{eT().then(m).catch(C=>r(C instanceof Error?C.message:String(C)))},[]);const b=e!==null&&a===(e.context??"")&&c.trim()===e.namespace;async function w(C){if(C.preventDefault(),!u){f(!0),d(null);try{m(await tT({context:a,namespace:c.trim()}))}catch(v){d(v instanceof Error?v.message:String(v))}finally{f(!1)}}}return x.jsxs(x.Fragment,{children:[x.jsxs("p",{className:"settings-sub",children:[x.jsx("strong",{children:"Kubernetes"})," — run on your own cluster with ",x.jsx("code",{children:"--backend k8s"}),". The run's resources (image, GPUs, topology) come from a manifest committed on the experiment branch (default ",x.jsx("code",{children:".orx/k8s.yaml"}),"); only the cluster context and namespace live here. Auth comes from your kubeconfig."]}),n?x.jsx("div",{className:"settings-card",children:x.jsx("div",{className:"error",children:n})}):e?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"settings-card",children:[x.jsxs("div",{className:"settings-card-head",children:[x.jsx("h3",{children:"Kubernetes cluster"}),x.jsx("div",{className:"spacer",style:{flex:1}}),x.jsx($M,{s:e})]}),e.preflight.error&&x.jsx("p",{className:"settings-note",children:e.preflight.error}),x.jsxs("form",{className:"form settings-form",onSubmit:w,children:[x.jsxs("div",{className:"row2",children:[x.jsxs("label",{children:["Context",x.jsxs("select",{value:a,onChange:C=>l(C.target.value),children:[x.jsxs("option",{value:"",children:["kubectl default",e.currentContext?` (${e.currentContext})`:""]}),e.contexts.map(C=>x.jsx("option",{value:C,children:C},C))]})]}),x.jsxs("label",{children:["Namespace",x.jsx("input",{className:"mono",type:"text",value:c,onChange:C=>o(C.target.value),placeholder:"default",autoComplete:"off",spellCheck:!1})]})]}),g&&x.jsx("div",{className:"error",children:g}),x.jsx("div",{className:"actions",children:x.jsx("button",{type:"submit",className:"btn primary",disabled:u||b,children:u?"Saving…":"Save"})})]})]}),x.jsxs("div",{className:"settings-card",children:[x.jsx("div",{className:"settings-card-head",children:x.jsx("h3",{children:"Run manifest"})}),x.jsxs("p",{className:"settings-sub",children:["Each run applies the manifest committed on its experiment branch — default"," ",x.jsx("code",{children:".orx/k8s.yaml"}),", or ",x.jsx("code",{children:"--manifest <path>"}),". It declares whatever the run needs (image, GPU requests, an Indexed Job across nodes, extra Services, …); orx injects the run script as ",x.jsx("code",{children:"$ORX_SCRIPT"}),", the"," ",x.jsx("code",{children:"orx-env"})," Secret, run labels, and a default timeout, and requires exactly one Job (or one labelled ",x.jsx("code",{children:'orx-primary: "true"'}),") whose completion is the run's. Logs follow that Job's leader pod. Use"," ",x.jsx("code",{children:"{{ORX_RUN}}"})," in resource names to keep re-runs collision-free."]})]})]}):x.jsxs("div",{className:"settings-loading",children:[x.jsx("span",{className:"spinner"})," Checking kubectl…"]})]})}const qM={env:"MODAL_TOKEN_ID env var",syncedEnv:"~/.openresearch/env",modalToml:"~/.modal.toml (modal token new)"};function VM({s:e}){return e.ready?x.jsx("span",{className:"badge ok",children:"connected"}):!e.tokenConfigured&&!e.modalImportable?x.jsx("span",{className:"badge",children:"not set up"}):e.modalImportable?e.tokenConfigured?x.jsx("span",{className:"badge",children:"unknown"}):x.jsx("span",{className:"badge err",children:"no token"}):x.jsx("span",{className:"badge err",children:e.envProvisioned?"env broken":"env not built"})}function YM(){const[e,t]=X.useState(null),[n,r]=X.useState(null),[a,l]=X.useState(!1),[c,o]=X.useState(null);X.useEffect(()=>{nT().then(t).catch(f=>r(f instanceof Error?f.message:String(f)))},[]);async function u(){if(!a){l(!0),o(null);try{t(await iT())}catch(f){o(f instanceof Error?f.message:String(f))}finally{l(!1)}}}return x.jsxs("div",{className:"settings-card",children:[x.jsxs("div",{className:"settings-card-head",children:[x.jsx("h3",{children:"Modal"}),x.jsx("div",{className:"spacer",style:{flex:1}}),e&&x.jsx(VM,{s:e})]}),x.jsxs("p",{className:"settings-sub",children:["Serverless GPUs on your own Modal account with"," ",x.jsx("code",{children:"--backend modal --flavor <name>"})," (t4, a10g, a100-80gb, h100, …). orx manages a dedicated Python env with the Modal SDK; sandboxes scale to zero between runs."]}),n?x.jsx("div",{className:"error",children:n}):e?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"kv",children:[x.jsx("span",{className:"k",children:"Environment"}),x.jsx("span",{className:"v",children:e.modalImportable?"ready":e.envProvisioned?"provisioned (modal import failing)":"not built yet"}),x.jsx("span",{className:"k",children:"Token"}),x.jsx("span",{className:"v",children:e.tokenSource?qM[e.tokenSource]:"not configured"})]}),!e.tokenConfigured&&x.jsxs("p",{className:"settings-note",children:["No Modal token found. Run ",x.jsx("code",{children:"modal token new"}),", or add"," ",x.jsx("code",{children:"MODAL_TOKEN_ID"})," and ",x.jsx("code",{children:"MODAL_TOKEN_SECRET"})," in the Environment tab."]}),e.error&&e.envProvisioned&&!e.modalImportable&&x.jsx("p",{className:"settings-note",children:e.error}),c&&x.jsx("div",{className:"error",children:c}),!e.modalImportable&&x.jsx("div",{className:"actions",children:x.jsx("button",{className:"btn primary",onClick:()=>void u(),disabled:a,children:a?"Setting up… (~30–60s)":"Set up environment"})})]}):x.jsxs("div",{className:"settings-loading",children:[x.jsx("span",{className:"spinner"})," Checking Modal…"]})]})}function WM({test:e}){if(e===void 0)return x.jsx("span",{className:"muted",children:"never tested"});if(e==="testing")return x.jsx("span",{className:"spinner"});const t=e.reachable?e.gitFound?x.jsx("span",{className:"badge ok",children:"ready"}):x.jsx("span",{className:"badge err",children:"no git"}):x.jsx("span",{className:"badge err",title:e.error??void 0,children:"unreachable"});return x.jsxs(x.Fragment,{children:[t,x.jsx("span",{className:"ssh-tested-at",children:ua(e.testedAt)})]})}function XM(){const[e,t]=X.useState(null),[n,r]=X.useState({});X.useEffect(()=>{aT().then(t).catch(()=>t([]))},[]);async function a(l){r(c=>({...c,[l]:"testing"}));try{const c=await oT(l);r(o=>({...o,[l]:c}))}catch(c){r(o=>({...o,[l]:{reachable:!1,gitFound:!1,error:c instanceof Error?c.message:String(c),testedAt:Date.now()}}))}}return x.jsxs("div",{className:"settings-card",children:[x.jsx("h3",{children:"SSH hosts"}),x.jsxs("p",{className:"settings-sub",children:["Run experiments directly on your own boxes with"," ",x.jsx("code",{children:"--backend ssh --host <alias>"}),". Hosts come from"," ",x.jsx("code",{children:"~/.ssh/config"}),"; auth uses your keys/agent (orx never reads a key). The host just needs ",x.jsx("code",{children:"git"})," and ",x.jsx("code",{children:"bash"}),"."]}),e===null?x.jsxs("div",{className:"settings-loading",children:[x.jsx("span",{className:"spinner"})," Reading ~/.ssh/config…"]}):e.length===0?x.jsx("p",{className:"settings-empty",children:"No hosts found in ~/.ssh/config."}):x.jsxs("table",{className:"flavor-table ssh-table",children:[x.jsx("thead",{children:x.jsxs("tr",{children:[x.jsx("th",{children:"Host"}),x.jsx("th",{children:"Address"}),x.jsx("th",{children:"Identity"}),x.jsx("th",{children:"Status"}),x.jsx("th",{})]})}),x.jsx("tbody",{children:e.map(l=>x.jsxs("tr",{children:[x.jsx("td",{className:"mono",children:l.host}),x.jsxs("td",{className:"mono muted",children:[[l.user,l.hostname??"—"].filter(Boolean).join("@"),l.port?`:${l.port}`:""]}),x.jsx("td",{className:"mono muted",children:l.identityFile??"—"}),x.jsx("td",{children:x.jsx(WM,{test:n[l.host]??l.lastTest})}),x.jsx("td",{children:x.jsx("button",{className:"btn sm",onClick:()=>void a(l.host),disabled:n[l.host]==="testing",children:"Test"})})]},l.host))})]})]})}const KM=[{id:"hf",label:"HF Jobs"},{id:"modal",label:"Modal"},{id:"k8s",label:"Kubernetes"},{id:"ssh",label:"SSH"}];function ZM(){const[e,t]=X.useState("hf");return x.jsxs(x.Fragment,{children:[x.jsx("h1",{children:"Compute"}),x.jsxs("p",{className:"settings-sub",children:["Run experiments on external compute with"," ",x.jsx("code",{children:"--backend <name> --flavor <name>"}),"."]}),x.jsx("div",{className:"harness-tabs",children:KM.map(n=>x.jsx("button",{className:n.id===e?"active":"",onClick:()=>t(n.id),children:n.label},n.id))}),e==="hf"&&x.jsx(tL,{}),e==="modal"&&x.jsx(YM,{}),e==="k8s"&&x.jsx(GM,{}),e==="ssh"&&x.jsx(XM,{})]})}const QM={env:"HF_TOKEN env var",openresearchEnv:"~/.openresearch/env",hfCache:"~/.cache/huggingface/token (hf auth login)"};function JM({settings:e}){return e.configured?e.valid?x.jsx("span",{className:"badge ok",children:"connected"}):x.jsx("span",{className:"badge err",children:"invalid token"}):x.jsx("span",{className:"badge",children:"not configured"})}function eL({settings:e}){return!e.configured||!e.valid?null:e.jobsWrite===!0?x.jsx("span",{className:"badge ok",children:"jobs: write OK"}):e.jobsWrite===!1?x.jsx("span",{className:"badge err",children:"no job.write permission"}):x.jsx("span",{className:"badge",children:"jobs permission unknown"})}function tL(){const[e,t]=X.useState(null),[n,r]=X.useState(null),[a,l]=X.useState(""),[c,o]=X.useState(!1),[u,f]=X.useState(null),g=X.useRef(!1);X.useEffect(()=>{QA().then(m=>{g.current||t(m)}).catch(m=>{g.current||r(m instanceof Error?m.message:String(m))})},[]);async function d(m){if(m.preventDefault(),!(!a.trim()||c)){o(!0),f(null);try{const b=await JA(a.trim());g.current=!0,t(b),r(null),l("")}catch(b){f(b instanceof Error?b.message:String(b))}finally{o(!1)}}}return x.jsxs("div",{className:"settings-card",children:[x.jsxs("div",{className:"settings-card-head",children:[x.jsx("h3",{children:"Hugging Face Jobs"}),x.jsx("div",{className:"spacer",style:{flex:1}}),e&&x.jsx(JM,{settings:e})]}),x.jsxs("p",{className:"settings-sub",children:["Run experiments on your Hugging Face account with"," ",x.jsx("code",{children:"--backend hf --flavor <name>"})," (t4-small, a10g-small, a100-large, …). Billed to HF per minute."]}),n?x.jsx("div",{className:"error",children:n}):e?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"kv",children:[x.jsx("span",{className:"k",children:"Account"}),x.jsx("span",{className:"v",children:e.username??"—"}),x.jsx("span",{className:"k",children:"Token"}),x.jsx("span",{className:"v",children:e.maskedToken??"—"}),x.jsx("span",{className:"k",children:"Source"}),x.jsx("span",{className:"v",children:e.source?QM[e.source]:"not configured"}),x.jsx("span",{className:"k",children:"Jobs"}),x.jsxs("span",{className:"v",children:[x.jsx(eL,{settings:e}),(!e.configured||!e.valid)&&"—"]})]}),e.source==="env"&&x.jsx("p",{className:"settings-note",children:"HF_TOKEN is set in the environment and overrides any token saved here."}),e.valid&&e.jobsWrite===null&&x.jsxs("p",{className:"settings-note",children:["This token is valid but doesn't report whether it can launch Jobs — OAuth tokens from ",x.jsx("code",{children:"hf auth login"})," never do. Launches may still work; for a definitive check, save a write-scoped token from"," ",x.jsx("a",{href:"https://huggingface.co/settings/tokens",target:"_blank",rel:"noreferrer",children:"huggingface.co/settings/tokens"}),"."]})]}):x.jsxs("div",{className:"settings-loading",children:[x.jsx("span",{className:"spinner"})," Loading status…"]}),x.jsxs("form",{className:"form settings-form",onSubmit:d,children:[x.jsxs("label",{children:[e!=null&&e.configured?"Replace token":"New token",x.jsx("input",{type:"password",value:a,onChange:m=>l(m.target.value),placeholder:"hf_…",autoComplete:"off"})]}),u&&x.jsx("div",{className:"error",children:u}),x.jsx("div",{className:"actions",children:x.jsx("button",{type:"submit",className:"btn primary",disabled:!a.trim()||c,children:c?"Validating…":"Save"})})]})]})}const tw=/^hf_[A-Za-z0-9]{10,}$/;function nw(){return x.jsx("tr",{children:x.jsx("td",{colSpan:3,children:x.jsxs("p",{className:"settings-note",children:["This value looks like a Hugging Face token — compute runs only read it from"," ",x.jsx("code",{children:"HF_TOKEN"}),". Save it under that key if it's meant for HF Jobs."]})})})}const T1=["HF_TOKEN","WANDB_API_KEY"];function nL({name:e,entry:t,onVars:n,onError:r}){const[a,l]=X.useState(""),[c,o]=X.useState(!1),u=d=>r(`${e}: ${d instanceof Error?d.message:String(d)}`);async function f(){if(!(!a.trim()||c)){o(!0);try{n(await LS(e,a.trim())),l("")}catch(d){u(d)}finally{o(!1)}}}async function g(){if(!c){o(!0);try{n(await sT(e))}catch(d){u(d)}finally{o(!1)}}}return x.jsxs(x.Fragment,{children:[x.jsxs("tr",{children:[x.jsx("td",{className:"mono",children:e}),x.jsx("td",{className:"mono muted",children:t?x.jsxs(x.Fragment,{children:[t.maskedValue,t.inProcessEnv&&x.jsx("span",{className:"badge",children:"overridden by env"})]}):x.jsx("input",{className:"mono",type:"password",value:a,onChange:d=>l(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),f()),d.key==="Escape"&&!c&&l("")},placeholder:"value","aria-label":`Value for ${e}`,autoComplete:"new-password",disabled:c})}),x.jsx("td",{children:t?x.jsx("button",{className:"icon-btn",title:`Delete ${e}`,"aria-label":`Delete ${e}`,onClick:()=>void g(),disabled:c,children:x.jsx(Mu,{size:13})}):a.trim()&&x.jsx("button",{className:"btn sm",onClick:()=>void f(),disabled:c,children:c?"Saving…":"Save"})})]}),!t&&e!=="HF_TOKEN"&&tw.test(a.trim())&&x.jsx(nw,{})]})}function iL({onVars:e,onError:t,onDone:n}){const[r,a]=X.useState(""),[l,c]=X.useState(""),[o,u]=X.useState(!1);async function f(){if(!(!r.trim()||!l.trim()||o)){u(!0);try{e(await LS(r.trim(),l.trim())),n()}catch(d){t(`${r.trim()}: ${d instanceof Error?d.message:String(d)}`)}finally{u(!1)}}}const g=d=>{d.key==="Enter"&&(d.preventDefault(),f()),d.key==="Escape"&&!o&&n()};return x.jsxs(x.Fragment,{children:[x.jsxs("tr",{children:[x.jsx("td",{children:x.jsx("input",{autoFocus:!0,className:"mono",type:"text",value:r,onChange:d=>a(d.target.value),onKeyDown:g,placeholder:"MY_API_KEY","aria-label":"New variable key",autoComplete:"off",spellCheck:!1,disabled:o})}),x.jsx("td",{children:x.jsx("input",{className:"mono",type:"password",value:l,onChange:d=>c(d.target.value),onKeyDown:g,placeholder:"value","aria-label":"New variable value",autoComplete:"new-password",disabled:o})}),x.jsxs("td",{children:[x.jsx("button",{className:"btn sm",onClick:()=>void f(),disabled:o||!r.trim()||!l.trim(),children:o?"Saving…":"Save"}),x.jsx("button",{className:"icon-btn",title:"Cancel","aria-label":"Cancel new variable",onClick:n,disabled:o,children:x.jsx(No,{size:13})})]})]}),r.trim()!=="HF_TOKEN"&&tw.test(l.trim())&&x.jsx(nw,{})]})}function rL(){const[e,t]=X.useState(null),[n,r]=X.useState(null),[a,l]=X.useState(!1),[c,o]=X.useState(null);X.useEffect(()=>{rT().then(t).catch(d=>r(d instanceof Error?d.message:String(d)))},[]);const u=d=>{t(d),o(null)},f=e===null?[]:e.map(d=>d.key).filter(d=>!T1.includes(d)),g=[...T1,...f];return x.jsxs("div",{className:"settings-card",children:[x.jsxs("div",{className:"settings-card-head",children:[x.jsx("h3",{children:"Environment variables"}),x.jsx("div",{className:"spacer",style:{flex:1}}),x.jsxs("button",{className:"btn sm",onClick:()=>l(!0),disabled:a||e===null,children:[x.jsx(fg,{size:12})," Add variable"]})]}),x.jsxs("p",{className:"settings-sub",children:["Stored in ",x.jsx("code",{children:"~/.openresearch/env"})," and passed to runs and the research agent."," ",x.jsx("code",{children:"HF_TOKEN"})," and ",x.jsx("code",{children:"WANDB_API_KEY"})," are always listed since runs typically need them. Variables set in orx's own environment win on conflicts."]}),n?x.jsx("div",{className:"error",children:n}):e===null?x.jsxs("div",{className:"settings-loading",children:[x.jsx("span",{className:"spinner"})," Loading…"]}):x.jsx("table",{className:"env-table",children:x.jsxs("tbody",{children:[g.map(d=>x.jsx(nL,{name:d,entry:e.find(m=>m.key===d),onVars:u,onError:o},d)),a&&x.jsx(iL,{onVars:u,onError:o,onDone:()=>l(!1)})]})}),c&&x.jsx("div",{className:"error",children:c})]})}function sL(){const[e,t]=X.useState(null),[n,r]=X.useState(""),[a,l]=X.useState(""),[c,o]=X.useState(!1),[u,f]=X.useState(null);X.useEffect(()=>{OS().then(m=>{t(m),r(m.userName??""),l(m.userEmail??"")}).catch(()=>{})},[]);const g=e!==null&&n.trim()===(e.userName??"")&&a.trim()===(e.userEmail??"");async function d(m){if(m.preventDefault(),!(c||g)){o(!0),f(null);try{const b=await uT({userName:n.trim(),userEmail:a.trim()});t(b),r(b.userName??""),l(b.userEmail??"")}catch(b){f(b instanceof Error?b.message:String(b))}finally{o(!1)}}}return x.jsxs(x.Fragment,{children:[x.jsx("h1",{children:"Git"}),x.jsx("p",{className:"settings-sub",children:"Experiment branches are committed and pushed from local clones with this identity."}),e?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"settings-card",children:[x.jsx("h3",{children:"Identity"}),x.jsxs("form",{className:"form",onSubmit:d,children:[x.jsxs("div",{className:"row2",children:[x.jsxs("label",{children:["user.name",x.jsx("input",{type:"text",value:n,onChange:m=>r(m.target.value),autoComplete:"off"})]}),x.jsxs("label",{children:["user.email",x.jsx("input",{type:"text",value:a,onChange:m=>l(m.target.value),autoComplete:"off"})]})]}),u&&x.jsx("div",{className:"error",children:u}),x.jsx("div",{className:"actions",children:x.jsx("button",{type:"submit",className:"btn primary",disabled:c||g||!n.trim()&&!a.trim(),children:c?"Saving…":"Save"})})]})]}),x.jsxs("div",{className:"settings-card",children:[x.jsx("h3",{children:"GitHub access"}),x.jsxs("div",{className:"kv",children:[x.jsx("span",{className:"k",children:"git"}),x.jsx("span",{className:"v",children:e.gitVersion??"not found"}),x.jsx("span",{className:"k",children:"Token"}),x.jsx("span",{className:"v",children:e.githubTokenSource==="env"?"GITHUB_TOKEN env var":e.githubTokenSource==="stored"?"token saved in orx":e.githubTokenSource==="gh"?"gh CLI (gh auth token)":"none found"})]}),!e.githubTokenSource&&x.jsxs(x.Fragment,{children:[x.jsxs("p",{className:"settings-note",children:["No GitHub token found — private repo clones and branch pushes will fail. Run"," ",x.jsx("code",{children:"gh auth login"}),", or paste a personal access token:"]}),x.jsx(ew,{onSaved:t})]}),e.githubTokenSource==="stored"&&x.jsx("div",{className:"actions",children:x.jsx("button",{className:"btn",onClick:()=>{fT().then(t).catch(()=>{})},children:"Remove saved token"})})]})]}):x.jsxs("div",{className:"settings-loading",children:[x.jsx("span",{className:"spinner"})," Loading…"]})]})}const Bp=e=>e==="running"||e==="starting";function aL(e){return Bp(e.status)?Ny(Date.now()-e.createdAt):e.endedAt?Ny(e.endedAt-e.createdAt):"—"}function N1({instances:e,emptyLabel:t}){return e.length===0?x.jsx("p",{className:"instances-empty",children:t}):x.jsx("div",{className:"instances-table-wrap",children:x.jsxs("table",{className:"runs-table",children:[x.jsx("thead",{children:x.jsxs("tr",{children:[x.jsx("th",{children:"Backend"}),x.jsx("th",{children:"Project"}),x.jsx("th",{children:"Status"}),x.jsx("th",{children:"Started"}),x.jsx("th",{children:"Runtime"})]})}),x.jsx("tbody",{children:e.map(n=>{var a;const r=typeof((a=n.backend)==null?void 0:a.url)=="string"?n.backend.url:void 0;return x.jsxs("tr",{children:[x.jsx("td",{children:x.jsxs("span",{className:"backend-cell",children:[x.jsx(HM,{backend:n.backend}),r&&x.jsx("a",{className:"icon-btn",href:r,target:"_blank",rel:"noreferrer",title:"Open job page","aria-label":"Open job page",onClick:l=>l.stopPropagation(),children:x.jsx(kS,{size:12})})]})}),x.jsx("td",{children:n.projectName??bp(n.projectId)}),x.jsx("td",{children:x.jsx(Oo,{status:n.status})}),x.jsx("td",{children:ua(n.createdAt)}),x.jsx("td",{className:"mono",children:aL(n)})]},n.id)})})]})})}function oL(){const[e,t]=X.useState(null),[n,r]=X.useState(null),[a,l]=X.useState(!1),[,c]=X.useState(0);X.useEffect(()=>{const d=setInterval(()=>c(m=>m+1),3e4);return()=>clearInterval(d)},[]);const o=()=>{l(!0),YA().then(d=>{t(d),r(null)}).catch(d=>{r(d instanceof Error?d.message:String(d)),t(m=>m??[])}).finally(()=>l(!1))};X.useEffect(()=>o(),[]);const u=(d,m)=>m.createdAt-d.createdAt,f=e==null?void 0:e.filter(d=>Bp(d.status)).sort(u),g=e==null?void 0:e.filter(d=>!Bp(d.status)).sort(u);return x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"settings-head-row",children:[x.jsx("h1",{children:"Instances"}),x.jsxs("button",{className:"btn sm",onClick:o,disabled:a,children:[x.jsx(cu,{size:12,className:a?"spin":""})," Refresh"]})]}),x.jsx("p",{className:"settings-sub",children:"Compute spun up across all projects — Modal, Hugging Face, SSH, and Kubernetes."}),n&&x.jsx("div",{className:"error",children:n}),!f||!g?x.jsxs("div",{className:"settings-loading",children:[x.jsx("span",{className:"spinner"})," Loading…"]}):x.jsxs(x.Fragment,{children:[x.jsxs("h2",{className:"instances-section-title",children:["Running",f.length>0&&x.jsx("span",{className:"count-badge",children:f.length})]}),x.jsx(N1,{instances:f,emptyLabel:"Nothing running right now."}),x.jsx("h2",{className:"instances-section-title",children:"Past"}),x.jsx(N1,{instances:g,emptyLabel:"No past instances yet."})]})]})}const lL=[{id:"harnesses",label:"Harnesses",icon:x.jsx(eA,{size:15})},{id:"compute",label:"Compute",icon:x.jsx(fA,{size:15})},{id:"instances",label:"Instances",icon:x.jsx(vp,{size:15})},{id:"environment",label:"Environment",icon:x.jsx(zA,{size:15})},{id:"git",label:"Git",icon:x.jsx(Ru,{size:15})}];function cL({tab:e}){return x.jsxs("div",{className:"settings-view",children:[e==="harnesses"&&x.jsx(UM,{}),e==="compute"&&x.jsx(ZM,{}),e==="environment"&&x.jsxs(x.Fragment,{children:[x.jsx("h1",{children:"Environment"}),x.jsx("p",{className:"settings-sub",children:"Variables available to runs and the research agent (API keys, tokens)."}),x.jsx(rL,{})]}),e==="instances"&&x.jsx(oL,{}),e==="git"&&x.jsx(sL,{})]})}function uL({skills:e,activeIndex:t,onPick:n,onHover:r}){return x.jsx("div",{className:"skill-menu",children:e.map((a,l)=>x.jsxs("button",{type:"button",className:`skill-item ${l===t?"active":""}`,onMouseDown:c=>{c.preventDefault(),n(a)},onMouseEnter:()=>r(l),children:[x.jsxs("span",{className:"skill-name",children:["/",a.name," ",x.jsx("span",{className:"skill-hint",children:a.argHint})]}),x.jsx("span",{className:"skill-desc",children:a.description})]},a.name))})}const D1={"claude-code":"Claude Code",codex:"Codex",opencode:"OpenCode"};function R1(e){var n,r,a;const t=e.find(l=>l.agentReady);return t?{harness:t.id,model:((n=t.models[0])==null?void 0:n.id)??null,permissionMode:((r=t.options)==null?void 0:r.defaultPermissionMode)??null,reasoningLevel:((a=t.options)==null?void 0:a.defaultReasoningLevel)??null}:null}function iw(){const[e,t]=X.useState(!1),n=X.useRef(null);return X.useEffect(()=>{if(!e)return;const r=a=>{var l;(l=n.current)!=null&&l.contains(a.target)||t(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e]),{open:e,setOpen:t,ref:n}}function hL({value:e,onSelect:t,onHarnesses:n,lockHarness:r=!1}){const[a,l]=X.useState([]),{open:c,setOpen:o,ref:u}=iw(),[f,g]=X.useState("");X.useEffect(()=>{dg().then(w=>{l(w),n==null||n(w)}).catch(()=>{})},[]);const d=X.useMemo(()=>{const w=f.trim().toLowerCase();return(r&&e?a.filter(v=>v.id===e.harness):a).map(v=>{let y=v.models;return w?y=y.filter(S=>S.id.toLowerCase().includes(w)):v.id==="opencode"&&(y=y.slice(0,6)),{harness:v,models:y,hidden:w?0:v.models.length-y.length}})},[a,f,r,e]),m=(w,C)=>{var y,S;const v=(e==null?void 0:e.harness)===w.id;t({harness:w.id,model:C,permissionMode:v?e.permissionMode:((y=w.options)==null?void 0:y.defaultPermissionMode)??null,reasoningLevel:v?e.reasoningLevel:((S=w.options)==null?void 0:S.defaultReasoningLevel)??null}),o(!1),g("")},b=e?e.model?uu(e.model):"Default model":"Model";return x.jsxs("div",{className:"model-picker",ref:u,children:[x.jsxs("button",{type:"button",className:"composer-pill",title:"Harness + model for this chat",onClick:()=>o(w=>!w),children:[b,x.jsx(Du,{size:12})]}),c&&x.jsxs("div",{className:"model-menu align-right",children:[x.jsx("input",{autoFocus:!0,type:"text",placeholder:"Search models…",value:f,onChange:w=>g(w.target.value)}),x.jsxs("div",{className:"model-menu-list",children:[d.map(({harness:w,models:C,hidden:v})=>x.jsxs("div",{children:[x.jsx("div",{className:"model-group",children:w.name}),w.agentReady?x.jsxs(x.Fragment,{children:[C.map(y=>x.jsxs("button",{className:"model-item",onClick:()=>m(w,y.id),children:[x.jsxs("span",{children:[uu(y.id),x.jsx("span",{className:"model-id",children:y.id})]}),(e==null?void 0:e.harness)===w.id&&(e==null?void 0:e.model)===y.id&&x.jsx(Ti,{size:13})]},y.id)),v>0&&x.jsxs("div",{className:"model-more",children:[v," more — search to find"]})]}):x.jsx("div",{className:"model-more",children:w.agentNote??"Not available"})]},w.id)),a.length===0&&x.jsx("div",{className:"model-more",children:"Detecting harnesses…"})]})]})]})}function M1({choices:e,value:t,defaultId:n,header:r,align:a="left",variant:l="pill",title:c,numbered:o=!1,onSelect:u}){var y,S;const{open:f,setOpen:g,ref:d}=iw();if(e.length===0)return null;const m=t??n??((y=e[0])==null?void 0:y.id)??null,b=e.find(_=>_.id===m),w=e.find(_=>_.id===n),C=(b==null?void 0:b.label)??((S=e[0])==null?void 0:S.label)??"",v=_=>{u(_),g(!1)};return x.jsxs("div",{className:"option-picker",ref:d,children:[x.jsxs("button",{type:"button",className:l==="pill"?"composer-pill":"composer-bare",title:c,onClick:()=>g(_=>!_),children:[C,x.jsx(Du,{size:12})]}),f&&x.jsxs("div",{className:`option-menu ${a==="right"?"align-right":""}`,children:[r&&x.jsx("div",{className:"model-group",children:r}),w&&x.jsxs(x.Fragment,{children:[x.jsxs("button",{className:"model-item",onClick:()=>v(w.id),children:[x.jsxs("span",{children:[w.label," ",x.jsx("span",{className:"option-default",children:"· Default"})]}),m===w.id&&x.jsx(Ti,{size:13})]}),x.jsx("div",{className:"option-sep"})]}),e.map((_,k)=>x.jsxs("button",{className:"model-item",onClick:()=>v(_.id),children:[x.jsx("span",{children:_.label}),m===_.id?x.jsx(Ti,{size:13}):o&&x.jsx("span",{className:"option-num",children:k+1})]},_.id))]})]})}const rw="orx:agent-selection";function fL(){try{const e=localStorage.getItem(rw);return e?JSON.parse(e):null}catch{return null}}const sw="local-";function dL(e,t){const n=e.findIndex(a=>a.id===t.id);if(n>=0){const a=e.slice();return a[n]=t,a}return[...t.role==="user"?e.filter(a=>!a.id.startsWith(sw)):e,t]}function pL(e,t){switch(t.type){case"reset":return{messagesBySession:{},busySessions:new Set};case"seed":return{...e,messagesBySession:{...e.messagesBySession,[t.sessionId]:t.messages}};case"upsertMessage":{const n=e.messagesBySession[t.sessionId]??[];return{...e,messagesBySession:{...e.messagesBySession,[t.sessionId]:dL(n,t.message)}}}case"optimisticUser":{const n=e.messagesBySession[t.sessionId]??[],r=t.text?[{id:"p0",type:"text",text:t.text}]:[];t.imageUrls.forEach((l,c)=>r.push({id:`img${c}`,type:"image",text:l}));const a={id:`${sw}${Date.now()}`,role:"user",parts:r,createdAt:Date.now()};return{...e,messagesBySession:{...e.messagesBySession,[t.sessionId]:[...n,a]}}}case"busy":{const n=new Set(e.busySessions);return t.busy?n.add(t.sessionId):n.delete(t.sessionId),{...e,busySessions:n}}case"seedBusy":return{...e,busySessions:new Set(t.sessions)}}}function gL({harnesses:e,selection:t}){if(e.length===0)return null;const n=t?e.find(r=>r.id===t.harness):void 0;return n?x.jsxs("p",{className:"chat-empty-hint",children:["Chatting with ",n.name,n.account?` as ${n.account}`:""," — detected automatically, switch in the model picker below."]}):x.jsx("p",{className:"chat-empty-hint",children:"No coding agent detected on this machine — install Claude Code, Codex or opencode and sign in, then re-open the model picker below."})}function aw(e){return e==="error"?"tool-status error":e==="completed"?"tool-status":"tool-status running"}function mL(e){if(!e)return"";const t=Math.max(0,Math.floor((Date.now()-e)/1e3));if(t<60)return"now";const n=Math.floor(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60);return r<24?`${r}h`:`${Math.floor(r/24)}d`}function L1(e){const t=e.replace(/\/+$/,"");return t.slice(t.lastIndexOf("/")+1)||t}function Ip(e){var c,o;const t=e.tool??"tool",n=((c=e.state)==null?void 0:c.input)??{},r=typeof n.command=="string"?n.command:null,a=typeof n.filePath=="string"?n.filePath:null,l=typeof n.description=="string"?n.description:null;switch(t){case"Bash":case"bash":return r?`Ran ${r}`:"Ran command";case"Read":return a?`Read ${L1(a)}`:"Read file";case"Edit":case"Write":case"NotebookEdit":return a?`Edited ${L1(a)}`:"Edited file";case"Grep":return typeof n.pattern=="string"?`Searched “${n.pattern}”`:"Searched";case"Glob":return typeof n.pattern=="string"?`Found ${n.pattern}`:"Listed files";case"WebFetch":case"WebSearch":return l??"Searched the web";case"Task":return l??"Ran a subagent";case"error":return"Error";default:{const u=l??a??r??((o=e.state)==null?void 0:o.title)??"";return u?`${t}: ${u}`:t}}}function _L({part:e,onOpenFile:t}){var o,u;const n=e.state,r=(n==null?void 0:n.error)||(n==null?void 0:n.output)||"",a=typeof((o=n==null?void 0:n.input)==null?void 0:o.command)=="string"?n.input.command:null,l=typeof((u=n==null?void 0:n.input)==null?void 0:u.filePath)=="string"?n.input.filePath:null,c=!!(r||a||l);return x.jsxs("details",{className:"tool-row",open:!1,children:[x.jsxs("summary",{children:[x.jsx("span",{className:aw(n==null?void 0:n.status)}),x.jsx("span",{className:"tool-line",children:Ip(e)}),l&&t&&x.jsx("button",{className:"tool-open file-link",title:`Open ${l}`,onClick:f=>{f.preventDefault(),f.stopPropagation(),t(l)},children:"open"})]}),c&&x.jsxs("div",{className:"tool-detail",children:[a&&x.jsx("div",{className:"tool-cmd-full",children:a}),r&&x.jsx("div",{className:"tool-output",children:r.slice(0,2e4)})]})]})}function vL({parts:e,onOpenFile:t}){const n=e.some(u=>{var f;return((f=u.state)==null?void 0:f.status)==="running"}),r=e.some(u=>{var f;return((f=u.state)==null?void 0:f.status)==="error"}),[a,l]=X.useState(!1),c=a||n,o=e.length===1?Ip(e[0]):n?Ip(e.find(u=>{var f;return((f=u.state)==null?void 0:f.status)==="running"})??e[e.length-1]):`Used ${e.length} tools`;return x.jsxs("div",{className:`tool-group ${r?"has-error":""}`,children:[x.jsxs("button",{className:"tool-group-summary",onClick:()=>l(u=>!u),children:[x.jsx("span",{className:aw(n?"running":r?"error":"completed")}),x.jsx("span",{className:"tool-line",children:o}),x.jsx(ug,{size:12,className:`tool-chevron ${c?"open":""}`})]}),c&&x.jsx("div",{className:"tool-group-rows",children:e.map(u=>x.jsx(_L,{part:u,onOpenFile:t},u.id))})]})}function yL({part:e,onRespond:t,onOpenFile:n}){var f,g;const r=e.prompt,[a,l]=X.useState([]),c=r.resolved||!t,o=d=>t==null?void 0:t({promptId:e.id,...d});if(r.kind==="plan")return x.jsxs("div",{className:`prompt-card plan ${c?"resolved":""}`,children:[x.jsx("div",{className:"prompt-head",children:"Proposed plan"}),x.jsx("div",{className:"prompt-plan",children:x.jsx(rm,{text:r.plan??"",onOpenFile:n})}),c?x.jsx("div",{className:"prompt-resolved",children:"Resolved"}):x.jsxs("div",{className:"prompt-actions",children:[x.jsx("button",{className:"btn-primary",onClick:()=>o({approve:!0,resumeMode:"auto"}),children:"Approve & run"}),x.jsx("button",{className:"btn-ghost",onClick:()=>o({approve:!0,resumeMode:"bypass"}),children:"Approve & bypass all"}),x.jsx("button",{className:"btn-ghost",onClick:()=>o({approve:!1}),children:"Keep planning"})]})]});if(r.kind==="permission"){const d=typeof((f=r.toolInput)==null?void 0:f.command)=="string"&&r.toolInput.command||typeof((g=r.toolInput)==null?void 0:g.filePath)=="string"&&r.toolInput.filePath||"";return x.jsxs("div",{className:`prompt-card permission ${c?"resolved":""}`,children:[x.jsxs("div",{className:"prompt-head",children:["Permission needed: ",x.jsx("code",{children:r.tool})]}),d&&x.jsx("div",{className:"prompt-sub",children:d}),c?x.jsx("div",{className:"prompt-resolved",children:"Resolved"}):x.jsxs("div",{className:"prompt-actions",children:[x.jsx("button",{className:"btn-primary",onClick:()=>o({approve:!0}),children:"Allow"}),x.jsx("button",{className:"btn-ghost",onClick:()=>o({approve:!1}),children:"Deny"})]})]})}const u=d=>l(m=>r.multiSelect?m.includes(d)?m.filter(b=>b!==d):[...m,d]:[d]);return x.jsxs("div",{className:`prompt-card question ${c?"resolved":""}`,children:[r.header&&x.jsx("div",{className:"prompt-head",children:r.header}),r.question&&x.jsx("div",{className:"prompt-q",children:r.question}),x.jsx("div",{className:"prompt-options",children:(r.options??[]).map(d=>{const m=a.includes(d.label);return x.jsxs("button",{className:`prompt-option ${m?"sel":""}`,disabled:c,onClick:()=>c?void 0:r.multiSelect?u(d.label):o({answers:[d.label]}),children:[x.jsx("span",{className:"prompt-option-label",children:d.label}),d.description&&x.jsx("span",{className:"prompt-option-desc",children:d.description})]},d.label)})}),r.multiSelect&&!c&&x.jsx("div",{className:"prompt-actions",children:x.jsx("button",{className:"btn-primary",disabled:a.length===0,onClick:()=>o({answers:a}),children:"Submit"})}),c&&x.jsx("div",{className:"prompt-resolved",children:"Resolved"})]})}function bL({message:e,onOpenFile:t,onRespond:n}){if(e.role==="user"){const c=e.parts.filter(u=>u.type==="text").map(u=>u.text??"").join(` -`),o=e.parts.filter(u=>u.type==="image"&&u.text).map(u=>u.text.startsWith("data:")?u.text:_T(u.text));return x.jsxs("div",{className:"msg-user",children:[c,o.length>0&&x.jsx("div",{className:"msg-images",children:o.map((u,f)=>x.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:x.jsx("img",{src:u,alt:"attachment"})},f))})]})}const r=[];let a=[];const l=()=>{a.length!==0&&(r.push(x.jsx(vL,{parts:a,onOpenFile:t},`tg-${a[0].id}`)),a=[])};for(const c of e.parts){if(c.type==="tool"){a.push(c);continue}l(),c.type==="text"&&c.text?r.push(x.jsx(rm,{text:c.text,onOpenFile:t},c.id)):c.type==="reasoning"&&c.text?r.push(x.jsxs("details",{className:"reasoning",children:[x.jsx("summary",{children:"thinking…"}),c.text]},c.id)):c.type==="prompt"&&c.prompt&&r.push(x.jsx(yL,{part:c,onRespond:n,onOpenFile:t},c.id))}return l(),x.jsx("div",{className:"msg-assistant",children:r})}function SL({projectId:e,railHeader:t,railOpen:n,onShowRail:r,mainView:a,onSelectMainView:l,panelOpen:c,onTogglePanel:o,onOpenFile:u,children:f}){var dt,Ht;const[g,d]=X.useState([]),[m,b]=X.useState(null),[w,C]=X.useState(""),[v,y]=X.useState([]),[S,_]=X.useReducer(pL,{messagesBySession:{},busySessions:new Set}),[k,D]=X.useState([]),[T,R]=X.useState(fL),[N,L]=X.useState({}),I=X.useRef(new Set),z=X.useRef(null),q=X.useRef(!0),P=X.useRef(null),[U,V]=X.useState([]),[G,W]=X.useState(0),[K,j]=X.useState(!1);X.useEffect(()=>{dT().then(V).catch(()=>{})},[]);const M=w.startsWith("/")&&!/\s/.test(w)?w.slice(1):null,O=M!==null&&!K?U.filter(me=>me.name.startsWith(M.toLowerCase())):[],$=O.length>0,F=Math.min(G,Math.max(0,O.length-1));X.useEffect(()=>W(0),[M]);function J(me){var Ee;C(`/${me.name} `),(Ee=P.current)==null||Ee.focus()}function re(me){for(const Ee of me){if(!/^image\/(png|jpeg|gif|webp)$/.test(Ee.type))continue;const De=new FileReader;De.onload=()=>{const ue=De.result;y(be=>[...be,{dataUrl:ue,mediaType:Ee.type}])},De.readAsDataURL(Ee)}}function le(me){const Ee=Array.from(me.clipboardData.items).filter(De=>De.kind==="file"&&De.type.startsWith("image/")).map(De=>De.getAsFile()).filter(De=>De!==null);Ee.length>0&&(me.preventDefault(),re(Ee))}const Z=g.find(me=>me.id===m),H=Z?{harness:Z.harness,model:N.model??Z.model,permissionMode:N.permissionMode??Z.permissionMode,reasoningLevel:N.reasoningLevel??Z.reasoningLevel}:T??R1(k),ee=H?k.find(me=>me.id===H.harness):void 0,te=ee==null?void 0:ee.options,de=me=>{Z?L({model:me.model,permissionMode:me.permissionMode,reasoningLevel:me.reasoningLevel}):(R(me),localStorage.setItem(rw,JSON.stringify(me)))},he=me=>{H&&de({...H,permissionMode:me})},ye=me=>{H&&de({...H,reasoningLevel:me})};X.useEffect(()=>{d([]),b(null),C(""),y([]),_({type:"reset"}),I.current=new Set,pT(e).then(me=>{d(me),b(Ee=>{var De;return Ee??((De=me[0])==null?void 0:De.id)??null}),_({type:"seedBusy",sessions:me.filter(Ee=>Ee.busy).map(Ee=>Ee.id)})}).catch(()=>{})},[e]),X.useEffect(()=>{!m||I.current.has(m)||(I.current.add(m),mT(m).then(me=>_({type:"seed",sessionId:m,messages:me})).catch(()=>I.current.delete(m)))},[m]),X.useEffect(()=>G4(me=>{switch(me.type){case"session":if(me.session.projectId!==e)return;d(Ee=>{const De=Ee.findIndex(be=>be.id===me.session.id);if(De<0)return[me.session,...Ee];const ue=Ee.slice();return ue[De]=me.session,ue});break;case"message":_({type:"upsertMessage",sessionId:me.sessionId,message:me.message});break;case"busy":_({type:"busy",sessionId:me.sessionId,busy:me.busy});break}}),[e]);const oe=m?S.messagesBySession[m]??[]:[],ve=m?S.busySessions.has(m):!1,we=Z;X.useEffect(()=>L({}),[m]),X.useEffect(()=>{const me=z.current;me&&q.current&&(me.scrollTop=me.scrollHeight)},[oe,ve]);async function Se(){const me=w.trim(),Ee=v;if(!me&&Ee.length===0||ve)return;const De=H;if(!De&&!m)return;C(""),y([]);let ue=m;try{if(!ue){const Re=await gT(e,De.harness,{model:De.model,permissionMode:De.permissionMode,reasoningLevel:De.reasoningLevel});I.current.add(Re.id),d(je=>[Re,...je]),b(Re.id),ue=Re.id}_({type:"optimisticUser",sessionId:ue,text:me,imageUrls:Ee.map(Re=>Re.dataUrl)}),_({type:"busy",sessionId:ue,busy:!0}),q.current=!0;const be=De?{model:De.model,permissionMode:De.permissionMode,reasoningLevel:De.reasoningLevel}:{};L({});const Ce=Ee.map(Re=>({mediaType:Re.mediaType,dataBase64:Re.dataUrl.slice(Re.dataUrl.indexOf(",")+1)}));await vT(ue,me,be,Ce.length?Ce:void 0)}catch{ue&&_({type:"busy",sessionId:ue,busy:!1})}}function $e(){m&&yT(m)}function Ve(me){m&&(_({type:"busy",sessionId:m,busy:!0}),bT(m,me).catch(()=>{m&&_({type:"busy",sessionId:m,busy:!1})}))}const it=x.jsxs("aside",{className:"session-rail floating-panel",children:[t,x.jsxs("nav",{className:"rail-nav",children:[x.jsxs("button",{className:"rail-nav-item",onClick:()=>{b(null),l("chat")},children:[x.jsx(fg,{size:15}),"New session"]}),x.jsxs("button",{className:`rail-nav-item ${a==="artifacts"?"active":""}`,onClick:()=>l("artifacts"),children:[x.jsx(RA,{size:15}),"Artifacts"]}),lL.map(me=>x.jsxs("button",{className:`rail-nav-item ${a===me.id?"active":""}`,onClick:()=>l(me.id),children:[me.icon,me.label]},me.id))]}),x.jsxs("div",{className:"rail-body",children:[x.jsx("div",{className:"rail-section-label",children:"Recents"}),g.map(me=>{var Ee;return x.jsxs("button",{className:`session-row ${me.id===m&&a==="chat"?"active":""}`,title:`${D1[me.harness]}${me.model?` · ${me.model}`:""}`,onClick:()=>{b(me.id),l("chat")},children:[x.jsx("span",{className:"session-dot",children:S.busySessions.has(me.id)&&x.jsx("span",{className:"busy-dot"})}),x.jsx("span",{className:"session-title",children:((Ee=me.title)==null?void 0:Ee.trim())||"Untitled"}),x.jsx("span",{className:"session-time",children:mL(me.updatedAt)})]},me.id)})]})]});return a!=="chat"?x.jsxs(x.Fragment,{children:[n&&it,x.jsxs("section",{className:"chat-pane",children:[!n&&x.jsx("div",{className:"chat-header",children:x.jsx("button",{className:"icon-btn",title:"Show sidebar","aria-label":"Show sidebar",onClick:r,children:x.jsx(_p,{size:15})})}),x.jsx("div",{className:"settings-view-scroll",children:f})]})]}):x.jsxs(x.Fragment,{children:[n&&it,x.jsxs("section",{className:"chat-pane",children:[x.jsxs("div",{className:"chat-header",children:[!n&&x.jsx("button",{className:"icon-btn",title:"Show sidebar","aria-label":"Show sidebar",onClick:r,children:x.jsx(_p,{size:15})}),x.jsx("div",{className:"title",title:we?((dt=we.title)==null?void 0:dt.trim())||"Untitled":"New session",children:we?((Ht=we.title)==null?void 0:Ht.trim())||"Untitled":"New session"}),x.jsx("button",{className:`icon-btn ${c?"active":""}`,title:"Experiments","aria-label":"Experiments",onClick:o,children:x.jsx(yA,{size:15})})]}),oe.length===0&&!ve?x.jsxs("div",{className:"chat-empty",children:[x.jsxs("h2",{children:["Open",x.jsx("span",{children:"Research"})]}),x.jsx("p",{children:"Ask the agent to explore your codebase, branch experiments, and launch runs."}),x.jsx(gL,{harnesses:k,selection:T??R1(k)})]}):x.jsx("div",{className:"chat-thread",ref:z,onScroll:me=>{const Ee=me.currentTarget;q.current=Ee.scrollHeight-Ee.scrollTop-Ee.clientHeight<60},children:x.jsxs("div",{className:"chat-thread-inner",children:[oe.map(me=>x.jsx(bL,{message:me,onOpenFile:u,onRespond:Ve},me.id)),ve&&x.jsxs("div",{className:"working",children:[x.jsx("span",{className:"spinner"})," Working…"]})]})}),x.jsx("div",{className:"composer",children:x.jsxs("div",{className:"composer-box",children:[$&&x.jsx(uL,{skills:O,activeIndex:F,onPick:J,onHover:W}),v.length>0&&x.jsx("div",{className:"composer-attachments",children:v.map((me,Ee)=>x.jsxs("div",{className:"attachment-thumb",children:[x.jsx("img",{src:me.dataUrl,alt:"pasted"}),x.jsx("button",{title:"Remove image","aria-label":"Remove image",onClick:()=>y(De=>De.filter((ue,be)=>be!==Ee)),children:x.jsx(No,{size:11})})]},Ee))}),x.jsx("textarea",{ref:P,value:w,placeholder:H?`Message ${D1[H.harness]}…`:"Ask the research agent… ( / for skills)",rows:2,onPaste:le,onDragOver:me=>{me.dataTransfer.types.includes("Files")&&me.preventDefault()},onDrop:me=>{me.dataTransfer.files.length!==0&&(me.preventDefault(),re(Array.from(me.dataTransfer.files)))},onChange:me=>{C(me.target.value),j(!1)},onKeyDown:me=>{if($){if(me.key==="ArrowDown"||me.key==="ArrowUp"){me.preventDefault();const Ee=me.key==="ArrowDown"?1:-1;W((F+Ee+O.length)%O.length);return}if(me.key==="Enter"||me.key==="Tab"){me.preventDefault(),J(O[F]);return}if(me.key==="Escape"){me.preventDefault(),j(!0);return}}me.key==="Enter"&&!me.shiftKey&&(me.preventDefault(),Se())}}),x.jsxs("div",{className:"composer-actions",children:[x.jsx(M1,{choices:(te==null?void 0:te.permissionModes)??[],value:(H==null?void 0:H.permissionMode)??null,defaultId:(te==null?void 0:te.defaultPermissionMode)??null,header:"Mode",align:"left",variant:"pill",numbered:!0,title:"Permission mode for this chat",onSelect:he}),x.jsx("div",{style:{flex:1}}),x.jsx(hL,{value:H,onSelect:de,onHarnesses:D,lockHarness:!!Z}),x.jsx(M1,{choices:(te==null?void 0:te.reasoningLevels)??[],value:(H==null?void 0:H.reasoningLevel)??null,defaultId:(te==null?void 0:te.defaultReasoningLevel)??null,header:"Reasoning",align:"right",variant:"bare",title:"Reasoning level for this chat",onSelect:ye}),ve?x.jsx("button",{className:"send-btn stop",title:"Stop","aria-label":"Stop",onClick:$e,children:x.jsx(No,{size:16})}):x.jsx("button",{className:"send-btn",title:"Send","aria-label":"Send",onClick:()=>void Se(),disabled:!w.trim()&&v.length===0,children:x.jsx(uA,{size:16})})]})]})})]})]})}function O1({active:e,label:t,icon:n,onSelect:r,onClose:a}){return x.jsxs("button",{className:`tab closable ${e?"active":""}`,onClick:r,title:t,children:[n,x.jsx("span",{className:"tab-label",children:t}),x.jsx("span",{role:"button",className:"tab-close",title:"Close tab",onClick:l=>{l.stopPropagation(),a()},children:x.jsx(No,{size:12})})]})}function j1(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,r)}return n}function nt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?j1(Object(n),!0).forEach((function(r){zp(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j1(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function zp(e,t,n){return(t=(function(r){var a=(function(l,c){if(typeof l!="object"||l===null)return l;var o=l[Symbol.toPrimitive];if(o!==void 0){var u=o.call(l,c);if(typeof u!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(l)})(r,"string");return typeof a=="symbol"?a:String(a)})(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gr(e,t){if(e==null)return{};var n,r,a=(function(c,o){if(c==null)return{};var u,f,g={},d=Object.keys(c);for(f=0;f<d.length;f++)u=d[f],o.indexOf(u)>=0||(g[u]=c[u]);return g})(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Xe(e,t){return lw(e)||(function(n,r){var a=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(a!=null){var l,c,o,u,f=[],g=!0,d=!1;try{if(o=(a=a.call(n)).next,r===0){if(Object(a)!==a)return;g=!1}else for(;!(g=(l=o.call(a)).done)&&(f.push(l.value),f.length!==r);g=!0);}catch(m){d=!0,c=m}finally{try{if(!g&&a.return!=null&&(u=a.return(),Object(u)!==u))return}finally{if(d)throw c}}return f}})(e,t)||$u(e,t)||uw()}function ow(e){return lw(e)||cw(e)||$u(e)||uw()}function xn(e){return(function(t){if(Array.isArray(t))return Hp(t)})(e)||cw(e)||$u(e)||(function(){throw new TypeError(`Invalid attempt to spread non-iterable instance. +`),o=e.parts.filter(u=>u.type==="image"&&u.text).map(u=>u.text.startsWith("data:")?u.text:_T(u.text));return x.jsxs("div",{className:"msg-user",children:[c,o.length>0&&x.jsx("div",{className:"msg-images",children:o.map((u,f)=>x.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:x.jsx("img",{src:u,alt:"attachment"})},f))})]})}const r=[];let a=[];const l=()=>{a.length!==0&&(r.push(x.jsx(vL,{parts:a,onOpenFile:t},`tg-${a[0].id}`)),a=[])};for(const c of e.parts){if(c.type==="tool"){a.push(c);continue}l(),c.type==="text"&&c.text?r.push(x.jsx(rm,{text:c.text,onOpenFile:t},c.id)):c.type==="reasoning"&&c.text?r.push(x.jsxs("details",{className:"reasoning",children:[x.jsx("summary",{children:"thinking…"}),c.text]},c.id)):c.type==="prompt"&&c.prompt&&r.push(x.jsx(yL,{part:c,onRespond:n,onOpenFile:t},c.id))}return l(),x.jsx("div",{className:"msg-assistant",children:r})}function SL({projectId:e,railHeader:t,railOpen:n,onShowRail:r,mainView:a,onSelectMainView:l,panelOpen:c,onTogglePanel:o,onOpenFile:u,children:f}){var dt,Ht;const[g,d]=X.useState([]),[m,b]=X.useState(null),[w,C]=X.useState(""),[v,y]=X.useState([]),[S,_]=X.useReducer(pL,{messagesBySession:{},busySessions:new Set}),[k,D]=X.useState([]),[T,R]=X.useState(fL),[N,L]=X.useState({}),I=X.useRef(new Set),z=X.useRef(null),q=X.useRef(!0),P=X.useRef(null),[U,V]=X.useState([]),[G,W]=X.useState(0),[K,j]=X.useState(!1);X.useEffect(()=>{dT().then(V).catch(()=>{})},[]);const M=w.startsWith("/")&&!/\s/.test(w)?w.slice(1):null,O=M!==null&&!K?U.filter(me=>me.name.startsWith(M.toLowerCase())):[],$=O.length>0,F=Math.min(G,Math.max(0,O.length-1));X.useEffect(()=>W(0),[M]);function J(me){var Ee;C(`/${me.name} `),(Ee=P.current)==null||Ee.focus()}function re(me){for(const Ee of me){if(!/^image\/(png|jpeg|gif|webp)$/.test(Ee.type))continue;const De=new FileReader;De.onload=()=>{const ue=De.result;y(be=>[...be,{dataUrl:ue,mediaType:Ee.type}])},De.readAsDataURL(Ee)}}function le(me){const Ee=Array.from(me.clipboardData.items).filter(De=>De.kind==="file"&&De.type.startsWith("image/")).map(De=>De.getAsFile()).filter(De=>De!==null);Ee.length>0&&(me.preventDefault(),re(Ee))}const Z=g.find(me=>me.id===m),H=Z?{harness:Z.harness,model:N.model??Z.model,permissionMode:N.permissionMode??Z.permissionMode,reasoningLevel:N.reasoningLevel??Z.reasoningLevel}:T??R1(k),ee=H?k.find(me=>me.id===H.harness):void 0,te=ee==null?void 0:ee.options,de=me=>{Z?L({model:me.model,permissionMode:me.permissionMode,reasoningLevel:me.reasoningLevel}):(R(me),localStorage.setItem(rw,JSON.stringify(me)))},he=me=>{H&&de({...H,permissionMode:me})},ye=me=>{H&&de({...H,reasoningLevel:me})};X.useEffect(()=>{d([]),b(null),C(""),y([]),_({type:"reset"}),I.current=new Set,pT(e).then(me=>{d(me),b(Ee=>{var De;return Ee??((De=me[0])==null?void 0:De.id)??null}),_({type:"seedBusy",sessions:me.filter(Ee=>Ee.busy).map(Ee=>Ee.id)})}).catch(()=>{})},[e]),X.useEffect(()=>{!m||I.current.has(m)||(I.current.add(m),mT(m).then(me=>_({type:"seed",sessionId:m,messages:me})).catch(()=>I.current.delete(m)))},[m]),X.useEffect(()=>G4(me=>{switch(me.type){case"session":if(me.session.projectId!==e)return;d(Ee=>{const De=Ee.findIndex(be=>be.id===me.session.id);if(De<0)return[me.session,...Ee];const ue=Ee.slice();return ue[De]=me.session,ue});break;case"message":_({type:"upsertMessage",sessionId:me.sessionId,message:me.message});break;case"busy":_({type:"busy",sessionId:me.sessionId,busy:me.busy});break}}),[e]);const oe=m?S.messagesBySession[m]??[]:[],ve=m?S.busySessions.has(m):!1,we=Z;X.useEffect(()=>L({}),[m]),X.useEffect(()=>{const me=z.current;me&&q.current&&(me.scrollTop=me.scrollHeight)},[oe,ve]);async function Se(){const me=w.trim(),Ee=v;if(!me&&Ee.length===0||ve)return;const De=H;if(!De&&!m)return;C(""),y([]);let ue=m;try{if(!ue){const Re=await gT(e,De.harness,{model:De.model,permissionMode:De.permissionMode,reasoningLevel:De.reasoningLevel});I.current.add(Re.id),d(je=>[Re,...je]),b(Re.id),ue=Re.id}_({type:"optimisticUser",sessionId:ue,text:me,imageUrls:Ee.map(Re=>Re.dataUrl)}),_({type:"busy",sessionId:ue,busy:!0}),q.current=!0;const be=De?{model:De.model,permissionMode:De.permissionMode,reasoningLevel:De.reasoningLevel}:{};L({});const Ce=Ee.map(Re=>({mediaType:Re.mediaType,dataBase64:Re.dataUrl.slice(Re.dataUrl.indexOf(",")+1)}));await vT(ue,me,be,Ce.length?Ce:void 0)}catch{ue&&_({type:"busy",sessionId:ue,busy:!1})}}function $e(){m&&yT(m)}function Ve(me){m&&(_({type:"busy",sessionId:m,busy:!0}),bT(m,me).catch(()=>{m&&_({type:"busy",sessionId:m,busy:!1})}))}const it=x.jsxs("aside",{className:"session-rail floating-panel",children:[t,x.jsxs("nav",{className:"rail-nav",children:[x.jsxs("button",{className:"rail-nav-item",onClick:()=>{b(null),l("chat")},children:[x.jsx(fg,{size:15}),"New session"]}),x.jsxs("button",{className:`rail-nav-item ${a==="artifacts"?"active":""}`,onClick:()=>l("artifacts"),children:[x.jsx(RA,{size:15}),"Artifacts"]}),lL.map(me=>x.jsxs("button",{className:`rail-nav-item ${a===me.id?"active":""}`,onClick:()=>l(me.id),children:[me.icon,me.label]},me.id))]}),x.jsxs("div",{className:"rail-body",children:[x.jsx("div",{className:"rail-section-label",children:"Recents"}),g.map(me=>{var Ee;return x.jsxs("button",{className:`session-row ${me.id===m&&a==="chat"?"active":""}`,title:`${D1[me.harness]}${me.model?` · ${me.model}`:""}`,onClick:()=>{b(me.id),l("chat")},children:[x.jsx("span",{className:"session-dot",children:S.busySessions.has(me.id)&&x.jsx("span",{className:"busy-dot"})}),x.jsx("span",{className:"session-title",children:((Ee=me.title)==null?void 0:Ee.trim())||"Untitled"}),x.jsx("span",{className:"session-time",children:mL(me.updatedAt)})]},me.id)})]})]});return a!=="chat"?x.jsxs(x.Fragment,{children:[n&&it,x.jsxs("section",{className:"chat-pane",children:[!n&&x.jsx("div",{className:"chat-header",children:x.jsx("button",{className:"icon-btn",title:"Show sidebar","aria-label":"Show sidebar",onClick:r,children:x.jsx(_p,{size:15})})}),x.jsx("div",{className:"settings-view-scroll",children:f})]})]}):x.jsxs(x.Fragment,{children:[n&&it,x.jsxs("section",{className:"chat-pane",children:[x.jsxs("div",{className:"chat-header",children:[!n&&x.jsx("button",{className:"icon-btn",title:"Show sidebar","aria-label":"Show sidebar",onClick:r,children:x.jsx(_p,{size:15})}),x.jsx("div",{className:"title",title:we?((dt=we.title)==null?void 0:dt.trim())||"Untitled":"New session",children:we?((Ht=we.title)==null?void 0:Ht.trim())||"Untitled":"New session"}),x.jsx("button",{className:`icon-btn ${c?"active":""}`,title:"Experiments","aria-label":"Experiments",onClick:o,children:x.jsx(yA,{size:15})})]}),oe.length===0&&!ve?x.jsxs("div",{className:"chat-empty",children:[x.jsxs("h2",{children:["Open",x.jsx("span",{children:"Research"})]}),x.jsx("p",{children:"Ask the agent to explore your codebase, create and run your baseline experiment, and branch variants off it."}),x.jsx(gL,{harnesses:k,selection:T??R1(k)})]}):x.jsx("div",{className:"chat-thread",ref:z,onScroll:me=>{const Ee=me.currentTarget;q.current=Ee.scrollHeight-Ee.scrollTop-Ee.clientHeight<60},children:x.jsxs("div",{className:"chat-thread-inner",children:[oe.map(me=>x.jsx(bL,{message:me,onOpenFile:u,onRespond:Ve},me.id)),ve&&x.jsxs("div",{className:"working",children:[x.jsx("span",{className:"spinner"})," Working…"]})]})}),x.jsx("div",{className:"composer",children:x.jsxs("div",{className:"composer-box",children:[$&&x.jsx(uL,{skills:O,activeIndex:F,onPick:J,onHover:W}),v.length>0&&x.jsx("div",{className:"composer-attachments",children:v.map((me,Ee)=>x.jsxs("div",{className:"attachment-thumb",children:[x.jsx("img",{src:me.dataUrl,alt:"pasted"}),x.jsx("button",{title:"Remove image","aria-label":"Remove image",onClick:()=>y(De=>De.filter((ue,be)=>be!==Ee)),children:x.jsx(No,{size:11})})]},Ee))}),x.jsx("textarea",{ref:P,value:w,placeholder:H?`Message ${D1[H.harness]}…`:"Ask the research agent… ( / for skills)",rows:2,onPaste:le,onDragOver:me=>{me.dataTransfer.types.includes("Files")&&me.preventDefault()},onDrop:me=>{me.dataTransfer.files.length!==0&&(me.preventDefault(),re(Array.from(me.dataTransfer.files)))},onChange:me=>{C(me.target.value),j(!1)},onKeyDown:me=>{if($){if(me.key==="ArrowDown"||me.key==="ArrowUp"){me.preventDefault();const Ee=me.key==="ArrowDown"?1:-1;W((F+Ee+O.length)%O.length);return}if(me.key==="Enter"||me.key==="Tab"){me.preventDefault(),J(O[F]);return}if(me.key==="Escape"){me.preventDefault(),j(!0);return}}me.key==="Enter"&&!me.shiftKey&&(me.preventDefault(),Se())}}),x.jsxs("div",{className:"composer-actions",children:[x.jsx(M1,{choices:(te==null?void 0:te.permissionModes)??[],value:(H==null?void 0:H.permissionMode)??null,defaultId:(te==null?void 0:te.defaultPermissionMode)??null,header:"Mode",align:"left",variant:"pill",numbered:!0,title:"Permission mode for this chat",onSelect:he}),x.jsx("div",{style:{flex:1}}),x.jsx(hL,{value:H,onSelect:de,onHarnesses:D,lockHarness:!!Z}),x.jsx(M1,{choices:(te==null?void 0:te.reasoningLevels)??[],value:(H==null?void 0:H.reasoningLevel)??null,defaultId:(te==null?void 0:te.defaultReasoningLevel)??null,header:"Reasoning",align:"right",variant:"bare",title:"Reasoning level for this chat",onSelect:ye}),ve?x.jsx("button",{className:"send-btn stop",title:"Stop","aria-label":"Stop",onClick:$e,children:x.jsx(No,{size:16})}):x.jsx("button",{className:"send-btn",title:"Send","aria-label":"Send",onClick:()=>void Se(),disabled:!w.trim()&&v.length===0,children:x.jsx(uA,{size:16})})]})]})})]})]})}function O1({active:e,label:t,icon:n,onSelect:r,onClose:a}){return x.jsxs("button",{className:`tab closable ${e?"active":""}`,onClick:r,title:t,children:[n,x.jsx("span",{className:"tab-label",children:t}),x.jsx("span",{role:"button",className:"tab-close",title:"Close tab",onClick:l=>{l.stopPropagation(),a()},children:x.jsx(No,{size:12})})]})}function j1(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,r)}return n}function nt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?j1(Object(n),!0).forEach((function(r){zp(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j1(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function zp(e,t,n){return(t=(function(r){var a=(function(l,c){if(typeof l!="object"||l===null)return l;var o=l[Symbol.toPrimitive];if(o!==void 0){var u=o.call(l,c);if(typeof u!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(l)})(r,"string");return typeof a=="symbol"?a:String(a)})(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gr(e,t){if(e==null)return{};var n,r,a=(function(c,o){if(c==null)return{};var u,f,g={},d=Object.keys(c);for(f=0;f<d.length;f++)u=d[f],o.indexOf(u)>=0||(g[u]=c[u]);return g})(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Xe(e,t){return lw(e)||(function(n,r){var a=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(a!=null){var l,c,o,u,f=[],g=!0,d=!1;try{if(o=(a=a.call(n)).next,r===0){if(Object(a)!==a)return;g=!1}else for(;!(g=(l=o.call(a)).done)&&(f.push(l.value),f.length!==r);g=!0);}catch(m){d=!0,c=m}finally{try{if(!g&&a.return!=null&&(u=a.return(),Object(u)!==u))return}finally{if(d)throw c}}return f}})(e,t)||$u(e,t)||uw()}function ow(e){return lw(e)||cw(e)||$u(e)||uw()}function xn(e){return(function(t){if(Array.isArray(t))return Hp(t)})(e)||cw(e)||$u(e)||(function(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)})()}function lw(e){if(Array.isArray(e))return e}function cw(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function $u(e,t){if(e){if(typeof e=="string")return Hp(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Hp(e,t):void 0}}function Hp(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function uw(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function sm(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=$u(e))||t){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(u){throw u},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var l,c=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var u=n.next();return c=u.done,u},e:function(u){o=!0,l=u},f:function(){try{c||n.return==null||n.return()}finally{if(o)throw l}}}}var jc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function tl(e,t){return e(t={exports:{}},t.exports),t.exports}var bn=tl((function(e){/*! @@ -306,7 +306,7 @@ WARNING: This link could potentially be dangerous`)){const y=window.open();if(y) `:` `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(N){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),y.isLinux&&N&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(N){const L=this._getMouseBufferCoords(N),I=this._model.finalSelectionStart,z=this._model.finalSelectionEnd;return!!(I&&z&&L)&&this._areCoordsInSelection(L,I,z)}isCellInSelection(N,L){const I=this._model.finalSelectionStart,z=this._model.finalSelectionEnd;return!(!I||!z)&&this._areCoordsInSelection([N,L],I,z)}_areCoordsInSelection(N,L,I){return N[1]>L[1]&&N[1]<I[1]||L[1]===I[1]&&N[1]===L[1]&&N[0]>=L[0]&&N[0]<I[0]||L[1]<I[1]&&N[1]===I[1]&&N[0]<I[0]||L[1]<I[1]&&N[1]===L[1]&&N[0]>=L[0]}_selectWordAtCursor(N,L){var q,P;const I=(P=(q=this._linkifier.currentLink)==null?void 0:q.link)==null?void 0:P.range;if(I)return this._model.selectionStart=[I.start.x-1,I.start.y-1],this._model.selectionStartLength=(0,S.getRangeLength)(I,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const z=this._getMouseBufferCoords(N);return!!z&&(this._selectWordAt(z,L),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(N,L){this._model.clearSelection(),N=Math.max(N,0),L=Math.min(L,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,N],this._model.selectionEnd=[this._bufferService.cols,L],this.refresh(),this._onSelectionChange.fire()}_handleTrim(N){this._model.handleTrim(N)&&this.refresh()}_getMouseBufferCoords(N){const L=this._mouseService.getCoords(N,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(L)return L[0]--,L[1]--,L[1]+=this._bufferService.buffer.ydisp,L}_getMouseEventScrollAmount(N){let L=(0,d.getCoordsRelativeToElement)(this._coreBrowserService.window,N,this._screenElement)[1];const I=this._renderService.dimensions.css.canvas.height;return L>=0&&L<=I?0:(L>I&&(L-=I),L=Math.min(Math.max(L,-50),50),L/=50,L/Math.abs(L)+Math.round(14*L))}shouldForceSelection(N){return y.isMac?N.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:N.shiftKey}handleMouseDown(N){if(this._mouseDownTimeStamp=N.timeStamp,(N.button!==2||!this.hasSelection)&&N.button===0){if(!this._enabled){if(!this.shouldForceSelection(N))return;N.stopPropagation()}N.preventDefault(),this._dragScrollAmount=0,this._enabled&&N.shiftKey?this._handleIncrementalClick(N):N.detail===1?this._handleSingleClick(N):N.detail===2?this._handleDoubleClick(N):N.detail===3&&this._handleTripleClick(N),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(N){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(N))}_handleSingleClick(N){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(N)?3:0,this._model.selectionStart=this._getMouseBufferCoords(N),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const L=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);L&&L.length!==this._model.selectionStart[0]&&L.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(N){this._selectWordAtCursor(N,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(N){const L=this._getMouseBufferCoords(N);L&&(this._activeSelectionMode=2,this._selectLineAt(L[1]))}shouldColumnSelect(N){return N.altKey&&!(y.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(N){if(N.stopImmediatePropagation(),!this._model.selectionStart)return;const L=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(N),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(N),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const I=this._bufferService.buffer;if(this._model.selectionEnd[1]<I.lines.length){const z=I.lines.get(this._model.selectionEnd[1]);z&&z.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}L&&L[0]===this._model.selectionEnd[0]&&L[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const N=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(N.ydisp+this._bufferService.rows,N.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=N.ydisp),this.refresh()}}_handleMouseUp(N){const L=N.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&L<500&&N.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const I=this._mouseService.getCoords(N,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(I&&I[0]!==void 0&&I[1]!==void 0){const z=(0,m.moveToCellSequence)(I[0]-1,I[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(z,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const N=this._model.finalSelectionStart,L=this._model.finalSelectionEnd,I=!(!N||!L||N[0]===L[0]&&N[1]===L[1]);I?N&&L&&(this._oldSelectionStart&&this._oldSelectionEnd&&N[0]===this._oldSelectionStart[0]&&N[1]===this._oldSelectionStart[1]&&L[0]===this._oldSelectionEnd[0]&&L[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(N,L,I)):this._oldHasSelection&&this._fireOnSelectionChange(N,L,I)}_fireOnSelectionChange(N,L,I){this._oldSelectionStart=N,this._oldSelectionEnd=L,this._oldHasSelection=I,this._onSelectionChange.fire()}_handleBufferActivate(N){this.clearSelection(),this._trimListener.dispose(),this._trimListener=N.activeBuffer.lines.onTrim((L=>this._handleTrim(L)))}_convertViewportColToCharacterIndex(N,L){let I=L;for(let z=0;L>=z;z++){const q=N.loadCell(z,this._workCell).getChars().length;this._workCell.getWidth()===0?I--:q>1&&L!==z&&(I+=q-1)}return I}setSelection(N,L,I){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[N,L],this._model.selectionStartLength=I,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(N){this._isClickInSelection(N)||(this._selectWordAtCursor(N,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(N,L,I=!0,z=!0){if(N[0]>=this._bufferService.cols)return;const q=this._bufferService.buffer,P=q.lines.get(N[1]);if(!P)return;const U=q.translateBufferLineToString(N[1],!1);let V=this._convertViewportColToCharacterIndex(P,N[0]),G=V;const W=N[0]-V;let K=0,j=0,M=0,O=0;if(U.charAt(V)===" "){for(;V>0&&U.charAt(V-1)===" ";)V--;for(;G<U.length&&U.charAt(G+1)===" ";)G++}else{let J=N[0],re=N[0];P.getWidth(J)===0&&(K++,J--),P.getWidth(re)===2&&(j++,re++);const le=P.getString(re).length;for(le>1&&(O+=le-1,G+=le-1);J>0&&V>0&&!this._isCharWordSeparator(P.loadCell(J-1,this._workCell));){P.loadCell(J-1,this._workCell);const Z=this._workCell.getChars().length;this._workCell.getWidth()===0?(K++,J--):Z>1&&(M+=Z-1,V-=Z-1),V--,J--}for(;re<P.length&&G+1<U.length&&!this._isCharWordSeparator(P.loadCell(re+1,this._workCell));){P.loadCell(re+1,this._workCell);const Z=this._workCell.getChars().length;this._workCell.getWidth()===2?(j++,re++):Z>1&&(O+=Z-1,G+=Z-1),G++,re++}}G++;let $=V+W-K+M,F=Math.min(this._bufferService.cols,G-V+K+j-M-O);if(L||U.slice(V,G).trim()!==""){if(I&&$===0&&P.getCodePoint(0)!==32){const J=q.lines.get(N[1]-1);if(J&&P.isWrapped&&J.getCodePoint(this._bufferService.cols-1)!==32){const re=this._getWordAt([this._bufferService.cols-1,N[1]-1],!1,!0,!1);if(re){const le=this._bufferService.cols-re.start;$-=le,F+=le}}}if(z&&$+F===this._bufferService.cols&&P.getCodePoint(this._bufferService.cols-1)!==32){const J=q.lines.get(N[1]+1);if(J!=null&&J.isWrapped&&J.getCodePoint(0)!==32){const re=this._getWordAt([0,N[1]+1],!1,!1,!0);re&&(F+=re.length)}}return{start:$,length:F}}}_selectWordAt(N,L){const I=this._getWordAt(N,L);if(I){for(;I.start<0;)I.start+=this._bufferService.cols,N[1]--;this._model.selectionStart=[I.start,N[1]],this._model.selectionStartLength=I.length}}_selectToWordAt(N){const L=this._getWordAt(N,!0);if(L){let I=N[1];for(;L.start<0;)L.start+=this._bufferService.cols,I--;if(!this._model.areSelectionValuesReversed())for(;L.start+L.length>this._bufferService.cols;)L.length-=this._bufferService.cols,I++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?L.start:L.start+L.length,I]}}_isCharWordSeparator(N){return N.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(N.getChars())>=0}_selectLineAt(N){const L=this._bufferService.buffer.getWrappedRangeForLine(N),I={start:{x:0,y:L.first},end:{x:this._bufferService.cols-1,y:L.last}};this._model.selectionStart=[0,L.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,S.getRangeLength)(I,this._bufferService.cols)}};o.SelectionService=R=f([g(3,k.IBufferService),g(4,k.ICoreService),g(5,w.IMouseService),g(6,k.IOptionsService),g(7,w.IRenderService),g(8,w.ICoreBrowserService)],R)},4725:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ILinkProviderService=o.IThemeService=o.ICharacterJoinerService=o.ISelectionService=o.IRenderService=o.IMouseService=o.ICoreBrowserService=o.ICharSizeService=void 0;const f=u(8343);o.ICharSizeService=(0,f.createDecorator)("CharSizeService"),o.ICoreBrowserService=(0,f.createDecorator)("CoreBrowserService"),o.IMouseService=(0,f.createDecorator)("MouseService"),o.IRenderService=(0,f.createDecorator)("RenderService"),o.ISelectionService=(0,f.createDecorator)("SelectionService"),o.ICharacterJoinerService=(0,f.createDecorator)("CharacterJoinerService"),o.IThemeService=(0,f.createDecorator)("ThemeService"),o.ILinkProviderService=(0,f.createDecorator)("LinkProviderService")},6731:function(c,o,u){var f=this&&this.__decorate||function(R,N,L,I){var z,q=arguments.length,P=q<3?N:I===null?I=Object.getOwnPropertyDescriptor(N,L):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")P=Reflect.decorate(R,N,L,I);else for(var U=R.length-1;U>=0;U--)(z=R[U])&&(P=(q<3?z(P):q>3?z(N,L,P):z(N,L))||P);return q>3&&P&&Object.defineProperty(N,L,P),P},g=this&&this.__param||function(R,N){return function(L,I){N(L,I,R)}};Object.defineProperty(o,"__esModule",{value:!0}),o.ThemeService=o.DEFAULT_ANSI_COLORS=void 0;const d=u(7239),m=u(8055),b=u(8460),w=u(844),C=u(2585),v=m.css.toColor("#ffffff"),y=m.css.toColor("#000000"),S=m.css.toColor("#ffffff"),_=m.css.toColor("#000000"),k={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};o.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const R=[m.css.toColor("#2e3436"),m.css.toColor("#cc0000"),m.css.toColor("#4e9a06"),m.css.toColor("#c4a000"),m.css.toColor("#3465a4"),m.css.toColor("#75507b"),m.css.toColor("#06989a"),m.css.toColor("#d3d7cf"),m.css.toColor("#555753"),m.css.toColor("#ef2929"),m.css.toColor("#8ae234"),m.css.toColor("#fce94f"),m.css.toColor("#729fcf"),m.css.toColor("#ad7fa8"),m.css.toColor("#34e2e2"),m.css.toColor("#eeeeec")],N=[0,95,135,175,215,255];for(let L=0;L<216;L++){const I=N[L/36%6|0],z=N[L/6%6|0],q=N[L%6];R.push({css:m.channels.toCss(I,z,q),rgba:m.channels.toRgba(I,z,q)})}for(let L=0;L<24;L++){const I=8+10*L;R.push({css:m.channels.toCss(I,I,I),rgba:m.channels.toRgba(I,I,I)})}return R})());let D=o.ThemeService=class extends w.Disposable{get colors(){return this._colors}constructor(R){super(),this._optionsService=R,this._contrastCache=new d.ColorContrastCache,this._halfContrastCache=new d.ColorContrastCache,this._onChangeColors=this.register(new b.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:v,background:y,cursor:S,cursorAccent:_,selectionForeground:void 0,selectionBackgroundTransparent:k,selectionBackgroundOpaque:m.color.blend(y,k),selectionInactiveBackgroundTransparent:k,selectionInactiveBackgroundOpaque:m.color.blend(y,k),ansi:o.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(R={}){const N=this._colors;if(N.foreground=T(R.foreground,v),N.background=T(R.background,y),N.cursor=T(R.cursor,S),N.cursorAccent=T(R.cursorAccent,_),N.selectionBackgroundTransparent=T(R.selectionBackground,k),N.selectionBackgroundOpaque=m.color.blend(N.background,N.selectionBackgroundTransparent),N.selectionInactiveBackgroundTransparent=T(R.selectionInactiveBackground,N.selectionBackgroundTransparent),N.selectionInactiveBackgroundOpaque=m.color.blend(N.background,N.selectionInactiveBackgroundTransparent),N.selectionForeground=R.selectionForeground?T(R.selectionForeground,m.NULL_COLOR):void 0,N.selectionForeground===m.NULL_COLOR&&(N.selectionForeground=void 0),m.color.isOpaque(N.selectionBackgroundTransparent)&&(N.selectionBackgroundTransparent=m.color.opacity(N.selectionBackgroundTransparent,.3)),m.color.isOpaque(N.selectionInactiveBackgroundTransparent)&&(N.selectionInactiveBackgroundTransparent=m.color.opacity(N.selectionInactiveBackgroundTransparent,.3)),N.ansi=o.DEFAULT_ANSI_COLORS.slice(),N.ansi[0]=T(R.black,o.DEFAULT_ANSI_COLORS[0]),N.ansi[1]=T(R.red,o.DEFAULT_ANSI_COLORS[1]),N.ansi[2]=T(R.green,o.DEFAULT_ANSI_COLORS[2]),N.ansi[3]=T(R.yellow,o.DEFAULT_ANSI_COLORS[3]),N.ansi[4]=T(R.blue,o.DEFAULT_ANSI_COLORS[4]),N.ansi[5]=T(R.magenta,o.DEFAULT_ANSI_COLORS[5]),N.ansi[6]=T(R.cyan,o.DEFAULT_ANSI_COLORS[6]),N.ansi[7]=T(R.white,o.DEFAULT_ANSI_COLORS[7]),N.ansi[8]=T(R.brightBlack,o.DEFAULT_ANSI_COLORS[8]),N.ansi[9]=T(R.brightRed,o.DEFAULT_ANSI_COLORS[9]),N.ansi[10]=T(R.brightGreen,o.DEFAULT_ANSI_COLORS[10]),N.ansi[11]=T(R.brightYellow,o.DEFAULT_ANSI_COLORS[11]),N.ansi[12]=T(R.brightBlue,o.DEFAULT_ANSI_COLORS[12]),N.ansi[13]=T(R.brightMagenta,o.DEFAULT_ANSI_COLORS[13]),N.ansi[14]=T(R.brightCyan,o.DEFAULT_ANSI_COLORS[14]),N.ansi[15]=T(R.brightWhite,o.DEFAULT_ANSI_COLORS[15]),R.extendedAnsi){const L=Math.min(N.ansi.length-16,R.extendedAnsi.length);for(let I=0;I<L;I++)N.ansi[I+16]=T(R.extendedAnsi[I],o.DEFAULT_ANSI_COLORS[I+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(R){this._restoreColor(R),this._onChangeColors.fire(this.colors)}_restoreColor(R){if(R!==void 0)switch(R){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[R]=this._restoreColors.ansi[R]}else for(let N=0;N<this._restoreColors.ansi.length;++N)this._colors.ansi[N]=this._restoreColors.ansi[N]}modifyColors(R){R(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function T(R,N){if(R!==void 0)try{return m.css.toColor(R)}catch{}return N}o.ThemeService=D=f([g(0,C.IOptionsService)],D)},6349:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CircularList=void 0;const f=u(8460),g=u(844);class d extends g.Disposable{constructor(b){super(),this._maxLength=b,this.onDeleteEmitter=this.register(new f.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new f.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new f.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(b){if(this._maxLength===b)return;const w=new Array(b);for(let C=0;C<Math.min(b,this.length);C++)w[C]=this._array[this._getCyclicIndex(C)];this._array=w,this._maxLength=b,this._startIndex=0}get length(){return this._length}set length(b){if(b>this._length)for(let w=this._length;w<b;w++)this._array[w]=void 0;this._length=b}get(b){return this._array[this._getCyclicIndex(b)]}set(b,w){this._array[this._getCyclicIndex(b)]=w}push(b){this._array[this._getCyclicIndex(this._length)]=b,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(b,w,...C){if(w){for(let v=b;v<this._length-w;v++)this._array[this._getCyclicIndex(v)]=this._array[this._getCyclicIndex(v+w)];this._length-=w,this.onDeleteEmitter.fire({index:b,amount:w})}for(let v=this._length-1;v>=b;v--)this._array[this._getCyclicIndex(v+C.length)]=this._array[this._getCyclicIndex(v)];for(let v=0;v<C.length;v++)this._array[this._getCyclicIndex(b+v)]=C[v];if(C.length&&this.onInsertEmitter.fire({index:b,amount:C.length}),this._length+C.length>this._maxLength){const v=this._length+C.length-this._maxLength;this._startIndex+=v,this._length=this._maxLength,this.onTrimEmitter.fire(v)}else this._length+=C.length}trimStart(b){b>this._length&&(b=this._length),this._startIndex+=b,this._length-=b,this.onTrimEmitter.fire(b)}shiftElements(b,w,C){if(!(w<=0)){if(b<0||b>=this._length)throw new Error("start argument out of range");if(b+C<0)throw new Error("Cannot shift elements in list beyond index 0");if(C>0){for(let y=w-1;y>=0;y--)this.set(b+y+C,this.get(b+y));const v=b+w+C-this._length;if(v>0)for(this._length+=v;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let v=0;v<w;v++)this.set(b+v+C,this.get(b+v))}}_getCyclicIndex(b){return(this._startIndex+b)%this._maxLength}}o.CircularList=d},1439:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.clone=void 0,o.clone=function u(f,g=5){if(typeof f!="object")return f;const d=Array.isArray(f)?[]:{};for(const m in f)d[m]=g<=1?f[m]:f[m]&&u(f[m],g-1);return d}},8055:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.contrastRatio=o.toPaddedHex=o.rgba=o.rgb=o.css=o.color=o.channels=o.NULL_COLOR=void 0;let u=0,f=0,g=0,d=0;var m,b,w,C,v;function y(_){const k=_.toString(16);return k.length<2?"0"+k:k}function S(_,k){return _<k?(k+.05)/(_+.05):(_+.05)/(k+.05)}o.NULL_COLOR={css:"#00000000",rgba:0},(function(_){_.toCss=function(k,D,T,R){return R!==void 0?`#${y(k)}${y(D)}${y(T)}${y(R)}`:`#${y(k)}${y(D)}${y(T)}`},_.toRgba=function(k,D,T,R=255){return(k<<24|D<<16|T<<8|R)>>>0},_.toColor=function(k,D,T,R){return{css:_.toCss(k,D,T,R),rgba:_.toRgba(k,D,T,R)}}})(m||(o.channels=m={})),(function(_){function k(D,T){return d=Math.round(255*T),[u,f,g]=v.toChannels(D.rgba),{css:m.toCss(u,f,g,d),rgba:m.toRgba(u,f,g,d)}}_.blend=function(D,T){if(d=(255&T.rgba)/255,d===1)return{css:T.css,rgba:T.rgba};const R=T.rgba>>24&255,N=T.rgba>>16&255,L=T.rgba>>8&255,I=D.rgba>>24&255,z=D.rgba>>16&255,q=D.rgba>>8&255;return u=I+Math.round((R-I)*d),f=z+Math.round((N-z)*d),g=q+Math.round((L-q)*d),{css:m.toCss(u,f,g),rgba:m.toRgba(u,f,g)}},_.isOpaque=function(D){return(255&D.rgba)==255},_.ensureContrastRatio=function(D,T,R){const N=v.ensureContrastRatio(D.rgba,T.rgba,R);if(N)return m.toColor(N>>24&255,N>>16&255,N>>8&255)},_.opaque=function(D){const T=(255|D.rgba)>>>0;return[u,f,g]=v.toChannels(T),{css:m.toCss(u,f,g),rgba:T}},_.opacity=k,_.multiplyOpacity=function(D,T){return d=255&D.rgba,k(D,d*T/255)},_.toColorRGB=function(D){return[D.rgba>>24&255,D.rgba>>16&255,D.rgba>>8&255]}})(b||(o.color=b={})),(function(_){let k,D;try{const T=document.createElement("canvas");T.width=1,T.height=1;const R=T.getContext("2d",{willReadFrequently:!0});R&&(k=R,k.globalCompositeOperation="copy",D=k.createLinearGradient(0,0,1,1))}catch{}_.toColor=function(T){if(T.match(/#[\da-f]{3,8}/i))switch(T.length){case 4:return u=parseInt(T.slice(1,2).repeat(2),16),f=parseInt(T.slice(2,3).repeat(2),16),g=parseInt(T.slice(3,4).repeat(2),16),m.toColor(u,f,g);case 5:return u=parseInt(T.slice(1,2).repeat(2),16),f=parseInt(T.slice(2,3).repeat(2),16),g=parseInt(T.slice(3,4).repeat(2),16),d=parseInt(T.slice(4,5).repeat(2),16),m.toColor(u,f,g,d);case 7:return{css:T,rgba:(parseInt(T.slice(1),16)<<8|255)>>>0};case 9:return{css:T,rgba:parseInt(T.slice(1),16)>>>0}}const R=T.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(R)return u=parseInt(R[1]),f=parseInt(R[2]),g=parseInt(R[3]),d=Math.round(255*(R[5]===void 0?1:parseFloat(R[5]))),m.toColor(u,f,g,d);if(!k||!D)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=D,k.fillStyle=T,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[u,f,g,d]=k.getImageData(0,0,1,1).data,d!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:m.toRgba(u,f,g,d),css:T}}})(w||(o.css=w={})),(function(_){function k(D,T,R){const N=D/255,L=T/255,I=R/255;return .2126*(N<=.03928?N/12.92:Math.pow((N+.055)/1.055,2.4))+.7152*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.0722*(I<=.03928?I/12.92:Math.pow((I+.055)/1.055,2.4))}_.relativeLuminance=function(D){return k(D>>16&255,D>>8&255,255&D)},_.relativeLuminance2=k})(C||(o.rgb=C={})),(function(_){function k(T,R,N){const L=T>>24&255,I=T>>16&255,z=T>>8&255;let q=R>>24&255,P=R>>16&255,U=R>>8&255,V=S(C.relativeLuminance2(q,P,U),C.relativeLuminance2(L,I,z));for(;V<N&&(q>0||P>0||U>0);)q-=Math.max(0,Math.ceil(.1*q)),P-=Math.max(0,Math.ceil(.1*P)),U-=Math.max(0,Math.ceil(.1*U)),V=S(C.relativeLuminance2(q,P,U),C.relativeLuminance2(L,I,z));return(q<<24|P<<16|U<<8|255)>>>0}function D(T,R,N){const L=T>>24&255,I=T>>16&255,z=T>>8&255;let q=R>>24&255,P=R>>16&255,U=R>>8&255,V=S(C.relativeLuminance2(q,P,U),C.relativeLuminance2(L,I,z));for(;V<N&&(q<255||P<255||U<255);)q=Math.min(255,q+Math.ceil(.1*(255-q))),P=Math.min(255,P+Math.ceil(.1*(255-P))),U=Math.min(255,U+Math.ceil(.1*(255-U))),V=S(C.relativeLuminance2(q,P,U),C.relativeLuminance2(L,I,z));return(q<<24|P<<16|U<<8|255)>>>0}_.blend=function(T,R){if(d=(255&R)/255,d===1)return R;const N=R>>24&255,L=R>>16&255,I=R>>8&255,z=T>>24&255,q=T>>16&255,P=T>>8&255;return u=z+Math.round((N-z)*d),f=q+Math.round((L-q)*d),g=P+Math.round((I-P)*d),m.toRgba(u,f,g)},_.ensureContrastRatio=function(T,R,N){const L=C.relativeLuminance(T>>8),I=C.relativeLuminance(R>>8);if(S(L,I)<N){if(I<L){const P=k(T,R,N),U=S(L,C.relativeLuminance(P>>8));if(U<N){const V=D(T,R,N);return U>S(L,C.relativeLuminance(V>>8))?P:V}return P}const z=D(T,R,N),q=S(L,C.relativeLuminance(z>>8));if(q<N){const P=k(T,R,N);return q>S(L,C.relativeLuminance(P>>8))?z:P}return z}},_.reduceLuminance=k,_.increaseLuminance=D,_.toChannels=function(T){return[T>>24&255,T>>16&255,T>>8&255,255&T]}})(v||(o.rgba=v={})),o.toPaddedHex=y,o.contrastRatio=S},8969:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CoreTerminal=void 0;const f=u(844),g=u(2585),d=u(4348),m=u(7866),b=u(744),w=u(7302),C=u(6975),v=u(8460),y=u(1753),S=u(1480),_=u(7994),k=u(9282),D=u(5435),T=u(5981),R=u(2660);let N=!1;class L extends f.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new v.EventEmitter),this._onScroll.event((z=>{var q;(q=this._onScrollApi)==null||q.fire(z.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(z){for(const q in z)this.optionsService.options[q]=z[q]}constructor(z){super(),this._windowsWrappingHeuristics=this.register(new f.MutableDisposable),this._onBinary=this.register(new v.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new v.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new v.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new v.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new v.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new v.EventEmitter),this._instantiationService=new d.InstantiationService,this.optionsService=this.register(new w.OptionsService(z)),this._instantiationService.setService(g.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(b.BufferService)),this._instantiationService.setService(g.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(m.LogService)),this._instantiationService.setService(g.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(C.CoreService)),this._instantiationService.setService(g.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(y.CoreMouseService)),this._instantiationService.setService(g.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(S.UnicodeService)),this._instantiationService.setService(g.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(_.CharsetService),this._instantiationService.setService(g.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(R.OscLinkService),this._instantiationService.setService(g.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new D.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,v.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,v.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,v.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,v.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((q=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((q=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new T.WriteBuffer(((q,P)=>this._inputHandler.parse(q,P)))),this.register((0,v.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(z,q){this._writeBuffer.write(z,q)}writeSync(z,q){this._logService.logLevel<=g.LogLevelEnum.WARN&&!N&&(this._logService.warn("writeSync is unreliable and will be removed soon."),N=!0),this._writeBuffer.writeSync(z,q)}input(z,q=!0){this.coreService.triggerDataEvent(z,q)}resize(z,q){isNaN(z)||isNaN(q)||(z=Math.max(z,b.MINIMUM_COLS),q=Math.max(q,b.MINIMUM_ROWS),this._bufferService.resize(z,q))}scroll(z,q=!1){this._bufferService.scroll(z,q)}scrollLines(z,q,P){this._bufferService.scrollLines(z,q,P)}scrollPages(z){this.scrollLines(z*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(z){const q=z-this._bufferService.buffer.ydisp;q!==0&&this.scrollLines(q)}registerEscHandler(z,q){return this._inputHandler.registerEscHandler(z,q)}registerDcsHandler(z,q){return this._inputHandler.registerDcsHandler(z,q)}registerCsiHandler(z,q){return this._inputHandler.registerCsiHandler(z,q)}registerOscHandler(z,q){return this._inputHandler.registerOscHandler(z,q)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let z=!1;const q=this.optionsService.rawOptions.windowsPty;q&&q.buildNumber!==void 0&&q.buildNumber!==void 0?z=q.backend==="conpty"&&q.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(z=!0),z?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const z=[];z.push(this.onLineFeed(k.updateWindowsModeWrappedState.bind(null,this._bufferService))),z.push(this.registerCsiHandler({final:"H"},(()=>((0,k.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,f.toDisposable)((()=>{for(const q of z)q.dispose()}))}}}o.CoreTerminal=L},8460:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.runAndSubscribe=o.forwardEvent=o.EventEmitter=void 0,o.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=u=>(this._listeners.push(u),{dispose:()=>{if(!this._disposed){for(let f=0;f<this._listeners.length;f++)if(this._listeners[f]===u)return void this._listeners.splice(f,1)}}})),this._event}fire(u,f){const g=[];for(let d=0;d<this._listeners.length;d++)g.push(this._listeners[d]);for(let d=0;d<g.length;d++)g[d].call(void 0,u,f)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},o.forwardEvent=function(u,f){return u((g=>f.fire(g)))},o.runAndSubscribe=function(u,f){return f(void 0),u((g=>f(g)))}},5435:function(c,o,u){var f=this&&this.__decorate||function(K,j,M,O){var $,F=arguments.length,J=F<3?j:O===null?O=Object.getOwnPropertyDescriptor(j,M):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")J=Reflect.decorate(K,j,M,O);else for(var re=K.length-1;re>=0;re--)($=K[re])&&(J=(F<3?$(J):F>3?$(j,M,J):$(j,M))||J);return F>3&&J&&Object.defineProperty(j,M,J),J},g=this&&this.__param||function(K,j){return function(M,O){j(M,O,K)}};Object.defineProperty(o,"__esModule",{value:!0}),o.InputHandler=o.WindowsOptionsReportType=void 0;const d=u(2584),m=u(7116),b=u(2015),w=u(844),C=u(482),v=u(8437),y=u(8460),S=u(643),_=u(511),k=u(3734),D=u(2585),T=u(1480),R=u(6242),N=u(6351),L=u(5941),I={"(":0,")":1,"*":2,"+":3,"-":1,".":2},z=131072;function q(K,j){if(K>24)return j.setWinLines||!1;switch(K){case 1:return!!j.restoreWin;case 2:return!!j.minimizeWin;case 3:return!!j.setWinPosition;case 4:return!!j.setWinSizePixels;case 5:return!!j.raiseWin;case 6:return!!j.lowerWin;case 7:return!!j.refreshWin;case 8:return!!j.setWinSizeChars;case 9:return!!j.maximizeWin;case 10:return!!j.fullscreenWin;case 11:return!!j.getWinState;case 13:return!!j.getWinPosition;case 14:return!!j.getWinSizePixels;case 15:return!!j.getScreenSizePixels;case 16:return!!j.getCellSizePixels;case 18:return!!j.getWinSizeChars;case 19:return!!j.getScreenSizeChars;case 20:return!!j.getIconTitle;case 21:return!!j.getWinTitle;case 22:return!!j.pushTitle;case 23:return!!j.popTitle;case 24:return!!j.setWinLines}return!1}var P;(function(K){K[K.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",K[K.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(P||(o.WindowsOptionsReportType=P={}));let U=0;class V extends w.Disposable{getAttrData(){return this._curAttrData}constructor(j,M,O,$,F,J,re,le,Z=new b.EscapeSequenceParser){super(),this._bufferService=j,this._charsetService=M,this._coreService=O,this._logService=$,this._optionsService=F,this._oscLinkService=J,this._coreMouseService=re,this._unicodeService=le,this._parser=Z,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new C.StringToUtf32,this._utf8Decoder=new C.Utf8ToUtf32,this._workCell=new _.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=v.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=v.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new y.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new y.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new y.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new y.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new y.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new y.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new y.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new y.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new y.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new y.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new y.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new y.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new y.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new G(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((H=>this._activeBuffer=H.activeBuffer))),this._parser.setCsiHandlerFallback(((H,ee)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(H),params:ee.toArray()})})),this._parser.setEscHandlerFallback((H=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(H)})})),this._parser.setExecuteHandlerFallback((H=>{this._logService.debug("Unknown EXECUTE code: ",{code:H})})),this._parser.setOscHandlerFallback(((H,ee,te)=>{this._logService.debug("Unknown OSC code: ",{identifier:H,action:ee,data:te})})),this._parser.setDcsHandlerFallback(((H,ee,te)=>{ee==="HOOK"&&(te=te.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(H),action:ee,payload:te})})),this._parser.setPrintHandler(((H,ee,te)=>this.print(H,ee,te))),this._parser.registerCsiHandler({final:"@"},(H=>this.insertChars(H))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(H=>this.scrollLeft(H))),this._parser.registerCsiHandler({final:"A"},(H=>this.cursorUp(H))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(H=>this.scrollRight(H))),this._parser.registerCsiHandler({final:"B"},(H=>this.cursorDown(H))),this._parser.registerCsiHandler({final:"C"},(H=>this.cursorForward(H))),this._parser.registerCsiHandler({final:"D"},(H=>this.cursorBackward(H))),this._parser.registerCsiHandler({final:"E"},(H=>this.cursorNextLine(H))),this._parser.registerCsiHandler({final:"F"},(H=>this.cursorPrecedingLine(H))),this._parser.registerCsiHandler({final:"G"},(H=>this.cursorCharAbsolute(H))),this._parser.registerCsiHandler({final:"H"},(H=>this.cursorPosition(H))),this._parser.registerCsiHandler({final:"I"},(H=>this.cursorForwardTab(H))),this._parser.registerCsiHandler({final:"J"},(H=>this.eraseInDisplay(H,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(H=>this.eraseInDisplay(H,!0))),this._parser.registerCsiHandler({final:"K"},(H=>this.eraseInLine(H,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(H=>this.eraseInLine(H,!0))),this._parser.registerCsiHandler({final:"L"},(H=>this.insertLines(H))),this._parser.registerCsiHandler({final:"M"},(H=>this.deleteLines(H))),this._parser.registerCsiHandler({final:"P"},(H=>this.deleteChars(H))),this._parser.registerCsiHandler({final:"S"},(H=>this.scrollUp(H))),this._parser.registerCsiHandler({final:"T"},(H=>this.scrollDown(H))),this._parser.registerCsiHandler({final:"X"},(H=>this.eraseChars(H))),this._parser.registerCsiHandler({final:"Z"},(H=>this.cursorBackwardTab(H))),this._parser.registerCsiHandler({final:"`"},(H=>this.charPosAbsolute(H))),this._parser.registerCsiHandler({final:"a"},(H=>this.hPositionRelative(H))),this._parser.registerCsiHandler({final:"b"},(H=>this.repeatPrecedingCharacter(H))),this._parser.registerCsiHandler({final:"c"},(H=>this.sendDeviceAttributesPrimary(H))),this._parser.registerCsiHandler({prefix:">",final:"c"},(H=>this.sendDeviceAttributesSecondary(H))),this._parser.registerCsiHandler({final:"d"},(H=>this.linePosAbsolute(H))),this._parser.registerCsiHandler({final:"e"},(H=>this.vPositionRelative(H))),this._parser.registerCsiHandler({final:"f"},(H=>this.hVPosition(H))),this._parser.registerCsiHandler({final:"g"},(H=>this.tabClear(H))),this._parser.registerCsiHandler({final:"h"},(H=>this.setMode(H))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(H=>this.setModePrivate(H))),this._parser.registerCsiHandler({final:"l"},(H=>this.resetMode(H))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(H=>this.resetModePrivate(H))),this._parser.registerCsiHandler({final:"m"},(H=>this.charAttributes(H))),this._parser.registerCsiHandler({final:"n"},(H=>this.deviceStatus(H))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(H=>this.deviceStatusPrivate(H))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(H=>this.softReset(H))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(H=>this.setCursorStyle(H))),this._parser.registerCsiHandler({final:"r"},(H=>this.setScrollRegion(H))),this._parser.registerCsiHandler({final:"s"},(H=>this.saveCursor(H))),this._parser.registerCsiHandler({final:"t"},(H=>this.windowOptions(H))),this._parser.registerCsiHandler({final:"u"},(H=>this.restoreCursor(H))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(H=>this.insertColumns(H))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(H=>this.deleteColumns(H))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(H=>this.selectProtected(H))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(H=>this.requestMode(H,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(H=>this.requestMode(H,!1))),this._parser.setExecuteHandler(d.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(d.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(d.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(d.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(d.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(d.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(d.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(d.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(d.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(d.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(d.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(d.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new R.OscHandler((H=>(this.setTitle(H),this.setIconName(H),!0)))),this._parser.registerOscHandler(1,new R.OscHandler((H=>this.setIconName(H)))),this._parser.registerOscHandler(2,new R.OscHandler((H=>this.setTitle(H)))),this._parser.registerOscHandler(4,new R.OscHandler((H=>this.setOrReportIndexedColor(H)))),this._parser.registerOscHandler(8,new R.OscHandler((H=>this.setHyperlink(H)))),this._parser.registerOscHandler(10,new R.OscHandler((H=>this.setOrReportFgColor(H)))),this._parser.registerOscHandler(11,new R.OscHandler((H=>this.setOrReportBgColor(H)))),this._parser.registerOscHandler(12,new R.OscHandler((H=>this.setOrReportCursorColor(H)))),this._parser.registerOscHandler(104,new R.OscHandler((H=>this.restoreIndexedColor(H)))),this._parser.registerOscHandler(110,new R.OscHandler((H=>this.restoreFgColor(H)))),this._parser.registerOscHandler(111,new R.OscHandler((H=>this.restoreBgColor(H)))),this._parser.registerOscHandler(112,new R.OscHandler((H=>this.restoreCursorColor(H)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const H in m.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:H},(()=>this.selectCharset("("+H))),this._parser.registerEscHandler({intermediates:")",final:H},(()=>this.selectCharset(")"+H))),this._parser.registerEscHandler({intermediates:"*",final:H},(()=>this.selectCharset("*"+H))),this._parser.registerEscHandler({intermediates:"+",final:H},(()=>this.selectCharset("+"+H))),this._parser.registerEscHandler({intermediates:"-",final:H},(()=>this.selectCharset("-"+H))),this._parser.registerEscHandler({intermediates:".",final:H},(()=>this.selectCharset("."+H))),this._parser.registerEscHandler({intermediates:"/",final:H},(()=>this.selectCharset("/"+H)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((H=>(this._logService.error("Parsing error: ",H),H))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new N.DcsHandler(((H,ee)=>this.requestStatusString(H,ee))))}_preserveStack(j,M,O,$){this._parseStack.paused=!0,this._parseStack.cursorStartX=j,this._parseStack.cursorStartY=M,this._parseStack.decodedLength=O,this._parseStack.position=$}_logSlowResolvingAsync(j){this._logService.logLevel<=D.LogLevelEnum.WARN&&Promise.race([j,new Promise(((M,O)=>setTimeout((()=>O("#SLOW_TIMEOUT")),5e3)))]).catch((M=>{if(M!=="#SLOW_TIMEOUT")throw M;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(j,M){let O,$=this._activeBuffer.x,F=this._activeBuffer.y,J=0;const re=this._parseStack.paused;if(re){if(O=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,M))return this._logSlowResolvingAsync(O),O;$=this._parseStack.cursorStartX,F=this._parseStack.cursorStartY,this._parseStack.paused=!1,j.length>z&&(J=this._parseStack.position+z)}if(this._logService.logLevel<=D.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof j=="string"?` "${j}"`:` "${Array.prototype.map.call(j,(H=>String.fromCharCode(H))).join("")}"`),typeof j=="string"?j.split("").map((H=>H.charCodeAt(0))):j),this._parseBuffer.length<j.length&&this._parseBuffer.length<z&&(this._parseBuffer=new Uint32Array(Math.min(j.length,z))),re||this._dirtyRowTracker.clearRange(),j.length>z)for(let H=J;H<j.length;H+=z){const ee=H+z<j.length?H+z:j.length,te=typeof j=="string"?this._stringDecoder.decode(j.substring(H,ee),this._parseBuffer):this._utf8Decoder.decode(j.subarray(H,ee),this._parseBuffer);if(O=this._parser.parse(this._parseBuffer,te))return this._preserveStack($,F,te,H),this._logSlowResolvingAsync(O),O}else if(!re){const H=typeof j=="string"?this._stringDecoder.decode(j,this._parseBuffer):this._utf8Decoder.decode(j,this._parseBuffer);if(O=this._parser.parse(this._parseBuffer,H))return this._preserveStack($,F,H,0),this._logSlowResolvingAsync(O),O}this._activeBuffer.x===$&&this._activeBuffer.y===F||this._onCursorMove.fire();const le=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),Z=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);Z<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(Z,this._bufferService.rows-1),Math.min(le,this._bufferService.rows-1))}print(j,M,O){let $,F;const J=this._charsetService.charset,re=this._optionsService.rawOptions.screenReaderMode,le=this._bufferService.cols,Z=this._coreService.decPrivateModes.wraparound,H=this._coreService.modes.insertMode,ee=this._curAttrData;let te=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&O-M>0&&te.getWidth(this._activeBuffer.x-1)===2&&te.setCellFromCodepoint(this._activeBuffer.x-1,0,1,ee);let de=this._parser.precedingJoinState;for(let he=M;he<O;++he){if($=j[he],$<127&&J){const we=J[String.fromCharCode($)];we&&($=we.charCodeAt(0))}const ye=this._unicodeService.charProperties($,de);F=T.UnicodeService.extractWidth(ye);const oe=T.UnicodeService.extractShouldJoin(ye),ve=oe?T.UnicodeService.extractWidth(de):0;if(de=ye,re&&this._onA11yChar.fire((0,C.stringFromCodePoint)($)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+F-ve>le){if(Z){const we=te;let Se=this._activeBuffer.x-ve;for(this._activeBuffer.x=ve,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),te=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),ve>0&&te instanceof v.BufferLine&&te.copyCellsFrom(we,Se,0,ve,!1);Se<le;)we.setCellFromCodepoint(Se++,0,1,ee)}else if(this._activeBuffer.x=le-1,F===2)continue}if(oe&&this._activeBuffer.x){const we=te.getWidth(this._activeBuffer.x-1)?1:2;te.addCodepointToCell(this._activeBuffer.x-we,$,F);for(let Se=F-ve;--Se>=0;)te.setCellFromCodepoint(this._activeBuffer.x++,0,0,ee)}else if(H&&(te.insertCells(this._activeBuffer.x,F-ve,this._activeBuffer.getNullCell(ee)),te.getWidth(le-1)===2&&te.setCellFromCodepoint(le-1,S.NULL_CELL_CODE,S.NULL_CELL_WIDTH,ee)),te.setCellFromCodepoint(this._activeBuffer.x++,$,F,ee),F>0)for(;--F;)te.setCellFromCodepoint(this._activeBuffer.x++,0,0,ee)}this._parser.precedingJoinState=de,this._activeBuffer.x<le&&O-M>0&&te.getWidth(this._activeBuffer.x)===0&&!te.hasContent(this._activeBuffer.x)&&te.setCellFromCodepoint(this._activeBuffer.x,0,1,ee),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(j,M){return j.final!=="t"||j.prefix||j.intermediates?this._parser.registerCsiHandler(j,M):this._parser.registerCsiHandler(j,(O=>!q(O.params[0],this._optionsService.rawOptions.windowOptions)||M(O)))}registerDcsHandler(j,M){return this._parser.registerDcsHandler(j,new N.DcsHandler(M))}registerEscHandler(j,M){return this._parser.registerEscHandler(j,M)}registerOscHandler(j,M){return this._parser.registerOscHandler(j,new R.OscHandler(M))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var j;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((j=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&j.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);M.hasWidth(this._activeBuffer.x)&&!M.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const j=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-j),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(j=this._bufferService.cols-1){this._activeBuffer.x=Math.min(j,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(j,M){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=j,this._activeBuffer.y=this._activeBuffer.scrollTop+M):(this._activeBuffer.x=j,this._activeBuffer.y=M),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(j,M){this._restrictCursor(),this._setCursor(this._activeBuffer.x+j,this._activeBuffer.y+M)}cursorUp(j){const M=this._activeBuffer.y-this._activeBuffer.scrollTop;return M>=0?this._moveCursor(0,-Math.min(M,j.params[0]||1)):this._moveCursor(0,-(j.params[0]||1)),!0}cursorDown(j){const M=this._activeBuffer.scrollBottom-this._activeBuffer.y;return M>=0?this._moveCursor(0,Math.min(M,j.params[0]||1)):this._moveCursor(0,j.params[0]||1),!0}cursorForward(j){return this._moveCursor(j.params[0]||1,0),!0}cursorBackward(j){return this._moveCursor(-(j.params[0]||1),0),!0}cursorNextLine(j){return this.cursorDown(j),this._activeBuffer.x=0,!0}cursorPrecedingLine(j){return this.cursorUp(j),this._activeBuffer.x=0,!0}cursorCharAbsolute(j){return this._setCursor((j.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(j){return this._setCursor(j.length>=2?(j.params[1]||1)-1:0,(j.params[0]||1)-1),!0}charPosAbsolute(j){return this._setCursor((j.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(j){return this._moveCursor(j.params[0]||1,0),!0}linePosAbsolute(j){return this._setCursor(this._activeBuffer.x,(j.params[0]||1)-1),!0}vPositionRelative(j){return this._moveCursor(0,j.params[0]||1),!0}hVPosition(j){return this.cursorPosition(j),!0}tabClear(j){const M=j.params[0];return M===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:M===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(j){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=j.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(j){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=j.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(j){const M=j.params[0];return M===1&&(this._curAttrData.bg|=536870912),M!==2&&M!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(j,M,O,$=!1,F=!1){const J=this._activeBuffer.lines.get(this._activeBuffer.ybase+j);J.replaceCells(M,O,this._activeBuffer.getNullCell(this._eraseAttrData()),F),$&&(J.isWrapped=!1)}_resetBufferLine(j,M=!1){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+j);O&&(O.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),M),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+j),O.isWrapped=!1)}eraseInDisplay(j,M=!1){let O;switch(this._restrictCursor(this._bufferService.cols),j.params[0]){case 0:for(O=this._activeBuffer.y,this._dirtyRowTracker.markDirty(O),this._eraseInBufferLine(O++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);O<this._bufferService.rows;O++)this._resetBufferLine(O,M);this._dirtyRowTracker.markDirty(O);break;case 1:for(O=this._activeBuffer.y,this._dirtyRowTracker.markDirty(O),this._eraseInBufferLine(O,0,this._activeBuffer.x+1,!0,M),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(O+1).isWrapped=!1);O--;)this._resetBufferLine(O,M);this._dirtyRowTracker.markDirty(0);break;case 2:for(O=this._bufferService.rows,this._dirtyRowTracker.markDirty(O-1);O--;)this._resetBufferLine(O,M);this._dirtyRowTracker.markDirty(0);break;case 3:const $=this._activeBuffer.lines.length-this._bufferService.rows;$>0&&(this._activeBuffer.lines.trimStart($),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-$,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-$,0),this._onScroll.fire(0))}return!0}eraseInLine(j,M=!1){switch(this._restrictCursor(this._bufferService.cols),j.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,M);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,M)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(j){this._restrictCursor();let M=j.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=this._activeBuffer.ybase+this._activeBuffer.y,$=this._bufferService.rows-1-this._activeBuffer.scrollBottom,F=this._bufferService.rows-1+this._activeBuffer.ybase-$+1;for(;M--;)this._activeBuffer.lines.splice(F-1,1),this._activeBuffer.lines.splice(O,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(j){this._restrictCursor();let M=j.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=this._activeBuffer.ybase+this._activeBuffer.y;let $;for($=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-$;M--;)this._activeBuffer.lines.splice(O,1),this._activeBuffer.lines.splice($,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(j){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.insertCells(this._activeBuffer.x,j.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(j){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.deleteCells(this._activeBuffer.x,j.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(j){let M=j.params[0]||1;for(;M--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(j){let M=j.params[0]||1;for(;M--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(v.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(j){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=j.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const $=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);$.deleteCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData())),$.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(j){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=j.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const $=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);$.insertCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData())),$.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(j){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=j.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const $=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);$.insertCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData())),$.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(j){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=j.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const $=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);$.deleteCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData())),$.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(j){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(j.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(j){const M=this._parser.precedingJoinState;if(!M)return!0;const O=j.params[0]||1,$=T.UnicodeService.extractWidth(M),F=this._activeBuffer.x-$,J=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(F),re=new Uint32Array(J.length*O);let le=0;for(let H=0;H<J.length;){const ee=J.codePointAt(H)||0;re[le++]=ee,H+=ee>65535?2:1}let Z=le;for(let H=1;H<O;++H)re.copyWithin(Z,0,le),Z+=le;return this.print(re,0,Z),!0}sendDeviceAttributesPrimary(j){return j.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(d.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(d.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(j){return j.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(d.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(d.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(j.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(d.C0.ESC+"[>83;40003;0c")),!0}_is(j){return(this._optionsService.rawOptions.termName+"").indexOf(j)===0}setMode(j){for(let M=0;M<j.length;M++)switch(j.params[M]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(j){for(let M=0;M<j.length;M++)switch(j.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,m.DEFAULT_CHARSET),this._charsetService.setgCharset(1,m.DEFAULT_CHARSET),this._charsetService.setgCharset(2,m.DEFAULT_CHARSET),this._charsetService.setgCharset(3,m.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(j){for(let M=0;M<j.length;M++)switch(j.params[M]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(j){for(let M=0;M<j.length;M++)switch(j.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),j.params[M]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(j,M){const O=this._coreService.decPrivateModes,{activeProtocol:$,activeEncoding:F}=this._coreMouseService,J=this._coreService,{buffers:re,cols:le}=this._bufferService,{active:Z,alt:H}=re,ee=this._optionsService.rawOptions,te=oe=>oe?1:2,de=j.params[0];return he=de,ye=M?de===2?4:de===4?te(J.modes.insertMode):de===12?3:de===20?te(ee.convertEol):0:de===1?te(O.applicationCursorKeys):de===3?ee.windowOptions.setWinLines?le===80?2:le===132?1:0:0:de===6?te(O.origin):de===7?te(O.wraparound):de===8?3:de===9?te($==="X10"):de===12?te(ee.cursorBlink):de===25?te(!J.isCursorHidden):de===45?te(O.reverseWraparound):de===66?te(O.applicationKeypad):de===67?4:de===1e3?te($==="VT200"):de===1002?te($==="DRAG"):de===1003?te($==="ANY"):de===1004?te(O.sendFocus):de===1005?4:de===1006?te(F==="SGR"):de===1015?4:de===1016?te(F==="SGR_PIXELS"):de===1048?1:de===47||de===1047||de===1049?te(Z===H):de===2004?te(O.bracketedPasteMode):0,J.triggerDataEvent(`${d.C0.ESC}[${M?"":"?"}${he};${ye}$y`),!0;var he,ye}_updateAttrColor(j,M,O,$,F){return M===2?(j|=50331648,j&=-16777216,j|=k.AttributeData.fromColorRGB([O,$,F])):M===5&&(j&=-50331904,j|=33554432|255&O),j}_extractColor(j,M,O){const $=[0,0,-1,0,0,0];let F=0,J=0;do{if($[J+F]=j.params[M+J],j.hasSubParams(M+J)){const re=j.getSubParams(M+J);let le=0;do $[1]===5&&(F=1),$[J+le+1+F]=re[le];while(++le<re.length&&le+J+1+F<$.length);break}if($[1]===5&&J+F>=2||$[1]===2&&J+F>=5)break;$[1]&&(F=1)}while(++J+M<j.length&&J+F<$.length);for(let re=2;re<$.length;++re)$[re]===-1&&($[re]=0);switch($[0]){case 38:O.fg=this._updateAttrColor(O.fg,$[1],$[3],$[4],$[5]);break;case 48:O.bg=this._updateAttrColor(O.bg,$[1],$[3],$[4],$[5]);break;case 58:O.extended=O.extended.clone(),O.extended.underlineColor=this._updateAttrColor(O.extended.underlineColor,$[1],$[3],$[4],$[5])}return J}_processUnderline(j,M){M.extended=M.extended.clone(),(!~j||j>5)&&(j=1),M.extended.underlineStyle=j,M.fg|=268435456,j===0&&(M.fg&=-268435457),M.updateExtended()}_processSGR0(j){j.fg=v.DEFAULT_ATTR_DATA.fg,j.bg=v.DEFAULT_ATTR_DATA.bg,j.extended=j.extended.clone(),j.extended.underlineStyle=0,j.extended.underlineColor&=-67108864,j.updateExtended()}charAttributes(j){if(j.length===1&&j.params[0]===0)return this._processSGR0(this._curAttrData),!0;const M=j.length;let O;const $=this._curAttrData;for(let F=0;F<M;F++)O=j.params[F],O>=30&&O<=37?($.fg&=-50331904,$.fg|=16777216|O-30):O>=40&&O<=47?($.bg&=-50331904,$.bg|=16777216|O-40):O>=90&&O<=97?($.fg&=-50331904,$.fg|=16777224|O-90):O>=100&&O<=107?($.bg&=-50331904,$.bg|=16777224|O-100):O===0?this._processSGR0($):O===1?$.fg|=134217728:O===3?$.bg|=67108864:O===4?($.fg|=268435456,this._processUnderline(j.hasSubParams(F)?j.getSubParams(F)[0]:1,$)):O===5?$.fg|=536870912:O===7?$.fg|=67108864:O===8?$.fg|=1073741824:O===9?$.fg|=2147483648:O===2?$.bg|=134217728:O===21?this._processUnderline(2,$):O===22?($.fg&=-134217729,$.bg&=-134217729):O===23?$.bg&=-67108865:O===24?($.fg&=-268435457,this._processUnderline(0,$)):O===25?$.fg&=-536870913:O===27?$.fg&=-67108865:O===28?$.fg&=-1073741825:O===29?$.fg&=2147483647:O===39?($.fg&=-67108864,$.fg|=16777215&v.DEFAULT_ATTR_DATA.fg):O===49?($.bg&=-67108864,$.bg|=16777215&v.DEFAULT_ATTR_DATA.bg):O===38||O===48||O===58?F+=this._extractColor(j,F,$):O===53?$.bg|=1073741824:O===55?$.bg&=-1073741825:O===59?($.extended=$.extended.clone(),$.extended.underlineColor=-1,$.updateExtended()):O===100?($.fg&=-67108864,$.fg|=16777215&v.DEFAULT_ATTR_DATA.fg,$.bg&=-67108864,$.bg|=16777215&v.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",O);return!0}deviceStatus(j){switch(j.params[0]){case 5:this._coreService.triggerDataEvent(`${d.C0.ESC}[0n`);break;case 6:const M=this._activeBuffer.y+1,O=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${d.C0.ESC}[${M};${O}R`)}return!0}deviceStatusPrivate(j){if(j.params[0]===6){const M=this._activeBuffer.y+1,O=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${d.C0.ESC}[?${M};${O}R`)}return!0}softReset(j){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=v.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(j){const M=j.params[0]||1;switch(M){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const O=M%2==1;return this._optionsService.options.cursorBlink=O,!0}setScrollRegion(j){const M=j.params[0]||1;let O;return(j.length<2||(O=j.params[1])>this._bufferService.rows||O===0)&&(O=this._bufferService.rows),O>M&&(this._activeBuffer.scrollTop=M-1,this._activeBuffer.scrollBottom=O-1,this._setCursor(0,0)),!0}windowOptions(j){if(!q(j.params[0],this._optionsService.rawOptions.windowOptions))return!0;const M=j.length>1?j.params[1]:0;switch(j.params[0]){case 14:M!==2&&this._onRequestWindowsOptionsReport.fire(P.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(P.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${d.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:M!==0&&M!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),M!==0&&M!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:M!==0&&M!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),M!==0&&M!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(j){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(j){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(j){return this._windowTitle=j,this._onTitleChange.fire(j),!0}setIconName(j){return this._iconName=j,!0}setOrReportIndexedColor(j){const M=[],O=j.split(";");for(;O.length>1;){const $=O.shift(),F=O.shift();if(/^\d+$/.exec($)){const J=parseInt($);if(W(J))if(F==="?")M.push({type:0,index:J});else{const re=(0,L.parseColor)(F);re&&M.push({type:1,index:J,color:re})}}}return M.length&&this._onColor.fire(M),!0}setHyperlink(j){const M=j.split(";");return!(M.length<2)&&(M[1]?this._createHyperlink(M[0],M[1]):!M[0]&&this._finishHyperlink())}_createHyperlink(j,M){this._getCurrentLinkId()&&this._finishHyperlink();const O=j.split(":");let $;const F=O.findIndex((J=>J.startsWith("id=")));return F!==-1&&($=O[F].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:$,uri:M}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(j,M){const O=j.split(";");for(let $=0;$<O.length&&!(M>=this._specialColors.length);++$,++M)if(O[$]==="?")this._onColor.fire([{type:0,index:this._specialColors[M]}]);else{const F=(0,L.parseColor)(O[$]);F&&this._onColor.fire([{type:1,index:this._specialColors[M],color:F}])}return!0}setOrReportFgColor(j){return this._setOrReportSpecialColor(j,0)}setOrReportBgColor(j){return this._setOrReportSpecialColor(j,1)}setOrReportCursorColor(j){return this._setOrReportSpecialColor(j,2)}restoreIndexedColor(j){if(!j)return this._onColor.fire([{type:2}]),!0;const M=[],O=j.split(";");for(let $=0;$<O.length;++$)if(/^\d+$/.exec(O[$])){const F=parseInt(O[$]);W(F)&&M.push({type:2,index:F})}return M.length&&this._onColor.fire(M),!0}restoreFgColor(j){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(j){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(j){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,m.DEFAULT_CHARSET),!0}selectCharset(j){return j.length!==2?(this.selectDefaultCharset(),!0):(j[0]==="/"||this._charsetService.setgCharset(I[j[0]],m.CHARSETS[j[1]]||m.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const j=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,j,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=v.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=v.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(j){return this._charsetService.setgLevel(j),!0}screenAlignmentPattern(){const j=new _.CellData;j.content=4194373,j.fg=this._curAttrData.fg,j.bg=this._curAttrData.bg,this._setCursor(0,0);for(let M=0;M<this._bufferService.rows;++M){const O=this._activeBuffer.ybase+this._activeBuffer.y+M,$=this._activeBuffer.lines.get(O);$&&($.fill(j),$.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(j,M){const O=this._bufferService.buffer,$=this._optionsService.rawOptions;return(F=>(this._coreService.triggerDataEvent(`${d.C0.ESC}${F}${d.C0.ESC}\\`),!0))(j==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:j==='"p'?'P1$r61;1"p':j==="r"?`P1$r${O.scrollTop+1};${O.scrollBottom+1}r`:j==="m"?"P1$r0m":j===" q"?`P1$r${{block:2,underline:4,bar:6}[$.cursorStyle]-($.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(j,M){this._dirtyRowTracker.markRangeDirty(j,M)}}o.InputHandler=V;let G=class{constructor(K){this._bufferService=K,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(K){K<this.start?this.start=K:K>this.end&&(this.end=K)}markRangeDirty(K,j){K>j&&(U=K,K=j,j=U),K<this.start&&(this.start=K),j>this.end&&(this.end=j)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function W(K){return 0<=K&&K<256}G=f([g(0,D.IBufferService)],G)},844:(c,o)=>{function u(f){for(const g of f)g.dispose();f.length=0}Object.defineProperty(o,"__esModule",{value:!0}),o.getDisposeArrayDisposable=o.disposeArray=o.toDisposable=o.MutableDisposable=o.Disposable=void 0,o.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const f of this._disposables)f.dispose();this._disposables.length=0}register(f){return this._disposables.push(f),f}unregister(f){const g=this._disposables.indexOf(f);g!==-1&&this._disposables.splice(g,1)}},o.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(f){var g;this._isDisposed||f===this._value||((g=this._value)==null||g.dispose(),this._value=f)}clear(){this.value=void 0}dispose(){var f;this._isDisposed=!0,(f=this._value)==null||f.dispose(),this._value=void 0}},o.toDisposable=function(f){return{dispose:f}},o.disposeArray=u,o.getDisposeArrayDisposable=function(f){return{dispose:()=>u(f)}}},1505:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.FourKeyMap=o.TwoKeyMap=void 0;class u{constructor(){this._data={}}set(g,d,m){this._data[g]||(this._data[g]={}),this._data[g][d]=m}get(g,d){return this._data[g]?this._data[g][d]:void 0}clear(){this._data={}}}o.TwoKeyMap=u,o.FourKeyMap=class{constructor(){this._data=new u}set(f,g,d,m,b){this._data.get(f,g)||this._data.set(f,g,new u),this._data.get(f,g).set(d,m,b)}get(f,g,d,m){var b;return(b=this._data.get(f,g))==null?void 0:b.get(d,m)}clear(){this._data.clear()}}},6114:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.isChromeOS=o.isLinux=o.isWindows=o.isIphone=o.isIpad=o.isMac=o.getSafariVersion=o.isSafari=o.isLegacyEdge=o.isFirefox=o.isNode=void 0,o.isNode=typeof process<"u"&&"title"in process;const u=o.isNode?"node":navigator.userAgent,f=o.isNode?"node":navigator.platform;o.isFirefox=u.includes("Firefox"),o.isLegacyEdge=u.includes("Edge"),o.isSafari=/^((?!chrome|android).)*safari/i.test(u),o.getSafariVersion=function(){if(!o.isSafari)return 0;const g=u.match(/Version\/(\d+)/);return g===null||g.length<2?0:parseInt(g[1])},o.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(f),o.isIpad=f==="iPad",o.isIphone=f==="iPhone",o.isWindows=["Windows","Win16","Win32","WinCE"].includes(f),o.isLinux=f.indexOf("Linux")>=0,o.isChromeOS=/\bCrOS\b/.test(u)},6106:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.SortedList=void 0;let u=0;o.SortedList=class{constructor(f){this._getKey=f,this._array=[]}clear(){this._array.length=0}insert(f){this._array.length!==0?(u=this._search(this._getKey(f)),this._array.splice(u,0,f)):this._array.push(f)}delete(f){if(this._array.length===0)return!1;const g=this._getKey(f);if(g===void 0||(u=this._search(g),u===-1)||this._getKey(this._array[u])!==g)return!1;do if(this._array[u]===f)return this._array.splice(u,1),!0;while(++u<this._array.length&&this._getKey(this._array[u])===g);return!1}*getKeyIterator(f){if(this._array.length!==0&&(u=this._search(f),!(u<0||u>=this._array.length)&&this._getKey(this._array[u])===f))do yield this._array[u];while(++u<this._array.length&&this._getKey(this._array[u])===f)}forEachByKey(f,g){if(this._array.length!==0&&(u=this._search(f),!(u<0||u>=this._array.length)&&this._getKey(this._array[u])===f))do g(this._array[u]);while(++u<this._array.length&&this._getKey(this._array[u])===f)}values(){return[...this._array].values()}_search(f){let g=0,d=this._array.length-1;for(;d>=g;){let m=g+d>>1;const b=this._getKey(this._array[m]);if(b>f)d=m-1;else{if(!(b<f)){for(;m>0&&this._getKey(this._array[m-1])===f;)m--;return m}g=m+1}}return g}}},7226:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DebouncedIdleTask=o.IdleTaskQueue=o.PriorityTaskQueue=void 0;const f=u(6114);class g{constructor(){this._tasks=[],this._i=0}enqueue(b){this._tasks.push(b),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(b){this._idleCallback=void 0;let w=0,C=0,v=b.timeRemaining(),y=0;for(;this._i<this._tasks.length;){if(w=Date.now(),this._tasks[this._i]()||this._i++,w=Math.max(1,Date.now()-w),C=Math.max(w,C),y=b.timeRemaining(),1.5*C>y)return v-w<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(v-w))}ms`),void this._start();v=y}this.clear()}}class d extends g{_requestCallback(b){return setTimeout((()=>b(this._createDeadline(16))))}_cancelCallback(b){clearTimeout(b)}_createDeadline(b){const w=Date.now()+b;return{timeRemaining:()=>Math.max(0,w-Date.now())}}}o.PriorityTaskQueue=d,o.IdleTaskQueue=!f.isNode&&"requestIdleCallback"in window?class extends g{_requestCallback(m){return requestIdleCallback(m)}_cancelCallback(m){cancelIdleCallback(m)}}:d,o.DebouncedIdleTask=class{constructor(){this._queue=new o.IdleTaskQueue}set(m){this._queue.clear(),this._queue.enqueue(m)}flush(){this._queue.flush()}}},9282:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.updateWindowsModeWrappedState=void 0;const f=u(643);o.updateWindowsModeWrappedState=function(g){const d=g.buffer.lines.get(g.buffer.ybase+g.buffer.y-1),m=d==null?void 0:d.get(g.cols-1),b=g.buffer.lines.get(g.buffer.ybase+g.buffer.y);b&&m&&(b.isWrapped=m[f.CHAR_DATA_CODE_INDEX]!==f.NULL_CELL_CODE&&m[f.CHAR_DATA_CODE_INDEX]!==f.WHITESPACE_CELL_CODE)}},3734:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ExtendedAttrs=o.AttributeData=void 0;class u{constructor(){this.fg=0,this.bg=0,this.extended=new f}static toColorRGB(d){return[d>>>16&255,d>>>8&255,255&d]}static fromColorRGB(d){return(255&d[0])<<16|(255&d[1])<<8|255&d[2]}clone(){const d=new u;return d.fg=this.fg,d.bg=this.bg,d.extended=this.extended.clone(),d}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}o.AttributeData=u;class f{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(d){this._ext=d}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(d){this._ext&=-469762049,this._ext|=d<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(d){this._ext&=-67108864,this._ext|=67108863&d}get urlId(){return this._urlId}set urlId(d){this._urlId=d}get underlineVariantOffset(){const d=(3758096384&this._ext)>>29;return d<0?4294967288^d:d}set underlineVariantOffset(d){this._ext&=536870911,this._ext|=d<<29&3758096384}constructor(d=0,m=0){this._ext=0,this._urlId=0,this._ext=d,this._urlId=m}clone(){return new f(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}o.ExtendedAttrs=f},9092:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Buffer=o.MAX_BUFFER_SIZE=void 0;const f=u(6349),g=u(7226),d=u(3734),m=u(8437),b=u(4634),w=u(511),C=u(643),v=u(4863),y=u(7116);o.MAX_BUFFER_SIZE=4294967295,o.Buffer=class{constructor(S,_,k){this._hasScrollback=S,this._optionsService=_,this._bufferService=k,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=m.DEFAULT_ATTR_DATA.clone(),this.savedCharset=y.DEFAULT_CHARSET,this.markers=[],this._nullCell=w.CellData.fromCharData([0,C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE]),this._whitespaceCell=w.CellData.fromCharData([0,C.WHITESPACE_CELL_CHAR,C.WHITESPACE_CELL_WIDTH,C.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new g.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new f.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(S){return S?(this._nullCell.fg=S.fg,this._nullCell.bg=S.bg,this._nullCell.extended=S.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new d.ExtendedAttrs),this._nullCell}getWhitespaceCell(S){return S?(this._whitespaceCell.fg=S.fg,this._whitespaceCell.bg=S.bg,this._whitespaceCell.extended=S.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new d.ExtendedAttrs),this._whitespaceCell}getBlankLine(S,_){return new m.BufferLine(this._bufferService.cols,this.getNullCell(S),_)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const S=this.ybase+this.y-this.ydisp;return S>=0&&S<this._rows}_getCorrectBufferLength(S){if(!this._hasScrollback)return S;const _=S+this._optionsService.rawOptions.scrollback;return _>o.MAX_BUFFER_SIZE?o.MAX_BUFFER_SIZE:_}fillViewportRows(S){if(this.lines.length===0){S===void 0&&(S=m.DEFAULT_ATTR_DATA);let _=this._rows;for(;_--;)this.lines.push(this.getBlankLine(S))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new f.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(S,_){const k=this.getNullCell(m.DEFAULT_ATTR_DATA);let D=0;const T=this._getCorrectBufferLength(_);if(T>this.lines.maxLength&&(this.lines.maxLength=T),this.lines.length>0){if(this._cols<S)for(let N=0;N<this.lines.length;N++)D+=+this.lines.get(N).resize(S,k);let R=0;if(this._rows<_)for(let N=this._rows;N<_;N++)this.lines.length<_+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new m.BufferLine(S,k)):this.ybase>0&&this.lines.length<=this.ybase+this.y+R+1?(this.ybase--,R++,this.ydisp>0&&this.ydisp--):this.lines.push(new m.BufferLine(S,k)));else for(let N=this._rows;N>_;N--)this.lines.length>_+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(T<this.lines.maxLength){const N=this.lines.length-T;N>0&&(this.lines.trimStart(N),this.ybase=Math.max(this.ybase-N,0),this.ydisp=Math.max(this.ydisp-N,0),this.savedY=Math.max(this.savedY-N,0)),this.lines.maxLength=T}this.x=Math.min(this.x,S-1),this.y=Math.min(this.y,_-1),R&&(this.y+=R),this.savedX=Math.min(this.savedX,S-1),this.scrollTop=0}if(this.scrollBottom=_-1,this._isReflowEnabled&&(this._reflow(S,_),this._cols>S))for(let R=0;R<this.lines.length;R++)D+=+this.lines.get(R).resize(S,k);this._cols=S,this._rows=_,this._memoryCleanupQueue.clear(),D>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let S=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,S=!1);let _=0;for(;this._memoryCleanupPosition<this.lines.length;)if(_+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),_>100)return!0;return S}get _isReflowEnabled(){const S=this._optionsService.rawOptions.windowsPty;return S&&S.buildNumber?this._hasScrollback&&S.backend==="conpty"&&S.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(S,_){this._cols!==S&&(S>this._cols?this._reflowLarger(S,_):this._reflowSmaller(S,_))}_reflowLarger(S,_){const k=(0,b.reflowLargerGetLinesToRemove)(this.lines,this._cols,S,this.ybase+this.y,this.getNullCell(m.DEFAULT_ATTR_DATA));if(k.length>0){const D=(0,b.reflowLargerCreateNewLayout)(this.lines,k);(0,b.reflowLargerApplyNewLayout)(this.lines,D.layout),this._reflowLargerAdjustViewport(S,_,D.countRemoved)}}_reflowLargerAdjustViewport(S,_,k){const D=this.getNullCell(m.DEFAULT_ATTR_DATA);let T=k;for(;T-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<_&&this.lines.push(new m.BufferLine(S,D))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-k,0)}_reflowSmaller(S,_){const k=this.getNullCell(m.DEFAULT_ATTR_DATA),D=[];let T=0;for(let R=this.lines.length-1;R>=0;R--){let N=this.lines.get(R);if(!N||!N.isWrapped&&N.getTrimmedLength()<=S)continue;const L=[N];for(;N.isWrapped&&R>0;)N=this.lines.get(--R),L.unshift(N);const I=this.ybase+this.y;if(I>=R&&I<R+L.length)continue;const z=L[L.length-1].getTrimmedLength(),q=(0,b.reflowSmallerGetNewLineLengths)(L,this._cols,S),P=q.length-L.length;let U;U=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+P):Math.max(0,this.lines.length-this.lines.maxLength+P);const V=[];for(let O=0;O<P;O++){const $=this.getBlankLine(m.DEFAULT_ATTR_DATA,!0);V.push($)}V.length>0&&(D.push({start:R+L.length+T,newLines:V}),T+=V.length),L.push(...V);let G=q.length-1,W=q[G];W===0&&(G--,W=q[G]);let K=L.length-P-1,j=z;for(;K>=0;){const O=Math.min(j,W);if(L[G]===void 0)break;if(L[G].copyCellsFrom(L[K],j-O,W-O,O,!0),W-=O,W===0&&(G--,W=q[G]),j-=O,j===0){K--;const $=Math.max(K,0);j=(0,b.getWrappedLineTrimmedLength)(L,$,this._cols)}}for(let O=0;O<L.length;O++)q[O]<S&&L[O].setCell(q[O],k);let M=P-U;for(;M-- >0;)this.ybase===0?this.y<_-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+T)-_&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+P,this.ybase+_-1)}if(D.length>0){const R=[],N=[];for(let G=0;G<this.lines.length;G++)N.push(this.lines.get(G));const L=this.lines.length;let I=L-1,z=0,q=D[z];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+T);let P=0;for(let G=Math.min(this.lines.maxLength-1,L+T-1);G>=0;G--)if(q&&q.start>I+P){for(let W=q.newLines.length-1;W>=0;W--)this.lines.set(G--,q.newLines[W]);G++,R.push({index:I+1,amount:q.newLines.length}),P+=q.newLines.length,q=D[++z]}else this.lines.set(G,N[I--]);let U=0;for(let G=R.length-1;G>=0;G--)R[G].index+=U,this.lines.onInsertEmitter.fire(R[G]),U+=R[G].amount;const V=Math.max(0,L+T-this.lines.maxLength);V>0&&this.lines.onTrimEmitter.fire(V)}}translateBufferLineToString(S,_,k=0,D){const T=this.lines.get(S);return T?T.translateToString(_,k,D):""}getWrappedRangeForLine(S){let _=S,k=S;for(;_>0&&this.lines.get(_).isWrapped;)_--;for(;k+1<this.lines.length&&this.lines.get(k+1).isWrapped;)k++;return{first:_,last:k}}setupTabStops(S){for(S!=null?this.tabs[S]||(S=this.prevStop(S)):(this.tabs={},S=0);S<this._cols;S+=this._optionsService.rawOptions.tabStopWidth)this.tabs[S]=!0}prevStop(S){for(S==null&&(S=this.x);!this.tabs[--S]&&S>0;);return S>=this._cols?this._cols-1:S<0?0:S}nextStop(S){for(S==null&&(S=this.x);!this.tabs[++S]&&S<this._cols;);return S>=this._cols?this._cols-1:S<0?0:S}clearMarkers(S){this._isClearing=!0;for(let _=0;_<this.markers.length;_++)this.markers[_].line===S&&(this.markers[_].dispose(),this.markers.splice(_--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let S=0;S<this.markers.length;S++)this.markers[S].dispose(),this.markers.splice(S--,1);this._isClearing=!1}addMarker(S){const _=new v.Marker(S);return this.markers.push(_),_.register(this.lines.onTrim((k=>{_.line-=k,_.line<0&&_.dispose()}))),_.register(this.lines.onInsert((k=>{_.line>=k.index&&(_.line+=k.amount)}))),_.register(this.lines.onDelete((k=>{_.line>=k.index&&_.line<k.index+k.amount&&_.dispose(),_.line>k.index&&(_.line-=k.amount)}))),_.register(_.onDispose((()=>this._removeMarker(_)))),_}_removeMarker(S){this._isClearing||this.markers.splice(this.markers.indexOf(S),1)}}},8437:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferLine=o.DEFAULT_ATTR_DATA=void 0;const f=u(3734),g=u(511),d=u(643),m=u(482);o.DEFAULT_ATTR_DATA=Object.freeze(new f.AttributeData);let b=0;class w{constructor(v,y,S=!1){this.isWrapped=S,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*v);const _=y||g.CellData.fromCharData([0,d.NULL_CELL_CHAR,d.NULL_CELL_WIDTH,d.NULL_CELL_CODE]);for(let k=0;k<v;++k)this.setCell(k,_);this.length=v}get(v){const y=this._data[3*v+0],S=2097151&y;return[this._data[3*v+1],2097152&y?this._combined[v]:S?(0,m.stringFromCodePoint)(S):"",y>>22,2097152&y?this._combined[v].charCodeAt(this._combined[v].length-1):S]}set(v,y){this._data[3*v+1]=y[d.CHAR_DATA_ATTR_INDEX],y[d.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[v]=y[1],this._data[3*v+0]=2097152|v|y[d.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*v+0]=y[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[d.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(v){return this._data[3*v+0]>>22}hasWidth(v){return 12582912&this._data[3*v+0]}getFg(v){return this._data[3*v+1]}getBg(v){return this._data[3*v+2]}hasContent(v){return 4194303&this._data[3*v+0]}getCodePoint(v){const y=this._data[3*v+0];return 2097152&y?this._combined[v].charCodeAt(this._combined[v].length-1):2097151&y}isCombined(v){return 2097152&this._data[3*v+0]}getString(v){const y=this._data[3*v+0];return 2097152&y?this._combined[v]:2097151&y?(0,m.stringFromCodePoint)(2097151&y):""}isProtected(v){return 536870912&this._data[3*v+2]}loadCell(v,y){return b=3*v,y.content=this._data[b+0],y.fg=this._data[b+1],y.bg=this._data[b+2],2097152&y.content&&(y.combinedData=this._combined[v]),268435456&y.bg&&(y.extended=this._extendedAttrs[v]),y}setCell(v,y){2097152&y.content&&(this._combined[v]=y.combinedData),268435456&y.bg&&(this._extendedAttrs[v]=y.extended),this._data[3*v+0]=y.content,this._data[3*v+1]=y.fg,this._data[3*v+2]=y.bg}setCellFromCodepoint(v,y,S,_){268435456&_.bg&&(this._extendedAttrs[v]=_.extended),this._data[3*v+0]=y|S<<22,this._data[3*v+1]=_.fg,this._data[3*v+2]=_.bg}addCodepointToCell(v,y,S){let _=this._data[3*v+0];2097152&_?this._combined[v]+=(0,m.stringFromCodePoint)(y):2097151&_?(this._combined[v]=(0,m.stringFromCodePoint)(2097151&_)+(0,m.stringFromCodePoint)(y),_&=-2097152,_|=2097152):_=y|4194304,S&&(_&=-12582913,_|=S<<22),this._data[3*v+0]=_}insertCells(v,y,S){if((v%=this.length)&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,S),y<this.length-v){const _=new g.CellData;for(let k=this.length-v-y-1;k>=0;--k)this.setCell(v+y+k,this.loadCell(v+k,_));for(let k=0;k<y;++k)this.setCell(v+k,S)}else for(let _=v;_<this.length;++_)this.setCell(_,S);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,S)}deleteCells(v,y,S){if(v%=this.length,y<this.length-v){const _=new g.CellData;for(let k=0;k<this.length-v-y;++k)this.setCell(v+k,this.loadCell(v+y+k,_));for(let k=this.length-y;k<this.length;++k)this.setCell(k,S)}else for(let _=v;_<this.length;++_)this.setCell(_,S);v&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,S),this.getWidth(v)!==0||this.hasContent(v)||this.setCellFromCodepoint(v,0,1,S)}replaceCells(v,y,S,_=!1){if(_)for(v&&this.getWidth(v-1)===2&&!this.isProtected(v-1)&&this.setCellFromCodepoint(v-1,0,1,S),y<this.length&&this.getWidth(y-1)===2&&!this.isProtected(y)&&this.setCellFromCodepoint(y,0,1,S);v<y&&v<this.length;)this.isProtected(v)||this.setCell(v,S),v++;else for(v&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,S),y<this.length&&this.getWidth(y-1)===2&&this.setCellFromCodepoint(y,0,1,S);v<y&&v<this.length;)this.setCell(v++,S)}resize(v,y){if(v===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const S=3*v;if(v>this.length){if(this._data.buffer.byteLength>=4*S)this._data=new Uint32Array(this._data.buffer,0,S);else{const _=new Uint32Array(S);_.set(this._data),this._data=_}for(let _=this.length;_<v;++_)this.setCell(_,y)}else{this._data=this._data.subarray(0,S);const _=Object.keys(this._combined);for(let D=0;D<_.length;D++){const T=parseInt(_[D],10);T>=v&&delete this._combined[T]}const k=Object.keys(this._extendedAttrs);for(let D=0;D<k.length;D++){const T=parseInt(k[D],10);T>=v&&delete this._extendedAttrs[T]}}return this.length=v,4*S*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const v=new Uint32Array(this._data.length);return v.set(this._data),this._data=v,1}return 0}fill(v,y=!1){if(y)for(let S=0;S<this.length;++S)this.isProtected(S)||this.setCell(S,v);else{this._combined={},this._extendedAttrs={};for(let S=0;S<this.length;++S)this.setCell(S,v)}}copyFrom(v){this.length!==v.length?this._data=new Uint32Array(v._data):this._data.set(v._data),this.length=v.length,this._combined={};for(const y in v._combined)this._combined[y]=v._combined[y];this._extendedAttrs={};for(const y in v._extendedAttrs)this._extendedAttrs[y]=v._extendedAttrs[y];this.isWrapped=v.isWrapped}clone(){const v=new w(0);v._data=new Uint32Array(this._data),v.length=this.length;for(const y in this._combined)v._combined[y]=this._combined[y];for(const y in this._extendedAttrs)v._extendedAttrs[y]=this._extendedAttrs[y];return v.isWrapped=this.isWrapped,v}getTrimmedLength(){for(let v=this.length-1;v>=0;--v)if(4194303&this._data[3*v+0])return v+(this._data[3*v+0]>>22);return 0}getNoBgTrimmedLength(){for(let v=this.length-1;v>=0;--v)if(4194303&this._data[3*v+0]||50331648&this._data[3*v+2])return v+(this._data[3*v+0]>>22);return 0}copyCellsFrom(v,y,S,_,k){const D=v._data;if(k)for(let R=_-1;R>=0;R--){for(let N=0;N<3;N++)this._data[3*(S+R)+N]=D[3*(y+R)+N];268435456&D[3*(y+R)+2]&&(this._extendedAttrs[S+R]=v._extendedAttrs[y+R])}else for(let R=0;R<_;R++){for(let N=0;N<3;N++)this._data[3*(S+R)+N]=D[3*(y+R)+N];268435456&D[3*(y+R)+2]&&(this._extendedAttrs[S+R]=v._extendedAttrs[y+R])}const T=Object.keys(v._combined);for(let R=0;R<T.length;R++){const N=parseInt(T[R],10);N>=y&&(this._combined[N-y+S]=v._combined[N])}}translateToString(v,y,S,_){y=y??0,S=S??this.length,v&&(S=Math.min(S,this.getTrimmedLength())),_&&(_.length=0);let k="";for(;y<S;){const D=this._data[3*y+0],T=2097151&D,R=2097152&D?this._combined[y]:T?(0,m.stringFromCodePoint)(T):d.WHITESPACE_CELL_CHAR;if(k+=R,_)for(let N=0;N<R.length;++N)_.push(y);y+=D>>22||1}return _&&_.push(y),k}}o.BufferLine=w},4841:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.getRangeLength=void 0,o.getRangeLength=function(u,f){if(u.start.y>u.end.y)throw new Error(`Buffer range end (${u.end.x}, ${u.end.y}) cannot be before start (${u.start.x}, ${u.start.y})`);return f*(u.end.y-u.start.y)+(u.end.x-u.start.x+1)}},4634:(c,o)=>{function u(f,g,d){if(g===f.length-1)return f[g].getTrimmedLength();const m=!f[g].hasContent(d-1)&&f[g].getWidth(d-1)===1,b=f[g+1].getWidth(0)===2;return m&&b?d-1:d}Object.defineProperty(o,"__esModule",{value:!0}),o.getWrappedLineTrimmedLength=o.reflowSmallerGetNewLineLengths=o.reflowLargerApplyNewLayout=o.reflowLargerCreateNewLayout=o.reflowLargerGetLinesToRemove=void 0,o.reflowLargerGetLinesToRemove=function(f,g,d,m,b){const w=[];for(let C=0;C<f.length-1;C++){let v=C,y=f.get(++v);if(!y.isWrapped)continue;const S=[f.get(C)];for(;v<f.length&&y.isWrapped;)S.push(y),y=f.get(++v);if(m>=C&&m<v){C+=S.length-1;continue}let _=0,k=u(S,_,g),D=1,T=0;for(;D<S.length;){const N=u(S,D,g),L=N-T,I=d-k,z=Math.min(L,I);S[_].copyCellsFrom(S[D],T,k,z,!1),k+=z,k===d&&(_++,k=0),T+=z,T===N&&(D++,T=0),k===0&&_!==0&&S[_-1].getWidth(d-1)===2&&(S[_].copyCellsFrom(S[_-1],d-1,k++,1,!1),S[_-1].setCell(d-1,b))}S[_].replaceCells(k,d,b);let R=0;for(let N=S.length-1;N>0&&(N>_||S[N].getTrimmedLength()===0);N--)R++;R>0&&(w.push(C+S.length-R),w.push(R)),C+=S.length-1}return w},o.reflowLargerCreateNewLayout=function(f,g){const d=[];let m=0,b=g[m],w=0;for(let C=0;C<f.length;C++)if(b===C){const v=g[++m];f.onDeleteEmitter.fire({index:C-w,amount:v}),C+=v-1,w+=v,b=g[++m]}else d.push(C);return{layout:d,countRemoved:w}},o.reflowLargerApplyNewLayout=function(f,g){const d=[];for(let m=0;m<g.length;m++)d.push(f.get(g[m]));for(let m=0;m<d.length;m++)f.set(m,d[m]);f.length=g.length},o.reflowSmallerGetNewLineLengths=function(f,g,d){const m=[],b=f.map(((y,S)=>u(f,S,g))).reduce(((y,S)=>y+S));let w=0,C=0,v=0;for(;v<b;){if(b-v<d){m.push(b-v);break}w+=d;const y=u(f,C,g);w>y&&(w-=y,C++);const S=f[C].getWidth(w-1)===2;S&&w--;const _=S?d-1:d;m.push(_),v+=_}return m},o.getWrappedLineTrimmedLength=u},5295:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferSet=void 0;const f=u(8460),g=u(844),d=u(9092);class m extends g.Disposable{constructor(w,C){super(),this._optionsService=w,this._bufferService=C,this._onBufferActivate=this.register(new f.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new d.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new d.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(w){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(w),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(w,C){this._normal.resize(w,C),this._alt.resize(w,C),this.setupTabStops(w)}setupTabStops(w){this._normal.setupTabStops(w),this._alt.setupTabStops(w)}}o.BufferSet=m},511:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CellData=void 0;const f=u(482),g=u(643),d=u(3734);class m extends d.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new d.ExtendedAttrs,this.combinedData=""}static fromCharData(w){const C=new m;return C.setFromCharData(w),C}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,f.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(w){this.fg=w[g.CHAR_DATA_ATTR_INDEX],this.bg=0;let C=!1;if(w[g.CHAR_DATA_CHAR_INDEX].length>2)C=!0;else if(w[g.CHAR_DATA_CHAR_INDEX].length===2){const v=w[g.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=v&&v<=56319){const y=w[g.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=y&&y<=57343?this.content=1024*(v-55296)+y-56320+65536|w[g.CHAR_DATA_WIDTH_INDEX]<<22:C=!0}else C=!0}else this.content=w[g.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[g.CHAR_DATA_WIDTH_INDEX]<<22;C&&(this.combinedData=w[g.CHAR_DATA_CHAR_INDEX],this.content=2097152|w[g.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}o.CellData=m},643:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.WHITESPACE_CELL_CODE=o.WHITESPACE_CELL_WIDTH=o.WHITESPACE_CELL_CHAR=o.NULL_CELL_CODE=o.NULL_CELL_WIDTH=o.NULL_CELL_CHAR=o.CHAR_DATA_CODE_INDEX=o.CHAR_DATA_WIDTH_INDEX=o.CHAR_DATA_CHAR_INDEX=o.CHAR_DATA_ATTR_INDEX=o.DEFAULT_EXT=o.DEFAULT_ATTR=o.DEFAULT_COLOR=void 0,o.DEFAULT_COLOR=0,o.DEFAULT_ATTR=256|o.DEFAULT_COLOR<<9,o.DEFAULT_EXT=0,o.CHAR_DATA_ATTR_INDEX=0,o.CHAR_DATA_CHAR_INDEX=1,o.CHAR_DATA_WIDTH_INDEX=2,o.CHAR_DATA_CODE_INDEX=3,o.NULL_CELL_CHAR="",o.NULL_CELL_WIDTH=1,o.NULL_CELL_CODE=0,o.WHITESPACE_CELL_CHAR=" ",o.WHITESPACE_CELL_WIDTH=1,o.WHITESPACE_CELL_CODE=32},4863:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Marker=void 0;const f=u(8460),g=u(844);class d{get id(){return this._id}constructor(b){this.line=b,this.isDisposed=!1,this._disposables=[],this._id=d._nextId++,this._onDispose=this.register(new f.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,g.disposeArray)(this._disposables),this._disposables.length=0)}register(b){return this._disposables.push(b),b}}o.Marker=d,d._nextId=1},7116:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DEFAULT_CHARSET=o.CHARSETS=void 0,o.CHARSETS={},o.DEFAULT_CHARSET=o.CHARSETS.B,o.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},o.CHARSETS.A={"#":"£"},o.CHARSETS.B=void 0,o.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},o.CHARSETS.C=o.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},o.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},o.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},o.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},o.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},o.CHARSETS.E=o.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},o.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},o.CHARSETS.H=o.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},o.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(c,o)=>{var u,f,g;Object.defineProperty(o,"__esModule",{value:!0}),o.C1_ESCAPED=o.C1=o.C0=void 0,(function(d){d.NUL="\0",d.SOH="",d.STX="",d.ETX="",d.EOT="",d.ENQ="",d.ACK="",d.BEL="\x07",d.BS="\b",d.HT=" ",d.LF=` `,d.VT="\v",d.FF="\f",d.CR="\r",d.SO="",d.SI="",d.DLE="",d.DC1="",d.DC2="",d.DC3="",d.DC4="",d.NAK="",d.SYN="",d.ETB="",d.CAN="",d.EM="",d.SUB="",d.ESC="\x1B",d.FS="",d.GS="",d.RS="",d.US="",d.SP=" ",d.DEL=""})(u||(o.C0=u={})),(function(d){d.PAD="€",d.HOP="",d.BPH="‚",d.NBH="ƒ",d.IND="„",d.NEL="…",d.SSA="†",d.ESA="‡",d.HTS="ˆ",d.HTJ="‰",d.VTS="Š",d.PLD="‹",d.PLU="Œ",d.RI="",d.SS2="Ž",d.SS3="",d.DCS="",d.PU1="‘",d.PU2="’",d.STS="“",d.CCH="”",d.MW="•",d.SPA="–",d.EPA="—",d.SOS="˜",d.SGCI="™",d.SCI="š",d.CSI="›",d.ST="œ",d.OSC="",d.PM="ž",d.APC="Ÿ"})(f||(o.C1=f={})),(function(d){d.ST=`${u.ESC}\\`})(g||(o.C1_ESCAPED=g={}))},7399:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.evaluateKeyboardEvent=void 0;const f=u(2584),g={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};o.evaluateKeyboardEvent=function(d,m,b,w){const C={type:0,cancel:!1,key:void 0},v=(d.shiftKey?1:0)|(d.altKey?2:0)|(d.ctrlKey?4:0)|(d.metaKey?8:0);switch(d.keyCode){case 0:d.key==="UIKeyInputUpArrow"?C.key=m?f.C0.ESC+"OA":f.C0.ESC+"[A":d.key==="UIKeyInputLeftArrow"?C.key=m?f.C0.ESC+"OD":f.C0.ESC+"[D":d.key==="UIKeyInputRightArrow"?C.key=m?f.C0.ESC+"OC":f.C0.ESC+"[C":d.key==="UIKeyInputDownArrow"&&(C.key=m?f.C0.ESC+"OB":f.C0.ESC+"[B");break;case 8:C.key=d.ctrlKey?"\b":f.C0.DEL,d.altKey&&(C.key=f.C0.ESC+C.key);break;case 9:if(d.shiftKey){C.key=f.C0.ESC+"[Z";break}C.key=f.C0.HT,C.cancel=!0;break;case 13:C.key=d.altKey?f.C0.ESC+f.C0.CR:f.C0.CR,C.cancel=!0;break;case 27:C.key=f.C0.ESC,d.altKey&&(C.key=f.C0.ESC+f.C0.ESC),C.cancel=!0;break;case 37:if(d.metaKey)break;v?(C.key=f.C0.ESC+"[1;"+(v+1)+"D",C.key===f.C0.ESC+"[1;3D"&&(C.key=f.C0.ESC+(b?"b":"[1;5D"))):C.key=m?f.C0.ESC+"OD":f.C0.ESC+"[D";break;case 39:if(d.metaKey)break;v?(C.key=f.C0.ESC+"[1;"+(v+1)+"C",C.key===f.C0.ESC+"[1;3C"&&(C.key=f.C0.ESC+(b?"f":"[1;5C"))):C.key=m?f.C0.ESC+"OC":f.C0.ESC+"[C";break;case 38:if(d.metaKey)break;v?(C.key=f.C0.ESC+"[1;"+(v+1)+"A",b||C.key!==f.C0.ESC+"[1;3A"||(C.key=f.C0.ESC+"[1;5A")):C.key=m?f.C0.ESC+"OA":f.C0.ESC+"[A";break;case 40:if(d.metaKey)break;v?(C.key=f.C0.ESC+"[1;"+(v+1)+"B",b||C.key!==f.C0.ESC+"[1;3B"||(C.key=f.C0.ESC+"[1;5B")):C.key=m?f.C0.ESC+"OB":f.C0.ESC+"[B";break;case 45:d.shiftKey||d.ctrlKey||(C.key=f.C0.ESC+"[2~");break;case 46:C.key=v?f.C0.ESC+"[3;"+(v+1)+"~":f.C0.ESC+"[3~";break;case 36:C.key=v?f.C0.ESC+"[1;"+(v+1)+"H":m?f.C0.ESC+"OH":f.C0.ESC+"[H";break;case 35:C.key=v?f.C0.ESC+"[1;"+(v+1)+"F":m?f.C0.ESC+"OF":f.C0.ESC+"[F";break;case 33:d.shiftKey?C.type=2:d.ctrlKey?C.key=f.C0.ESC+"[5;"+(v+1)+"~":C.key=f.C0.ESC+"[5~";break;case 34:d.shiftKey?C.type=3:d.ctrlKey?C.key=f.C0.ESC+"[6;"+(v+1)+"~":C.key=f.C0.ESC+"[6~";break;case 112:C.key=v?f.C0.ESC+"[1;"+(v+1)+"P":f.C0.ESC+"OP";break;case 113:C.key=v?f.C0.ESC+"[1;"+(v+1)+"Q":f.C0.ESC+"OQ";break;case 114:C.key=v?f.C0.ESC+"[1;"+(v+1)+"R":f.C0.ESC+"OR";break;case 115:C.key=v?f.C0.ESC+"[1;"+(v+1)+"S":f.C0.ESC+"OS";break;case 116:C.key=v?f.C0.ESC+"[15;"+(v+1)+"~":f.C0.ESC+"[15~";break;case 117:C.key=v?f.C0.ESC+"[17;"+(v+1)+"~":f.C0.ESC+"[17~";break;case 118:C.key=v?f.C0.ESC+"[18;"+(v+1)+"~":f.C0.ESC+"[18~";break;case 119:C.key=v?f.C0.ESC+"[19;"+(v+1)+"~":f.C0.ESC+"[19~";break;case 120:C.key=v?f.C0.ESC+"[20;"+(v+1)+"~":f.C0.ESC+"[20~";break;case 121:C.key=v?f.C0.ESC+"[21;"+(v+1)+"~":f.C0.ESC+"[21~";break;case 122:C.key=v?f.C0.ESC+"[23;"+(v+1)+"~":f.C0.ESC+"[23~";break;case 123:C.key=v?f.C0.ESC+"[24;"+(v+1)+"~":f.C0.ESC+"[24~";break;default:if(!d.ctrlKey||d.shiftKey||d.altKey||d.metaKey)if(b&&!w||!d.altKey||d.metaKey)!b||d.altKey||d.ctrlKey||d.shiftKey||!d.metaKey?d.key&&!d.ctrlKey&&!d.altKey&&!d.metaKey&&d.keyCode>=48&&d.key.length===1?C.key=d.key:d.key&&d.ctrlKey&&(d.key==="_"&&(C.key=f.C0.US),d.key==="@"&&(C.key=f.C0.NUL)):d.keyCode===65&&(C.type=1);else{const y=g[d.keyCode],S=y==null?void 0:y[d.shiftKey?1:0];if(S)C.key=f.C0.ESC+S;else if(d.keyCode>=65&&d.keyCode<=90){const _=d.ctrlKey?d.keyCode-64:d.keyCode+32;let k=String.fromCharCode(_);d.shiftKey&&(k=k.toUpperCase()),C.key=f.C0.ESC+k}else if(d.keyCode===32)C.key=f.C0.ESC+(d.ctrlKey?f.C0.NUL:" ");else if(d.key==="Dead"&&d.code.startsWith("Key")){let _=d.code.slice(3,4);d.shiftKey||(_=_.toLowerCase()),C.key=f.C0.ESC+_,C.cancel=!0}}else d.keyCode>=65&&d.keyCode<=90?C.key=String.fromCharCode(d.keyCode-64):d.keyCode===32?C.key=f.C0.NUL:d.keyCode>=51&&d.keyCode<=55?C.key=String.fromCharCode(d.keyCode-51+27):d.keyCode===56?C.key=f.C0.DEL:d.keyCode===219?C.key=f.C0.ESC:d.keyCode===220?C.key=f.C0.FS:d.keyCode===221&&(C.key=f.C0.GS)}return C}},482:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Utf8ToUtf32=o.StringToUtf32=o.utf32ToString=o.stringFromCodePoint=void 0,o.stringFromCodePoint=function(u){return u>65535?(u-=65536,String.fromCharCode(55296+(u>>10))+String.fromCharCode(u%1024+56320)):String.fromCharCode(u)},o.utf32ToString=function(u,f=0,g=u.length){let d="";for(let m=f;m<g;++m){let b=u[m];b>65535?(b-=65536,d+=String.fromCharCode(55296+(b>>10))+String.fromCharCode(b%1024+56320)):d+=String.fromCharCode(b)}return d},o.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(u,f){const g=u.length;if(!g)return 0;let d=0,m=0;if(this._interim){const b=u.charCodeAt(m++);56320<=b&&b<=57343?f[d++]=1024*(this._interim-55296)+b-56320+65536:(f[d++]=this._interim,f[d++]=b),this._interim=0}for(let b=m;b<g;++b){const w=u.charCodeAt(b);if(55296<=w&&w<=56319){if(++b>=g)return this._interim=w,d;const C=u.charCodeAt(b);56320<=C&&C<=57343?f[d++]=1024*(w-55296)+C-56320+65536:(f[d++]=w,f[d++]=C)}else w!==65279&&(f[d++]=w)}return d}},o.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(u,f){const g=u.length;if(!g)return 0;let d,m,b,w,C=0,v=0,y=0;if(this.interim[0]){let k=!1,D=this.interim[0];D&=(224&D)==192?31:(240&D)==224?15:7;let T,R=0;for(;(T=63&this.interim[++R])&&R<4;)D<<=6,D|=T;const N=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,L=N-R;for(;y<L;){if(y>=g)return 0;if(T=u[y++],(192&T)!=128){y--,k=!0;break}this.interim[R++]=T,D<<=6,D|=63&T}k||(N===2?D<128?y--:f[C++]=D:N===3?D<2048||D>=55296&&D<=57343||D===65279||(f[C++]=D):D<65536||D>1114111||(f[C++]=D)),this.interim.fill(0)}const S=g-4;let _=y;for(;_<g;){for(;!(!(_<S)||128&(d=u[_])||128&(m=u[_+1])||128&(b=u[_+2])||128&(w=u[_+3]));)f[C++]=d,f[C++]=m,f[C++]=b,f[C++]=w,_+=4;if(d=u[_++],d<128)f[C++]=d;else if((224&d)==192){if(_>=g)return this.interim[0]=d,C;if(m=u[_++],(192&m)!=128){_--;continue}if(v=(31&d)<<6|63&m,v<128){_--;continue}f[C++]=v}else if((240&d)==224){if(_>=g)return this.interim[0]=d,C;if(m=u[_++],(192&m)!=128){_--;continue}if(_>=g)return this.interim[0]=d,this.interim[1]=m,C;if(b=u[_++],(192&b)!=128){_--;continue}if(v=(15&d)<<12|(63&m)<<6|63&b,v<2048||v>=55296&&v<=57343||v===65279)continue;f[C++]=v}else if((248&d)==240){if(_>=g)return this.interim[0]=d,C;if(m=u[_++],(192&m)!=128){_--;continue}if(_>=g)return this.interim[0]=d,this.interim[1]=m,C;if(b=u[_++],(192&b)!=128){_--;continue}if(_>=g)return this.interim[0]=d,this.interim[1]=m,this.interim[2]=b,C;if(w=u[_++],(192&w)!=128){_--;continue}if(v=(7&d)<<18|(63&m)<<12|(63&b)<<6|63&w,v<65536||v>1114111)continue;f[C++]=v}}return C}}},225:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeV6=void 0;const f=u(1480),g=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],d=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let m;o.UnicodeV6=class{constructor(){if(this.version="6",!m){m=new Uint8Array(65536),m.fill(1),m[0]=0,m.fill(0,1,32),m.fill(0,127,160),m.fill(2,4352,4448),m[9001]=2,m[9002]=2,m.fill(2,11904,42192),m[12351]=1,m.fill(2,44032,55204),m.fill(2,63744,64256),m.fill(2,65040,65050),m.fill(2,65072,65136),m.fill(2,65280,65377),m.fill(2,65504,65511);for(let b=0;b<g.length;++b)m.fill(0,g[b][0],g[b][1]+1)}}wcwidth(b){return b<32?0:b<127?1:b<65536?m[b]:(function(w,C){let v,y=0,S=C.length-1;if(w<C[0][0]||w>C[S][1])return!1;for(;S>=y;)if(v=y+S>>1,w>C[v][1])y=v+1;else{if(!(w<C[v][0]))return!0;S=v-1}return!1})(b,d)?0:b>=131072&&b<=196605||b>=196608&&b<=262141?2:1}charProperties(b,w){let C=this.wcwidth(b),v=C===0&&w!==0;if(v){const y=f.UnicodeService.extractWidth(w);y===0?v=!1:y>C&&(C=y)}return f.UnicodeService.createPropertyValue(0,C,v)}}},5981:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.WriteBuffer=void 0;const f=u(8460),g=u(844);class d extends g.Disposable{constructor(b){super(),this._action=b,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new f.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(b,w){if(w!==void 0&&this._syncCalls>w)return void(this._syncCalls=0);if(this._pendingData+=b.length,this._writeBuffer.push(b),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let C;for(this._isSyncWriting=!0;C=this._writeBuffer.shift();){this._action(C);const v=this._callbacks.shift();v&&v()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(b,w){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=b.length,this._writeBuffer.push(b),this._callbacks.push(w),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=b.length,this._writeBuffer.push(b),this._callbacks.push(w)}_innerWrite(b=0,w=!0){const C=b||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const v=this._writeBuffer[this._bufferOffset],y=this._action(v,w);if(y){const _=k=>Date.now()-C>=12?setTimeout((()=>this._innerWrite(0,k))):this._innerWrite(C,k);return void y.catch((k=>(queueMicrotask((()=>{throw k})),Promise.resolve(!1)))).then(_)}const S=this._callbacks[this._bufferOffset];if(S&&S(),this._bufferOffset++,this._pendingData-=v.length,Date.now()-C>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}o.WriteBuffer=d},5941:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.toRgbString=o.parseColor=void 0;const u=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,f=/^[\da-f]+$/;function g(d,m){const b=d.toString(16),w=b.length<2?"0"+b:b;switch(m){case 4:return b[0];case 8:return w;case 12:return(w+w).slice(0,3);default:return w+w}}o.parseColor=function(d){if(!d)return;let m=d.toLowerCase();if(m.indexOf("rgb:")===0){m=m.slice(4);const b=u.exec(m);if(b){const w=b[1]?15:b[4]?255:b[7]?4095:65535;return[Math.round(parseInt(b[1]||b[4]||b[7]||b[10],16)/w*255),Math.round(parseInt(b[2]||b[5]||b[8]||b[11],16)/w*255),Math.round(parseInt(b[3]||b[6]||b[9]||b[12],16)/w*255)]}}else if(m.indexOf("#")===0&&(m=m.slice(1),f.exec(m)&&[3,6,9,12].includes(m.length))){const b=m.length/3,w=[0,0,0];for(let C=0;C<3;++C){const v=parseInt(m.slice(b*C,b*C+b),16);w[C]=b===1?v<<4:b===2?v:b===3?v>>4:v>>8}return w}},o.toRgbString=function(d,m=16){const[b,w,C]=d;return`rgb:${g(b,m)}/${g(w,m)}/${g(C,m)}`}},5770:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.PAYLOAD_LIMIT=void 0,o.PAYLOAD_LIMIT=1e7},6351:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DcsHandler=o.DcsParser=void 0;const f=u(482),g=u(8742),d=u(5770),m=[];o.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=m,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=m}registerHandler(w,C){this._handlers[w]===void 0&&(this._handlers[w]=[]);const v=this._handlers[w];return v.push(C),{dispose:()=>{const y=v.indexOf(C);y!==-1&&v.splice(y,1)}}}clearHandler(w){this._handlers[w]&&delete this._handlers[w]}setHandlerFallback(w){this._handlerFb=w}reset(){if(this._active.length)for(let w=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;w>=0;--w)this._active[w].unhook(!1);this._stack.paused=!1,this._active=m,this._ident=0}hook(w,C){if(this.reset(),this._ident=w,this._active=this._handlers[w]||m,this._active.length)for(let v=this._active.length-1;v>=0;v--)this._active[v].hook(C);else this._handlerFb(this._ident,"HOOK",C)}put(w,C,v){if(this._active.length)for(let y=this._active.length-1;y>=0;y--)this._active[y].put(w,C,v);else this._handlerFb(this._ident,"PUT",(0,f.utf32ToString)(w,C,v))}unhook(w,C=!0){if(this._active.length){let v=!1,y=this._active.length-1,S=!1;if(this._stack.paused&&(y=this._stack.loopPosition-1,v=C,S=this._stack.fallThrough,this._stack.paused=!1),!S&&v===!1){for(;y>=0&&(v=this._active[y].unhook(w),v!==!0);y--)if(v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=y,this._stack.fallThrough=!1,v;y--}for(;y>=0;y--)if(v=this._active[y].unhook(!1),v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=y,this._stack.fallThrough=!0,v}else this._handlerFb(this._ident,"UNHOOK",w);this._active=m,this._ident=0}};const b=new g.Params;b.addParam(0),o.DcsHandler=class{constructor(w){this._handler=w,this._data="",this._params=b,this._hitLimit=!1}hook(w){this._params=w.length>1||w.params[0]?w.clone():b,this._data="",this._hitLimit=!1}put(w,C,v){this._hitLimit||(this._data+=(0,f.utf32ToString)(w,C,v),this._data.length>d.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(w){let C=!1;if(this._hitLimit)C=!1;else if(w&&(C=this._handler(this._data,this._params),C instanceof Promise))return C.then((v=>(this._params=b,this._data="",this._hitLimit=!1,v)));return this._params=b,this._data="",this._hitLimit=!1,C}}},2015:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.EscapeSequenceParser=o.VT500_TRANSITION_TABLE=o.TransitionTable=void 0;const f=u(844),g=u(8742),d=u(6242),m=u(6351);class b{constructor(y){this.table=new Uint8Array(y)}setDefault(y,S){this.table.fill(y<<4|S)}add(y,S,_,k){this.table[S<<8|y]=_<<4|k}addMany(y,S,_,k){for(let D=0;D<y.length;D++)this.table[S<<8|y[D]]=_<<4|k}}o.TransitionTable=b;const w=160;o.VT500_TRANSITION_TABLE=(function(){const v=new b(4095),y=Array.apply(null,Array(256)).map(((R,N)=>N)),S=(R,N)=>y.slice(R,N),_=S(32,127),k=S(0,24);k.push(25),k.push.apply(k,S(28,32));const D=S(0,14);let T;for(T in v.setDefault(1,0),v.addMany(_,0,2,0),D)v.addMany([24,26,153,154],T,3,0),v.addMany(S(128,144),T,3,0),v.addMany(S(144,152),T,3,0),v.add(156,T,0,0),v.add(27,T,11,1),v.add(157,T,4,8),v.addMany([152,158,159],T,0,7),v.add(155,T,11,3),v.add(144,T,11,9);return v.addMany(k,0,3,0),v.addMany(k,1,3,1),v.add(127,1,0,1),v.addMany(k,8,0,8),v.addMany(k,3,3,3),v.add(127,3,0,3),v.addMany(k,4,3,4),v.add(127,4,0,4),v.addMany(k,6,3,6),v.addMany(k,5,3,5),v.add(127,5,0,5),v.addMany(k,2,3,2),v.add(127,2,0,2),v.add(93,1,4,8),v.addMany(_,8,5,8),v.add(127,8,5,8),v.addMany([156,27,24,26,7],8,6,0),v.addMany(S(28,32),8,0,8),v.addMany([88,94,95],1,0,7),v.addMany(_,7,0,7),v.addMany(k,7,0,7),v.add(156,7,0,0),v.add(127,7,0,7),v.add(91,1,11,3),v.addMany(S(64,127),3,7,0),v.addMany(S(48,60),3,8,4),v.addMany([60,61,62,63],3,9,4),v.addMany(S(48,60),4,8,4),v.addMany(S(64,127),4,7,0),v.addMany([60,61,62,63],4,0,6),v.addMany(S(32,64),6,0,6),v.add(127,6,0,6),v.addMany(S(64,127),6,0,0),v.addMany(S(32,48),3,9,5),v.addMany(S(32,48),5,9,5),v.addMany(S(48,64),5,0,6),v.addMany(S(64,127),5,7,0),v.addMany(S(32,48),4,9,5),v.addMany(S(32,48),1,9,2),v.addMany(S(32,48),2,9,2),v.addMany(S(48,127),2,10,0),v.addMany(S(48,80),1,10,0),v.addMany(S(81,88),1,10,0),v.addMany([89,90,92],1,10,0),v.addMany(S(96,127),1,10,0),v.add(80,1,11,9),v.addMany(k,9,0,9),v.add(127,9,0,9),v.addMany(S(28,32),9,0,9),v.addMany(S(32,48),9,9,12),v.addMany(S(48,60),9,8,10),v.addMany([60,61,62,63],9,9,10),v.addMany(k,11,0,11),v.addMany(S(32,128),11,0,11),v.addMany(S(28,32),11,0,11),v.addMany(k,10,0,10),v.add(127,10,0,10),v.addMany(S(28,32),10,0,10),v.addMany(S(48,60),10,8,10),v.addMany([60,61,62,63],10,0,11),v.addMany(S(32,48),10,9,12),v.addMany(k,12,0,12),v.add(127,12,0,12),v.addMany(S(28,32),12,0,12),v.addMany(S(32,48),12,9,12),v.addMany(S(48,64),12,0,11),v.addMany(S(64,127),12,12,13),v.addMany(S(64,127),10,12,13),v.addMany(S(64,127),9,12,13),v.addMany(k,13,13,13),v.addMany(_,13,13,13),v.add(127,13,0,13),v.addMany([27,156,24,26],13,14,0),v.add(w,0,2,0),v.add(w,8,5,8),v.add(w,6,0,6),v.add(w,11,0,11),v.add(w,13,13,13),v})();class C extends f.Disposable{constructor(y=o.VT500_TRANSITION_TABLE){super(),this._transitions=y,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new g.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(S,_,k)=>{},this._executeHandlerFb=S=>{},this._csiHandlerFb=(S,_)=>{},this._escHandlerFb=S=>{},this._errorHandlerFb=S=>S,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,f.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new d.OscParser),this._dcsParser=this.register(new m.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(y,S=[64,126]){let _=0;if(y.prefix){if(y.prefix.length>1)throw new Error("only one byte as prefix supported");if(_=y.prefix.charCodeAt(0),_&&60>_||_>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(y.intermediates){if(y.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let D=0;D<y.intermediates.length;++D){const T=y.intermediates.charCodeAt(D);if(32>T||T>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");_<<=8,_|=T}}if(y.final.length!==1)throw new Error("final must be a single byte");const k=y.final.charCodeAt(0);if(S[0]>k||k>S[1])throw new Error(`final must be in range ${S[0]} .. ${S[1]}`);return _<<=8,_|=k,_}identToString(y){const S=[];for(;y;)S.push(String.fromCharCode(255&y)),y>>=8;return S.reverse().join("")}setPrintHandler(y){this._printHandler=y}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(y,S){const _=this._identifier(y,[48,126]);this._escHandlers[_]===void 0&&(this._escHandlers[_]=[]);const k=this._escHandlers[_];return k.push(S),{dispose:()=>{const D=k.indexOf(S);D!==-1&&k.splice(D,1)}}}clearEscHandler(y){this._escHandlers[this._identifier(y,[48,126])]&&delete this._escHandlers[this._identifier(y,[48,126])]}setEscHandlerFallback(y){this._escHandlerFb=y}setExecuteHandler(y,S){this._executeHandlers[y.charCodeAt(0)]=S}clearExecuteHandler(y){this._executeHandlers[y.charCodeAt(0)]&&delete this._executeHandlers[y.charCodeAt(0)]}setExecuteHandlerFallback(y){this._executeHandlerFb=y}registerCsiHandler(y,S){const _=this._identifier(y);this._csiHandlers[_]===void 0&&(this._csiHandlers[_]=[]);const k=this._csiHandlers[_];return k.push(S),{dispose:()=>{const D=k.indexOf(S);D!==-1&&k.splice(D,1)}}}clearCsiHandler(y){this._csiHandlers[this._identifier(y)]&&delete this._csiHandlers[this._identifier(y)]}setCsiHandlerFallback(y){this._csiHandlerFb=y}registerDcsHandler(y,S){return this._dcsParser.registerHandler(this._identifier(y),S)}clearDcsHandler(y){this._dcsParser.clearHandler(this._identifier(y))}setDcsHandlerFallback(y){this._dcsParser.setHandlerFallback(y)}registerOscHandler(y,S){return this._oscParser.registerHandler(y,S)}clearOscHandler(y){this._oscParser.clearHandler(y)}setOscHandlerFallback(y){this._oscParser.setHandlerFallback(y)}setErrorHandler(y){this._errorHandler=y}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(y,S,_,k,D){this._parseStack.state=y,this._parseStack.handlers=S,this._parseStack.handlerPos=_,this._parseStack.transition=k,this._parseStack.chunkPos=D}parse(y,S,_){let k,D=0,T=0,R=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,R=this._parseStack.chunkPos+1;else{if(_===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const N=this._parseStack.handlers;let L=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(_===!1&&L>-1){for(;L>=0&&(k=N[L](this._params),k!==!0);L--)if(k instanceof Promise)return this._parseStack.handlerPos=L,k}this._parseStack.handlers=[];break;case 4:if(_===!1&&L>-1){for(;L>=0&&(k=N[L](),k!==!0);L--)if(k instanceof Promise)return this._parseStack.handlerPos=L,k}this._parseStack.handlers=[];break;case 6:if(D=y[this._parseStack.chunkPos],k=this._dcsParser.unhook(D!==24&&D!==26,_),k)return k;D===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(D=y[this._parseStack.chunkPos],k=this._oscParser.end(D!==24&&D!==26,_),k)return k;D===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,R=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let N=R;N<S;++N){switch(D=y[N],T=this._transitions.table[this.currentState<<8|(D<160?D:w)],T>>4){case 2:for(let P=N+1;;++P){if(P>=S||(D=y[P])<32||D>126&&D<w){this._printHandler(y,N,P),N=P-1;break}if(++P>=S||(D=y[P])<32||D>126&&D<w){this._printHandler(y,N,P),N=P-1;break}if(++P>=S||(D=y[P])<32||D>126&&D<w){this._printHandler(y,N,P),N=P-1;break}if(++P>=S||(D=y[P])<32||D>126&&D<w){this._printHandler(y,N,P),N=P-1;break}}break;case 3:this._executeHandlers[D]?this._executeHandlers[D]():this._executeHandlerFb(D),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:N,code:D,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const L=this._csiHandlers[this._collect<<8|D];let I=L?L.length-1:-1;for(;I>=0&&(k=L[I](this._params),k!==!0);I--)if(k instanceof Promise)return this._preserveStack(3,L,I,T,N),k;I<0&&this._csiHandlerFb(this._collect<<8|D,this._params),this.precedingJoinState=0;break;case 8:do switch(D){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(D-48)}while(++N<S&&(D=y[N])>47&&D<60);N--;break;case 9:this._collect<<=8,this._collect|=D;break;case 10:const z=this._escHandlers[this._collect<<8|D];let q=z?z.length-1:-1;for(;q>=0&&(k=z[q](),k!==!0);q--)if(k instanceof Promise)return this._preserveStack(4,z,q,T,N),k;q<0&&this._escHandlerFb(this._collect<<8|D),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|D,this._params);break;case 13:for(let P=N+1;;++P)if(P>=S||(D=y[P])===24||D===26||D===27||D>127&&D<w){this._dcsParser.put(y,N,P),N=P-1;break}break;case 14:if(k=this._dcsParser.unhook(D!==24&&D!==26),k)return this._preserveStack(6,[],0,T,N),k;D===27&&(T|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let P=N+1;;P++)if(P>=S||(D=y[P])<32||D>127&&D<w){this._oscParser.put(y,N,P),N=P-1;break}break;case 6:if(k=this._oscParser.end(D!==24&&D!==26),k)return this._preserveStack(5,[],0,T,N),k;D===27&&(T|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&T}}}o.EscapeSequenceParser=C},6242:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.OscHandler=o.OscParser=void 0;const f=u(5770),g=u(482),d=[];o.OscParser=class{constructor(){this._state=0,this._active=d,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(m,b){this._handlers[m]===void 0&&(this._handlers[m]=[]);const w=this._handlers[m];return w.push(b),{dispose:()=>{const C=w.indexOf(b);C!==-1&&w.splice(C,1)}}}clearHandler(m){this._handlers[m]&&delete this._handlers[m]}setHandlerFallback(m){this._handlerFb=m}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=d}reset(){if(this._state===2)for(let m=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;m>=0;--m)this._active[m].end(!1);this._stack.paused=!1,this._active=d,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||d,this._active.length)for(let m=this._active.length-1;m>=0;m--)this._active[m].start();else this._handlerFb(this._id,"START")}_put(m,b,w){if(this._active.length)for(let C=this._active.length-1;C>=0;C--)this._active[C].put(m,b,w);else this._handlerFb(this._id,"PUT",(0,g.utf32ToString)(m,b,w))}start(){this.reset(),this._state=1}put(m,b,w){if(this._state!==3){if(this._state===1)for(;b<w;){const C=m[b++];if(C===59){this._state=2,this._start();break}if(C<48||57<C)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+C-48}this._state===2&&w-b>0&&this._put(m,b,w)}}end(m,b=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let w=!1,C=this._active.length-1,v=!1;if(this._stack.paused&&(C=this._stack.loopPosition-1,w=b,v=this._stack.fallThrough,this._stack.paused=!1),!v&&w===!1){for(;C>=0&&(w=this._active[C].end(m),w!==!0);C--)if(w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!1,w;C--}for(;C>=0;C--)if(w=this._active[C].end(!1),w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!0,w}else this._handlerFb(this._id,"END",m);this._active=d,this._id=-1,this._state=0}}},o.OscHandler=class{constructor(m){this._handler=m,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(m,b,w){this._hitLimit||(this._data+=(0,g.utf32ToString)(m,b,w),this._data.length>f.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(m){let b=!1;if(this._hitLimit)b=!1;else if(m&&(b=this._handler(this._data),b instanceof Promise))return b.then((w=>(this._data="",this._hitLimit=!1,w)));return this._data="",this._hitLimit=!1,b}}},8742:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Params=void 0;const u=2147483647;class f{static fromArray(d){const m=new f;if(!d.length)return m;for(let b=Array.isArray(d[0])?1:0;b<d.length;++b){const w=d[b];if(Array.isArray(w))for(let C=0;C<w.length;++C)m.addSubParam(w[C]);else m.addParam(w)}return m}constructor(d=32,m=32){if(this.maxLength=d,this.maxSubParamsLength=m,m>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(d),this.length=0,this._subParams=new Int32Array(m),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(d),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const d=new f(this.maxLength,this.maxSubParamsLength);return d.params.set(this.params),d.length=this.length,d._subParams.set(this._subParams),d._subParamsLength=this._subParamsLength,d._subParamsIdx.set(this._subParamsIdx),d._rejectDigits=this._rejectDigits,d._rejectSubDigits=this._rejectSubDigits,d._digitIsSub=this._digitIsSub,d}toArray(){const d=[];for(let m=0;m<this.length;++m){d.push(this.params[m]);const b=this._subParamsIdx[m]>>8,w=255&this._subParamsIdx[m];w-b>0&&d.push(Array.prototype.slice.call(this._subParams,b,w))}return d}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(d){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(d<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=d>u?u:d}}addSubParam(d){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(d<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=d>u?u:d,this._subParamsIdx[this.length-1]++}}hasSubParams(d){return(255&this._subParamsIdx[d])-(this._subParamsIdx[d]>>8)>0}getSubParams(d){const m=this._subParamsIdx[d]>>8,b=255&this._subParamsIdx[d];return b-m>0?this._subParams.subarray(m,b):null}getSubParamsAll(){const d={};for(let m=0;m<this.length;++m){const b=this._subParamsIdx[m]>>8,w=255&this._subParamsIdx[m];w-b>0&&(d[m]=this._subParams.slice(b,w))}return d}addDigit(d){let m;if(this._rejectDigits||!(m=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const b=this._digitIsSub?this._subParams:this.params,w=b[m-1];b[m-1]=~w?Math.min(10*w+d,u):d}}o.Params=f},5741:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.AddonManager=void 0,o.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let u=this._addons.length-1;u>=0;u--)this._addons[u].instance.dispose()}loadAddon(u,f){const g={instance:f,dispose:f.dispose,isDisposed:!1};this._addons.push(g),f.dispose=()=>this._wrappedAddonDispose(g),f.activate(u)}_wrappedAddonDispose(u){if(u.isDisposed)return;let f=-1;for(let g=0;g<this._addons.length;g++)if(this._addons[g]===u){f=g;break}if(f===-1)throw new Error("Could not dispose an addon that has not been loaded");u.isDisposed=!0,u.dispose.apply(u.instance),this._addons.splice(f,1)}}},8771:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferApiView=void 0;const f=u(3785),g=u(511);o.BufferApiView=class{constructor(d,m){this._buffer=d,this.type=m}init(d){return this._buffer=d,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(d){const m=this._buffer.lines.get(d);if(m)return new f.BufferLineApiView(m)}getNullCell(){return new g.CellData}}},3785:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferLineApiView=void 0;const f=u(511);o.BufferLineApiView=class{constructor(g){this._line=g}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(g,d){if(!(g<0||g>=this._line.length))return d?(this._line.loadCell(g,d),d):this._line.loadCell(g,new f.CellData)}translateToString(g,d,m){return this._line.translateToString(g,d,m)}}},8285:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferNamespaceApi=void 0;const f=u(8771),g=u(8460),d=u(844);class m extends d.Disposable{constructor(w){super(),this._core=w,this._onBufferChange=this.register(new g.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new f.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new f.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}o.BufferNamespaceApi=m},7975:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ParserApi=void 0,o.ParserApi=class{constructor(u){this._core=u}registerCsiHandler(u,f){return this._core.registerCsiHandler(u,(g=>f(g.toArray())))}addCsiHandler(u,f){return this.registerCsiHandler(u,f)}registerDcsHandler(u,f){return this._core.registerDcsHandler(u,((g,d)=>f(g,d.toArray())))}addDcsHandler(u,f){return this.registerDcsHandler(u,f)}registerEscHandler(u,f){return this._core.registerEscHandler(u,f)}addEscHandler(u,f){return this.registerEscHandler(u,f)}registerOscHandler(u,f){return this._core.registerOscHandler(u,f)}addOscHandler(u,f){return this.registerOscHandler(u,f)}}},7090:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeApi=void 0,o.UnicodeApi=class{constructor(u){this._core=u}register(u){this._core.unicodeService.register(u)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(u){this._core.unicodeService.activeVersion=u}}},744:function(c,o,u){var f=this&&this.__decorate||function(v,y,S,_){var k,D=arguments.length,T=D<3?y:_===null?_=Object.getOwnPropertyDescriptor(y,S):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(v,y,S,_);else for(var R=v.length-1;R>=0;R--)(k=v[R])&&(T=(D<3?k(T):D>3?k(y,S,T):k(y,S))||T);return D>3&&T&&Object.defineProperty(y,S,T),T},g=this&&this.__param||function(v,y){return function(S,_){y(S,_,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.BufferService=o.MINIMUM_ROWS=o.MINIMUM_COLS=void 0;const d=u(8460),m=u(844),b=u(5295),w=u(2585);o.MINIMUM_COLS=2,o.MINIMUM_ROWS=1;let C=o.BufferService=class extends m.Disposable{get buffer(){return this.buffers.active}constructor(v){super(),this.isUserScrolling=!1,this._onResize=this.register(new d.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new d.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(v.rawOptions.cols||0,o.MINIMUM_COLS),this.rows=Math.max(v.rawOptions.rows||0,o.MINIMUM_ROWS),this.buffers=this.register(new b.BufferSet(v,this))}resize(v,y){this.cols=v,this.rows=y,this.buffers.resize(v,y),this._onResize.fire({cols:v,rows:y})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(v,y=!1){const S=this.buffer;let _;_=this._cachedBlankLine,_&&_.length===this.cols&&_.getFg(0)===v.fg&&_.getBg(0)===v.bg||(_=S.getBlankLine(v,y),this._cachedBlankLine=_),_.isWrapped=y;const k=S.ybase+S.scrollTop,D=S.ybase+S.scrollBottom;if(S.scrollTop===0){const T=S.lines.isFull;D===S.lines.length-1?T?S.lines.recycle().copyFrom(_):S.lines.push(_.clone()):S.lines.splice(D+1,0,_.clone()),T?this.isUserScrolling&&(S.ydisp=Math.max(S.ydisp-1,0)):(S.ybase++,this.isUserScrolling||S.ydisp++)}else{const T=D-k+1;S.lines.shiftElements(k+1,T-1,-1),S.lines.set(D,_.clone())}this.isUserScrolling||(S.ydisp=S.ybase),this._onScroll.fire(S.ydisp)}scrollLines(v,y,S){const _=this.buffer;if(v<0){if(_.ydisp===0)return;this.isUserScrolling=!0}else v+_.ydisp>=_.ybase&&(this.isUserScrolling=!1);const k=_.ydisp;_.ydisp=Math.max(Math.min(_.ydisp+v,_.ybase),0),k!==_.ydisp&&(y||this._onScroll.fire(_.ydisp))}};o.BufferService=C=f([g(0,w.IOptionsService)],C)},7994:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CharsetService=void 0,o.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(u){this.glevel=u,this.charset=this._charsets[u]}setgCharset(u,f){this._charsets[u]=f,this.glevel===u&&(this.charset=f)}}},1753:function(c,o,u){var f=this&&this.__decorate||function(_,k,D,T){var R,N=arguments.length,L=N<3?k:T===null?T=Object.getOwnPropertyDescriptor(k,D):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(_,k,D,T);else for(var I=_.length-1;I>=0;I--)(R=_[I])&&(L=(N<3?R(L):N>3?R(k,D,L):R(k,D))||L);return N>3&&L&&Object.defineProperty(k,D,L),L},g=this&&this.__param||function(_,k){return function(D,T){k(D,T,_)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CoreMouseService=void 0;const d=u(2585),m=u(8460),b=u(844),w={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:_=>_.button!==4&&_.action===1&&(_.ctrl=!1,_.alt=!1,_.shift=!1,!0)},VT200:{events:19,restrict:_=>_.action!==32},DRAG:{events:23,restrict:_=>_.action!==32||_.button!==3},ANY:{events:31,restrict:_=>!0}};function C(_,k){let D=(_.ctrl?16:0)|(_.shift?4:0)|(_.alt?8:0);return _.button===4?(D|=64,D|=_.action):(D|=3&_.button,4&_.button&&(D|=64),8&_.button&&(D|=128),_.action===32?D|=32:_.action!==0||k||(D|=3)),D}const v=String.fromCharCode,y={DEFAULT:_=>{const k=[C(_,!1)+32,_.col+32,_.row+32];return k[0]>255||k[1]>255||k[2]>255?"":`\x1B[M${v(k[0])}${v(k[1])}${v(k[2])}`},SGR:_=>{const k=_.action===0&&_.button!==4?"m":"M";return`\x1B[<${C(_,!0)};${_.col};${_.row}${k}`},SGR_PIXELS:_=>{const k=_.action===0&&_.button!==4?"m":"M";return`\x1B[<${C(_,!0)};${_.x};${_.y}${k}`}};let S=o.CoreMouseService=class extends b.Disposable{constructor(_,k){super(),this._bufferService=_,this._coreService=k,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new m.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const D of Object.keys(w))this.addProtocol(D,w[D]);for(const D of Object.keys(y))this.addEncoding(D,y[D]);this.reset()}addProtocol(_,k){this._protocols[_]=k}addEncoding(_,k){this._encodings[_]=k}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(_){if(!this._protocols[_])throw new Error(`unknown protocol "${_}"`);this._activeProtocol=_,this._onProtocolChange.fire(this._protocols[_].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(_){if(!this._encodings[_])throw new Error(`unknown encoding "${_}"`);this._activeEncoding=_}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(_){if(_.col<0||_.col>=this._bufferService.cols||_.row<0||_.row>=this._bufferService.rows||_.button===4&&_.action===32||_.button===3&&_.action!==32||_.button!==4&&(_.action===2||_.action===3)||(_.col++,_.row++,_.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,_,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(_))return!1;const k=this._encodings[this._activeEncoding](_);return k&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(k):this._coreService.triggerDataEvent(k,!0)),this._lastEvent=_,!0}explainEvents(_){return{down:!!(1&_),up:!!(2&_),drag:!!(4&_),move:!!(8&_),wheel:!!(16&_)}}_equalEvents(_,k,D){if(D){if(_.x!==k.x||_.y!==k.y)return!1}else if(_.col!==k.col||_.row!==k.row)return!1;return _.button===k.button&&_.action===k.action&&_.ctrl===k.ctrl&&_.alt===k.alt&&_.shift===k.shift}};o.CoreMouseService=S=f([g(0,d.IBufferService),g(1,d.ICoreService)],S)},6975:function(c,o,u){var f=this&&this.__decorate||function(S,_,k,D){var T,R=arguments.length,N=R<3?_:D===null?D=Object.getOwnPropertyDescriptor(_,k):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(S,_,k,D);else for(var L=S.length-1;L>=0;L--)(T=S[L])&&(N=(R<3?T(N):R>3?T(_,k,N):T(_,k))||N);return R>3&&N&&Object.defineProperty(_,k,N),N},g=this&&this.__param||function(S,_){return function(k,D){_(k,D,S)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CoreService=void 0;const d=u(1439),m=u(8460),b=u(844),w=u(2585),C=Object.freeze({insertMode:!1}),v=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let y=o.CoreService=class extends b.Disposable{constructor(S,_,k){super(),this._bufferService=S,this._logService=_,this._optionsService=k,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new m.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new m.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new m.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new m.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,d.clone)(C),this.decPrivateModes=(0,d.clone)(v)}reset(){this.modes=(0,d.clone)(C),this.decPrivateModes=(0,d.clone)(v)}triggerDataEvent(S,_=!1){if(this._optionsService.rawOptions.disableStdin)return;const k=this._bufferService.buffer;_&&this._optionsService.rawOptions.scrollOnUserInput&&k.ybase!==k.ydisp&&this._onRequestScrollToBottom.fire(),_&&this._onUserInput.fire(),this._logService.debug(`sending data "${S}"`,(()=>S.split("").map((D=>D.charCodeAt(0))))),this._onData.fire(S)}triggerBinaryEvent(S){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${S}"`,(()=>S.split("").map((_=>_.charCodeAt(0))))),this._onBinary.fire(S))}};o.CoreService=y=f([g(0,w.IBufferService),g(1,w.ILogService),g(2,w.IOptionsService)],y)},9074:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DecorationService=void 0;const f=u(8055),g=u(8460),d=u(844),m=u(6106);let b=0,w=0;class C extends d.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new m.SortedList((S=>S==null?void 0:S.marker.line)),this._onDecorationRegistered=this.register(new g.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new g.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,d.toDisposable)((()=>this.reset())))}registerDecoration(S){if(S.marker.isDisposed)return;const _=new v(S);if(_){const k=_.marker.onDispose((()=>_.dispose()));_.onDispose((()=>{_&&(this._decorations.delete(_)&&this._onDecorationRemoved.fire(_),k.dispose())})),this._decorations.insert(_),this._onDecorationRegistered.fire(_)}return _}reset(){for(const S of this._decorations.values())S.dispose();this._decorations.clear()}*getDecorationsAtCell(S,_,k){let D=0,T=0;for(const R of this._decorations.getKeyIterator(_))D=R.options.x??0,T=D+(R.options.width??1),S>=D&&S<T&&(!k||(R.options.layer??"bottom")===k)&&(yield R)}forEachDecorationAtCell(S,_,k,D){this._decorations.forEachByKey(_,(T=>{b=T.options.x??0,w=b+(T.options.width??1),S>=b&&S<w&&(!k||(T.options.layer??"bottom")===k)&&D(T)}))}}o.DecorationService=C;class v extends d.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=f.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=f.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(S){super(),this.options=S,this.onRenderEmitter=this.register(new g.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new g.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=S.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.InstantiationService=o.ServiceCollection=void 0;const f=u(2585),g=u(8343);class d{constructor(...b){this._entries=new Map;for(const[w,C]of b)this.set(w,C)}set(b,w){const C=this._entries.get(b);return this._entries.set(b,w),C}forEach(b){for(const[w,C]of this._entries.entries())b(w,C)}has(b){return this._entries.has(b)}get(b){return this._entries.get(b)}}o.ServiceCollection=d,o.InstantiationService=class{constructor(){this._services=new d,this._services.set(f.IInstantiationService,this)}setService(m,b){this._services.set(m,b)}getService(m){return this._services.get(m)}createInstance(m,...b){const w=(0,g.getServiceDependencies)(m).sort(((y,S)=>y.index-S.index)),C=[];for(const y of w){const S=this._services.get(y.id);if(!S)throw new Error(`[createInstance] ${m.name} depends on UNKNOWN service ${y.id}.`);C.push(S)}const v=w.length>0?w[0].index:b.length;if(b.length!==v)throw new Error(`[createInstance] First service dependency of ${m.name} at position ${v+1} conflicts with ${b.length} static arguments`);return new m(...b,...C)}}},7866:function(c,o,u){var f=this&&this.__decorate||function(v,y,S,_){var k,D=arguments.length,T=D<3?y:_===null?_=Object.getOwnPropertyDescriptor(y,S):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(v,y,S,_);else for(var R=v.length-1;R>=0;R--)(k=v[R])&&(T=(D<3?k(T):D>3?k(y,S,T):k(y,S))||T);return D>3&&T&&Object.defineProperty(y,S,T),T},g=this&&this.__param||function(v,y){return function(S,_){y(S,_,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.traceCall=o.setTraceLogger=o.LogService=void 0;const d=u(844),m=u(2585),b={trace:m.LogLevelEnum.TRACE,debug:m.LogLevelEnum.DEBUG,info:m.LogLevelEnum.INFO,warn:m.LogLevelEnum.WARN,error:m.LogLevelEnum.ERROR,off:m.LogLevelEnum.OFF};let w,C=o.LogService=class extends d.Disposable{get logLevel(){return this._logLevel}constructor(v){super(),this._optionsService=v,this._logLevel=m.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),w=this}_updateLogLevel(){this._logLevel=b[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(v){for(let y=0;y<v.length;y++)typeof v[y]=="function"&&(v[y]=v[y]())}_log(v,y,S){this._evalLazyOptionalParams(S),v.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+y,...S)}trace(v,...y){var S;this._logLevel<=m.LogLevelEnum.TRACE&&this._log(((S=this._optionsService.options.logger)==null?void 0:S.trace.bind(this._optionsService.options.logger))??console.log,v,y)}debug(v,...y){var S;this._logLevel<=m.LogLevelEnum.DEBUG&&this._log(((S=this._optionsService.options.logger)==null?void 0:S.debug.bind(this._optionsService.options.logger))??console.log,v,y)}info(v,...y){var S;this._logLevel<=m.LogLevelEnum.INFO&&this._log(((S=this._optionsService.options.logger)==null?void 0:S.info.bind(this._optionsService.options.logger))??console.info,v,y)}warn(v,...y){var S;this._logLevel<=m.LogLevelEnum.WARN&&this._log(((S=this._optionsService.options.logger)==null?void 0:S.warn.bind(this._optionsService.options.logger))??console.warn,v,y)}error(v,...y){var S;this._logLevel<=m.LogLevelEnum.ERROR&&this._log(((S=this._optionsService.options.logger)==null?void 0:S.error.bind(this._optionsService.options.logger))??console.error,v,y)}};o.LogService=C=f([g(0,m.IOptionsService)],C),o.setTraceLogger=function(v){w=v},o.traceCall=function(v,y,S){if(typeof S.value!="function")throw new Error("not supported");const _=S.value;S.value=function(...k){if(w.logLevel!==m.LogLevelEnum.TRACE)return _.apply(this,k);w.trace(`GlyphRenderer#${_.name}(${k.map((T=>JSON.stringify(T))).join(", ")})`);const D=_.apply(this,k);return w.trace(`GlyphRenderer#${_.name} return`,D),D}}},7302:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.OptionsService=o.DEFAULT_OPTIONS=void 0;const f=u(8460),g=u(844),d=u(6114);o.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:d.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const m=["normal","bold","100","200","300","400","500","600","700","800","900"];class b extends g.Disposable{constructor(C){super(),this._onOptionChange=this.register(new f.EventEmitter),this.onOptionChange=this._onOptionChange.event;const v={...o.DEFAULT_OPTIONS};for(const y in C)if(y in v)try{const S=C[y];v[y]=this._sanitizeAndValidateOption(y,S)}catch(S){console.error(S)}this.rawOptions=v,this.options={...v},this._setupOptions(),this.register((0,g.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(C,v){return this.onOptionChange((y=>{y===C&&v(this.rawOptions[C])}))}onMultipleOptionChange(C,v){return this.onOptionChange((y=>{C.indexOf(y)!==-1&&v()}))}_setupOptions(){const C=y=>{if(!(y in o.DEFAULT_OPTIONS))throw new Error(`No option with key "${y}"`);return this.rawOptions[y]},v=(y,S)=>{if(!(y in o.DEFAULT_OPTIONS))throw new Error(`No option with key "${y}"`);S=this._sanitizeAndValidateOption(y,S),this.rawOptions[y]!==S&&(this.rawOptions[y]=S,this._onOptionChange.fire(y))};for(const y in this.rawOptions){const S={get:C.bind(this,y),set:v.bind(this,y)};Object.defineProperty(this.options,y,S)}}_sanitizeAndValidateOption(C,v){switch(C){case"cursorStyle":if(v||(v=o.DEFAULT_OPTIONS[C]),!(function(y){return y==="block"||y==="underline"||y==="bar"})(v))throw new Error(`"${v}" is not a valid value for ${C}`);break;case"wordSeparator":v||(v=o.DEFAULT_OPTIONS[C]);break;case"fontWeight":case"fontWeightBold":if(typeof v=="number"&&1<=v&&v<=1e3)break;v=m.includes(v)?v:o.DEFAULT_OPTIONS[C];break;case"cursorWidth":v=Math.floor(v);case"lineHeight":case"tabStopWidth":if(v<1)throw new Error(`${C} cannot be less than 1, value: ${v}`);break;case"minimumContrastRatio":v=Math.max(1,Math.min(21,Math.round(10*v)/10));break;case"scrollback":if((v=Math.min(v,4294967295))<0)throw new Error(`${C} cannot be less than 0, value: ${v}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(v<=0)throw new Error(`${C} cannot be less than or equal to 0, value: ${v}`);break;case"rows":case"cols":if(!v&&v!==0)throw new Error(`${C} must be numeric, value: ${v}`);break;case"windowsPty":v=v??{}}return v}}o.OptionsService=b},2660:function(c,o,u){var f=this&&this.__decorate||function(b,w,C,v){var y,S=arguments.length,_=S<3?w:v===null?v=Object.getOwnPropertyDescriptor(w,C):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(b,w,C,v);else for(var k=b.length-1;k>=0;k--)(y=b[k])&&(_=(S<3?y(_):S>3?y(w,C,_):y(w,C))||_);return S>3&&_&&Object.defineProperty(w,C,_),_},g=this&&this.__param||function(b,w){return function(C,v){w(C,v,b)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkService=void 0;const d=u(2585);let m=o.OscLinkService=class{constructor(b){this._bufferService=b,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(b){const w=this._bufferService.buffer;if(b.id===void 0){const k=w.addMarker(w.ybase+w.y),D={data:b,id:this._nextId++,lines:[k]};return k.onDispose((()=>this._removeMarkerFromLink(D,k))),this._dataByLinkId.set(D.id,D),D.id}const C=b,v=this._getEntryIdKey(C),y=this._entriesWithId.get(v);if(y)return this.addLineToLink(y.id,w.ybase+w.y),y.id;const S=w.addMarker(w.ybase+w.y),_={id:this._nextId++,key:this._getEntryIdKey(C),data:C,lines:[S]};return S.onDispose((()=>this._removeMarkerFromLink(_,S))),this._entriesWithId.set(_.key,_),this._dataByLinkId.set(_.id,_),_.id}addLineToLink(b,w){const C=this._dataByLinkId.get(b);if(C&&C.lines.every((v=>v.line!==w))){const v=this._bufferService.buffer.addMarker(w);C.lines.push(v),v.onDispose((()=>this._removeMarkerFromLink(C,v)))}}getLinkData(b){var w;return(w=this._dataByLinkId.get(b))==null?void 0:w.data}_getEntryIdKey(b){return`${b.id};;${b.uri}`}_removeMarkerFromLink(b,w){const C=b.lines.indexOf(w);C!==-1&&(b.lines.splice(C,1),b.lines.length===0&&(b.data.id!==void 0&&this._entriesWithId.delete(b.key),this._dataByLinkId.delete(b.id)))}};o.OscLinkService=m=f([g(0,d.IBufferService)],m)},8343:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.createDecorator=o.getServiceDependencies=o.serviceRegistry=void 0;const u="di$target",f="di$dependencies";o.serviceRegistry=new Map,o.getServiceDependencies=function(g){return g[f]||[]},o.createDecorator=function(g){if(o.serviceRegistry.has(g))return o.serviceRegistry.get(g);const d=function(m,b,w){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(C,v,y){v[u]===v?v[f].push({id:C,index:y}):(v[f]=[{id:C,index:y}],v[u]=v)})(d,m,w)};return d.toString=()=>g,o.serviceRegistry.set(g,d),d}},2585:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.IDecorationService=o.IUnicodeService=o.IOscLinkService=o.IOptionsService=o.ILogService=o.LogLevelEnum=o.IInstantiationService=o.ICharsetService=o.ICoreService=o.ICoreMouseService=o.IBufferService=void 0;const f=u(8343);var g;o.IBufferService=(0,f.createDecorator)("BufferService"),o.ICoreMouseService=(0,f.createDecorator)("CoreMouseService"),o.ICoreService=(0,f.createDecorator)("CoreService"),o.ICharsetService=(0,f.createDecorator)("CharsetService"),o.IInstantiationService=(0,f.createDecorator)("InstantiationService"),(function(d){d[d.TRACE=0]="TRACE",d[d.DEBUG=1]="DEBUG",d[d.INFO=2]="INFO",d[d.WARN=3]="WARN",d[d.ERROR=4]="ERROR",d[d.OFF=5]="OFF"})(g||(o.LogLevelEnum=g={})),o.ILogService=(0,f.createDecorator)("LogService"),o.IOptionsService=(0,f.createDecorator)("OptionsService"),o.IOscLinkService=(0,f.createDecorator)("OscLinkService"),o.IUnicodeService=(0,f.createDecorator)("UnicodeService"),o.IDecorationService=(0,f.createDecorator)("DecorationService")},1480:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeService=void 0;const f=u(8460),g=u(225);class d{static extractShouldJoin(b){return(1&b)!=0}static extractWidth(b){return b>>1&3}static extractCharKind(b){return b>>3}static createPropertyValue(b,w,C=!1){return(16777215&b)<<3|(3&w)<<1|(C?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new f.EventEmitter,this.onChange=this._onChange.event;const b=new g.UnicodeV6;this.register(b),this._active=b.version,this._activeProvider=b}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(b){if(!this._providers[b])throw new Error(`unknown Unicode version "${b}"`);this._active=b,this._activeProvider=this._providers[b],this._onChange.fire(b)}register(b){this._providers[b.version]=b}wcwidth(b){return this._activeProvider.wcwidth(b)}getStringCellWidth(b){let w=0,C=0;const v=b.length;for(let y=0;y<v;++y){let S=b.charCodeAt(y);if(55296<=S&&S<=56319){if(++y>=v)return w+this.wcwidth(S);const D=b.charCodeAt(y);56320<=D&&D<=57343?S=1024*(S-55296)+D-56320+65536:w+=this.wcwidth(D)}const _=this.charProperties(S,C);let k=d.extractWidth(_);d.extractShouldJoin(_)&&(k-=d.extractWidth(C)),w+=k,C=_}return w}charProperties(b,w){return this._activeProvider.charProperties(b,w)}}o.UnicodeService=d}},r={};function a(c){var o=r[c];if(o!==void 0)return o.exports;var u=r[c]={exports:{}};return n[c].call(u.exports,u,u.exports,a),u.exports}var l={};return(()=>{var c=l;Object.defineProperty(c,"__esModule",{value:!0}),c.Terminal=void 0;const o=a(9042),u=a(3236),f=a(844),g=a(5741),d=a(8285),m=a(7975),b=a(7090),w=["cols","rows"];class C extends f.Disposable{constructor(y){super(),this._core=this.register(new u.Terminal(y)),this._addonManager=this.register(new g.AddonManager),this._publicOptions={...this._core.options};const S=k=>this._core.options[k],_=(k,D)=>{this._checkReadonlyOptions(k),this._core.options[k]=D};for(const k in this._core.options){const D={get:S.bind(this,k),set:_.bind(this,k)};Object.defineProperty(this._publicOptions,k,D)}}_checkReadonlyOptions(y){if(w.includes(y))throw new Error(`Option "${y}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new m.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new b.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new d.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const y=this._core.coreService.decPrivateModes;let S="none";switch(this._core.coreMouseService.activeProtocol){case"X10":S="x10";break;case"VT200":S="vt200";break;case"DRAG":S="drag";break;case"ANY":S="any"}return{applicationCursorKeysMode:y.applicationCursorKeys,applicationKeypadMode:y.applicationKeypad,bracketedPasteMode:y.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:S,originMode:y.origin,reverseWraparoundMode:y.reverseWraparound,sendFocusMode:y.sendFocus,wraparoundMode:y.wraparound}}get options(){return this._publicOptions}set options(y){for(const S in y)this._publicOptions[S]=y[S]}blur(){this._core.blur()}focus(){this._core.focus()}input(y,S=!0){this._core.input(y,S)}resize(y,S){this._verifyIntegers(y,S),this._core.resize(y,S)}open(y){this._core.open(y)}attachCustomKeyEventHandler(y){this._core.attachCustomKeyEventHandler(y)}attachCustomWheelEventHandler(y){this._core.attachCustomWheelEventHandler(y)}registerLinkProvider(y){return this._core.registerLinkProvider(y)}registerCharacterJoiner(y){return this._checkProposedApi(),this._core.registerCharacterJoiner(y)}deregisterCharacterJoiner(y){this._checkProposedApi(),this._core.deregisterCharacterJoiner(y)}registerMarker(y=0){return this._verifyIntegers(y),this._core.registerMarker(y)}registerDecoration(y){return this._checkProposedApi(),this._verifyPositiveIntegers(y.x??0,y.width??0,y.height??0),this._core.registerDecoration(y)}hasSelection(){return this._core.hasSelection()}select(y,S,_){this._verifyIntegers(y,S,_),this._core.select(y,S,_)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(y,S){this._verifyIntegers(y,S),this._core.selectLines(y,S)}dispose(){super.dispose()}scrollLines(y){this._verifyIntegers(y),this._core.scrollLines(y)}scrollPages(y){this._verifyIntegers(y),this._core.scrollPages(y)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(y){this._verifyIntegers(y),this._core.scrollToLine(y)}clear(){this._core.clear()}write(y,S){this._core.write(y,S)}writeln(y,S){this._core.write(y),this._core.write(`\r -`,S)}paste(y){this._core.paste(y)}refresh(y,S){this._verifyIntegers(y,S),this._core.refresh(y,S)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(y){this._addonManager.loadAddon(this,y)}static get strings(){return o}_verifyIntegers(...y){for(const S of y)if(S===1/0||isNaN(S)||S%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...y){for(const S of y)if(S&&(S===1/0||isNaN(S)||S%1!=0||S<0))throw new Error("This API only accepts positive integers")}}c.Terminal=C})(),l})()))})(ip)),ip.exports}var Uj=Pj();function db(e){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function $j({runId:e}){const t=X.useRef(null);return X.useEffect(()=>{const n=t.current;if(!n)return;const r=new Uj.Terminal({convertEol:!0,disableStdin:!0,fontSize:12,fontFamily:'ui-monospace, "SF Mono", Menlo, Consolas, monospace',scrollback:2e4,theme:{background:"#1a1a1a",foreground:"#e6e1e0",cursor:"#1a1a1a",selectionBackground:"#2c3441"}}),a=new Fj.FitAddon;r.loadAddon(a),r.open(n);try{a.fit()}catch{}const l=new ResizeObserver(()=>{try{a.fit()}catch{}});l.observe(n);let c=!1,o=0,u=!1,f=!1;async function g(){if(u){f=!0;return}u=!0;try{for(;;){const m=await WA(e,o);if(c)return;if(m.dataBase64&&r.write(db(m.dataBase64)),o=m.nextOffset,m.eof)break}}catch{}finally{u=!1,f&&!c&&(f=!1,g())}}const d=U4(e,m=>{if(c)return;const b=db(m.dataBase64);!u&&m.offset===o?(r.write(b),o+=b.length):m.offset+b.length>o&&g()});return g(),()=>{c=!0,d(),l.disconnect(),r.dispose()}},[e]),x.jsx("div",{ref:t,style:{width:"100%",height:"100%"}})}const $s="__uncommitted__";function Gj({state:e}){return!e||e.loading?x.jsx("div",{className:"changes-note",children:"Loading diff…"}):e.error?x.jsx("div",{className:"error",children:e.error}):e.payload?e.payload.truncated?x.jsx(Ij,{bytesRead:e.payload.bytesRead,byteLimit:e.payload.byteLimit}):x.jsx(Pw,{diff:e.payload.diff}):x.jsx("div",{className:"diff-empty",children:"No changes."})}function qj({experiment:e,view:t,runs:n,selectedRunId:r,onSelectRun:a}){const l=n.filter(c=>c.experimentId===e.id).sort((c,o)=>o.createdAt-c.createdAt);return t==="terminal"?x.jsx(Vj,{experiment:e,expRuns:l,selectedRunId:r,onSelectRun:a}):x.jsx(Yj,{experiment:e})}function Vj({experiment:e,expRuns:t,selectedRunId:n,onSelectRun:r}){const[a,l]=X.useState(null),[c,o]=X.useState(!1),u=X.useRef(null),f=n&&t.find(w=>w.id===n)||t[0]||null,g=(f==null?void 0:f.status)==="running"||(f==null?void 0:f.status)==="starting",d=w=>{const C=t.findIndex(v=>v.id===w);return C===-1?t.length:t.length-C},m=X.useRef(null);X.useEffect(()=>{if(m.current===null){m.current=new Set(t.map(C=>C.id));return}const w=t.find(C=>!m.current.has(C.id));for(const C of t)m.current.add(C.id);w&&r(w.id)},[t,r]),X.useEffect(()=>{if(!c)return;const w=C=>{var v;(v=u.current)!=null&&v.contains(C.target)||o(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[c]);async function b(){if(f){l(null);try{await MS(f.id)}catch(w){l(w instanceof Error?w.message:String(w))}}}return x.jsxs("div",{className:"term-view",children:[x.jsxs("div",{className:"term-bar",children:[x.jsx("div",{className:"term-title",title:e.title||e.slug,children:e.title||e.slug}),x.jsx("span",{style:{flex:1}}),a&&x.jsx("span",{className:"error",children:a}),g&&x.jsxs("button",{className:"btn sm ghost",onClick:()=>void b(),children:[x.jsx(sA,{size:13}),"Stop"]}),t.length>0&&f&&x.jsxs("div",{className:"run-history",ref:u,children:[x.jsxs("button",{className:"run-picker",title:"Switch run",onClick:()=>o(w=>!w),children:[x.jsxs("span",{className:"run-label",children:["Run ",d(f.id)]}),x.jsx(Oo,{status:f.status}),x.jsx(Du,{size:14,className:"run-picker-chev"})]}),c&&x.jsx("div",{className:"history-menu",children:t.map(w=>x.jsxs("button",{className:`history-item ${w.id===(f==null?void 0:f.id)?"active":""}`,onClick:()=>{r(w.id),o(!1)},children:[x.jsxs("span",{className:"run-label",children:["Run ",d(w.id)]}),x.jsx(Oo,{status:w.status}),x.jsx("span",{className:"when",children:ua(w.createdAt)})]},w.id))})]})]}),x.jsx("div",{className:"term-fill",children:f?x.jsx($j,{runId:f.id},f.id):x.jsx("div",{className:"term-empty",children:"No runs yet — ask the agent to launch one."})})]})}function Yj({experiment:e}){const[t,n]=X.useState(null),[r,a]=X.useState(null),[l,c]=X.useState(null),[o,u]=X.useState(null),[f,g]=X.useState({}),d=!!(l&&l.diff.trim()!==""&&l.experimentId===e.id);async function m(){a(null);try{const[w,C]=await Promise.all([XA(e.id),Ay(e.projectId)]);n(w),c(C),u(v=>{var S;return v!==null?v:C.diff.trim()!==""&&C.experimentId===e.id?$s:((S=w[0])==null?void 0:S.sha)??null})}catch(w){a(w instanceof Error?w.message:String(w))}}X.useEffect(()=>{t===null&&!r&&m()},[t,r,e.id]),X.useEffect(()=>{const w=setInterval(()=>{Ay(e.projectId).then(c).catch(()=>{})},5e3);return()=>clearInterval(w)},[e.projectId]),X.useEffect(()=>{var w;o===$s&&l&&!d&&u(((w=t==null?void 0:t[0])==null?void 0:w.sha)??null)},[o,l,d,t]),X.useEffect(()=>{if(!o||o===$s||f[o])return;const w=o;g(C=>({...C,[w]:{loading:!0}})),KA(e.id,w).then(C=>g(v=>({...v,[w]:{loading:!1,payload:C}}))).catch(C=>g(v=>({...v,[w]:{loading:!1,error:C instanceof Error?C.message:String(C)}})))},[o,f,e.id]);const b=!d&&((t==null?void 0:t.length)??0)===0;return x.jsx("div",{className:"drawer",children:x.jsx("div",{className:"drawer-body",children:x.jsx("div",{className:"drawer-section",children:r?x.jsx("div",{className:"error",children:r}):t===null?x.jsx("div",{className:"changes-note",children:"Loading changes…"}):b?x.jsx("div",{className:"changes-note",children:"No changes yet — the agent hasn't committed on this branch."}):x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"commit-picker",children:[o===$s&&x.jsx("span",{className:"uncommitted-dot"}),x.jsxs("select",{className:"input sm",value:o??"",onChange:w=>u(w.target.value),children:[d&&x.jsx("option",{value:$s,children:"● Uncommitted changes"}),t.map(w=>x.jsxs("option",{value:w.sha,children:[w.sha.slice(0,7)," — ",w.subject]},w.sha))]}),x.jsx("button",{className:"icon-btn",title:"Refresh","aria-label":"Refresh",onClick:()=>void m(),children:x.jsx(DS,{size:14})})]}),x.jsx("div",{style:{marginTop:10},children:o===$s&&l?l.truncated?x.jsxs("div",{className:"truncated-notice",children:[x.jsx("h4",{children:"Diff too large to display"}),x.jsx("p",{children:"The uncommitted diff is too large to display. View it locally with git."})]}):x.jsx(Pw,{diff:l.diff}):o?x.jsx(Gj,{state:f[o]}):x.jsx("div",{className:"changes-note",children:"Select a commit to view its diff."})})]})})})})}function Wj(e,t){return Qx(e,qx(t))}function Xj({projectId:e,path:t,onOpenFile:n}){const[r,a]=X.useState(null),[l,c]=X.useState(null),[o,u]=X.useState(!0),[f,g]=X.useState(0),d=/\.(md|mdx|markdown)$/i.test(t),[m,b]=X.useState(!1);X.useEffect(()=>{let C=!1;return u(!0),ZA(e,t).then(v=>{C||(a(v),c(null))}).catch(v=>{C||c(v.message)}).finally(()=>{C||u(!1)}),()=>{C=!0}},[e,t,f]);const w=X.useMemo(()=>r&&!r.notFound?Wj(r.content,t):null,[r,t]);return x.jsxs("div",{className:"file-view",children:[x.jsxs("div",{className:"file-view-header",children:[x.jsx(TS,{size:13,style:{flexShrink:0}}),x.jsx("code",{className:"file-view-path",title:t,children:t}),d&&x.jsx("button",{className:`icon-btn ${m?"active":""}`,title:m?"Rendered view":"Source view","aria-label":m?"Rendered view":"Source view",onClick:()=>b(C=>!C),children:x.jsx(oA,{size:13})}),x.jsx("button",{className:"icon-btn",title:"Reload file","aria-label":"Reload file",onClick:()=>g(C=>C+1),children:o?x.jsx("span",{className:"spinner"}):x.jsx(DS,{size:13})})]}),x.jsx("div",{className:"file-view-body",children:l?x.jsxs("div",{className:"file-view-note",children:["Failed to load file: ",l]}):r===null?x.jsx("div",{className:"file-view-note",children:"Loading…"}):r.notFound?x.jsx("div",{className:"file-view-note",children:"File not found in the project clone."}):x.jsxs(x.Fragment,{children:[d&&!m?x.jsx("div",{className:"file-view-md",children:x.jsx(rm,{text:r.content,onOpenFile:n})}):x.jsx("pre",{className:"file-view-code",children:x.jsx("code",{children:w})}),r.truncated&&x.jsx("div",{className:"file-view-note",children:"File truncated — showing the first 512 KB."})]})})]})}function Kj({projectName:e,onHome:t,onCollapse:n}){return x.jsxs("div",{className:"rail-brand",children:[x.jsxs("button",{className:"brand",onClick:t,title:"All projects",children:[x.jsx(cg,{size:15}),x.jsx("span",{className:"brand-project",children:e})]}),n&&x.jsx("button",{className:"icon-btn",title:"Hide sidebar","aria-label":"Hide sidebar",onClick:n,children:x.jsx(_p,{size:15})})]})}function Zj({onDone:e}){const[t,n]=X.useState(0),[r,a]=X.useState(null),[l,c]=X.useState(null),[o,u]=X.useState(!1),f=g=>{u(!0),Promise.allSettled([dg(g).then(a),OS().then(c)]).finally(()=>u(!1))};return X.useEffect(()=>f(!1),[]),x.jsx("div",{className:"home onboarding",children:x.jsx("div",{className:"home-inner",children:t===0?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"onb-eyebrow",children:["Open",x.jsx("span",{children:"Research"})," · step 1 of 2"]}),x.jsx("h2",{className:"onb-title",children:"Your coding agents"}),x.jsx("p",{className:"onb-sub",children:"orx found the agent CLIs on this machine and drives them directly — chat and autoresearch run on your own logins, no extra API keys."}),x.jsx("div",{className:"onb-cards",children:r===null?x.jsxs("div",{className:"onb-loading",children:[x.jsx("span",{className:"spinner"})," Detecting Claude Code, Codex, OpenCode…"]}):r.map(g=>x.jsx(Jj,{h:g},g.id))}),x.jsxs("div",{className:"onb-actions",children:[x.jsxs("button",{className:"btn ghost",onClick:()=>f(!0),disabled:o,children:[x.jsx(cu,{size:12,className:o?"spin":""})," Re-check"]}),x.jsx("div",{style:{flex:1}}),x.jsxs("button",{className:"btn primary",onClick:()=>n(1),children:["Continue ",x.jsx(ky,{size:13})]})]})]}):x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"onb-eyebrow",children:["Open",x.jsx("span",{children:"Research"})," · step 2 of 2"]}),x.jsx("h2",{className:"onb-title",children:"Git & GitHub"}),x.jsx("p",{className:"onb-sub",children:"A project is a clone of one of your GitHub repos, made with your own git credentials. Every experiment becomes a branch pushed to that repo — compute jobs clone it from there."}),x.jsx("div",{className:"onb-cards",children:x.jsx(e8,{git:l,onUpdate:c})}),x.jsxs("div",{className:"onb-actions",children:[x.jsxs("button",{className:"btn ghost",onClick:()=>n(0),children:[x.jsx(cg,{size:12})," Back"]}),x.jsxs("button",{className:"btn ghost",onClick:()=>f(!1),disabled:o,children:[x.jsx(cu,{size:12,className:o?"spin":""})," Re-check"]}),x.jsx("div",{style:{flex:1}}),x.jsxs("button",{className:"btn primary",onClick:e,children:["Create your first project ",x.jsx(ky,{size:13})]})]})]})})})}function Qj(e){return e.agentReady?{cls:"st-done",label:"connected"}:e.installed?{cls:"st-starting",label:"not signed in"}:{cls:"st-idle",label:"not detected"}}function Jj({h:e}){var r,a;const t=Qj(e),n=(r=e.version)==null?void 0:r.replace(/\s*\(.*\)$/,"");return x.jsxs("div",{className:"onb-card",children:[x.jsxs("div",{className:"onb-card-head",children:[x.jsx("span",{className:"onb-card-name",children:e.name}),x.jsxs("span",{className:`status-badge ${t.cls}`,children:[e.agentReady?x.jsx(Ti,{size:12,strokeWidth:3}):x.jsx("span",{className:"dot"}),t.label]})]}),e.agentReady?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"onb-card-detail mono",children:[e.account??"API key",e.plan?` · ${e.plan}`:""]}),x.jsx("div",{className:"onb-card-meta",children:[n,e.models.length>0&&`${e.models.length} model${e.models.length===1?"":"s"} — ${e.models.slice(0,3).map(l=>uu(l.id)).join(", ")}${e.models.length>3?", …":""}`].filter(Boolean).join(" · ")})]}):x.jsx("div",{className:"onb-card-meta",children:(a=e.agentNote)==null?void 0:a.replace(/`/g,"")})]})}function e8({git:e,onUpdate:t}){const[n,r]=X.useState(!1),a=()=>{navigator.clipboard.writeText("gh auth login").then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};if(e===null)return x.jsxs("div",{className:"onb-loading",children:[x.jsx("span",{className:"spinner"})," Checking git…"]});if(!e.gitVersion)return x.jsxs("div",{className:"onb-card",children:[x.jsxs("div",{className:"onb-card-head",children:[x.jsx("span",{className:"onb-card-name",children:"git"}),x.jsxs("span",{className:"status-badge st-failed",children:[x.jsx("span",{className:"dot"})," not found"]})]}),x.jsx("div",{className:"onb-card-meta",children:"Install git to clone projects, then re-open orx."})]});const l=[e.userName,e.userEmail&&`<${e.userEmail}>`].filter(Boolean).join(" ");return x.jsxs("div",{className:"onb-card",children:[x.jsxs("div",{className:"onb-card-row",children:[x.jsx("span",{className:"onb-card-name",children:"git"}),x.jsxs("span",{className:"onb-card-detail mono",children:[e.gitVersion.replace(/^git version /,""),l?` · ${l}`:""]}),x.jsxs("span",{className:`status-badge ${l?"st-done":"st-starting"}`,children:[l?x.jsx(Ti,{size:12,strokeWidth:3}):x.jsx("span",{className:"dot"}),l?"ready":"no identity"]})]}),x.jsxs("div",{className:"onb-card-row",children:[x.jsx("span",{className:"onb-card-name",children:"GitHub"}),x.jsx("span",{className:"onb-card-detail mono",children:e.githubTokenSource==="env"?"token from GITHUB_TOKEN":e.githubTokenSource==="stored"?"token saved in orx":e.githubTokenSource==="gh"?"signed in via gh CLI":"not connected"}),x.jsxs("span",{className:`status-badge ${e.githubTokenSource?"st-done":"st-starting"}`,children:[e.githubTokenSource?x.jsx(Ti,{size:12,strokeWidth:3}):x.jsx("span",{className:"dot"}),e.githubTokenSource?"ready":"check"]})]}),!l&&x.jsxs("div",{className:"onb-card-meta",children:["Set ",x.jsx("code",{children:"git config --global user.name / user.email"})," so the agent can commit."]}),!e.githubTokenSource&&x.jsxs("div",{className:"onb-gh-options",children:[x.jsx("div",{className:"onb-card-meta",children:"GitHub access is used to clone your repos and push experiment branches. Connect either way:"}),x.jsxs("div",{className:"onb-gh-option",children:[x.jsx("span",{className:"onb-gh-option-label",children:"GitHub CLI"}),x.jsx("div",{className:"onb-gh-option-body",children:e.ghInstalled?x.jsxs(x.Fragment,{children:[x.jsx("code",{className:"onb-gh-cmd",children:"gh auth login"}),x.jsxs("button",{className:"btn ghost",onClick:a,children:[n?x.jsx(Ti,{size:12,strokeWidth:3}):x.jsx(hg,{size:12}),n?"Copied":"Copy"]}),x.jsx("span",{className:"onb-gh-hint",children:"run in a terminal, then Re-check"})]}):x.jsxs("span",{className:"onb-gh-hint",children:["install the GitHub CLI, run ",x.jsx("code",{children:"gh auth login"}),", then Re-check"]})})]}),x.jsx("div",{className:"onb-gh-or",children:"or"}),x.jsxs("div",{className:"onb-gh-option",children:[x.jsx("span",{className:"onb-gh-option-label",children:"Paste a token"}),x.jsx(ew,{onSaved:t})]})]})]})}function pb(e){const t=e.trim().replace(/^git@github\.com:/i,"").replace(/^https?:\/\/(www\.)?github\.com\//i,"").replace(/\.git$/i,"").replace(/^\/+|\/+$/g,""),[n,r]=t.split("/");return!n||!r||/[\s:@]/.test(n)||/[\s:@]/.test(r)?null:{owner:n,repo:r}}function t8(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48).replace(/-+$/,"")||"experiment"}function n8({onCreated:e,onCancel:t}){const[n,r]=X.useState("existing"),[a,l]=X.useState("use"),[c,o]=X.useState(""),[u,f]=X.useState(""),[g,d]=X.useState(!1),[m,b]=X.useState("main"),[w,C]=X.useState(!1),[v,y]=X.useState(null),S=pb(c),_=u.trim()&&(n==="new"||S!==null),k=T=>{var R;o(T),g||f(((R=pb(T))==null?void 0:R.repo)??"")};async function D(T){if(T.preventDefault(),!(!_||w)){C(!0),y(null);try{const R=await $A(n==="new"?{name:u.trim(),createRepo:!0}:{name:u.trim(),githubOwner:S.owner,githubRepo:S.repo,baselineBranch:m.trim()||"main",forkRepo:a==="fork"});e(R)}catch(R){y(R instanceof Error?R.message:String(R))}finally{C(!1)}}}return x.jsxs("form",{className:"form",onSubmit:D,children:[x.jsxs("div",{className:"seg form-seg",children:[x.jsx("button",{type:"button",className:n==="existing"?"active":"",onClick:()=>r("existing"),children:"Existing repo"}),x.jsx("button",{type:"button",className:n==="new"?"active":"",onClick:()=>r("new"),children:"New blank repo"})]}),n==="existing"?x.jsxs(x.Fragment,{children:[x.jsxs("label",{children:["GitHub repository",x.jsx("input",{value:c,onChange:T=>k(T.target.value),placeholder:"https://github.com/karpathy/nanoGPT",autoFocus:!0,spellCheck:!1}),x.jsx("span",{className:`repo-hint mono ${S?"ok":""}`,children:S?`${S.owner} / ${S.repo}`:c.trim()?"paste a GitHub URL or owner/repo":"URL or owner/repo — cloned with your git credentials"})]}),x.jsxs("div",{className:"seg form-seg",children:[x.jsx("button",{type:"button",className:a==="use"?"active":"",onClick:()=>l("use"),children:"Use this repo"}),x.jsx("button",{type:"button",className:a==="fork"?"active":"",onClick:()=>l("fork"),children:"Fork a copy"})]}),x.jsx("span",{className:"repo-hint",children:a==="fork"?`snapshots ${S?`${S.owner}/${S.repo}`:"the repo"} into a private repo on your account`:"experiments push branches here — if you can't push to it, a fork is made automatically"}),x.jsxs("div",{className:"row2",children:[x.jsxs("label",{children:["Project name",x.jsx("input",{value:u,onChange:T=>{d(!0),f(T.target.value)},placeholder:"my-research"})]}),x.jsxs("label",{children:["Baseline branch",x.jsx("input",{value:m,onChange:T=>b(T.target.value),placeholder:"main"})]})]})]}):x.jsxs("label",{children:["Project name",x.jsx("input",{value:u,onChange:T=>{d(!0),f(T.target.value)},placeholder:"my-research",autoFocus:!0}),x.jsx("span",{className:`repo-hint mono ${u.trim()?"ok":""}`,children:u.trim()?`creates github.com/you/${t8(u)} · private`:"a blank private repo is created on your GitHub account"})]}),v&&x.jsx("div",{className:"error",children:v}),x.jsxs("div",{className:"actions",children:[t&&x.jsx("button",{type:"button",className:"btn ghost",onClick:t,children:"Cancel"}),x.jsx("button",{type:"submit",className:"btn primary",disabled:!_||w,children:w?n==="new"?"Creating repo…":a==="fork"?"Forking repo…":"Cloning repo…":"Create project"})]})]})}function gb({projects:e,onOpen:t,onCreated:n,onDeleted:r}){const[a,l]=X.useState(!1),[c,o]=X.useState(null);async function u(f){if(window.confirm(`Delete project "${f.name}"? +`,S)}paste(y){this._core.paste(y)}refresh(y,S){this._verifyIntegers(y,S),this._core.refresh(y,S)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(y){this._addonManager.loadAddon(this,y)}static get strings(){return o}_verifyIntegers(...y){for(const S of y)if(S===1/0||isNaN(S)||S%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...y){for(const S of y)if(S&&(S===1/0||isNaN(S)||S%1!=0||S<0))throw new Error("This API only accepts positive integers")}}c.Terminal=C})(),l})()))})(ip)),ip.exports}var Uj=Pj();function db(e){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function $j({runId:e}){const t=X.useRef(null);return X.useEffect(()=>{const n=t.current;if(!n)return;const r=new Uj.Terminal({convertEol:!0,disableStdin:!0,fontSize:12,fontFamily:'ui-monospace, "SF Mono", Menlo, Consolas, monospace',scrollback:2e4,theme:{background:"#1a1a1a",foreground:"#e6e1e0",cursor:"#1a1a1a",selectionBackground:"#2c3441"}}),a=new Fj.FitAddon;r.loadAddon(a),r.open(n);try{a.fit()}catch{}const l=new ResizeObserver(()=>{try{a.fit()}catch{}});l.observe(n);let c=!1,o=0,u=!1,f=!1;async function g(){if(u){f=!0;return}u=!0;try{for(;;){const m=await WA(e,o);if(c)return;if(m.dataBase64&&r.write(db(m.dataBase64)),o=m.nextOffset,m.eof)break}}catch{}finally{u=!1,f&&!c&&(f=!1,g())}}const d=U4(e,m=>{if(c)return;const b=db(m.dataBase64);!u&&m.offset===o?(r.write(b),o+=b.length):m.offset+b.length>o&&g()});return g(),()=>{c=!0,d(),l.disconnect(),r.dispose()}},[e]),x.jsx("div",{ref:t,style:{width:"100%",height:"100%"}})}const $s="__uncommitted__";function Gj({state:e}){return!e||e.loading?x.jsx("div",{className:"changes-note",children:"Loading diff…"}):e.error?x.jsx("div",{className:"error",children:e.error}):e.payload?e.payload.truncated?x.jsx(Ij,{bytesRead:e.payload.bytesRead,byteLimit:e.payload.byteLimit}):x.jsx(Pw,{diff:e.payload.diff}):x.jsx("div",{className:"diff-empty",children:"No changes."})}function qj({experiment:e,view:t,runs:n,selectedRunId:r,onSelectRun:a}){const l=n.filter(c=>c.experimentId===e.id).sort((c,o)=>o.createdAt-c.createdAt);return t==="terminal"?x.jsx(Vj,{experiment:e,expRuns:l,selectedRunId:r,onSelectRun:a}):x.jsx(Yj,{experiment:e})}function Vj({experiment:e,expRuns:t,selectedRunId:n,onSelectRun:r}){const[a,l]=X.useState(null),[c,o]=X.useState(!1),u=X.useRef(null),f=n&&t.find(w=>w.id===n)||t[0]||null,g=(f==null?void 0:f.status)==="running"||(f==null?void 0:f.status)==="starting",d=w=>{const C=t.findIndex(v=>v.id===w);return C===-1?t.length:t.length-C},m=X.useRef(null);X.useEffect(()=>{if(m.current===null){m.current=new Set(t.map(C=>C.id));return}const w=t.find(C=>!m.current.has(C.id));for(const C of t)m.current.add(C.id);w&&r(w.id)},[t,r]),X.useEffect(()=>{if(!c)return;const w=C=>{var v;(v=u.current)!=null&&v.contains(C.target)||o(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[c]);async function b(){if(f){l(null);try{await MS(f.id)}catch(w){l(w instanceof Error?w.message:String(w))}}}return x.jsxs("div",{className:"term-view",children:[x.jsxs("div",{className:"term-bar",children:[x.jsx("div",{className:"term-title",title:e.title||e.slug,children:e.title||e.slug}),x.jsx("span",{style:{flex:1}}),a&&x.jsx("span",{className:"error",children:a}),g&&x.jsxs("button",{className:"btn sm ghost",onClick:()=>void b(),children:[x.jsx(sA,{size:13}),"Stop"]}),t.length>0&&f&&x.jsxs("div",{className:"run-history",ref:u,children:[x.jsxs("button",{className:"run-picker",title:"Switch run",onClick:()=>o(w=>!w),children:[x.jsxs("span",{className:"run-label",children:["Run ",d(f.id)]}),x.jsx(Oo,{status:f.status}),x.jsx(Du,{size:14,className:"run-picker-chev"})]}),c&&x.jsx("div",{className:"history-menu",children:t.map(w=>x.jsxs("button",{className:`history-item ${w.id===(f==null?void 0:f.id)?"active":""}`,onClick:()=>{r(w.id),o(!1)},children:[x.jsxs("span",{className:"run-label",children:["Run ",d(w.id)]}),x.jsx(Oo,{status:w.status}),x.jsx("span",{className:"when",children:ua(w.createdAt)})]},w.id))})]})]}),x.jsx("div",{className:"term-fill",children:f?x.jsx($j,{runId:f.id},f.id):x.jsx("div",{className:"term-empty",children:"No runs yet — ask the agent to launch one."})})]})}function Yj({experiment:e}){const[t,n]=X.useState(null),[r,a]=X.useState(null),[l,c]=X.useState(null),[o,u]=X.useState(null),[f,g]=X.useState({}),d=!!(l&&l.diff.trim()!==""&&l.experimentId===e.id);async function m(){a(null);try{const[w,C]=await Promise.all([XA(e.id),Ay(e.projectId)]);n(w),c(C),u(v=>{var S;return v!==null?v:C.diff.trim()!==""&&C.experimentId===e.id?$s:((S=w[0])==null?void 0:S.sha)??null})}catch(w){a(w instanceof Error?w.message:String(w))}}X.useEffect(()=>{t===null&&!r&&m()},[t,r,e.id]),X.useEffect(()=>{const w=setInterval(()=>{Ay(e.projectId).then(c).catch(()=>{})},5e3);return()=>clearInterval(w)},[e.projectId]),X.useEffect(()=>{var w;o===$s&&l&&!d&&u(((w=t==null?void 0:t[0])==null?void 0:w.sha)??null)},[o,l,d,t]),X.useEffect(()=>{if(!o||o===$s||f[o])return;const w=o;g(C=>({...C,[w]:{loading:!0}})),KA(e.id,w).then(C=>g(v=>({...v,[w]:{loading:!1,payload:C}}))).catch(C=>g(v=>({...v,[w]:{loading:!1,error:C instanceof Error?C.message:String(C)}})))},[o,f,e.id]);const b=!d&&((t==null?void 0:t.length)??0)===0;return x.jsx("div",{className:"drawer",children:x.jsx("div",{className:"drawer-body",children:x.jsx("div",{className:"drawer-section",children:r?x.jsx("div",{className:"error",children:r}):t===null?x.jsx("div",{className:"changes-note",children:"Loading changes…"}):b?x.jsx("div",{className:"changes-note",children:"No changes yet — the agent hasn't committed on this branch."}):x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"commit-picker",children:[o===$s&&x.jsx("span",{className:"uncommitted-dot"}),x.jsxs("select",{className:"input sm",value:o??"",onChange:w=>u(w.target.value),children:[d&&x.jsx("option",{value:$s,children:"● Uncommitted changes"}),t.map(w=>x.jsxs("option",{value:w.sha,children:[w.sha.slice(0,7)," — ",w.subject]},w.sha))]}),x.jsx("button",{className:"icon-btn",title:"Refresh","aria-label":"Refresh",onClick:()=>void m(),children:x.jsx(DS,{size:14})})]}),x.jsx("div",{style:{marginTop:10},children:o===$s&&l?l.truncated?x.jsxs("div",{className:"truncated-notice",children:[x.jsx("h4",{children:"Diff too large to display"}),x.jsx("p",{children:"The uncommitted diff is too large to display. View it locally with git."})]}):x.jsx(Pw,{diff:l.diff}):o?x.jsx(Gj,{state:f[o]}):x.jsx("div",{className:"changes-note",children:"Select a commit to view its diff."})})]})})})})}function Wj(e,t){return Qx(e,qx(t))}function Xj({projectId:e,path:t,onOpenFile:n}){const[r,a]=X.useState(null),[l,c]=X.useState(null),[o,u]=X.useState(!0),[f,g]=X.useState(0),d=/\.(md|mdx|markdown)$/i.test(t),[m,b]=X.useState(!1);X.useEffect(()=>{let C=!1;return u(!0),ZA(e,t).then(v=>{C||(a(v),c(null))}).catch(v=>{C||c(v.message)}).finally(()=>{C||u(!1)}),()=>{C=!0}},[e,t,f]);const w=X.useMemo(()=>r&&!r.notFound?Wj(r.content,t):null,[r,t]);return x.jsxs("div",{className:"file-view",children:[x.jsxs("div",{className:"file-view-header",children:[x.jsx(TS,{size:13,style:{flexShrink:0}}),x.jsx("code",{className:"file-view-path",title:t,children:t}),d&&x.jsx("button",{className:`icon-btn ${m?"active":""}`,title:m?"Rendered view":"Source view","aria-label":m?"Rendered view":"Source view",onClick:()=>b(C=>!C),children:x.jsx(oA,{size:13})}),x.jsx("button",{className:"icon-btn",title:"Reload file","aria-label":"Reload file",onClick:()=>g(C=>C+1),children:o?x.jsx("span",{className:"spinner"}):x.jsx(DS,{size:13})})]}),x.jsx("div",{className:"file-view-body",children:l?x.jsxs("div",{className:"file-view-note",children:["Failed to load file: ",l]}):r===null?x.jsx("div",{className:"file-view-note",children:"Loading…"}):r.notFound?x.jsx("div",{className:"file-view-note",children:"File not found in the project clone."}):x.jsxs(x.Fragment,{children:[d&&!m?x.jsx("div",{className:"file-view-md",children:x.jsx(rm,{text:r.content,onOpenFile:n})}):x.jsx("pre",{className:"file-view-code",children:x.jsx("code",{children:w})}),r.truncated&&x.jsx("div",{className:"file-view-note",children:"File truncated — showing the first 512 KB."})]})})]})}function Kj({projectName:e,onHome:t,onCollapse:n}){return x.jsxs("div",{className:"rail-brand",children:[x.jsxs("button",{className:"brand",onClick:t,title:"All projects",children:[x.jsx(cg,{size:15}),x.jsx("span",{className:"brand-project",children:e})]}),n&&x.jsx("button",{className:"icon-btn",title:"Hide sidebar","aria-label":"Hide sidebar",onClick:n,children:x.jsx(_p,{size:15})})]})}function Zj({onDone:e}){const[t,n]=X.useState(0),[r,a]=X.useState(null),[l,c]=X.useState(null),[o,u]=X.useState(!1),f=g=>{u(!0),Promise.allSettled([dg(g).then(a),OS().then(c)]).finally(()=>u(!1))};return X.useEffect(()=>f(!1),[]),x.jsx("div",{className:"home onboarding",children:x.jsx("div",{className:"home-inner",children:t===0?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"onb-eyebrow",children:["Open",x.jsx("span",{children:"Research"})," · step 1 of 2"]}),x.jsx("h2",{className:"onb-title",children:"Your coding agents"}),x.jsx("p",{className:"onb-sub",children:"orx found the agent CLIs on this machine and drives them directly — chat and autoresearch run on your own logins, no extra API keys."}),x.jsx("div",{className:"onb-cards",children:r===null?x.jsxs("div",{className:"onb-loading",children:[x.jsx("span",{className:"spinner"})," Detecting Claude Code, Codex, OpenCode…"]}):r.map(g=>x.jsx(Jj,{h:g},g.id))}),x.jsxs("div",{className:"onb-actions",children:[x.jsxs("button",{className:"btn ghost",onClick:()=>f(!0),disabled:o,children:[x.jsx(cu,{size:12,className:o?"spin":""})," Re-check"]}),x.jsx("div",{style:{flex:1}}),x.jsxs("button",{className:"btn primary",onClick:()=>n(1),children:["Continue ",x.jsx(ky,{size:13})]})]})]}):x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"onb-eyebrow",children:["Open",x.jsx("span",{children:"Research"})," · step 2 of 2"]}),x.jsx("h2",{className:"onb-title",children:"Git & GitHub"}),x.jsx("p",{className:"onb-sub",children:"A project is a clone of one of your GitHub repos, made with your own git credentials. Every experiment becomes a branch pushed to that repo — compute jobs clone it from there."}),x.jsx("div",{className:"onb-cards",children:x.jsx(e8,{git:l,onUpdate:c})}),x.jsxs("div",{className:"onb-actions",children:[x.jsxs("button",{className:"btn ghost",onClick:()=>n(0),children:[x.jsx(cg,{size:12})," Back"]}),x.jsxs("button",{className:"btn ghost",onClick:()=>f(!1),disabled:o,children:[x.jsx(cu,{size:12,className:o?"spin":""})," Re-check"]}),x.jsx("div",{style:{flex:1}}),x.jsxs("button",{className:"btn primary",onClick:e,children:["Create your first project ",x.jsx(ky,{size:13})]})]})]})})})}function Qj(e){return e.agentReady?{cls:"st-done",label:"connected"}:e.installed?{cls:"st-starting",label:"not signed in"}:{cls:"st-idle",label:"not detected"}}function Jj({h:e}){var r,a;const t=Qj(e),n=(r=e.version)==null?void 0:r.replace(/\s*\(.*\)$/,"");return x.jsxs("div",{className:"onb-card",children:[x.jsxs("div",{className:"onb-card-head",children:[x.jsx("span",{className:"onb-card-name",children:e.name}),x.jsxs("span",{className:`status-badge ${t.cls}`,children:[e.agentReady?x.jsx(Ti,{size:12,strokeWidth:3}):x.jsx("span",{className:"dot"}),t.label]})]}),e.agentReady?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"onb-card-detail mono",children:[e.account??"API key",e.plan?` · ${e.plan}`:""]}),x.jsx("div",{className:"onb-card-meta",children:[n,e.models.length>0&&`${e.models.length} model${e.models.length===1?"":"s"} — ${e.models.slice(0,3).map(l=>uu(l.id)).join(", ")}${e.models.length>3?", …":""}`].filter(Boolean).join(" · ")})]}):x.jsx("div",{className:"onb-card-meta",children:(a=e.agentNote)==null?void 0:a.replace(/`/g,"")})]})}function e8({git:e,onUpdate:t}){const[n,r]=X.useState(!1),a=()=>{navigator.clipboard.writeText("gh auth login").then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};if(e===null)return x.jsxs("div",{className:"onb-loading",children:[x.jsx("span",{className:"spinner"})," Checking git…"]});if(!e.gitVersion)return x.jsxs("div",{className:"onb-card",children:[x.jsxs("div",{className:"onb-card-head",children:[x.jsx("span",{className:"onb-card-name",children:"git"}),x.jsxs("span",{className:"status-badge st-failed",children:[x.jsx("span",{className:"dot"})," not found"]})]}),x.jsx("div",{className:"onb-card-meta",children:"Install git to clone projects, then re-open orx."})]});const l=[e.userName,e.userEmail&&`<${e.userEmail}>`].filter(Boolean).join(" ");return x.jsxs("div",{className:"onb-card",children:[x.jsxs("div",{className:"onb-card-row",children:[x.jsx("span",{className:"onb-card-name",children:"git"}),x.jsxs("span",{className:"onb-card-detail mono",children:[e.gitVersion.replace(/^git version /,""),l?` · ${l}`:""]}),x.jsxs("span",{className:`status-badge ${l?"st-done":"st-starting"}`,children:[l?x.jsx(Ti,{size:12,strokeWidth:3}):x.jsx("span",{className:"dot"}),l?"ready":"no identity"]})]}),x.jsxs("div",{className:"onb-card-row",children:[x.jsx("span",{className:"onb-card-name",children:"GitHub"}),x.jsx("span",{className:"onb-card-detail mono",children:e.githubTokenSource==="env"?"token from GITHUB_TOKEN":e.githubTokenSource==="stored"?"token saved in orx":e.githubTokenSource==="gh"?"signed in via gh CLI":"not connected"}),x.jsxs("span",{className:`status-badge ${e.githubTokenSource?"st-done":"st-starting"}`,children:[e.githubTokenSource?x.jsx(Ti,{size:12,strokeWidth:3}):x.jsx("span",{className:"dot"}),e.githubTokenSource?"ready":"check"]})]}),!l&&x.jsxs("div",{className:"onb-card-meta",children:["Set ",x.jsx("code",{children:"git config --global user.name / user.email"})," so the agent can commit."]}),!e.githubTokenSource&&x.jsxs("div",{className:"onb-gh-options",children:[x.jsx("div",{className:"onb-card-meta",children:"GitHub access is used to clone your repos and push experiment branches. Connect either way:"}),x.jsxs("div",{className:"onb-gh-option",children:[x.jsx("span",{className:"onb-gh-option-label",children:"GitHub CLI"}),x.jsx("div",{className:"onb-gh-option-body",children:e.ghInstalled?x.jsxs(x.Fragment,{children:[x.jsx("code",{className:"onb-gh-cmd",children:"gh auth login"}),x.jsxs("button",{className:"btn ghost",onClick:a,children:[n?x.jsx(Ti,{size:12,strokeWidth:3}):x.jsx(hg,{size:12}),n?"Copied":"Copy"]}),x.jsx("span",{className:"onb-gh-hint",children:"run in a terminal, then Re-check"})]}):x.jsxs("span",{className:"onb-gh-hint",children:["install the GitHub CLI, run ",x.jsx("code",{children:"gh auth login"}),", then Re-check"]})})]}),x.jsx("div",{className:"onb-gh-or",children:"or"}),x.jsxs("div",{className:"onb-gh-option",children:[x.jsx("span",{className:"onb-gh-option-label",children:"Paste a token"}),x.jsx(ew,{onSaved:t})]})]})]})}function pb(e){const t=e.trim().replace(/^git@github\.com:/i,"").replace(/^https?:\/\/(www\.)?github\.com\//i,"").replace(/\.git$/i,"").replace(/^\/+|\/+$/g,""),[n,r]=t.split("/");return!n||!r||/[\s:@]/.test(n)||/[\s:@]/.test(r)?null:{owner:n,repo:r}}function t8(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48).replace(/-+$/,"")||"experiment"}function n8({onCreated:e,onCancel:t}){const[n,r]=X.useState("existing"),[a,l]=X.useState("use"),[c,o]=X.useState(""),[u,f]=X.useState(""),[g,d]=X.useState(!1),[m,b]=X.useState("main"),[w,C]=X.useState(!1),[v,y]=X.useState(null),S=pb(c),_=u.trim()&&(n==="new"||S!==null),k=T=>{var R;o(T),g||f(((R=pb(T))==null?void 0:R.repo)??"")};async function D(T){if(T.preventDefault(),!(!_||w)){C(!0),y(null);try{const R=await $A(n==="new"?{name:u.trim(),createRepo:!0}:{name:u.trim(),githubOwner:S.owner,githubRepo:S.repo,baselineBranch:m.trim()||"main",forkRepo:a==="fork"});e(R)}catch(R){y(R instanceof Error?R.message:String(R))}finally{C(!1)}}}return x.jsxs("form",{className:"form",onSubmit:D,children:[x.jsxs("div",{className:"seg form-seg",children:[x.jsx("button",{type:"button",className:n==="existing"?"active":"",onClick:()=>r("existing"),children:"Existing repo"}),x.jsx("button",{type:"button",className:n==="new"?"active":"",onClick:()=>r("new"),children:"New blank repo"})]}),n==="existing"?x.jsxs(x.Fragment,{children:[x.jsxs("label",{children:["GitHub repository",x.jsx("input",{value:c,onChange:T=>k(T.target.value),placeholder:"https://github.com/karpathy/nanoGPT",autoFocus:!0,spellCheck:!1}),x.jsx("span",{className:`repo-hint mono ${S?"ok":""}`,children:S?`${S.owner} / ${S.repo}`:c.trim()?"paste a GitHub URL or owner/repo":"URL or owner/repo — cloned with your git credentials"})]}),x.jsxs("div",{className:"seg form-seg",children:[x.jsx("button",{type:"button",className:a==="use"?"active":"",onClick:()=>l("use"),children:"Use this repo"}),x.jsx("button",{type:"button",className:a==="fork"?"active":"",onClick:()=>l("fork"),children:"Fork a copy"})]}),x.jsx("span",{className:"repo-hint",children:a==="fork"?`snapshots ${S?`${S.owner}/${S.repo}`:"the repo"} into a private repo on your account`:"experiments push branches here — if you can't push to it, a fork is made automatically"}),x.jsxs("div",{className:"row2",children:[x.jsxs("label",{children:["Project name",x.jsx("input",{value:u,onChange:T=>{d(!0),f(T.target.value)},placeholder:"my-research"})]}),x.jsxs("label",{children:["Branch",x.jsx("input",{value:m,onChange:T=>b(T.target.value),placeholder:"main"})]})]})]}):x.jsxs("label",{children:["Project name",x.jsx("input",{value:u,onChange:T=>{d(!0),f(T.target.value)},placeholder:"my-research",autoFocus:!0}),x.jsx("span",{className:`repo-hint mono ${u.trim()?"ok":""}`,children:u.trim()?`creates github.com/you/${t8(u)} · private`:"a blank private repo is created on your GitHub account"})]}),v&&x.jsx("div",{className:"error",children:v}),x.jsxs("div",{className:"actions",children:[t&&x.jsx("button",{type:"button",className:"btn ghost",onClick:t,children:"Cancel"}),x.jsx("button",{type:"submit",className:"btn primary",disabled:!_||w,children:w?n==="new"?"Creating repo…":a==="fork"?"Forking repo…":"Cloning repo…":"Create project"})]})]})}function gb({projects:e,onOpen:t,onCreated:n,onDeleted:r}){const[a,l]=X.useState(!1),[c,o]=X.useState(null);async function u(f){if(window.confirm(`Delete project "${f.name}"? Its experiments, runs and chats are removed from orx. The GitHub repo (${f.githubOwner}/${f.githubRepo}) is kept.`)){o(f.id);try{await GA(f.id),r(f.id)}catch(d){window.alert(d instanceof Error?d.message:String(d))}finally{o(null)}}}return x.jsxs("div",{className:"home",children:[x.jsxs("div",{className:"home-inner",children:[x.jsxs("div",{className:"home-brand",children:["Open",x.jsx("span",{children:"Research"})]}),x.jsxs("div",{className:"home-head",children:[x.jsx("h2",{children:"Projects"}),x.jsxs("button",{className:"btn sm",onClick:()=>l(!0),children:[x.jsx(fg,{size:13})," New project"]})]}),x.jsx("div",{className:"home-list",children:e.length===0?x.jsx("div",{className:"changes-note",children:"No projects yet — create one to get started."}):e.map(f=>x.jsxs("div",{className:"project-card",role:"button",tabIndex:0,onClick:()=>t(f.id),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&t(f.id)},children:[x.jsx("span",{className:"name",children:f.name}),x.jsxs("span",{className:"repo mono",children:[f.githubOwner,"/",f.githubRepo," · ",f.baselineBranch]}),x.jsxs("span",{className:"time",children:["created ",ua(f.createdAt)]}),x.jsx("button",{className:"project-delete",title:`Delete ${f.name}`,disabled:c===f.id,onClick:g=>{g.stopPropagation(),u(f)},children:x.jsx(Mu,{size:14})})]},f.id))})]}),a&&x.jsx("div",{className:"modal-backdrop",onClick:()=>l(!1),children:x.jsxs("div",{className:"modal",onClick:f=>f.stopPropagation(),children:[x.jsx("h2",{children:"New project"}),x.jsx(n8,{onCancel:()=>l(!1),onCreated:f=>{l(!1),n(f)}})]})})]})}function i8(e){const t=jS(e.backend);return t?[t,BS(e.backend)].filter(Boolean).join(" · "):"—"}function r8({runs:e,experiments:t,onOpen:n,onOpenChanges:r,onCancel:a}){const l=new Map(t.map(o=>[o.id,o.slug])),c=[...e].sort((o,u)=>u.createdAt-o.createdAt);return c.length===0?x.jsx("div",{className:"empty-state",children:x.jsx("p",{children:"No runs yet."})}):x.jsx("div",{className:"runs-table-wrap",children:x.jsxs("table",{className:"runs-table",children:[x.jsx("thead",{children:x.jsxs("tr",{children:[x.jsx("th",{children:"Run"}),x.jsx("th",{children:"Experiment"}),x.jsx("th",{children:"Status"}),x.jsx("th",{children:"Backend"}),x.jsx("th",{children:"Commit"}),x.jsx("th",{children:"Started"}),x.jsx("th",{children:"Exit"}),x.jsx("th",{})]})}),x.jsx("tbody",{children:c.map(o=>{const u=o.status==="running"||o.status==="starting";return x.jsxs("tr",{className:"clickable",onClick:()=>n(o),children:[x.jsx("td",{className:"mono",children:bp(o.id)}),x.jsx("td",{className:"mono",children:l.get(o.experimentId)??bp(o.experimentId)}),x.jsx("td",{children:x.jsx(Oo,{status:o.status})}),x.jsx("td",{className:"mono",children:i8(o)}),x.jsx("td",{className:"mono",children:o.commitSha?o.commitSha.slice(0,7):"—"}),x.jsx("td",{children:ua(o.createdAt)}),x.jsx("td",{className:"mono",children:o.exitCode??"—"}),x.jsx("td",{children:x.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[x.jsx("button",{className:"icon-btn",title:"Open changes",onClick:f=>{f.stopPropagation(),r(o.experimentId)},children:x.jsx(Ru,{size:14})}),u&&x.jsx("button",{className:"btn sm danger",onClick:f=>{f.stopPropagation(),a(o.id)},children:"Cancel"})]})})]},o.id)})})]})})}function Lt(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Lt(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var s8={value:()=>{}};function ih(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new nu(n)}function nu(e){this._=e}function a8(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",a=n.indexOf(".");if(a>=0&&(r=n.slice(a+1),n=n.slice(0,a)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}nu.prototype=ih.prototype={constructor:nu,on:function(e,t){var n=this._,r=a8(e+"",n),a,l=-1,c=r.length;if(arguments.length<2){for(;++l<c;)if((a=(e=r[l]).type)&&(a=o8(n[a],e.name)))return a;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++l<c;)if(a=(e=r[l]).type)n[a]=mb(n[a],e.name,t);else if(t==null)for(a in n)n[a]=mb(n[a],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new nu(e)},call:function(e,t){if((a=arguments.length-2)>0)for(var n=new Array(a),r=0,a,l;r<a;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],r=0,a=l.length;r<a;++r)l[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],a=0,l=r.length;a<l;++a)r[a].value.apply(t,n)}};function o8(e,t){for(var n=0,r=e.length,a;n<r;++n)if((a=e[n]).name===t)return a.value}function mb(e,t,n){for(var r=0,a=e.length;r<a;++r)if(e[r].name===t){e[r]=s8,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Yp="http://www.w3.org/1999/xhtml";const _b={svg:"http://www.w3.org/2000/svg",xhtml:Yp,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function rh(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),_b.hasOwnProperty(t)?{space:_b[t],local:e}:e}function l8(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Yp&&t.documentElement.namespaceURI===Yp?t.createElement(e):t.createElementNS(n,e)}}function c8(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function $w(e){var t=rh(e);return(t.local?c8:l8)(t)}function u8(){}function gm(e){return e==null?u8:function(){return this.querySelector(e)}}function h8(e){typeof e!="function"&&(e=gm(e));for(var t=this._groups,n=t.length,r=new Array(n),a=0;a<n;++a)for(var l=t[a],c=l.length,o=r[a]=new Array(c),u,f,g=0;g<c;++g)(u=l[g])&&(f=e.call(u,u.__data__,g,l))&&("__data__"in u&&(f.__data__=u.__data__),o[g]=f);return new En(r,this._parents)}function f8(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function d8(){return[]}function Gw(e){return e==null?d8:function(){return this.querySelectorAll(e)}}function p8(e){return function(){return f8(e.apply(this,arguments))}}function g8(e){typeof e=="function"?e=p8(e):e=Gw(e);for(var t=this._groups,n=t.length,r=[],a=[],l=0;l<n;++l)for(var c=t[l],o=c.length,u,f=0;f<o;++f)(u=c[f])&&(r.push(e.call(u,u.__data__,f,c)),a.push(u));return new En(r,a)}function qw(e){return function(){return this.matches(e)}}function Vw(e){return function(t){return t.matches(e)}}var m8=Array.prototype.find;function _8(e){return function(){return m8.call(this.children,e)}}function v8(){return this.firstElementChild}function y8(e){return this.select(e==null?v8:_8(typeof e=="function"?e:Vw(e)))}var b8=Array.prototype.filter;function S8(){return Array.from(this.children)}function x8(e){return function(){return b8.call(this.children,e)}}function w8(e){return this.selectAll(e==null?S8:x8(typeof e=="function"?e:Vw(e)))}function C8(e){typeof e!="function"&&(e=qw(e));for(var t=this._groups,n=t.length,r=new Array(n),a=0;a<n;++a)for(var l=t[a],c=l.length,o=r[a]=[],u,f=0;f<c;++f)(u=l[f])&&e.call(u,u.__data__,f,l)&&o.push(u);return new En(r,this._parents)}function Yw(e){return new Array(e.length)}function E8(){return new En(this._enter||this._groups.map(Yw),this._parents)}function _u(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}_u.prototype={constructor:_u,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function k8(e){return function(){return e}}function A8(e,t,n,r,a,l){for(var c=0,o,u=t.length,f=l.length;c<f;++c)(o=t[c])?(o.__data__=l[c],r[c]=o):n[c]=new _u(e,l[c]);for(;c<u;++c)(o=t[c])&&(a[c]=o)}function T8(e,t,n,r,a,l,c){var o,u,f=new Map,g=t.length,d=l.length,m=new Array(g),b;for(o=0;o<g;++o)(u=t[o])&&(m[o]=b=c.call(u,u.__data__,o,t)+"",f.has(b)?a[o]=u:f.set(b,u));for(o=0;o<d;++o)b=c.call(e,l[o],o,l)+"",(u=f.get(b))?(r[o]=u,u.__data__=l[o],f.delete(b)):n[o]=new _u(e,l[o]);for(o=0;o<g;++o)(u=t[o])&&f.get(m[o])===u&&(a[o]=u)}function N8(e){return e.__data__}function D8(e,t){if(!arguments.length)return Array.from(this,N8);var n=t?T8:A8,r=this._parents,a=this._groups;typeof e!="function"&&(e=k8(e));for(var l=a.length,c=new Array(l),o=new Array(l),u=new Array(l),f=0;f<l;++f){var g=r[f],d=a[f],m=d.length,b=R8(e.call(g,g&&g.__data__,f,r)),w=b.length,C=o[f]=new Array(w),v=c[f]=new Array(w),y=u[f]=new Array(m);n(g,d,C,v,y,b,t);for(var S=0,_=0,k,D;S<w;++S)if(k=C[S]){for(S>=_&&(_=S+1);!(D=v[_])&&++_<w;);k._next=D||null}}return c=new En(c,r),c._enter=o,c._exit=u,c}function R8(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function M8(){return new En(this._exit||this._groups.map(Yw),this._parents)}function L8(e,t,n){var r=this.enter(),a=this,l=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(a=t(a),a&&(a=a.selection())),n==null?l.remove():n(l),r&&a?r.merge(a).order():a}function O8(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,a=n.length,l=r.length,c=Math.min(a,l),o=new Array(a),u=0;u<c;++u)for(var f=n[u],g=r[u],d=f.length,m=o[u]=new Array(d),b,w=0;w<d;++w)(b=f[w]||g[w])&&(m[w]=b);for(;u<a;++u)o[u]=n[u];return new En(o,this._parents)}function j8(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],a=r.length-1,l=r[a],c;--a>=0;)(c=r[a])&&(l&&c.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(c,l),l=c);return this}function B8(e){e||(e=I8);function t(d,m){return d&&m?e(d.__data__,m.__data__):!d-!m}for(var n=this._groups,r=n.length,a=new Array(r),l=0;l<r;++l){for(var c=n[l],o=c.length,u=a[l]=new Array(o),f,g=0;g<o;++g)(f=c[g])&&(u[g]=f);u.sort(t)}return new En(a,this._parents).order()}function I8(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function z8(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function H8(){return Array.from(this)}function F8(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],a=0,l=r.length;a<l;++a){var c=r[a];if(c)return c}return null}function P8(){let e=0;for(const t of this)++e;return e}function U8(){return!this.node()}function $8(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var a=t[n],l=0,c=a.length,o;l<c;++l)(o=a[l])&&e.call(o,o.__data__,l,a);return this}function G8(e){return function(){this.removeAttribute(e)}}function q8(e){return function(){this.removeAttributeNS(e.space,e.local)}}function V8(e,t){return function(){this.setAttribute(e,t)}}function Y8(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function W8(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function X8(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function K8(e,t){var n=rh(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?q8:G8:typeof t=="function"?n.local?X8:W8:n.local?Y8:V8)(n,t))}function Ww(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Z8(e){return function(){this.style.removeProperty(e)}}function Q8(e,t,n){return function(){this.style.setProperty(e,t,n)}}function J8(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function eB(e,t,n){return arguments.length>1?this.each((t==null?Z8:typeof t=="function"?J8:Q8)(e,t,n??"")):ia(this.node(),e)}function ia(e,t){return e.style.getPropertyValue(t)||Ww(e).getComputedStyle(e,null).getPropertyValue(t)}function tB(e){return function(){delete this[e]}}function nB(e,t){return function(){this[e]=t}}function iB(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function rB(e,t){return arguments.length>1?this.each((t==null?tB:typeof t=="function"?iB:nB)(e,t)):this.node()[e]}function Xw(e){return e.trim().split(/^|\s+/)}function mm(e){return e.classList||new Kw(e)}function Kw(e){this._node=e,this._names=Xw(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 Zw(e,t){for(var n=mm(e),r=-1,a=t.length;++r<a;)n.add(t[r])}function Qw(e,t){for(var n=mm(e),r=-1,a=t.length;++r<a;)n.remove(t[r])}function sB(e){return function(){Zw(this,e)}}function aB(e){return function(){Qw(this,e)}}function oB(e,t){return function(){(t.apply(this,arguments)?Zw:Qw)(this,e)}}function lB(e,t){var n=Xw(e+"");if(arguments.length<2){for(var r=mm(this.node()),a=-1,l=n.length;++a<l;)if(!r.contains(n[a]))return!1;return!0}return this.each((typeof t=="function"?oB:t?sB:aB)(n,t))}function cB(){this.textContent=""}function uB(e){return function(){this.textContent=e}}function hB(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function fB(e){return arguments.length?this.each(e==null?cB:(typeof e=="function"?hB:uB)(e)):this.node().textContent}function dB(){this.innerHTML=""}function pB(e){return function(){this.innerHTML=e}}function gB(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function mB(e){return arguments.length?this.each(e==null?dB:(typeof e=="function"?gB:pB)(e)):this.node().innerHTML}function _B(){this.nextSibling&&this.parentNode.appendChild(this)}function vB(){return this.each(_B)}function yB(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function bB(){return this.each(yB)}function SB(e){var t=typeof e=="function"?e:$w(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function xB(){return null}function wB(e,t){var n=typeof e=="function"?e:$w(e),r=t==null?xB:typeof t=="function"?t:gm(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function CB(){var e=this.parentNode;e&&e.removeChild(this)}function EB(){return this.each(CB)}function kB(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function AB(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function TB(e){return this.select(e?AB:kB)}function NB(e){return arguments.length?this.property("__data__",e):this.node().__data__}function DB(e){return function(t){e.call(this,t,this.__data__)}}function RB(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function MB(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,a=t.length,l;n<a;++n)l=t[n],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):t[++r]=l;++r?t.length=r:delete this.__on}}}function LB(e,t,n){return function(){var r=this.__on,a,l=DB(t);if(r){for(var c=0,o=r.length;c<o;++c)if((a=r[c]).type===e.type&&a.name===e.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=l,a.options=n),a.value=t;return}}this.addEventListener(e.type,l,n),a={type:e.type,name:e.name,value:t,listener:l,options:n},r?r.push(a):this.__on=[a]}}function OB(e,t,n){var r=RB(e+""),a,l=r.length,c;if(arguments.length<2){var o=this.node().__on;if(o){for(var u=0,f=o.length,g;u<f;++u)for(a=0,g=o[u];a<l;++a)if((c=r[a]).type===g.type&&c.name===g.name)return g.value}return}for(o=t?LB:MB,a=0;a<l;++a)this.each(o(r[a],t,n));return this}function Jw(e,t,n){var r=Ww(e),a=r.CustomEvent;typeof a=="function"?a=new a(t,n):(a=r.document.createEvent("Event"),n?(a.initEvent(t,n.bubbles,n.cancelable),a.detail=n.detail):a.initEvent(t,!1,!1)),e.dispatchEvent(a)}function jB(e,t){return function(){return Jw(this,e,t)}}function BB(e,t){return function(){return Jw(this,e,t.apply(this,arguments))}}function IB(e,t){return this.each((typeof t=="function"?BB:jB)(e,t))}function*zB(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],a=0,l=r.length,c;a<l;++a)(c=r[a])&&(yield c)}var eC=[null];function En(e,t){this._groups=e,this._parents=t}function nl(){return new En([[document.documentElement]],eC)}function HB(){return this}En.prototype=nl.prototype={constructor:En,select:h8,selectAll:g8,selectChild:y8,selectChildren:w8,filter:C8,data:D8,enter:E8,exit:M8,join:L8,merge:O8,selection:HB,order:j8,sort:B8,call:z8,nodes:H8,node:F8,size:P8,empty:U8,each:$8,attr:K8,style:eB,property:rB,classed:lB,text:fB,html:mB,raise:vB,lower:bB,append:SB,insert:wB,remove:EB,clone:TB,datum:NB,on:OB,dispatch:IB,[Symbol.iterator]:zB};function yn(e){return typeof e=="string"?new En([[document.querySelector(e)]],[document.documentElement]):new En([[e]],eC)}function FB(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Fn(e,t){if(e=FB(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var a=t.getBoundingClientRect();return[e.clientX-a.left-t.clientLeft,e.clientY-a.top-t.clientTop]}}return[e.pageX,e.pageY]}const PB={passive:!1},Ho={capture:!0,passive:!1};function rp(e){e.stopImmediatePropagation()}function Js(e){e.preventDefault(),e.stopImmediatePropagation()}function tC(e){var t=e.document.documentElement,n=yn(e).on("dragstart.drag",Js,Ho);"onselectstart"in t?n.on("selectstart.drag",Js,Ho):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function nC(e,t){var n=e.document.documentElement,r=yn(e).on("dragstart.drag",null);t&&(r.on("click.drag",Js,Ho),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Fc=e=>()=>e;function Wp(e,{sourceEvent:t,subject:n,target:r,identifier:a,active:l,x:c,y:o,dx:u,dy:f,dispatch:g}){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:r,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:l,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:o,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:g}})}Wp.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function UB(e){return!e.ctrlKey&&!e.button}function $B(){return this.parentNode}function GB(e,t){return t??{x:e.x,y:e.y}}function qB(){return navigator.maxTouchPoints||"ontouchstart"in this}function iC(){var e=UB,t=$B,n=GB,r=qB,a={},l=ih("start","drag","end"),c=0,o,u,f,g,d=0;function m(k){k.on("mousedown.drag",b).filter(r).on("touchstart.drag",v).on("touchmove.drag",y,PB).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(k,D){if(!(g||!e.call(this,k,D))){var T=_(this,t.call(this,k,D),k,D,"mouse");T&&(yn(k.view).on("mousemove.drag",w,Ho).on("mouseup.drag",C,Ho),tC(k.view),rp(k),f=!1,o=k.clientX,u=k.clientY,T("start",k))}}function w(k){if(Js(k),!f){var D=k.clientX-o,T=k.clientY-u;f=D*D+T*T>d}a.mouse("drag",k)}function C(k){yn(k.view).on("mousemove.drag mouseup.drag",null),nC(k.view,f),Js(k),a.mouse("end",k)}function v(k,D){if(e.call(this,k,D)){var T=k.changedTouches,R=t.call(this,k,D),N=T.length,L,I;for(L=0;L<N;++L)(I=_(this,R,k,D,T[L].identifier,T[L]))&&(rp(k),I("start",k,T[L]))}}function y(k){var D=k.changedTouches,T=D.length,R,N;for(R=0;R<T;++R)(N=a[D[R].identifier])&&(Js(k),N("drag",k,D[R]))}function S(k){var D=k.changedTouches,T=D.length,R,N;for(g&&clearTimeout(g),g=setTimeout(function(){g=null},500),R=0;R<T;++R)(N=a[D[R].identifier])&&(rp(k),N("end",k,D[R]))}function _(k,D,T,R,N,L){var I=l.copy(),z=Fn(L||T,D),q,P,U;if((U=n.call(k,new Wp("beforestart",{sourceEvent:T,target:m,identifier:N,active:c,x:z[0],y:z[1],dx:0,dy:0,dispatch:I}),R))!=null)return q=U.x-z[0]||0,P=U.y-z[1]||0,function V(G,W,K){var j=z,M;switch(G){case"start":a[N]=V,M=c++;break;case"end":delete a[N],--c;case"drag":z=Fn(K||W,D),M=c;break}I.call(G,k,new Wp(G,{sourceEvent:W,subject:U,target:m,identifier:N,active:M,x:z[0]+q,y:z[1]+P,dx:z[0]-j[0],dy:z[1]-j[1],dispatch:I}),R)}}return m.filter=function(k){return arguments.length?(e=typeof k=="function"?k:Fc(!!k),m):e},m.container=function(k){return arguments.length?(t=typeof k=="function"?k:Fc(k),m):t},m.subject=function(k){return arguments.length?(n=typeof k=="function"?k:Fc(k),m):n},m.touchable=function(k){return arguments.length?(r=typeof k=="function"?k:Fc(!!k),m):r},m.on=function(){var k=l.on.apply(l,arguments);return k===l?m:k},m.clickDistance=function(k){return arguments.length?(d=(k=+k)*k,m):Math.sqrt(d)},m}function _m(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function rC(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function il(){}var Fo=.7,vu=1/Fo,ea="\\s*([+-]?\\d+)\\s*",Po="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ti="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",VB=/^#([0-9a-f]{3,8})$/,YB=new RegExp(`^rgb\\(${ea},${ea},${ea}\\)$`),WB=new RegExp(`^rgb\\(${ti},${ti},${ti}\\)$`),XB=new RegExp(`^rgba\\(${ea},${ea},${ea},${Po}\\)$`),KB=new RegExp(`^rgba\\(${ti},${ti},${ti},${Po}\\)$`),ZB=new RegExp(`^hsl\\(${Po},${ti},${ti}\\)$`),QB=new RegExp(`^hsla\\(${Po},${ti},${ti},${Po}\\)$`),vb={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};_m(il,Yr,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:yb,formatHex:yb,formatHex8:JB,formatHsl:eI,formatRgb:bb,toString:bb});function yb(){return this.rgb().formatHex()}function JB(){return this.rgb().formatHex8()}function eI(){return sC(this).formatHsl()}function bb(){return this.rgb().formatRgb()}function Yr(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=VB.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Sb(t):n===3?new ln(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Pc(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Pc(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=YB.exec(e))?new ln(t[1],t[2],t[3],1):(t=WB.exec(e))?new ln(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=XB.exec(e))?Pc(t[1],t[2],t[3],t[4]):(t=KB.exec(e))?Pc(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ZB.exec(e))?Cb(t[1],t[2]/100,t[3]/100,1):(t=QB.exec(e))?Cb(t[1],t[2]/100,t[3]/100,t[4]):vb.hasOwnProperty(e)?Sb(vb[e]):e==="transparent"?new ln(NaN,NaN,NaN,0):null}function Sb(e){return new ln(e>>16&255,e>>8&255,e&255,1)}function Pc(e,t,n,r){return r<=0&&(e=t=n=NaN),new ln(e,t,n,r)}function tI(e){return e instanceof il||(e=Yr(e)),e?(e=e.rgb(),new ln(e.r,e.g,e.b,e.opacity)):new ln}function Xp(e,t,n,r){return arguments.length===1?tI(e):new ln(e,t,n,r??1)}function ln(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}_m(ln,Xp,rC(il,{brighter(e){return e=e==null?vu:Math.pow(vu,e),new ln(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Fo:Math.pow(Fo,e),new ln(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ln(Gr(this.r),Gr(this.g),Gr(this.b),yu(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:xb,formatHex:xb,formatHex8:nI,formatRgb:wb,toString:wb}));function xb(){return`#${Ur(this.r)}${Ur(this.g)}${Ur(this.b)}`}function nI(){return`#${Ur(this.r)}${Ur(this.g)}${Ur(this.b)}${Ur((isNaN(this.opacity)?1:this.opacity)*255)}`}function wb(){const e=yu(this.opacity);return`${e===1?"rgb(":"rgba("}${Gr(this.r)}, ${Gr(this.g)}, ${Gr(this.b)}${e===1?")":`, ${e})`}`}function yu(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Gr(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ur(e){return e=Gr(e),(e<16?"0":"")+e.toString(16)}function Cb(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Pn(e,t,n,r)}function sC(e){if(e instanceof Pn)return new Pn(e.h,e.s,e.l,e.opacity);if(e instanceof il||(e=Yr(e)),!e)return new Pn;if(e instanceof Pn)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,a=Math.min(t,n,r),l=Math.max(t,n,r),c=NaN,o=l-a,u=(l+a)/2;return o?(t===l?c=(n-r)/o+(n<r)*6:n===l?c=(r-t)/o+2:c=(t-n)/o+4,o/=u<.5?l+a:2-l-a,c*=60):o=u>0&&u<1?0:c,new Pn(c,o,u,e.opacity)}function iI(e,t,n,r){return arguments.length===1?sC(e):new Pn(e,t,n,r??1)}function Pn(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}_m(Pn,iI,rC(il,{brighter(e){return e=e==null?vu:Math.pow(vu,e),new Pn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Fo:Math.pow(Fo,e),new Pn(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,r=n+(n<.5?n:1-n)*t,a=2*n-r;return new ln(sp(e>=240?e-240:e+120,a,r),sp(e,a,r),sp(e<120?e+240:e-120,a,r),this.opacity)},clamp(){return new Pn(Eb(this.h),Uc(this.s),Uc(this.l),yu(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=yu(this.opacity);return`${e===1?"hsl(":"hsla("}${Eb(this.h)}, ${Uc(this.s)*100}%, ${Uc(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Eb(e){return e=(e||0)%360,e<0?e+360:e}function Uc(e){return Math.max(0,Math.min(1,e||0))}function sp(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 vm=e=>()=>e;function rI(e,t){return function(n){return e+n*t}}function sI(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function aI(e){return(e=+e)==1?aC:function(t,n){return n-t?sI(t,n,e):vm(isNaN(t)?n:t)}}function aC(e,t){var n=t-e;return n?rI(e,n):vm(isNaN(e)?t:e)}const bu=(function e(t){var n=aI(t);function r(a,l){var c=n((a=Xp(a)).r,(l=Xp(l)).r),o=n(a.g,l.g),u=n(a.b,l.b),f=aC(a.opacity,l.opacity);return function(g){return a.r=c(g),a.g=o(g),a.b=u(g),a.opacity=f(g),a+""}}return r.gamma=e,r})(1);function oI(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),a;return function(l){for(a=0;a<n;++a)r[a]=e[a]*(1-l)+t[a]*l;return r}}function lI(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function cI(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,a=new Array(r),l=new Array(n),c;for(c=0;c<r;++c)a[c]=Ao(e[c],t[c]);for(;c<n;++c)l[c]=t[c];return function(o){for(c=0;c<r;++c)l[c]=a[c](o);return l}}function uI(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function ei(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function hI(e,t){var n={},r={},a;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(a in t)a in e?n[a]=Ao(e[a],t[a]):r[a]=t[a];return function(l){for(a in n)r[a]=n[a](l);return r}}var Kp=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ap=new RegExp(Kp.source,"g");function fI(e){return function(){return e}}function dI(e){return function(t){return e(t)+""}}function oC(e,t){var n=Kp.lastIndex=ap.lastIndex=0,r,a,l,c=-1,o=[],u=[];for(e=e+"",t=t+"";(r=Kp.exec(e))&&(a=ap.exec(t));)(l=a.index)>n&&(l=t.slice(n,l),o[c]?o[c]+=l:o[++c]=l),(r=r[0])===(a=a[0])?o[c]?o[c]+=a:o[++c]=a:(o[++c]=null,u.push({i:c,x:ei(r,a)})),n=ap.lastIndex;return n<t.length&&(l=t.slice(n),o[c]?o[c]+=l:o[++c]=l),o.length<2?u[0]?dI(u[0].x):fI(t):(t=u.length,function(f){for(var g=0,d;g<t;++g)o[(d=u[g]).i]=d.x(f);return o.join("")})}function Ao(e,t){var n=typeof t,r;return t==null||n==="boolean"?vm(t):(n==="number"?ei:n==="string"?(r=Yr(t))?(t=r,bu):oC:t instanceof Yr?bu:t instanceof Date?uI:lI(t)?oI:Array.isArray(t)?cI:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?hI:ei)(e,t)}var kb=180/Math.PI,Zp={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function lC(e,t,n,r,a,l){var c,o,u;return(c=Math.sqrt(e*e+t*t))&&(e/=c,t/=c),(u=e*n+t*r)&&(n-=e*u,r-=t*u),(o=Math.sqrt(n*n+r*r))&&(n/=o,r/=o,u/=o),e*r<t*n&&(e=-e,t=-t,u=-u,c=-c),{translateX:a,translateY:l,rotate:Math.atan2(t,e)*kb,skewX:Math.atan(u)*kb,scaleX:c,scaleY:o}}var $c;function pI(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Zp:lC(t.a,t.b,t.c,t.d,t.e,t.f)}function gI(e){return e==null||($c||($c=document.createElementNS("http://www.w3.org/2000/svg","g")),$c.setAttribute("transform",e),!(e=$c.transform.baseVal.consolidate()))?Zp:(e=e.matrix,lC(e.a,e.b,e.c,e.d,e.e,e.f))}function cC(e,t,n,r){function a(f){return f.length?f.pop()+" ":""}function l(f,g,d,m,b,w){if(f!==d||g!==m){var C=b.push("translate(",null,t,null,n);w.push({i:C-4,x:ei(f,d)},{i:C-2,x:ei(g,m)})}else(d||m)&&b.push("translate("+d+t+m+n)}function c(f,g,d,m){f!==g?(f-g>180?g+=360:g-f>180&&(f+=360),m.push({i:d.push(a(d)+"rotate(",null,r)-2,x:ei(f,g)})):g&&d.push(a(d)+"rotate("+g+r)}function o(f,g,d,m){f!==g?m.push({i:d.push(a(d)+"skewX(",null,r)-2,x:ei(f,g)}):g&&d.push(a(d)+"skewX("+g+r)}function u(f,g,d,m,b,w){if(f!==d||g!==m){var C=b.push(a(b)+"scale(",null,",",null,")");w.push({i:C-4,x:ei(f,d)},{i:C-2,x:ei(g,m)})}else(d!==1||m!==1)&&b.push(a(b)+"scale("+d+","+m+")")}return function(f,g){var d=[],m=[];return f=e(f),g=e(g),l(f.translateX,f.translateY,g.translateX,g.translateY,d,m),c(f.rotate,g.rotate,d,m),o(f.skewX,g.skewX,d,m),u(f.scaleX,f.scaleY,g.scaleX,g.scaleY,d,m),f=g=null,function(b){for(var w=-1,C=m.length,v;++w<C;)d[(v=m[w]).i]=v.x(b);return d.join("")}}}var mI=cC(pI,"px, ","px)","deg)"),_I=cC(gI,", ",")",")"),vI=1e-12;function Ab(e){return((e=Math.exp(e))+1/e)/2}function yI(e){return((e=Math.exp(e))-1/e)/2}function bI(e){return((e=Math.exp(2*e))-1)/(e+1)}const iu=(function e(t,n,r){function a(l,c){var o=l[0],u=l[1],f=l[2],g=c[0],d=c[1],m=c[2],b=g-o,w=d-u,C=b*b+w*w,v,y;if(C<vI)y=Math.log(m/f)/t,v=function(R){return[o+R*b,u+R*w,f*Math.exp(t*R*y)]};else{var S=Math.sqrt(C),_=(m*m-f*f+r*C)/(2*f*n*S),k=(m*m-f*f-r*C)/(2*m*n*S),D=Math.log(Math.sqrt(_*_+1)-_),T=Math.log(Math.sqrt(k*k+1)-k);y=(T-D)/t,v=function(R){var N=R*y,L=Ab(D),I=f/(n*S)*(L*bI(t*N+D)-yI(D));return[o+I*b,u+I*w,f*L/Ab(t*N+D)]}}return v.duration=y*1e3*t/Math.SQRT2,v}return a.rho=function(l){var c=Math.max(.001,+l),o=c*c,u=o*o;return e(c,o,u)},a})(Math.SQRT2,2,4);var ra=0,So=0,yo=0,uC=1e3,Su,xo,xu=0,Wr=0,sh=0,Uo=typeof performance=="object"&&performance.now?performance:Date,hC=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ym(){return Wr||(hC(SI),Wr=Uo.now()+sh)}function SI(){Wr=0}function wu(){this._call=this._time=this._next=null}wu.prototype=fC.prototype={constructor:wu,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ym():+n)+(t==null?0:+t),!this._next&&xo!==this&&(xo?xo._next=this:Su=this,xo=this),this._call=e,this._time=n,Qp()},stop:function(){this._call&&(this._call=null,this._time=1/0,Qp())}};function fC(e,t,n){var r=new wu;return r.restart(e,t,n),r}function xI(){ym(),++ra;for(var e=Su,t;e;)(t=Wr-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ra}function Tb(){Wr=(xu=Uo.now())+sh,ra=So=0;try{xI()}finally{ra=0,CI(),Wr=0}}function wI(){var e=Uo.now(),t=e-xu;t>uC&&(sh-=t,xu=e)}function CI(){for(var e,t=Su,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Su=n);xo=e,Qp(r)}function Qp(e){if(!ra){So&&(So=clearTimeout(So));var t=e-Wr;t>24?(e<1/0&&(So=setTimeout(Tb,e-Uo.now()-sh)),yo&&(yo=clearInterval(yo))):(yo||(xu=Uo.now(),yo=setInterval(wI,uC)),ra=1,hC(Tb))}}function Nb(e,t,n){var r=new wu;return t=t==null?0:+t,r.restart(a=>{r.stop(),e(a+t)},t,n),r}var EI=ih("start","end","cancel","interrupt"),kI=[],dC=0,Db=1,Jp=2,ru=3,Rb=4,eg=5,su=6;function ah(e,t,n,r,a,l){var c=e.__transition;if(!c)e.__transition={};else if(n in c)return;AI(e,n,{name:t,index:r,group:a,on:EI,tween:kI,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:dC})}function bm(e,t){var n=Vn(e,t);if(n.state>dC)throw new Error("too late; already scheduled");return n}function si(e,t){var n=Vn(e,t);if(n.state>ru)throw new Error("too late; already running");return n}function Vn(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function AI(e,t,n){var r=e.__transition,a;r[t]=n,n.timer=fC(l,0,n.time);function l(f){n.state=Db,n.timer.restart(c,n.delay,n.time),n.delay<=f&&c(f-n.delay)}function c(f){var g,d,m,b;if(n.state!==Db)return u();for(g in r)if(b=r[g],b.name===n.name){if(b.state===ru)return Nb(c);b.state===Rb?(b.state=su,b.timer.stop(),b.on.call("interrupt",e,e.__data__,b.index,b.group),delete r[g]):+g<t&&(b.state=su,b.timer.stop(),b.on.call("cancel",e,e.__data__,b.index,b.group),delete r[g])}if(Nb(function(){n.state===ru&&(n.state=Rb,n.timer.restart(o,n.delay,n.time),o(f))}),n.state=Jp,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Jp){for(n.state=ru,a=new Array(m=n.tween.length),g=0,d=-1;g<m;++g)(b=n.tween[g].value.call(e,e.__data__,n.index,n.group))&&(a[++d]=b);a.length=d+1}}function o(f){for(var g=f<n.duration?n.ease.call(null,f/n.duration):(n.timer.restart(u),n.state=eg,1),d=-1,m=a.length;++d<m;)a[d].call(e,g);n.state===eg&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){n.state=su,n.timer.stop(),delete r[t];for(var f in r)return;delete e.__transition}}function au(e,t){var n=e.__transition,r,a,l=!0,c;if(n){t=t==null?null:t+"";for(c in n){if((r=n[c]).name!==t){l=!1;continue}a=r.state>Jp&&r.state<eg,r.state=su,r.timer.stop(),r.on.call(a?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[c]}l&&delete e.__transition}}function TI(e){return this.each(function(){au(this,e)})}function NI(e,t){var n,r;return function(){var a=si(this,e),l=a.tween;if(l!==n){r=n=l;for(var c=0,o=r.length;c<o;++c)if(r[c].name===t){r=r.slice(),r.splice(c,1);break}}a.tween=r}}function DI(e,t,n){var r,a;if(typeof n!="function")throw new Error;return function(){var l=si(this,e),c=l.tween;if(c!==r){a=(r=c).slice();for(var o={name:t,value:n},u=0,f=a.length;u<f;++u)if(a[u].name===t){a[u]=o;break}u===f&&a.push(o)}l.tween=a}}function RI(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Vn(this.node(),n).tween,a=0,l=r.length,c;a<l;++a)if((c=r[a]).name===e)return c.value;return null}return this.each((t==null?NI:DI)(n,e,t))}function Sm(e,t,n){var r=e._id;return e.each(function(){var a=si(this,r);(a.value||(a.value={}))[t]=n.apply(this,arguments)}),function(a){return Vn(a,r).value[t]}}function pC(e,t){var n;return(typeof t=="number"?ei:t instanceof Yr?bu:(n=Yr(t))?(t=n,bu):oC)(e,t)}function MI(e){return function(){this.removeAttribute(e)}}function LI(e){return function(){this.removeAttributeNS(e.space,e.local)}}function OI(e,t,n){var r,a=n+"",l;return function(){var c=this.getAttribute(e);return c===a?null:c===r?l:l=t(r=c,n)}}function jI(e,t,n){var r,a=n+"",l;return function(){var c=this.getAttributeNS(e.space,e.local);return c===a?null:c===r?l:l=t(r=c,n)}}function BI(e,t,n){var r,a,l;return function(){var c,o=n(this),u;return o==null?void this.removeAttribute(e):(c=this.getAttribute(e),u=o+"",c===u?null:c===r&&u===a?l:(a=u,l=t(r=c,o)))}}function II(e,t,n){var r,a,l;return function(){var c,o=n(this),u;return o==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),u=o+"",c===u?null:c===r&&u===a?l:(a=u,l=t(r=c,o)))}}function zI(e,t){var n=rh(e),r=n==="transform"?_I:pC;return this.attrTween(e,typeof t=="function"?(n.local?II:BI)(n,r,Sm(this,"attr."+e,t)):t==null?(n.local?LI:MI)(n):(n.local?jI:OI)(n,r,t))}function HI(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function FI(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function PI(e,t){var n,r;function a(){var l=t.apply(this,arguments);return l!==r&&(n=(r=l)&&FI(e,l)),n}return a._value=t,a}function UI(e,t){var n,r;function a(){var l=t.apply(this,arguments);return l!==r&&(n=(r=l)&&HI(e,l)),n}return a._value=t,a}function $I(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=rh(e);return this.tween(n,(r.local?PI:UI)(r,t))}function GI(e,t){return function(){bm(this,e).delay=+t.apply(this,arguments)}}function qI(e,t){return t=+t,function(){bm(this,e).delay=t}}function VI(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?GI:qI)(t,e)):Vn(this.node(),t).delay}function YI(e,t){return function(){si(this,e).duration=+t.apply(this,arguments)}}function WI(e,t){return t=+t,function(){si(this,e).duration=t}}function XI(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?YI:WI)(t,e)):Vn(this.node(),t).duration}function KI(e,t){if(typeof t!="function")throw new Error;return function(){si(this,e).ease=t}}function ZI(e){var t=this._id;return arguments.length?this.each(KI(t,e)):Vn(this.node(),t).ease}function QI(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;si(this,e).ease=n}}function JI(e){if(typeof e!="function")throw new Error;return this.each(QI(this._id,e))}function e7(e){typeof e!="function"&&(e=qw(e));for(var t=this._groups,n=t.length,r=new Array(n),a=0;a<n;++a)for(var l=t[a],c=l.length,o=r[a]=[],u,f=0;f<c;++f)(u=l[f])&&e.call(u,u.__data__,f,l)&&o.push(u);return new Ri(r,this._parents,this._name,this._id)}function t7(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,a=n.length,l=Math.min(r,a),c=new Array(r),o=0;o<l;++o)for(var u=t[o],f=n[o],g=u.length,d=c[o]=new Array(g),m,b=0;b<g;++b)(m=u[b]||f[b])&&(d[b]=m);for(;o<r;++o)c[o]=t[o];return new Ri(c,this._parents,this._name,this._id)}function n7(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function i7(e,t,n){var r,a,l=n7(t)?bm:si;return function(){var c=l(this,e),o=c.on;o!==r&&(a=(r=o).copy()).on(t,n),c.on=a}}function r7(e,t){var n=this._id;return arguments.length<2?Vn(this.node(),n).on.on(e):this.each(i7(n,e,t))}function s7(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function a7(){return this.on("end.remove",s7(this._id))}function o7(e){var t=this._name,n=this._id;typeof e!="function"&&(e=gm(e));for(var r=this._groups,a=r.length,l=new Array(a),c=0;c<a;++c)for(var o=r[c],u=o.length,f=l[c]=new Array(u),g,d,m=0;m<u;++m)(g=o[m])&&(d=e.call(g,g.__data__,m,o))&&("__data__"in g&&(d.__data__=g.__data__),f[m]=d,ah(f[m],t,n,m,f,Vn(g,n)));return new Ri(l,this._parents,t,n)}function l7(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Gw(e));for(var r=this._groups,a=r.length,l=[],c=[],o=0;o<a;++o)for(var u=r[o],f=u.length,g,d=0;d<f;++d)if(g=u[d]){for(var m=e.call(g,g.__data__,d,u),b,w=Vn(g,n),C=0,v=m.length;C<v;++C)(b=m[C])&&ah(b,t,n,C,m,w);l.push(m),c.push(g)}return new Ri(l,c,t,n)}var c7=nl.prototype.constructor;function u7(){return new c7(this._groups,this._parents)}function h7(e,t){var n,r,a;return function(){var l=ia(this,e),c=(this.style.removeProperty(e),ia(this,e));return l===c?null:l===n&&c===r?a:a=t(n=l,r=c)}}function gC(e){return function(){this.style.removeProperty(e)}}function f7(e,t,n){var r,a=n+"",l;return function(){var c=ia(this,e);return c===a?null:c===r?l:l=t(r=c,n)}}function d7(e,t,n){var r,a,l;return function(){var c=ia(this,e),o=n(this),u=o+"";return o==null&&(u=o=(this.style.removeProperty(e),ia(this,e))),c===u?null:c===r&&u===a?l:(a=u,l=t(r=c,o))}}function p7(e,t){var n,r,a,l="style."+t,c="end."+l,o;return function(){var u=si(this,e),f=u.on,g=u.value[l]==null?o||(o=gC(t)):void 0;(f!==n||a!==g)&&(r=(n=f).copy()).on(c,a=g),u.on=r}}function g7(e,t,n){var r=(e+="")=="transform"?mI:pC;return t==null?this.styleTween(e,h7(e,r)).on("end.style."+e,gC(e)):typeof t=="function"?this.styleTween(e,d7(e,r,Sm(this,"style."+e,t))).each(p7(this._id,e)):this.styleTween(e,f7(e,r,t),n).on("end.style."+e,null)}function m7(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function _7(e,t,n){var r,a;function l(){var c=t.apply(this,arguments);return c!==a&&(r=(a=c)&&m7(e,c,n)),r}return l._value=t,l}function v7(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,_7(e,t,n??""))}function y7(e){return function(){this.textContent=e}}function b7(e){return function(){var t=e(this);this.textContent=t??""}}function S7(e){return this.tween("text",typeof e=="function"?b7(Sm(this,"text",e)):y7(e==null?"":e+""))}function x7(e){return function(t){this.textContent=e.call(this,t)}}function w7(e){var t,n;function r(){var a=e.apply(this,arguments);return a!==n&&(t=(n=a)&&x7(a)),t}return r._value=e,r}function C7(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,w7(e))}function E7(){for(var e=this._name,t=this._id,n=mC(),r=this._groups,a=r.length,l=0;l<a;++l)for(var c=r[l],o=c.length,u,f=0;f<o;++f)if(u=c[f]){var g=Vn(u,t);ah(u,e,n,f,c,{time:g.time+g.delay+g.duration,delay:0,duration:g.duration,ease:g.ease})}return new Ri(r,this._parents,e,n)}function k7(){var e,t,n=this,r=n._id,a=n.size();return new Promise(function(l,c){var o={value:c},u={value:function(){--a===0&&l()}};n.each(function(){var f=si(this,r),g=f.on;g!==e&&(t=(e=g).copy(),t._.cancel.push(o),t._.interrupt.push(o),t._.end.push(u)),f.on=t}),a===0&&l()})}var A7=0;function Ri(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function mC(){return++A7}var ki=nl.prototype;Ri.prototype={constructor:Ri,select:o7,selectAll:l7,selectChild:ki.selectChild,selectChildren:ki.selectChildren,filter:e7,merge:t7,selection:u7,transition:E7,call:ki.call,nodes:ki.nodes,node:ki.node,size:ki.size,empty:ki.empty,each:ki.each,on:r7,attr:zI,attrTween:$I,style:g7,styleTween:v7,text:S7,textTween:C7,remove:a7,tween:RI,delay:VI,duration:XI,ease:ZI,easeVarying:JI,end:k7,[Symbol.iterator]:ki[Symbol.iterator]};function T7(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var N7={time:null,delay:0,duration:250,ease:T7};function D7(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function R7(e){var t,n;e instanceof Ri?(t=e._id,e=e._name):(t=mC(),(n=N7).time=ym(),e=e==null?null:e+"");for(var r=this._groups,a=r.length,l=0;l<a;++l)for(var c=r[l],o=c.length,u,f=0;f<o;++f)(u=c[f])&&ah(u,e,t,f,c,n||D7(u,t));return new Ri(r,this._parents,e,t)}nl.prototype.interrupt=TI;nl.prototype.transition=R7;const Gc=e=>()=>e;function M7(e,{sourceEvent:t,target:n,transform:r,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:r,enumerable:!0,configurable:!0},_:{value:a}})}function Ai(e,t,n){this.k=e,this.x=t,this.y=n}Ai.prototype={constructor:Ai,scale:function(e){return e===1?this:new Ai(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ai(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 oh=new Ai(1,0,0);_C.prototype=Ai.prototype;function _C(e){for(;!e.__zoom;)if(!(e=e.parentNode))return oh;return e.__zoom}function op(e){e.stopImmediatePropagation()}function bo(e){e.preventDefault(),e.stopImmediatePropagation()}function L7(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function O7(){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 Mb(){return this.__zoom||oh}function j7(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function B7(){return navigator.maxTouchPoints||"ontouchstart"in this}function I7(e,t,n){var r=e.invertX(t[0][0])-n[0][0],a=e.invertX(t[1][0])-n[1][0],l=e.invertY(t[0][1])-n[0][1],c=e.invertY(t[1][1])-n[1][1];return e.translate(a>r?(r+a)/2:Math.min(0,r)||Math.max(0,a),c>l?(l+c)/2:Math.min(0,l)||Math.max(0,c))}function vC(){var e=L7,t=O7,n=I7,r=j7,a=B7,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],o=250,u=iu,f=ih("start","zoom","end"),g,d,m,b=500,w=150,C=0,v=10;function y(U){U.property("__zoom",Mb).on("wheel.zoom",N,{passive:!1}).on("mousedown.zoom",L).on("dblclick.zoom",I).filter(a).on("touchstart.zoom",z).on("touchmove.zoom",q).on("touchend.zoom touchcancel.zoom",P).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(U,V,G,W){var K=U.selection?U.selection():U;K.property("__zoom",Mb),U!==K?D(U,V,G,W):K.interrupt().each(function(){T(this,arguments).event(W).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},y.scaleBy=function(U,V,G,W){y.scaleTo(U,function(){var K=this.__zoom.k,j=typeof V=="function"?V.apply(this,arguments):V;return K*j},G,W)},y.scaleTo=function(U,V,G,W){y.transform(U,function(){var K=t.apply(this,arguments),j=this.__zoom,M=G==null?k(K):typeof G=="function"?G.apply(this,arguments):G,O=j.invert(M),$=typeof V=="function"?V.apply(this,arguments):V;return n(_(S(j,$),M,O),K,c)},G,W)},y.translateBy=function(U,V,G,W){y.transform(U,function(){return n(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof G=="function"?G.apply(this,arguments):G),t.apply(this,arguments),c)},null,W)},y.translateTo=function(U,V,G,W,K){y.transform(U,function(){var j=t.apply(this,arguments),M=this.__zoom,O=W==null?k(j):typeof W=="function"?W.apply(this,arguments):W;return n(oh.translate(O[0],O[1]).scale(M.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof G=="function"?-G.apply(this,arguments):-G),j,c)},W,K)};function S(U,V){return V=Math.max(l[0],Math.min(l[1],V)),V===U.k?U:new Ai(V,U.x,U.y)}function _(U,V,G){var W=V[0]-G[0]*U.k,K=V[1]-G[1]*U.k;return W===U.x&&K===U.y?U:new Ai(U.k,W,K)}function k(U){return[(+U[0][0]+ +U[1][0])/2,(+U[0][1]+ +U[1][1])/2]}function D(U,V,G,W){U.on("start.zoom",function(){T(this,arguments).event(W).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(W).end()}).tween("zoom",function(){var K=this,j=arguments,M=T(K,j).event(W),O=t.apply(K,j),$=G==null?k(O):typeof G=="function"?G.apply(K,j):G,F=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),J=K.__zoom,re=typeof V=="function"?V.apply(K,j):V,le=u(J.invert($).concat(F/J.k),re.invert($).concat(F/re.k));return function(Z){if(Z===1)Z=re;else{var H=le(Z),ee=F/H[2];Z=new Ai(ee,$[0]-H[0]*ee,$[1]-H[1]*ee)}M.zoom(null,Z)}})}function T(U,V,G){return!G&&U.__zooming||new R(U,V)}function R(U,V){this.that=U,this.args=V,this.active=0,this.sourceEvent=null,this.extent=t.apply(U,V),this.taps=0}R.prototype={event:function(U){return U&&(this.sourceEvent=U),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(U,V){return this.mouse&&U!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&U!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&U!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(U){var V=yn(this.that).datum();f.call(U,this.that,new M7(U,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:f}),V)}};function N(U,...V){if(!e.apply(this,arguments))return;var G=T(this,V).event(U),W=this.__zoom,K=Math.max(l[0],Math.min(l[1],W.k*Math.pow(2,r.apply(this,arguments)))),j=Fn(U);if(G.wheel)(G.mouse[0][0]!==j[0]||G.mouse[0][1]!==j[1])&&(G.mouse[1]=W.invert(G.mouse[0]=j)),clearTimeout(G.wheel);else{if(W.k===K)return;G.mouse=[j,W.invert(j)],au(this),G.start()}bo(U),G.wheel=setTimeout(M,w),G.zoom("mouse",n(_(S(W,K),G.mouse[0],G.mouse[1]),G.extent,c));function M(){G.wheel=null,G.end()}}function L(U,...V){if(m||!e.apply(this,arguments))return;var G=U.currentTarget,W=T(this,V,!0).event(U),K=yn(U.view).on("mousemove.zoom",$,!0).on("mouseup.zoom",F,!0),j=Fn(U,G),M=U.clientX,O=U.clientY;tC(U.view),op(U),W.mouse=[j,this.__zoom.invert(j)],au(this),W.start();function $(J){if(bo(J),!W.moved){var re=J.clientX-M,le=J.clientY-O;W.moved=re*re+le*le>C}W.event(J).zoom("mouse",n(_(W.that.__zoom,W.mouse[0]=Fn(J,G),W.mouse[1]),W.extent,c))}function F(J){K.on("mousemove.zoom mouseup.zoom",null),nC(J.view,W.moved),bo(J),W.event(J).end()}}function I(U,...V){if(e.apply(this,arguments)){var G=this.__zoom,W=Fn(U.changedTouches?U.changedTouches[0]:U,this),K=G.invert(W),j=G.k*(U.shiftKey?.5:2),M=n(_(S(G,j),W,K),t.apply(this,V),c);bo(U),o>0?yn(this).transition().duration(o).call(D,M,W,U):yn(this).call(y.transform,M,W,U)}}function z(U,...V){if(e.apply(this,arguments)){var G=U.touches,W=G.length,K=T(this,V,U.changedTouches.length===W).event(U),j,M,O,$;for(op(U),M=0;M<W;++M)O=G[M],$=Fn(O,this),$=[$,this.__zoom.invert($),O.identifier],K.touch0?!K.touch1&&K.touch0[2]!==$[2]&&(K.touch1=$,K.taps=0):(K.touch0=$,j=!0,K.taps=1+!!g);g&&(g=clearTimeout(g)),j&&(K.taps<2&&(d=$[0],g=setTimeout(function(){g=null},b)),au(this),K.start())}}function q(U,...V){if(this.__zooming){var G=T(this,V).event(U),W=U.changedTouches,K=W.length,j,M,O,$;for(bo(U),j=0;j<K;++j)M=W[j],O=Fn(M,this),G.touch0&&G.touch0[2]===M.identifier?G.touch0[0]=O:G.touch1&&G.touch1[2]===M.identifier&&(G.touch1[0]=O);if(M=G.that.__zoom,G.touch1){var F=G.touch0[0],J=G.touch0[1],re=G.touch1[0],le=G.touch1[1],Z=(Z=re[0]-F[0])*Z+(Z=re[1]-F[1])*Z,H=(H=le[0]-J[0])*H+(H=le[1]-J[1])*H;M=S(M,Math.sqrt(Z/H)),O=[(F[0]+re[0])/2,(F[1]+re[1])/2],$=[(J[0]+le[0])/2,(J[1]+le[1])/2]}else if(G.touch0)O=G.touch0[0],$=G.touch0[1];else return;G.zoom("touch",n(_(M,O,$),G.extent,c))}}function P(U,...V){if(this.__zooming){var G=T(this,V).event(U),W=U.changedTouches,K=W.length,j,M;for(op(U),m&&clearTimeout(m),m=setTimeout(function(){m=null},b),j=0;j<K;++j)M=W[j],G.touch0&&G.touch0[2]===M.identifier?delete G.touch0:G.touch1&&G.touch1[2]===M.identifier&&delete G.touch1;if(G.touch1&&!G.touch0&&(G.touch0=G.touch1,delete G.touch1),G.touch0)G.touch0[1]=this.__zoom.invert(G.touch0[0]);else if(G.end(),G.taps===2&&(M=Fn(M,this),Math.hypot(d[0]-M[0],d[1]-M[1])<v)){var O=yn(this).on("dblclick.zoom");O&&O.apply(this,arguments)}}}return y.wheelDelta=function(U){return arguments.length?(r=typeof U=="function"?U:Gc(+U),y):r},y.filter=function(U){return arguments.length?(e=typeof U=="function"?U:Gc(!!U),y):e},y.touchable=function(U){return arguments.length?(a=typeof U=="function"?U:Gc(!!U),y):a},y.extent=function(U){return arguments.length?(t=typeof U=="function"?U:Gc([[+U[0][0],+U[0][1]],[+U[1][0],+U[1][1]]]),y):t},y.scaleExtent=function(U){return arguments.length?(l[0]=+U[0],l[1]=+U[1],y):[l[0],l[1]]},y.translateExtent=function(U){return arguments.length?(c[0][0]=+U[0][0],c[1][0]=+U[1][0],c[0][1]=+U[0][1],c[1][1]=+U[1][1],y):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},y.constrain=function(U){return arguments.length?(n=U,y):n},y.duration=function(U){return arguments.length?(o=+U,y):o},y.interpolate=function(U){return arguments.length?(u=U,y):u},y.on=function(){var U=f.on.apply(f,arguments);return U===f?y:U},y.clickDistance=function(U){return arguments.length?(C=(U=+U)*U,y):Math.sqrt(C)},y.tapDistance=function(U){return arguments.length?(v=+U,y):v},y}const qn={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.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 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:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", 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.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},$o=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],yC=["Enter"," ","Escape"],bC={"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 sa;(function(e){e.Strict="strict",e.Loose="loose"})(sa||(sa={}));var qr;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(qr||(qr={}));var Go;(function(e){e.Partial="partial",e.Full="full"})(Go||(Go={}));const SC={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var dr;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(dr||(dr={}));var Cu;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Cu||(Cu={}));var Te;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Te||(Te={}));const Lb={[Te.Left]:Te.Right,[Te.Right]:Te.Left,[Te.Top]:Te.Bottom,[Te.Bottom]:Te.Top};function xC(e){return e===null?null:e?"valid":"invalid"}const wC=e=>"id"in e&&"source"in e&&"target"in e,z7=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),xm=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),rl=(e,t=[0,0])=>{const{width:n,height:r}=Oi(e),a=e.origin??t,l=n*a[0],c=r*a[1];return{x:e.position.x-l,y:e.position.y-c}},H7=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,a)=>{const l=typeof a=="string";let c=!t.nodeLookup&&!l?a:void 0;t.nodeLookup&&(c=l?t.nodeLookup.get(a):xm(a)?a:t.nodeLookup.get(a.id));const o=c?Eu(c,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return lh(r,o)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ch(n)},sl=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(a=>{(t.filter===void 0||t.filter(a))&&(n=lh(n,Eu(a)),r=!0)}),r?ch(n):{x:0,y:0,width:0,height:0}},wm=(e,t,[n,r,a]=[0,0,1],l=!1,c=!1)=>{const o=(t.x-n)/a,u=(t.y-r)/a,f=t.width/a,g=t.height/a,d=[];for(const m of e.values()){const{measured:b,selectable:w=!0,hidden:C=!1}=m;if(c&&!w||C)continue;const v=b.width??m.width??m.initialWidth??0,y=b.height??m.height??m.initialHeight??0,{x:S,y:_}=m.internals.positionAbsolute,k=AC(o,u,f,g,S,_,v,y),D=v*y,T=l&&k>0;(!m.internals.handleBounds||T||k>=D||m.dragging)&&d.push(m)}return d},F7=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function P7(e,t){const n=new Map,r=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)&&(!r||r.has(a.id))&&n.set(a.id,a)}),n}async function U7({nodes:e,width:t,height:n,panZoom:r,minZoom:a,maxZoom:l},c){if(e.size===0)return!0;const o=P7(e,c),u=sl(o),f=Em(u,t,n,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??l,(c==null?void 0:c.padding)??.1);return await r.setViewport(f,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function CC({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:a,onError:l}){const c=n.get(e),o=c.parentId?n.get(c.parentId):void 0,{x:u,y:f}=o?o.internals.positionAbsolute:{x:0,y:0},g=c.origin??r;let d=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!o)l==null||l("005",qn.error005());else{const b=o.measured.width,w=o.measured.height;b&&w&&(d=[[u,f],[u+b,f+w]])}else o&&Kr(c.extent)&&(d=[[c.extent[0][0]+u,c.extent[0][1]+f],[c.extent[1][0]+u,c.extent[1][1]+f]]);const m=Kr(d)?Xr(t,d,c.measured):t;return(c.measured.width===void 0||c.measured.height===void 0)&&(l==null||l("015",qn.error015())),{position:{x:m.x-u+(c.measured.width??0)*g[0],y:m.y-f+(c.measured.height??0)*g[1]},positionAbsolute:m}}async function $7({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:a}){const l=new Set(e.map(m=>m.id)),c=[];for(const m of n){if(m.deletable===!1)continue;const b=l.has(m.id),w=!b&&m.parentId&&c.find(C=>C.id===m.parentId);(b||w)&&c.push(m)}const o=new Set(t.map(m=>m.id)),u=r.filter(m=>m.deletable!==!1),g=F7(c,u);for(const m of u)o.has(m.id)&&!g.find(w=>w.id===m.id)&&g.push(m);if(!a)return{edges:g,nodes:c};const d=await a({nodes:c,edges:g});return typeof d=="boolean"?d?{edges:g,nodes:c}:{edges:[],nodes:[]}:d}const aa=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Xr=(e={x:0,y:0},t,n)=>({x:aa(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:aa(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function EC(e,t,n){const{width:r,height:a}=Oi(n),{x:l,y:c}=n.internals.positionAbsolute;return Xr(e,[[l,c],[l+r,c+a]],t)}const Ob=(e,t,n)=>e<t?aa(Math.abs(e-t),1,t)/t:e>n?-aa(Math.abs(e-n),1,t)/t:0,Cm=(e,t,n=15,r=40)=>{const a=Ob(e.x,r,t.width-r)*n,l=Ob(e.y,r,t.height-r)*n;return[a,l]},lh=(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)}),tg=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),ch=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),qo=(e,t=[0,0])=>{var a,l;const{x:n,y:r}=xm(e)?e.internals.positionAbsolute:rl(e,t);return{x:n,y:r,width:((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0,height:((l=e.measured)==null?void 0:l.height)??e.height??e.initialHeight??0}},Eu=(e,t=[0,0])=>{var a,l;const{x:n,y:r}=xm(e)?e.internals.positionAbsolute:rl(e,t);return{x:n,y:r,x2:n+(((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0),y2:r+(((l=e.measured)==null?void 0:l.height)??e.height??e.initialHeight??0)}},kC=(e,t)=>ch(lh(tg(e),tg(t))),AC=(e,t,n,r,a,l,c,o)=>{const u=Math.max(0,Math.min(e+n,a+c)-Math.max(e,a)),f=Math.max(0,Math.min(t+r,l+o)-Math.max(t,l));return Math.ceil(u*f)},ku=(e,t)=>AC(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),jb=e=>Un(e.width)&&Un(e.height)&&Un(e.x)&&Un(e.y),Un=e=>!isNaN(e)&&isFinite(e),TC=(e,t)=>(n,r)=>{},al=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),ol=({x:e,y:t},[n,r,a],l=!1,c=[1,1])=>{const o={x:(e-n)/a,y:(t-r)/a};return l?al(o,c):o},oa=({x:e,y:t},[n,r,a])=>({x:e*a+n,y:t*a+r});function Gs(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(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function G7(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Gs(e,n),a=Gs(e,t);return{top:r,right:a,bottom:r,left:a,x:a*2,y:r*2}}if(typeof e=="object"){const r=Gs(e.top??e.y??0,n),a=Gs(e.bottom??e.y??0,n),l=Gs(e.left??e.x??0,t),c=Gs(e.right??e.x??0,t);return{top:r,right:c,bottom:a,left:l,x:l+c,y:r+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function q7(e,t,n,r,a,l){const{x:c,y:o}=oa(e,[t,n,r]),{x:u,y:f}=oa({x:e.x+e.width,y:e.y+e.height},[t,n,r]),g=a-u,d=l-f;return{left:Math.floor(c),top:Math.floor(o),right:Math.floor(g),bottom:Math.floor(d)}}const Em=(e,t,n,r,a,l)=>{const c=G7(l,t,n),o=(t-c.x)/e.width,u=(n-c.y)/e.height,f=Math.min(o,u),g=aa(f,r,a),d=e.x+e.width/2,m=e.y+e.height/2,b=t/2-d*g,w=n/2-m*g,C=q7(e,b,w,g,t,n),v={left:Math.min(C.left-c.left,0),top:Math.min(C.top-c.top,0),right:Math.min(C.right-c.right,0),bottom:Math.min(C.bottom-c.bottom,0)};return{x:b-v.left+v.right,y:w-v.top+v.bottom,zoom:g}},Vo=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Kr(e){return e!=null&&e!=="parent"}function Oi(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 NC(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 DC(e,t={width:0,height:0},n,r,a){const l={...e},c=r.get(n);if(c){const o=c.origin||a;l.x+=c.internals.positionAbsolute.x-(t.width??0)*o[0],l.y+=c.internals.positionAbsolute.y-(t.height??0)*o[1]}return l}function Bb(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function V7(){let e,t;return{promise:new Promise((r,a)=>{e=r,t=a}),resolve:e,reject:t}}function Y7(e){return{...bC,...e||{}}}function To(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:a}){const{x:l,y:c}=$n(e),o=ol({x:l-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},r),{x:u,y:f}=n?al(o,t):o;return{xSnapped:u,ySnapped:f,...o}}const km=e=>({width:e.offsetWidth,height:e.offsetHeight}),RC=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},W7=["INPUT","SELECT","TEXTAREA"];function MC(e){var r,a;const t=((a=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:a[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:W7.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const LC=e=>"clientX"in e,$n=(e,t)=>{var l,c;const n=LC(e),r=n?e.clientX:(l=e.touches)==null?void 0:l[0].clientX,a=n?e.clientY:(c=e.touches)==null?void 0:c[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:a-((t==null?void 0:t.top)??0)}},Ib=(e,t,n,r,a)=>{const l=t.querySelectorAll(`.${e}`);return!l||!l.length?null:Array.from(l).map(c=>{const o=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:e,nodeId:a,position:c.getAttribute("data-handlepos"),x:(o.left-n.left)/r,y:(o.top-n.top)/r,...km(c)}})};function OC({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:o}){const u=e*.125+a*.375+c*.375+n*.125,f=t*.125+l*.375+o*.375+r*.125,g=Math.abs(u-e),d=Math.abs(f-t);return[u,f,g,d]}function qc(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function zb({pos:e,x1:t,y1:n,x2:r,y2:a,c:l}){switch(e){case Te.Left:return[t-qc(t-r,l),n];case Te.Right:return[t+qc(r-t,l),n];case Te.Top:return[t,n-qc(n-a,l)];case Te.Bottom:return[t,n+qc(a-n,l)]}}function jC({sourceX:e,sourceY:t,sourcePosition:n=Te.Bottom,targetX:r,targetY:a,targetPosition:l=Te.Top,curvature:c=.25}){const[o,u]=zb({pos:n,x1:e,y1:t,x2:r,y2:a,c}),[f,g]=zb({pos:l,x1:r,y1:a,x2:e,y2:t,c}),[d,m,b,w]=OC({sourceX:e,sourceY:t,targetX:r,targetY:a,sourceControlX:o,sourceControlY:u,targetControlX:f,targetControlY:g});return[`M${e},${t} C${o},${u} ${f},${g} ${r},${a}`,d,m,b,w]}function BC({sourceX:e,sourceY:t,targetX:n,targetY:r}){const a=Math.abs(n-e)/2,l=n<e?n+a:n-a,c=Math.abs(r-t)/2,o=r<t?r+c:r-c;return[l,o,a,c]}function X7({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:a=!1,zIndexMode:l="basic"}){if(l==="manual")return r;const c=a&&n?r+1e3:r,o=Math.max(e.parentId||a&&e.selected?e.internals.z:0,t.parentId||a&&t.selected?t.internals.z:0);return c+o}function K7({sourceNode:e,targetNode:t,width:n,height:r,transform:a}){const l=lh(Eu(e),Eu(t));l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);const c={x:-a[0]/a[2],y:-a[1]/a[2],width:n/a[2],height:r/a[2]};return ku(c,ch(l))>0}const Z7=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Q7=(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)),J7=(e,t,n={})=>{var l;if(!e.source||!e.target)return(l=n.onError)==null||l.call(n,"006",qn.error006()),t;const r=n.getEdgeId||Z7;let a;return wC(e)?a={...e}:a={...e,id:r(e)},Q7(a,t)?t:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,t.concat(a))};function IC({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[a,l,c,o]=BC({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,a,l,c,o]}const Hb={[Te.Left]:{x:-1,y:0},[Te.Right]:{x:1,y:0},[Te.Top]:{x:0,y:-1},[Te.Bottom]:{x:0,y:1}},e9=({source:e,sourcePosition:t=Te.Bottom,target:n})=>t===Te.Left||t===Te.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Fb=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function t9({source:e,sourcePosition:t=Te.Bottom,target:n,targetPosition:r=Te.Top,center:a,offset:l,stepPosition:c}){const o=Hb[t],u=Hb[r],f={x:e.x+o.x*l,y:e.y+o.y*l},g={x:n.x+u.x*l,y:n.y+u.y*l},d=e9({source:f,sourcePosition:t,target:g}),m=d.x!==0?"x":"y",b=d[m];let w=[],C,v;const y={x:0,y:0},S={x:0,y:0},[,,_,k]=BC({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[m]*u[m]===-1){m==="x"?(C=a.x??f.x+(g.x-f.x)*c,v=a.y??(f.y+g.y)/2):(C=a.x??(f.x+g.x)/2,v=a.y??f.y+(g.y-f.y)*c);const N=[{x:C,y:f.y},{x:C,y:g.y}],L=[{x:f.x,y:v},{x:g.x,y:v}];o[m]===b?w=m==="x"?N:L:w=m==="x"?L:N}else{const N=[{x:f.x,y:g.y}],L=[{x:g.x,y:f.y}];if(m==="x"?w=o.x===b?L:N:w=o.y===b?N:L,t===r){const U=Math.abs(e[m]-n[m]);if(U<=l){const V=Math.min(l-1,l-U);o[m]===b?y[m]=(f[m]>e[m]?-1:1)*V:S[m]=(g[m]>n[m]?-1:1)*V}}if(t!==r){const U=m==="x"?"y":"x",V=o[m]===u[U],G=f[U]>g[U],W=f[U]<g[U];(o[m]===1&&(!V&&G||V&&W)||o[m]!==1&&(!V&&W||V&&G))&&(w=m==="x"?N:L)}const I={x:f.x+y.x,y:f.y+y.y},z={x:g.x+S.x,y:g.y+S.y},q=Math.max(Math.abs(I.x-w[0].x),Math.abs(z.x-w[0].x)),P=Math.max(Math.abs(I.y-w[0].y),Math.abs(z.y-w[0].y));q>=P?(C=(I.x+z.x)/2,v=w[0].y):(C=w[0].x,v=(I.y+z.y)/2)}const D={x:f.x+y.x,y:f.y+y.y},T={x:g.x+S.x,y:g.y+S.y};return[[e,...D.x!==w[0].x||D.y!==w[0].y?[D]:[],...w,...T.x!==w[w.length-1].x||T.y!==w[w.length-1].y?[T]:[],n],C,v,_,k]}function n9(e,t,n,r){const a=Math.min(Fb(e,t)/2,Fb(t,n)/2,r),{x:l,y:c}=t;if(e.x===l&&l===n.x||e.y===c&&c===n.y)return`L${l} ${c}`;if(e.y===c){const f=e.x<n.x?-1:1,g=e.y<n.y?1:-1;return`L ${l+a*f},${c}Q ${l},${c} ${l},${c+a*g}`}const o=e.x<n.x?1:-1,u=e.y<n.y?-1:1;return`L ${l},${c+a*u}Q ${l},${c} ${l+a*o},${c}`}function ng({sourceX:e,sourceY:t,sourcePosition:n=Te.Bottom,targetX:r,targetY:a,targetPosition:l=Te.Top,borderRadius:c=5,centerX:o,centerY:u,offset:f=20,stepPosition:g=.5}){const[d,m,b,w,C]=t9({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:a},targetPosition:l,center:{x:o,y:u},offset:f,stepPosition:g});let v=`M${d[0].x} ${d[0].y}`;for(let y=1;y<d.length-1;y++)v+=n9(d[y-1],d[y],d[y+1],c);return v+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[v,m,b,w,C]}function Pb(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function i9(e){var d;const{sourceNode:t,targetNode:n}=e;if(!Pb(t)||!Pb(n))return null;const r=t.internals.handleBounds||Ub(t.handles),a=n.internals.handleBounds||Ub(n.handles),l=$b((r==null?void 0:r.source)??[],e.sourceHandle),c=$b(e.connectionMode===sa.Strict?(a==null?void 0:a.target)??[]:((a==null?void 0:a.target)??[]).concat((a==null?void 0:a.source)??[]),e.targetHandle);if(!l||!c)return(d=e.onError)==null||d.call(e,"008",qn.error008(l?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const o=(l==null?void 0:l.position)||Te.Bottom,u=(c==null?void 0:c.position)||Te.Top,f=Zr(t,l,o),g=Zr(n,c,u);return{sourceX:f.x,sourceY:f.y,targetX:g.x,targetY:g.y,sourcePosition:o,targetPosition:u}}function Ub(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function Zr(e,t,n=Te.Left,r=!1){const a=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,l=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:c,height:o}=t??Oi(e);if(r)return{x:a+c/2,y:l+o/2};switch((t==null?void 0:t.position)??n){case Te.Top:return{x:a+c/2,y:l};case Te.Right:return{x:a+c,y:l+o/2};case Te.Bottom:return{x:a+c/2,y:l+o};case Te.Left:return{x:a,y:l+o/2}}}function $b(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function ig(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function r9(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:a}){const l=new Set;return e.reduce((c,o)=>([o.markerStart||r,o.markerEnd||a].forEach(u=>{if(u&&typeof u=="object"){const f=ig(u,t);l.has(f)||(c.push({id:f,color:u.color||n,...u}),l.add(f))}}),c),[]).sort((c,o)=>c.id.localeCompare(o.id))}const zC=1e3,s9=10,Am={nodeOrigin:[0,0],nodeExtent:$o,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},a9={...Am,checkEquality:!0};function Tm(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function o9(e,t,n){const r=Tm(Am,n);for(const a of e.values())if(a.parentId)Dm(a,e,t,r);else{const l=rl(a,r.nodeOrigin),c=Kr(a.extent)?a.extent:r.nodeExtent,o=Xr(l,c,Oi(a));a.internals.positionAbsolute=o}}function l9(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const a of e.handles){const l={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(l):a.type==="target"&&r.push(l)}return{source:n,target:r}}function Nm(e){return e==="manual"}function rg(e,t,n,r={}){var g,d;const a=Tm(a9,r),l={i:0},c=new Map(t),o=a!=null&&a.elevateNodesOnSelect&&!Nm(a.zIndexMode)?zC:0;let u=e.length>0,f=!1;t.clear(),n.clear();for(const m of e){let b=c.get(m.id);if(a.checkEquality&&m===(b==null?void 0:b.internals.userNode))t.set(m.id,b);else{const w=rl(m,a.nodeOrigin),C=Kr(m.extent)?m.extent:a.nodeExtent,v=Xr(w,C,Oi(m));b={...a.defaults,...m,measured:{width:(g=m.measured)==null?void 0:g.width,height:(d=m.measured)==null?void 0:d.height},internals:{positionAbsolute:v,handleBounds:l9(m,b),z:HC(m,o,a.zIndexMode),userNode:m}},t.set(m.id,b)}(b.measured===void 0||b.measured.width===void 0||b.measured.height===void 0)&&!b.hidden&&(u=!1),m.parentId&&Dm(b,t,n,r,l),f||(f=m.selected??!1)}return{nodesInitialized:u,hasSelectedNodes:f}}function c9(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 Dm(e,t,n,r,a){const{elevateNodesOnSelect:l,nodeOrigin:c,nodeExtent:o,zIndexMode:u}=Tm(Am,r),f=e.parentId,g=t.get(f);if(!g){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}c9(e,n),a&&!g.parentId&&g.internals.rootParentIndex===void 0&&u==="auto"&&(g.internals.rootParentIndex=++a.i,g.internals.z=g.internals.z+a.i*s9),a&&g.internals.rootParentIndex!==void 0&&(a.i=g.internals.rootParentIndex);const d=l&&!Nm(u)?zC:0,{x:m,y:b,z:w}=u9(e,g,c,o,d,u),{positionAbsolute:C}=e.internals,v=m!==C.x||b!==C.y;(v||w!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:v?{x:m,y:b}:C,z:w}})}function HC(e,t,n){const r=Un(e.zIndex)?e.zIndex:0;return Nm(n)?r:r+(e.selected?t:0)}function u9(e,t,n,r,a,l){const{x:c,y:o}=t.internals.positionAbsolute,u=Oi(e),f=rl(e,n),g=Kr(e.extent)?Xr(f,e.extent,u):f;let d=Xr({x:c+g.x,y:o+g.y},r,u);e.extent==="parent"&&(d=EC(d,u,t));const m=HC(e,a,l),b=t.internals.z??0;return{x:d.x,y:d.y,z:b>=m?b+1:m}}function Rm(e,t,n,r=[0,0]){var c;const a=[],l=new Map;for(const o of e){const u=t.get(o.parentId);if(!u)continue;const f=((c=l.get(o.parentId))==null?void 0:c.expandedRect)??qo(u),g=kC(f,o.rect);l.set(o.parentId,{expandedRect:g,parent:u})}return l.size>0&&l.forEach(({expandedRect:o,parent:u},f)=>{var _;const g=u.internals.positionAbsolute,d=Oi(u),m=u.origin??r,b=o.x<g.x?Math.round(Math.abs(g.x-o.x)):0,w=o.y<g.y?Math.round(Math.abs(g.y-o.y)):0,C=Math.max(d.width,Math.round(o.width)),v=Math.max(d.height,Math.round(o.height)),y=(C-d.width)*m[0],S=(v-d.height)*m[1];(b>0||w>0||y||S)&&(a.push({id:f,type:"position",position:{x:u.position.x-b+y,y:u.position.y-w+S}}),(_=n.get(f))==null||_.forEach(k=>{e.some(D=>D.id===k.id)||a.push({id:k.id,type:"position",position:{x:k.position.x+b,y:k.position.y+w}})})),(d.width<o.width||d.height<o.height||b||w)&&a.push({id:f,type:"dimensions",setAttributes:!0,dimensions:{width:C+(b?m[0]*b-y:0),height:v+(w?m[1]*w-S:0)}})}),a}function h9(e,t,n,r,a,l,c){const o=r==null?void 0:r.querySelector(".xyflow__viewport");let u=!1;if(!o)return{changes:[],updatedInternals:u};const f=[],g=window.getComputedStyle(o),{m22:d}=new window.DOMMatrixReadOnly(g.transform),m=[];for(const b of e.values()){const w=t.get(b.id);if(!w)continue;if(w.hidden){t.set(w.id,{...w,internals:{...w.internals,handleBounds:void 0}}),u=!0;continue}const C=km(b.nodeElement),v=w.measured.width!==C.width||w.measured.height!==C.height;if(!!(C.width&&C.height&&(v||!w.internals.handleBounds||b.force))){const S=b.nodeElement.getBoundingClientRect(),_=Kr(w.extent)?w.extent:l;let{positionAbsolute:k}=w.internals;w.parentId&&w.extent==="parent"?k=EC(k,C,t.get(w.parentId)):_&&(k=Xr(k,_,C));const D={...w,measured:C,internals:{...w.internals,positionAbsolute:k,handleBounds:{source:Ib("source",b.nodeElement,S,d,w.id),target:Ib("target",b.nodeElement,S,d,w.id)}}};t.set(w.id,D),w.parentId&&Dm(D,t,n,{nodeOrigin:a,zIndexMode:c}),u=!0,v&&(f.push({id:w.id,type:"dimensions",dimensions:C}),w.expandParent&&w.parentId&&m.push({id:w.id,parentId:w.parentId,rect:qo(D,a)}))}}if(m.length>0){const b=Rm(m,t,n,a);f.push(...b)}return{changes:f,updatedInternals:u}}async function f9({delta:e,panZoom:t,transform:n,translateExtent:r,width:a,height:l}){if(!t||!e.x&&!e.y)return!1;const c=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[a,l]],r);return!!c&&(c.x!==n[0]||c.y!==n[1]||c.k!==n[2])}function Gb(e,t,n,r,a,l){let c=a;const o=r.get(c)||new Map;r.set(c,o.set(n,t)),c=`${a}-${e}`;const u=r.get(c)||new Map;if(r.set(c,u.set(n,t)),l){c=`${a}-${e}-${l}`;const f=r.get(c)||new Map;r.set(c,f.set(n,t))}}function FC(e,t,n){e.clear(),t.clear();for(const r of n){const{source:a,target:l,sourceHandle:c=null,targetHandle:o=null}=r,u={edgeId:r.id,source:a,target:l,sourceHandle:c,targetHandle:o},f=`${a}-${c}--${l}-${o}`,g=`${l}-${o}--${a}-${c}`;Gb("source",u,g,e,a,c),Gb("target",u,f,e,l,o),t.set(r.id,r)}}function PC(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:PC(n,t):!1}function qb(e,t,n){var a;let r=e;do{if((a=r==null?void 0:r.matches)!=null&&a.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function d9(e,t,n,r){const a=new Map;for(const[l,c]of e)if((c.selected||c.id===r)&&(!c.parentId||!PC(c,e))&&(c.draggable||t&&typeof c.draggable>"u")){const o=e.get(l);o&&a.set(l,{id:l,position:o.position||{x:0,y:0},distance:{x:n.x-o.internals.positionAbsolute.x,y:n.y-o.internals.positionAbsolute.y},extent:o.extent,parentId:o.parentId,origin:o.origin,expandParent:o.expandParent,internals:{positionAbsolute:o.internals.positionAbsolute||{x:0,y:0}},measured:{width:o.measured.width??0,height:o.measured.height??0}})}return a}function lp({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var c,o,u;const a=[];for(const[f,g]of t){const d=(c=n.get(f))==null?void 0:c.internals.userNode;d&&a.push({...d,position:g.position,dragging:r})}if(!e)return[a[0],a];const l=(o=n.get(e))==null?void 0:o.internals.userNode;return[l?{...l,position:((u=t.get(e))==null?void 0:u.position)||l.position,dragging:r}:a[0],a]}function p9({dragItems:e,snapGrid:t,x:n,y:r}){const a=e.values().next().value;if(!a)return null;const l={x:n-a.distance.x,y:r-a.distance.y},c=al(l,t);return{x:c.x-l.x,y:c.y-l.y}}function g9({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:a}){let l={x:null,y:null},c=0,o=new Map,u=!1,f={x:0,y:0},g=null,d=!1,m=null,b=!1,w=!1,C=null;function v({noDragClassName:S,handleSelector:_,domNode:k,isSelectable:D,nodeId:T,nodeClickDistance:R=0}){m=yn(k);function N({x:q,y:P}){const{nodeLookup:U,nodeExtent:V,snapGrid:G,snapToGrid:W,nodeOrigin:K,onNodeDrag:j,onSelectionDrag:M,onError:O,updateNodePositions:$}=t();l={x:q,y:P};let F=!1;const J=o.size>1,re=J&&V?tg(sl(o)):null,le=J&&W?p9({dragItems:o,snapGrid:G,x:q,y:P}):null;for(const[Z,H]of o){if(!U.has(Z))continue;let ee={x:q-H.distance.x,y:P-H.distance.y};W&&(ee=le?{x:Math.round(ee.x+le.x),y:Math.round(ee.y+le.y)}:al(ee,G));let te=null;if(J&&V&&!H.extent&&re){const{positionAbsolute:ye}=H.internals,oe=ye.x-re.x+V[0][0],ve=ye.x+H.measured.width-re.x2+V[1][0],we=ye.y-re.y+V[0][1],Se=ye.y+H.measured.height-re.y2+V[1][1];te=[[oe,we],[ve,Se]]}const{position:de,positionAbsolute:he}=CC({nodeId:Z,nextPosition:ee,nodeLookup:U,nodeExtent:te||V,nodeOrigin:K,onError:O});F=F||H.position.x!==de.x||H.position.y!==de.y,H.position=de,H.internals.positionAbsolute=he}if(w=w||F,!!F&&($(o,!0),C&&(r||j||!T&&M))){const[Z,H]=lp({nodeId:T,dragItems:o,nodeLookup:U});r==null||r(C,o,Z,H),j==null||j(C,Z,H),T||M==null||M(C,H)}}async function L(){if(!g)return;const{transform:q,panBy:P,autoPanSpeed:U,autoPanOnNodeDrag:V}=t();if(!V){u=!1,cancelAnimationFrame(c);return}const[G,W]=Cm(f,g,U);(G!==0||W!==0)&&(l.x=(l.x??0)-G/q[2],l.y=(l.y??0)-W/q[2],await P({x:G,y:W})&&N(l)),c=requestAnimationFrame(L)}function I(q){var J;const{nodeLookup:P,multiSelectionActive:U,nodesDraggable:V,transform:G,snapGrid:W,snapToGrid:K,selectNodesOnDrag:j,onNodeDragStart:M,onSelectionDragStart:O,unselectNodesAndEdges:$}=t();d=!0,(!j||!D)&&!U&&T&&((J=P.get(T))!=null&&J.selected||$()),D&&j&&T&&(e==null||e(T));const F=To(q.sourceEvent,{transform:G,snapGrid:W,snapToGrid:K,containerBounds:g});if(l=F,o=d9(P,V,F,T),o.size>0&&(n||M||!T&&O)){const[re,le]=lp({nodeId:T,dragItems:o,nodeLookup:P});n==null||n(q.sourceEvent,o,re,le),M==null||M(q.sourceEvent,re,le),T||O==null||O(q.sourceEvent,le)}}const z=iC().clickDistance(R).on("start",q=>{const{domNode:P,nodeDragThreshold:U,transform:V,snapGrid:G,snapToGrid:W}=t();g=(P==null?void 0:P.getBoundingClientRect())||null,b=!1,w=!1,C=q.sourceEvent,U===0&&I(q),l=To(q.sourceEvent,{transform:V,snapGrid:G,snapToGrid:W,containerBounds:g}),f=$n(q.sourceEvent,g)}).on("drag",q=>{const{autoPanOnNodeDrag:P,transform:U,snapGrid:V,snapToGrid:G,nodeDragThreshold:W,nodeLookup:K}=t(),j=To(q.sourceEvent,{transform:U,snapGrid:V,snapToGrid:G,containerBounds:g});if(C=q.sourceEvent,(q.sourceEvent.type==="touchmove"&&q.sourceEvent.touches.length>1||T&&!K.has(T))&&(b=!0),!b){if(!u&&P&&d&&(u=!0,L()),!d){const M=$n(q.sourceEvent,g),O=M.x-f.x,$=M.y-f.y;Math.sqrt(O*O+$*$)>W&&I(q)}(l.x!==j.xSnapped||l.y!==j.ySnapped)&&o&&d&&(f=$n(q.sourceEvent,g),N(j))}}).on("end",q=>{if(!d||b){b&&o.size>0&&t().updateNodePositions(o,!1);return}if(u=!1,d=!1,cancelAnimationFrame(c),o.size>0){const{nodeLookup:P,updateNodePositions:U,onNodeDragStop:V,onSelectionDragStop:G}=t();if(w&&(U(o,!1),w=!1),a||V||!T&&G){const[W,K]=lp({nodeId:T,dragItems:o,nodeLookup:P,dragging:!1});a==null||a(q.sourceEvent,o,W,K),V==null||V(q.sourceEvent,W,K),T||G==null||G(q.sourceEvent,K)}}}).filter(q=>{const P=q.target;return!q.button&&(!S||!qb(P,`.${S}`,k))&&(!_||qb(P,_,k))});m.call(z)}function y(){m==null||m.on(".drag",null)}return{update:v,destroy:y}}function m9(e,t,n){const r=[],a={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const l of t.values())ku(a,qo(l))>0&&r.push(l);return r}const _9=250;function v9(e,t,n,r){var o,u;let a=[],l=1/0;const c=m9(e,n,t+_9);for(const f of c){const g=[...((o=f.internals.handleBounds)==null?void 0:o.source)??[],...((u=f.internals.handleBounds)==null?void 0:u.target)??[]];for(const d of g){if(r.nodeId===d.nodeId&&r.type===d.type&&r.id===d.id)continue;const{x:m,y:b}=Zr(f,d,d.position,!0),w=Math.sqrt(Math.pow(m-e.x,2)+Math.pow(b-e.y,2));w>t||(w<l?(a=[{...d,x:m,y:b}],l=w):w===l&&a.push({...d,x:m,y:b}))}}if(!a.length)return null;if(a.length>1){const f=r.type==="source"?"target":"source";return a.find(g=>g.type===f)??a[0]}return a[0]}function UC(e,t,n,r,a,l=!1){var f,g,d;const c=r.get(e);if(!c)return null;const o=a==="strict"?(f=c.internals.handleBounds)==null?void 0:f[t]:[...((g=c.internals.handleBounds)==null?void 0:g.source)??[],...((d=c.internals.handleBounds)==null?void 0:d.target)??[]],u=(n?o==null?void 0:o.find(m=>m.id===n):o==null?void 0:o[0])??null;return u&&l?{...u,...Zr(c,u,u.position,!0)}:u}function $C(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function y9(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const GC=()=>!0;function b9(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:a,edgeUpdaterType:l,isTarget:c,domNode:o,nodeLookup:u,lib:f,autoPanOnConnect:g,flowId:d,panBy:m,cancelConnection:b,onConnectStart:w,onConnect:C,onConnectEnd:v,isValidConnection:y=GC,onReconnectEnd:S,updateConnection:_,getTransform:k,getFromHandle:D,autoPanSpeed:T,dragThreshold:R=1,handleDomNode:N}){const L=RC(e.target);let I=0,z;const{x:q,y:P}=$n(e),U=$C(l,N),V=o==null?void 0:o.getBoundingClientRect();let G=!1;if(!V||!U)return;const W=UC(a,U,r,u,t);if(!W)return;let K=$n(e,V),j=!1,M=null,O=!1,$=null;function F(){if(!g||!V)return;const[de,he]=Cm(K,V,T);m({x:de,y:he}),I=requestAnimationFrame(F)}const J={...W,nodeId:a,type:U,position:W.position},re=u.get(a);let Z={inProgress:!0,isValid:null,from:Zr(re,J,Te.Left,!0),fromHandle:J,fromPosition:J.position,fromNode:re,to:K,toHandle:null,toPosition:Lb[J.position],toNode:null,pointer:K};function H(){G=!0,_(Z),w==null||w(e,{nodeId:a,handleId:r,handleType:U})}R===0&&H();function ee(de){if(!G){const{x:Se,y:$e}=$n(de),Ve=Se-q,it=$e-P;if(!(Ve*Ve+it*it>R*R))return;H()}if(!D()||!J){te(de);return}const he=k();K=$n(de,V),z=v9(ol(K,he,!1,[1,1]),n,u,J),j||(F(),j=!0);const ye=qC(de,{handle:z,connectionMode:t,fromNodeId:a,fromHandleId:r,fromType:c?"target":"source",isValidConnection:y,doc:L,lib:f,flowId:d,nodeLookup:u});$=ye.handleDomNode,M=ye.connection,O=y9(!!z,ye.isValid);const oe=u.get(a),ve=oe?Zr(oe,J,Te.Left,!0):Z.from,we={...Z,from:ve,isValid:O,to:ye.toHandle&&O?oa({x:ye.toHandle.x,y:ye.toHandle.y},he):K,toHandle:ye.toHandle,toPosition:O&&ye.toHandle?ye.toHandle.position:Lb[J.position],toNode:ye.toHandle?u.get(ye.toHandle.nodeId):null,pointer:K};_(we),Z=we}function te(de){if(!("touches"in de&&de.touches.length>0)){if(G){(z||$)&&M&&O&&(C==null||C(M));const{inProgress:he,...ye}=Z,oe={...ye,toPosition:Z.toHandle?Z.toPosition:null};v==null||v(de,oe),l&&(S==null||S(de,oe))}b(),cancelAnimationFrame(I),j=!1,O=!1,M=null,$=null,L.removeEventListener("mousemove",ee),L.removeEventListener("mouseup",te),L.removeEventListener("touchmove",ee),L.removeEventListener("touchend",te)}}L.addEventListener("mousemove",ee),L.addEventListener("mouseup",te),L.addEventListener("touchmove",ee),L.addEventListener("touchend",te)}function qC(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:a,fromType:l,doc:c,lib:o,flowId:u,isValidConnection:f=GC,nodeLookup:g}){const d=l==="target",m=t?c.querySelector(`.${o}-flow__handle[data-id="${u}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:b,y:w}=$n(e),C=c.elementFromPoint(b,w),v=C!=null&&C.classList.contains(`${o}-flow__handle`)?C:m,y={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const S=$C(void 0,v),_=v.getAttribute("data-nodeid"),k=v.getAttribute("data-handleid"),D=v.classList.contains("connectable"),T=v.classList.contains("connectableend");if(!_||!S)return y;const R={source:d?_:r,sourceHandle:d?k:a,target:d?r:_,targetHandle:d?a:k};y.connection=R;const L=D&&T&&(n===sa.Strict?d&&S==="source"||!d&&S==="target":_!==r||k!==a);y.isValid=L&&f(R),y.toHandle=UC(_,S,k,g,n,!0)}return y}const sg={onPointerDown:b9,isValid:qC};function S9({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const a=yn(e);function l({translateExtent:o,width:u,height:f,zoomStep:g=1,pannable:d=!0,zoomable:m=!0,inversePan:b=!1}){const w=_=>{if(_.sourceEvent.type!=="wheel"||!t)return;const k=n(),D=_.sourceEvent.ctrlKey&&Vo()?10:1,T=-_.sourceEvent.deltaY*(_.sourceEvent.deltaMode===1?.05:_.sourceEvent.deltaMode?1:.002)*g,R=k[2]*Math.pow(2,T*D);t.scaleTo(R)};let C=[0,0];const v=_=>{(_.sourceEvent.type==="mousedown"||_.sourceEvent.type==="touchstart")&&(C=[_.sourceEvent.clientX??_.sourceEvent.touches[0].clientX,_.sourceEvent.clientY??_.sourceEvent.touches[0].clientY])},y=_=>{const k=n();if(_.sourceEvent.type!=="mousemove"&&_.sourceEvent.type!=="touchmove"||!t)return;const D=[_.sourceEvent.clientX??_.sourceEvent.touches[0].clientX,_.sourceEvent.clientY??_.sourceEvent.touches[0].clientY],T=[D[0]-C[0],D[1]-C[1]];C=D;const R=r()*Math.max(k[2],Math.log(k[2]))*(b?-1:1),N={x:k[0]-T[0]*R,y:k[1]-T[1]*R},L=[[0,0],[u,f]];t.setViewportConstrained({x:N.x,y:N.y,zoom:k[2]},L,o)},S=vC().on("start",v).on("zoom",d?y:null).on("zoom.wheel",m?w:null);a.call(S,{})}function c(){a.on("zoom",null)}return{update:l,destroy:c,pointer:Fn}}const uh=e=>({x:e.x,y:e.y,zoom:e.k}),cp=({x:e,y:t,zoom:n})=>oh.translate(e,t).scale(n),Zs=(e,t)=>e.target.closest(`.${t}`),VC=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),x9=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,up=(e,t=0,n=x9,r=()=>{})=>{const a=typeof t=="number"&&t>0;return a||r(),a?e.transition().duration(t).ease(n).on("end",r):e},YC=e=>{const t=e.ctrlKey&&Vo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function w9({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:a,panOnScrollSpeed:l,zoomOnPinch:c,onPanZoomStart:o,onPanZoom:u,onPanZoomEnd:f}){return g=>{if(Zs(g,t))return g.ctrlKey&&g.preventDefault(),!1;g.preventDefault(),g.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(g.ctrlKey&&c){const v=Fn(g),y=YC(g),S=d*Math.pow(2,y);r.scaleTo(n,S,v,g);return}const m=g.deltaMode===1?20:1;let b=a===qr.Vertical?0:g.deltaX*m,w=a===qr.Horizontal?0:g.deltaY*m;!Vo()&&g.shiftKey&&a!==qr.Vertical&&(b=g.deltaY*m,w=0),r.translateBy(n,-(b/d)*l,-(w/d)*l,{internal:!0});const C=uh(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(u==null||u(g,C),e.panScrollTimeout=setTimeout(()=>{f==null||f(g,C),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,o==null||o(g,C))}}function C9({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,a){const l=r.type==="wheel",c=!t&&l&&!r.ctrlKey,o=Zs(r,e);if(r.ctrlKey&&l&&o&&r.preventDefault(),c||o)return null;r.preventDefault(),n.call(this,r,a)}}function E9({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var l,c,o;if((l=r.sourceEvent)!=null&&l.internal)return;const a=uh(r.transform);e.mouseButton=((c=r.sourceEvent)==null?void 0:c.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=a,((o=r.sourceEvent)==null?void 0:o.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,a))}}function k9({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:a}){return l=>{var c,o;e.usedRightMouseButton=!!(n&&VC(t,e.mouseButton??0)),(c=l.sourceEvent)!=null&&c.sync||r([l.transform.x,l.transform.y,l.transform.k]),a&&!((o=l.sourceEvent)!=null&&o.internal)&&(a==null||a(l.sourceEvent,uh(l.transform)))}}function A9({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:a,onPaneContextMenu:l}){return c=>{var o;if(!((o=c.sourceEvent)!=null&&o.internal)&&(e.isZoomingOrPanning=!1,l&&VC(t,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&l(c.sourceEvent),e.usedRightMouseButton=!1,r(!1),a)){const u=uh(c.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,u)},n?150:0)}}}function T9({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:a,zoomOnDoubleClick:l,userSelectionActive:c,noWheelClassName:o,noPanClassName:u,lib:f,connectionInProgress:g}){return d=>{var v;const m=e||t,b=n&&d.ctrlKey,w=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(Zs(d,`${f}-flow__node`)||Zs(d,`${f}-flow__edge`)))return!0;if(!r&&!m&&!a&&!l&&!n||c||g&&!w||Zs(d,o)&&w||Zs(d,u)&&(!w||a&&w&&!e)||!n&&d.ctrlKey&&w)return!1;if(!n&&d.type==="touchstart"&&((v=d.touches)==null?void 0:v.length)>1)return d.preventDefault(),!1;if(!m&&!a&&!b&&w||!r&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(r)&&!r.includes(d.button)&&d.type==="mousedown")return!1;const C=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||w)&&C}}function N9({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:a,onPanZoom:l,onPanZoomStart:c,onPanZoomEnd:o,onDraggingChange:u}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},g=e.getBoundingClientRect(),d=vC().scaleExtent([t,n]).translateExtent(r),m=yn(e).call(d);S({x:a.x,y:a.y,zoom:aa(a.zoom,t,n)},[[0,0],[g.width,g.height]],r);const b=m.on("wheel.zoom"),w=m.on("dblclick.zoom");d.wheelDelta(YC);async function C(z,q){return m?new Promise(P=>{d==null||d.interpolate((q==null?void 0:q.interpolate)==="linear"?Ao:iu).transform(up(m,q==null?void 0:q.duration,q==null?void 0:q.ease,()=>P(!0)),z)}):!1}function v({noWheelClassName:z,noPanClassName:q,onPaneContextMenu:P,userSelectionActive:U,panOnScroll:V,panOnDrag:G,panOnScrollMode:W,panOnScrollSpeed:K,preventScrolling:j,zoomOnPinch:M,zoomOnScroll:O,zoomOnDoubleClick:$,zoomActivationKeyPressed:F,lib:J,onTransformChange:re,connectionInProgress:le,paneClickDistance:Z,selectionOnDrag:H}){U&&!f.isZoomingOrPanning&&y();const ee=V&&!F&&!U;d.clickDistance(H?1/0:!Un(Z)||Z<0?0:Z);const te=ee?w9({zoomPanValues:f,noWheelClassName:z,d3Selection:m,d3Zoom:d,panOnScrollMode:W,panOnScrollSpeed:K,zoomOnPinch:M,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:o}):C9({noWheelClassName:z,preventScrolling:j,d3ZoomHandler:b});m.on("wheel.zoom",te,{passive:!1});const de=E9({zoomPanValues:f,onDraggingChange:u,onPanZoomStart:c});d.on("start",de);const he=k9({zoomPanValues:f,panOnDrag:G,onPaneContextMenu:!!P,onPanZoom:l,onTransformChange:re});d.on("zoom",he);const ye=A9({zoomPanValues:f,panOnDrag:G,panOnScroll:V,onPaneContextMenu:P,onPanZoomEnd:o,onDraggingChange:u});d.on("end",ye);const oe=T9({zoomActivationKeyPressed:F,panOnDrag:G,zoomOnScroll:O,panOnScroll:V,zoomOnDoubleClick:$,zoomOnPinch:M,userSelectionActive:U,noPanClassName:q,noWheelClassName:z,lib:J,connectionInProgress:le});d.filter(oe),$?m.on("dblclick.zoom",w):m.on("dblclick.zoom",null)}function y(){d.on("zoom",null)}async function S(z,q,P){const U=cp(z),V=d==null?void 0:d.constrain()(U,q,P);return V&&await C(V),V}async function _(z,q){const P=cp(z);return await C(P,q),P}function k(z){if(m){const q=cp(z),P=m.property("__zoom");(P.k!==z.zoom||P.x!==z.x||P.y!==z.y)&&(d==null||d.transform(m,q,null,{sync:!0}))}}function D(){const z=m?_C(m.node()):{x:0,y:0,k:1};return{x:z.x,y:z.y,zoom:z.k}}async function T(z,q){return m?new Promise(P=>{d==null||d.interpolate((q==null?void 0:q.interpolate)==="linear"?Ao:iu).scaleTo(up(m,q==null?void 0:q.duration,q==null?void 0:q.ease,()=>P(!0)),z)}):!1}async function R(z,q){return m?new Promise(P=>{d==null||d.interpolate((q==null?void 0:q.interpolate)==="linear"?Ao:iu).scaleBy(up(m,q==null?void 0:q.duration,q==null?void 0:q.ease,()=>P(!0)),z)}):!1}function N(z){d==null||d.scaleExtent(z)}function L(z){d==null||d.translateExtent(z)}function I(z){const q=!Un(z)||z<0?0:z;d==null||d.clickDistance(q)}return{update:v,destroy:y,setViewport:_,setViewportConstrained:S,getViewport:D,scaleTo:T,scaleBy:R,setScaleExtent:N,setTranslateExtent:L,syncViewport:k,setClickDistance:I}}var la;(function(e){e.Line="line",e.Handle="handle"})(la||(la={}));function D9({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:a,affectsY:l}){const c=e-t,o=n-r,u=[c>0?1:c<0?-1:0,o>0?1:o<0?-1:0];return c&&a&&(u[0]=u[0]*-1),o&&l&&(u[1]=u[1]*-1),u}function Vb(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),a=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:a}}function hr(e,t){return Math.max(0,t-e)}function fr(e,t){return Math.max(0,e-t)}function Vc(e,t,n){return Math.max(0,t-e,e-n)}function Yb(e,t){return e?!t:t}function R9(e,t,n,r,a,l,c,o){let{affectsX:u,affectsY:f}=t;const{isHorizontal:g,isVertical:d}=t,m=g&&d,{xSnapped:b,ySnapped:w}=n,{minWidth:C,maxWidth:v,minHeight:y,maxHeight:S}=r,{x:_,y:k,width:D,height:T,aspectRatio:R}=e;let N=Math.floor(g?b-e.pointerX:0),L=Math.floor(d?w-e.pointerY:0);const I=D+(u?-N:N),z=T+(f?-L:L),q=-l[0]*D,P=-l[1]*T;let U=Vc(I,C,v),V=Vc(z,y,S);if(c){let K=0,j=0;u&&N<0?K=hr(_+N+q,c[0][0]):!u&&N>0&&(K=fr(_+I+q,c[1][0])),f&&L<0?j=hr(k+L+P,c[0][1]):!f&&L>0&&(j=fr(k+z+P,c[1][1])),U=Math.max(U,K),V=Math.max(V,j)}if(o){let K=0,j=0;u&&N>0?K=fr(_+N,o[0][0]):!u&&N<0&&(K=hr(_+I,o[1][0])),f&&L>0?j=fr(k+L,o[0][1]):!f&&L<0&&(j=hr(k+z,o[1][1])),U=Math.max(U,K),V=Math.max(V,j)}if(a){if(g){const K=Vc(I/R,y,S)*R;if(U=Math.max(U,K),c){let j=0;!u&&!f||u&&!f&&m?j=fr(k+P+I/R,c[1][1])*R:j=hr(k+P+(u?N:-N)/R,c[0][1])*R,U=Math.max(U,j)}if(o){let j=0;!u&&!f||u&&!f&&m?j=hr(k+I/R,o[1][1])*R:j=fr(k+(u?N:-N)/R,o[0][1])*R,U=Math.max(U,j)}}if(d){const K=Vc(z*R,C,v)/R;if(V=Math.max(V,K),c){let j=0;!u&&!f||f&&!u&&m?j=fr(_+z*R+q,c[1][0])/R:j=hr(_+(f?L:-L)*R+q,c[0][0])/R,V=Math.max(V,j)}if(o){let j=0;!u&&!f||f&&!u&&m?j=hr(_+z*R,o[1][0])/R:j=fr(_+(f?L:-L)*R,o[0][0])/R,V=Math.max(V,j)}}}L=L+(L<0?V:-V),N=N+(N<0?U:-U),a&&(m?I>z*R?L=(Yb(u,f)?-N:N)/R:N=(Yb(u,f)?-L:L)*R:g?(L=N/R,f=u):(N=L*R,u=f));const G=u?_+N:_,W=f?k+L:k;return{width:D+(u?-N:N),height:T+(f?-L:L),x:l[0]*N*(u?-1:1)+G,y:l[1]*L*(f?-1:1)+W}}const WC={width:0,height:0,x:0,y:0},M9={...WC,pointerX:0,pointerY:0,aspectRatio:1};function L9(e,t,n){const r=t.position.x+e.position.x,a=t.position.y+e.position.y,l=e.measured.width??0,c=e.measured.height??0,o=n[0]*l,u=n[1]*c;return[[r-o,a-u],[r+l-o,a+c-u]]}function O9({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:a}){const l=yn(e);let c={controlDirection:Vb("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function o({controlPosition:f,boundaries:g,keepAspectRatio:d,resizeDirection:m,onResizeStart:b,onResize:w,onResizeEnd:C,shouldResize:v}){let y={...WC},S={...M9};c={boundaries:g,resizeDirection:m,keepAspectRatio:d,controlDirection:Vb(f)};let _,k=null,D=[],T,R,N,L=!1;const I=iC().on("start",z=>{const{nodeLookup:q,transform:P,snapGrid:U,snapToGrid:V,nodeOrigin:G,paneDomNode:W}=n();if(_=q.get(t),!_)return;k=(W==null?void 0:W.getBoundingClientRect())??null;const{xSnapped:K,ySnapped:j}=To(z.sourceEvent,{transform:P,snapGrid:U,snapToGrid:V,containerBounds:k});y={width:_.measured.width??0,height:_.measured.height??0,x:_.position.x??0,y:_.position.y??0},S={...y,pointerX:K,pointerY:j,aspectRatio:y.width/y.height},T=void 0,R=Kr(_.extent)?_.extent:void 0,_.parentId&&(_.extent==="parent"||_.expandParent)&&(T=q.get(_.parentId)),T&&_.extent==="parent"&&(R=[[0,0],[T.measured.width,T.measured.height]]),D=[],N=void 0;for(const[M,O]of q)if(O.parentId===t&&(D.push({id:M,position:{...O.position},extent:O.extent}),O.extent==="parent"||O.expandParent)){const $=L9(O,_,O.origin??G);N?N=[[Math.min($[0][0],N[0][0]),Math.min($[0][1],N[0][1])],[Math.max($[1][0],N[1][0]),Math.max($[1][1],N[1][1])]]:N=$}b==null||b(z,{...y})}).on("drag",z=>{const{transform:q,snapGrid:P,snapToGrid:U,nodeOrigin:V}=n(),G=To(z.sourceEvent,{transform:q,snapGrid:P,snapToGrid:U,containerBounds:k}),W=[];if(!_)return;const{x:K,y:j,width:M,height:O}=y,$={},F=_.origin??V,{width:J,height:re,x:le,y:Z}=R9(S,c.controlDirection,G,c.boundaries,c.keepAspectRatio,F,R,N),H=J!==M,ee=re!==O,te=le!==K&&H,de=Z!==j&ⅇif(!te&&!de&&!H&&!ee)return;if((te||de||F[0]===1||F[1]===1)&&($.x=te?le:y.x,$.y=de?Z:y.y,y.x=$.x,y.y=$.y,D.length>0)){const ve=le-K,we=Z-j;for(const Se of D)Se.position={x:Se.position.x-ve+F[0]*(J-M),y:Se.position.y-we+F[1]*(re-O)},W.push(Se)}if((H||ee)&&($.width=H&&(!c.resizeDirection||c.resizeDirection==="horizontal")?J:y.width,$.height=ee&&(!c.resizeDirection||c.resizeDirection==="vertical")?re:y.height,y.width=$.width,y.height=$.height),T&&_.expandParent){const ve=F[0]*($.width??0);$.x&&$.x<ve&&(y.x=ve,S.x=S.x-($.x-ve));const we=F[1]*($.height??0);$.y&&$.y<we&&(y.y=we,S.y=S.y-($.y-we))}const he=D9({width:y.width,prevWidth:M,height:y.height,prevHeight:O,affectsX:c.controlDirection.affectsX,affectsY:c.controlDirection.affectsY}),ye={...y,direction:he};(v==null?void 0:v(z,ye))!==!1&&(L=!0,w==null||w(z,ye),r($,W))}).on("end",z=>{L&&(C==null||C(z,{...y}),a==null||a({...y}),L=!1)});l.call(I)}function u(){l.on(".drag",null)}return{update:o,destroy:u}}var hp={exports:{}},fp={},dp={exports:{}},pp={};/** * @license React @@ -330,4 +330,4 @@ Its experiments, runs and chats are removed from orx. The GitHub repo (${f.githu `,` +`).split(` `)),g=f.reduce((d,m)=>d.concat(...m),[]);return[f,g]}return[[],[]]},[e]);return X.useEffect(()=>{const u=(t==null?void 0:t.target)??sS,f=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const g=b=>{var v,y;if(a.current=b.ctrlKey||b.metaKey||b.shiftKey||b.altKey,(!a.current||a.current&&!f)&&MC(b))return!1;const C=oS(b.code,o);if(l.current.add(b[C]),aS(c,l.current,!1)){const S=((y=(v=b.composedPath)==null?void 0:v.call(b))==null?void 0:y[0])||b.target,_=(S==null?void 0:S.nodeName)==="BUTTON"||(S==null?void 0:S.nodeName)==="A";t.preventDefault!==!1&&(a.current||!_)&&b.preventDefault(),r(!0)}},d=b=>{const w=oS(b.code,o);aS(c,l.current,!0)?(r(!1),l.current.clear()):l.current.delete(b[w]),b.key==="Meta"&&l.current.clear(),a.current=!1},m=()=>{l.current.clear(),r(!1)};return u==null||u.addEventListener("keydown",g),u==null||u.addEventListener("keyup",d),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{u==null||u.removeEventListener("keydown",g),u==null||u.removeEventListener("keyup",d),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[e,r]),n}function aS(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(a=>t.has(a)))}function oS(e,t){return t.includes(e)?"code":"key"}const hz=()=>{const e=yt();return X.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,a,l],panZoom:c}=e.getState();return c?(await c.setViewport({x:t.x??r,y:t.y??a,zoom:t.zoom??l},n),!0):!1},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:a,minZoom:l,maxZoom:c,panZoom:o}=e.getState(),u=Em(t,r,a,l,c,(n==null?void 0:n.padding)??.1);return o?(await o.setViewport(u,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:a,snapToGrid:l,domNode:c}=e.getState();if(!c)return t;const{x:o,y:u}=c.getBoundingClientRect(),f={x:t.x-o,y:t.y-u},g=n.snapGrid??a,d=n.snapToGrid??l;return ol(f,r,d,g)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:a,y:l}=r.getBoundingClientRect(),c=oa(t,n);return{x:c.x+a,y:c.y+l}}}),[])};function eE(e,t){const n=[],r=new Map,a=[];for(const l of e)if(l.type==="add"){a.push(l);continue}else if(l.type==="remove"||l.type==="replace")r.set(l.id,[l]);else{const c=r.get(l.id);c?c.push(l):r.set(l.id,[l])}for(const l of t){const c=r.get(l.id);if(!c){n.push(l);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){n.push({...c[0].item});continue}const o={...l};for(const u of c)fz(u,o);n.push(o)}return a.length&&a.forEach(l=>{l.index!==void 0?n.splice(l.index,0,{...l.item}):n.push({...l.item})}),n}function fz(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 dz(e,t){return eE(e,t)}function pz(e,t){return eE(e,t)}function Pr(e,t){return{id:e,type:"select",selected:t}}function Qs(e,t=new Set,n=!1){const r=[];for(const[a,l]of e){const c=t.has(a);!(l.selected===void 0&&!c)&&l.selected!==c&&(n&&(l.selected=c),r.push(Pr(l.id,c)))}return r}function lS({items:e=[],lookup:t}){var a;const n=[],r=new Map(e.map(l=>[l.id,l]));for(const[l,c]of e.entries()){const o=t.get(c.id),u=((a=o==null?void 0:o.internals)==null?void 0:a.userNode)??o;u!==void 0&&u!==c&&n.push({id:c.id,item:c,type:"replace"}),u===void 0&&n.push({item:c,type:"add",index:l})}for(const[l]of t)r.get(l)===void 0&&n.push({id:l,type:"remove"});return n}function cS(e){return{id:e.id,type:"remove"}}const gz=TC();function mz(e,t,n={}){return J7(e,t,{...n,onError:n.onError??gz})}const uS=e=>z7(e),_z=e=>wC(e);function tE(e){return X.forwardRef(e)}const vz=typeof window<"u"?X.useLayoutEffect:X.useEffect;function hS(e){const[t,n]=X.useState(BigInt(0)),[r]=X.useState(()=>yz(()=>n(a=>a+BigInt(1))));return vz(()=>{const a=r.get();a.length&&(e(a),r.reset())},[t]),r}function yz(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const nE=X.createContext(null);function bz({children:e}){const t=yt(),n=X.useCallback(o=>{const{nodes:u=[],setNodes:f,hasDefaultNodes:g,onNodesChange:d,nodeLookup:m,fitViewQueued:b,onNodesChangeMiddlewareMap:w}=t.getState();let C=u;for(const y of o)C=typeof y=="function"?y(C):y;let v=lS({items:C,lookup:m});for(const y of w.values())v=y(v);g&&f(C),v.length>0?d==null||d(v):b&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:S,setNodes:_}=t.getState();y&&_(S)})},[]),r=hS(n),a=X.useCallback(o=>{const{edges:u=[],setEdges:f,hasDefaultEdges:g,onEdgesChange:d,edgeLookup:m}=t.getState();let b=u;for(const w of o)b=typeof w=="function"?w(b):w;g?f(b):d&&d(lS({items:b,lookup:m}))},[]),l=hS(a),c=X.useMemo(()=>({nodeQueue:r,edgeQueue:l}),[]);return x.jsx(nE.Provider,{value:c,children:e})}function Sz(){const e=X.useContext(nE);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const xz=e=>!!e.panZoom;function Mm(){const e=hz(),t=yt(),n=Sz(),r=Ze(xz),a=X.useMemo(()=>{const l=d=>t.getState().nodeLookup.get(d),c=d=>{n.nodeQueue.push(d)},o=d=>{n.edgeQueue.push(d)},u=d=>{var y,S;const{nodeLookup:m,nodeOrigin:b}=t.getState(),w=uS(d)?d:m.get(d.id),C=w.parentId?DC(w.position,w.measured,w.parentId,m,b):w.position,v={...w,position:C,width:((y=w.measured)==null?void 0:y.width)??w.width,height:((S=w.measured)==null?void 0:S.height)??w.height};return qo(v)},f=(d,m,b={replace:!1})=>{c(w=>w.map(C=>{if(C.id===d){const v=typeof m=="function"?m(C):m;return b.replace&&uS(v)?v:{...C,...v}}return C}))},g=(d,m,b={replace:!1})=>{o(w=>w.map(C=>{if(C.id===d){const v=typeof m=="function"?m(C):m;return b.replace&&_z(v)?v:{...C,...v}}return C}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var m;return(m=l(d))==null?void 0:m.internals.userNode},getInternalNode:l,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(m=>({...m}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:c,setEdges:o,addNodes:d=>{const m=Array.isArray(d)?d:[d];n.nodeQueue.push(b=>[...b,...m])},addEdges:d=>{const m=Array.isArray(d)?d:[d];n.edgeQueue.push(b=>[...b,...m])},toObject:()=>{const{nodes:d=[],edges:m=[],transform:b}=t.getState(),[w,C,v]=b;return{nodes:d.map(y=>({...y})),edges:m.map(y=>({...y})),viewport:{x:w,y:C,zoom:v}}},deleteElements:async({nodes:d=[],edges:m=[]})=>{const{nodes:b,edges:w,onNodesDelete:C,onEdgesDelete:v,triggerNodeChanges:y,triggerEdgeChanges:S,onDelete:_,onBeforeDelete:k}=t.getState(),{nodes:D,edges:T}=await $7({nodesToRemove:d,edgesToRemove:m,nodes:b,edges:w,onBeforeDelete:k}),R=T.length>0,N=D.length>0;if(R){const L=T.map(cS);v==null||v(T),S(L)}if(N){const L=D.map(cS);C==null||C(D),y(L)}return(N||R)&&(_==null||_({nodes:D,edges:T})),{deletedNodes:D,deletedEdges:T}},getIntersectingNodes:(d,m=!0,b)=>{const w=jb(d),C=w?d:u(d),v=b!==void 0;return C?(b||t.getState().nodes).filter(y=>{const S=t.getState().nodeLookup.get(y.id);if(S&&!w&&(y.id===d.id||!S.internals.positionAbsolute))return!1;const _=qo(v?y:S),k=ku(_,C);return m&&k>0||k>=_.width*_.height||k>=C.width*C.height}):[]},isNodeIntersecting:(d,m,b=!0)=>{const C=jb(d)?d:u(d);if(!C)return!1;const v=ku(C,m);return b&&v>0||v>=m.width*m.height||v>=C.width*C.height},updateNode:f,updateNodeData:(d,m,b={replace:!1})=>{f(d,w=>{const C=typeof m=="function"?m(w):m;return b.replace?{...w,data:C}:{...w,data:{...w.data,...C}}},b)},updateEdge:g,updateEdgeData:(d,m,b={replace:!1})=>{g(d,w=>{const C=typeof m=="function"?m(w):m;return b.replace?{...w,data:C}:{...w,data:{...w.data,...C}}},b)},getNodesBounds:d=>{const{nodeLookup:m,nodeOrigin:b}=t.getState();return H7(d,{nodeLookup:m,nodeOrigin:b})},getHandleConnections:({type:d,id:m,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}-${d}${m?`-${m}`:""}`))==null?void 0:w.values())??[])},getNodeConnections:({type:d,handleId:m,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}${d?m?`-${d}-${m}`:`-${d}`:""}`))==null?void 0:w.values())??[])},fitView:async d=>{const m=t.getState().fitViewResolver??V7();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:m}),n.nodeQueue.push(b=>[...b]),m.promise}}},[]);return X.useMemo(()=>({...a,...e,viewportInitialized:r}),[r])}const fS=e=>e.selected,wz=typeof window<"u"?window:void 0;function Cz({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=yt(),{deleteElements:r}=Mm(),a=Yo(e,{actInsideInputWithModifier:!1}),l=Yo(t,{target:wz});X.useEffect(()=>{if(a){const{edges:c,nodes:o}=n.getState();r({nodes:o.filter(fS),edges:c.filter(fS)}),n.setState({nodesSelectionActive:!1})}},[a]),X.useEffect(()=>{n.setState({multiSelectionActive:l})},[l])}function Ez(e){const t=yt();X.useEffect(()=>{const n=()=>{var a,l,c,o;if(!e.current||!(((l=(a=e.current).checkVisibility)==null?void 0:l.call(a))??!0))return!1;const r=km(e.current);(r.height===0||r.width===0)&&((o=(c=t.getState()).onError)==null||o.call(c,"004",qn.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const dh={position:"absolute",width:"100%",height:"100%",top:0,left:0},kz=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Az({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:a=.5,panOnScrollMode:l=qr.Free,zoomOnDoubleClick:c=!0,panOnDrag:o=!0,defaultViewport:u,translateExtent:f,minZoom:g,maxZoom:d,zoomActivationKeyCode:m,preventScrolling:b=!0,children:w,noWheelClassName:C,noPanClassName:v,onViewportChange:y,isControlledViewport:S,paneClickDistance:_,selectionOnDrag:k}){const D=yt(),T=X.useRef(null),{userSelectionActive:R,lib:N,connectionInProgress:L}=Ze(kz,vt),I=Yo(m),z=X.useRef();Ez(T);const q=X.useCallback(P=>{y==null||y({x:P[0],y:P[1],zoom:P[2]}),S||D.setState({transform:P})},[y,S]);return X.useEffect(()=>{if(T.current){z.current=N9({domNode:T.current,minZoom:g,maxZoom:d,translateExtent:f,viewport:u,onDraggingChange:G=>D.setState(W=>W.paneDragging===G?W:{paneDragging:G}),onPanZoomStart:(G,W)=>{const{onViewportChangeStart:K,onMoveStart:j}=D.getState();j==null||j(G,W),K==null||K(W)},onPanZoom:(G,W)=>{const{onViewportChange:K,onMove:j}=D.getState();j==null||j(G,W),K==null||K(W)},onPanZoomEnd:(G,W)=>{const{onViewportChangeEnd:K,onMoveEnd:j}=D.getState();j==null||j(G,W),K==null||K(W)}});const{x:P,y:U,zoom:V}=z.current.getViewport();return D.setState({panZoom:z.current,transform:[P,U,V],domNode:T.current.closest(".react-flow")}),()=>{var G;(G=z.current)==null||G.destroy()}}},[]),X.useEffect(()=>{var P;(P=z.current)==null||P.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:a,panOnScrollMode:l,zoomOnDoubleClick:c,panOnDrag:o,zoomActivationKeyPressed:I,preventScrolling:b,noPanClassName:v,userSelectionActive:R,noWheelClassName:C,lib:N,onTransformChange:q,connectionInProgress:L,selectionOnDrag:k,paneClickDistance:_})},[e,t,n,r,a,l,c,o,I,b,v,R,C,N,q,L,k,_]),x.jsx("div",{className:"react-flow__renderer",ref:T,style:dh,children:w})}const Tz=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Nz(){const{userSelectionActive:e,userSelectionRect:t}=Ze(Tz,vt);return e&&t?x.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 gp=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Dz=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Rz({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Go.Full,panOnDrag:r,autoPanOnSelection:a,paneClickDistance:l,selectionOnDrag:c,onSelectionStart:o,onSelectionEnd:u,onPaneClick:f,onPaneContextMenu:g,onPaneScroll:d,onPaneMouseEnter:m,onPaneMouseMove:b,onPaneMouseLeave:w,children:C}){const v=X.useRef(0),y=yt(),{userSelectionActive:S,elementsSelectable:_,dragging:k,panBy:D,autoPanSpeed:T}=Ze(Dz,vt),R=_&&(e||S),N=X.useRef(null),L=X.useRef(),I=X.useRef(new Set),z=X.useRef(new Set),q=X.useRef(!1),P=X.useRef(!1),U=X.useRef({x:0,y:0}),V=X.useRef(!1),G=H=>{if(P.current||q.current||y.getState().connection.inProgress){P.current=!1,q.current=!1;return}f==null||f(H),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},W=H=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){H.preventDefault();return}g==null||g(H)},K=d?H=>d(H):void 0,j=H=>{P.current&&(H.stopPropagation(),P.current=!1)},M=H=>{var Se,$e;const{domNode:ee,transform:te}=y.getState();if(L.current=ee==null?void 0:ee.getBoundingClientRect(),!L.current)return;const de=H.target===N.current;if(!de&&!!H.target.closest(".nokey")||!e||!(c&&de||t)||H.button!==0||!H.isPrimary)return;($e=(Se=H.target)==null?void 0:Se.setPointerCapture)==null||$e.call(Se,H.pointerId),P.current=!1;const{x:oe,y:ve}=$n(H.nativeEvent,L.current),we=ol({x:oe,y:ve},te);y.setState({userSelectionRect:{width:0,height:0,startX:we.x,startY:we.y,x:oe,y:ve}}),de||(H.stopPropagation(),H.preventDefault())};function O(H,ee){const{userSelectionRect:te}=y.getState();if(!te)return;const{transform:de,nodeLookup:he,edgeLookup:ye,connectionLookup:oe,triggerNodeChanges:ve,triggerEdgeChanges:we,defaultEdgeOptions:Se}=y.getState(),$e={x:te.startX,y:te.startY},{x:Ve,y:it}=oa($e,de),dt={startX:$e.x,startY:$e.y,x:H<Ve?H:Ve,y:ee<it?ee:it,width:Math.abs(H-Ve),height:Math.abs(ee-it)},Ht=I.current,me=z.current;I.current=new Set(wm(he,dt,de,n===Go.Partial,!0).map(De=>De.id)),z.current=new Set;const Ee=(Se==null?void 0:Se.selectable)??!0;for(const De of I.current){const ue=oe.get(De);if(ue)for(const{edgeId:be}of ue.values()){const Ce=ye.get(be);Ce&&(Ce.selectable??Ee)&&z.current.add(be)}}if(!Bb(Ht,I.current)){const De=Qs(he,I.current,!0);ve(De)}if(!Bb(me,z.current)){const De=Qs(ye,z.current);we(De)}y.setState({userSelectionRect:dt,userSelectionActive:!0,nodesSelectionActive:!1})}function $(){if(!a||!L.current)return;const[H,ee]=Cm(U.current,L.current,T);D({x:H,y:ee}).then(te=>{if(!P.current||!te){v.current=requestAnimationFrame($);return}const{x:de,y:he}=U.current;O(de,he),v.current=requestAnimationFrame($)})}const F=()=>{cancelAnimationFrame(v.current),v.current=0,V.current=!1};X.useEffect(()=>()=>F(),[]);const J=H=>{const{userSelectionRect:ee,transform:te,resetSelectedElements:de}=y.getState();if(!L.current||!ee)return;const{x:he,y:ye}=$n(H.nativeEvent,L.current);U.current={x:he,y:ye};const oe=oa({x:ee.startX,y:ee.startY},te);if(!P.current){const ve=t?0:l;if(Math.hypot(he-oe.x,ye-oe.y)<=ve)return;de(),o==null||o(H)}P.current=!0,V.current||($(),V.current=!0),O(he,ye)},re=H=>{var ee,te;if(!R){H.target===N.current&&y.getState().connection.inProgress&&(q.current=!0);return}H.button===0&&((te=(ee=H.target)==null?void 0:ee.releasePointerCapture)==null||te.call(ee,H.pointerId),!S&&H.target===N.current&&y.getState().userSelectionRect&&(G==null||G(H)),y.setState({userSelectionActive:!1,userSelectionRect:null}),P.current&&(u==null||u(H),y.setState({nodesSelectionActive:I.current.size>0})),F())},le=H=>{var ee,te;(te=(ee=H.target)==null?void 0:ee.releasePointerCapture)==null||te.call(ee,H.pointerId),F()},Z=r===!0||Array.isArray(r)&&r.includes(0);return x.jsxs("div",{className:Lt(["react-flow__pane",{draggable:Z,dragging:k,selection:e}]),onClick:R?void 0:gp(G,N),onContextMenu:gp(W,N),onWheel:gp(K,N),onPointerEnter:R?void 0:m,onPointerMove:R?J:b,onPointerUp:re,onPointerCancel:R?le:void 0,onPointerDownCapture:R?M:void 0,onClickCapture:R?j:void 0,onPointerLeave:w,ref:N,style:dh,children:[C,x.jsx(Nz,{})]})}function ag({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:a,unselectNodesAndEdges:l,multiSelectionActive:c,nodeLookup:o,onError:u}=t.getState(),f=o.get(e);if(!f){u==null||u("012",qn.error012(e));return}t.setState({nodesSelectionActive:!1}),f.selected?(n||f.selected&&c)&&(l({nodes:[f],edges:[]}),requestAnimationFrame(()=>{var g;return(g=r==null?void 0:r.current)==null?void 0:g.blur()})):a([e])}function iE({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:a,isSelectable:l,nodeClickDistance:c}){const o=yt(),[u,f]=X.useState(!1),g=X.useRef();return X.useEffect(()=>{g.current=g9({getStoreItems:()=>o.getState(),onNodeMouseDown:d=>{ag({id:d,store:o,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),X.useEffect(()=>{if(!(t||!e.current||!g.current))return g.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:l,nodeId:a,nodeClickDistance:c}),()=>{var d;(d=g.current)==null||d.destroy()}},[n,r,t,l,e,a,c]),u}const Mz=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function rE(){const e=yt();return X.useCallback(n=>{const{nodeExtent:r,snapToGrid:a,snapGrid:l,nodesDraggable:c,onError:o,updateNodePositions:u,nodeLookup:f,nodeOrigin:g}=e.getState(),d=new Map,m=Mz(c),b=a?l[0]:5,w=a?l[1]:5,C=n.direction.x*b*n.factor,v=n.direction.y*w*n.factor;for(const[,y]of f){if(!m(y))continue;let S={x:y.internals.positionAbsolute.x+C,y:y.internals.positionAbsolute.y+v};a&&(S=al(S,l));const{position:_,positionAbsolute:k}=CC({nodeId:y.id,nextPosition:S,nodeLookup:f,nodeExtent:r,nodeOrigin:g,onError:o});y.position=_,y.internals.positionAbsolute=k,d.set(y.id,y)}u(d)},[])}const Lm=X.createContext(null),Lz=Lm.Provider;Lm.Consumer;const sE=()=>X.useContext(Lm),Oz=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),aE=X.createContext(null);function jz({children:e}){const t=Ze(Oz,vt);return x.jsx(aE.Provider,{value:t,children:e})}function Bz(){const e=X.useContext(aE);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const Iz={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},zz=(e,t,n)=>r=>{const{connectionClickStartHandle:a,connectionMode:l,connection:c}=r,{fromHandle:o,toHandle:u,isValid:f}=c;if(!o&&!a)return Iz;const g=(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.id)===t&&(u==null?void 0:u.type)===n;return{connectingFrom:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,connectingTo:g,clickConnecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,isPossibleEndHandle:l===sa.Strict?(o==null?void 0:o.type)!==n:e!==(o==null?void 0:o.nodeId)||t!==(o==null?void 0:o.id),connectionInProcess:!!o,clickConnectionInProcess:!!a,valid:g&&f}};function Hz({type:e="source",position:t=Te.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:a=!0,isConnectableEnd:l=!0,id:c,onConnect:o,children:u,className:f,onMouseDown:g,onTouchStart:d,...m},b){var V,G;const w=c||null,C=e==="target",v=yt(),y=sE(),{connectOnClick:S,noPanClassName:_,rfId:k}=Bz(),{connectingFrom:D,connectingTo:T,clickConnecting:R,isPossibleEndHandle:N,connectionInProcess:L,clickConnectionInProcess:I,valid:z}=Ze(zz(y,w,e),vt);y||(G=(V=v.getState()).onError)==null||G.call(V,"010",qn.error010());const q=W=>{const{defaultEdgeOptions:K,onConnect:j,hasDefaultEdges:M}=v.getState(),O={...K,...W};if(M){const{edges:$,setEdges:F,onError:J}=v.getState();F(mz(O,$,{onError:J}))}j==null||j(O),o==null||o(O)},P=W=>{if(!y)return;const K=LC(W.nativeEvent);if(a&&(K&&W.button===0||!K)){const j=v.getState();sg.onPointerDown(W.nativeEvent,{handleDomNode:W.currentTarget,autoPanOnConnect:j.autoPanOnConnect,connectionMode:j.connectionMode,connectionRadius:j.connectionRadius,domNode:j.domNode,nodeLookup:j.nodeLookup,lib:j.lib,isTarget:C,handleId:w,nodeId:y,flowId:j.rfId,panBy:j.panBy,cancelConnection:j.cancelConnection,onConnectStart:j.onConnectStart,onConnectEnd:(...M)=>{var O,$;return($=(O=v.getState()).onConnectEnd)==null?void 0:$.call(O,...M)},updateConnection:j.updateConnection,onConnect:q,isValidConnection:n||((...M)=>{var O,$;return(($=(O=v.getState()).isValidConnection)==null?void 0:$.call(O,...M))??!0}),getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,autoPanSpeed:j.autoPanSpeed,dragThreshold:j.connectionDragThreshold})}K?g==null||g(W):d==null||d(W)},U=W=>{const{onClickConnectStart:K,onClickConnectEnd:j,connectionClickStartHandle:M,connectionMode:O,isValidConnection:$,lib:F,rfId:J,nodeLookup:re,connection:le}=v.getState();if(!y||!M&&!a)return;if(!M){K==null||K(W.nativeEvent,{nodeId:y,handleId:w,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:y,type:e,id:w}});return}const Z=RC(W.target),H=n||$,{connection:ee,isValid:te}=sg.isValid(W.nativeEvent,{handle:{nodeId:y,id:w,type:e},connectionMode:O,fromNodeId:M.nodeId,fromHandleId:M.id||null,fromType:M.type,isValidConnection:H,flowId:J,doc:Z,lib:F,nodeLookup:re});te&&ee&&q(ee);const de=structuredClone(le);delete de.inProgress,de.toPosition=de.toHandle?de.toHandle.position:null,j==null||j(W,de),v.setState({connectionClickStartHandle:null})};return x.jsx("div",{"data-handleid":w,"data-nodeid":y,"data-handlepos":t,"data-id":`${k}-${y}-${w}-${e}`,className:Lt(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",_,f,{source:!C,target:C,connectable:r,connectablestart:a,connectableend:l,clickconnecting:R,connectingfrom:D,connectingto:T,valid:z,connectionindicator:r&&(!L||N)&&(L||I?l:a)}]),onMouseDown:P,onTouchStart:P,onClick:S?U:void 0,ref:b,...m,children:u})}const ca=X.memo(tE(Hz));function Fz({data:e,isConnectable:t,sourcePosition:n=Te.Bottom}){return x.jsxs(x.Fragment,{children:[e==null?void 0:e.label,x.jsx(ca,{type:"source",position:n,isConnectable:t})]})}function Pz({data:e,isConnectable:t,targetPosition:n=Te.Top,sourcePosition:r=Te.Bottom}){return x.jsxs(x.Fragment,{children:[x.jsx(ca,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,x.jsx(ca,{type:"source",position:r,isConnectable:t})]})}function Uz(){return null}function $z({data:e,isConnectable:t,targetPosition:n=Te.Top}){return x.jsxs(x.Fragment,{children:[x.jsx(ca,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Au={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},dS={input:Fz,default:Pz,output:$z,group:Uz};function Gz(e){var t,n,r,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??((r=e.style)==null?void 0:r.width),height:e.height??((a=e.style)==null?void 0:a.height)}}const qz=e=>{const{width:t,height:n,x:r,y:a}=sl(e.nodeLookup,{filter:l=>!!l.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(${r}px,${a}px)`}};function Vz({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=yt(),{width:a,height:l,transformString:c,userSelectionActive:o}=Ze(qz,vt),u=rE(),f=X.useRef(null);X.useEffect(()=>{var b;n||(b=f.current)==null||b.focus({preventScroll:!0})},[n]);const g=!o&&a!==null&&l!==null;if(iE({nodeRef:f,disabled:!g}),!g)return null;const d=e?b=>{const w=r.getState().nodes.filter(C=>C.selected);e(b,w)}:void 0,m=b=>{Object.prototype.hasOwnProperty.call(Au,b.key)&&(b.preventDefault(),u({direction:Au[b.key],factor:b.shiftKey?4:1}))};return x.jsx("div",{className:Lt(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c},children:x.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:m,style:{width:a,height:l}})})}const pS=typeof window<"u"?window:void 0,Yz=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function oE({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:a,onPaneContextMenu:l,onPaneScroll:c,paneClickDistance:o,deleteKeyCode:u,selectionKeyCode:f,selectionOnDrag:g,selectionMode:d,onSelectionStart:m,onSelectionEnd:b,multiSelectionKeyCode:w,panActivationKeyCode:C,zoomActivationKeyCode:v,elementsSelectable:y,zoomOnScroll:S,zoomOnPinch:_,panOnScroll:k,panOnScrollSpeed:D,panOnScrollMode:T,zoomOnDoubleClick:R,panOnDrag:N,autoPanOnSelection:L,defaultViewport:I,translateExtent:z,minZoom:q,maxZoom:P,preventScrolling:U,onSelectionContextMenu:V,noWheelClassName:G,noPanClassName:W,disableKeyboardA11y:K,onViewportChange:j,isControlledViewport:M}){const{nodesSelectionActive:O,userSelectionActive:$}=Ze(Yz,vt),F=Yo(f,{target:pS}),J=Yo(C,{target:pS}),re=J||N,le=J||k,Z=g&&re!==!0,H=F||$||Z;return Cz({deleteKeyCode:u,multiSelectionKeyCode:w}),x.jsx(Az,{onPaneContextMenu:l,elementsSelectable:y,zoomOnScroll:S,zoomOnPinch:_,panOnScroll:le,panOnScrollSpeed:D,panOnScrollMode:T,zoomOnDoubleClick:R,panOnDrag:!F&&re,defaultViewport:I,translateExtent:z,minZoom:q,maxZoom:P,zoomActivationKeyCode:v,preventScrolling:U,noWheelClassName:G,noPanClassName:W,onViewportChange:j,isControlledViewport:M,paneClickDistance:o,selectionOnDrag:Z,children:x.jsxs(Rz,{onSelectionStart:m,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:a,onPaneContextMenu:l,onPaneScroll:c,panOnDrag:re,autoPanOnSelection:L,isSelecting:!!H,selectionMode:d,selectionKeyPressed:F,paneClickDistance:o,selectionOnDrag:Z,children:[e,O&&x.jsx(Vz,{onSelectionContextMenu:V,noPanClassName:W,disableKeyboardA11y:K})]})})}oE.displayName="FlowRenderer";const Wz=X.memo(oE),Xz=e=>t=>e?wm(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 Kz(e){return Ze(X.useCallback(Xz(e),[e]),vt)}const Zz=e=>e.updateNodeInternals;function Qz(){const e=Ze(Zz),[t]=X.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(a=>{const l=a.target.getAttribute("data-id");r.set(l,{id:l,nodeElement:a.target,force:!0})}),e(r)}));return X.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Jz({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const a=yt(),l=X.useRef(null),c=X.useRef(null),o=X.useRef(e.sourcePosition),u=X.useRef(e.targetPosition),f=X.useRef(t),g=n&&!!e.internals.handleBounds;return X.useEffect(()=>{l.current&&!e.hidden&&(!g||c.current!==l.current)&&(c.current&&(r==null||r.unobserve(c.current)),r==null||r.observe(l.current),c.current=l.current)},[g,e.hidden]),X.useEffect(()=>()=>{c.current&&(r==null||r.unobserve(c.current),c.current=null)},[]),X.useEffect(()=>{if(l.current){const d=f.current!==t,m=o.current!==e.sourcePosition,b=u.current!==e.targetPosition;(d||m||b)&&(f.current=t,o.current=e.sourcePosition,u.current=e.targetPosition,a.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:l.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),l}function eH({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:a,onContextMenu:l,onDoubleClick:c,nodesDraggable:o,elementsSelectable:u,nodesConnectable:f,nodesFocusable:g,resizeObserver:d,noDragClassName:m,noPanClassName:b,disableKeyboardA11y:w,rfId:C,nodeTypes:v,nodeClickDistance:y,onError:S}){const{node:_,internals:k,isParent:D}=Ze(H=>{const ee=H.nodeLookup.get(e),te=H.parentLookup.has(e);return{node:ee,internals:ee.internals,isParent:te}},vt);let T=_.type||"default",R=(v==null?void 0:v[T])||dS[T];R===void 0&&(S==null||S("003",qn.error003(T)),T="default",R=(v==null?void 0:v.default)||dS.default);const N=!!(_.draggable||o&&typeof _.draggable>"u"),L=!!(_.selectable||u&&typeof _.selectable>"u"),I=!!(_.connectable||f&&typeof _.connectable>"u"),z=!!(_.focusable||g&&typeof _.focusable>"u"),q=yt(),P=NC(_),U=Jz({node:_,nodeType:T,hasDimensions:P,resizeObserver:d}),V=iE({nodeRef:U,disabled:_.hidden||!N,noDragClassName:m,handleSelector:_.dragHandle,nodeId:e,isSelectable:L,nodeClickDistance:y}),G=rE();if(_.hidden)return null;const W=Oi(_),K=Gz(_),j=L||N||t||n||r||a,M=n?H=>n(H,{...k.userNode}):void 0,O=r?H=>r(H,{...k.userNode}):void 0,$=a?H=>a(H,{...k.userNode}):void 0,F=l?H=>l(H,{...k.userNode}):void 0,J=c?H=>c(H,{...k.userNode}):void 0,re=H=>{const{selectNodesOnDrag:ee,nodeDragThreshold:te}=q.getState();L&&(!ee||!N||te>0)&&ag({id:e,store:q,nodeRef:U}),t&&t(H,{...k.userNode})},le=H=>{if(!(MC(H.nativeEvent)||w)){if(yC.includes(H.key)&&L){const ee=H.key==="Escape";ag({id:e,store:q,unselect:ee,nodeRef:U})}else if(N&&_.selected&&Object.prototype.hasOwnProperty.call(Au,H.key)){H.preventDefault();const{ariaLabelConfig:ee}=q.getState();q.setState({ariaLiveMessage:ee["node.a11yDescription.ariaLiveMessage"]({direction:H.key.replace("Arrow","").toLowerCase(),x:~~k.positionAbsolute.x,y:~~k.positionAbsolute.y})}),G({direction:Au[H.key],factor:H.shiftKey?4:1})}}},Z=()=>{var oe;if(w||!((oe=U.current)!=null&&oe.matches(":focus-visible")))return;const{transform:H,width:ee,height:te,autoPanOnNodeFocus:de,setCenter:he}=q.getState();if(!de)return;wm(new Map([[e,_]]),{x:0,y:0,width:ee,height:te},H,!0).length>0||he(_.position.x+W.width/2,_.position.y+W.height/2,{zoom:H[2]})};return x.jsx("div",{className:Lt(["react-flow__node",`react-flow__node-${T}`,{[b]:N},_.className,{selected:_.selected,selectable:L,parent:D,draggable:N,dragging:V}]),ref:U,style:{zIndex:k.z,transform:`translate(${k.positionAbsolute.x}px,${k.positionAbsolute.y}px)`,pointerEvents:j?"all":"none",visibility:P?"visible":"hidden",..._.style,...K},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:M,onMouseMove:O,onMouseLeave:$,onContextMenu:F,onClick:re,onDoubleClick:J,onKeyDown:z?le:void 0,tabIndex:z?0:void 0,onFocus:z?Z:void 0,role:_.ariaRole??(z?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${ZC}-${C}`,"aria-label":_.ariaLabel,..._.domAttributes,children:x.jsx(Lz,{value:e,children:x.jsx(R,{id:e,data:_.data,type:T,positionAbsoluteX:k.positionAbsolute.x,positionAbsoluteY:k.positionAbsolute.y,selected:_.selected??!1,selectable:L,draggable:N,deletable:_.deletable??!0,isConnectable:I,sourcePosition:_.sourcePosition,targetPosition:_.targetPosition,dragging:V,dragHandle:_.dragHandle,zIndex:k.z,parentId:_.parentId,...W})})})}var tH=X.memo(eH);const nH=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function lE(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:a,onError:l}=Ze(nH,vt),c=Kz(e.onlyRenderVisibleElements),o=Qz();return x.jsx("div",{className:"react-flow__nodes",style:dh,children:c.map(u=>x.jsx(tH,{id:u,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:o,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:a,nodeClickDistance:e.nodeClickDistance,onError:l},u))})}lE.displayName="NodeRenderer";const iH=X.memo(lE);function rH(e){return Ze(X.useCallback(n=>{if(!e)return n.edges.map(a=>a.id);const r=[];if(n.width&&n.height)for(const a of n.edges){const l=n.nodeLookup.get(a.source),c=n.nodeLookup.get(a.target);l&&c&&K7({sourceNode:l,targetNode:c,width:n.width,height:n.height,transform:n.transform})&&r.push(a.id)}return r},[e]),vt)}const sH=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return x.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},aH=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return x.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},gS={[Cu.Arrow]:sH,[Cu.ArrowClosed]:aH};function oH(e){const t=yt();return X.useMemo(()=>{var a,l;return Object.prototype.hasOwnProperty.call(gS,e)?gS[e]:((l=(a=t.getState()).onError)==null||l.call(a,"009",qn.error009(e)),null)},[e])}const lH=({id:e,type:t,color:n,width:r=12.5,height:a=12.5,markerUnits:l="strokeWidth",strokeWidth:c,orient:o="auto-start-reverse"})=>{const u=oH(t);return u?x.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:o,refX:"0",refY:"0",children:x.jsx(u,{color:n,strokeWidth:c})}):null},cE=({defaultColor:e,rfId:t})=>{const n=Ze(l=>l.edges),r=Ze(l=>l.defaultEdgeOptions),a=X.useMemo(()=>r9(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return a.length?x.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:x.jsx("defs",{children:a.map(l=>x.jsx(lH,{id:l.id,type:l.type,color:l.color,width:l.width,height:l.height,markerUnits:l.markerUnits,strokeWidth:l.strokeWidth,orient:l.orient},l.id))})}):null};cE.displayName="MarkerDefinitions";var cH=X.memo(cE);function uE({x:e,y:t,label:n,labelStyle:r,labelShowBg:a=!0,labelBgStyle:l,labelBgPadding:c=[2,4],labelBgBorderRadius:o=2,children:u,className:f,...g}){const[d,m]=X.useState({x:1,y:0,width:0,height:0}),b=Lt(["react-flow__edge-textwrapper",f]),w=X.useRef(null);return X.useEffect(()=>{if(w.current){const C=w.current.getBBox();m({x:C.x,y:C.y,width:C.width,height:C.height})}},[n]),n?x.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:b,visibility:d.width?"visible":"hidden",...g,children:[a&&x.jsx("rect",{width:d.width+2*c[0],x:-c[0],y:-c[1],height:d.height+2*c[1],className:"react-flow__edge-textbg",style:l,rx:o,ry:o}),x.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:w,style:r,children:n}),u]}):null}uE.displayName="EdgeText";const uH=X.memo(uE);function ph({path:e,labelX:t,labelY:n,label:r,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:o,labelBgBorderRadius:u,interactionWidth:f=20,...g}){return x.jsxs(x.Fragment,{children:[x.jsx("path",{...g,d:e,fill:"none",className:Lt(["react-flow__edge-path",g.className])}),f?x.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,r&&Un(t)&&Un(n)?x.jsx(uH,{x:t,y:n,label:r,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:o,labelBgBorderRadius:u}):null]})}function mS({pos:e,x1:t,y1:n,x2:r,y2:a}){return e===Te.Left||e===Te.Right?[.5*(t+r),n]:[t,.5*(n+a)]}function hE({sourceX:e,sourceY:t,sourcePosition:n=Te.Bottom,targetX:r,targetY:a,targetPosition:l=Te.Top}){const[c,o]=mS({pos:n,x1:e,y1:t,x2:r,y2:a}),[u,f]=mS({pos:l,x1:r,y1:a,x2:e,y2:t}),[g,d,m,b]=OC({sourceX:e,sourceY:t,targetX:r,targetY:a,sourceControlX:c,sourceControlY:o,targetControlX:u,targetControlY:f});return[`M${e},${t} C${c},${o} ${u},${f} ${r},${a}`,g,d,m,b]}function fE(e){return X.memo(({id:t,sourceX:n,sourceY:r,targetX:a,targetY:l,sourcePosition:c,targetPosition:o,label:u,labelStyle:f,labelShowBg:g,labelBgStyle:d,labelBgPadding:m,labelBgBorderRadius:b,style:w,markerEnd:C,markerStart:v,interactionWidth:y})=>{const[S,_,k]=hE({sourceX:n,sourceY:r,sourcePosition:c,targetX:a,targetY:l,targetPosition:o}),D=e.isInternal?void 0:t;return x.jsx(ph,{id:D,path:S,labelX:_,labelY:k,label:u,labelStyle:f,labelShowBg:g,labelBgStyle:d,labelBgPadding:m,labelBgBorderRadius:b,style:w,markerEnd:C,markerStart:v,interactionWidth:y})})}const hH=fE({isInternal:!1}),dE=fE({isInternal:!0});hH.displayName="SimpleBezierEdge";dE.displayName="SimpleBezierEdgeInternal";function pE(e){return X.memo(({id:t,sourceX:n,sourceY:r,targetX:a,targetY:l,label:c,labelStyle:o,labelShowBg:u,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:d,style:m,sourcePosition:b=Te.Bottom,targetPosition:w=Te.Top,markerEnd:C,markerStart:v,pathOptions:y,interactionWidth:S})=>{const[_,k,D]=ng({sourceX:n,sourceY:r,sourcePosition:b,targetX:a,targetY:l,targetPosition:w,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset,stepPosition:y==null?void 0:y.stepPosition}),T=e.isInternal?void 0:t;return x.jsx(ph,{id:T,path:_,labelX:k,labelY:D,label:c,labelStyle:o,labelShowBg:u,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:d,style:m,markerEnd:C,markerStart:v,interactionWidth:S})})}const gE=pE({isInternal:!1}),mE=pE({isInternal:!0});gE.displayName="SmoothStepEdge";mE.displayName="SmoothStepEdgeInternal";function _E(e){return X.memo(({id:t,...n})=>{var a;const r=e.isInternal?void 0:t;return x.jsx(gE,{...n,id:r,pathOptions:X.useMemo(()=>{var l;return{borderRadius:0,offset:(l=n.pathOptions)==null?void 0:l.offset}},[(a=n.pathOptions)==null?void 0:a.offset])})})}const fH=_E({isInternal:!1}),vE=_E({isInternal:!0});fH.displayName="StepEdge";vE.displayName="StepEdgeInternal";function yE(e){return X.memo(({id:t,sourceX:n,sourceY:r,targetX:a,targetY:l,label:c,labelStyle:o,labelShowBg:u,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:d,style:m,markerEnd:b,markerStart:w,interactionWidth:C})=>{const[v,y,S]=IC({sourceX:n,sourceY:r,targetX:a,targetY:l}),_=e.isInternal?void 0:t;return x.jsx(ph,{id:_,path:v,labelX:y,labelY:S,label:c,labelStyle:o,labelShowBg:u,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:d,style:m,markerEnd:b,markerStart:w,interactionWidth:C})})}const dH=yE({isInternal:!1}),bE=yE({isInternal:!0});dH.displayName="StraightEdge";bE.displayName="StraightEdgeInternal";function SE(e){return X.memo(({id:t,sourceX:n,sourceY:r,targetX:a,targetY:l,sourcePosition:c=Te.Bottom,targetPosition:o=Te.Top,label:u,labelStyle:f,labelShowBg:g,labelBgStyle:d,labelBgPadding:m,labelBgBorderRadius:b,style:w,markerEnd:C,markerStart:v,pathOptions:y,interactionWidth:S})=>{const[_,k,D]=jC({sourceX:n,sourceY:r,sourcePosition:c,targetX:a,targetY:l,targetPosition:o,curvature:y==null?void 0:y.curvature}),T=e.isInternal?void 0:t;return x.jsx(ph,{id:T,path:_,labelX:k,labelY:D,label:u,labelStyle:f,labelShowBg:g,labelBgStyle:d,labelBgPadding:m,labelBgBorderRadius:b,style:w,markerEnd:C,markerStart:v,interactionWidth:S})})}const pH=SE({isInternal:!1}),xE=SE({isInternal:!0});pH.displayName="BezierEdge";xE.displayName="BezierEdgeInternal";const _S={default:xE,straight:bE,step:vE,smoothstep:mE,simplebezier:dE},vS={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},gH=(e,t,n)=>n===Te.Left?e-t:n===Te.Right?e+t:e,mH=(e,t,n)=>n===Te.Top?e-t:n===Te.Bottom?e+t:e,yS="react-flow__edgeupdater";function bS({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:a,onMouseEnter:l,onMouseOut:c,type:o}){return x.jsx("circle",{onMouseDown:a,onMouseEnter:l,onMouseOut:c,className:Lt([yS,`${yS}-${o}`]),cx:gH(t,r,e),cy:mH(n,r,e),r,stroke:"transparent",fill:"transparent"})}function _H({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:a,targetX:l,targetY:c,sourcePosition:o,targetPosition:u,onReconnect:f,onReconnectStart:g,onReconnectEnd:d,setReconnecting:m,setUpdateHover:b}){const w=yt(),C=(k,D)=>{if(k.button!==0)return;const{autoPanOnConnect:T,domNode:R,connectionMode:N,connectionRadius:L,lib:I,onConnectStart:z,cancelConnection:q,nodeLookup:P,rfId:U,panBy:V,updateConnection:G}=w.getState(),W=D.type==="target",K=(O,$)=>{m(!1),d==null||d(O,n,D.type,$)},j=O=>f==null?void 0:f(n,O),M=(O,$)=>{m(!0),g==null||g(k,n,D.type),z==null||z(O,$)};sg.onPointerDown(k.nativeEvent,{autoPanOnConnect:T,connectionMode:N,connectionRadius:L,domNode:R,handleId:D.id,nodeId:D.nodeId,nodeLookup:P,isTarget:W,edgeUpdaterType:D.type,lib:I,flowId:U,cancelConnection:q,panBy:V,isValidConnection:(...O)=>{var $,F;return((F=($=w.getState()).isValidConnection)==null?void 0:F.call($,...O))??!0},onConnect:j,onConnectStart:M,onConnectEnd:(...O)=>{var $,F;return(F=($=w.getState()).onConnectEnd)==null?void 0:F.call($,...O)},onReconnectEnd:K,updateConnection:G,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:k.currentTarget})},v=k=>C(k,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=k=>C(k,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),S=()=>b(!0),_=()=>b(!1);return x.jsxs(x.Fragment,{children:[(e===!0||e==="source")&&x.jsx(bS,{position:o,centerX:r,centerY:a,radius:t,onMouseDown:v,onMouseEnter:S,onMouseOut:_,type:"source"}),(e===!0||e==="target")&&x.jsx(bS,{position:u,centerX:l,centerY:c,radius:t,onMouseDown:y,onMouseEnter:S,onMouseOut:_,type:"target"})]})}function vH({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:a,onDoubleClick:l,onContextMenu:c,onMouseEnter:o,onMouseMove:u,onMouseLeave:f,reconnectRadius:g,onReconnect:d,onReconnectStart:m,onReconnectEnd:b,rfId:w,edgeTypes:C,noPanClassName:v,onError:y,disableKeyboardA11y:S}){let _=Ze(he=>he.edgeLookup.get(e));const k=Ze(he=>he.defaultEdgeOptions);_=k?{...k,..._}:_;let D=_.type||"default",T=(C==null?void 0:C[D])||_S[D];T===void 0&&(y==null||y("011",qn.error011(D)),D="default",T=(C==null?void 0:C.default)||_S.default);const R=!!(_.focusable||t&&typeof _.focusable>"u"),N=typeof d<"u"&&(_.reconnectable||n&&typeof _.reconnectable>"u"),L=!!(_.selectable||r&&typeof _.selectable>"u"),I=X.useRef(null),[z,q]=X.useState(!1),[P,U]=X.useState(!1),V=yt(),{zIndex:G=_.zIndex,sourceX:W,sourceY:K,targetX:j,targetY:M,sourcePosition:O,targetPosition:$}=Ze(X.useCallback(he=>{const ye=he.nodeLookup.get(_.source),oe=he.nodeLookup.get(_.target);if(!ye||!oe)return vS;const ve=i9({id:e,sourceNode:ye,targetNode:oe,sourceHandle:_.sourceHandle||null,targetHandle:_.targetHandle||null,connectionMode:he.connectionMode,onError:y}),we=X7({selected:_.selected,zIndex:_.zIndex,sourceNode:ye,targetNode:oe,elevateOnSelect:he.elevateEdgesOnSelect,zIndexMode:he.zIndexMode});return{...ve||vS,zIndex:we}},[_.source,_.target,_.sourceHandle,_.targetHandle,_.selected,_.zIndex]),vt),F=X.useMemo(()=>_.markerStart?`url('#${ig(_.markerStart,w)}')`:void 0,[_.markerStart,w]),J=X.useMemo(()=>_.markerEnd?`url('#${ig(_.markerEnd,w)}')`:void 0,[_.markerEnd,w]);if(_.hidden||W===null||K===null||j===null||M===null)return null;const re=he=>{var we;const{addSelectedEdges:ye,unselectNodesAndEdges:oe,multiSelectionActive:ve}=V.getState();L&&(V.setState({nodesSelectionActive:!1}),_.selected&&ve?(oe({nodes:[],edges:[_]}),(we=I.current)==null||we.blur()):ye([e])),a&&a(he,_)},le=l?he=>{l(he,{..._})}:void 0,Z=c?he=>{c(he,{..._})}:void 0,H=o?he=>{o(he,{..._})}:void 0,ee=u?he=>{u(he,{..._})}:void 0,te=f?he=>{f(he,{..._})}:void 0,de=he=>{var ye;if(!S&&yC.includes(he.key)&&L){const{unselectNodesAndEdges:oe,addSelectedEdges:ve}=V.getState();he.key==="Escape"?((ye=I.current)==null||ye.blur(),oe({edges:[_]})):ve([e])}};return x.jsx("svg",{style:{zIndex:G},children:x.jsxs("g",{className:Lt(["react-flow__edge",`react-flow__edge-${D}`,_.className,v,{selected:_.selected,animated:_.animated,inactive:!L&&!a,updating:z,selectable:L}]),onClick:re,onDoubleClick:le,onContextMenu:Z,onMouseEnter:H,onMouseMove:ee,onMouseLeave:te,onKeyDown:R?de:void 0,tabIndex:R?0:void 0,role:_.ariaRole??(R?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":_.ariaLabel===null?void 0:_.ariaLabel||`Edge from ${_.source} to ${_.target}`,"aria-describedby":R?`${QC}-${w}`:void 0,ref:I,..._.domAttributes,children:[!P&&x.jsx(T,{id:e,source:_.source,target:_.target,type:_.type,selected:_.selected,animated:_.animated,selectable:L,deletable:_.deletable??!0,label:_.label,labelStyle:_.labelStyle,labelShowBg:_.labelShowBg,labelBgStyle:_.labelBgStyle,labelBgPadding:_.labelBgPadding,labelBgBorderRadius:_.labelBgBorderRadius,sourceX:W,sourceY:K,targetX:j,targetY:M,sourcePosition:O,targetPosition:$,data:_.data,style:_.style,sourceHandleId:_.sourceHandle,targetHandleId:_.targetHandle,markerStart:F,markerEnd:J,pathOptions:"pathOptions"in _?_.pathOptions:void 0,interactionWidth:_.interactionWidth}),N&&x.jsx(_H,{edge:_,isReconnectable:N,reconnectRadius:g,onReconnect:d,onReconnectStart:m,onReconnectEnd:b,sourceX:W,sourceY:K,targetX:j,targetY:M,sourcePosition:O,targetPosition:$,setUpdateHover:q,setReconnecting:U})]})})}var yH=X.memo(vH);const bH=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function wE({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:a,onReconnect:l,onEdgeContextMenu:c,onEdgeMouseEnter:o,onEdgeMouseMove:u,onEdgeMouseLeave:f,onEdgeClick:g,reconnectRadius:d,onEdgeDoubleClick:m,onReconnectStart:b,onReconnectEnd:w,disableKeyboardA11y:C}){const{edgesFocusable:v,edgesReconnectable:y,elementsSelectable:S,onError:_}=Ze(bH,vt),k=rH(t);return x.jsxs("div",{className:"react-flow__edges",children:[x.jsx(cH,{defaultColor:e,rfId:n}),k.map(D=>x.jsx(yH,{id:D,edgesFocusable:v,edgesReconnectable:y,elementsSelectable:S,noPanClassName:a,onReconnect:l,onContextMenu:c,onMouseEnter:o,onMouseMove:u,onMouseLeave:f,onClick:g,reconnectRadius:d,onDoubleClick:m,onReconnectStart:b,onReconnectEnd:w,rfId:n,onError:_,edgeTypes:r,disableKeyboardA11y:C},D))]})}wE.displayName="EdgeRenderer";const SH=X.memo(wE),xH=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function wH({children:e}){const t=Ze(xH);return x.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function CH(e){const t=Mm(),n=X.useRef(!1);X.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const EH=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function kH(e){const t=Ze(EH),n=yt();return X.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function AH(e){return e.connection.inProgress?{...e.connection,to:ol(e.connection.to,e.transform)}:{...e.connection}}function TH(e){return AH}function NH(e){const t=TH();return Ze(t,vt)}const DH=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function RH({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:a,width:l,height:c,isValid:o,inProgress:u}=Ze(DH,vt);return!(l&&a&&u)?null:x.jsx("svg",{style:e,width:l,height:c,className:"react-flow__connectionline react-flow__container",children:x.jsx("g",{className:Lt(["react-flow__connection",xC(o)]),children:x.jsx(CE,{style:t,type:n,CustomComponent:r,isValid:o})})})}const CE=({style:e,type:t=dr.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:a,from:l,fromNode:c,fromHandle:o,fromPosition:u,to:f,toNode:g,toHandle:d,toPosition:m,pointer:b}=NH();if(!a)return;if(n)return x.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:c,fromHandle:o,fromX:l.x,fromY:l.y,toX:f.x,toY:f.y,fromPosition:u,toPosition:m,connectionStatus:xC(r),toNode:g,toHandle:d,pointer:b});let w="";const C={sourceX:l.x,sourceY:l.y,sourcePosition:u,targetX:f.x,targetY:f.y,targetPosition:m};switch(t){case dr.Bezier:[w]=jC(C);break;case dr.SimpleBezier:[w]=hE(C);break;case dr.Step:[w]=ng({...C,borderRadius:0});break;case dr.SmoothStep:[w]=ng(C);break;default:[w]=IC(C)}return x.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};CE.displayName="ConnectionLine";const MH={};function SS(e=MH){X.useRef(e),yt(),X.useEffect(()=>{},[e])}function LH(){yt(),X.useRef(!1),X.useEffect(()=>{},[])}function EE({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:a,onNodeDoubleClick:l,onEdgeDoubleClick:c,onNodeMouseEnter:o,onNodeMouseMove:u,onNodeMouseLeave:f,onNodeContextMenu:g,onSelectionContextMenu:d,onSelectionStart:m,onSelectionEnd:b,connectionLineType:w,connectionLineStyle:C,connectionLineComponent:v,connectionLineContainerStyle:y,selectionKeyCode:S,selectionOnDrag:_,selectionMode:k,multiSelectionKeyCode:D,panActivationKeyCode:T,zoomActivationKeyCode:R,deleteKeyCode:N,onlyRenderVisibleElements:L,elementsSelectable:I,defaultViewport:z,translateExtent:q,minZoom:P,maxZoom:U,preventScrolling:V,defaultMarkerColor:G,zoomOnScroll:W,zoomOnPinch:K,panOnScroll:j,panOnScrollSpeed:M,panOnScrollMode:O,zoomOnDoubleClick:$,panOnDrag:F,autoPanOnSelection:J,onPaneClick:re,onPaneMouseEnter:le,onPaneMouseMove:Z,onPaneMouseLeave:H,onPaneScroll:ee,onPaneContextMenu:te,paneClickDistance:de,nodeClickDistance:he,onEdgeContextMenu:ye,onEdgeMouseEnter:oe,onEdgeMouseMove:ve,onEdgeMouseLeave:we,reconnectRadius:Se,onReconnect:$e,onReconnectStart:Ve,onReconnectEnd:it,noDragClassName:dt,noWheelClassName:Ht,noPanClassName:me,disableKeyboardA11y:Ee,nodeExtent:De,rfId:ue,viewport:be,onViewportChange:Ce}){return SS(e),SS(t),LH(),CH(n),kH(be),x.jsx(Wz,{onPaneClick:re,onPaneMouseEnter:le,onPaneMouseMove:Z,onPaneMouseLeave:H,onPaneContextMenu:te,onPaneScroll:ee,paneClickDistance:de,deleteKeyCode:N,selectionKeyCode:S,selectionOnDrag:_,selectionMode:k,onSelectionStart:m,onSelectionEnd:b,multiSelectionKeyCode:D,panActivationKeyCode:T,zoomActivationKeyCode:R,elementsSelectable:I,zoomOnScroll:W,zoomOnPinch:K,zoomOnDoubleClick:$,panOnScroll:j,panOnScrollSpeed:M,panOnScrollMode:O,panOnDrag:F,autoPanOnSelection:J,defaultViewport:z,translateExtent:q,minZoom:P,maxZoom:U,onSelectionContextMenu:d,preventScrolling:V,noDragClassName:dt,noWheelClassName:Ht,noPanClassName:me,disableKeyboardA11y:Ee,onViewportChange:Ce,isControlledViewport:!!be,children:x.jsxs(wH,{children:[x.jsx(SH,{edgeTypes:t,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:$e,onReconnectStart:Ve,onReconnectEnd:it,onlyRenderVisibleElements:L,onEdgeContextMenu:ye,onEdgeMouseEnter:oe,onEdgeMouseMove:ve,onEdgeMouseLeave:we,reconnectRadius:Se,defaultMarkerColor:G,noPanClassName:me,disableKeyboardA11y:Ee,rfId:ue}),x.jsx(RH,{style:C,type:w,component:v,containerStyle:y}),x.jsx("div",{className:"react-flow__edgelabel-renderer"}),x.jsx(iH,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:l,onNodeMouseEnter:o,onNodeMouseMove:u,onNodeMouseLeave:f,onNodeContextMenu:g,nodeClickDistance:he,onlyRenderVisibleElements:L,noPanClassName:me,noDragClassName:dt,disableKeyboardA11y:Ee,nodeExtent:De,rfId:ue}),x.jsx("div",{className:"react-flow__viewport-portal"})]})})}EE.displayName="GraphView";const OH=X.memo(EE),jH=TC(),xS=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:a,height:l,fitView:c,fitViewOptions:o,minZoom:u=.5,maxZoom:f=2,nodeOrigin:g,nodeExtent:d,zIndexMode:m="basic"}={})=>{const b=new Map,w=new Map,C=new Map,v=new Map,y=r??t??[],S=n??e??[],_=g??[0,0],k=d??$o;FC(C,v,y);const{nodesInitialized:D}=rg(S,b,w,{nodeOrigin:_,nodeExtent:k,zIndexMode:m});let T=[0,0,1];if(c&&a&&l){const R=sl(b,{filter:z=>!!((z.width||z.initialWidth)&&(z.height||z.initialHeight))}),{x:N,y:L,zoom:I}=Em(R,a,l,u,f,(o==null?void 0:o.padding)??.1);T=[N,L,I]}return{rfId:"1",width:a??0,height:l??0,transform:T,nodes:S,nodesInitialized:D,nodeLookup:b,parentLookup:w,edges:y,edgeLookup:v,connectionLookup:C,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:u,maxZoom:f,translateExtent:$o,nodeExtent:k,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:sa.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:_,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:c??!1,fitViewOptions:o,fitViewResolver:null,connection:{...SC},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:jH,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:bC,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},BH=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:a,height:l,fitView:c,fitViewOptions:o,minZoom:u,maxZoom:f,nodeOrigin:g,nodeExtent:d,zIndexMode:m})=>V9((b,w)=>{async function C(){const{nodeLookup:v,panZoom:y,fitViewOptions:S,fitViewResolver:_,width:k,height:D,minZoom:T,maxZoom:R}=w();y&&(await U7({nodes:v,width:k,height:D,panZoom:y,minZoom:T,maxZoom:R},S),_==null||_.resolve(!0),b({fitViewResolver:null}))}return{...xS({nodes:e,edges:t,width:a,height:l,fitView:c,fitViewOptions:o,minZoom:u,maxZoom:f,nodeOrigin:g,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:m}),setNodes:v=>{const{nodeLookup:y,parentLookup:S,nodeOrigin:_,elevateNodesOnSelect:k,fitViewQueued:D,zIndexMode:T,nodesSelectionActive:R}=w(),{nodesInitialized:N,hasSelectedNodes:L}=rg(v,y,S,{nodeOrigin:_,nodeExtent:d,elevateNodesOnSelect:k,checkEquality:!0,zIndexMode:T}),I=R&&L;D&&N?(C(),b({nodes:v,nodesInitialized:N,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:I})):b({nodes:v,nodesInitialized:N,nodesSelectionActive:I})},setEdges:v=>{const{connectionLookup:y,edgeLookup:S}=w();FC(y,S,v),b({edges:v})},setDefaultNodesAndEdges:(v,y)=>{if(v){const{setNodes:S}=w();S(v),b({hasDefaultNodes:!0})}if(y){const{setEdges:S}=w();S(y),b({hasDefaultEdges:!0})}},updateNodeInternals:v=>{const{triggerNodeChanges:y,nodeLookup:S,parentLookup:_,domNode:k,nodeOrigin:D,nodeExtent:T,debug:R,fitViewQueued:N,zIndexMode:L}=w(),{changes:I,updatedInternals:z}=h9(v,S,_,k,D,T,L);z&&(o9(S,_,{nodeOrigin:D,nodeExtent:T,zIndexMode:L}),N?(C(),b({fitViewQueued:!1,fitViewOptions:void 0})):b({}),(I==null?void 0:I.length)>0&&(R&&console.log("React Flow: trigger node changes",I),y==null||y(I)))},updateNodePositions:(v,y=!1)=>{const S=[];let _=[];const{nodeLookup:k,triggerNodeChanges:D,connection:T,updateConnection:R,onNodesChangeMiddlewareMap:N}=w();for(const[L,I]of v){const z=k.get(L),q=!!(z!=null&&z.expandParent&&(z!=null&&z.parentId)&&(I!=null&&I.position)),P={id:L,type:"position",position:q?{x:Math.max(0,I.position.x),y:Math.max(0,I.position.y)}:I.position,dragging:y};if(z&&T.inProgress&&T.fromNode.id===z.id){const U=Zr(z,T.fromHandle,Te.Left,!0);R({...T,from:U})}q&&z.parentId&&S.push({id:L,parentId:z.parentId,rect:{...I.internals.positionAbsolute,width:I.measured.width??0,height:I.measured.height??0}}),_.push(P)}if(S.length>0){const{parentLookup:L,nodeOrigin:I}=w(),z=Rm(S,k,L,I);_.push(...z)}for(const L of N.values())_=L(_);D(_)},triggerNodeChanges:v=>{const{onNodesChange:y,setNodes:S,nodes:_,hasDefaultNodes:k,debug:D}=w();if(v!=null&&v.length){if(k){const T=dz(v,_);S(T)}D&&console.log("React Flow: trigger node changes",v),y==null||y(v)}},triggerEdgeChanges:v=>{const{onEdgesChange:y,setEdges:S,edges:_,hasDefaultEdges:k,debug:D}=w();if(v!=null&&v.length){if(k){const T=pz(v,_);S(T)}D&&console.log("React Flow: trigger edge changes",v),y==null||y(v)}},addSelectedNodes:v=>{const{multiSelectionActive:y,edgeLookup:S,nodeLookup:_,triggerNodeChanges:k,triggerEdgeChanges:D}=w();if(y){const T=v.map(R=>Pr(R,!0));k(T);return}k(Qs(_,new Set([...v]),!0)),D(Qs(S))},addSelectedEdges:v=>{const{multiSelectionActive:y,edgeLookup:S,nodeLookup:_,triggerNodeChanges:k,triggerEdgeChanges:D}=w();if(y){const T=v.map(R=>Pr(R,!0));D(T);return}D(Qs(S,new Set([...v]))),k(Qs(_,new Set,!0))},unselectNodesAndEdges:({nodes:v,edges:y}={})=>{const{edges:S,nodes:_,nodeLookup:k,triggerNodeChanges:D,triggerEdgeChanges:T}=w(),R=v||_,N=y||S,L=[];for(const z of R){if(!z.selected)continue;const q=k.get(z.id);q&&(q.selected=!1),L.push(Pr(z.id,!1))}const I=[];for(const z of N)z.selected&&I.push(Pr(z.id,!1));D(L),T(I)},setMinZoom:v=>{const{panZoom:y,maxZoom:S}=w();y==null||y.setScaleExtent([v,S]),b({minZoom:v})},setMaxZoom:v=>{const{panZoom:y,minZoom:S}=w();y==null||y.setScaleExtent([S,v]),b({maxZoom:v})},setTranslateExtent:v=>{var y;(y=w().panZoom)==null||y.setTranslateExtent(v),b({translateExtent:v})},resetSelectedElements:()=>{const{edges:v,nodes:y,triggerNodeChanges:S,triggerEdgeChanges:_,elementsSelectable:k}=w();if(!k)return;const D=y.reduce((R,N)=>N.selected?[...R,Pr(N.id,!1)]:R,[]),T=v.reduce((R,N)=>N.selected?[...R,Pr(N.id,!1)]:R,[]);S(D),_(T)},setNodeExtent:v=>{const{nodes:y,nodeLookup:S,parentLookup:_,nodeOrigin:k,elevateNodesOnSelect:D,nodeExtent:T,zIndexMode:R}=w();v[0][0]===T[0][0]&&v[0][1]===T[0][1]&&v[1][0]===T[1][0]&&v[1][1]===T[1][1]||(rg(y,S,_,{nodeOrigin:k,nodeExtent:v,elevateNodesOnSelect:D,checkEquality:!1,zIndexMode:R}),b({nodeExtent:v}))},panBy:v=>{const{transform:y,width:S,height:_,panZoom:k,translateExtent:D}=w();return f9({delta:v,panZoom:k,transform:y,translateExtent:D,width:S,height:_})},setCenter:async(v,y,S)=>{const{width:_,height:k,maxZoom:D,panZoom:T}=w();if(!T)return!1;const R=typeof(S==null?void 0:S.zoom)<"u"?S.zoom:D;return await T.setViewport({x:_/2-v*R,y:k/2-y*R,zoom:R},{duration:S==null?void 0:S.duration,ease:S==null?void 0:S.ease,interpolate:S==null?void 0:S.interpolate}),!0},cancelConnection:()=>{b({connection:{...SC}})},updateConnection:v=>{b({connection:v})},reset:()=>b({...xS()})}},Object.is);function IH({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:a,initialHeight:l,initialMinZoom:c,initialMaxZoom:o,initialFitViewOptions:u,fitView:f,nodeOrigin:g,nodeExtent:d,zIndexMode:m,children:b}){const[w]=X.useState(()=>BH({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:a,height:l,fitView:f,minZoom:c,maxZoom:o,fitViewOptions:u,nodeOrigin:g,nodeExtent:d,zIndexMode:m}));return x.jsx(Y9,{value:w,children:x.jsx(bz,{children:x.jsx(jz,{children:b})})})}function zH({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:a,width:l,height:c,fitView:o,fitViewOptions:u,minZoom:f,maxZoom:g,nodeOrigin:d,nodeExtent:m,zIndexMode:b}){return X.useContext(hh)?x.jsx(x.Fragment,{children:e}):x.jsx(IH,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:a,initialWidth:l,initialHeight:c,fitView:o,initialFitViewOptions:u,initialMinZoom:f,initialMaxZoom:g,nodeOrigin:d,nodeExtent:m,zIndexMode:b,children:e})}const HH={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function FH({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:a,nodeTypes:l,edgeTypes:c,onNodeClick:o,onEdgeClick:u,onInit:f,onMove:g,onMoveStart:d,onMoveEnd:m,onConnect:b,onConnectStart:w,onConnectEnd:C,onClickConnectStart:v,onClickConnectEnd:y,onNodeMouseEnter:S,onNodeMouseMove:_,onNodeMouseLeave:k,onNodeContextMenu:D,onNodeDoubleClick:T,onNodeDragStart:R,onNodeDrag:N,onNodeDragStop:L,onNodesDelete:I,onEdgesDelete:z,onDelete:q,onSelectionChange:P,onSelectionDragStart:U,onSelectionDrag:V,onSelectionDragStop:G,onSelectionContextMenu:W,onSelectionStart:K,onSelectionEnd:j,onBeforeDelete:M,connectionMode:O,connectionLineType:$=dr.Bezier,connectionLineStyle:F,connectionLineComponent:J,connectionLineContainerStyle:re,deleteKeyCode:le="Backspace",selectionKeyCode:Z="Shift",selectionOnDrag:H=!1,selectionMode:ee=Go.Full,panActivationKeyCode:te="Space",multiSelectionKeyCode:de=Vo()?"Meta":"Control",zoomActivationKeyCode:he=Vo()?"Meta":"Control",snapToGrid:ye,snapGrid:oe,onlyRenderVisibleElements:ve=!1,selectNodesOnDrag:we,nodesDraggable:Se,autoPanOnNodeFocus:$e,nodesConnectable:Ve,nodesFocusable:it,nodeOrigin:dt=JC,edgesFocusable:Ht,edgesReconnectable:me,elementsSelectable:Ee=!0,defaultViewport:De=az,minZoom:ue=.5,maxZoom:be=2,translateExtent:Ce=$o,preventScrolling:Re=!0,nodeExtent:je,defaultMarkerColor:xt="#b1b1b7",zoomOnScroll:Ye=!0,zoomOnPinch:Ot=!0,panOnScroll:wt=!1,panOnScrollSpeed:Gt=.5,panOnScrollMode:rt=qr.Free,zoomOnDoubleClick:Yn=!0,panOnDrag:un=!0,onPaneClick:gh,onPaneMouseEnter:ts,onPaneMouseMove:ns,onPaneMouseLeave:is,onPaneScroll:ai,onPaneContextMenu:rs,paneClickDistance:vr=1,nodeClickDistance:mh=0,children:ll,onReconnect:ga,onReconnectStart:yr,onReconnectEnd:_h,onEdgeContextMenu:cl,onEdgeDoubleClick:ul,onEdgeMouseEnter:hl,onEdgeMouseMove:ma,onEdgeMouseLeave:_a,reconnectRadius:fl=10,onNodesChange:dl,onEdgesChange:Wn,noDragClassName:jt="nodrag",noWheelClassName:qt="nowheel",noPanClassName:oi="nopan",fitView:ss,fitViewOptions:pl,connectOnClick:vh,attributionPosition:gl,proOptions:br,defaultEdgeOptions:va,elevateNodesOnSelect:ji=!0,elevateEdgesOnSelect:Bi=!1,disableKeyboardA11y:Ii=!1,autoPanOnConnect:zi,autoPanOnNodeDrag:At,autoPanOnSelection:ml=!0,autoPanSpeed:_l,connectionRadius:li,isValidConnection:Hi,onError:yh,style:vl,id:ya,nodeDragThreshold:bh,connectionDragThreshold:as,viewport:os,onViewportChange:Bn,width:Zt,height:yl,colorMode:Sh="light",debug:ba,onScroll:Sr,ariaLabelConfig:ls,zIndexMode:bl="basic",...Qt},Sa){const cs=ya||"1",xa=uz(Sh),Fi=X.useCallback(wa=>{wa.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Sr==null||Sr(wa)},[Sr]);return x.jsx("div",{"data-testid":"rf__wrapper",...Qt,onScroll:Fi,style:{...vl,...HH},ref:Sa,className:Lt(["react-flow",a,xa]),id:ya,role:"application",children:x.jsxs(zH,{nodes:e,edges:t,width:Zt,height:yl,fitView:ss,fitViewOptions:pl,minZoom:ue,maxZoom:be,nodeOrigin:dt,nodeExtent:je,zIndexMode:bl,children:[x.jsx(cz,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:b,onConnectStart:w,onConnectEnd:C,onClickConnectStart:v,onClickConnectEnd:y,nodesDraggable:Se,autoPanOnNodeFocus:$e,nodesConnectable:Ve,nodesFocusable:it,edgesFocusable:Ht,edgesReconnectable:me,elementsSelectable:Ee,elevateNodesOnSelect:ji,elevateEdgesOnSelect:Bi,minZoom:ue,maxZoom:be,nodeExtent:je,onNodesChange:dl,onEdgesChange:Wn,snapToGrid:ye,snapGrid:oe,connectionMode:O,translateExtent:Ce,connectOnClick:vh,defaultEdgeOptions:va,fitView:ss,fitViewOptions:pl,onNodesDelete:I,onEdgesDelete:z,onDelete:q,onNodeDragStart:R,onNodeDrag:N,onNodeDragStop:L,onSelectionDrag:V,onSelectionDragStart:U,onSelectionDragStop:G,onMove:g,onMoveStart:d,onMoveEnd:m,noPanClassName:oi,nodeOrigin:dt,rfId:cs,autoPanOnConnect:zi,autoPanOnNodeDrag:At,autoPanSpeed:_l,onError:yh,connectionRadius:li,isValidConnection:Hi,selectNodesOnDrag:we,nodeDragThreshold:bh,connectionDragThreshold:as,onBeforeDelete:M,debug:ba,ariaLabelConfig:ls,zIndexMode:bl}),x.jsx(OH,{onInit:f,onNodeClick:o,onEdgeClick:u,onNodeMouseEnter:S,onNodeMouseMove:_,onNodeMouseLeave:k,onNodeContextMenu:D,onNodeDoubleClick:T,nodeTypes:l,edgeTypes:c,connectionLineType:$,connectionLineStyle:F,connectionLineComponent:J,connectionLineContainerStyle:re,selectionKeyCode:Z,selectionOnDrag:H,selectionMode:ee,deleteKeyCode:le,multiSelectionKeyCode:de,panActivationKeyCode:te,zoomActivationKeyCode:he,onlyRenderVisibleElements:ve,defaultViewport:De,translateExtent:Ce,minZoom:ue,maxZoom:be,preventScrolling:Re,zoomOnScroll:Ye,zoomOnPinch:Ot,zoomOnDoubleClick:Yn,panOnScroll:wt,panOnScrollSpeed:Gt,panOnScrollMode:rt,panOnDrag:un,autoPanOnSelection:ml,onPaneClick:gh,onPaneMouseEnter:ts,onPaneMouseMove:ns,onPaneMouseLeave:is,onPaneScroll:ai,onPaneContextMenu:rs,paneClickDistance:vr,nodeClickDistance:mh,onSelectionContextMenu:W,onSelectionStart:K,onSelectionEnd:j,onReconnect:ga,onReconnectStart:yr,onReconnectEnd:_h,onEdgeContextMenu:cl,onEdgeDoubleClick:ul,onEdgeMouseEnter:hl,onEdgeMouseMove:ma,onEdgeMouseLeave:_a,reconnectRadius:fl,defaultMarkerColor:xt,noDragClassName:jt,noWheelClassName:qt,noPanClassName:oi,rfId:cs,disableKeyboardA11y:Ii,nodeExtent:je,viewport:os,onViewportChange:Bn}),x.jsx(sz,{onSelectionChange:P}),ll,x.jsx(ez,{proOptions:br,position:gl}),x.jsx(J9,{rfId:cs,disableKeyboardA11y:Ii})]})})}var PH=tE(FH);function UH({dimensions:e,lineWidth:t,variant:n,className:r}){return x.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Lt(["react-flow__background-pattern",n,r])})}function $H({radius:e,className:t}){return x.jsx("circle",{cx:e,cy:e,r:e,className:Lt(["react-flow__background-pattern","dots",t])})}var Ni;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ni||(Ni={}));const GH={[Ni.Dots]:1,[Ni.Lines]:1,[Ni.Cross]:6},qH=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function kE({id:e,variant:t=Ni.Dots,gap:n=20,size:r,lineWidth:a=1,offset:l=0,color:c,bgColor:o,style:u,className:f,patternClassName:g}){const d=X.useRef(null),{transform:m,patternId:b}=Ze(qH,vt),w=r||GH[t],C=t===Ni.Dots,v=t===Ni.Cross,y=Array.isArray(n)?n:[n,n],S=[y[0]*m[2]||1,y[1]*m[2]||1],_=w*m[2],k=Array.isArray(l)?l:[l,l],D=v?[_,_]:S,T=[k[0]*m[2]||1+D[0]/2,k[1]*m[2]||1+D[1]/2],R=`${b}${e||""}`;return x.jsxs("svg",{className:Lt(["react-flow__background",f]),style:{...u,...dh,"--xy-background-color-props":o,"--xy-background-pattern-color-props":c},ref:d,"data-testid":"rf__background",children:[x.jsx("pattern",{id:R,x:m[0]%S[0],y:m[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`,children:C?x.jsx($H,{radius:_/2,className:g}):x.jsx(UH,{dimensions:D,lineWidth:a,variant:t,className:g})}),x.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${R})`})]})}kE.displayName="Background";const VH=X.memo(kE);function YH(){return x.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:x.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function WH(){return x.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:x.jsx("path",{d:"M0 0h32v4.2H0z"})})}function XH(){return x.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:x.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 KH(){return x.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:x.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 ZH(){return x.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:x.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 Wc({children:e,className:t,...n}){return x.jsx("button",{type:"button",className:Lt(["react-flow__controls-button",t]),...n,children:e})}const QH=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function AE({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:a,onZoomIn:l,onZoomOut:c,onFitView:o,onInteractiveChange:u,className:f,children:g,position:d="bottom-left",orientation:m="vertical","aria-label":b}){const w=yt(),{isInteractive:C,minZoomReached:v,maxZoomReached:y,ariaLabelConfig:S}=Ze(QH,vt),{zoomIn:_,zoomOut:k,fitView:D}=Mm(),T=()=>{_(),l==null||l()},R=()=>{k(),c==null||c()},N=()=>{D(a),o==null||o()},L=()=>{w.setState({nodesDraggable:!C,nodesConnectable:!C,elementsSelectable:!C}),u==null||u(!C)},I=m==="horizontal"?"horizontal":"vertical";return x.jsxs(fh,{className:Lt(["react-flow__controls",I,f]),position:d,style:e,"data-testid":"rf__controls","aria-label":b??S["controls.ariaLabel"],children:[t&&x.jsxs(x.Fragment,{children:[x.jsx(Wc,{onClick:T,className:"react-flow__controls-zoomin",title:S["controls.zoomIn.ariaLabel"],"aria-label":S["controls.zoomIn.ariaLabel"],disabled:y,children:x.jsx(YH,{})}),x.jsx(Wc,{onClick:R,className:"react-flow__controls-zoomout",title:S["controls.zoomOut.ariaLabel"],"aria-label":S["controls.zoomOut.ariaLabel"],disabled:v,children:x.jsx(WH,{})})]}),n&&x.jsx(Wc,{className:"react-flow__controls-fitview",onClick:N,title:S["controls.fitView.ariaLabel"],"aria-label":S["controls.fitView.ariaLabel"],children:x.jsx(XH,{})}),r&&x.jsx(Wc,{className:"react-flow__controls-interactive",onClick:L,title:S["controls.interactive.ariaLabel"],"aria-label":S["controls.interactive.ariaLabel"],children:C?x.jsx(ZH,{}):x.jsx(KH,{})}),g]})}AE.displayName="Controls";X.memo(AE);function JH({id:e,x:t,y:n,width:r,height:a,style:l,color:c,strokeColor:o,strokeWidth:u,className:f,borderRadius:g,shapeRendering:d,selected:m,onClick:b}){const{background:w,backgroundColor:C}=l||{},v=c||w||C;return x.jsx("rect",{className:Lt(["react-flow__minimap-node",{selected:m},f]),x:t,y:n,rx:g,ry:g,width:r,height:a,style:{fill:v,stroke:o,strokeWidth:u},shapeRendering:d,onClick:b?y=>b(y,e):void 0})}const eF=X.memo(JH),tF=e=>e.nodes.map(t=>t.id),mp=e=>e instanceof Function?e:()=>e;function nF({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:a,nodeComponent:l=eF,onClick:c}){const o=Ze(tF,vt),u=mp(t),f=mp(e),g=mp(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return x.jsx(x.Fragment,{children:o.map(m=>x.jsx(rF,{id:m,nodeColorFunc:u,nodeStrokeColorFunc:f,nodeClassNameFunc:g,nodeBorderRadius:r,nodeStrokeWidth:a,NodeComponent:l,onClick:c,shapeRendering:d},m))})}function iF({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:a,nodeStrokeWidth:l,shapeRendering:c,NodeComponent:o,onClick:u}){const{node:f,x:g,y:d,width:m,height:b}=Ze(w=>{const C=w.nodeLookup.get(e);if(!C)return{node:void 0,x:0,y:0,width:0,height:0};const v=C.internals.userNode,{x:y,y:S}=C.internals.positionAbsolute,{width:_,height:k}=Oi(v);return{node:v,x:y,y:S,width:_,height:k}},vt);return!f||f.hidden||!NC(f)?null:x.jsx(o,{x:g,y:d,width:m,height:b,style:f.style,selected:!!f.selected,className:r(f),color:t(f),borderRadius:a,strokeColor:n(f),strokeWidth:l,shapeRendering:c,onClick:u,id:f.id})}const rF=X.memo(iF);var sF=X.memo(nF);const aF=200,oF=150,lF=e=>!e.hidden,cF=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?kC(sl(e.nodeLookup,{filter:lF}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},uF="react-flow__minimap-desc";function TE({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:a="",nodeBorderRadius:l=5,nodeStrokeWidth:c,nodeComponent:o,bgColor:u,maskColor:f,maskStrokeColor:g,maskStrokeWidth:d,position:m="bottom-right",onClick:b,onNodeClick:w,pannable:C=!1,zoomable:v=!1,ariaLabel:y,inversePan:S,zoomStep:_=1,offsetScale:k=5}){const D=yt(),T=X.useRef(null),{boundingRect:R,viewBB:N,rfId:L,panZoom:I,translateExtent:z,flowWidth:q,flowHeight:P,ariaLabelConfig:U}=Ze(cF,vt),V=(e==null?void 0:e.width)??aF,G=(e==null?void 0:e.height)??oF,W=R.width/V,K=R.height/G,j=Math.max(W,K),M=j*V,O=j*G,$=k*j,F=R.x-(M-R.width)/2-$,J=R.y-(O-R.height)/2-$,re=M+$*2,le=O+$*2,Z=`${uF}-${L}`,H=X.useRef(0),ee=X.useRef();H.current=j,X.useEffect(()=>{if(T.current&&I)return ee.current=S9({domNode:T.current,panZoom:I,getTransform:()=>D.getState().transform,getViewScale:()=>H.current}),()=>{var ye;(ye=ee.current)==null||ye.destroy()}},[I]),X.useEffect(()=>{var ye;(ye=ee.current)==null||ye.update({translateExtent:z,width:q,height:P,inversePan:S,pannable:C,zoomStep:_,zoomable:v})},[C,v,S,_,z,q,P]);const te=b?ye=>{var we;const[oe,ve]=((we=ee.current)==null?void 0:we.pointer(ye))||[0,0];b(ye,{x:oe,y:ve})}:void 0,de=w?X.useCallback((ye,oe)=>{const ve=D.getState().nodeLookup.get(oe).internals.userNode;w(ye,ve)},[]):void 0,he=y??U["minimap.ariaLabel"];return x.jsx(fh,{position:m,style:{...e,"--xy-minimap-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-color-props":typeof g=="string"?g:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*j:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:Lt(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:x.jsxs("svg",{width:V,height:G,viewBox:`${F} ${J} ${re} ${le}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Z,ref:T,onClick:te,children:[he&&x.jsx("title",{id:Z,children:he}),x.jsx(sF,{onClick:de,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:l,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:o}),x.jsx("path",{className:"react-flow__minimap-mask",d:`M${F-$},${J-$}h${re+$*2}v${le+$*2}h${-re-$*2}z - M${N.x},${N.y}h${N.width}v${N.height}h${-N.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}TE.displayName="MiniMap";X.memo(TE);const hF=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,fF={[la.Line]:"right",[la.Handle]:"bottom-right"};function dF({nodeId:e,position:t,variant:n=la.Handle,className:r,style:a=void 0,children:l,color:c,minWidth:o=10,minHeight:u=10,maxWidth:f=Number.MAX_VALUE,maxHeight:g=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:m,autoScale:b=!0,shouldResize:w,onResizeStart:C,onResize:v,onResizeEnd:y}){const S=sE(),_=typeof e=="string"?e:S,k=yt(),D=X.useRef(null),T=n===la.Handle,R=Ze(X.useCallback(hF(T&&b),[T,b]),vt),N=X.useRef(null),L=t??fF[n];X.useEffect(()=>{if(!(!D.current||!_))return N.current||(N.current=O9({domNode:D.current,nodeId:_,getStoreItems:()=>{const{nodeLookup:z,transform:q,snapGrid:P,snapToGrid:U,nodeOrigin:V,domNode:G}=k.getState();return{nodeLookup:z,transform:q,snapGrid:P,snapToGrid:U,nodeOrigin:V,paneDomNode:G}},onChange:(z,q)=>{const{triggerNodeChanges:P,nodeLookup:U,parentLookup:V,nodeOrigin:G}=k.getState(),W=[],K={x:z.x,y:z.y},j=U.get(_);if(j&&j.expandParent&&j.parentId){const M=j.origin??G,O=z.width??j.measured.width??0,$=z.height??j.measured.height??0,F={id:j.id,parentId:j.parentId,rect:{width:O,height:$,...DC({x:z.x??j.position.x,y:z.y??j.position.y},{width:O,height:$},j.parentId,U,M)}},J=Rm([F],U,V,G);W.push(...J),K.x=z.x?Math.max(M[0]*O,z.x):void 0,K.y=z.y?Math.max(M[1]*$,z.y):void 0}if(K.x!==void 0&&K.y!==void 0){const M={id:_,type:"position",position:{...K}};W.push(M)}if(z.width!==void 0&&z.height!==void 0){const O={id:_,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:z.width,height:z.height}};W.push(O)}for(const M of q){const O={...M,type:"position"};W.push(O)}P(W)},onEnd:({width:z,height:q})=>{const P={id:_,type:"dimensions",resizing:!1,dimensions:{width:z,height:q}};k.getState().triggerNodeChanges([P])}})),N.current.update({controlPosition:L,boundaries:{minWidth:o,minHeight:u,maxWidth:f,maxHeight:g},keepAspectRatio:d,resizeDirection:m,onResizeStart:C,onResize:v,onResizeEnd:y,shouldResize:w}),()=>{var z;(z=N.current)==null||z.destroy()}},[L,o,u,f,g,d,C,v,y,w]);const I=L.split("-");return x.jsx("div",{className:Lt(["react-flow__resize-control","nodrag",...I,n,r]),ref:D,style:{...a,scale:R,...c&&{[T?"backgroundColor":"borderColor"]:c}},children:l})}X.memo(dF);const og=240,pF=132,ou=44,gF=72;function mF(e){const t=new Map(e.map(l=>[l.id,{exp:l,children:[]}])),n=[];for(const l of e){const c=t.get(l.id),o=l.parentExperimentId?t.get(l.parentExperimentId):void 0;o?o.children.push(c):n.push(c)}const r=(l,c)=>l.exp.createdAt-c.exp.createdAt,a=l=>{l.children.sort(r),l.children.forEach(a)};return n.sort(r),n.forEach(a),n}function lu(e){if(e.children.length===0)return og;const t=e.children.reduce((n,r)=>n+lu(r),0)+ou*(e.children.length-1);return Math.max(og,t)}function _F(e){return e==="done"?"pass":e==="failed"?"fail":e==="running"||e==="starting"?"live":"other"}const vF=X.memo(function({data:t}){const{exp:n,latestRun:r,runs:a,isBaseline:l,selected:c,onOpenView:o}=t,u=r==null?void 0:r.status,f=u==="running"||u==="starting",g=l?"BASELINE":f?"RUNNING":"EXPERIMENT",d=a.slice(-8);return x.jsxs("div",{className:`exp-node ${c?"selected":""} ${f?"live":""}`,children:[x.jsx(ca,{type:"target",position:Te.Top}),x.jsxs("div",{className:"node-eyebrow",children:[x.jsx("span",{children:g}),x.jsx(Oo,{status:u??"idle"})]}),x.jsx("div",{className:"node-head",children:x.jsx("span",{className:"node-slug",children:n.slug})}),(n.title||n.description)&&x.jsx("div",{className:"node-title",children:n.title||n.description}),x.jsxs("div",{className:"node-meta",children:[x.jsx("span",{children:"RUNS"}),d.length>0?x.jsx("span",{className:"run-squares",children:d.map(m=>x.jsx("span",{className:`run-sq ${_F(m.status)}`,title:m.status},m.id))}):x.jsx("span",{children:"no runs"}),x.jsx("span",{style:{flex:1}}),r&&x.jsx("span",{children:ua(r.createdAt)})]}),x.jsxs("div",{className:"node-actions",onClick:m=>m.stopPropagation(),children:[x.jsxs("button",{className:"node-action",title:"Open changes",onClick:()=>o(n.id,"changes"),children:[x.jsx(Ru,{size:13}),"Changes"]}),a.length>0&&x.jsxs("button",{className:"node-action",title:"Open terminal",onClick:()=>o(n.id,"terminal"),children:[x.jsx(RS,{size:13}),"Terminal"]})]}),x.jsx(ca,{type:"source",position:Te.Bottom})]})}),yF={exp:vF},bF={type:"default",style:{stroke:"var(--text)",strokeWidth:1.5,opacity:.3}};function SF({experiments:e,runs:t,selectedId:n,onSelect:r,onOpenView:a}){const{nodes:l,edges:c}=X.useMemo(()=>{const o=new Map;for(const b of t){const w=o.get(b.experimentId);w?w.push(b):o.set(b.experimentId,[b])}for(const b of o.values())b.sort((w,C)=>w.createdAt-C.createdAt);const u=[],f=[],g=mF(e);function d(b,w,C){const v=o.get(b.exp.id)??[];if(u.push({id:b.exp.id,type:"exp",position:{x:w-og/2,y:C},data:{exp:b.exp,latestRun:v[v.length-1]??null,runs:v,isBaseline:!b.exp.parentExperimentId,selected:b.exp.id===n,onOpenView:a}}),b.children.length===0)return;const y=b.children.reduce((_,k)=>_+lu(k),0)+ou*(b.children.length-1);let S=w-y/2;for(const _ of b.children){const k=lu(_);f.push({id:`e-${b.exp.id}-${_.exp.id}`,source:b.exp.id,target:_.exp.id}),d(_,S+k/2,C+pF+gF),S+=k+ou}}let m=0;for(const b of g){const w=lu(b);d(b,m+w/2,0),m+=w+ou}return{nodes:u,edges:f}},[e,t,n,a]);return e.length===0?x.jsx("div",{className:"empty-state",children:x.jsx("p",{children:"No experiments yet — ask the agent to branch one from the baseline."})}):x.jsx(PH,{nodes:l,edges:c,nodeTypes:yF,defaultEdgeOptions:bF,nodesDraggable:!1,nodesConnectable:!1,minZoom:.15,fitView:!0,fitViewOptions:{padding:.25,maxZoom:1},onNodeClick:(o,u)=>r(u.id),onPaneClick:()=>r(null),children:x.jsx(VH,{variant:Ni.Dots,color:"var(--dots-strong)",gap:28,size:1.6})})}const Xc=(e,t)=>e.id===t.id&&e.view===t.view,wS="orx:onboarded",NE="orx:panel-width",Tu=360,xF=10,wF=232,CF=380,EF=wF+56,kF=80;function lg(){return Math.max(Tu,window.innerWidth-EF-CF)}function AF(){const e=lg();try{const t=Number(localStorage.getItem(NE));if(Number.isFinite(t)&&t>=Tu)return Math.min(t,e)}catch{}return Math.max(Tu,Math.min(760,e,Math.round(window.innerWidth*.42)))}function Kc(e,t){const n=e.findIndex(a=>a.id===t.id);if(n<0)return[...e,t];const r=e.slice();return r[n]=t,r}function TF(){var ye;const[e,t]=X.useState(null),[n,r]=X.useState(null),[a,l]=X.useState([]),[c,o]=X.useState([]),[u,f]=X.useState(null),[g,d]=X.useState("tree"),[m,b]=X.useState(null),[w,C]=X.useState(null),[v,y]=X.useState("experiments"),[S,_]=X.useState([]),[k,D]=X.useState([]),[T,R]=X.useState(!0),[N,L]=X.useState(!1),[I,z]=X.useState(AF),[q,P]=X.useState(!0),[U,V]=X.useState(!1),[G,W]=X.useState("chat"),[K,j]=X.useState(()=>{try{return localStorage.getItem(wS)==="1"}catch{return!0}}),M=X.useRef(n);M.current=n,X.useEffect(()=>{UA().then(oe=>{t(oe),r(ve=>{var we;return ve??((we=oe[0])==null?void 0:we.id)??null})}).catch(()=>t([]))},[]),X.useEffect(()=>{const oe=()=>z(ve=>Math.min(ve,lg()));return window.addEventListener("resize",oe),()=>window.removeEventListener("resize",oe)},[]),X.useEffect(()=>{n&&(l([]),o([]),f(null),b(null),C(null),_([]),D([]),y("experiments"),qA(n).then(l).catch(()=>{}),VA(n).then(o).catch(()=>{}),Ty(n).then(f).catch(()=>{}))},[n]);const O=X.useCallback(()=>{const oe=M.current;oe&&Ty(oe).then(f).catch(()=>{})},[]);q4({onRun:oe=>{oe.projectId===M.current&&o(ve=>Kc(ve,oe))},onExperiment:oe=>{oe.projectId===M.current&&l(ve=>Kc(ve,oe))},onProject:oe=>{t(ve=>ve?Kc(ve,oe):[oe])},onArtifacts:oe=>{oe===M.current&&O()}});const $=X.useCallback((oe,ve="changes")=>{b(oe);const we={id:oe,view:ve};_(Se=>Se.some($e=>Xc($e,we))?Se:[...Se,we]),y(we),R(!0)},[]),F=X.useCallback(oe=>{const ve=S.findIndex(Se=>Xc(Se,oe));if(ve===-1)return;const we=S.filter((Se,$e)=>$e!==ve);_(we),typeof v=="object"&&"view"in v&&Xc(v,oe)&&y(we[Math.min(ve,we.length-1)]??"experiments")},[S,v]),J=X.useCallback(oe=>{var $e;let ve=oe;const we=($e=e==null?void 0:e.find(Ve=>Ve.id===n))==null?void 0:$e.repoPath;if(we&&ve.startsWith(we))ve=ve.slice(we.length).replace(/^\/+/,"");else if(ve.startsWith("/")){const Ve=ve.match(/\/repos\/[^/]+\/[^/]+\/(.+)$/);Ve&&(ve=Ve[1])}if(!ve)return;const Se={path:ve};D(Ve=>Ve.some(it=>it.path===ve)?Ve:[...Ve,Se]),y(Se),R(!0)},[e,n]),re=X.useCallback(oe=>{const ve=k.findIndex(Se=>Se.path===oe.path);if(ve===-1)return;const we=k.filter((Se,$e)=>$e!==ve);D(we),typeof v=="object"&&"path"in v&&v.path===oe.path&&y(we[Math.min(ve,we.length-1)]??"experiments")},[k,v]),le=oe=>{oe.preventDefault(),oe.currentTarget.setPointerCapture(oe.pointerId);const ve=document.body.style.userSelect;document.body.style.userSelect="none";const we=$e=>{const Ve=Math.round(window.innerWidth-$e.clientX-xF),it=lg();if(Ve>it+kF){L(!0);return}L(!1);const dt=Math.min(Math.max(Ve,Tu),it);z(dt);try{localStorage.setItem(NE,String(dt))}catch{}},Se=()=>{window.removeEventListener("pointermove",we),window.removeEventListener("pointerup",Se),window.removeEventListener("pointercancel",Se),document.body.style.userSelect=ve};window.addEventListener("pointermove",we),window.addEventListener("pointerup",Se),window.addEventListener("pointercancel",Se)},Z=oe=>{t(ve=>ve?Kc(ve,oe):[oe]),r(oe.id),V(!1)},H=oe=>{t(ve=>ve&&ve.filter(we=>we.id!==oe)),n===oe&&r(null)},ee=typeof v=="object"&&"view"in v?v:null,te=typeof v=="object"&&"path"in v?v:null,de=ee?a.find(oe=>oe.id===ee.id)??null:null;if(e===null)return x.jsx("div",{className:"app",children:x.jsx("div",{className:"empty-state",children:x.jsx("span",{className:"spinner"})})});if(e.length===0)return x.jsx("div",{className:"app",children:K?x.jsx(gb,{projects:e,onOpen:r,onCreated:Z,onDeleted:H}):x.jsx(Zj,{onDone:()=>{try{localStorage.setItem(wS,"1")}catch{}j(!0)}})});const he=x.jsx(Kj,{projectName:((ye=e.find(oe=>oe.id===n))==null?void 0:ye.name)??"",onHome:()=>V(!0),onCollapse:()=>P(!1)});return x.jsx("div",{className:"app",children:U?x.jsx(gb,{projects:e,onOpen:oe=>{r(oe),V(!1)},onCreated:Z,onDeleted:H}):x.jsxs("div",{className:"app-body",children:[n&&x.jsx(SL,{projectId:n,railHeader:he,railOpen:q,onShowRail:()=>P(!0),mainView:G,onSelectMainView:W,panelOpen:T,onTogglePanel:()=>{T&&L(!1),R(!T)},onOpenFile:J,children:G==="artifacts"?(()=>{const oe=e.find(ve=>ve.id===n);return oe?x.jsx(P4,{project:oe,artifacts:u,onChanged:O}):null})():G!=="chat"?x.jsx(cL,{tab:G}):null}),G==="chat"&&T&&x.jsxs("aside",{className:`right-pane floating-panel ${N?"max":""}`,style:N?void 0:{width:I},children:[!N&&x.jsx("div",{className:"panel-resizer",onPointerDown:le}),x.jsxs("div",{className:"tabs",children:[x.jsxs("div",{className:"tab-strip",children:[x.jsx("button",{className:`tab ${v==="experiments"?"active":""}`,onClick:()=>y("experiments"),children:"Experiments"}),S.map(oe=>{const ve=a.find(we=>we.id===oe.id);return x.jsx(O1,{active:ee!==null&&Xc(ee,oe),label:ve?ve.title||ve.slug:"…",icon:oe.view==="terminal"?x.jsx(RS,{size:12,style:{flexShrink:0}}):x.jsx(Ru,{size:12,style:{flexShrink:0}}),onSelect:()=>{y(oe),b(oe.id)},onClose:()=>F(oe)},`${oe.id}:${oe.view}`)}),k.map(oe=>x.jsx(O1,{active:te!==null&&te.path===oe.path,label:oe.path.split("/").pop()||oe.path,icon:x.jsx(AS,{size:12,style:{flexShrink:0}}),onSelect:()=>y(oe),onClose:()=>re(oe)},`file:${oe.path}`))]}),x.jsxs("div",{className:"panel-controls",children:[x.jsx("button",{className:"icon-btn",title:N?"Restore panel":"Expand panel","aria-label":N?"Restore panel":"Expand panel",onClick:()=>L(oe=>!oe),children:N?x.jsx(NA,{size:14}):x.jsx(AA,{size:14})}),x.jsx("button",{className:"icon-btn",title:"Close panel","aria-label":"Close panel",onClick:()=>{R(!1),L(!1)},children:x.jsx(No,{size:14})})]})]}),v==="experiments"?x.jsxs("div",{className:"tab-body",children:[x.jsx("div",{className:"pane-toolbar",children:x.jsxs("div",{className:"seg",children:[x.jsx("button",{className:g==="tree"?"active":"",onClick:()=>d("tree"),children:"Tree"}),x.jsx("button",{className:g==="table"?"active":"",onClick:()=>d("table"),children:"Table"})]})}),x.jsx("div",{className:"pane-content",children:g==="tree"?x.jsx(SF,{experiments:a,runs:c,selectedId:m,onSelect:oe=>{C(null),b(oe)},onOpenView:$}):x.jsx(r8,{runs:c,experiments:a,onOpen:oe=>{C(oe.id),$(oe.experimentId,"terminal")},onOpenChanges:oe=>$(oe,"changes"),onCancel:oe=>void MS(oe).catch(()=>{})})})]}):te?x.jsx("div",{className:"tab-body",children:n&&x.jsx(Xj,{projectId:n,path:te.path,onOpenFile:J},te.path)}):x.jsx("div",{className:"tab-body",children:ee&&de&&x.jsx(qj,{experiment:de,view:ee.view,runs:c,selectedRunId:w,onSelectRun:C},`${ee.id}:${ee.view}`)})]})]})})}Gk.createRoot(document.getElementById("root")).render(x.jsx(X.StrictMode,{children:x.jsx(TF,{})})); + M${N.x},${N.y}h${N.width}v${N.height}h${-N.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}TE.displayName="MiniMap";X.memo(TE);const hF=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,fF={[la.Line]:"right",[la.Handle]:"bottom-right"};function dF({nodeId:e,position:t,variant:n=la.Handle,className:r,style:a=void 0,children:l,color:c,minWidth:o=10,minHeight:u=10,maxWidth:f=Number.MAX_VALUE,maxHeight:g=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:m,autoScale:b=!0,shouldResize:w,onResizeStart:C,onResize:v,onResizeEnd:y}){const S=sE(),_=typeof e=="string"?e:S,k=yt(),D=X.useRef(null),T=n===la.Handle,R=Ze(X.useCallback(hF(T&&b),[T,b]),vt),N=X.useRef(null),L=t??fF[n];X.useEffect(()=>{if(!(!D.current||!_))return N.current||(N.current=O9({domNode:D.current,nodeId:_,getStoreItems:()=>{const{nodeLookup:z,transform:q,snapGrid:P,snapToGrid:U,nodeOrigin:V,domNode:G}=k.getState();return{nodeLookup:z,transform:q,snapGrid:P,snapToGrid:U,nodeOrigin:V,paneDomNode:G}},onChange:(z,q)=>{const{triggerNodeChanges:P,nodeLookup:U,parentLookup:V,nodeOrigin:G}=k.getState(),W=[],K={x:z.x,y:z.y},j=U.get(_);if(j&&j.expandParent&&j.parentId){const M=j.origin??G,O=z.width??j.measured.width??0,$=z.height??j.measured.height??0,F={id:j.id,parentId:j.parentId,rect:{width:O,height:$,...DC({x:z.x??j.position.x,y:z.y??j.position.y},{width:O,height:$},j.parentId,U,M)}},J=Rm([F],U,V,G);W.push(...J),K.x=z.x?Math.max(M[0]*O,z.x):void 0,K.y=z.y?Math.max(M[1]*$,z.y):void 0}if(K.x!==void 0&&K.y!==void 0){const M={id:_,type:"position",position:{...K}};W.push(M)}if(z.width!==void 0&&z.height!==void 0){const O={id:_,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:z.width,height:z.height}};W.push(O)}for(const M of q){const O={...M,type:"position"};W.push(O)}P(W)},onEnd:({width:z,height:q})=>{const P={id:_,type:"dimensions",resizing:!1,dimensions:{width:z,height:q}};k.getState().triggerNodeChanges([P])}})),N.current.update({controlPosition:L,boundaries:{minWidth:o,minHeight:u,maxWidth:f,maxHeight:g},keepAspectRatio:d,resizeDirection:m,onResizeStart:C,onResize:v,onResizeEnd:y,shouldResize:w}),()=>{var z;(z=N.current)==null||z.destroy()}},[L,o,u,f,g,d,C,v,y,w]);const I=L.split("-");return x.jsx("div",{className:Lt(["react-flow__resize-control","nodrag",...I,n,r]),ref:D,style:{...a,scale:R,...c&&{[T?"backgroundColor":"borderColor"]:c}},children:l})}X.memo(dF);const og=240,pF=132,ou=44,gF=72;function mF(e){const t=new Map(e.map(l=>[l.id,{exp:l,children:[]}])),n=[];for(const l of e){const c=t.get(l.id),o=l.parentExperimentId?t.get(l.parentExperimentId):void 0;o?o.children.push(c):n.push(c)}const r=(l,c)=>l.exp.createdAt-c.exp.createdAt,a=l=>{l.children.sort(r),l.children.forEach(a)};return n.sort(r),n.forEach(a),n}function lu(e){if(e.children.length===0)return og;const t=e.children.reduce((n,r)=>n+lu(r),0)+ou*(e.children.length-1);return Math.max(og,t)}function _F(e){return e==="done"?"pass":e==="failed"?"fail":e==="running"||e==="starting"?"live":"other"}const vF=X.memo(function({data:t}){const{exp:n,latestRun:r,runs:a,isBaseline:l,selected:c,onOpenView:o}=t,u=r==null?void 0:r.status,f=u==="running"||u==="starting",g=l?"BASELINE":f?"RUNNING":"EXPERIMENT",d=a.slice(-8);return x.jsxs("div",{className:`exp-node ${c?"selected":""} ${f?"live":""}`,children:[x.jsx(ca,{type:"target",position:Te.Top}),x.jsxs("div",{className:"node-eyebrow",children:[x.jsx("span",{children:g}),x.jsx(Oo,{status:u??"idle"})]}),x.jsx("div",{className:"node-head",children:x.jsx("span",{className:"node-slug",children:n.slug})}),(n.title||n.description)&&x.jsx("div",{className:"node-title",children:n.title||n.description}),x.jsxs("div",{className:"node-meta",children:[x.jsx("span",{children:"RUNS"}),d.length>0?x.jsx("span",{className:"run-squares",children:d.map(m=>x.jsx("span",{className:`run-sq ${_F(m.status)}`,title:m.status},m.id))}):x.jsx("span",{children:"no runs"}),x.jsx("span",{style:{flex:1}}),r&&x.jsx("span",{children:ua(r.createdAt)})]}),x.jsxs("div",{className:"node-actions",onClick:m=>m.stopPropagation(),children:[x.jsxs("button",{className:"node-action",title:"Open changes",onClick:()=>o(n.id,"changes"),children:[x.jsx(Ru,{size:13}),"Changes"]}),a.length>0&&x.jsxs("button",{className:"node-action",title:"Open terminal",onClick:()=>o(n.id,"terminal"),children:[x.jsx(RS,{size:13}),"Terminal"]})]}),x.jsx(ca,{type:"source",position:Te.Bottom})]})}),yF={exp:vF},bF={type:"default",style:{stroke:"var(--text)",strokeWidth:1.5,opacity:.3}};function SF({experiments:e,runs:t,selectedId:n,onSelect:r,onOpenView:a}){const{nodes:l,edges:c}=X.useMemo(()=>{const o=new Map;for(const b of t){const w=o.get(b.experimentId);w?w.push(b):o.set(b.experimentId,[b])}for(const b of o.values())b.sort((w,C)=>w.createdAt-C.createdAt);const u=[],f=[],g=mF(e);function d(b,w,C){const v=o.get(b.exp.id)??[];if(u.push({id:b.exp.id,type:"exp",position:{x:w-og/2,y:C},data:{exp:b.exp,latestRun:v[v.length-1]??null,runs:v,isBaseline:!b.exp.parentExperimentId,selected:b.exp.id===n,onOpenView:a}}),b.children.length===0)return;const y=b.children.reduce((_,k)=>_+lu(k),0)+ou*(b.children.length-1);let S=w-y/2;for(const _ of b.children){const k=lu(_);f.push({id:`e-${b.exp.id}-${_.exp.id}`,source:b.exp.id,target:_.exp.id}),d(_,S+k/2,C+pF+gF),S+=k+ou}}let m=0;for(const b of g){const w=lu(b);d(b,m+w/2,0),m+=w+ou}return{nodes:u,edges:f}},[e,t,n,a]);return e.length===0?x.jsx("div",{className:"empty-state",children:x.jsx("p",{children:"No experiments yet — ask the agent in chat to create and run your baseline experiment."})}):x.jsx(PH,{nodes:l,edges:c,nodeTypes:yF,defaultEdgeOptions:bF,nodesDraggable:!1,nodesConnectable:!1,minZoom:.15,fitView:!0,fitViewOptions:{padding:.25,maxZoom:1},onNodeClick:(o,u)=>r(u.id),onPaneClick:()=>r(null),children:x.jsx(VH,{variant:Ni.Dots,color:"var(--dots-strong)",gap:28,size:1.6})})}const Xc=(e,t)=>e.id===t.id&&e.view===t.view,wS="orx:onboarded",NE="orx:panel-width",Tu=360,xF=10,wF=232,CF=380,EF=wF+56,kF=80;function lg(){return Math.max(Tu,window.innerWidth-EF-CF)}function AF(){const e=lg();try{const t=Number(localStorage.getItem(NE));if(Number.isFinite(t)&&t>=Tu)return Math.min(t,e)}catch{}return Math.max(Tu,Math.min(760,e,Math.round(window.innerWidth*.42)))}function Kc(e,t){const n=e.findIndex(a=>a.id===t.id);if(n<0)return[...e,t];const r=e.slice();return r[n]=t,r}function TF(){var ye;const[e,t]=X.useState(null),[n,r]=X.useState(null),[a,l]=X.useState([]),[c,o]=X.useState([]),[u,f]=X.useState(null),[g,d]=X.useState("tree"),[m,b]=X.useState(null),[w,C]=X.useState(null),[v,y]=X.useState("experiments"),[S,_]=X.useState([]),[k,D]=X.useState([]),[T,R]=X.useState(!0),[N,L]=X.useState(!1),[I,z]=X.useState(AF),[q,P]=X.useState(!0),[U,V]=X.useState(!1),[G,W]=X.useState("chat"),[K,j]=X.useState(()=>{try{return localStorage.getItem(wS)==="1"}catch{return!0}}),M=X.useRef(n);M.current=n,X.useEffect(()=>{UA().then(oe=>{t(oe),r(ve=>{var we;return ve??((we=oe[0])==null?void 0:we.id)??null})}).catch(()=>t([]))},[]),X.useEffect(()=>{const oe=()=>z(ve=>Math.min(ve,lg()));return window.addEventListener("resize",oe),()=>window.removeEventListener("resize",oe)},[]),X.useEffect(()=>{n&&(l([]),o([]),f(null),b(null),C(null),_([]),D([]),y("experiments"),qA(n).then(l).catch(()=>{}),VA(n).then(o).catch(()=>{}),Ty(n).then(f).catch(()=>{}))},[n]);const O=X.useCallback(()=>{const oe=M.current;oe&&Ty(oe).then(f).catch(()=>{})},[]);q4({onRun:oe=>{oe.projectId===M.current&&o(ve=>Kc(ve,oe))},onExperiment:oe=>{oe.projectId===M.current&&l(ve=>Kc(ve,oe))},onProject:oe=>{t(ve=>ve?Kc(ve,oe):[oe])},onArtifacts:oe=>{oe===M.current&&O()}});const $=X.useCallback((oe,ve="changes")=>{b(oe);const we={id:oe,view:ve};_(Se=>Se.some($e=>Xc($e,we))?Se:[...Se,we]),y(we),R(!0)},[]),F=X.useCallback(oe=>{const ve=S.findIndex(Se=>Xc(Se,oe));if(ve===-1)return;const we=S.filter((Se,$e)=>$e!==ve);_(we),typeof v=="object"&&"view"in v&&Xc(v,oe)&&y(we[Math.min(ve,we.length-1)]??"experiments")},[S,v]),J=X.useCallback(oe=>{var $e;let ve=oe;const we=($e=e==null?void 0:e.find(Ve=>Ve.id===n))==null?void 0:$e.repoPath;if(we&&ve.startsWith(we))ve=ve.slice(we.length).replace(/^\/+/,"");else if(ve.startsWith("/")){const Ve=ve.match(/\/repos\/[^/]+\/[^/]+\/(.+)$/);Ve&&(ve=Ve[1])}if(!ve)return;const Se={path:ve};D(Ve=>Ve.some(it=>it.path===ve)?Ve:[...Ve,Se]),y(Se),R(!0)},[e,n]),re=X.useCallback(oe=>{const ve=k.findIndex(Se=>Se.path===oe.path);if(ve===-1)return;const we=k.filter((Se,$e)=>$e!==ve);D(we),typeof v=="object"&&"path"in v&&v.path===oe.path&&y(we[Math.min(ve,we.length-1)]??"experiments")},[k,v]),le=oe=>{oe.preventDefault(),oe.currentTarget.setPointerCapture(oe.pointerId);const ve=document.body.style.userSelect;document.body.style.userSelect="none";const we=$e=>{const Ve=Math.round(window.innerWidth-$e.clientX-xF),it=lg();if(Ve>it+kF){L(!0);return}L(!1);const dt=Math.min(Math.max(Ve,Tu),it);z(dt);try{localStorage.setItem(NE,String(dt))}catch{}},Se=()=>{window.removeEventListener("pointermove",we),window.removeEventListener("pointerup",Se),window.removeEventListener("pointercancel",Se),document.body.style.userSelect=ve};window.addEventListener("pointermove",we),window.addEventListener("pointerup",Se),window.addEventListener("pointercancel",Se)},Z=oe=>{t(ve=>ve?Kc(ve,oe):[oe]),r(oe.id),V(!1)},H=oe=>{t(ve=>ve&&ve.filter(we=>we.id!==oe)),n===oe&&r(null)},ee=typeof v=="object"&&"view"in v?v:null,te=typeof v=="object"&&"path"in v?v:null,de=ee?a.find(oe=>oe.id===ee.id)??null:null;if(e===null)return x.jsx("div",{className:"app",children:x.jsx("div",{className:"empty-state",children:x.jsx("span",{className:"spinner"})})});if(e.length===0)return x.jsx("div",{className:"app",children:K?x.jsx(gb,{projects:e,onOpen:r,onCreated:Z,onDeleted:H}):x.jsx(Zj,{onDone:()=>{try{localStorage.setItem(wS,"1")}catch{}j(!0)}})});const he=x.jsx(Kj,{projectName:((ye=e.find(oe=>oe.id===n))==null?void 0:ye.name)??"",onHome:()=>V(!0),onCollapse:()=>P(!1)});return x.jsx("div",{className:"app",children:U?x.jsx(gb,{projects:e,onOpen:oe=>{r(oe),V(!1)},onCreated:Z,onDeleted:H}):x.jsxs("div",{className:"app-body",children:[n&&x.jsx(SL,{projectId:n,railHeader:he,railOpen:q,onShowRail:()=>P(!0),mainView:G,onSelectMainView:W,panelOpen:T,onTogglePanel:()=>{T&&L(!1),R(!T)},onOpenFile:J,children:G==="artifacts"?(()=>{const oe=e.find(ve=>ve.id===n);return oe?x.jsx(P4,{project:oe,artifacts:u,onChanged:O}):null})():G!=="chat"?x.jsx(cL,{tab:G}):null}),G==="chat"&&T&&x.jsxs("aside",{className:`right-pane floating-panel ${N?"max":""}`,style:N?void 0:{width:I},children:[!N&&x.jsx("div",{className:"panel-resizer",onPointerDown:le}),x.jsxs("div",{className:"tabs",children:[x.jsxs("div",{className:"tab-strip",children:[x.jsx("button",{className:`tab ${v==="experiments"?"active":""}`,onClick:()=>y("experiments"),children:"Experiments"}),S.map(oe=>{const ve=a.find(we=>we.id===oe.id);return x.jsx(O1,{active:ee!==null&&Xc(ee,oe),label:ve?ve.title||ve.slug:"…",icon:oe.view==="terminal"?x.jsx(RS,{size:12,style:{flexShrink:0}}):x.jsx(Ru,{size:12,style:{flexShrink:0}}),onSelect:()=>{y(oe),b(oe.id)},onClose:()=>F(oe)},`${oe.id}:${oe.view}`)}),k.map(oe=>x.jsx(O1,{active:te!==null&&te.path===oe.path,label:oe.path.split("/").pop()||oe.path,icon:x.jsx(AS,{size:12,style:{flexShrink:0}}),onSelect:()=>y(oe),onClose:()=>re(oe)},`file:${oe.path}`))]}),x.jsxs("div",{className:"panel-controls",children:[x.jsx("button",{className:"icon-btn",title:N?"Restore panel":"Expand panel","aria-label":N?"Restore panel":"Expand panel",onClick:()=>L(oe=>!oe),children:N?x.jsx(NA,{size:14}):x.jsx(AA,{size:14})}),x.jsx("button",{className:"icon-btn",title:"Close panel","aria-label":"Close panel",onClick:()=>{R(!1),L(!1)},children:x.jsx(No,{size:14})})]})]}),v==="experiments"?x.jsxs("div",{className:"tab-body",children:[x.jsx("div",{className:"pane-toolbar",children:x.jsxs("div",{className:"seg",children:[x.jsx("button",{className:g==="tree"?"active":"",onClick:()=>d("tree"),children:"Tree"}),x.jsx("button",{className:g==="table"?"active":"",onClick:()=>d("table"),children:"Table"})]})}),x.jsx("div",{className:"pane-content",children:g==="tree"?x.jsx(SF,{experiments:a,runs:c,selectedId:m,onSelect:oe=>{C(null),b(oe)},onOpenView:$}):x.jsx(r8,{runs:c,experiments:a,onOpen:oe=>{C(oe.id),$(oe.experimentId,"terminal")},onOpenChanges:oe=>$(oe,"changes"),onCancel:oe=>void MS(oe).catch(()=>{})})})]}):te?x.jsx("div",{className:"tab-body",children:n&&x.jsx(Xj,{projectId:n,path:te.path,onOpenFile:J},te.path)}):x.jsx("div",{className:"tab-body",children:ee&&de&&x.jsx(qj,{experiment:de,view:ee.view,runs:c,selectedRunId:w,onSelectRun:C},`${ee.id}:${ee.view}`)})]})]})})}Gk.createRoot(document.getElementById("root")).render(x.jsx(X.StrictMode,{children:x.jsx(TF,{})})); diff --git a/ui/dist/index.html b/ui/dist/index.html index 37f1d73b..9e6ed921 100644 --- a/ui/dist/index.html +++ b/ui/dist/index.html @@ -8,7 +8,7 @@ html { background: #ffffff; } @media (prefers-color-scheme: dark) { html { background: #0e0c0c; } } </style> - <script type="module" crossorigin src="/assets/index-kEYVZ_Rj.js"></script> + <script type="module" crossorigin src="/assets/index-DTKGATIK.js"></script> <link rel="stylesheet" crossorigin href="/assets/index-BeHHFtbu.css"> </head> <body> diff --git a/ui/src/api.ts b/ui/src/api.ts index 7c9087f7..d36bb4c0 100644 --- a/ui/src/api.ts +++ b/ui/src/api.ts @@ -122,8 +122,12 @@ export const listInstances = () => get<{ instances: Instance[] }>("/api/instances").then((r) => r.instances); export interface NewExperiment { - parentExperimentId: string; - slug: string; + /** Omit on an empty project to create the baseline root; once a root + * exists, an omitted parent attaches the node under the oldest root. */ + parentExperimentId?: string; + /** Force a new baseline root even when the project already has one. */ + baseline?: boolean; + slug?: string; title?: string; description?: string; runCommand?: string; diff --git a/ui/src/components/ChatPanel.tsx b/ui/src/components/ChatPanel.tsx index 3af347a0..1cbc9570 100644 --- a/ui/src/components/ChatPanel.tsx +++ b/ui/src/components/ChatPanel.tsx @@ -870,7 +870,10 @@ export function ChatPanel({ <h2> Open<span>Research</span> </h2> - <p>Ask the agent to explore your codebase, branch experiments, and launch runs.</p> + <p> + Ask the agent to explore your codebase, create and run your baseline experiment, and + branch variants off it. + </p> <EmptyStateAgentHint harnesses={harnesses} selection={selection ?? defaultSelection(harnesses)} diff --git a/ui/src/components/NewProjectForm.tsx b/ui/src/components/NewProjectForm.tsx index 71175b72..d1a71700 100644 --- a/ui/src/components/NewProjectForm.tsx +++ b/ui/src/components/NewProjectForm.tsx @@ -152,7 +152,7 @@ export function NewProjectForm({ /> </label> <label> - Baseline branch + Branch <input value={branch} onChange={(e) => setBranch(e.target.value)} diff --git a/ui/src/components/TreeView.tsx b/ui/src/components/TreeView.tsx index 09cceaba..fefa687f 100644 --- a/ui/src/components/TreeView.tsx +++ b/ui/src/components/TreeView.tsx @@ -205,7 +205,7 @@ export function TreeView({ if (experiments.length === 0) { return ( <div className="empty-state"> - <p>No experiments yet — ask the agent to branch one from the baseline.</p> + <p>No experiments yet — ask the agent in chat to create and run your baseline experiment.</p> </div> ); }