From da3a6cc6f9d2b71fd6c1e17c32aa0fc351c54141 Mon Sep 17 00:00:00 2001 From: evanlowe <62918515+evanlowe@users.noreply.github.com> Date: Thu, 3 Sep 2026 09:52:42 +0800 Subject: [PATCH] fix: update Studio VeADK version and package sources --- frontend/src/automations/templateProject.ts | 22 ++++++- frontend/src/ui/cloudEnvironmentDockerfile.ts | 18 ++++- frontend/tests/automation-artifacts.test.mjs | 13 +++- frontend/tests/cloudEnvironment.test.mjs | 10 +++ .../test_generated_agent_backend_codegen.py | 34 +++++----- ...enerated_agent_backend_codegen_extended.py | 4 +- .../test_generated_agent_component_matrix.py | 4 +- veadk/cli/generated_agent_codegen.py | 30 ++++++--- .../{index-CeLcxSwu.js => index-Cp46ADZF.js} | 65 ++++++++++--------- ...Cv7h6eVb.js => CodeDiffEditor-B-C-CiRH.js} | 2 +- ...qW.js => MarkdownPromptEditor-BrM0rJhH.js} | 2 +- .../{arc-opUgesWg.js => arc-hwlJnZdT.js} | 2 +- ...hannel--4CO-J5d.js => channel-DbmWggSv.js} | 2 +- ...ex.es-DdBVCEJD.js => index.es-N4fbTgEC.js} | 2 +- ...n-B5O-1ikd.js => jspdf.es.min-DdKAD-38.js} | 6 +- ...{linear-BOFUFmS4.js => linear-CK6paJef.js} | 2 +- ...Jv.js => abnfDiagram-N423BO3Z-CCvEE9ia.js} | 2 +- ... architectureDiagram-T3A2C74G-DCaleCkq.js} | 2 +- ...h.js => blockDiagram-VBNYF7ZC-BxPdxAIr.js} | 2 +- ...B9ao.js => c4Diagram-5PPSVZJV-CdAe8Oaa.js} | 2 +- ...DGIWk2d7.js => chunk-2GRJ4B5K-BNyX5d4q.js} | 2 +- ...BtKX7835.js => chunk-2Q5K7J3B-C5REuRiF.js} | 2 +- ...NtiPzhT8.js => chunk-5RXB4S5H-BvHpXtmc.js} | 2 +- ...2cyYV1MQ.js => chunk-5VM5RSS4-B5UYy-kl.js} | 2 +- ...ymTjYlg6.js => chunk-6Q2QTUOP-B12w4_01.js} | 2 +- ...DSIIegha.js => chunk-GF5L2VYU-Bp7X2tQC.js} | 2 +- ...B93TJKMC.js => chunk-JWPE2WC7-BStSfn6-.js} | 2 +- ...Dadbv9HH.js => chunk-KBJHAD2P-Cn28CXEK.js} | 2 +- ...BzaL2KSa.js => chunk-RYQCIY6F-CXKQyLDF.js} | 2 +- ...CTvtSXwE.js => chunk-XXDRQBXY-C2x3qET9.js} | 2 +- .../mermaid/classDiagram-JCYQIIEL-CUtftVKQ.js | 1 + .../mermaid/classDiagram-JCYQIIEL-DCqPJLAD.js | 1 - .../classDiagram-v2-OCEON4UE-CUtftVKQ.js | 1 + .../classDiagram-v2-OCEON4UE-DCqPJLAD.js | 1 - ...f.js => cose-bilkent-JH36ORCC-CztL9Zj1.js} | 2 +- ...iUSTH7.js => cynefin-OW5HDTMX-fJh5F3qh.js} | 2 +- ...js => cynefinDiagram-MW4NZA55-D3SXj5lk.js} | 2 +- ...DhVcVgEo.js => dagre-VZM6K2ZE-8qwdOP_Y.js} | 2 +- ...ea_rpy.js => diagram-7IWD3JNH-Bunw2kcz.js} | 2 +- ...gO5iM8.js => diagram-B4RE2ZJO-D3LuCRfW.js} | 2 +- ...SuPFVo.js => diagram-LBJQPF4R-DiG42pYG.js} | 2 +- ...67OcuE.js => diagram-Q27KOJAE-miHc4jaN.js} | 2 +- ...MqvsYM.js => diagram-UB23O5K3-iLp35_id.js} | 2 +- ...7E.js => ebnfDiagram-BXEA7PRR-VCRpQkBy.js} | 2 +- ...Rg6K.js => erDiagram-JOGREHBK-CMY1HKiB.js} | 2 +- ...p5.js => flowDiagram-UKHOOZJN-Dj_ll1pT.js} | 2 +- ...j.js => ganttDiagram-PKOTCBZU-D9vAe7TI.js} | 2 +- ...s => gitGraphDiagram-DS77QQ5N-CJTzZ95_.js} | 2 +- ...xG.js => infoDiagram-6WML65LV-C8JOQT4w.js} | 2 +- ...s => ishikawaDiagram-WSZJBQD7-CoVScg5T.js} | 2 +- ...js => journeyDiagram-NVQOT4AX-PmZ11Fni.js} | 2 +- ...=> kanban-definition-27J2QSJJ-nxip1m4b.js} | 2 +- ...e-B_GhFya9.js => mermaid.core-u1Q_qVDs.js} | 8 +-- ...> mindmap-definition-FAOFIHXS-_jvWfYDH.js} | 2 +- ...X1s.js => pegDiagram-VL7TDLO6-kgG-QmbM.js} | 2 +- ...ILL.js => pieDiagram-7S7Q4E2Y-F8myL8ZP.js} | 2 +- ...s => quadrantDiagram-CIZ2JOQS-Bk9sujKF.js} | 2 +- ...s => railroadDiagram-AXF67PYL-BxeC-v_y.js} | 2 +- ...> requirementDiagram-LRYGKXZP-BwC4PDx9.js} | 2 +- ....js => sankeyDiagram-W5VNT64P-DNdlgJYt.js} | 2 +- ...s => sequenceDiagram-SI44F4Z6-Cnkh_CJq.js} | 2 +- ...aD.js => sizeCapture-X5ZJPWSS-f5WSyKlD.js} | 2 +- ...h.js => stateDiagram-OKZ733FA-D7NIlwf8.js} | 2 +- .../stateDiagram-v2-UEYNNEHI-Cc_Z2xa9.js | 1 + .../stateDiagram-v2-UEYNNEHI-xzb4V7vP.js | 1 - ...W61E.js => swimlanes-SLNWSIFB-yxTDoLVt.js} | 4 +- .../swimlanesDiagram-ULZ7WXOC-ChK0VwyP.js | 8 --- .../swimlanesDiagram-ULZ7WXOC-DM0SBL6V.js | 8 +++ ... timeline-definition-Z64GVDOM-QtCdxNFM.js} | 2 +- ...Ew.js => vennDiagram-T6HMQDX7-TES5O4R_.js} | 2 +- ...js => wardleyDiagram-T6FBY63Y-DI3xj-mT.js} | 2 +- ...js => xychartDiagram-ELKLHX3M-PqaaE1Vs.js} | 2 +- veadk/webui/index.html | 2 +- 73 files changed, 209 insertions(+), 137 deletions(-) rename veadk/webui/assets/app/{index-CeLcxSwu.js => index-Cp46ADZF.js} (98%) rename veadk/webui/assets/chunks/{CodeDiffEditor-Cv7h6eVb.js => CodeDiffEditor-B-C-CiRH.js} (99%) rename veadk/webui/assets/chunks/{MarkdownPromptEditor-DH3YPDqW.js => MarkdownPromptEditor-BrM0rJhH.js} (99%) rename veadk/webui/assets/chunks/{arc-opUgesWg.js => arc-hwlJnZdT.js} (98%) rename veadk/webui/assets/chunks/{channel--4CO-J5d.js => channel-DbmWggSv.js} (53%) rename veadk/webui/assets/chunks/{index.es-DdBVCEJD.js => index.es-N4fbTgEC.js} (99%) rename veadk/webui/assets/chunks/{jspdf.es.min-B5O-1ikd.js => jspdf.es.min-DdKAD-38.js} (99%) rename veadk/webui/assets/chunks/{linear-BOFUFmS4.js => linear-CK6paJef.js} (98%) rename veadk/webui/assets/visualizations/mermaid/{abnfDiagram-N423BO3Z-DawPhBJv.js => abnfDiagram-N423BO3Z-CCvEE9ia.js} (86%) rename veadk/webui/assets/visualizations/mermaid/{architectureDiagram-T3A2C74G-BFmKgS3N.js => architectureDiagram-T3A2C74G-DCaleCkq.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{blockDiagram-VBNYF7ZC-TO-qGkih.js => blockDiagram-VBNYF7ZC-BxPdxAIr.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{c4Diagram-5PPSVZJV-Cs53B9ao.js => c4Diagram-5PPSVZJV-CdAe8Oaa.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{chunk-2GRJ4B5K-DGIWk2d7.js => chunk-2GRJ4B5K-BNyX5d4q.js} (93%) rename veadk/webui/assets/visualizations/mermaid/{chunk-2Q5K7J3B-BtKX7835.js => chunk-2Q5K7J3B-C5REuRiF.js} (66%) rename veadk/webui/assets/visualizations/mermaid/{chunk-5RXB4S5H-NtiPzhT8.js => chunk-5RXB4S5H-BvHpXtmc.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{chunk-5VM5RSS4-2cyYV1MQ.js => chunk-5VM5RSS4-B5UYy-kl.js} (83%) rename veadk/webui/assets/visualizations/mermaid/{chunk-6Q2QTUOP-ymTjYlg6.js => chunk-6Q2QTUOP-B12w4_01.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{chunk-GF5L2VYU-DSIIegha.js => chunk-GF5L2VYU-Bp7X2tQC.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{chunk-JWPE2WC7-B93TJKMC.js => chunk-JWPE2WC7-BStSfn6-.js} (78%) rename veadk/webui/assets/visualizations/mermaid/{chunk-KBJHAD2P-Dadbv9HH.js => chunk-KBJHAD2P-Cn28CXEK.js} (87%) rename veadk/webui/assets/visualizations/mermaid/{chunk-RYQCIY6F-BzaL2KSa.js => chunk-RYQCIY6F-CXKQyLDF.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{chunk-XXDRQBXY-CTvtSXwE.js => chunk-XXDRQBXY-C2x3qET9.js} (53%) create mode 100644 veadk/webui/assets/visualizations/mermaid/classDiagram-JCYQIIEL-CUtftVKQ.js delete mode 100644 veadk/webui/assets/visualizations/mermaid/classDiagram-JCYQIIEL-DCqPJLAD.js create mode 100644 veadk/webui/assets/visualizations/mermaid/classDiagram-v2-OCEON4UE-CUtftVKQ.js delete mode 100644 veadk/webui/assets/visualizations/mermaid/classDiagram-v2-OCEON4UE-DCqPJLAD.js rename veadk/webui/assets/visualizations/mermaid/{cose-bilkent-JH36ORCC-B81Ssp7f.js => cose-bilkent-JH36ORCC-CztL9Zj1.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{cynefin-OW5HDTMX-BIiUSTH7.js => cynefin-OW5HDTMX-fJh5F3qh.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{cynefinDiagram-MW4NZA55-DRGgUPwI.js => cynefinDiagram-MW4NZA55-D3SXj5lk.js} (98%) rename veadk/webui/assets/visualizations/mermaid/{dagre-VZM6K2ZE-DhVcVgEo.js => dagre-VZM6K2ZE-8qwdOP_Y.js} (97%) rename veadk/webui/assets/visualizations/mermaid/{diagram-7IWD3JNH-Ciea_rpy.js => diagram-7IWD3JNH-Bunw2kcz.js} (96%) rename veadk/webui/assets/visualizations/mermaid/{diagram-B4RE2ZJO-BCgO5iM8.js => diagram-B4RE2ZJO-D3LuCRfW.js} (97%) rename veadk/webui/assets/visualizations/mermaid/{diagram-LBJQPF4R-MhSuPFVo.js => diagram-LBJQPF4R-DiG42pYG.js} (94%) rename veadk/webui/assets/visualizations/mermaid/{diagram-Q27KOJAE-Ct67OcuE.js => diagram-Q27KOJAE-miHc4jaN.js} (98%) rename veadk/webui/assets/visualizations/mermaid/{diagram-UB23O5K3-iSMqvsYM.js => diagram-UB23O5K3-iLp35_id.js} (95%) rename veadk/webui/assets/visualizations/mermaid/{ebnfDiagram-BXEA7PRR-BqhRpo7E.js => ebnfDiagram-BXEA7PRR-VCRpQkBy.js} (87%) rename veadk/webui/assets/visualizations/mermaid/{erDiagram-JOGREHBK-B0tjRg6K.js => erDiagram-JOGREHBK-CMY1HKiB.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{flowDiagram-UKHOOZJN-C_Jx4fp5.js => flowDiagram-UKHOOZJN-Dj_ll1pT.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{ganttDiagram-PKOTCBZU-jp-eXm0j.js => ganttDiagram-PKOTCBZU-D9vAe7TI.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{gitGraphDiagram-DS77QQ5N-hohivKFF.js => gitGraphDiagram-DS77QQ5N-CJTzZ95_.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{infoDiagram-6WML65LV-DRmoLcxG.js => infoDiagram-6WML65LV-C8JOQT4w.js} (69%) rename veadk/webui/assets/visualizations/mermaid/{ishikawaDiagram-WSZJBQD7-Dcd-d-fm.js => ishikawaDiagram-WSZJBQD7-CoVScg5T.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{journeyDiagram-NVQOT4AX-BRwpyxwJ.js => journeyDiagram-NVQOT4AX-PmZ11Fni.js} (98%) rename veadk/webui/assets/visualizations/mermaid/{kanban-definition-27J2QSJJ-BIyo7Ukc.js => kanban-definition-27J2QSJJ-nxip1m4b.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{mermaid.core-B_GhFya9.js => mermaid.core-u1Q_qVDs.js} (98%) rename veadk/webui/assets/visualizations/mermaid/{mindmap-definition-FAOFIHXS-BVv-XJ5P.js => mindmap-definition-FAOFIHXS-_jvWfYDH.js} (98%) rename veadk/webui/assets/visualizations/mermaid/{pegDiagram-VL7TDLO6-DaE-pX1s.js => pegDiagram-VL7TDLO6-kgG-QmbM.js} (87%) rename veadk/webui/assets/visualizations/mermaid/{pieDiagram-7S7Q4E2Y-WuWNWILL.js => pieDiagram-7S7Q4E2Y-F8myL8ZP.js} (96%) rename veadk/webui/assets/visualizations/mermaid/{quadrantDiagram-CIZ2JOQS-Bj9bw8vt.js => quadrantDiagram-CIZ2JOQS-Bk9sujKF.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{railroadDiagram-AXF67PYL-Dtt_tkn5.js => railroadDiagram-AXF67PYL-BxeC-v_y.js} (84%) rename veadk/webui/assets/visualizations/mermaid/{requirementDiagram-LRYGKXZP-CmusRbN5.js => requirementDiagram-LRYGKXZP-BwC4PDx9.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{sankeyDiagram-W5VNT64P-CQIZpTZi.js => sankeyDiagram-W5VNT64P-DNdlgJYt.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{sequenceDiagram-SI44F4Z6-CgqSDjmC.js => sequenceDiagram-SI44F4Z6-Cnkh_CJq.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{sizeCapture-X5ZJPWSS-NQodEuaD.js => sizeCapture-X5ZJPWSS-f5WSyKlD.js} (87%) rename veadk/webui/assets/visualizations/mermaid/{stateDiagram-OKZ733FA-BJUfo3bh.js => stateDiagram-OKZ733FA-D7NIlwf8.js} (96%) create mode 100644 veadk/webui/assets/visualizations/mermaid/stateDiagram-v2-UEYNNEHI-Cc_Z2xa9.js delete mode 100644 veadk/webui/assets/visualizations/mermaid/stateDiagram-v2-UEYNNEHI-xzb4V7vP.js rename veadk/webui/assets/visualizations/mermaid/{swimlanes-SLNWSIFB-DsnwW61E.js => swimlanes-SLNWSIFB-yxTDoLVt.js} (99%) delete mode 100644 veadk/webui/assets/visualizations/mermaid/swimlanesDiagram-ULZ7WXOC-ChK0VwyP.js create mode 100644 veadk/webui/assets/visualizations/mermaid/swimlanesDiagram-ULZ7WXOC-DM0SBL6V.js rename veadk/webui/assets/visualizations/mermaid/{timeline-definition-Z64GVDOM-B9bA-HU7.js => timeline-definition-Z64GVDOM-QtCdxNFM.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{vennDiagram-T6HMQDX7-CRLg76Ew.js => vennDiagram-T6HMQDX7-TES5O4R_.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{wardleyDiagram-T6FBY63Y-rnZWAORD.js => wardleyDiagram-T6FBY63Y-DI3xj-mT.js} (99%) rename veadk/webui/assets/visualizations/mermaid/{xychartDiagram-ELKLHX3M-DXpcCjJ4.js => xychartDiagram-ELKLHX3M-PqaaE1Vs.js} (99%) diff --git a/frontend/src/automations/templateProject.ts b/frontend/src/automations/templateProject.ts index f1a214cbf..20cbef4dc 100644 --- a/frontend/src/automations/templateProject.ts +++ b/frontend/src/automations/templateProject.ts @@ -40,6 +40,24 @@ const AGENTKIT_BASE_IMAGES: Record = { "agentkit-prod-public-ap-southeast-1.cr.bytepluses.com/base/py-simple:python3.12-bookworm-slim-latest", }; +const VEADK_VERSION = "1.1.9"; +const VOLCENGINE_PYPI_INDEXES = [ + "https://repo.huaweicloud.com/repository/pypi/simple", + "https://mirrors.aliyun.com/pypi/simple/", + "https://pypi.org/simple", +] as const; + +function buildPythonDependencyInstall(cloudProvider: CloudProvider): string { + if (cloudProvider !== "volcengine") { + return "RUN uv pip install -r requirements.txt"; + } + + const attempts = VOLCENGINE_PYPI_INDEXES.map( + (index) => `uv pip install --index-url ${index} -r requirements.txt`, + ); + return `RUN ${attempts.join(" || \\\n ")}`; +} + function buildEnvExample(cloudProvider: CloudProvider): string { const secrets = cloudCredentialSecretNames(cloudProvider); const providerName = cloudProviderDisplayName(cloudProvider); @@ -115,7 +133,7 @@ root_agent = Agent( tools=[get_city_weather], ) `, - "requirements.txt": `veadk-python==1.1.6 + "requirements.txt": `veadk-python==${VEADK_VERSION} agentkit-sdk-python==0.8.4 google-adk==2.1.0 lark-channel-sdk==1.2.0 @@ -128,7 +146,7 @@ ENV UV_SYSTEM_PYTHON=1 UV_COMPILE_BYTECODE=1 PYTHONUNBUFFERED=1 WORKDIR /app COPY requirements.txt ./ -RUN uv pip install -r requirements.txt +${buildPythonDependencyInstall(cloudProvider)} COPY . . diff --git a/frontend/src/ui/cloudEnvironmentDockerfile.ts b/frontend/src/ui/cloudEnvironmentDockerfile.ts index 64bc49980..04b81e9bd 100644 --- a/frontend/src/ui/cloudEnvironmentDockerfile.ts +++ b/frontend/src/ui/cloudEnvironmentDockerfile.ts @@ -7,6 +7,11 @@ const AGENTKIT_BASE_IMAGES: Record = { byteplus: "agentkit-prod-public-ap-southeast-1.cr.bytepluses.com/base/py-simple:python3.12-bookworm-slim-latest", }; +const VOLCENGINE_PYPI_INDEXES = [ + "https://repo.huaweicloud.com/repository/pypi/simple", + "https://mirrors.aliyun.com/pypi/simple/", + "https://pypi.org/simple", +] as const; const LARK_CLI_VERSION = "1.0.87"; const LARK_CLI_SHA256 = { @@ -66,6 +71,17 @@ function githubReleaseUrls( : [official, mirror]; } +function renderPythonDependencyInstall(cloudProvider: CloudProvider): string { + if (cloudProvider !== "volcengine") { + return "RUN uv pip install -r requirements.txt"; + } + + const attempts = VOLCENGINE_PYPI_INDEXES.map( + (index) => `uv pip install --index-url ${index} -r requirements.txt`, + ); + return `RUN ${attempts.join(" || \\\n ")}`; +} + export function buildCloudEnvironmentDockerfile( cloudProvider: CloudProvider, cliTools: CloudCliToolId[], @@ -123,7 +139,7 @@ export function buildCloudEnvironmentDockerfile( "", "# Install Python dependencies before copying the source for better layer caching.", "COPY requirements.txt requirements.txt", - "RUN uv pip install -r requirements.txt", + renderPythonDependencyInstall(cloudProvider), "", "# Copy the Agent application and configure its runtime entrypoint.", "EXPOSE 8000", diff --git a/frontend/tests/automation-artifacts.test.mjs b/frontend/tests/automation-artifacts.test.mjs index 17d1b96bd..44c4b8e53 100644 --- a/frontend/tests/automation-artifacts.test.mjs +++ b/frontend/tests/automation-artifacts.test.mjs @@ -40,7 +40,7 @@ test("generates the basic Studio project and Runtime delivery workflow in fronte assert.equal( files["requirements.txt"], [ - "veadk-python==1.1.6", + "veadk-python==1.1.9", "agentkit-sdk-python==0.8.4", "google-adk==2.1.0", "lark-channel-sdk==1.2.0", @@ -49,6 +49,14 @@ test("generates the basic Studio project and Runtime delivery workflow in fronte "", ].join("\n"), ); + const huawei = "https://repo.huaweicloud.com/repository/pypi/simple"; + const aliyun = "https://mirrors.aliyun.com/pypi/simple/"; + const pypi = "https://pypi.org/simple"; + assert.match(files.Dockerfile, new RegExp(huawei.replaceAll(".", "\\."))); + assert.match(files.Dockerfile, new RegExp(aliyun.replaceAll(".", "\\."))); + assert.match(files.Dockerfile, new RegExp(pypi.replaceAll(".", "\\."))); + assert.ok(files.Dockerfile.indexOf(huawei) < files.Dockerfile.indexOf(aliyun)); + assert.ok(files.Dockerfile.indexOf(aliyun) < files.Dockerfile.indexOf(pypi)); assert.match(files["README.md"], /python app\.py/); const workflow = buildRuntimeDeliveryWorkflow({ @@ -86,6 +94,9 @@ test("generates BytePlus template and Runtime delivery workflow in frontend", as assert.match(files[".env.example"], /AGENTKIT_CLOUD_PROVIDER=byteplus/); assert.match(files[".env.example"], /https:\/\/ark\.ap-southeast\.bytepluses\.com\/api\/v3/); assert.doesNotMatch(files[".env.example"], /VOLCENGINE_ACCESS_KEY=/); + assert.match(files.Dockerfile, /RUN uv pip install -r requirements\.txt/); + assert.doesNotMatch(files.Dockerfile, /repo\.huaweicloud\.com/); + assert.doesNotMatch(files.Dockerfile, /mirrors\.aliyun\.com/); const workflow = buildRuntimeDeliveryWorkflow({ baseBranch: "main", diff --git a/frontend/tests/cloudEnvironment.test.mjs b/frontend/tests/cloudEnvironment.test.mjs index e9623ed6e..8686bcb2d 100644 --- a/frontend/tests/cloudEnvironment.test.mjs +++ b/frontend/tests/cloudEnvironment.test.mjs @@ -142,6 +142,16 @@ test("builds an editable provider-specific Dockerfile preview", () => { assert.match(volcengine, /# Install Lark CLI/); assert.match(volcengine, /# Install Python dependencies/); assert.match(volcengine, /# Copy the Agent application/); + const huawei = "https://repo.huaweicloud.com/repository/pypi/simple"; + const aliyun = "https://mirrors.aliyun.com/pypi/simple/"; + const pypi = "https://pypi.org/simple"; + assert.match(volcengine, new RegExp(huawei.replaceAll(".", "\\."))); + assert.match(volcengine, new RegExp(aliyun.replaceAll(".", "\\."))); + assert.match(volcengine, new RegExp(pypi.replaceAll(".", "\\."))); + assert.ok(volcengine.indexOf(huawei) < volcengine.indexOf(aliyun)); + assert.ok(volcengine.indexOf(aliyun) < volcengine.indexOf(pypi)); + assert.match(byteplus, /RUN uv pip install -r requirements\.txt/); + assert.doesNotMatch(byteplus, /repo\.huaweicloud\.com|mirrors\.aliyun\.com/); }); test("exports cloud environment selections through YAML", () => { diff --git a/tests/cli/test_generated_agent_backend_codegen.py b/tests/cli/test_generated_agent_backend_codegen.py index efa0902b5..d693f164c 100644 --- a/tests/cli/test_generated_agent_backend_codegen.py +++ b/tests/cli/test_generated_agent_backend_codegen.py @@ -86,7 +86,7 @@ def test_minimal_codegen_agent_py_compiles(tmp_path) -> None: file.content for file in project.files if file.path == "requirements.txt" ) assert requirements == ( - "veadk-python==1.1.7\n" + "veadk-python==1.1.9\n" "agentkit-sdk-python==0.8.4\n" "google-adk==2.1.0\n" "starlette==0.52.1\n" @@ -130,14 +130,12 @@ def test_quick_mode_codegen_adds_dynamic_agent_toolset_and_managed_rules() -> No assert "create_agents" in agent_py assert "handoff_to" in agent_py assert "'dynamicAgentDelegation': True" in agent_py - assert "veadk-python==1.1.7\n" in requirements + assert "veadk-python==1.1.9\n" in requirements assert "github.com/volcengine/veadk-python" not in requirements - assert "RUN uv pip install -r requirements.txt || \\" in dockerfile - assert ( - "uv pip install --index-url " - "https://repo.huaweicloud.com/repository/pypi/simple -r requirements.txt" - in dockerfile - ) + huawei = "https://repo.huaweicloud.com/repository/pypi/simple" + aliyun = "https://mirrors.aliyun.com/pypi/simple/" + pypi = "https://pypi.org/simple" + assert dockerfile.index(huawei) < dockerfile.index(aliyun) < dockerfile.index(pypi) compat_py = next( file.content @@ -757,7 +755,7 @@ def test_traditional_codegen_does_not_add_dynamic_agent_capability() -> None: assert "CreateAgentToolset" not in agent_py assert "动态子智能体协作规则" not in agent_py assert "dynamicAgentDelegation" not in agent_py - assert "veadk-python==1.1.7" in requirements + assert "veadk-python==1.1.9" in requirements def test_codegen_environment_image_adds_skills_without_replacing_agent_skills() -> None: @@ -923,12 +921,18 @@ def test_codegen_cloud_environment_uses_provider_base_image( in files["Dockerfile"] ) assert 'CMD ["python", "-m", "app"]' in files["Dockerfile"] - assert "RUN uv pip install -r requirements.txt || \\" in files["Dockerfile"] - assert ( - "uv pip install --index-url " - "https://repo.huaweicloud.com/repository/pypi/simple -r requirements.txt" - in files["Dockerfile"] - ) + dockerfile = files["Dockerfile"] + if cloud_provider == "volcengine": + huawei = "https://repo.huaweicloud.com/repository/pypi/simple" + aliyun = "https://mirrors.aliyun.com/pypi/simple/" + pypi = "https://pypi.org/simple" + assert ( + dockerfile.index(huawei) < dockerfile.index(aliyun) < dockerfile.index(pypi) + ) + else: + assert "RUN uv pip install -r requirements.txt" in dockerfile + assert "repo.huaweicloud.com" not in dockerfile + assert "mirrors.aliyun.com" not in dockerfile def test_codegen_cloud_environment_installs_github_cli_for_both_architectures() -> None: diff --git a/tests/cli/test_generated_agent_backend_codegen_extended.py b/tests/cli/test_generated_agent_backend_codegen_extended.py index 32c3bbcf4..aa82c5d00 100644 --- a/tests/cli/test_generated_agent_backend_codegen_extended.py +++ b/tests/cli/test_generated_agent_backend_codegen_extended.py @@ -75,7 +75,7 @@ "agents/demo_agent/__init__.py": "ba3abbb199bbae74dc75151a44ba53a557e5f47d509835950ca756346c5a9582", "agents/demo_agent/dynamic_a2a.py": "d136f27d6a77439708c415686a3d167f2ad2fb9a96a5f8a0751916b09d46e364", ".env.example": "ec3258da9bef4e74333376d8554c265ccb12a4a1e5d4e1e1b0acdf5c9ae93ab6", - "requirements.txt": "33054921190810d876ac568ff102f3f42e15d85657f01a033598fc4f50994db4", + "requirements.txt": "a66e74d4c0b91cc4cc036f6026599a787056ea72a034d857bedd92fddc6d779f", "README.md": "a34208314cf9061c02662028d7a9dd97448e6b73c1d732cb4aeaa8f70dbbc684", } @@ -86,7 +86,7 @@ "agents/full_agent/__init__.py": "ba3abbb199bbae74dc75151a44ba53a557e5f47d509835950ca756346c5a9582", "agents/full_agent/dynamic_a2a.py": "d136f27d6a77439708c415686a3d167f2ad2fb9a96a5f8a0751916b09d46e364", ".env.example": "2bfd3afda4e661fbb71588ec5f0d584ce6682363cacc81b0394f8da09f7977e8", - "requirements.txt": "ee61f1353a4ac0771229b38afb1e2983c8f77ddfe0b0b2dfbe22767376668654", + "requirements.txt": "63eb2d042226abfb78238725727c6a13724472a1f55d84d55f3fa79cd07be9eb", "README.md": "1bf4dc889c7d1076f50784d253b53412ba7c49bcb69a5d948f9092dbbecb18ac", } diff --git a/tests/cli/test_generated_agent_component_matrix.py b/tests/cli/test_generated_agent_component_matrix.py index 448dc7e88..9d3b1dde2 100644 --- a/tests/cli/test_generated_agent_component_matrix.py +++ b/tests/cli/test_generated_agent_component_matrix.py @@ -67,7 +67,7 @@ def _assert_python_files_compile(project: GeneratedProject) -> None: def _veadk_requirement(extras: set[str]) -> str: extras_str = f"[{','.join(sorted(extras))}]" if extras else "" - return f"veadk-python{extras_str}==1.1.7" + return f"veadk-python{extras_str}==1.1.9" EXPECTED_LTM_EXTRAS = { @@ -778,5 +778,5 @@ def test_deeply_nested_agent_types_generate_complete_component_project() -> None assert 'KnowledgeBase(backend="context_search"' in agent_py assert "OpentelemetryTracer()" in agent_py assert _env_keys(files[".env.example"]) == expected_env - assert "veadk-python[extensions]==1.1.7" in files["requirements.txt"] + assert "veadk-python[extensions]==1.1.9" in files["requirements.txt"] _assert_python_files_compile(project) diff --git a/veadk/cli/generated_agent_codegen.py b/veadk/cli/generated_agent_codegen.py index 4f2d9526e..83f252fe2 100644 --- a/veadk/cli/generated_agent_codegen.py +++ b/veadk/cli/generated_agent_codegen.py @@ -64,7 +64,12 @@ "volcengine": "agentkit-prod-public-cn-beijing.cr.volces.com/base/py-simple:python3.12-bookworm-slim-latest", "byteplus": "agentkit-prod-public-ap-southeast-1.cr.bytepluses.com/base/py-simple:python3.12-bookworm-slim-latest", } -_PYPI_FALLBACK_INDEX = "https://repo.huaweicloud.com/repository/pypi/simple" +_VEADK_VERSION = "1.1.9" +_VOLCENGINE_PYPI_INDEXES = ( + "https://repo.huaweicloud.com/repository/pypi/simple", + "https://mirrors.aliyun.com/pypi/simple/", + "https://pypi.org/simple", +) _LARK_CLI_VERSION = "1.0.87" _LARK_CLI_SHA256 = { "amd64": "6027b1ddc12440400581bbdf9554850d8e119c7dd400439b1220e7a87b9673c5", @@ -1060,7 +1065,7 @@ def render_requirements( unique_extras = sorted(all_extras) extras_str = f"[{','.join(unique_extras)}]" if unique_extras else "" managed_sidecar = "harness-sidecar" in all_extras - pkg = f"veadk-python{extras_str}==1.1.7" + pkg = f"veadk-python{extras_str}=={_VEADK_VERSION}" agentkit_sdk = ( "agentkit-sdk-python==0.8.1" if managed_sidecar @@ -1239,7 +1244,7 @@ def _render_managed_main_py() -> str: def _render_quick_mode_compat_py() -> str: - """Backport quick-mode runtime behavior while deployments stay on 1.1.7.""" + """Keep quick-mode runtime behavior available in the pinned runtime.""" create_agents_schema = pformat( CreateAgentsInput.model_json_schema(by_alias=True), @@ -1412,7 +1417,7 @@ def _get_declaration(self) -> types.FunctionDeclaration | None: class CreateAgentToolset(_BaseCreateAgentToolset): - """Keep quick-mode semantics available in the pinned 1.1.7 runtime.""" + """Keep quick-mode semantics available in the pinned runtime.""" _MAX_COMPLETED_CREATIONS = 128 @@ -2144,6 +2149,17 @@ def _github_release_urls(cloud_provider: str, repository: str) -> list[str]: return [mirror, official] if cloud_provider == "volcengine" else [official, mirror] +def _render_python_dependency_install(cloud_provider: str) -> str: + if cloud_provider != "volcengine": + return "RUN uv pip install -r requirements.txt" + + attempts = [ + f"uv pip install --index-url {index} -r requirements.txt" + for index in _VOLCENGINE_PYPI_INDEXES + ] + return "RUN " + " || \\\n ".join(attempts) + + def render_cloud_environment_dockerfile(draft: AgentDraft) -> str | None: """Render the custom image or an AgentKit-compatible image for selected CLIs.""" if draft.cloudEnvironment.resolvedImage: @@ -2232,11 +2248,7 @@ def render_cloud_environment_dockerfile(draft: AgentDraft) -> str | None: "", "# Install Python dependencies before copying the source for better layer caching.", "COPY requirements.txt requirements.txt", - ( - "RUN uv pip install -r requirements.txt || \\\n" - f" uv pip install --index-url {_PYPI_FALLBACK_INDEX} " - "-r requirements.txt" - ), + _render_python_dependency_install(draft.cloudProvider), "", "# Copy the Agent application and configure its runtime entrypoint.", "EXPOSE 8000", diff --git a/veadk/webui/assets/app/index-CeLcxSwu.js b/veadk/webui/assets/app/index-Cp46ADZF.js similarity index 98% rename from veadk/webui/assets/app/index-CeLcxSwu.js rename to veadk/webui/assets/app/index-Cp46ADZF.js index 878a027b6..11e95abd9 100644 --- a/veadk/webui/assets/app/index-CeLcxSwu.js +++ b/veadk/webui/assets/app/index-Cp46ADZF.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/visualizations/mermaid/mermaid.core-B_GhFya9.js","assets/chunks/purify.es-BnINGy_Y.js","assets/chunks/MarkdownPromptEditor-DH3YPDqW.js","assets/styles/MarkdownPromptEditor-ZH9qtki0.css"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/visualizations/mermaid/mermaid.core-u1Q_qVDs.js","assets/chunks/purify.es-BnINGy_Y.js","assets/chunks/MarkdownPromptEditor-BrM0rJhH.js","assets/styles/MarkdownPromptEditor-ZH9qtki0.css"])))=>i.map(i=>d[i]); var hke=Object.defineProperty;var vF=e=>{throw TypeError(e)};var pke=(e,t,n)=>t in e?hke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var kr=(e,t,n)=>pke(e,typeof t!="symbol"?t+"":t,n),wF=(e,t,n)=>t.has(e)||vF("Cannot "+n);var qa=(e,t,n)=>(wF(e,t,"read from private field"),n?n.call(e):t.get(e)),SF=(e,t,n)=>t.has(e)?vF("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),hI=(e,t,n,r)=>(wF(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function mke(e,t){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var op=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function N1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Vte={exports:{}},tN={};/** * @license React * react-jsx-runtime.production.js @@ -462,7 +462,7 @@ ${r}`}}async function u9(e,t=!1){const n=await wt(`/web/model-api-keys${t?"?refr `)},VH=function(){var e=parseInt(document.body.getAttribute(hy)||"0",10);return isFinite(e)?e:0},DPe=function(){p.useEffect(function(){return document.body.setAttribute(hy,(VH()+1).toString()),function(){var e=VH()-1;e<=0?document.body.removeAttribute(hy):document.body.setAttribute(hy,e.toString())}},[])},PPe=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;DPe();var s=p.useMemo(function(){return jPe(i)},[i]);return p.createElement(RPe,{styles:IPe(s,!t,i,n?"":"!important")})},f4=!1;if(typeof window<"u")try{var Wk=Object.defineProperty({},"passive",{get:function(){return f4=!0,!0}});window.addEventListener("test",Wk,Wk),window.removeEventListener("test",Wk,Wk)}catch{f4=!1}var H0=f4?{passive:!1}:!1,MPe=function(e){return e.tagName==="TEXTAREA"},dce=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!MPe(e)&&n[t]==="visible")},LPe=function(e){return dce(e,"overflowY")},$Pe=function(e){return dce(e,"overflowX")},HH=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=fce(e,r);if(i){var s=hce(e,r),a=s[1],l=s[2];if(a>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},BPe=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},QPe=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},fce=function(e,t){return e==="v"?LPe(t):$Pe(t)},hce=function(e,t){return e==="v"?BPe(t):QPe(t)},UPe=function(e,t){return e==="h"&&t==="rtl"?-1:1},FPe=function(e,t,n,r,i){var s=UPe(e,window.getComputedStyle(t).direction),a=s*r,l=n.target,c=t.contains(l),u=!1,d=a>0,f=0,h=0;do{if(!l)break;var m=hce(e,l),g=m[0],b=m[1],y=m[2],O=b-y-s*g;(g||O)&&fce(e,l)&&(f+=O,h+=g);var v=l.parentNode;l=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},Yk=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},qH=function(e){return[e.deltaX,e.deltaY]},XH=function(e){return e&&"current"in e?e.current:e},zPe=function(e,t){return e[0]===t[0]&&e[1]===t[1]},VPe=function(e){return` .block-interactivity-`.concat(e,` {pointer-events: none;} .allow-interactivity-`).concat(e,` {pointer-events: all;} -`)},HPe=0,q0=[];function qPe(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),i=p.useState(HPe++)[0],s=p.useState(uce)[0],a=p.useRef(e);p.useEffect(function(){a.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var b=hPe([e.lockRef.current],(e.shards||[]).map(XH),!0).filter(Boolean);return b.forEach(function(y){return y.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),b.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=p.useCallback(function(b,y){if("touches"in b&&b.touches.length===2||b.type==="wheel"&&b.ctrlKey)return!a.current.allowPinchZoom;var O=Yk(b),v=n.current,x="deltaX"in b?b.deltaX:v[0]-O[0],w="deltaY"in b?b.deltaY:v[1]-O[1],S,E=b.target,k=Math.abs(x)>Math.abs(w)?"h":"v";if("touches"in b&&k==="h"&&E.type==="range")return!1;var _=window.getSelection(),C=_&&_.anchorNode,T=C?C===E||C.contains(E):!1;if(T)return!1;var A=HH(k,E);if(!A)return!0;if(A?S=k:(S=k==="v"?"h":"v",A=HH(k,E)),!A)return!1;if(!r.current&&"changedTouches"in b&&(x||w)&&(r.current=S),!S)return!0;var j=r.current||S;return FPe(j,y,b,j==="h"?x:w)},[]),c=p.useCallback(function(b){var y=b;if(!(!q0.length||q0[q0.length-1]!==s)){var O="deltaY"in y?qH(y):Yk(y),v=t.current.filter(function(S){return S.name===y.type&&(S.target===y.target||y.target===S.shadowParent)&&zPe(S.delta,O)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var x=(a.current.shards||[]).map(XH).filter(Boolean).filter(function(S){return S.contains(y.target)}),w=x.length>0?l(y,x[0]):!a.current.noIsolation;w&&y.cancelable&&y.preventDefault()}}},[]),u=p.useCallback(function(b,y,O,v){var x={name:b,delta:y,target:O,should:v,shadowParent:XPe(O)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(w){return w!==x})},1)},[]),d=p.useCallback(function(b){n.current=Yk(b),r.current=void 0},[]),f=p.useCallback(function(b){u(b.type,qH(b),b.target,l(b,e.lockRef.current))},[]),h=p.useCallback(function(b){u(b.type,Yk(b),b.target,l(b,e.lockRef.current))},[]);p.useEffect(function(){return q0.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,H0),document.addEventListener("touchmove",c,H0),document.addEventListener("touchstart",d,H0),function(){q0=q0.filter(function(b){return b!==s}),document.removeEventListener("wheel",c,H0),document.removeEventListener("touchmove",c,H0),document.removeEventListener("touchstart",d,H0)}},[]);var m=e.removeScrollBar,g=e.inert;return p.createElement(p.Fragment,null,g?p.createElement(s,{styles:VPe(i)}):null,m?p.createElement(PPe,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function XPe(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const GPe=wPe(cce,qPe);var M9=p.forwardRef(function(e,t){return p.createElement(FN,Gu({},e,{ref:t,sideCar:GPe}))});M9.classNames=FN.classNames;var WPe=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},X0=new WeakMap,Zk=new WeakMap,Kk={},S5=0,pce=function(e){return e&&(e.host||pce(e.parentNode))},YPe=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=pce(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},ZPe=function(e,t,n,r){var i=YPe(t,Array.isArray(e)?e:[e]);Kk[n]||(Kk[n]=new WeakMap);var s=Kk[n],a=[],l=new Set,c=new Set(i),u=function(f){!f||l.has(f)||(l.add(f),u(f.parentNode))};i.forEach(u);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(l.has(h))d(h);else try{var m=h.getAttribute(r),g=m!==null&&m!=="false",b=(X0.get(h)||0)+1,y=(s.get(h)||0)+1;X0.set(h,b),s.set(h,y),a.push(h),b===1&&g&&Zk.set(h,!0),y===1&&h.setAttribute(n,"true"),g||h.setAttribute(r,"true")}catch(O){console.error("aria-hidden: cannot operate on ",h,O)}})};return d(t),l.clear(),S5++,function(){a.forEach(function(f){var h=X0.get(f)-1,m=s.get(f)-1;X0.set(f,h),s.set(f,m),h||(Zk.has(f)||f.removeAttribute(r),Zk.delete(f)),m||f.removeAttribute(n)}),S5--,S5||(X0=new WeakMap,X0=new WeakMap,Zk=new WeakMap,Kk={})}},mce=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=WPe(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),ZPe(r,i,n,"aria-hidden")):function(){return null}},KPe=Object.defineProperty,JPe=(e,t)=>KPe(e,"name",{value:t,configurable:!0});function KS(e){const[t,n]=p.useState(void 0);return Ic(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let a,l;if("borderBoxSize"in s){const c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;a=u.inlineSize,l=u.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}JPe(KS,"useSize");var e3e=Object.defineProperty,th=(e,t)=>e3e(e,"name",{value:t,configurable:!0}),L9="Checkbox",[t3e,rMt]=rl(L9),[n3e,$9]=t3e(L9);function gce(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:s,form:a,name:l,onCheckedChange:c,required:u,value:d="on",internal_do_not_use_render:f}=e,[h,m]=Bc({prop:n,defaultProp:i??!1,onChange:c,caller:L9}),[g,b]=p.useState(null),[y,O]=p.useState(null),v=p.useRef(!1),[x,w]=p.useReducer(k=>k+1,0),S=g?!!a||!!g.closest("form"):!0,E={checked:h,disabled:s,setChecked:m,control:g,setControl:b,name:l,form:a,value:d,hasConsumerStoppedPropagationRef:v,userInteractionCount:x,onUserInteraction:w,required:u,defaultChecked:Pf(i)?!1:i,isFormControl:S,bubbleInput:y,setBubbleInput:O};return o.jsx(n3e,{scope:t,...E,children:bce(f)?f(E):r})}th(gce,"CheckboxProvider");var r3e="CheckboxTrigger",i3e=p.forwardRef(th(function({__scopeCheckbox:t,onKeyDown:n,onClick:r,...i},s){const{control:a,value:l,disabled:c,checked:u,required:d,setControl:f,setChecked:h,hasConsumerStoppedPropagationRef:m,onUserInteraction:g,isFormControl:b,bubbleInput:y}=$9(r3e,t),O=zr(s,f),v=p.useRef(u);return p.useEffect(()=>{const x=a==null?void 0:a.form;if(x){const w=th(()=>h(v.current),"reset");return x.addEventListener("reset",w),()=>x.removeEventListener("reset",w)}},[a,h]),o.jsx(pi.button,{type:"button",role:"checkbox","aria-checked":Pf(u)?"mixed":u,"aria-required":d,"data-state":B9(u),"data-disabled":c?"":void 0,disabled:c,value:l,...i,ref:O,onKeyDown:mn(n,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:mn(r,x=>{g(),h(w=>Pf(w)?!0:!w),y&&b&&(m.current=x.isPropagationStopped(),m.current||x.stopPropagation())})})},"CheckboxTrigger")),s3e=p.forwardRef(th(function(t,n){const{__scopeCheckbox:r,name:i,checked:s,defaultChecked:a,required:l,disabled:c,value:u,onCheckedChange:d,form:f,...h}=t;return o.jsx(gce,{__scopeCheckbox:r,checked:s,defaultChecked:a,disabled:c,required:l,onCheckedChange:d,name:i,form:f,value:u,internal_do_not_use_render:({isFormControl:m})=>o.jsxs(o.Fragment,{children:[o.jsx(i3e,{...h,ref:n,__scopeCheckbox:r}),m&&o.jsx(c3e,{__scopeCheckbox:r})]})})},"Checkbox")),a3e="CheckboxIndicator",o3e=p.forwardRef(th(function(t,n){const{__scopeCheckbox:r,forceMount:i,...s}=t,a=$9(a3e,r);return o.jsx(Ed,{present:i||Pf(a.checked)||a.checked===!0,children:o.jsx(pi.span,{"data-state":B9(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:n,style:{pointerEvents:"none",...t.style}})})},"CheckboxIndicator")),l3e="CheckboxBubbleInput",c3e=p.forwardRef(th(function({__scopeCheckbox:t,onClick:n,...r},i){const{control:s,hasConsumerStoppedPropagationRef:a,userInteractionCount:l,checked:c,defaultChecked:u,required:d,disabled:f,name:h,value:m,form:g,bubbleInput:b,setBubbleInput:y}=$9(l3e,t),O=zr(i,y),v=KS(s),x=p.useRef(!1),w=p.useRef(c),S=p.useRef(l);p.useEffect(()=>{const k=b;if(!k)return;const _=window.HTMLInputElement.prototype,T=Object.getOwnPropertyDescriptor(_,"checked").set,A=l!==S.current;S.current=l;const j=w.current!==c;w.current=c;const L=!(A&&a.current);if(j&&T){x.current=!A;const I=new Event("click",{bubbles:L});k.indeterminate=Pf(c),T.call(k,Pf(c)?!1:c),k.dispatchEvent(I),x.current=!1}},[b,c,a,l]);const E=p.useRef(Pf(c)?!1:c);return o.jsx(pi.input,{type:"checkbox","aria-hidden":!0,defaultChecked:u??E.current,required:d,disabled:f,name:h,value:m,form:g,...r,tabIndex:-1,ref:O,onClick:mn(n,k=>{x.current&&k.stopPropagation()}),style:{...r.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function bce(e){return typeof e=="function"}th(bce,"isFunction");function Pf(e){return e==="indeterminate"}th(Pf,"isIndeterminate");function B9(e){return Pf(e)?"indeterminate":e?"checked":"unchecked"}th(B9,"getState");const u3e=["top","right","bottom","left"],zp=Math.min,Mf=Math.max,SC=Math.round,Jk=Math.floor,Lf=e=>({x:e,y:e}),d3e={left:"right",right:"left",bottom:"top",top:"bottom"};function yce(e,t,n){return Mf(e,zp(t,n))}function nh(e,t){return typeof e=="function"?e(t):e}function Vp(e){return e.split("-")[0]}function X1(e){return e.split("-")[1]}function Q9(e){return e==="x"?"y":"x"}function U9(e){return e==="y"?"height":"width"}function td(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function F9(e){return Q9(td(e))}function f3e(e,t,n){n===void 0&&(n=!1);const r=X1(e),i=F9(e),s=U9(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=EC(a)),[a,EC(a)]}function h3e(e){const t=EC(e);return[h4(e),t,h4(t)]}function h4(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const GH=["left","right"],WH=["right","left"],p3e=["top","bottom"],m3e=["bottom","top"];function g3e(e,t,n){switch(e){case"top":case"bottom":return n?t?WH:GH:t?GH:WH;case"left":case"right":return t?p3e:m3e;default:return[]}}function b3e(e,t,n,r){const i=X1(e);let s=g3e(Vp(e),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),t&&(s=s.concat(s.map(h4)))),s}function EC(e){const t=Vp(e);return d3e[t]+e.slice(t.length)}function y3e(e){var t,n,r,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function Oce(e){return typeof e!="number"?y3e(e):{top:e,right:e,bottom:e,left:e}}function kC(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function YH(e,t,n){let{reference:r,floating:i}=e;const s=td(t),a=F9(t),l=U9(a),c=Vp(t),u=s==="y",d=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,h=r[l]/2-i[l]/2;let m;switch(c){case"top":m={x:d,y:r.y-i.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-i.width,y:f};break;default:m={x:r.x,y:r.y}}const g=X1(t);return g&&(m[a]+=h*(g==="end"?1:-1)*(n&&u?-1:1)),m}async function O3e(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:a,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:m=0}=nh(t,e),g=Oce(m),y=l[h?f==="floating"?"reference":"floating":f],O=kC(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:u,rootBoundary:d,strategy:c})),v=f==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),w=await(s.isElement==null?void 0:s.isElement(x))&&await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1},S=kC(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:x,strategy:c}):v);return{top:(O.top-S.top+g.top)/w.y,bottom:(S.bottom-O.bottom+g.bottom)/w.y,left:(O.left-S.left+g.left)/w.x,right:(S.right-O.right+g.right)/w.x}}const x3e=50,v3e=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:O3e},c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:d,y:f}=YH(u,r,c),h=r,m=0;const g={};for(let b=0;b({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:a,elements:l,middlewareData:c}=t,{element:u,padding:d=0}=nh(e,t)||{};if(u==null)return{};const f=Oce(d),h={x:n,y:r},m=F9(i),g=U9(m),b=await a.getDimensions(u),y=m==="y",O=y?"top":"left",v=y?"bottom":"right",x=y?"clientHeight":"clientWidth",w=s.reference[g]+s.reference[m]-h[m]-s.floating[g],S=h[m]-s.reference[m],E=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let k=E?E[x]:0;(!k||!await(a.isElement==null?void 0:a.isElement(E)))&&(k=l.floating[x]||s.floating[g]);const _=w/2-S/2,C=k/2-b[g]/2-1,T=zp(f[O],C),A=zp(f[v],C),j=k-b[g]-A,L=k/2-b[g]/2+_,I=yce(T,L,j),M=!c.arrow&&X1(i)!=null&&L!==I&&s.reference[g]/2-(LI<=0)){var A,j;const I=(((A=s.flip)==null?void 0:A.index)||0)+1,M=k[I];if(M&&(!(f==="alignment"?v!==td(M):!1)||T.every(Q=>td(Q.placement)===v?Q.overflows[0]>0:!0)))return{data:{index:I,overflows:T},reset:{placement:M}};let N=(j=T.filter(D=>D.overflows[0]<=0).sort((D,Q)=>D.overflows[1]-Q.overflows[1])[0])==null?void 0:j.placement;if(!N)switch(m){case"bestFit":{var L;const D=(L=T.filter(Q=>{if(E){const F=td(Q.placement);return F===v||F==="y"}return!0}).map(Q=>[Q.placement,Q.overflows.filter(F=>F>0).reduce((F,$)=>F+$,0)]).sort((Q,F)=>Q[1]-F[1])[0])==null?void 0:L[0];D&&(N=D);break}case"initialPlacement":N=l;break}if(i!==N)return{reset:{placement:N}}}return{}}}};function ZH(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function KH(e){return u3e.some(t=>e[t]>=0)}const E3e=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=nh(e,t);switch(i){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=ZH(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:KH(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),l=ZH(a,n.floating);return{data:{escapedOffsets:l,escaped:KH(l)}}}default:return{}}}}},xce=new Set(["left","top"]);async function k3e(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=Vp(n),l=X1(n),c=td(n)==="y",u=xce.has(a)?-1:1,d=s&&c?-1:1,f=nh(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof g=="number"&&(m=l==="end"?g*-1:g),c?{x:m*d,y:h*u}:{x:h*u,y:m*d}}const _3e=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:a,middlewareData:l}=t,c=await k3e(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:s+c.y,data:{...c,placement:a}}}}},T3e=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:v=>{let{x,y:w}=v;return{x,y:w}}},...u}=nh(e,t),d={x:n,y:r},f=await s.detectOverflow(t,u),h=td(i),m=Q9(h);let g=d[m],b=d[h];const y=(v,x)=>yce(x+f[v==="y"?"top":"left"],x,x-f[v==="y"?"bottom":"right"]);a&&(g=y(m,g)),l&&(b=y(h,b));const O=c.fn({...t,[m]:g,[h]:b});return{...O,data:{x:O.x-n,y:O.y-r,enabled:{[m]:a,[h]:l}}}}}},C3e=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:i,y:s,placement:a,rects:l,middlewareData:c}=t,{offset:u=0,mainAxis:d=!0,crossAxis:f=!0}=nh(e,t),h={x:i,y:s},m=td(a),g=Q9(m);let b=h[g],y=h[m];const O=nh(u,t),v=typeof O=="number"?{mainAxis:O,crossAxis:0}:{mainAxis:(n=O.mainAxis)!=null?n:0,crossAxis:(r=O.crossAxis)!=null?r:0};if(d){const S=g==="y"?"height":"width",E=l.reference[g]-l.floating[S]+v.mainAxis,k=l.reference[g]+l.reference[S]-v.mainAxis;bk&&(b=k)}if(f){var x,w;const S=g==="y"?"width":"height",E=xce.has(Vp(a)),k=l.reference[m]-l.floating[S]+(E&&((x=c.offset)==null?void 0:x[m])||0)+(E?0:v.crossAxis),_=l.reference[m]+l.reference[S]+(E?0:((w=c.offset)==null?void 0:w[m])||0)-(E?v.crossAxis:0);y_&&(y=_)}return{[g]:b,[m]:y}}}},A3e=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:s}=t,{apply:a=()=>{},...l}=nh(e,t),c=await i.detectOverflow(t,l),u=Vp(n),d=X1(n),f=td(n)==="y",{width:h,height:m}=r.floating;let g,b;u==="top"||u==="bottom"?(g=u,b=d===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(b=u,g=d==="end"?"top":"bottom");const y=m-c.top-c.bottom,O=h-c.left-c.right,v=zp(m-c[g],y),x=zp(h-c[b],O),w=t.middlewareData.shift,S=!w;let E=v,k=x;w!=null&&w.enabled.x&&(k=O),w!=null&&w.enabled.y&&(E=y),S&&!d&&(f?k=h-2*Mf(c.left,c.right):E=m-2*Mf(c.top,c.bottom)),await a({...t,availableWidth:k,availableHeight:E});const _=await i.getDimensions(s.floating);return h!==_.width||m!==_.height?{reset:{rects:!0}}:{}}}};function zN(){return typeof window<"u"}function G1(e){return vce(e)?(e.nodeName||"").toLowerCase():"#document"}function Ka(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function mh(e){var t;return(t=(vce(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function vce(e){return zN()?e instanceof Node||e instanceof Ka(e).Node:!1}function md(e){return zN()?e instanceof Element||e instanceof Ka(e).Element:!1}function kd(e){return zN()?e instanceof HTMLElement||e instanceof Ka(e).HTMLElement:!1}function JH(e){return!zN()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ka(e).ShadowRoot}function VN(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=gd(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function N3e(e){return/^(table|td|th)$/.test(G1(e))}function HN(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const j3e=/transform|translate|scale|rotate|perspective|filter/,R3e=/paint|layout|strict|content/,km=e=>!!e&&e!=="none";let E5;function z9(e){const t=md(e)?gd(e):e;return km(t.transform)||km(t.translate)||km(t.scale)||km(t.rotate)||km(t.perspective)||!V9()&&(km(t.backdropFilter)||km(t.filter))||j3e.test(t.willChange||"")||R3e.test(t.contain||"")}function I3e(e){let t=Mg(e);for(;kd(t)&&!Sw(t);){if(z9(t))return t;if(HN(t))return null;t=Mg(t)}return null}function V9(){return E5==null&&(E5=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),E5}function Sw(e){return/^(html|body|#document)$/.test(G1(e))}function gd(e){return Ka(e).getComputedStyle(e)}function qN(e){return md(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Mg(e){if(G1(e)==="html")return e;const t=e.assignedSlot||e.parentNode||JH(e)&&e.host||mh(e);return JH(t)?t.host:t}function wce(e){const t=Mg(e);return Sw(t)?(e.ownerDocument||e).body:kd(t)&&VN(t)?t:wce(t)}function Ew(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=wce(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),a=Ka(i);if(s){const l=p4(a);return t.concat(a,a.visualViewport||[],VN(i)?i:[],l&&n?Ew(l):[])}else return t.concat(i,Ew(i,[],n))}function p4(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Sce(e){const t=gd(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=kd(e),s=i?e.offsetWidth:n,a=i?e.offsetHeight:r,l=SC(n)!==s||SC(r)!==a;return l&&(n=s,r=a),{width:n,height:r,$:l}}function H9(e){return md(e)?e:e.contextElement}function py(e){const t=H9(e);if(!kd(t))return Lf(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=Sce(t);let a=(s?SC(n.width):n.width)/r,l=(s?SC(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const D3e=Lf(0);function Ece(e){const t=Ka(e);return!V9()||!t.visualViewport?D3e:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function P3e(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Ka(e)}function Lg(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=H9(e);let a=Lf(1);t&&(r?md(r)&&(a=py(r)):a=py(e));const l=P3e(s,n,r)?Ece(s):Lf(0);let c=(i.left+l.x)/a.x,u=(i.top+l.y)/a.y,d=i.width/a.x,f=i.height/a.y;if(s&&r){const h=Ka(s),m=md(r)?Ka(r):r;let g=h,b=p4(g);for(;b&&m!==g;){const y=py(b),O=b.getBoundingClientRect(),v=gd(b),x=O.left+(b.clientLeft+parseFloat(v.paddingLeft))*y.x,w=O.top+(b.clientTop+parseFloat(v.paddingTop))*y.y;c*=y.x,u*=y.y,d*=y.x,f*=y.y,c+=x,u+=w,g=Ka(b),b=p4(g)}}return kC({width:d,height:f,x:c,y:u})}function XN(e,t){const n=qN(e).scrollLeft;return t?t.left+n:Lg(mh(e)).left+n}function kce(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-XN(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function M3e(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",a=mh(r),l=t?HN(t.floating):!1;if(r===a||l&&s)return n;let c={scrollLeft:0,scrollTop:0},u=Lf(1);const d=Lf(0),f=kd(r);if((f||!s)&&((G1(r)!=="body"||VN(a))&&(c=qN(r)),f)){const m=Lg(r);u=py(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const h=a&&!f&&!s?kce(a,c):Lf(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function L3e(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function $3e(e){const t=qN(e),n=e.ownerDocument.body,r=Mf(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Mf(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-t.scrollLeft+XN(e);const a=-t.scrollTop;return gd(n).direction==="rtl"&&(s+=Mf(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:s,y:a}}const B3e=25;function Q3e(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=Ka(e),s=mh(e),a=i.visualViewport;let l=s.clientWidth,c=s.clientHeight,u=0,d=0;if(a){const h=!V9()||t==="fixed";r?h||(u=-a.offsetLeft,d=-a.offsetTop):(l=a.width,c=a.height,h&&(u=a.offsetLeft,d=a.offsetTop))}if(XN(s)<=0){const h=s.ownerDocument,m=h.body,g=getComputedStyle(m),b=h.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,y=Math.abs(s.clientWidth-m.clientWidth-b),O=getComputedStyle(s).scrollbarGutter==="stable both-edges"?y/2:y;O<=B3e&&(l-=O)}return{width:l,height:c,x:u,y:d}}function U3e(e,t){const n=Lg(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=py(e),a=e.clientWidth*s.x,l=e.clientHeight*s.y,c=i*s.x,u=r*s.y;return{width:a,height:l,x:c,y:u}}function eq(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=Q3e(e,n,t);else if(t==="document")r=$3e(mh(e));else if(md(t))r=U3e(t,n);else{const i=Ece(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return kC(r)}function F3e(e,t){const n=t.get(e);if(n)return n;let r=Ew(e,[],!1).filter(l=>md(l)&&G1(l)!=="body"),i=null;const s=gd(e).position==="fixed";let a=s?Mg(e):e;for(;md(a)&&!Sw(a);){const l=gd(a),c=z9(a),u=i?i.position:s?"fixed":"";!c&&(u==="fixed"||u==="absolute"&&l.position==="static")?r=r.filter(f=>f!==a):i=l,a=Mg(a)}return t.set(e,r),r}function z3e(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?HN(t)?[]:F3e(t,this._c):[].concat(n),r],l=eq(t,a[0],i);let c=l.top,u=l.right,d=l.bottom,f=l.left;for(let h=1;h{l(!1,1e-7)},1e3)}k=!1}try{r=new IntersectionObserver(_,{...E,root:s.ownerDocument})}catch{r=new IntersectionObserver(_,E)}r.observe(e)}const c=Ka(e),u=()=>l(n);return c.addEventListener("resize",u),l(!0),()=>{c.removeEventListener("resize",u),a()}}function Y3e(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=H9(e),d=i||s?[...u?Ew(u):[],...t?Ew(t):[]]:[];d.forEach(O=>{i&&O.addEventListener("scroll",n),s&&O.addEventListener("resize",n)});const f=u&&l?W3e(u,n,s):null;let h=-1,m=null;a&&(m=new ResizeObserver(O=>{let[v]=O;v&&v.target===u&&m&&t&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var x;(x=m)==null||x.observe(t)})),n()}),u&&!c&&m.observe(u),t&&m.observe(t));let g,b=c?Lg(e):null;c&&y();function y(){const O=Lg(e);b&&!Tce(b,O)&&n(),b=O,g=requestAnimationFrame(y)}return n(),()=>{var O;d.forEach(v=>{i&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),f==null||f(),(O=m)==null||O.disconnect(),m=null,c&&cancelAnimationFrame(g)}}const Z3e=_3e,K3e=T3e,J3e=S3e,eMe=A3e,tMe=E3e,nq=w3e,nMe=C3e,rMe=(e,t,n)=>{const r=new Map,i=n??{},s={...G3e,...i.platform,_c:r};return v3e(e,t,{...i,platform:s})};var iMe=typeof document<"u",sMe=function(){},W_=iMe?p.useLayoutEffect:sMe;function _C(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!_C(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!_C(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Cce(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function rq(e,t){const n=Cce(e);return Math.round(t*n)/n}function _5(e){const t=p.useRef(e);return W_(()=>{t.current=e}),t}function aMe(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:a}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[d,f]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=p.useState(r);_C(h,r)||m(r);const[g,b]=p.useState(null),[y,O]=p.useState(null),v=p.useCallback(Q=>{Q!==E.current&&(E.current=Q,b(Q))},[]),x=p.useCallback(Q=>{Q!==k.current&&(k.current=Q,O(Q))},[]),w=s||g,S=a||y,E=p.useRef(null),k=p.useRef(null),_=p.useRef(d),C=c!=null,T=_5(c),A=_5(i),j=_5(u),L=p.useCallback(()=>{if(!E.current||!k.current)return;const Q={placement:t,strategy:n,middleware:h};A.current&&(Q.platform=A.current),rMe(E.current,k.current,Q).then(F=>{const $={...F,isPositioned:j.current!==!1};I.current&&!_C(_.current,$)&&(_.current=$,Cr.flushSync(()=>{f($)}))})},[h,t,n,A,j]);W_(()=>{u===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,f(Q=>({...Q,isPositioned:!1})))},[u]);const I=p.useRef(!1);W_(()=>(I.current=!0,()=>{I.current=!1}),[]),W_(()=>{if(w&&(E.current=w),S&&(k.current=S),w&&S){if(T.current)return T.current(w,S,L);L()}},[w,S,L,T,C]);const M=p.useMemo(()=>({reference:E,floating:k,setReference:v,setFloating:x}),[v,x]),N=p.useMemo(()=>({reference:w,floating:S}),[w,S]),D=p.useMemo(()=>{const Q={position:n,left:0,top:0};if(!N.floating)return Q;const F=rq(N.floating,d.x),$=rq(N.floating,d.y);return l?{...Q,transform:"translate("+F+"px, "+$+"px)",...Cce(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:$}},[n,l,N.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:L,refs:M,elements:N,floatingStyles:D}),[d,L,M,N,D])}const oMe=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?nq({element:r.current,padding:i}).fn(n):{}:r?nq({element:r,padding:i}).fn(n):{}}}},lMe=(e,t)=>{const n=Z3e(e);return{name:n.name,fn:n.fn,options:[e,t]}},cMe=(e,t)=>{const n=K3e(e);return{name:n.name,fn:n.fn,options:[e,t]}},uMe=(e,t)=>({fn:nMe(e).fn,options:[e,t]}),dMe=(e,t)=>{const n=J3e(e);return{name:n.name,fn:n.fn,options:[e,t]}},fMe=(e,t)=>{const n=eMe(e);return{name:n.name,fn:n.fn,options:[e,t]}},hMe=(e,t)=>{const n=tMe(e);return{name:n.name,fn:n.fn,options:[e,t]}},pMe=(e,t)=>{const n=oMe(e);return{name:n.name,fn:n.fn,options:[e,t]}};var mMe=Object.defineProperty,Cp=(e,t)=>mMe(e,"name",{value:t,configurable:!0}),Ace="Popper",[Nce,W1]=rl(Ace),[gMe,jce]=Nce(Ace),bMe=Cp(e=>{const{__scopePopper:t,children:n}=e,[r,i]=p.useState(null),[s,a]=p.useState(void 0);return o.jsx(gMe,{scope:t,anchor:r,onAnchorChange:i,placementState:s,setPlacementState:a,children:n})},"Popper"),yMe="PopperAnchor",OMe=p.forwardRef(Cp(function(t,n){const{__scopePopper:r,virtualRef:i,...s}=t,a=jce(yMe,r),l=p.useRef(null),c=a.onAnchorChange,u=p.useCallback(b=>{l.current=b,b&&c(b)},[c]),d=zr(n,u),f=p.useRef(null);p.useEffect(()=>{if(!i)return;const b=f.current;f.current=i.current,b!==f.current&&c(f.current)});const h=a.placementState&&GN(a.placementState),m=h==null?void 0:h[0],g=h==null?void 0:h[1];return i?null:o.jsx(pi.div,{"data-radix-popper-side":m,"data-radix-popper-align":g,...s,ref:d})},"PopperAnchor")),Rce="PopperContent",[xMe,iMt]=Nce(Rce),vMe=p.forwardRef(Cp(function(t,n){var q,X,K,de,xe,Me,Ae;const{__scopePopper:r,side:i="bottom",sideOffset:s=0,align:a="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:g="optimized",onPlaced:b,...y}=t,O=jce(Rce,r),[v,x]=p.useState(null),w=zr(n,x),[S,E]=p.useState(null),k=KS(S),_=(k==null?void 0:k.width)??0,C=(k==null?void 0:k.height)??0,T=i+(a!=="center"?"-"+a:""),A=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},j=Array.isArray(d)?d:[d],L=j.length>0,I={padding:A,boundary:j.filter(Ice),altBoundary:L},{refs:M,floatingStyles:N,placement:D,isPositioned:Q,middlewareData:F}=aMe({strategy:"fixed",placement:T,whileElementsMounted:Cp((...He)=>Y3e(...He,{animationFrame:g==="always"}),"whileElementsMounted"),elements:{reference:O.anchor},middleware:[lMe({mainAxis:s+C,alignmentAxis:l}),u&&cMe({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?uMe():void 0,...I}),u&&dMe({...I}),fMe({...I,apply:Cp(({elements:He,rects:et,availableWidth:Te,availableHeight:Re})=>{const{width:he,height:me}=et.reference,Se=He.floating.style;Se.setProperty("--radix-popper-available-width",`${Te}px`),Se.setProperty("--radix-popper-available-height",`${Re}px`),Se.setProperty("--radix-popper-anchor-width",`${he}px`),Se.setProperty("--radix-popper-anchor-height",`${me}px`)},"apply")}),S&&pMe({element:S,padding:c}),wMe({arrowWidth:_,arrowHeight:C}),m&&hMe({strategy:"referenceHidden",...I,boundary:L?I.boundary:void 0})]}),$=O.setPlacementState;Ic(()=>($(D),()=>{$(void 0)}),[D,$]);const[H,z]=GN(D),B=yu(b);Ic(()=>{Q&&(B==null||B())},[Q,B]);const V=(q=F.arrow)==null?void 0:q.x,Z=(X=F.arrow)==null?void 0:X.y,ce=((K=F.arrow)==null?void 0:K.centerOffset)!==0,[be,ie]=p.useState();return Ic(()=>{v&&ie(window.getComputedStyle(v).zIndex)},[v]),o.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...N,transform:Q?N.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:be,"--radix-popper-transform-origin":[(de=F.transformOrigin)==null?void 0:de.x,(xe=F.transformOrigin)==null?void 0:xe.y].join(" "),...((Me=F.hide)==null?void 0:Me.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:o.jsx(xMe,{scope:r,placedSide:H,placedAlign:z,onArrowChange:E,arrowX:V,arrowY:Z,shouldHideArrow:ce,children:o.jsx(pi.div,{"data-side":H,"data-align":z,...y,ref:w,style:{...y.style,animation:Q?(Ae=y.style)==null?void 0:Ae.animation:"none"}})})})},"PopperContent"));function Ice(e){return e!==null}Cp(Ice,"isNotNull");var wMe=Cp(e=>({name:"transformOrigin",options:e,fn(t){var y,O,v;const{placement:n,rects:r,middlewareData:i}=t,a=((y=i.arrow)==null?void 0:y.centerOffset)!==0,l=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[u,d]=GN(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((O=i.arrow)==null?void 0:O.x)??0)+l/2,m=(((v=i.arrow)==null?void 0:v.y)??0)+c/2;let g="",b="";return u==="bottom"?(g=a?f:`${h}px`,b=`${-c}px`):u==="top"?(g=a?f:`${h}px`,b=`${r.floating.height+c}px`):u==="right"?(g=`${-c}px`,b=a?f:`${m}px`):u==="left"&&(g=`${r.floating.width+c}px`,b=a?f:`${m}px`),{data:{x:g,y:b}}}}),"transformOrigin");function GN(e){const[t,n="center"]=e.split("-");return[t,n]}Cp(GN,"getSideAndAlignFromPlacement");var WN=bMe,q9=OMe,X9=vMe,SMe=Object.defineProperty,G9=(e,t)=>SMe(e,"name",{value:t,configurable:!0}),T5=!1;function Dce(){const[e,t]=p.useState(T5);return p.useEffect(()=>{T5||(T5=!0,t(!0))},[]),e}G9(Dce,"useIsHydrated");var Pce=r0[" useSyncExternalStore ".trim().toString()];function Mce(){return()=>{}}G9(Mce,"subscribe");function Lce(){return Pce(Mce,()=>!0,()=>!1)}G9(Lce,"useIsHydratedModern");var EMe=typeof Pce=="function"?Lce:Dce,kMe=Object.defineProperty,f0=(e,t)=>kMe(e,"name",{value:t,configurable:!0}),C5="rovingFocusGroup.onEntryFocus",_Me={bubbles:!1,cancelable:!0},YN="RovingFocusGroup",[m4,$ce,TMe]=A9(YN),[CMe,Y1]=rl(YN,[TMe]),[AMe,NMe]=CMe(YN),jMe=p.forwardRef(f0(function(t,n){return o.jsx(m4.Provider,{scope:t.__scopeRovingFocusGroup,children:o.jsx(m4.Slot,{scope:t.__scopeRovingFocusGroup,children:o.jsx(RMe,{...t,ref:n})})})},"RovingFocusGroup")),RMe=p.forwardRef(f0(function(t,n){const{__scopeRovingFocusGroup:r,orientation:i,loop:s=!1,dir:a,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...h}=t,m=p.useRef(null),g=zr(n,m),b=ZS(a),[y,O]=Bc({prop:l,defaultProp:c??null,onChange:u,caller:YN}),[v,x]=p.useState(!1),w=yu(d),S=$ce(r),E=p.useRef(!1),[k,_]=p.useState(0);return p.useEffect(()=>{const C=m.current;if(C)return C.addEventListener(C5,w),()=>C.removeEventListener(C5,w)},[w]),o.jsx(AMe,{scope:r,orientation:i,dir:b,loop:s,currentTabStopId:y,onItemFocus:p.useCallback(C=>O(C),[O]),onItemShiftTab:p.useCallback(()=>x(!0),[]),onFocusableItemAdd:p.useCallback(()=>_(C=>C+1),[]),onFocusableItemRemove:p.useCallback(()=>_(C=>C-1),[]),children:o.jsx(pi.div,{tabIndex:v||k===0?-1:0,"data-orientation":i,...h,ref:g,style:{outline:"none",...t.style},onMouseDown:mn(t.onMouseDown,()=>{E.current=!0}),onFocus:mn(t.onFocus,C=>{const T=!E.current;if(C.target===C.currentTarget&&T&&!v){const A=new CustomEvent(C5,_Me);if(C.currentTarget.dispatchEvent(A),!A.defaultPrevented){const j=S().filter(D=>D.focusable),L=j.find(D=>D.active),I=j.find(D=>D.id===y),N=[L,I,...j].filter(Boolean).map(D=>D.ref.current);W9(N,f)}}E.current=!1}),onBlur:mn(t.onBlur,()=>x(!1))})})},"RovingFocusGroupImpl")),IMe="RovingFocusGroupItem",DMe=p.forwardRef(f0(function(t,n){const{__scopeRovingFocusGroup:r,focusable:i=!0,active:s=!1,tabStopId:a,children:l,...c}=t,u=Fp(),d=a||u,f=NMe(IMe,r),h=f.currentTabStopId===d,m=$ce(r),{onFocusableItemAdd:g,onFocusableItemRemove:b,currentTabStopId:y}=f,O=EMe();return Ic(()=>{if(!(!O||!i))return g(),()=>b()},[O,i,g,b]),p.useEffect(()=>{if(!(O||!i))return g(),()=>b()},[O,i,g,b]),o.jsx(m4.ItemSlot,{scope:r,id:d,focusable:i,active:s,children:o.jsx(pi.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...c,ref:n,onMouseDown:mn(t.onMouseDown,v=>{i?f.onItemFocus(d):v.preventDefault()}),onFocus:mn(t.onFocus,()=>f.onItemFocus(d)),onKeyDown:mn(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const x=Qce(v,f.orientation,f.dir);if(x!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let S=m().filter(E=>E.focusable).map(E=>E.ref.current);if(x==="last")S.reverse();else if(x==="prev"||x==="next"){x==="prev"&&S.reverse();const E=S.indexOf(v.currentTarget);S=f.loop?Uce(S,E+1):S.slice(E+1)}setTimeout(()=>W9(S))}}),children:typeof l=="function"?l({isCurrentTabStop:h,hasTabStop:y!=null}):l})})},"RovingFocusGroupItem")),PMe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Bce(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}f0(Bce,"getDirectionAwareKey");function Qce(e,t,n){const r=Bce(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return PMe[r]}f0(Qce,"getFocusIntent");function W9(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}f0(W9,"focusFirst");function Uce(e,t){return e.map((n,r)=>e[(t+r)%e.length])}f0(Uce,"wrapArray");var Y9=jMe,Z9=DMe,MMe=Object.defineProperty,Ir=(e,t)=>MMe(e,"name",{value:t,configurable:!0}),g4=["Enter"," "],LMe=["ArrowDown","PageUp","Home"],Fce=["ArrowUp","PageDown","End"],$Me=[...LMe,...Fce],BMe={ltr:[...g4,"ArrowRight"],rtl:[...g4,"ArrowLeft"]},QMe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ZN="Menu",[kw,UMe,FMe]=A9(ZN),[h0,zce]=rl(ZN,[FMe,W1,Y1]),KN=W1(),Vce=Y1(),[Hce,um]=h0(ZN),[zMe,JS]=h0(ZN),VMe=Ir(e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:a=!0}=e,l=KN(t),[c,u]=p.useState(null),d=p.useRef(!1),f=yu(s),h=ZS(i);return p.useEffect(()=>{const m=Ir(()=>{d.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},"handleKeyDown"),g=Ir(()=>d.current=!1,"handlePointer");return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),p.useEffect(()=>{if(!n)return;const m=Ir(()=>f(!1),"handleBlur");return window.addEventListener("blur",m),()=>window.removeEventListener("blur",m)},[n,f]),o.jsx(WN,{...l,children:o.jsx(Hce,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:o.jsx(zMe,{scope:t,onClose:p.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:a,children:r})})})},"Menu"),qce=p.forwardRef(Ir(function(t,n){const{__scopeMenu:r,...i}=t,s=KN(r);return o.jsx(q9,{...s,...i,ref:n})},"MenuAnchor")),Xce="MenuPortal",[HMe,Gce]=h0(Xce,{forceMount:void 0}),qMe=Ir(e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=um(Xce,t);return o.jsx(HMe,{scope:t,forceMount:n,children:o.jsx(Ed,{present:n||s.open,children:o.jsx(D9,{asChild:!0,container:i,children:r})})})},"MenuPortal"),pu="MenuContent",[XMe,K9]=h0(pu),GMe=p.forwardRef(Ir(function(t,n){const r=Gce(pu,t.__scopeMenu),{forceMount:i=r.forceMount,...s}=t,a=um(pu,t.__scopeMenu),l=JS(pu,t.__scopeMenu);return o.jsx(kw.Provider,{scope:t.__scopeMenu,children:o.jsx(Ed,{present:i||a.open,children:o.jsx(kw.Slot,{scope:t.__scopeMenu,children:l.modal?o.jsx(WMe,{...s,ref:n}):o.jsx(YMe,{...s,ref:n})})})})},"MenuContent")),WMe=p.forwardRef(Ir(function(t,n){const r=um(pu,t.__scopeMenu),i=p.useRef(null),s=zr(n,i);return p.useEffect(()=>{const a=i.current;if(a)return mce(a)},[]),o.jsx(J9,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:mn(t.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),YMe=p.forwardRef(Ir(function(t,n){const r=um(pu,t.__scopeMenu);return o.jsx(J9,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),ZMe=Jf("MenuContent.ScrollLock"),J9=p.forwardRef(Ir(function(t,n){const{__scopeMenu:r,loop:i=!1,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:l,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:m,onDismiss:g,disableOutsideScroll:b,...y}=t,O=um(pu,r),v=JS(pu,r),x=KN(r),w=Vce(r),S=UMe(r),[E,k]=p.useState(null),_=p.useRef(null),C=zr(n,_,O.onContentChange),T=p.useRef(0),A=p.useRef(""),j=p.useRef(0),L=p.useRef(null),I=p.useRef("right"),M=p.useRef(0),N=b?M9:p.Fragment,D=b?{as:ZMe,allowPinchZoom:!0}:void 0,Q=Ir($=>{var ie,q;const H=A.current+$,z=S().filter(X=>!X.disabled),B=document.activeElement,V=(ie=z.find(X=>X.ref.current===B))==null?void 0:ie.textValue,Z=z.map(X=>X.textValue),ce=nue(Z,H,V),be=(q=z.find(X=>X.textValue===ce))==null?void 0:q.ref.current;Ir(function X(K){A.current=K,window.clearTimeout(T.current),K!==""&&(T.current=window.setTimeout(()=>X(""),1e3))},"updateSearch")(H),be&&setTimeout(()=>be.focus())},"handleTypeaheadSearch");p.useEffect(()=>()=>window.clearTimeout(T.current),[]),UN();const F=p.useCallback($=>{var z,B;return I.current===((z=L.current)==null?void 0:z.side)&&iue($,(B=L.current)==null?void 0:B.area)},[]);return o.jsx(XMe,{scope:r,searchRef:A,onItemEnter:p.useCallback($=>{F($)&&$.preventDefault()},[F]),onItemLeave:p.useCallback($=>{var H;F($)||((H=_.current)==null||H.focus(),k(null))},[F]),onTriggerLeave:p.useCallback($=>{F($)&&$.preventDefault()},[F]),pointerGraceTimerRef:j,onPointerGraceIntentChange:p.useCallback($=>{L.current=$},[]),children:o.jsx(N,{...D,children:o.jsx(ece,{asChild:!0,trapped:s,onMountAutoFocus:mn(a,$=>{var H;$.preventDefault(),(H=_.current)==null||H.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:o.jsx(j9,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:m,onDismiss:g,children:o.jsx(Y9,{asChild:!0,...w,dir:v.dir,orientation:"vertical",loop:i,currentTabStopId:E,onCurrentTabStopIdChange:k,onEntryFocus:mn(u,$=>{v.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:o.jsx(X9,{role:"menu","aria-orientation":"vertical","data-state":t7(O.open),"data-radix-menu-content":"",dir:v.dir,...x,...y,ref:C,style:{outline:"none",...y.style},onKeyDown:mn(y.onKeyDown,$=>{const z=$.target.closest("[data-radix-menu-content]")===$.currentTarget,B=$.ctrlKey||$.altKey||$.metaKey,V=$.key.length===1;z&&($.key==="Tab"&&$.preventDefault(),!B&&V&&Q($.key));const Z=_.current;if($.target!==Z||!$Me.includes($.key))return;$.preventDefault();const be=S().filter(ie=>!ie.disabled).map(ie=>ie.ref.current);Fce.includes($.key)&&be.reverse(),eue(be)}),onBlur:mn(t.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(T.current),A.current="")}),onPointerMove:mn(t.onPointerMove,e1($=>{const H=$.target,z=M.current!==$.clientX;if($.currentTarget.contains(H)&&z){const B=$.clientX>M.current?"right":"left";I.current=B,M.current=$.clientX}}))})})})})})})},"MenuContentImpl")),KMe=p.forwardRef(Ir(function(t,n){const{__scopeMenu:r,...i}=t;return o.jsx(pi.div,{role:"group",...i,ref:n})},"MenuGroup")),b4="MenuItem",iq="menu.itemSelect",e7=p.forwardRef(Ir(function(t,n){const{disabled:r=!1,onSelect:i,...s}=t,a=p.useRef(null),l=JS(b4,t.__scopeMenu),c=K9(b4,t.__scopeMenu),u=zr(n,a),d=p.useRef(!1),f=Ir(()=>{const h=a.current;if(!r&&h){const m=new CustomEvent(iq,{bubbles:!0,cancelable:!0});h.addEventListener(iq,g=>i==null?void 0:i(g),{once:!0}),C9(h,m),m.defaultPrevented?d.current=!1:l.onClose()}},"handleSelect");return o.jsx(Wce,{...s,ref:u,disabled:r,onClick:mn(t.onClick,f),onPointerDown:h=>{var m;(m=t.onPointerDown)==null||m.call(t,h),d.current=!0},onPointerUp:mn(t.onPointerUp,h=>{var m;d.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:mn(t.onKeyDown,h=>{r||h.target!==h.currentTarget||c.searchRef.current!==""&&h.key===" "||g4.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})},"MenuItem")),Wce=p.forwardRef(Ir(function(t,n){const{__scopeMenu:r,disabled:i=!1,textValue:s,...a}=t,l=K9(b4,r),c=Vce(r),u=p.useRef(null),d=zr(n,u),[f,h]=p.useState(!1),[m,g]=p.useState("");return p.useEffect(()=>{const b=u.current;b&&g((b.textContent??"").trim())},[a.children]),o.jsx(kw.ItemSlot,{scope:r,disabled:i,textValue:s??m,children:o.jsx(Z9,{asChild:!0,...c,focusable:!i,children:o.jsx(pi.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...a,ref:d,onPointerMove:mn(t.onPointerMove,e1(b=>{i?l.onItemLeave(b):(l.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:mn(t.onPointerLeave,e1(b=>l.onItemLeave(b))),onFocus:mn(t.onFocus,()=>h(!0)),onBlur:mn(t.onBlur,()=>h(!1))})})})},"MenuItemImpl")),JMe=p.forwardRef(Ir(function(t,n){const{checked:r=!1,onCheckedChange:i,...s}=t;return o.jsx(Zce,{scope:t.__scopeMenu,checked:r,children:o.jsx(e7,{role:"menuitemcheckbox","aria-checked":_w(r)?"mixed":r,...s,ref:n,"data-state":JN(r),onSelect:mn(s.onSelect,()=>i==null?void 0:i(_w(r)?!0:!r),{checkForDefaultPrevented:!1})})})},"MenuCheckboxItem")),e4e="MenuRadioGroup",[t4e,n4e]=h0(e4e,{value:void 0,onValueChange:Ir(()=>{},"onValueChange")}),r4e=p.forwardRef(Ir(function(t,n){const{value:r,onValueChange:i,...s}=t,a=yu(i);return o.jsx(t4e,{scope:t.__scopeMenu,value:r,onValueChange:a,children:o.jsx(KMe,{...s,ref:n})})},"MenuRadioGroup")),i4e="MenuRadioItem",s4e=p.forwardRef(Ir(function(t,n){const{value:r,...i}=t,s=n4e(i4e,t.__scopeMenu),a=r===s.value;return o.jsx(Zce,{scope:t.__scopeMenu,checked:a,children:o.jsx(e7,{role:"menuitemradio","aria-checked":a,...i,ref:n,"data-state":JN(a),onSelect:mn(i.onSelect,()=>{var l;return(l=s.onValueChange)==null?void 0:l.call(s,r)},{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),Yce="MenuItemIndicator",[Zce,a4e]=h0(Yce,{checked:!1}),o4e=p.forwardRef(Ir(function(t,n){const{__scopeMenu:r,forceMount:i,...s}=t,a=a4e(Yce,r);return o.jsx(Ed,{present:i||_w(a.checked)||a.checked===!0,children:o.jsx(pi.span,{...s,ref:n,"data-state":JN(a.checked)})})},"MenuItemIndicator")),l4e=p.forwardRef(Ir(function(t,n){const{__scopeMenu:r,...i}=t;return o.jsx(pi.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})},"MenuSeparator")),Kce="MenuSub",[c4e,Jce]=h0(Kce),u4e=Ir(e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=um(Kce,t),a=KN(t),[l,c]=p.useState(null),[u,d]=p.useState(null),f=yu(i);return p.useEffect(()=>(s.open===!1&&f(!1),()=>f(!1)),[s.open,f]),o.jsx(WN,{...a,children:o.jsx(Hce,{scope:t,open:r,onOpenChange:f,content:u,onContentChange:d,children:o.jsx(c4e,{scope:t,contentId:Fp(),triggerId:Fp(),trigger:l,onTriggerChange:c,children:n})})})},"MenuSub"),e2="MenuSubTrigger",d4e=p.forwardRef(Ir(function(t,n){const r=um(e2,t.__scopeMenu),i=JS(e2,t.__scopeMenu),s=Jce(e2,t.__scopeMenu),a=K9(e2,t.__scopeMenu),l=p.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=a,d={__scopeMenu:t.__scopeMenu},f=p.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);p.useEffect(()=>f,[f]),p.useEffect(()=>{const m=c.current;return()=>{window.clearTimeout(m),u(null)}},[c,u]);const h=zr(n,s.onTriggerChange);return o.jsx(qce,{asChild:!0,...d,children:o.jsx(Wce,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":r.open?s.contentId:void 0,"data-state":t7(r.open),...t,ref:h,onClick:m=>{var g;(g=t.onClick)==null||g.call(t,m),!(t.disabled||m.defaultPrevented)&&(m.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:mn(t.onPointerMove,e1(m=>{a.onItemEnter(m),!m.defaultPrevented&&!t.disabled&&!r.open&&!l.current&&(a.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),f()},100))})),onPointerLeave:mn(t.onPointerLeave,e1(m=>{var b,y;f();const g=(b=r.content)==null?void 0:b.getBoundingClientRect();if(g){const O=(y=r.content)==null?void 0:y.dataset.side,v=O==="right",x=v?-5:5,w=g[v?"left":"right"],S=g[v?"right":"left"];a.onPointerGraceIntentChange({area:[{x:m.clientX+x,y:m.clientY},{x:w,y:g.top},{x:S,y:g.top},{x:S,y:g.bottom},{x:w,y:g.bottom}],side:O}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(m),m.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:mn(t.onKeyDown,m=>{var b;t.disabled||m.target!==m.currentTarget||a.searchRef.current!==""&&m.key===" "||BMe[i.dir].includes(m.key)&&(r.onOpenChange(!0),(b=r.content)==null||b.focus(),m.preventDefault())})})})},"MenuSubTrigger")),f4e="MenuSubContent",h4e=p.forwardRef(Ir(function(t,n){const r=Gce(pu,t.__scopeMenu),{forceMount:i=r.forceMount,align:s="start",...a}=t,l=um(pu,t.__scopeMenu),c=JS(pu,t.__scopeMenu),u=Jce(f4e,t.__scopeMenu),d=p.useRef(null),f=zr(n,d);return o.jsx(kw.Provider,{scope:t.__scopeMenu,children:o.jsx(Ed,{present:i||l.open,children:o.jsx(kw.Slot,{scope:t.__scopeMenu,children:o.jsx(J9,{id:u.contentId,"aria-labelledby":u.triggerId,...a,ref:f,align:s,side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:h=>{var m;c.isUsingKeyboardRef.current&&((m=d.current)==null||m.focus()),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:mn(t.onFocusOutside,h=>{h.target!==u.trigger&&l.onOpenChange(!1)}),onEscapeKeyDown:mn(t.onEscapeKeyDown,h=>{c.onClose(),h.preventDefault()}),onKeyDown:mn(t.onKeyDown,h=>{var b;const m=h.currentTarget.contains(h.target),g=QMe[c.dir].includes(h.key);m&&g&&(l.onOpenChange(!1),(b=u.trigger)==null||b.focus(),h.preventDefault())})})})})})},"MenuSubContent"));function t7(e){return e?"open":"closed"}Ir(t7,"getOpenState");function _w(e){return e==="indeterminate"}Ir(_w,"isIndeterminate");function JN(e){return _w(e)?"indeterminate":e?"checked":"unchecked"}Ir(JN,"getCheckedState");function eue(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Ir(eue,"focusFirst");function tue(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Ir(tue,"wrapArray");function nue(e,t,n){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let a=tue(e,Math.max(s,0));i.length===1&&(a=a.filter(u=>u!==n));const c=a.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}Ir(nue,"getNextMatch");function rue(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,a=t.length-1;sr!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(i=!i)}return i}Ir(rue,"isPointInPolygon");function iue(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return rue(n,t)}Ir(iue,"isPointerInGraceArea");function e1(e){return t=>t.pointerType==="mouse"?e(t):void 0}Ir(e1,"whenMouse");var p4e=VMe,m4e=qce,g4e=qMe,b4e=GMe,y4e=e7,O4e=JMe,x4e=r4e,v4e=s4e,w4e=o4e,S4e=l4e,E4e=u4e,k4e=d4e,_4e=h4e,T4e=Object.defineProperty,Hl=(e,t)=>T4e(e,"name",{value:t,configurable:!0}),n7="DropdownMenu",[C4e,sMt]=rl(n7,[zce]),ql=zce(),[A4e,sue]=C4e(n7),N4e=Hl(e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:a,modal:l=!0}=e,c=ql(t),u=p.useRef(null),[d,f]=Bc({prop:i,defaultProp:s??!1,onChange:a,caller:n7});return o.jsx(A4e,{scope:t,triggerId:Fp(),triggerRef:u,contentId:Fp(),open:d,onOpenChange:f,onOpenToggle:p.useCallback(()=>f(h=>!h),[f]),modal:l,children:o.jsx(p4e,{...c,open:d,onOpenChange:f,dir:r,modal:l,children:n})})},"DropdownMenu"),j4e="DropdownMenuTrigger",R4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,disabled:i=!1,...s}=t,a=sue(j4e,r),l=ql(r),c=zr(n,a.triggerRef);return o.jsx(m4e,{asChild:!0,...l,children:o.jsx(pi.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...s,ref:c,onPointerDown:mn(t.onPointerDown,u=>{!i&&u.button===0&&u.ctrlKey===!1&&(a.onOpenToggle(),a.open||u.preventDefault())}),onKeyDown:mn(t.onKeyDown,u=>{i||(["Enter"," "].includes(u.key)&&a.onOpenToggle(),u.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),I4e=Hl(e=>{const{__scopeDropdownMenu:t,...n}=e,r=ql(t);return o.jsx(g4e,{...r,...n})},"DropdownMenuPortal"),D4e="DropdownMenuContent",P4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=sue(D4e,r),a=ql(r),l=p.useRef(!1);return o.jsx(b4e,{id:s.contentId,"aria-labelledby":s.triggerId,...a,...i,ref:n,onCloseAutoFocus:mn(t.onCloseAutoFocus,c=>{var u;l.current||(u=s.triggerRef.current)==null||u.focus(),l.current=!1,c.preventDefault()}),onInteractOutside:mn(t.onInteractOutside,c=>{const u=c.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,f=u.button===2||d;(!s.modal||f)&&(l.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),M4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(y4e,{...s,...i,ref:n})},"DropdownMenuItem")),L4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(O4e,{...s,...i,ref:n})},"DropdownMenuCheckboxItem")),$4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(x4e,{...s,...i,ref:n})},"DropdownMenuRadioGroup")),B4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(v4e,{...s,...i,ref:n})},"DropdownMenuRadioItem")),Q4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(w4e,{...s,...i,ref:n})},"DropdownMenuItemIndicator")),U4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(S4e,{...s,...i,ref:n})},"DropdownMenuSeparator")),F4e=Hl(e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,a=ql(t),[l,c]=Bc({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return o.jsx(E4e,{...a,open:l,onOpenChange:c,children:n})},"DropdownMenuSub"),z4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(k4e,{...s,...i,ref:n})},"DropdownMenuSubTrigger")),V4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(_4e,{...s,...i,ref:n,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuSubContent")),H4e=N4e,q4e=R4e,aue=I4e,X4e=P4e,oue=M4e,G4e=L4e,W4e=$4e,Y4e=B4e,lue=Q4e,Z4e=U4e,K4e=F4e,J4e=z4e,eLe=V4e,tLe=Object.defineProperty,dm=(e,t)=>tLe(e,"name",{value:t,configurable:!0}),r7="Popover",[cue,aMt]=rl(r7,[W1]),i7=W1(),[nLe,Z1]=cue(r7),rLe=dm(e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:a=!1}=e,l=i7(t),c=p.useRef(null),[u,d]=p.useState(!1),[f,h]=Bc({prop:r,defaultProp:i??!1,onChange:s,caller:r7});return o.jsx(WN,{...l,children:o.jsx(nLe,{scope:t,contentId:Fp(),triggerRef:c,open:f,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(m=>!m),[h]),hasCustomAnchor:u,onCustomAnchorAdd:p.useCallback(()=>d(!0),[]),onCustomAnchorRemove:p.useCallback(()=>d(!1),[]),modal:a,children:n})})},"Popover"),iLe="PopoverTrigger",sLe=p.forwardRef(dm(function(t,n){const{__scopePopover:r,...i}=t,s=Z1(iLe,r),a=i7(r),l=zr(n,s.triggerRef),c=o.jsx(pi.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s7(s.open),...i,ref:l,onClick:mn(t.onClick,s.onOpenToggle)});return s.hasCustomAnchor?c:o.jsx(q9,{asChild:!0,...a,children:c})},"PopoverTrigger")),uue="PopoverPortal",[aLe,oLe]=cue(uue,{forceMount:void 0}),lLe=dm(e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,s=Z1(uue,t);return o.jsx(aLe,{scope:t,forceMount:n,children:o.jsx(Ed,{present:n||s.open,children:o.jsx(D9,{asChild:!0,container:i,children:r})})})},"PopoverPortal"),Tw="PopoverContent",cLe=p.forwardRef(dm(function(t,n){const r=oLe(Tw,t.__scopePopover),{forceMount:i=r.forceMount,...s}=t,a=Z1(Tw,t.__scopePopover);return o.jsx(Ed,{present:i||a.open,children:a.modal?o.jsx(dLe,{...s,ref:n}):o.jsx(fLe,{...s,ref:n})})},"PopoverContent")),uLe=Jf("PopoverContent.RemoveScroll"),dLe=p.forwardRef(dm(function(t,n){const r=Z1(Tw,t.__scopePopover),i=p.useRef(null),s=zr(n,i),a=p.useRef(!1);return p.useEffect(()=>{const l=i.current;if(l)return mce(l)},[]),o.jsx(M9,{as:uLe,allowPinchZoom:!0,children:o.jsx(due,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:mn(t.onCloseAutoFocus,l=>{var c;l.preventDefault(),a.current||(c=r.triggerRef.current)==null||c.focus()}),onPointerDownOutside:mn(t.onPointerDownOutside,l=>{const c=l.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;a.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:mn(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),fLe=p.forwardRef(dm(function(t,n){const r=Z1(Tw,t.__scopePopover),i=p.useRef(!1),s=p.useRef(!1);return o.jsx(due,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var l,c;(l=t.onCloseAutoFocus)==null||l.call(t,a),a.defaultPrevented||(i.current||(c=r.triggerRef.current)==null||c.focus(),a.preventDefault()),i.current=!1,s.current=!1},onInteractOutside:a=>{var u,d;(u=t.onInteractOutside)==null||u.call(t,a),a.defaultPrevented||(i.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const l=a.target;((d=r.triggerRef.current)==null?void 0:d.contains(l))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})},"PopoverContentNonModal")),due=p.forwardRef(dm(function(t,n){const{__scopePopover:r,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,...h}=t,m=Z1(Tw,r),g=i7(r);return UN(),o.jsx(ece,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:s,onUnmountAutoFocus:a,children:o.jsx(j9,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:f,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onDismiss:()=>m.onOpenChange(!1),deferPointerDownOutside:!0,children:o.jsx(X9,{"data-state":s7(m.open),role:"dialog",id:m.contentId,...g,...h,ref:n,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})},"PopoverContentImpl"));function s7(e){return e?"open":"closed"}dm(s7,"getState");var fue=rLe,hue=sLe,pue=lLe,mue=cLe,hLe=Object.defineProperty,Ja=(e,t)=>hLe(e,"name",{value:t,configurable:!0}),gue="Radio",[pLe,bue]=rl(gue),[mLe,ej]=pLe(gue);function yue(e){const{__scopeRadio:t,checked:n=!1,children:r,disabled:i,form:s,name:a,onCheck:l,required:c,value:u="on",internal_do_not_use_render:d}=e,[f,h]=p.useState(null),[m,g]=p.useState(null),b=p.useRef(!1),[y,O]=p.useReducer(w=>w+1,0),v=f?!!s||!!f.closest("form"):!0,x={checked:n,disabled:i,required:c,name:a,form:s,value:u,control:f,setControl:h,hasConsumerStoppedPropagationRef:b,userInteractionCount:y,onUserInteraction:O,isFormControl:v,bubbleInput:m,setBubbleInput:g,onCheck:Ja(()=>l==null?void 0:l(),"onCheck")};return o.jsx(mLe,{scope:t,...x,children:Oue(d)?d(x):r})}Ja(yue,"RadioProvider");var gLe="RadioTrigger",bLe=p.forwardRef(Ja(function({__scopeRadio:t,onClick:n,...r},i){const{checked:s,disabled:a,value:l,setControl:c,onCheck:u,hasConsumerStoppedPropagationRef:d,onUserInteraction:f,isFormControl:h,bubbleInput:m}=ej(gLe,t),g=zr(i,c);return o.jsx(pi.button,{type:"button",role:"radio","aria-checked":s,"data-state":a7(s),"data-disabled":a?"":void 0,disabled:a,value:l,...r,ref:g,onClick:mn(n,b=>{s||(f(),u()),m&&h&&(d.current=b.isPropagationStopped(),d.current||b.stopPropagation())})})},"RadioTrigger")),yLe="RadioIndicator",OLe=p.forwardRef(Ja(function(t,n){const{__scopeRadio:r,forceMount:i,...s}=t,a=ej(yLe,r);return o.jsx(Ed,{present:i||a.checked,children:o.jsx(pi.span,{"data-state":a7(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:n})})},"RadioIndicator")),xLe="RadioBubbleInput",vLe=p.forwardRef(Ja(function({__scopeRadio:t,onClick:n,...r},i){const{control:s,checked:a,required:l,disabled:c,name:u,value:d,form:f,bubbleInput:h,setBubbleInput:m,hasConsumerStoppedPropagationRef:g,userInteractionCount:b}=ej(xLe,t),y=zr(i,m),O=KS(s),v=p.useRef(!1),x=p.useRef(a),w=p.useRef(b);p.useEffect(()=>{const E=h;if(!E)return;const k=window.HTMLInputElement.prototype,C=Object.getOwnPropertyDescriptor(k,"checked").set,T=b!==w.current;w.current=b;const A=x.current!==a;x.current=a;const j=!(T&&g.current);if(A&&C){v.current=!T;const L=new Event("click",{bubbles:j});C.call(E,a),E.dispatchEvent(L),v.current=!1}},[h,a,g,b]);const S=p.useRef(a);return o.jsx(pi.input,{type:"radio","aria-hidden":!0,defaultChecked:S.current,required:l,disabled:c,name:u,value:d,form:f,...r,tabIndex:-1,ref:y,onClick:mn(n,E=>{v.current&&E.stopPropagation()}),style:{...r.style,...O,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"RadioBubbleInput"));function Oue(e){return typeof e=="function"}Ja(Oue,"isFunction");function a7(e){return e?"checked":"unchecked"}Ja(a7,"getState");var wLe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],o7="RadioGroup",[SLe,oMt]=rl(o7,[Y1,bue]),xue=Y1(),tj=bue(),[ELe,kLe]=SLe(o7),_Le=p.forwardRef(Ja(function(t,n){const{__scopeRadioGroup:r,name:i,form:s,defaultValue:a,value:l,required:c=!1,disabled:u=!1,orientation:d,dir:f,loop:h=!0,onValueChange:m,...g}=t,b=xue(r),y=ZS(f),[O,v]=Bc({prop:l,defaultProp:a??null,onChange:m,caller:o7}),[x,w]=p.useState(null),S=zr(n,w),E=p.useRef(O);return p.useEffect(()=>{const k=s?x==null?void 0:x.ownerDocument.getElementById(s):x==null?void 0:x.closest("form");if(k instanceof HTMLFormElement){const _=Ja(()=>v(E.current),"reset");return k.addEventListener("reset",_),()=>k.removeEventListener("reset",_)}},[x,s,v]),o.jsx(ELe,{scope:r,name:i,form:s,required:c,disabled:u,value:O,onValueChange:v,children:o.jsx(Y9,{asChild:!0,...b,orientation:d,dir:y,loop:h,children:o.jsx(pi.div,{role:"radiogroup","aria-required":c,"aria-orientation":d,"data-disabled":u?"":void 0,dir:y,...g,ref:S})})})},"RadioGroup")),TLe="RadioGroupItemProvider",CLe="RadioGroupItemTrigger";function vue(e){const{__scopeRadioGroup:t,value:n,disabled:r,children:i,internal_do_not_use_render:s}=e,a=kLe(TLe,t),l=tj(t),c=a.disabled||r;return o.jsx(yue,{...l,checked:a.value===n,disabled:c,required:a.required,name:a.name,form:a.form,value:n,onCheck:()=>a.onValueChange(n),internal_do_not_use_render:s,children:i})}Ja(vue,"RadioGroupItemProvider");var ALe=p.forwardRef(Ja(function(t,n){const{__scopeRadioGroup:r,...i}=t,s=xue(r),a=tj(r),{checked:l,disabled:c}=ej(CLe,a.__scopeRadio),u=p.useRef(null),d=zr(n,u),f=p.useRef(!1);return p.useEffect(()=>{const h=Ja(g=>{wLe.includes(g.key)&&(f.current=!0)},"handleKeyDown"),m=Ja(()=>f.current=!1,"handleKeyUp");return document.addEventListener("keydown",h),document.addEventListener("keyup",m),()=>{document.removeEventListener("keydown",h),document.removeEventListener("keyup",m)}},[]),o.jsx(Z9,{asChild:!0,...s,focusable:!c,active:l,children:o.jsx(bLe,{...a,...i,ref:d,onKeyDown:mn(i.onKeyDown,h=>{h.key==="Enter"&&h.preventDefault()}),onFocus:mn(i.onFocus,()=>{var h;f.current&&((h=u.current)==null||h.click())})})})},"RadioGroupItemTrigger")),NLe=p.forwardRef(Ja(function(t,n){const{__scopeRadioGroup:r,value:i,disabled:s,...a}=t;return o.jsx(vue,{__scopeRadioGroup:r,value:i,disabled:s,internal_do_not_use_render:({isFormControl:l})=>o.jsxs(o.Fragment,{children:[o.jsx(ALe,{...a,ref:n,__scopeRadioGroup:r}),l&&o.jsx(jLe,{__scopeRadioGroup:r})]})})},"RadioGroupItem")),jLe=p.forwardRef(Ja(function(t,n){const{__scopeRadioGroup:r,...i}=t,s=tj(r);return o.jsx(vLe,{...s,...i,ref:n})},"RadioGroupItemBubbleInput")),RLe=p.forwardRef(Ja(function(t,n){const{__scopeRadioGroup:r,...i}=t,s=tj(r);return o.jsx(OLe,{...s,...i,ref:n})},"RadioGroupIndicator")),ILe=Object.defineProperty,Hp=(e,t)=>ILe(e,"name",{value:t,configurable:!0}),l7="Switch",[DLe,lMt]=rl(l7),[PLe,c7]=DLe(l7);function wue(e){const{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:s,form:a,name:l,onCheckedChange:c,required:u,value:d="on",internal_do_not_use_render:f}=e,[h,m]=Bc({prop:n,defaultProp:i??!1,onChange:c,caller:l7}),[g,b]=p.useState(null),[y,O]=p.useState(null),v=p.useRef(!1),[x,w]=p.useReducer(k=>k+1,0),S=g?!!a||!!g.closest("form"):!0,E={checked:h,setChecked:m,disabled:s,control:g,setControl:b,name:l,form:a,value:d,hasConsumerStoppedPropagationRef:v,userInteractionCount:x,onUserInteraction:w,required:u,defaultChecked:i,isFormControl:S,bubbleInput:y,setBubbleInput:O};return o.jsx(PLe,{scope:t,...E,children:Sue(f)?f(E):r})}Hp(wue,"SwitchProvider");var MLe="SwitchTrigger",LLe=p.forwardRef(Hp(function({__scopeSwitch:t,onClick:n,...r},i){const{control:s,form:a,value:l,disabled:c,checked:u,required:d,setControl:f,setChecked:h,hasConsumerStoppedPropagationRef:m,onUserInteraction:g,isFormControl:b,bubbleInput:y}=c7(MLe,t),O=zr(i,f),v=p.useRef(u);return p.useEffect(()=>{const x=a?s==null?void 0:s.ownerDocument.getElementById(a):s==null?void 0:s.form;if(x instanceof HTMLFormElement){const w=Hp(()=>h(v.current),"reset");return x.addEventListener("reset",w),()=>x.removeEventListener("reset",w)}},[s,a,h]),o.jsx(pi.button,{type:"button",role:"switch","aria-checked":u,"aria-required":d,"data-state":u7(u),"data-disabled":c?"":void 0,disabled:c,value:l,...r,ref:O,onClick:mn(n,x=>{g(),h(w=>!w),y&&b&&(m.current=x.isPropagationStopped(),m.current||x.stopPropagation())})})},"SwitchTrigger")),$Le=p.forwardRef(Hp(function(t,n){const{__scopeSwitch:r,name:i,checked:s,defaultChecked:a,required:l,disabled:c,value:u,onCheckedChange:d,form:f,...h}=t;return o.jsx(wue,{__scopeSwitch:r,checked:s,defaultChecked:a,disabled:c,required:l,onCheckedChange:d,name:i,form:f,value:u,internal_do_not_use_render:({isFormControl:m})=>o.jsxs(o.Fragment,{children:[o.jsx(LLe,{...h,ref:n,__scopeSwitch:r}),m&&o.jsx(FLe,{__scopeSwitch:r})]})})},"Switch")),BLe="SwitchThumb",QLe=p.forwardRef(Hp(function(t,n){const{__scopeSwitch:r,...i}=t,s=c7(BLe,r);return o.jsx(pi.span,{"data-state":u7(s.checked),"data-disabled":s.disabled?"":void 0,...i,ref:n})},"SwitchThumb")),ULe="SwitchBubbleInput",FLe=p.forwardRef(Hp(function({__scopeSwitch:t,onClick:n,...r},i){const{control:s,hasConsumerStoppedPropagationRef:a,userInteractionCount:l,checked:c,defaultChecked:u,required:d,disabled:f,name:h,value:m,form:g,bubbleInput:b,setBubbleInput:y}=c7(ULe,t),O=zr(i,y),v=KS(s),x=p.useRef(!1),w=p.useRef(c),S=p.useRef(l);p.useEffect(()=>{const k=b;if(!k)return;const _=window.HTMLInputElement.prototype,T=Object.getOwnPropertyDescriptor(_,"checked").set,A=l!==S.current;S.current=l;const j=w.current!==c;w.current=c;const L=!(A&&a.current);if(j&&T){x.current=!A;const I=new Event("click",{bubbles:L});T.call(k,c),k.dispatchEvent(I),x.current=!1}},[b,c,a,l]);const E=p.useRef(c);return o.jsx(pi.input,{type:"checkbox","aria-hidden":!0,defaultChecked:u??E.current,required:d,disabled:f,name:h,value:m,form:g,...r,tabIndex:-1,ref:O,onClick:mn(n,k=>{x.current&&k.stopPropagation()}),style:{...r.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"SwitchBubbleInput"));function Sue(e){return typeof e=="function"}Hp(Sue,"isFunction");function u7(e){return e?"checked":"unchecked"}Hp(u7,"getState");var zLe=Object.defineProperty,VLe=(e,t)=>zLe(e,"name",{value:t,configurable:!0}),HLe="Toggle",qLe=p.forwardRef(VLe(function(t,n){const{pressed:r,defaultPressed:i,onPressedChange:s,...a}=t,[l,c]=Bc({prop:r,onChange:s,defaultProp:i??!1,caller:HLe});return o.jsx(pi.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":t.disabled?"":void 0,...a,ref:n,onClick:mn(t.onClick,()=>{t.disabled||c(!l)})})},"Toggle")),XLe=Object.defineProperty,qp=(e,t)=>XLe(e,"name",{value:t,configurable:!0}),K1="ToggleGroup",[Eue,cMt]=rl(K1,[Y1]),kue=Y1(),GLe=p.forwardRef(qp(function(t,n){const{type:r,...i}=t;if(r==="single"){const s=i;return o.jsx(WLe,{role:"radiogroup",...s,ref:n})}if(r==="multiple"){const s=i;return o.jsx(YLe,{role:"toolbar",...s,ref:n})}throw new Error(`Missing prop \`type\` expected on \`${K1}\``)},"ToggleGroup")),[_ue,Tue]=Eue(K1),WLe=p.forwardRef(qp(function(t,n){const{value:r,defaultValue:i,onValueChange:s=qp(()=>{},"onValueChange"),...a}=t,[l,c]=Bc({prop:r,defaultProp:i??"",onChange:s,caller:K1});return o.jsx(_ue,{scope:t.__scopeToggleGroup,type:"single",value:p.useMemo(()=>l?[l]:[],[l]),onItemActivate:c,onItemDeactivate:p.useCallback(()=>c(""),[c]),children:o.jsx(Cue,{...a,ref:n})})},"ToggleGroupImplSingle")),YLe=p.forwardRef(qp(function(t,n){const{value:r,defaultValue:i,onValueChange:s=qp(()=>{},"onValueChange"),...a}=t,[l,c]=Bc({prop:r,defaultProp:i??[],onChange:s,caller:K1}),u=p.useCallback(f=>c((h=[])=>[...h,f]),[c]),d=p.useCallback(f=>c((h=[])=>h.filter(m=>m!==f)),[c]);return o.jsx(_ue,{scope:t.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:u,onItemDeactivate:d,children:o.jsx(Cue,{...a,ref:n})})},"ToggleGroupImplMultiple")),[ZLe,KLe]=Eue(K1),Cue=p.forwardRef(qp(function(t,n){const{__scopeToggleGroup:r,disabled:i=!1,rovingFocus:s=!0,orientation:a,dir:l,loop:c=!0,...u}=t,d=kue(r),f=ZS(l),h={dir:f,...u};return o.jsx(ZLe,{scope:r,rovingFocus:s,disabled:i,children:s?o.jsx(Y9,{asChild:!0,...d,orientation:a,dir:f,loop:c,children:o.jsx(pi.div,{...h,ref:n})}):o.jsx(pi.div,{...h,ref:n})})},"ToggleGroupImpl")),y4="ToggleGroupItem",JLe=p.forwardRef(qp(function(t,n){const r=Tue(y4,t.__scopeToggleGroup),i=KLe(y4,t.__scopeToggleGroup),s=kue(t.__scopeToggleGroup),a=r.value.includes(t.value),l=i.disabled||t.disabled,c={...t,pressed:a,disabled:l},u=p.useRef(null);return i.rovingFocus?o.jsx(Z9,{asChild:!0,...s,focusable:!l,active:a,ref:u,children:o.jsx(sq,{...c,ref:n})}):o.jsx(sq,{...c,ref:n})},"ToggleGroupItem")),sq=p.forwardRef(qp(function(t,n){const{__scopeToggleGroup:r,value:i,...s}=t,a=Tue(y4,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},c=a.type==="single"?l:void 0;return o.jsx(qLe,{...c,...s,ref:n,onPressedChange:u=>{u?a.onItemActivate(i):a.onItemDeactivate(i)}})},"ToggleGroupItemImpl")),e6e=Object.defineProperty,ga=(e,t)=>e6e(e,"name",{value:t,configurable:!0}),[d7,uMt]=rl("Tooltip",[W1]),f7=W1(),t6e="TooltipProvider",n6e=700,O4="tooltip.open",[r6e,h7]=d7(t6e),i6e=ga(e=>{const{__scopeTooltip:t,delayDuration:n=n6e,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,a=p.useRef(!0),l=p.useRef(!1),c=p.useRef(0);return p.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),o.jsx(r6e,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:p.useCallback(()=>{r<=0||(window.clearTimeout(c.current),a.current=!1)},[r]),onClose:p.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,r))},[r]),isPointerInTransitRef:l,onPointerInTransitChange:p.useCallback(u=>{l.current=u},[]),disableHoverableContent:i,children:s})},"TooltipProvider"),x4="Tooltip",[s6e,eE]=d7(x4),a6e=ga(e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:a,delayDuration:l}=e,c=h7(x4,e.__scopeTooltip),u=f7(t),[d,f]=p.useState(null),[h,m]=p.useState(void 0),g=Fp(),b=p.useRef(0),y=a??c.disableHoverableContent,O=l??c.delayDuration,v=p.useRef(!1),[x,w]=Bc({prop:r,defaultProp:i??!1,onChange:ga(T=>{T?(c.onOpen(),document.dispatchEvent(new CustomEvent(O4))):c.onClose(),s==null||s(T)},"onChange"),caller:x4}),S=p.useMemo(()=>x?v.current?"delayed-open":"instant-open":"closed",[x]),E=p.useCallback(()=>{window.clearTimeout(b.current),b.current=0,v.current=!1,w(!0)},[w]),k=p.useCallback(()=>{window.clearTimeout(b.current),b.current=0,w(!1)},[w]),_=p.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{v.current=!0,w(!0),b.current=0},O)},[O,w]);p.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]);const C=h??g;return o.jsx(WN,{...u,children:o.jsx(s6e,{scope:t,contentId:C,setContentId:m,open:x,stateAttribute:S,trigger:d,onTriggerChange:f,onTriggerEnter:p.useCallback(()=>{c.isOpenDelayedRef.current?_():E()},[c.isOpenDelayedRef,_,E]),onTriggerLeave:p.useCallback(()=>{y?k():(window.clearTimeout(b.current),b.current=0)},[k,y]),onOpen:E,onClose:k,disableHoverableContent:y,children:n})})},"Tooltip"),aq="TooltipTrigger",o6e=p.forwardRef(ga(function(t,n){const{__scopeTooltip:r,...i}=t,s=eE(aq,r),a=h7(aq,r),l=f7(r),c=p.useRef(null),u=zr(n,c,s.onTriggerChange),d=p.useRef(!1),f=p.useRef(!1),h=p.useCallback(()=>d.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),o.jsx(q9,{asChild:!0,...l,children:o.jsx(pi.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...i,ref:u,onPointerMove:mn(t.onPointerMove,m=>{m.pointerType!=="touch"&&!f.current&&!a.isPointerInTransitRef.current&&(s.onTriggerEnter(),f.current=!0)}),onPointerLeave:mn(t.onPointerLeave,()=>{s.onTriggerLeave(),f.current=!1}),onPointerDown:mn(t.onPointerDown,()=>{s.open&&s.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:mn(t.onFocus,()=>{d.current||s.onOpen()}),onBlur:mn(t.onBlur,s.onClose),onClick:mn(t.onClick,s.onClose)})})},"TooltipTrigger")),Aue="TooltipPortal",[l6e,c6e]=d7(Aue,{forceMount:void 0}),u6e=ga(e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=eE(Aue,t);return o.jsx(l6e,{scope:t,forceMount:n,children:o.jsx(Ed,{present:n||s.open,children:o.jsx(D9,{asChild:!0,container:i,children:r})})})},"TooltipPortal"),Cw="TooltipContent",d6e=p.forwardRef(ga(function(t,n){const r=c6e(Cw,t.__scopeTooltip),{forceMount:i=r.forceMount,side:s="top",...a}=t,l=eE(Cw,t.__scopeTooltip);return o.jsx(Ed,{present:i||l.open,children:l.disableHoverableContent?o.jsx(Nue,{side:s,...a,ref:n}):o.jsx(f6e,{side:s,...a,ref:n})})},"TooltipContent")),f6e=p.forwardRef(ga(function(t,n){const r=eE(Cw,t.__scopeTooltip),i=h7(Cw,t.__scopeTooltip),s=p.useRef(null),a=zr(n,s),[l,c]=p.useState(null),{trigger:u,onClose:d}=r,f=s.current,{onPointerInTransitChange:h}=i,m=p.useCallback(()=>{c(null),h(!1)},[h]),g=p.useCallback((b,y)=>{const O=b.currentTarget,v={x:b.clientX,y:b.clientY},x=jue(v,O.getBoundingClientRect()),w=Rue(v,x),S=Iue(y.getBoundingClientRect()),E=Pue([...w,...S]);c(E),h(!0)},[h]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(u&&f){const b=ga(O=>g(O,f),"handleTriggerLeave"),y=ga(O=>g(O,u),"handleContentLeave");return u.addEventListener("pointerleave",b),f.addEventListener("pointerleave",y),()=>{u.removeEventListener("pointerleave",b),f.removeEventListener("pointerleave",y)}}},[u,f,g,m]),p.useEffect(()=>{if(l){const b=ga(y=>{const O=y.target,v={x:y.clientX,y:y.clientY},x=(u==null?void 0:u.contains(O))||(f==null?void 0:f.contains(O)),w=!Due(v,l);x?m():w&&(m(),d())},"handleTrackPointerGrace");return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[u,f,l,d,m]),o.jsx(Nue,{...t,ref:a})},"TooltipContentHoverable")),h6e=jle("TooltipContent"),Nue=p.forwardRef(ga(function(t,n){const{__scopeTooltip:r,children:i,"aria-label":s,id:a,onEscapeKeyDown:l,onPointerDownOutside:c,...u}=t,d=eE(Cw,r),f=f7(r),{onClose:h}=d;p.useEffect(()=>(document.addEventListener(O4,h),()=>document.removeEventListener(O4,h)),[h]),p.useEffect(()=>{if(d.trigger){const g=ga(b=>{b.target instanceof Node&&b.target.contains(d.trigger)&&h()},"handleScroll");return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[d.trigger,h]);const{setContentId:m}=d;return Ic(()=>(m(a),()=>{m(void 0)}),[a,m]),o.jsx(j9,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:h,children:o.jsxs(X9,{"data-state":d.stateAttribute,role:s?void 0:"tooltip",id:s?void 0:d.contentId,...f,...u,ref:n,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[o.jsx(h6e,{children:i}),s?o.jsx(PDe,{id:d.contentId,role:"tooltip",children:s}):null]})})},"TooltipContentImpl"));function jue(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}ga(jue,"getExitSideFromRect");function Rue(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}ga(Rue,"getPaddedExitPoints");function Iue(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}ga(Iue,"getPointsFromRect");function Due(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,a=t.length-1;sr!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(i=!i)}return i}ga(Due,"isPointInPolygon");function Pue(e){const t=e.slice();return t.sort((n,r)=>n.xr.x?1:n.yr.y?1:0),Mue(t)}ga(Pue,"getHull");function Mue(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}ga(Mue,"getHullPresorted");var p6e=i6e,m6e=a6e,Lue=o6e,g6e=u6e,b6e=d6e;const y6e=()=>{var e;return typeof ClipboardItem<"u"&&!!((e=navigator.clipboard)!=null&&e.write)};function O6e(e){const{"text/plain":t,...n}=e;return new ClipboardItem({...n,...t?{"text/plain":new Blob([t],{type:"text/plain"})}:null})}async function x6e(e,t=document.body){if(typeof e=="string")return oq(e,t);try{return y6e()?(await navigator.clipboard.write([O6e(e)]),!0):e["text/plain"]?oq(e["text/plain"],t):!1}catch{return!1}}async function oq(e,t=document.body){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.opacity="0",t.appendChild(n),n.focus(),n.select();let r=!1;try{r=document.execCommand("copy")}catch{}return t.removeChild(n),r}function Xp(e){const t=p.useRef(e);return t.current=e,t}let t1=[],t2=!1;const lq=e=>{var t,n;if(e.key==="Escape"){const[r]=t1;r&&(e.preventDefault(),(n=(t=r.callback).current)==null||n.call(t))}},$ue=()=>{t1.length>0&&!t2?(document.body.addEventListener("keydown",lq),t2=!0):t1.length===0&&t2&&(document.body.removeEventListener("keydown",lq),t2=!1)},v6e=e=>{t1.unshift(e),$ue()},w6e=({id:e})=>{t1=t1.filter(t=>t.id!==e),$ue()},tE=(e,t)=>{const n=p.useId(),r=Xp(t);p.useEffect(()=>{if(!e)return;const i={id:n,callback:r};return v6e(i),()=>w6e(i)},[n,e,r])},S6e="_Tooltip_16g2y_1",E6e="_TriggerDecorator_16g2y_73",Bue={Tooltip:S6e,TriggerDecorator:E6e},vo=e=>{const{ref:t,children:n,content:r,forceOpen:i=r===null?!1:void 0,maxWidth:s=300,openDelay:a=150,interactive:l=!1,compact:c=!1,preventUnintentionalClickToClose:u,align:d,alignOffset:f=0,side:h,sideOffset:m=5,gutterSize:g="md",contentClassName:b,onPointerDown:y,onClick:O,...v}=e,[x,w]=p.useState(!1),[S,E]=p.useState(!1);k9(()=>E(!1),S?400:null);const k=i??x,_=T=>{typeof i!="boolean"&&(w(T),u&&E(T))},C=T=>{u&&S&&(T.preventDefault(),T.stopPropagation())};return o.jsxs(Que,{open:k,delayDuration:a,onOpenChange:_,disableHoverableContent:!l,children:[o.jsx(Lue,{asChild:!0,children:o.jsx(Ale,{...v,ref:t,onPointerDown:T=>{C(T),y==null||y(T)},onClick:T=>{C(T),O==null||O(T)},children:n})}),o.jsx(Uue,{maxWidth:s,compact:c,align:d,alignOffset:f,side:h,sideOffset:m,gutterSize:g,className:b,children:r})]})},Que=({children:e,open:t,onOpenChange:n,...r})=>(tE(t,()=>{n(!1)}),o.jsx(p6e,{children:o.jsx(m6e,{open:t,onOpenChange:n,...r,children:e})})),Uue=({children:e,maxWidth:t=300,compact:n=!1,clickable:r=void 0,alignOffset:i=0,sideOffset:s=5,gutterSize:a="md",className:l,style:c,...u})=>o.jsx(g6e,{children:o.jsx(b6e,{...u,className:ur(Bue.Tooltip,l),"data-compact":n,"data-clickable":r,"data-gutter-size":a,alignOffset:i,sideOffset:s,collisionPadding:15,hideWhenDetached:!0,style:{...c,maxWidth:t},onEscapeKeyDown:Df,children:e})}),k6e=({children:e,asChild:t=!0,...n})=>o.jsx(Lue,{asChild:t,...n,children:e}),_6e=e=>{const{children:t,className:n,focusable:r=!0,ref:i,...s}=e,a=typeof t=="string";return o.jsx(Ale,{ref:i,...s,className:ur(Bue.TriggerDecorator,n),tabIndex:r?0:void 0,children:a?o.jsx("span",{children:t}):t})};vo.Root=Que;vo.Content=Uue;vo.Trigger=k6e;vo.TriggerDecorator=_6e;const T6e=50,cq=48;function C6e(e){return(e.events??[]).flatMap(t=>{var i,s;const r=(((i=t.content)==null?void 0:i.parts)??[]).map(a=>typeof a.text=="string"?a.text:"").filter(Boolean).join("");return r?[{text:r,role:t.author??((s=t.content)==null?void 0:s.role)??"",ts:t.timestamp}]:[]})}function A6e(e){var t,n;for(const r of e.events??[])if(r.author==="user"||((t=r.content)==null?void 0:t.role)==="user"){const i=(((n=r.content)==null?void 0:n.parts)??[]).map(s=>s.text).find(Boolean);if(i)return i}return"未命名会话"}function N6e(e,t,n){const r=Math.max(0,t-cq),i=Math.min(e.length,t+n+cq);return(r>0?"…":"")+e.slice(r,i).trim()+(i{var c;if((c=l.events)!=null&&c.length)return l;try{return await PN(t,e,l.id)}catch{return l}})),a=[];for(const l of s)for(const{text:c,role:u,ts:d}of C6e(l)){const f=c.toLowerCase().indexOf(r);if(f!==-1){a.push({type:"session",appId:t,sessionId:l.id,title:A6e(l),snippet:N6e(c,f,r.length),role:u,ts:d??l.lastUpdateTime});break}}return a.sort((l,c)=>(c.ts??0)-(l.ts??0)),a.slice(0,T6e)}async function R6e(e,t){if(!e||!t.trim())return{results:[]};let n;try{n=await goe(e,t.trim())}catch(a){const l=String(a);return{results:[],note:l.includes("404")?"网络搜索接口未就绪(后端未启用 /web/search)。":`网络搜索失败:${l}`}}const{mounted:r,results:i,error:s}=n;return r?s?{results:[],note:s}:{results:i.map((a,l)=>({type:"web",index:l,title:a.title,url:a.url,siteName:a.siteName,summary:a.summary}))}:{results:[],note:"当前 Agent 未挂载 web_search 工具。"}}async function I6e(e,t,n,r){if(!t||!r.trim())return{results:[]};const i=await moe(t,e,r.trim(),n);if(!i.mounted)return{results:[],note:e==="knowledge"?"该 Agent 未挂载知识库。":"该 Agent 未挂载长期记忆。"};if(i.error)return{results:[],note:i.error};const s=i.sourceName??(e==="knowledge"?"知识库":"长期记忆");return{results:i.results.map((a,l)=>e==="knowledge"?{type:"knowledge",index:l,content:a.content,sourceName:s,sourceType:i.sourceType}:{type:"memory",index:l,content:a.content,sourceName:s,sourceType:i.sourceType,author:a.author,ts:a.timestamp})}}async function D6e(e,t,n){return e==="session"?{results:await j6e(n.userId,n.appId,t)}:e==="web"?R6e(n.appId,t):I6e(e,n.appId,n.userId,t)}function Fue({mirrored:e=!1}){return o.jsxs("g",{opacity:"0.5",transform:e?"translate(20 0) scale(-1 1)":void 0,children:[o.jsx("path",{className:"sidebar-panel-glyph__divider",d:"M5.938 6.833c.11 0 .249.102.249.292v6.042c0 .19-.14.291-.249.291s-.248-.101-.248-.291V7.125c0-.19.139-.292.248-.292Z",strokeWidth:"1.167"}),o.jsx("path",{className:"sidebar-panel-glyph__frame",d:"M14.5 3.75h-9a3 3 0 0 0-3 3v6.857a3 3 0 0 0 3 3h9a3 3 0 0 0 3-3V6.75a3 3 0 0 0-3-3Z",strokeWidth:"1.667",strokeLinecap:"round",strokeLinejoin:"round"})]})}function P6e(e){return o.jsx("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",...e,children:o.jsx(Fue,{})})}function M6e(e){return o.jsx("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",...e,children:o.jsx(Fue,{mirrored:!0})})}function L6e(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"M12 8.333c.368 0 .667.299.667.667v2h2a.667.667 0 0 1 0 1.333h-2v2a.667.667 0 0 1-1.334 0v-2h-2a.667.667 0 0 1 0-1.333h2V9c0-.368.299-.667.667-.667ZM7.667 1c3.49 0 6.383 2.554 6.913 5.896a.667.667 0 0 1-1.317.208 5.667 5.667 0 1 0-9.708 4.424.67.67 0 0 1 .07.12.667.667 0 0 1-.13.834l-.95.853 4.788-.002a.667.667 0 0 1 0 1.334l-5.657.002c-.917 0-1.35-1.131-.67-1.744l1.163-1.045A6.97 6.97 0 0 1 .667 8c0-3.866 3.134-7 7-7Z",fill:"currentColor"})})}function $6e(e){return o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.333",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"7.333",cy:"7.333",r:"5.333"}),o.jsx("path",{d:"m11.133 11.133 2.867 2.867"})]})}function B6e(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"M8 0.667c4.05 0 7.334 3.283 7.334 7.333 0 4.05-3.284 7.334-7.334 7.334S0.667 12.05 0.667 8 3.95 0.667 8 0.667Zm0 1.333a6 6 0 1 0 0 12A6 6 0 0 0 8 2ZM6.167 6c.368 0 .667.299.667.667v2a.667.667 0 0 1-1.334 0v-2c0-.368.299-.667.667-.667Zm3.666 0c.368 0 .667.299.667.667v2a.667.667 0 0 1-1.333 0v-2c0-.368.298-.667.666-.667Z",fill:"currentColor"})})}function zue(e){return o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M7.58 2.6a.667.667 0 0 0-.667-.667h-.666a.667.667 0 0 0-.667.667v10.667c0 .368.299.666.667.666h.666a.667.667 0 0 0 .667-.666V2.6Zm1.333 10.667A2 2 0 0 1 6.913 15.267h-.666a2 2 0 0 1-2-2V2.6a2 2 0 0 1 2-2h.666a2 2 0 0 1 2 2v10.667Z",fill:"currentColor"}),o.jsx("path",{d:"M11.88 5.045a.667.667 0 0 0-.801-.514l-.653.136a.667.667 0 0 0-.504.786l1.85 8.092c.081.358.44.589.8.514l.653-.137a.667.667 0 0 0 .504-.786L11.88 5.045Zm3.155 7.82a2 2 0 0 1-1.512 2.358l-.653.136a2 2 0 0 1-2.403-1.541L8.617 5.726a2 2 0 0 1 1.513-2.358l.652-.136a2 2 0 0 1 2.404 1.541l1.849 8.092Z",fill:"currentColor"}),o.jsx("path",{d:"M4.247 2.6a.667.667 0 0 0-.667-.667h-.667a.667.667 0 0 0-.666.667v10.667c0 .368.298.666.666.666h.667a.667.667 0 0 0 .667-.666V2.6ZM5.58 13.267a2 2 0 0 1-2 2h-.667a2 2 0 0 1-2-2V2.6a2 2 0 0 1 2-2h.667a2 2 0 0 1 2 2v10.667Z",fill:"currentColor"})]})}function Q6e({className:e="icon"}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M16.4 10.7a5.7 5.7 0 1 1-1.67-4.03"}),o.jsx("path",{d:"M15.25 15.25 19.6 19.6"})]})}function U6e({open:e}){return o.jsx("svg",{className:`search-source-chevron ${e?"open":""}`,viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:"m3.25 4.75 2.75 2.5 2.75-2.5"})})}function F6e({active:e=!1,onClick:t}){return o.jsxs("button",{className:`new-chat${e?" is-active":""}`,onClick:t,"aria-label":"搜索","aria-current":e?"page":void 0,title:"搜索",children:[o.jsx($6e,{className:"icon"}),o.jsx("span",{className:"sidebar-nav-label",children:"搜索"})]})}function z6e(e,t,n){const r=!!e,i=new Set((t==null?void 0:t.searchSources)??[]),s=a=>r?n?"正在检测 Agent 能力":`当前 Agent 未挂载${a}`:"请选择 Agent";return[{id:"session",label:"会话",ready:r,unavailableLabel:"请选择 Agent"},{id:"web",label:"网络",ready:r&&i.has("web"),description:"通过 web_search 工具检索",unavailableLabel:s(" web_search 工具")},{id:"knowledge",label:"知识库",ready:r&&i.has("knowledge"),unavailableLabel:s("知识库")},{id:"memory",label:"长期记忆",ready:r&&i.has("memory"),unavailableLabel:s("长期记忆")}]}function TC(e){return{context_search:"Context Search",local:"本地",mem0:"Mem0",milvus:"Milvus",opensearch:"OpenSearch",openviking:"OpenViking",redis:"Redis",tos_vector:"TOS Vector",viking:"VikingDB"}[e.toLowerCase()]??e}function uq(e){return e?new Date(e*1e3).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):""}function V6e({userId:e,appId:t,agentInfo:n,capabilitiesLoading:r,agentLabel:i,onOpenSession:s}){var M,N;const[a,l]=p.useState("session"),[c,u]=p.useState(""),[d,f]=p.useState([]),[h,m]=p.useState(),[g,b]=p.useState(!1),[y,O]=p.useState(!1),[v,x]=p.useState(!1),w=p.useRef(0),S=p.useRef(null),E=z6e(t,n,r),k=E.find(D=>D.id===a),_=a==="knowledge"?(M=n==null?void 0:n.components)==null?void 0:M.find(D=>D.source==="knowledgebase"||D.kind==="knowledgebase"):a==="memory"?(N=n==null?void 0:n.components)==null?void 0:N.find(D=>D.source==="long_term_memory"||D.kind==="memory"):void 0;p.useEffect(()=>{w.current+=1,l("session"),f([]),m(void 0),O(!1),b(!1),x(!1)},[t]),p.useEffect(()=>{if(!v)return;function D(Q){var F;(F=S.current)!=null&&F.contains(Q.target)||x(!1)}return document.addEventListener("pointerdown",D),()=>document.removeEventListener("pointerdown",D)},[v]);async function C(D,Q){var z;const F=D.trim();if(!F||!((z=E.find(B=>B.id===Q))!=null&&z.ready))return;const $=++w.current;b(!0),O(!0);let H;try{H=await D6e(Q,F,{userId:e,appId:t})}catch(B){const V=B instanceof Error?B.message:String(B);H={results:[],note:`搜索失败:${V}`}}$===w.current&&(f(H.results),m(H.note),b(!1))}function T(D){w.current+=1,u(D),f([]),m(void 0),O(!1),b(!1)}function A(D){w.current+=1,l(D),x(!1),f([]),m(void 0),O(!1),b(!1)}const j=!!(k!=null&&k.ready),L=t?a==="web"?"在网络中检索":a==="knowledge"?`在 ${(_==null?void 0:_.name)??"当前 Agent 的知识库"} 中检索`:a==="memory"?`在 ${(_==null?void 0:_.name)??"当前用户的长期记忆"} 中检索`:"在当前 Agent 的会话中检索":"请先选择 Agent",I=_!=null&&_.backend?TC(_.backend):"";return o.jsxs("div",{className:"search",children:[o.jsxs("div",{className:"search-box",children:[o.jsxs("div",{className:"search-source-picker-wrap",ref:S,children:[o.jsxs("button",{className:"search-source-picker",type:"button","aria-label":`搜索类型:${(k==null?void 0:k.label)??"未选择"}`,"aria-haspopup":"listbox","aria-expanded":v,onClick:()=>x(D=>!D),children:[o.jsx("span",{children:(k==null?void 0:k.label)??"搜索类型"}),I&&o.jsx("small",{children:I}),o.jsx(U6e,{open:v})]}),v&&o.jsx("div",{className:"search-source-menu",role:"listbox","aria-label":"选择搜索类型",children:E.map(D=>{var $,H;const Q=D.id==="knowledge"?($=n==null?void 0:n.components)==null?void 0:$.find(z=>z.source==="knowledgebase"||z.kind==="knowledgebase"):D.id==="memory"?(H=n==null?void 0:n.components)==null?void 0:H.find(z=>z.source==="long_term_memory"||z.kind==="memory"):void 0,F=Q?[Q.name,Q.backend?TC(Q.backend):""].filter(Boolean).join(" · "):D.ready?D.description:D.unavailableLabel;return o.jsxs("button",{type:"button",role:"option","aria-selected":a===D.id,disabled:!D.ready,onClick:()=>A(D.id),children:[o.jsx("span",{children:D.label}),F&&o.jsx("small",{children:F})]},D.id)})})]}),o.jsx("span",{className:"search-box-divider","aria-hidden":!0}),o.jsx("input",{className:"search-input",value:c,onChange:D=>T(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),C(c,a))},placeholder:L,disabled:!j,autoFocus:!0}),o.jsx("button",{className:"search-go",onClick:()=>void C(c,a),disabled:!c.trim()||g,"aria-label":"搜索",children:g?o.jsx(lr,{className:"icon spin"}):o.jsx(Q6e,{className:"icon"})})]}),o.jsx("div",{className:"search-results",children:j?y?g?null:h?o.jsx("div",{className:"search-empty",children:h}):d.length===0&&y?o.jsxs("div",{className:"search-empty",children:["未找到匹配「",c.trim(),"」的结果。"]}):d.map((D,Q)=>o.jsx(H6e,{result:D,agentLabel:i,onOpen:s},Q)):o.jsx("div",{className:"search-empty",children:a==="web"?"输入关键词后回车或点击按钮,通过 web_search 工具检索。":a==="knowledge"?"输入问题,检索当前 Agent 挂载的知识库。":a==="memory"?"输入线索,检索当前用户跨会话保存的长期记忆。":"输入关键词后回车或点击按钮,搜索当前 Agent 的会话。"}):o.jsx("div",{className:"search-empty",children:t?r?"正在读取当前 Agent 的检索能力…":(k==null?void 0:k.unavailableLabel)??"当前 Agent 未挂载该数据源":"选择一个 Agent 后,即可检索会话、网络及其挂载的数据源。"})})]})}function H6e({result:e,agentLabel:t,onOpen:n}){switch(e.type){case"session":return o.jsxs("button",{className:"search-result",onClick:()=>n(e.appId,e.sessionId),children:[o.jsx(Lae,{className:"search-result-icon"}),o.jsxs("div",{className:"search-result-body",children:[o.jsxs("div",{className:"search-result-head",children:[o.jsx("span",{className:"search-result-title",children:e.title}),o.jsxs("span",{className:"search-result-meta",children:[t(e.appId),e.ts?` · ${uq(e.ts)}`:""]})]}),o.jsx("div",{className:"search-result-snippet",children:e.snippet})]})]});case"web":return o.jsxs("a",{className:"search-result",href:e.url||void 0,target:"_blank",rel:"noreferrer noopener",children:[o.jsx(jN,{className:"search-result-icon"}),o.jsxs("div",{className:"search-result-body",children:[o.jsxs("div",{className:"search-result-head",children:[o.jsx("span",{className:"search-result-title",children:e.title||e.url}),o.jsxs("span",{className:"search-result-meta",children:[e.siteName,e.url&&o.jsx(Dg,{className:"search-result-ext"})]})]}),e.summary&&o.jsx("div",{className:"search-result-snippet",children:e.summary})]})]});case"knowledge":return o.jsxs("div",{className:"search-result search-result-static",children:[o.jsx(dq,{source:"knowledge"}),o.jsxs("div",{className:"search-result-body",children:[o.jsxs("div",{className:"search-result-head",children:[o.jsxs("span",{className:"search-result-title",children:["知识片段 ",e.index+1]}),o.jsxs("span",{className:"search-result-meta",children:[e.sourceName,e.sourceType?` · ${TC(e.sourceType)}`:""]})]}),o.jsx("div",{className:"search-result-snippet search-result-snippet-expanded",children:e.content})]})]});case"memory":return o.jsxs("div",{className:"search-result search-result-static",children:[o.jsx(dq,{source:"memory"}),o.jsxs("div",{className:"search-result-body",children:[o.jsxs("div",{className:"search-result-head",children:[o.jsxs("span",{className:"search-result-title",children:["记忆片段 ",e.index+1]}),o.jsxs("span",{className:"search-result-meta",children:[e.sourceName,e.sourceType?` · ${TC(e.sourceType)}`:"",e.ts?` · ${uq(e.ts)}`:""]})]}),o.jsx("div",{className:"search-result-snippet search-result-snippet-expanded",children:e.content})]})]});default:return null}}function dq({source:e,className:t="search-result-icon"}){return e==="knowledge"?o.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[o.jsx("path",{d:"M5 5.5h10.5A3.5 3.5 0 0 1 19 9v9.5H8.5A3.5 3.5 0 0 1 5 15V5.5Z"}),o.jsx("path",{d:"M8.25 9h7.5M8.25 12.25h6"})]}):o.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[o.jsx("path",{d:"M12 4.5a7.5 7.5 0 1 0 7.5 7.5"}),o.jsx("path",{d:"M12 8a4 4 0 1 0 4 4M12 11.3a.7.7 0 1 0 0 1.4.7.7 0 0 0 0-1.4Z"})]})}function q6e({filled:e=!1,...t}){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:e?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[o.jsx("rect",{x:"3.5",y:"9.3",width:"4.5",height:"10.2",rx:"1.5"}),o.jsx("path",{d:"M8 10.2 11.3 4.8c.5-.8 1.7-.45 1.7.5v3.8h4.2a2.1 2.1 0 0 1 2.04 2.6l-1.4 5.75A2.1 2.1 0 0 1 15.8 19H8"})]})}function X6e({filled:e=!1,...t}){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:e?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[o.jsx("rect",{x:"3.5",y:"4.5",width:"4.5",height:"10.2",rx:"1.5"}),o.jsx("path",{d:"M8 13.8 11.3 19.2c.5.8 1.7.45 1.7-.5v-3.8h4.2a2.1 2.1 0 0 0 2.04-2.6l-1.4-5.75A2.1 2.1 0 0 0 15.8 5H8"})]})}function Vue(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M5.25 4.25h9.5a2.5 2.5 0 0 1 2.5 2.5v3.5"}),o.jsx("path",{d:"M13.25 17.75h-8a2.5 2.5 0 0 1-2.5-2.5v-8a3 3 0 0 1 3-3"}),o.jsx("path",{d:"M7 8.25h5.5M7 11.75h3.25"}),o.jsx("path",{d:"m13.35 16.65.42-2.16 4.76-4.76a1.35 1.35 0 0 1 1.91 1.91l-4.76 4.76-2.33.25Z"}),o.jsx("path",{d:"m17.65 10.6 1.9 1.9"})]})}const nj="/assets/media/logo-DCsNZy-k.svg",p7="data:image/svg+xml,%3csvg%20width='28'%20height='23'%20viewBox='0%200%2028%2023'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M17.1957%209.44218C17.0253%209.58161%2016.7774%209.47317%2016.7774%209.24079V8.01696V0.611967C16.7774%200.395085%2016.514%200.271152%2016.3591%200.410576L6.04172%209.16334C5.87132%209.30276%205.62345%209.19432%205.62345%208.96194V2.98218C5.62345%202.81178%205.48403%202.67235%205.31362%202.67235H0.309832C0.139424%202.67235%200%202.81178%200%202.98218V21.7115C0%2021.9284%200.263357%2022.0524%200.418273%2021.9129L10.7202%2013.1602C10.8906%2013.0207%2011.1385%2013.1292%2011.1385%2013.3616V22.0059C11.1385%2022.2228%2011.4018%2022.3467%2011.5567%2022.2073L21.8586%2013.4545C22.0291%2013.3151%2022.2769%2013.4235%2022.2769%2013.6559V19.6357C22.2769%2019.8061%2022.4163%2019.9455%2022.5868%2019.9455H27.5905C27.7609%2019.9455%2027.9004%2019.8061%2027.9004%2019.6357V0.890816C27.9004%200.673934%2027.637%200.550001%2027.4821%200.689425L17.1957%209.44218Z'%20fill='%230066FC'/%3e%3c/svg%3e",fq="(max-width: 860px)";function hq({title:e}){const t=p.useRef(null),[n,r]=p.useState({left:!1,right:!1}),i=()=>{const s=t.current;if(!s)return;const a={left:s.scrollLeft>1,right:s.scrollLeft+s.clientWidthl.left===a.left&&l.right===a.right?l:a)};return p.useLayoutEffect(()=>{const s=t.current;if(!s)return;i();const a=new ResizeObserver(i);return a.observe(s),s.firstElementChild&&a.observe(s.firstElementChild),()=>a.disconnect()},[e]),o.jsx("span",{ref:t,className:`history-title${n.left?" has-left-fade":""}${n.right?" has-right-fade":""}`,onScroll:i,onPointerEnter:i,children:o.jsx("span",{className:"history-title-text",children:e})})}function G6e(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"7",cy:"7",r:"2.25"}),o.jsx("circle",{cx:"17",cy:"7",r:"2.25"}),o.jsx("circle",{cx:"7",cy:"17",r:"2.25"}),o.jsx("circle",{cx:"17",cy:"17",r:"2.25"})]})}function W6e(e){let t=2166136261;for(const r of e)t^=r.charCodeAt(0),t=Math.imul(t,16777619);const n=t>>>0;return{"--avatar-hue-a":194+n%22,"--avatar-hue-b":214+(n>>>6)%25,"--avatar-hue-c":176+(n>>>12)%25,"--avatar-x":`${22+(n>>>18)%55}%`,"--avatar-y":`${18+(n>>>24)%58}%`}}const Y6e={admin:"管理员",developer:"开发者",user:"普通用户"};function Z6e({activePage:e,access:t,userInfo:n,onAgentKitCli:r,onDeveloperResources:i,onSystemInfo:s,onIssueFeedback:a,onLogout:l}){const[c,u]=p.useState(!1),[d,f]=p.useState("");if(!n)return null;const h=vIe(n)||"用户",m=typeof n.email=="string"?n.email.trim():"",g=W6e(h),b=wIe(n),y=b===d?"":b;return o.jsxs("div",{className:"sidebar-user",children:[o.jsxs("div",{className:"sidebar-user-row",children:[o.jsxs("button",{type:"button",className:"sidebar-user-btn",onClick:()=>u(O=>!O),title:h,children:[o.jsx("span",{className:`account-avatar${y?" has-image":""}`,style:g,"aria-hidden":"true",children:y?o.jsx("img",{className:"account-avatar-image",src:y,alt:"","aria-hidden":"true",referrerPolicy:"no-referrer",onError:()=>f(y)}):null}),o.jsx("span",{className:"sidebar-user-identity",children:o.jsx("span",{className:"sidebar-user-name",children:h})})]}),o.jsxs("div",{className:"sidebar-user-shortcuts","aria-label":"快捷入口",children:[o.jsx(vo,{compact:!0,content:"体验 AgentKit CLI",children:o.jsx("button",{type:"button",className:"sidebar-user-shortcut",onClick:r,"aria-label":"体验 AgentKit CLI",children:o.jsx(bRe,{className:"icon"})})}),o.jsx(vo,{compact:!0,content:"开发者资源",children:o.jsx("button",{type:"button",className:`sidebar-user-shortcut${e==="developer-resources"?" is-active":""}`,onClick:i,"aria-label":"开发者资源","aria-current":e==="developer-resources"?"page":void 0,children:o.jsx(sRe,{className:"icon"})})})]})]}),c&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-scrim",onClick:()=>u(!1)}),o.jsxs("div",{className:"account-pop sidebar-user-pop",children:[o.jsxs("div",{className:"account-head",children:[o.jsx("span",{className:`account-avatar account-avatar--lg${y?" has-image":""}`,style:g,"aria-hidden":"true",children:y?o.jsx("img",{className:"account-avatar-image",src:y,alt:"","aria-hidden":"true",referrerPolicy:"no-referrer",onError:()=>f(y)}):null}),o.jsxs("div",{className:"account-id",children:[o.jsxs("div",{className:"account-name-row",children:[o.jsx("div",{className:"account-name",children:h}),o.jsx(ta,{color:"secondary",size:"sm",variant:"soft",pill:!0,children:Y6e[t.role]})]}),m&&m!==h&&o.jsx("div",{className:"account-sub",children:m})]})]}),o.jsxs("button",{type:"button",className:"account-action",onClick:()=>{u(!1),s()},children:[o.jsx(wd,{className:"icon"})," 系统信息"]}),o.jsxs("button",{type:"button",className:"account-action",onClick:()=>{u(!1),a()},children:[o.jsx(Vue,{className:"icon"})," 问题反馈"]}),o.jsxs("button",{type:"button",className:"account-action",onClick:()=>{u(!1),l()},children:[o.jsx(JRe,{className:"icon"})," 退出登录"]})]})]})]})}function K6e({branding:e,cloudProvider:t,sessions:n,currentSessionId:r,activePage:i,features:s,access:a,streamingSids:l,evaluatingSids:c,sandboxHistory:u,onNewChat:d,onSearch:f,onQuickCreate:h,onLibrary:m,onAddAgent:g,onMyAgents:b,onWorkspace:y,onApplications:O,onCronJobs:v,onAgentKitCli:x,onDeveloperResources:w,onSystemInfo:S,onIssueFeedback:E,onPickSession:k,onDeleteSession:_,userInfo:C,onLogout:T}){const A=$=>(s==null?void 0:s[$])!==!1,[j,L]=p.useState(null),I=p.useRef(typeof window<"u"&&window.matchMedia(fq).matches),[M,N]=p.useState(I.current),D=n.map($=>({id:$.id,title:QN($.events),createdAt:($.lastUpdateTime??0)*1e3})).sort(($,H)=>H.createdAt-$.createdAt),Q=()=>{I.current=!1,N($=>!$),L(null)};p.useEffect(()=>{const $=window.matchMedia(fq),H=z=>{z.matches?N(B=>B||(I.current=!0,!0)):I.current&&(I.current=!1,N(!1))};return $.addEventListener("change",H),()=>$.removeEventListener("change",H)},[]);const F=t==="byteplus"?p7:nj;return o.jsxs("aside",{className:`sidebar ${M?"is-collapsed":""}`,children:[o.jsxs("div",{className:"sidebar-top",children:[o.jsxs("div",{className:"sidebar-brand-row",children:[o.jsxs("button",{type:"button",className:"brand",onClick:d,"aria-label":"返回首页",title:"返回首页",children:[o.jsx("img",{className:"brand-logo",src:e.logoUrl||F,width:20,height:20,alt:"","aria-hidden":!0}),o.jsx("span",{className:"brand-title",children:e.title})]}),o.jsx("button",{type:"button",className:"sidebar-collapse-toggle",onClick:Q,"aria-label":M?"展开侧边栏":"收起侧边栏",title:M?"展开侧边栏":"收起侧边栏",children:M?o.jsx(M6e,{className:"icon"}):o.jsx(P6e,{className:"icon"})})]}),o.jsxs("nav",{className:"sidebar-nav","aria-label":"主导航",children:[A("newChat")&&o.jsxs("button",{className:`new-chat new-chat--conversation${i==="new-chat"?" is-active":""}`,onClick:d,"aria-label":"新会话","aria-current":i==="new-chat"?"page":void 0,title:"新会话",children:[o.jsx(L6e,{className:"icon"}),o.jsx("span",{className:"sidebar-nav-label",children:"新会话"})]}),A("search")&&o.jsx(F6e,{active:i==="search",onClick:f}),o.jsxs("button",{className:`new-chat new-chat--agents${i==="agents"?" is-active":""}`,onClick:b,"aria-label":"智能体","aria-current":i==="agents"?"page":void 0,title:"智能体",children:[o.jsx(B6e,{className:"icon"}),o.jsx("span",{className:"sidebar-nav-label",children:"智能体"})]}),o.jsxs("button",{className:`new-chat new-chat--workspaces${i==="workspaces"?" is-active":""}`,onClick:y,"aria-label":"工作区","aria-current":i==="workspaces"?"page":void 0,title:"工作区",children:[o.jsx(IRe,{className:"icon"}),o.jsx("span",{className:"sidebar-nav-label",children:"工作区"})]}),o.jsxs("button",{className:`new-chat new-chat--library${i==="library"?" is-active":""}`,onClick:m,"aria-label":"资源库","aria-current":i==="library"?"page":void 0,title:"资源库",children:[o.jsx(zue,{className:"icon"}),o.jsx("span",{className:"sidebar-nav-label",children:"资源库"})]}),o.jsxs("button",{className:`new-chat new-chat--cronjobs${i==="cronjobs"?" is-active":""}`,onClick:v,"aria-label":"定时任务","aria-current":i==="cronjobs"?"page":void 0,title:"定时任务",children:[o.jsx(K8,{className:"icon"}),o.jsx("span",{className:"sidebar-nav-label",children:"定时任务"})]}),o.jsxs("button",{className:`new-chat new-chat--applications${i==="applications"?" is-active":""}`,onClick:O,"aria-label":"自动化","aria-current":i==="applications"?"page":void 0,title:"自动化",children:[o.jsx(G6e,{className:"icon"}),o.jsx("span",{className:"sidebar-nav-label",children:"自动化"})]})]})]}),A("history")&&o.jsxs("div",{className:"sidebar-history",children:[o.jsxs("div",{className:"history-head",children:[o.jsx("span",{children:"历史会话"}),A("newChat")&&o.jsx("button",{type:"button",className:"history-new-chat",onClick:(u==null?void 0:u.onNew)??d,disabled:u==null?void 0:u.newDisabled,"aria-label":"新建会话",title:"新建会话",children:o.jsx(yo,{className:"icon"})})]}),o.jsx("div",{className:"history-list",children:u?o.jsxs(o.Fragment,{children:[u.loading&&u.threads.length===0?o.jsx("div",{className:"history-empty",role:"status",children:"正在加载历史会话…"}):null,u.error?o.jsx("div",{className:"history-error",role:"alert",children:u.error}):null,!u.loading&&!u.error&&u.threads.length===0?o.jsx("div",{className:"history-empty",children:"暂无会话"}):null,u.threads.map($=>{const H=$.id===u.currentThreadId,z=$.name||$.preview||`Thread ${$.id.slice(0,8)}`,B=$.id===u.busyThreadId;return o.jsxs("div",{className:`history-item ${H?"active":""}`,children:[o.jsxs("button",{type:"button",className:"history-item-btn",onClick:()=>u.onSelect($.id),"aria-current":H?"page":void 0,title:z,disabled:B,children:[o.jsx(hq,{title:z}),H?o.jsx("span",{className:"history-current-badge",children:"当前"}):null]}),o.jsx("button",{type:"button",className:"history-more","aria-label":`管理历史会话:${z}`,title:"更多",disabled:B,onClick:()=>L(V=>V===$.id?null:$.id),children:o.jsx(yH,{className:"icon"})}),j===$.id?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-scrim",onClick:()=>L(null)}),o.jsx("div",{className:"history-menu",children:o.jsxs("button",{type:"button",className:"menu-item menu-item--danger",onClick:()=>{L(null),u.onDelete($)},children:[o.jsx(Up,{className:"icon"})," 删除"]})})]}):null]},$.id)}),u.hasMore?o.jsx("button",{type:"button",className:"history-load-more",disabled:u.loading,onClick:u.onLoadMore,children:u.loading?"加载中…":"加载更多"}):null]}):o.jsxs(o.Fragment,{children:[D.length===0?o.jsx("div",{className:"history-empty",children:"暂无会话"}):null,D.map($=>{const H=$.id===r,z=(l==null?void 0:l.has($.id))===!0,B=!z&&(c==null?void 0:c.has($.id))===!0;return o.jsxs("div",{className:`history-item ${H?"active":""}`,children:[o.jsxs("button",{className:"history-item-btn",onClick:()=>k($.id),"aria-current":H?"page":void 0,title:$.title,children:[o.jsx(hq,{title:$.title}),B&&o.jsxs("span",{className:"history-evaluating-status",title:"正在自动评测",children:[o.jsx("span",{className:"history-evaluating","aria-hidden":"true"}),"评测中"]})]}),o.jsxs("div",{className:"history-action-slot",children:[z?o.jsx(WS,{className:"history-streaming-indicator",size:12,role:"status","aria-label":"正在生成"}):null,o.jsx("button",{type:"button",className:"history-more","aria-label":`管理历史会话:${$.title}`,title:"更多",onClick:()=>L(V=>V===$.id?null:$.id),children:o.jsx(yH,{className:"icon"})})]}),j===$.id&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-scrim",onClick:()=>L(null)}),o.jsx("div",{className:"history-menu",children:o.jsxs("button",{type:"button",className:"menu-item menu-item--danger",onClick:()=>{L(null),_($.id)},children:[o.jsx(Up,{className:"icon"})," 删除"]})})]})]},$.id)})]})})]}),o.jsx("div",{className:"sidebar-footer",children:o.jsx(Z6e,{activePage:i,access:a,userInfo:C,onAgentKitCli:x,onDeveloperResources:w,onSystemInfo:S,onIssueFeedback:E,onLogout:T})})]})}function qs(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n{}};function rj(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Y_.prototype=rj.prototype={constructor:Y_,on:function(e,t){var n=this._,r=e$e(e+"",n),i,s=-1,a=r.length;if(arguments.length<2){for(;++s0)for(var n=new Array(i),r=0,i,s;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),mq.hasOwnProperty(t)?{space:mq[t],local:e}:e}function n$e(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===v4&&t.documentElement.namespaceURI===v4?t.createElement(e):t.createElementNS(n,e)}}function r$e(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Hue(e){var t=ij(e);return(t.local?r$e:n$e)(t)}function i$e(){}function m7(e){return e==null?i$e:function(){return this.querySelector(e)}}function s$e(e){typeof e!="function"&&(e=m7(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=x&&(x=v+1);!(S=y[x])&&++x=0;)(a=r[i])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function N$e(e){e||(e=j$e);function t(f,h){return f&&h?e(f.__data__,h.__data__):!f-!h}for(var n=this._groups,r=n.length,i=new Array(r),s=0;st?1:e>=t?0:NaN}function R$e(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function I$e(){return Array.from(this)}function D$e(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?H$e:typeof t=="function"?X$e:q$e)(e,t,n??"")):n1(this.node(),e)}function n1(e,t){return e.style.getPropertyValue(t)||Yue(e).getComputedStyle(e,null).getPropertyValue(t)}function W$e(e){return function(){delete this[e]}}function Y$e(e,t){return function(){this[e]=t}}function Z$e(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function K$e(e,t){return arguments.length>1?this.each((t==null?W$e:typeof t=="function"?Z$e:Y$e)(e,t)):this.node()[e]}function Zue(e){return e.trim().split(/^|\s+/)}function g7(e){return e.classList||new Kue(e)}function Kue(e){this._node=e,this._names=Zue(e.getAttribute("class")||"")}Kue.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 Jue(e,t){for(var n=g7(e),r=-1,i=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function _8e(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,s;n()=>e;function w4(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:s,x:a,y:l,dx:c,dy:u,dispatch:d}){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:i,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}w4.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function M8e(e){return!e.ctrlKey&&!e.button}function L8e(){return this.parentNode}function $8e(e,t){return t??{x:e.x,y:e.y}}function B8e(){return navigator.maxTouchPoints||"ontouchstart"in this}function sde(){var e=M8e,t=L8e,n=$8e,r=B8e,i={},s=rj("start","drag","end"),a=0,l,c,u,d,f=0;function h(w){w.on("mousedown.drag",m).filter(r).on("touchstart.drag",y).on("touchmove.drag",O,P8e).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(w,S){if(!(d||!e.call(this,w,S))){var E=x(this,t.call(this,w,S),w,S,"mouse");E&&(Tl(w.view).on("mousemove.drag",g,Aw).on("mouseup.drag",b,Aw),rde(w.view),A5(w),u=!1,l=w.clientX,c=w.clientY,E("start",w))}}function g(w){if(my(w),!u){var S=w.clientX-l,E=w.clientY-c;u=S*S+E*E>f}i.mouse("drag",w)}function b(w){Tl(w.view).on("mousemove.drag mouseup.drag",null),ide(w.view,u),my(w),i.mouse("end",w)}function y(w,S){if(e.call(this,w,S)){var E=w.changedTouches,k=t.call(this,w,S),_=E.length,C,T;for(C=0;C<_;++C)(T=x(this,k,w,S,E[C].identifier,E[C]))&&(A5(w),T("start",w,E[C]))}}function O(w){var S=w.changedTouches,E=S.length,k,_;for(k=0;k>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?r2(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?r2(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=U8e.exec(e))?new Ho(t[1],t[2],t[3],1):(t=F8e.exec(e))?new Ho(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=z8e.exec(e))?r2(t[1],t[2],t[3],t[4]):(t=V8e.exec(e))?r2(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=H8e.exec(e))?wq(t[1],t[2]/100,t[3]/100,1):(t=q8e.exec(e))?wq(t[1],t[2]/100,t[3]/100,t[4]):gq.hasOwnProperty(e)?Oq(gq[e]):e==="transparent"?new Ho(NaN,NaN,NaN,0):null}function Oq(e){return new Ho(e>>16&255,e>>8&255,e&255,1)}function r2(e,t,n,r){return r<=0&&(e=t=n=NaN),new Ho(e,t,n,r)}function W8e(e){return e instanceof rE||(e=$g(e)),e?(e=e.rgb(),new Ho(e.r,e.g,e.b,e.opacity)):new Ho}function S4(e,t,n,r){return arguments.length===1?W8e(e):new Ho(e,t,n,r??1)}function Ho(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}b7(Ho,S4,ade(rE,{brighter(e){return e=e==null?AC:Math.pow(AC,e),new Ho(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Nw:Math.pow(Nw,e),new Ho(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ho(vg(this.r),vg(this.g),vg(this.b),NC(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:xq,formatHex:xq,formatHex8:Y8e,formatRgb:vq,toString:vq}));function xq(){return`#${ig(this.r)}${ig(this.g)}${ig(this.b)}`}function Y8e(){return`#${ig(this.r)}${ig(this.g)}${ig(this.b)}${ig((isNaN(this.opacity)?1:this.opacity)*255)}`}function vq(){const e=NC(this.opacity);return`${e===1?"rgb(":"rgba("}${vg(this.r)}, ${vg(this.g)}, ${vg(this.b)}${e===1?")":`, ${e})`}`}function NC(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function vg(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ig(e){return e=vg(e),(e<16?"0":"")+e.toString(16)}function wq(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ou(e,t,n,r)}function ode(e){if(e instanceof ou)return new ou(e.h,e.s,e.l,e.opacity);if(e instanceof rE||(e=$g(e)),!e)return new ou;if(e instanceof ou)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),a=NaN,l=s-i,c=(s+i)/2;return l?(t===s?a=(n-r)/l+(n0&&c<1?0:a,new ou(a,l,c,e.opacity)}function Z8e(e,t,n,r){return arguments.length===1?ode(e):new ou(e,t,n,r??1)}function ou(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}b7(ou,Z8e,ade(rE,{brighter(e){return e=e==null?AC:Math.pow(AC,e),new ou(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Nw:Math.pow(Nw,e),new ou(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,i=2*n-r;return new Ho(N5(e>=240?e-240:e+120,i,r),N5(e,i,r),N5(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new ou(Sq(this.h),i2(this.s),i2(this.l),NC(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=NC(this.opacity);return`${e===1?"hsl(":"hsla("}${Sq(this.h)}, ${i2(this.s)*100}%, ${i2(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Sq(e){return e=(e||0)%360,e<0?e+360:e}function i2(e){return Math.max(0,Math.min(1,e||0))}function N5(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 sj=e=>()=>e;function lde(e,t){return function(n){return e+n*t}}function K8e(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 dMt(e,t){var n=t-e;return n?lde(e,n>180||n<-180?n-360*Math.round(n/360):n):sj(isNaN(e)?t:e)}function J8e(e){return(e=+e)==1?cde:function(t,n){return n-t?K8e(t,n,e):sj(isNaN(t)?n:t)}}function cde(e,t){var n=t-e;return n?lde(e,n):sj(isNaN(e)?t:e)}const jC=function e(t){var n=J8e(t);function r(i,s){var a=n((i=S4(i)).r,(s=S4(s)).r),l=n(i.g,s.g),c=n(i.b,s.b),u=cde(i.opacity,s.opacity);return function(d){return i.r=a(d),i.g=l(d),i.b=c(d),i.opacity=u(d),i+""}}return r.gamma=e,r}(1);function e9e(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(s){for(i=0;in&&(s=t.slice(n,s),l[a]?l[a]+=s:l[++a]=s),(r=r[0])===(i=i[0])?l[a]?l[a]+=i:l[++a]=i:(l[++a]=null,c.push({i:a,x:Hu(r,i)})),n=j5.lastIndex;return n180?d+=360:d-u>180&&(u+=360),h.push({i:f.push(i(f)+"rotate(",null,r)-2,x:Hu(u,d)})):d&&f.push(i(f)+"rotate("+d+r)}function l(u,d,f,h){u!==d?h.push({i:f.push(i(f)+"skewX(",null,r)-2,x:Hu(u,d)}):d&&f.push(i(f)+"skewX("+d+r)}function c(u,d,f,h,m,g){if(u!==f||d!==h){var b=m.push(i(m)+"scale(",null,",",null,")");g.push({i:b-4,x:Hu(u,f)},{i:b-2,x:Hu(d,h)})}else(f!==1||h!==1)&&m.push(i(m)+"scale("+f+","+h+")")}return function(u,d){var f=[],h=[];return u=e(u),d=e(d),s(u.translateX,u.translateY,d.translateX,d.translateY,f,h),a(u.rotate,d.rotate,f,h),l(u.skewX,d.skewX,f,h),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,h),u=d=null,function(m){for(var g=-1,b=h.length,y;++g=0&&e._call.call(void 0,t),e=e._next;--r1}function _q(){Bg=(IC=Rw.now())+aj,r1=Fx=0;try{m9e()}finally{r1=0,b9e(),Bg=0}}function g9e(){var e=Rw.now(),t=e-IC;t>hde&&(aj-=t,IC=e)}function b9e(){for(var e,t=RC,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:RC=n);zx=e,_4(r)}function _4(e){if(!r1){Fx&&(Fx=clearTimeout(Fx));var t=e-Bg;t>24?(e<1/0&&(Fx=setTimeout(_q,e-Rw.now()-aj)),tx&&(tx=clearInterval(tx))):(tx||(IC=Rw.now(),tx=setInterval(g9e,hde)),r1=1,pde(_q))}}function Tq(e,t,n){var r=new DC;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var y9e=rj("start","end","cancel","interrupt"),O9e=[],gde=0,Cq=1,T4=2,K_=3,Aq=4,C4=5,J_=6;function oj(e,t,n,r,i,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;x9e(e,n,{name:t,index:r,group:i,on:y9e,tween:O9e,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:gde})}function O7(e,t){var n=_u(e,t);if(n.state>gde)throw new Error("too late; already scheduled");return n}function _d(e,t){var n=_u(e,t);if(n.state>K_)throw new Error("too late; already running");return n}function _u(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function x9e(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=mde(s,0,n.time);function s(u){n.state=Cq,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,f,h,m;if(n.state!==Cq)return c();for(d in r)if(m=r[d],m.name===n.name){if(m.state===K_)return Tq(a);m.state===Aq?(m.state=J_,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[d]):+dT4&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function Y9e(e,t,n){var r,i,s=W9e(t)?O7:_d;return function(){var a=s(this,e),l=a.on;l!==r&&(i=(r=l).copy()).on(t,n),a.on=i}}function Z9e(e,t){var n=this._id;return arguments.length<2?_u(this.node(),n).on.on(e):this.each(Y9e(n,e,t))}function K9e(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function J9e(){return this.on("end.remove",K9e(this._id))}function e7e(e){var t=this._name,n=this._id;typeof e!="function"&&(e=m7(e));for(var r=this._groups,i=r.length,s=new Array(i),a=0;a()=>e;function k7e(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){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:i}})}function _f(e,t,n){this.k=e,this.x=t,this.y=n}_f.prototype={constructor:_f,scale:function(e){return e===1?this:new _f(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new _f(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 lj=new _f(1,0,0);xde.prototype=_f.prototype;function xde(e){for(;!e.__zoom;)if(!(e=e.parentNode))return lj;return e.__zoom}function R5(e){e.stopImmediatePropagation()}function nx(e){e.preventDefault(),e.stopImmediatePropagation()}function _7e(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function T7e(){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 Nq(){return this.__zoom||lj}function C7e(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function A7e(){return navigator.maxTouchPoints||"ontouchstart"in this}function N7e(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function vde(){var e=_7e,t=T7e,n=N7e,r=C7e,i=A7e,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=Z_,u=rj("start","zoom","end"),d,f,h,m=500,g=150,b=0,y=10;function O(I){I.property("__zoom",Nq).on("wheel.zoom",_,{passive:!1}).on("mousedown.zoom",C).on("dblclick.zoom",T).filter(i).on("touchstart.zoom",A).on("touchmove.zoom",j).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}O.transform=function(I,M,N,D){var Q=I.selection?I.selection():I;Q.property("__zoom",Nq),I!==Q?S(I,M,N,D):Q.interrupt().each(function(){E(this,arguments).event(D).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},O.scaleBy=function(I,M,N,D){O.scaleTo(I,function(){var Q=this.__zoom.k,F=typeof M=="function"?M.apply(this,arguments):M;return Q*F},N,D)},O.scaleTo=function(I,M,N,D){O.transform(I,function(){var Q=t.apply(this,arguments),F=this.__zoom,$=N==null?w(Q):typeof N=="function"?N.apply(this,arguments):N,H=F.invert($),z=typeof M=="function"?M.apply(this,arguments):M;return n(x(v(F,z),$,H),Q,a)},N,D)},O.translateBy=function(I,M,N,D){O.transform(I,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof N=="function"?N.apply(this,arguments):N),t.apply(this,arguments),a)},null,D)},O.translateTo=function(I,M,N,D,Q){O.transform(I,function(){var F=t.apply(this,arguments),$=this.__zoom,H=D==null?w(F):typeof D=="function"?D.apply(this,arguments):D;return n(lj.translate(H[0],H[1]).scale($.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof N=="function"?-N.apply(this,arguments):-N),F,a)},D,Q)};function v(I,M){return M=Math.max(s[0],Math.min(s[1],M)),M===I.k?I:new _f(M,I.x,I.y)}function x(I,M,N){var D=M[0]-N[0]*I.k,Q=M[1]-N[1]*I.k;return D===I.x&&Q===I.y?I:new _f(I.k,D,Q)}function w(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function S(I,M,N,D){I.on("start.zoom",function(){E(this,arguments).event(D).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(D).end()}).tween("zoom",function(){var Q=this,F=arguments,$=E(Q,F).event(D),H=t.apply(Q,F),z=N==null?w(H):typeof N=="function"?N.apply(Q,F):N,B=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),V=Q.__zoom,Z=typeof M=="function"?M.apply(Q,F):M,ce=c(V.invert(z).concat(B/V.k),Z.invert(z).concat(B/Z.k));return function(be){if(be===1)be=Z;else{var ie=ce(be),q=B/ie[2];be=new _f(q,z[0]-ie[0]*q,z[1]-ie[1]*q)}$.zoom(null,be)}})}function E(I,M,N){return!N&&I.__zooming||new k(I,M)}function k(I,M){this.that=I,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(I,M),this.taps=0}k.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,M){return this.mouse&&I!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var M=Tl(this.that).datum();u.call(I,this.that,new k7e(I,{sourceEvent:this.sourceEvent,target:O,transform:this.that.__zoom,dispatch:u}),M)}};function _(I,...M){if(!e.apply(this,arguments))return;var N=E(this,M).event(I),D=this.__zoom,Q=Math.max(s[0],Math.min(s[1],D.k*Math.pow(2,r.apply(this,arguments)))),F=iu(I);if(N.wheel)(N.mouse[0][0]!==F[0]||N.mouse[0][1]!==F[1])&&(N.mouse[1]=D.invert(N.mouse[0]=F)),clearTimeout(N.wheel);else{if(D.k===Q)return;N.mouse=[F,D.invert(F)],eT(this),N.start()}nx(I),N.wheel=setTimeout($,g),N.zoom("mouse",n(x(v(D,Q),N.mouse[0],N.mouse[1]),N.extent,a));function $(){N.wheel=null,N.end()}}function C(I,...M){if(h||!e.apply(this,arguments))return;var N=I.currentTarget,D=E(this,M,!0).event(I),Q=Tl(I.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",B,!0),F=iu(I,N),$=I.clientX,H=I.clientY;rde(I.view),R5(I),D.mouse=[F,this.__zoom.invert(F)],eT(this),D.start();function z(V){if(nx(V),!D.moved){var Z=V.clientX-$,ce=V.clientY-H;D.moved=Z*Z+ce*ce>b}D.event(V).zoom("mouse",n(x(D.that.__zoom,D.mouse[0]=iu(V,N),D.mouse[1]),D.extent,a))}function B(V){Q.on("mousemove.zoom mouseup.zoom",null),ide(V.view,D.moved),nx(V),D.event(V).end()}}function T(I,...M){if(e.apply(this,arguments)){var N=this.__zoom,D=iu(I.changedTouches?I.changedTouches[0]:I,this),Q=N.invert(D),F=N.k*(I.shiftKey?.5:2),$=n(x(v(N,F),D,Q),t.apply(this,M),a);nx(I),l>0?Tl(this).transition().duration(l).call(S,$,D,I):Tl(this).call(O.transform,$,D,I)}}function A(I,...M){if(e.apply(this,arguments)){var N=I.touches,D=N.length,Q=E(this,M,I.changedTouches.length===D).event(I),F,$,H,z;for(R5(I),$=0;$`Seems like you have not used zustand provider 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.`},Iw=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],wde=["Enter"," ","Escape"],Sde={"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 i1;(function(e){e.Strict="strict",e.Loose="loose"})(i1||(i1={}));var wg;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(wg||(wg={}));var Dw;(function(e){e.Partial="partial",e.Full="full"})(Dw||(Dw={}));const Ede={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var ip;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ip||(ip={}));var Pw;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Pw||(Pw={}));var zt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(zt||(zt={}));const jq={[zt.Left]:zt.Right,[zt.Right]:zt.Left,[zt.Top]:zt.Bottom,[zt.Bottom]:zt.Top};function kde(e){return e===null?null:e?"valid":"invalid"}const _de=e=>"id"in e&&"source"in e&&"target"in e,j7e=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),v7=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),iE=(e,t=[0,0])=>{const{width:n,height:r}=gh(e),i=e.origin??t,s=n*i[0],a=r*i[1];return{x:e.position.x-s,y:e.position.y-a}},R7e=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,i)=>{const s=typeof i=="string";let a=!t.nodeLookup&&!s?i:void 0;t.nodeLookup&&(a=s?t.nodeLookup.get(i):v7(i)?i:t.nodeLookup.get(i.id));const l=a?PC(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return cj(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return uj(n)},sE=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(i=>{(t.filter===void 0||t.filter(i))&&(n=cj(n,PC(i)),r=!0)}),r?uj(n):{x:0,y:0,width:0,height:0}},w7=(e,t,[n,r,i]=[0,0,1],s=!1,a=!1)=>{const l={...J1(t,[n,r,i]),width:t.width/i,height:t.height/i},c=[];for(const u of e.values()){const{measured:d,selectable:f=!0,hidden:h=!1}=u;if(a&&!f||h)continue;const m=d.width??u.width??u.initialWidth??null,g=d.height??u.height??u.initialHeight??null,b=Mw(l,a1(u)),y=(m??0)*(g??0),O=s&&b>0;(!u.internals.handleBounds||O||b>=y||u.dragging)&&c.push(u)}return c},I7e=(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 D7e(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(i=>i.id)):null;return e.forEach(i=>{i.measured.width&&i.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!i.hidden)&&(!r||r.has(i.id))&&n.set(i.id,i)}),n}async function P7e({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:s},a){if(e.size===0)return!0;const l=D7e(e,a),c=sE(l),u=E7(c,t,n,(a==null?void 0:a.minZoom)??i,(a==null?void 0:a.maxZoom)??s,(a==null?void 0:a.padding)??.1);return await r.setViewport(u,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),!0}function Tde({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:s}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:c,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},d=a.origin??r;let f=a.extent||i;if(a.extent==="parent"&&!a.expandParent)if(!l)s==null||s("005",Ou.error005());else{const m=l.measured.width,g=l.measured.height;m&&g&&(f=[[c,u],[c+m,u+g]])}else l&&Ug(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const h=Ug(f)?Qg(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(s==null||s("015",Ou.error015())),{position:{x:h.x-c+(a.measured.width??0)*d[0],y:h.y-u+(a.measured.height??0)*d[1]},positionAbsolute:h}}async function M7e({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){const s=new Set(e.map(h=>h.id)),a=[];for(const h of n){if(h.deletable===!1)continue;const m=s.has(h.id),g=!m&&h.parentId&&a.find(b=>b.id===h.parentId);(m||g)&&a.push(h)}const l=new Set(t.map(h=>h.id)),c=r.filter(h=>h.deletable!==!1),d=I7e(a,c);for(const h of c)l.has(h.id)&&!d.find(g=>g.id===h.id)&&d.push(h);if(!i)return{edges:d,nodes:a};const f=await i({nodes:a,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:a}:{edges:[],nodes:[]}:f}const s1=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Qg=(e={x:0,y:0},t,n)=>({x:s1(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:s1(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Cde(e,t,n){const{width:r,height:i}=gh(n),{x:s,y:a}=n.internals.positionAbsolute;return Qg(e,[[s,a],[s+r,a+i]],t)}const Rq=(e,t,n)=>en?-s1(Math.abs(e-n),1,t)/t:0,S7=(e,t,n=15,r=40)=>{const i=Rq(e.x,r,t.width-r)*n,s=Rq(e.y,r,t.height-r)*n;return[i,s]},cj=(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)}),A4=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),uj=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),a1=(e,t=[0,0])=>{var i,s;const{x:n,y:r}=v7(e)?e.internals.positionAbsolute:iE(e,t);return{x:n,y:r,width:((i=e.measured)==null?void 0:i.width)??e.width??e.initialWidth??0,height:((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0}},PC=(e,t=[0,0])=>{var i,s;const{x:n,y:r}=v7(e)?e.internals.positionAbsolute:iE(e,t);return{x:n,y:r,x2:n+(((i=e.measured)==null?void 0:i.width)??e.width??e.initialWidth??0),y2:r+(((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0)}},Ade=(e,t)=>uj(cj(A4(e),A4(t))),Mw=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},Iq=e=>cu(e.width)&&cu(e.height)&&cu(e.x)&&cu(e.y),cu=e=>!isNaN(e)&&isFinite(e),Nde=(e,t)=>(n,r)=>{},aE=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),J1=({x:e,y:t},[n,r,i],s=!1,a=[1,1])=>{const l={x:(e-n)/i,y:(t-r)/i};return s?aE(l,a):l},o1=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function G0(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 L7e(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=G0(e,n),i=G0(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e=="object"){const r=G0(e.top??e.y??0,n),i=G0(e.bottom??e.y??0,n),s=G0(e.left??e.x??0,t),a=G0(e.right??e.x??0,t);return{top:r,right:a,bottom:i,left:s,x:s+a,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function $7e(e,t,n,r,i,s){const{x:a,y:l}=o1(e,[t,n,r]),{x:c,y:u}=o1({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=i-c,f=s-u;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(d),bottom:Math.floor(f)}}const E7=(e,t,n,r,i,s)=>{const a=L7e(s,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),d=s1(u,r,i),f=e.x+e.width/2,h=e.y+e.height/2,m=t/2-f*d,g=n/2-h*d,b=$7e(e,m,g,d,t,n),y={left:Math.min(b.left-a.left,0),top:Math.min(b.top-a.top,0),right:Math.min(b.right-a.right,0),bottom:Math.min(b.bottom-a.bottom,0)};return{x:m-y.left+y.right,y:g-y.top+y.bottom,zoom:d}},Lw=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ug(e){return e!=null&&e!=="parent"}function gh(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 k7(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 jde(e,t={width:0,height:0},n,r,i){const s={...e},a=r.get(n);if(a){const l=a.origin||i;s.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],s.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return s}function Dq(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function B7e(){let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}}function Q7e(e){return{...Sde,...e||{}}}function Tv(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){const{x:s,y:a}=uu(e),l=J1({x:s-((i==null?void 0:i.left)??0),y:a-((i==null?void 0:i.top)??0)},r),{x:c,y:u}=n?aE(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const _7=e=>({width:e.offsetWidth,height:e.offsetHeight}),Rde=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},U7e=["INPUT","SELECT","TEXTAREA"];function Ide(e){var r,i;const t=((i=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:i[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:U7e.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Dde=e=>"clientX"in e,uu=(e,t)=>{var s,a;const n=Dde(e),r=n?e.clientX:(s=e.touches)==null?void 0:s[0].clientX,i=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:i-((t==null?void 0:t.top)??0)}},Pq=(e,t,n,r,i)=>{const s=t.querySelectorAll(`.${e}`);return!s||!s.length?null:Array.from(s).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:i,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,..._7(a)}})};function Pde({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:s,targetControlX:a,targetControlY:l}){const c=e*.125+i*.375+a*.375+n*.125,u=t*.125+s*.375+l*.375+r*.125,d=Math.abs(c-e),f=Math.abs(u-t);return[c,u,d,f]}function o2(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Mq({pos:e,x1:t,y1:n,x2:r,y2:i,c:s}){switch(e){case zt.Left:return[t-o2(t-r,s),n];case zt.Right:return[t+o2(r-t,s),n];case zt.Top:return[t,n-o2(n-i,s)];case zt.Bottom:return[t,n+o2(i-n,s)]}}function Mde({sourceX:e,sourceY:t,sourcePosition:n=zt.Bottom,targetX:r,targetY:i,targetPosition:s=zt.Top,curvature:a=.25}){const[l,c]=Mq({pos:n,x1:e,y1:t,x2:r,y2:i,c:a}),[u,d]=Mq({pos:s,x1:r,y1:i,x2:e,y2:t,c:a}),[f,h,m,g]=Pde({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${l},${c} ${u},${d} ${r},${i}`,f,h,m,g]}function Lde({sourceX:e,sourceY:t,targetX:n,targetY:r}){const i=Math.abs(n-e)/2,s=n0}const V7e=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,H7e=(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)),q7e=(e,t,n={})=>{var s;if(!e.source||!e.target)return(s=n.onError)==null||s.call(n,"006",Ou.error006()),t;const r=n.getEdgeId||V7e;let i;return _de(e)?i={...e}:i={...e,id:r(e)},H7e(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function $de({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[i,s,a,l]=Lde({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,s,a,l]}const Lq={[zt.Left]:{x:-1,y:0},[zt.Right]:{x:1,y:0},[zt.Top]:{x:0,y:-1},[zt.Bottom]:{x:0,y:1}},X7e=({source:e,sourcePosition:t=zt.Bottom,target:n})=>t===zt.Left||t===zt.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function G7e({source:e,sourcePosition:t=zt.Bottom,target:n,targetPosition:r=zt.Top,center:i,offset:s,stepPosition:a}){const l=Lq[t],c=Lq[r],u={x:e.x+l.x*s,y:e.y+l.y*s},d={x:n.x+c.x*s,y:n.y+c.y*s},f=X7e({source:u,sourcePosition:t,target:d}),h=f.x!==0?"x":"y",m=f[h];let g=[],b,y;const O={x:0,y:0},v={x:0,y:0},[,,x,w]=Lde({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[h]*c[h]===-1){h==="x"?(b=i.x??u.x+(d.x-u.x)*a,y=i.y??(u.y+d.y)/2):(b=i.x??(u.x+d.x)/2,y=i.y??u.y+(d.y-u.y)*a);const _=[{x:b,y:u.y},{x:b,y:d.y}],C=[{x:u.x,y},{x:d.x,y}];l[h]===m?g=h==="x"?_:C:g=h==="x"?C:_}else{const _=[{x:u.x,y:d.y}],C=[{x:d.x,y:u.y}];if(h==="x"?g=l.x===m?C:_:g=l.y===m?_:C,t===r){const I=Math.abs(e[h]-n[h]);if(I<=s){const M=Math.min(s-1,s-I);l[h]===m?O[h]=(u[h]>e[h]?-1:1)*M:v[h]=(d[h]>n[h]?-1:1)*M}}if(t!==r){const I=h==="x"?"y":"x",M=l[h]===c[I],N=u[I]>d[I],D=u[I]=L?(b=(T.x+A.x)/2,y=g[0].y):(b=g[0].x,y=(T.y+A.y)/2)}const S={x:u.x+O.x,y:u.y+O.y},E={x:d.x+v.x,y:d.y+v.y};return[[e,...S.x!==g[0].x||S.y!==g[0].y?[S]:[],...g,...E.x!==g[g.length-1].x||E.y!==g[g.length-1].y?[E]:[],n],b,y,x,w]}function W7e(e,t,n,r){const i=Math.min($q(e,t)/2,$q(t,n)/2,r),{x:s,y:a}=t;if(e.x===s&&s===n.x||e.y===a&&a===n.y)return`L${s} ${a}`;if(e.y===a){const u=e.xn.id===t):e[0])||null}function N4(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function Z7e(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){const s=new Set;return e.reduce((a,l)=>([l.markerStart||r,l.markerEnd||i].forEach(c=>{if(c&&typeof c=="object"){const u=N4(c,t);s.has(u)||(a.push({id:u,color:c.color||n,...c}),s.add(u))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const Bde=1e3,K7e=10,T7={nodeOrigin:[0,0],nodeExtent:Iw,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},J7e={...T7,checkEquality:!0};function C7(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function eBe(e,t,n){const r=C7(T7,n);for(const i of e.values())if(i.parentId)N7(i,e,t,r);else{const s=iE(i,r.nodeOrigin),a=Ug(i.extent)?i.extent:r.nodeExtent,l=Qg(s,a,gh(i));i.internals.positionAbsolute=l}}function tBe(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const i of e.handles){const s={id:i.id,width:i.width??1,height:i.height??1,nodeId:e.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?n.push(s):i.type==="target"&&r.push(s)}return{source:n,target:r}}function A7(e){return e==="manual"}function j4(e,t,n,r={}){var d,f;const i=C7(J7e,r),s={i:0},a=new Map(t),l=i!=null&&i.elevateNodesOnSelect&&!A7(i.zIndexMode)?Bde:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const h of e){let m=a.get(h.id);if(i.checkEquality&&h===(m==null?void 0:m.internals.userNode))t.set(h.id,m);else{const g=iE(h,i.nodeOrigin),b=Ug(h.extent)?h.extent:i.nodeExtent,y=Qg(g,b,gh(h));m={...i.defaults,...h,measured:{width:(d=h.measured)==null?void 0:d.width,height:(f=h.measured)==null?void 0:f.height},internals:{positionAbsolute:y,handleBounds:tBe(h,m),z:Qde(h,l,i.zIndexMode),userNode:h}},t.set(h.id,m)}(m.measured===void 0||m.measured.width===void 0||m.measured.height===void 0)&&!m.hidden&&(c=!1),h.parentId&&N7(m,t,n,r,s),u||(u=h.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function nBe(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 N7(e,t,n,r,i){const{elevateNodesOnSelect:s,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=C7(T7,r),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}nBe(e,n),i&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++i.i,d.internals.z=d.internals.z+i.i*K7e),i&&d.internals.rootParentIndex!==void 0&&(i.i=d.internals.rootParentIndex);const f=s&&!A7(c)?Bde:0,{x:h,y:m,z:g}=rBe(e,d,a,l,f,c),{positionAbsolute:b}=e.internals,y=h!==b.x||m!==b.y;(y||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:h,y:m}:b,z:g}})}function Qde(e,t,n){const r=cu(e.zIndex)?e.zIndex:0;return A7(n)?r:r+(e.selected?t:0)}function rBe(e,t,n,r,i,s){const{x:a,y:l}=t.internals.positionAbsolute,c=gh(e),u=iE(e,n),d=Ug(e.extent)?Qg(u,e.extent,c):u;let f=Qg({x:a+d.x,y:l+d.y},r,c);e.extent==="parent"&&(f=Cde(f,c,t));const h=Qde(e,i,s),m=t.internals.z??0;return{x:f.x,y:f.y,z:m>=h?m+1:h}}function j7(e,t,n,r=[0,0]){var a;const i=[],s=new Map;for(const l of e){const c=t.get(l.parentId);if(!c)continue;const u=((a=s.get(l.parentId))==null?void 0:a.expandedRect)??a1(c),d=Ade(u,l.rect);s.set(l.parentId,{expandedRect:d,parent:c})}return s.size>0&&s.forEach(({expandedRect:l,parent:c},u)=>{var x;const d=c.internals.positionAbsolute,f=gh(c),h=c.origin??r,m=l.x0||g>0||O||v)&&(i.push({id:u,type:"position",position:{x:c.position.x-m+O,y:c.position.y-g+v}}),(x=n.get(u))==null||x.forEach(w=>{e.some(S=>S.id===w.id)||i.push({id:w.id,type:"position",position:{x:w.position.x+m,y:w.position.y+g}})})),(f.width0){const m=j7(h,t,n,i);u.push(...m)}return{changes:u,updatedInternals:c}}async function sBe({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:s}){if(!t||!e.x&&!e.y)return!1;const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,s]],r);return!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2])}function Fq(e,t,n,r,i,s){let a=i;const l=r.get(a)||new Map;r.set(a,l.set(n,t)),a=`${i}-${e}`;const c=r.get(a)||new Map;if(r.set(a,c.set(n,t)),s){a=`${i}-${e}-${s}`;const u=r.get(a)||new Map;r.set(a,u.set(n,t))}}function Ude(e,t,n){e.clear(),t.clear();for(const r of n){const{source:i,target:s,sourceHandle:a=null,targetHandle:l=null}=r,c={edgeId:r.id,source:i,target:s,sourceHandle:a,targetHandle:l},u=`${i}-${a}--${s}-${l}`,d=`${s}-${l}--${i}-${a}`;Fq("source",c,d,e,i,a),Fq("target",c,u,e,s,l),t.set(r.id,r)}}function Fde(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Fde(n,t):!1}function zq(e,t,n){var i;let r=e;do{if((i=r==null?void 0:r.matches)!=null&&i.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function aBe(e,t,n,r){const i=new Map;for(const[s,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!Fde(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(s);l&&i.set(s,{id:s,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return i}function I5({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const i=[];for(const[u,d]of t){const f=(a=n.get(u))==null?void 0:a.internals.userNode;f&&i.push({...f,position:d.position,dragging:r})}if(!e)return[i[0],i];const s=(l=n.get(e))==null?void 0:l.internals.userNode;return[s?{...s,position:((c=t.get(e))==null?void 0:c.position)||s.position,dragging:r}:i[0],i]}function oBe({dragItems:e,snapGrid:t,x:n,y:r}){const i=e.values().next().value;if(!i)return null;const s={x:n-i.distance.x,y:r-i.distance.y},a=aE(s,t);return{x:a.x-s.x,y:a.y-s.y}}function lBe({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let s={x:null,y:null},a=0,l=new Map,c=!1,u={x:0,y:0},d=null,f=!1,h=null,m=!1,g=!1,b=null;function y({noDragClassName:v,handleSelector:x,domNode:w,isSelectable:S,nodeId:E,nodeClickDistance:k=0}){h=Tl(w);function _({x:j,y:L}){const{nodeLookup:I,nodeExtent:M,snapGrid:N,snapToGrid:D,nodeOrigin:Q,onNodeDrag:F,onSelectionDrag:$,onError:H,updateNodePositions:z}=t();s={x:j,y:L};let B=!1;const V=l.size>1,Z=V&&M?A4(sE(l)):null,ce=V&&D?oBe({dragItems:l,snapGrid:N,x:j,y:L}):null;for(const[be,ie]of l){if(!I.has(be))continue;let q={x:j-ie.distance.x,y:L-ie.distance.y};D&&(q=ce?{x:Math.round(q.x+ce.x),y:Math.round(q.y+ce.y)}:aE(q,N));let X=null;if(V&&M&&!ie.extent&&Z){const{positionAbsolute:xe}=ie.internals,Me=xe.x-Z.x+M[0][0],Ae=xe.x+ie.measured.width-Z.x2+M[1][0],He=xe.y-Z.y+M[0][1],et=xe.y+ie.measured.height-Z.y2+M[1][1];X=[[Me,He],[Ae,et]]}const{position:K,positionAbsolute:de}=Tde({nodeId:be,nextPosition:q,nodeLookup:I,nodeExtent:X||M,nodeOrigin:Q,onError:H});B=B||ie.position.x!==K.x||ie.position.y!==K.y,ie.position=K,ie.internals.positionAbsolute=de}if(g=g||B,!!B&&(z(l,!0),b&&(r||F||!E&&$))){const[be,ie]=I5({nodeId:E,dragItems:l,nodeLookup:I});r==null||r(b,l,be,ie),F==null||F(b,be,ie),E||$==null||$(b,ie)}}async function C(){if(!d)return;const{transform:j,panBy:L,autoPanSpeed:I,autoPanOnNodeDrag:M}=t();if(!M){c=!1,cancelAnimationFrame(a);return}const[N,D]=S7(u,d,I);(N!==0||D!==0)&&(s.x=(s.x??0)-N/j[2],s.y=(s.y??0)-D/j[2],await L({x:N,y:D})&&_(s)),a=requestAnimationFrame(C)}function T(j){var V;const{nodeLookup:L,multiSelectionActive:I,nodesDraggable:M,transform:N,snapGrid:D,snapToGrid:Q,selectNodesOnDrag:F,onNodeDragStart:$,onSelectionDragStart:H,unselectNodesAndEdges:z}=t();f=!0,(!F||!S)&&!I&&E&&((V=L.get(E))!=null&&V.selected||z()),S&&F&&E&&(e==null||e(E));const B=Tv(j.sourceEvent,{transform:N,snapGrid:D,snapToGrid:Q,containerBounds:d});if(s=B,l=aBe(L,M,B,E),l.size>0&&(n||$||!E&&H)){const[Z,ce]=I5({nodeId:E,dragItems:l,nodeLookup:L});n==null||n(j.sourceEvent,l,Z,ce),$==null||$(j.sourceEvent,Z,ce),E||H==null||H(j.sourceEvent,ce)}}const A=sde().clickDistance(k).on("start",j=>{const{domNode:L,nodeDragThreshold:I,transform:M,snapGrid:N,snapToGrid:D}=t();d=(L==null?void 0:L.getBoundingClientRect())||null,m=!1,g=!1,b=j.sourceEvent,I===0&&T(j),s=Tv(j.sourceEvent,{transform:M,snapGrid:N,snapToGrid:D,containerBounds:d}),u=uu(j.sourceEvent,d)}).on("drag",j=>{const{autoPanOnNodeDrag:L,transform:I,snapGrid:M,snapToGrid:N,nodeDragThreshold:D,nodeLookup:Q}=t(),F=Tv(j.sourceEvent,{transform:I,snapGrid:M,snapToGrid:N,containerBounds:d});if(b=j.sourceEvent,(j.sourceEvent.type==="touchmove"&&j.sourceEvent.touches.length>1||E&&!Q.has(E))&&(m=!0),!m){if(!c&&L&&f&&(c=!0,C()),!f){const $=uu(j.sourceEvent,d),H=$.x-u.x,z=$.y-u.y;Math.sqrt(H*H+z*z)>D&&T(j)}(s.x!==F.xSnapped||s.y!==F.ySnapped)&&l&&f&&(u=uu(j.sourceEvent,d),_(F))}}).on("end",j=>{if(!f||m){m&&l.size>0&&t().updateNodePositions(l,!1);return}if(c=!1,f=!1,cancelAnimationFrame(a),l.size>0){const{nodeLookup:L,updateNodePositions:I,onNodeDragStop:M,onSelectionDragStop:N}=t();if(g&&(I(l,!1),g=!1),i||M||!E&&N){const[D,Q]=I5({nodeId:E,dragItems:l,nodeLookup:L,dragging:!1});i==null||i(j.sourceEvent,l,D,Q),M==null||M(j.sourceEvent,D,Q),E||N==null||N(j.sourceEvent,Q)}}}).filter(j=>{const L=j.target;return!j.button&&(!v||!zq(L,`.${v}`,w))&&(!x||zq(L,x,w))});h.call(A)}function O(){h==null||h.on(".drag",null)}return{update:y,destroy:O}}function cBe(e,t,n){const r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const s of t.values())Mw(i,a1(s))>0&&r.push(s);return r}const uBe=250;function dBe(e,t,n,r){var l,c;let i=[],s=1/0;const a=cBe(e,n,t+uBe);for(const u of a){const d=[...((l=u.internals.handleBounds)==null?void 0:l.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of d){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:h,y:m}=Fg(u,f,f.position,!0),g=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(m-e.y,2));g>t||(g1){const u=r.type==="source"?"target":"source";return i.find(d=>d.type===u)??i[0]}return i[0]}function zde(e,t,n,r,i,s=!1){var u,d,f;const a=r.get(e);if(!a)return null;const l=i==="strict"?(u=a.internals.handleBounds)==null?void 0:u[t]:[...((d=a.internals.handleBounds)==null?void 0:d.source)??[],...((f=a.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?l==null?void 0:l.find(h=>h.id===n):l==null?void 0:l[0])??null;return c&&s?{...c,...Fg(a,c,c.position,!0)}:c}function Vde(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function fBe(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Hde=()=>!0;function hBe(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:s,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:f,panBy:h,cancelConnection:m,onConnectStart:g,onConnect:b,onConnectEnd:y,isValidConnection:O=Hde,onReconnectEnd:v,updateConnection:x,getTransform:w,getFromHandle:S,autoPanSpeed:E,dragThreshold:k=1,handleDomNode:_}){const C=Rde(e.target);let T=0,A;const{x:j,y:L}=uu(e),I=Vde(s,_),M=l==null?void 0:l.getBoundingClientRect();let N=!1;if(!M||!I)return;const D=zde(i,I,r,c,t);if(!D)return;let Q=uu(e,M),F=!1,$=null,H=!1,z=null;function B(){if(!d||!M)return;const[K,de]=S7(Q,M,E);h({x:K,y:de}),T=requestAnimationFrame(B)}const V={...D,nodeId:i,type:I,position:D.position},Z=c.get(i);let be={inProgress:!0,isValid:null,from:Fg(Z,V,zt.Left,!0),fromHandle:V,fromPosition:V.position,fromNode:Z,to:Q,toHandle:null,toPosition:jq[V.position],toNode:null,pointer:Q};function ie(){N=!0,x(be),g==null||g(e,{nodeId:i,handleId:r,handleType:I})}k===0&&ie();function q(K){if(!N){const{x:et,y:Te}=uu(K),Re=et-j,he=Te-L;if(!(Re*Re+he*he>k*k))return;ie()}if(!S()||!V){X(K);return}const de=w();Q=uu(K,M),A=dBe(J1(Q,de,!1,[1,1]),n,c,V),F||(B(),F=!0);const xe=qde(K,{handle:A,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:a?"target":"source",isValidConnection:O,doc:C,lib:u,flowId:f,nodeLookup:c});z=xe.handleDomNode,$=xe.connection,H=fBe(!!A,xe.isValid);const Me=c.get(i),Ae=Me?Fg(Me,V,zt.Left,!0):be.from,He={...be,from:Ae,isValid:H,to:xe.toHandle&&H?o1({x:xe.toHandle.x,y:xe.toHandle.y},de):Q,toHandle:xe.toHandle,toPosition:H&&xe.toHandle?xe.toHandle.position:jq[V.position],toNode:xe.toHandle?c.get(xe.toHandle.nodeId):null,pointer:Q};x(He),be=He}function X(K){if(!("touches"in K&&K.touches.length>0)){if(N){(A||z)&&$&&H&&(b==null||b($));const{inProgress:de,...xe}=be,Me={...xe,toPosition:be.toHandle?be.toPosition:null};y==null||y(K,Me),s&&(v==null||v(K,Me))}m(),cancelAnimationFrame(T),F=!1,H=!1,$=null,z=null,C.removeEventListener("mousemove",q),C.removeEventListener("mouseup",X),C.removeEventListener("touchmove",q),C.removeEventListener("touchend",X)}}C.addEventListener("mousemove",q),C.addEventListener("mouseup",X),C.addEventListener("touchmove",q),C.addEventListener("touchend",X)}function qde(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:s,doc:a,lib:l,flowId:c,isValidConnection:u=Hde,nodeLookup:d}){const f=s==="target",h=t?a.querySelector(`.${l}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:m,y:g}=uu(e),b=a.elementFromPoint(m,g),y=b!=null&&b.classList.contains(`${l}-flow__handle`)?b:h,O={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const v=Vde(void 0,y),x=y.getAttribute("data-nodeid"),w=y.getAttribute("data-handleid"),S=y.classList.contains("connectable"),E=y.classList.contains("connectableend");if(!x||!v)return O;const k={source:f?x:r,sourceHandle:f?w:i,target:f?r:x,targetHandle:f?i:w};O.connection=k;const C=S&&E&&(n===i1.Strict?f&&v==="source"||!f&&v==="target":x!==r||w!==i);O.isValid=C&&u(k),O.toHandle=zde(x,v,w,d,n,!0)}return O}const R4={onPointerDown:hBe,isValid:qde};function pBe({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const i=Tl(e);function s({translateExtent:l,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:h=!0,inversePan:m=!1}){const g=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const w=n(),S=x.sourceEvent.ctrlKey&&Lw()?10:1,E=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*d,k=w[2]*Math.pow(2,E*S);t.scaleTo(k)};let b=[0,0];const y=x=>{(x.sourceEvent.type==="mousedown"||x.sourceEvent.type==="touchstart")&&(b=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY])},O=x=>{const w=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!t)return;const S=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],E=[S[0]-b[0],S[1]-b[1]];b=S;const k=r()*Math.max(w[2],Math.log(w[2]))*(m?-1:1),_={x:w[0]-E[0]*k,y:w[1]-E[1]*k},C=[[0,0],[c,u]];t.setViewportConstrained({x:_.x,y:_.y,zoom:w[2]},C,l)},v=vde().on("start",y).on("zoom",f?O:null).on("zoom.wheel",h?g:null);i.call(v,{})}function a(){i.on("zoom",null)}return{update:s,destroy:a,pointer:iu}}const dj=e=>({x:e.x,y:e.y,zoom:e.k}),D5=({x:e,y:t,zoom:n})=>lj.translate(e,t).scale(n),Vb=(e,t)=>e.target.closest(`.${t}`),Xde=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),mBe=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,P5=(e,t=0,n=mBe,r=()=>{})=>{const i=typeof t=="number"&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on("end",r):e},Gde=e=>{const t=e.ctrlKey&&Lw()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function gBe({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:s,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(Vb(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&a){const y=iu(d),O=Gde(d),v=f*Math.pow(2,O);r.scaleTo(n,v,y,d);return}const h=d.deltaMode===1?20:1;let m=i===wg.Vertical?0:d.deltaX*h,g=i===wg.Horizontal?0:d.deltaY*h;!Lw()&&d.shiftKey&&i!==wg.Vertical&&(m=d.deltaY*h,g=0),r.translateBy(n,-(m/f)*s,-(g/f)*s,{internal:!0});const b=dj(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(d,b),e.panScrollTimeout=setTimeout(()=>{u==null||u(d,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(d,b))}}function bBe({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){const s=r.type==="wheel",a=!t&&s&&!r.ctrlKey,l=Vb(r,e);if(r.ctrlKey&&s&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,i)}}function yBe({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var s,a,l;if((s=r.sourceEvent)!=null&&s.internal)return;const i=dj(r.transform);e.mouseButton=((a=r.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=i,((l=r.sourceEvent)==null?void 0:l.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,i))}}function OBe({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return s=>{var a,l;e.usedRightMouseButton=!!(n&&Xde(t,e.mouseButton??0)),(a=s.sourceEvent)!=null&&a.sync||r([s.transform.x,s.transform.y,s.transform.k]),i&&!((l=s.sourceEvent)!=null&&l.internal)&&(i==null||i(s.sourceEvent,dj(s.transform)))}}function xBe({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:s}){return a=>{var l;if(!((l=a.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,s&&Xde(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&s(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){const c=dj(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i==null||i(a.sourceEvent,c)},n?150:0)}}}function vBe({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:d}){return f=>{var y;const h=e||t,m=n&&f.ctrlKey,g=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Vb(f,`${u}-flow__node`)||Vb(f,`${u}-flow__edge`)))return!0;if(!r&&!h&&!i&&!s&&!n||a||d&&!g||Vb(f,l)&&g||Vb(f,c)&&(!g||i&&g&&!e)||!n&&f.ctrlKey&&g)return!1;if(!n&&f.type==="touchstart"&&((y=f.touches)==null?void 0:y.length)>1)return f.preventDefault(),!1;if(!h&&!i&&!m&&g||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const b=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||g)&&b}}function wBe({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:s,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),f=vde().scaleExtent([t,n]).translateExtent(r),h=Tl(e).call(f);v({x:i.x,y:i.y,zoom:s1(i.zoom,t,n)},[[0,0],[d.width,d.height]],r);const m=h.on("wheel.zoom"),g=h.on("dblclick.zoom");f.wheelDelta(Gde);async function b(A,j){return h?new Promise(L=>{f==null||f.interpolate((j==null?void 0:j.interpolate)==="linear"?_v:Z_).transform(P5(h,j==null?void 0:j.duration,j==null?void 0:j.ease,()=>L(!0)),A)}):!1}function y({noWheelClassName:A,noPanClassName:j,onPaneContextMenu:L,userSelectionActive:I,panOnScroll:M,panOnDrag:N,panOnScrollMode:D,panOnScrollSpeed:Q,preventScrolling:F,zoomOnPinch:$,zoomOnScroll:H,zoomOnDoubleClick:z,zoomActivationKeyPressed:B,lib:V,onTransformChange:Z,connectionInProgress:ce,paneClickDistance:be,selectionOnDrag:ie}){I&&!u.isZoomingOrPanning&&O();const q=M&&!B&&!I;f.clickDistance(ie?1/0:!cu(be)||be<0?0:be);const X=q?gBe({zoomPanValues:u,noWheelClassName:A,d3Selection:h,d3Zoom:f,panOnScrollMode:D,panOnScrollSpeed:Q,zoomOnPinch:$,onPanZoomStart:a,onPanZoom:s,onPanZoomEnd:l}):bBe({noWheelClassName:A,preventScrolling:F,d3ZoomHandler:m});h.on("wheel.zoom",X,{passive:!1});const K=yBe({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",K);const de=OBe({zoomPanValues:u,panOnDrag:N,onPaneContextMenu:!!L,onPanZoom:s,onTransformChange:Z});f.on("zoom",de);const xe=xBe({zoomPanValues:u,panOnDrag:N,panOnScroll:M,onPaneContextMenu:L,onPanZoomEnd:l,onDraggingChange:c});f.on("end",xe);const Me=vBe({zoomActivationKeyPressed:B,panOnDrag:N,zoomOnScroll:H,panOnScroll:M,zoomOnDoubleClick:z,zoomOnPinch:$,userSelectionActive:I,noPanClassName:j,noWheelClassName:A,lib:V,connectionInProgress:ce});f.filter(Me),z?h.on("dblclick.zoom",g):h.on("dblclick.zoom",null)}function O(){f.on("zoom",null)}async function v(A,j,L){const I=D5(A),M=f==null?void 0:f.constrain()(I,j,L);return M&&await b(M),M}async function x(A,j){const L=D5(A);return await b(L,j),L}function w(A){if(h){const j=D5(A),L=h.property("__zoom");(L.k!==A.zoom||L.x!==A.x||L.y!==A.y)&&(f==null||f.transform(h,j,null,{sync:!0}))}}function S(){const A=h?xde(h.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}async function E(A,j){return h?new Promise(L=>{f==null||f.interpolate((j==null?void 0:j.interpolate)==="linear"?_v:Z_).scaleTo(P5(h,j==null?void 0:j.duration,j==null?void 0:j.ease,()=>L(!0)),A)}):!1}async function k(A,j){return h?new Promise(L=>{f==null||f.interpolate((j==null?void 0:j.interpolate)==="linear"?_v:Z_).scaleBy(P5(h,j==null?void 0:j.duration,j==null?void 0:j.ease,()=>L(!0)),A)}):!1}function _(A){f==null||f.scaleExtent(A)}function C(A){f==null||f.translateExtent(A)}function T(A){const j=!cu(A)||A<0?0:A;f==null||f.clickDistance(j)}return{update:y,destroy:O,setViewport:x,setViewportConstrained:v,getViewport:S,scaleTo:E,scaleBy:k,setScaleExtent:_,setTranslateExtent:C,syncViewport:w,setClickDistance:T}}var l1;(function(e){e.Line="line",e.Handle="handle"})(l1||(l1={}));function SBe({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:s}){const a=e-t,l=n-r,c=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&i&&(c[0]=c[0]*-1),l&&s&&(c[1]=c[1]*-1),c}function Vq(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),i=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:i}}function Lh(e,t){return Math.max(0,t-e)}function $h(e,t){return Math.max(0,e-t)}function l2(e,t,n){return Math.max(0,t-e,e-n)}function Hq(e,t){return e?!t:t}function EBe(e,t,n,r,i,s,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:f}=t,h=d&&f,{xSnapped:m,ySnapped:g}=n,{minWidth:b,maxWidth:y,minHeight:O,maxHeight:v}=r,{x,y:w,width:S,height:E,aspectRatio:k}=e;let _=Math.floor(d?m-e.pointerX:0),C=Math.floor(f?g-e.pointerY:0);const T=S+(c?-_:_),A=E+(u?-C:C),j=-s[0]*S,L=-s[1]*E;let I=l2(T,b,y),M=l2(A,O,v);if(a){let Q=0,F=0;c&&_<0?Q=Lh(x+_+j,a[0][0]):!c&&_>0&&(Q=$h(x+T+j,a[1][0])),u&&C<0?F=Lh(w+C+L,a[0][1]):!u&&C>0&&(F=$h(w+A+L,a[1][1])),I=Math.max(I,Q),M=Math.max(M,F)}if(l){let Q=0,F=0;c&&_>0?Q=$h(x+_,l[0][0]):!c&&_<0&&(Q=Lh(x+T,l[1][0])),u&&C>0?F=$h(w+C,l[0][1]):!u&&C<0&&(F=Lh(w+A,l[1][1])),I=Math.max(I,Q),M=Math.max(M,F)}if(i){if(d){const Q=l2(T/k,O,v)*k;if(I=Math.max(I,Q),a){let F=0;!c&&!u||c&&!u&&h?F=$h(w+L+T/k,a[1][1])*k:F=Lh(w+L+(c?_:-_)/k,a[0][1])*k,I=Math.max(I,F)}if(l){let F=0;!c&&!u||c&&!u&&h?F=Lh(w+T/k,l[1][1])*k:F=$h(w+(c?_:-_)/k,l[0][1])*k,I=Math.max(I,F)}}if(f){const Q=l2(A*k,b,y)/k;if(M=Math.max(M,Q),a){let F=0;!c&&!u||u&&!c&&h?F=$h(x+A*k+j,a[1][0])/k:F=Lh(x+(u?C:-C)*k+j,a[0][0])/k,M=Math.max(M,F)}if(l){let F=0;!c&&!u||u&&!c&&h?F=Lh(x+A*k,l[1][0])/k:F=$h(x+(u?C:-C)*k,l[0][0])/k,M=Math.max(M,F)}}}C=C+(C<0?M:-M),_=_+(_<0?I:-I),i&&(h?T>A*k?C=(Hq(c,u)?-_:_)/k:_=(Hq(c,u)?-C:C)*k:d?(C=_/k,u=c):(_=C*k,c=u));const N=c?x+_:x,D=u?w+C:w;return{width:S+(c?-_:_),height:E+(u?-C:C),x:s[0]*_*(c?-1:1)+N,y:s[1]*C*(u?-1:1)+D}}const Wde={width:0,height:0,x:0,y:0},kBe={...Wde,pointerX:0,pointerY:0,aspectRatio:1};function _Be(e,t,n){const r=t.position.x+e.position.x,i=t.position.y+e.position.y,s=e.measured.width??0,a=e.measured.height??0,l=n[0]*s,c=n[1]*a;return[[r-l,i-c],[r+s-l,i+a-c]]}function TBe({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){const s=Tl(e);let a={controlDirection:Vq("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:d,keepAspectRatio:f,resizeDirection:h,onResizeStart:m,onResize:g,onResizeEnd:b,shouldResize:y}){let O={...Wde},v={...kBe};a={boundaries:d,resizeDirection:h,keepAspectRatio:f,controlDirection:Vq(u)};let x,w=null,S=[],E,k,_,C=!1;const T=sde().on("start",A=>{const{nodeLookup:j,transform:L,snapGrid:I,snapToGrid:M,nodeOrigin:N,paneDomNode:D}=n();if(x=j.get(t),!x)return;w=(D==null?void 0:D.getBoundingClientRect())??null;const{xSnapped:Q,ySnapped:F}=Tv(A.sourceEvent,{transform:L,snapGrid:I,snapToGrid:M,containerBounds:w});O={width:x.measured.width??0,height:x.measured.height??0,x:x.position.x??0,y:x.position.y??0},v={...O,pointerX:Q,pointerY:F,aspectRatio:O.width/O.height},E=void 0,k=Ug(x.extent)?x.extent:void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(E=j.get(x.parentId)),E&&x.extent==="parent"&&(k=[[0,0],[E.measured.width,E.measured.height]]),S=[],_=void 0;for(const[$,H]of j)if(H.parentId===t&&(S.push({id:$,position:{...H.position},extent:H.extent}),H.extent==="parent"||H.expandParent)){const z=_Be(H,x,H.origin??N);_?_=[[Math.min(z[0][0],_[0][0]),Math.min(z[0][1],_[0][1])],[Math.max(z[1][0],_[1][0]),Math.max(z[1][1],_[1][1])]]:_=z}m==null||m(A,{...O})}).on("drag",A=>{const{transform:j,snapGrid:L,snapToGrid:I,nodeOrigin:M}=n(),N=Tv(A.sourceEvent,{transform:j,snapGrid:L,snapToGrid:I,containerBounds:w}),D=[];if(!x)return;const{x:Q,y:F,width:$,height:H}=O,z={},B=x.origin??M,{width:V,height:Z,x:ce,y:be}=EBe(v,a.controlDirection,N,a.boundaries,a.keepAspectRatio,B,k,_),ie=V!==$,q=Z!==H,X=ce!==Q&&ie,K=be!==F&&q;if(!X&&!K&&!ie&&!q)return;if((X||K||B[0]===1||B[1]===1)&&(z.x=X?ce:O.x,z.y=K?be:O.y,O.x=z.x,O.y=z.y,S.length>0)){const Ae=ce-Q,He=be-F;for(const et of S)et.position={x:et.position.x-Ae+B[0]*(V-$),y:et.position.y-He+B[1]*(Z-H)},D.push(et)}if((ie||q)&&(z.width=ie&&(!a.resizeDirection||a.resizeDirection==="horizontal")?V:O.width,z.height=q&&(!a.resizeDirection||a.resizeDirection==="vertical")?Z:O.height,O.width=z.width,O.height=z.height),E&&x.expandParent){const Ae=B[0]*(z.width??0);z.x&&z.x{C&&(b==null||b(A,{...O}),i==null||i({...O}),C=!1)});s.call(T)}function c(){s.on(".drag",null)}return{update:l,destroy:c}}var Yde={exports:{}},Zde={},Kde={exports:{}},Jde={};/** +`)},HPe=0,q0=[];function qPe(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),i=p.useState(HPe++)[0],s=p.useState(uce)[0],a=p.useRef(e);p.useEffect(function(){a.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var b=hPe([e.lockRef.current],(e.shards||[]).map(XH),!0).filter(Boolean);return b.forEach(function(y){return y.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),b.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=p.useCallback(function(b,y){if("touches"in b&&b.touches.length===2||b.type==="wheel"&&b.ctrlKey)return!a.current.allowPinchZoom;var O=Yk(b),v=n.current,x="deltaX"in b?b.deltaX:v[0]-O[0],w="deltaY"in b?b.deltaY:v[1]-O[1],S,E=b.target,k=Math.abs(x)>Math.abs(w)?"h":"v";if("touches"in b&&k==="h"&&E.type==="range")return!1;var _=window.getSelection(),C=_&&_.anchorNode,T=C?C===E||C.contains(E):!1;if(T)return!1;var A=HH(k,E);if(!A)return!0;if(A?S=k:(S=k==="v"?"h":"v",A=HH(k,E)),!A)return!1;if(!r.current&&"changedTouches"in b&&(x||w)&&(r.current=S),!S)return!0;var j=r.current||S;return FPe(j,y,b,j==="h"?x:w)},[]),c=p.useCallback(function(b){var y=b;if(!(!q0.length||q0[q0.length-1]!==s)){var O="deltaY"in y?qH(y):Yk(y),v=t.current.filter(function(S){return S.name===y.type&&(S.target===y.target||y.target===S.shadowParent)&&zPe(S.delta,O)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var x=(a.current.shards||[]).map(XH).filter(Boolean).filter(function(S){return S.contains(y.target)}),w=x.length>0?l(y,x[0]):!a.current.noIsolation;w&&y.cancelable&&y.preventDefault()}}},[]),u=p.useCallback(function(b,y,O,v){var x={name:b,delta:y,target:O,should:v,shadowParent:XPe(O)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(w){return w!==x})},1)},[]),d=p.useCallback(function(b){n.current=Yk(b),r.current=void 0},[]),f=p.useCallback(function(b){u(b.type,qH(b),b.target,l(b,e.lockRef.current))},[]),h=p.useCallback(function(b){u(b.type,Yk(b),b.target,l(b,e.lockRef.current))},[]);p.useEffect(function(){return q0.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,H0),document.addEventListener("touchmove",c,H0),document.addEventListener("touchstart",d,H0),function(){q0=q0.filter(function(b){return b!==s}),document.removeEventListener("wheel",c,H0),document.removeEventListener("touchmove",c,H0),document.removeEventListener("touchstart",d,H0)}},[]);var m=e.removeScrollBar,g=e.inert;return p.createElement(p.Fragment,null,g?p.createElement(s,{styles:VPe(i)}):null,m?p.createElement(PPe,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function XPe(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const GPe=wPe(cce,qPe);var M9=p.forwardRef(function(e,t){return p.createElement(FN,Gu({},e,{ref:t,sideCar:GPe}))});M9.classNames=FN.classNames;var WPe=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},X0=new WeakMap,Zk=new WeakMap,Kk={},S5=0,pce=function(e){return e&&(e.host||pce(e.parentNode))},YPe=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=pce(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},ZPe=function(e,t,n,r){var i=YPe(t,Array.isArray(e)?e:[e]);Kk[n]||(Kk[n]=new WeakMap);var s=Kk[n],a=[],l=new Set,c=new Set(i),u=function(f){!f||l.has(f)||(l.add(f),u(f.parentNode))};i.forEach(u);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(l.has(h))d(h);else try{var m=h.getAttribute(r),g=m!==null&&m!=="false",b=(X0.get(h)||0)+1,y=(s.get(h)||0)+1;X0.set(h,b),s.set(h,y),a.push(h),b===1&&g&&Zk.set(h,!0),y===1&&h.setAttribute(n,"true"),g||h.setAttribute(r,"true")}catch(O){console.error("aria-hidden: cannot operate on ",h,O)}})};return d(t),l.clear(),S5++,function(){a.forEach(function(f){var h=X0.get(f)-1,m=s.get(f)-1;X0.set(f,h),s.set(f,m),h||(Zk.has(f)||f.removeAttribute(r),Zk.delete(f)),m||f.removeAttribute(n)}),S5--,S5||(X0=new WeakMap,X0=new WeakMap,Zk=new WeakMap,Kk={})}},mce=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=WPe(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),ZPe(r,i,n,"aria-hidden")):function(){return null}},KPe=Object.defineProperty,JPe=(e,t)=>KPe(e,"name",{value:t,configurable:!0});function KS(e){const[t,n]=p.useState(void 0);return Ic(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let a,l;if("borderBoxSize"in s){const c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;a=u.inlineSize,l=u.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}JPe(KS,"useSize");var e3e=Object.defineProperty,th=(e,t)=>e3e(e,"name",{value:t,configurable:!0}),L9="Checkbox",[t3e,aMt]=rl(L9),[n3e,$9]=t3e(L9);function gce(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:s,form:a,name:l,onCheckedChange:c,required:u,value:d="on",internal_do_not_use_render:f}=e,[h,m]=Bc({prop:n,defaultProp:i??!1,onChange:c,caller:L9}),[g,b]=p.useState(null),[y,O]=p.useState(null),v=p.useRef(!1),[x,w]=p.useReducer(k=>k+1,0),S=g?!!a||!!g.closest("form"):!0,E={checked:h,disabled:s,setChecked:m,control:g,setControl:b,name:l,form:a,value:d,hasConsumerStoppedPropagationRef:v,userInteractionCount:x,onUserInteraction:w,required:u,defaultChecked:Pf(i)?!1:i,isFormControl:S,bubbleInput:y,setBubbleInput:O};return o.jsx(n3e,{scope:t,...E,children:bce(f)?f(E):r})}th(gce,"CheckboxProvider");var r3e="CheckboxTrigger",i3e=p.forwardRef(th(function({__scopeCheckbox:t,onKeyDown:n,onClick:r,...i},s){const{control:a,value:l,disabled:c,checked:u,required:d,setControl:f,setChecked:h,hasConsumerStoppedPropagationRef:m,onUserInteraction:g,isFormControl:b,bubbleInput:y}=$9(r3e,t),O=zr(s,f),v=p.useRef(u);return p.useEffect(()=>{const x=a==null?void 0:a.form;if(x){const w=th(()=>h(v.current),"reset");return x.addEventListener("reset",w),()=>x.removeEventListener("reset",w)}},[a,h]),o.jsx(pi.button,{type:"button",role:"checkbox","aria-checked":Pf(u)?"mixed":u,"aria-required":d,"data-state":B9(u),"data-disabled":c?"":void 0,disabled:c,value:l,...i,ref:O,onKeyDown:mn(n,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:mn(r,x=>{g(),h(w=>Pf(w)?!0:!w),y&&b&&(m.current=x.isPropagationStopped(),m.current||x.stopPropagation())})})},"CheckboxTrigger")),s3e=p.forwardRef(th(function(t,n){const{__scopeCheckbox:r,name:i,checked:s,defaultChecked:a,required:l,disabled:c,value:u,onCheckedChange:d,form:f,...h}=t;return o.jsx(gce,{__scopeCheckbox:r,checked:s,defaultChecked:a,disabled:c,required:l,onCheckedChange:d,name:i,form:f,value:u,internal_do_not_use_render:({isFormControl:m})=>o.jsxs(o.Fragment,{children:[o.jsx(i3e,{...h,ref:n,__scopeCheckbox:r}),m&&o.jsx(c3e,{__scopeCheckbox:r})]})})},"Checkbox")),a3e="CheckboxIndicator",o3e=p.forwardRef(th(function(t,n){const{__scopeCheckbox:r,forceMount:i,...s}=t,a=$9(a3e,r);return o.jsx(Ed,{present:i||Pf(a.checked)||a.checked===!0,children:o.jsx(pi.span,{"data-state":B9(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:n,style:{pointerEvents:"none",...t.style}})})},"CheckboxIndicator")),l3e="CheckboxBubbleInput",c3e=p.forwardRef(th(function({__scopeCheckbox:t,onClick:n,...r},i){const{control:s,hasConsumerStoppedPropagationRef:a,userInteractionCount:l,checked:c,defaultChecked:u,required:d,disabled:f,name:h,value:m,form:g,bubbleInput:b,setBubbleInput:y}=$9(l3e,t),O=zr(i,y),v=KS(s),x=p.useRef(!1),w=p.useRef(c),S=p.useRef(l);p.useEffect(()=>{const k=b;if(!k)return;const _=window.HTMLInputElement.prototype,T=Object.getOwnPropertyDescriptor(_,"checked").set,A=l!==S.current;S.current=l;const j=w.current!==c;w.current=c;const L=!(A&&a.current);if(j&&T){x.current=!A;const I=new Event("click",{bubbles:L});k.indeterminate=Pf(c),T.call(k,Pf(c)?!1:c),k.dispatchEvent(I),x.current=!1}},[b,c,a,l]);const E=p.useRef(Pf(c)?!1:c);return o.jsx(pi.input,{type:"checkbox","aria-hidden":!0,defaultChecked:u??E.current,required:d,disabled:f,name:h,value:m,form:g,...r,tabIndex:-1,ref:O,onClick:mn(n,k=>{x.current&&k.stopPropagation()}),style:{...r.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function bce(e){return typeof e=="function"}th(bce,"isFunction");function Pf(e){return e==="indeterminate"}th(Pf,"isIndeterminate");function B9(e){return Pf(e)?"indeterminate":e?"checked":"unchecked"}th(B9,"getState");const u3e=["top","right","bottom","left"],zp=Math.min,Mf=Math.max,SC=Math.round,Jk=Math.floor,Lf=e=>({x:e,y:e}),d3e={left:"right",right:"left",bottom:"top",top:"bottom"};function yce(e,t,n){return Mf(e,zp(t,n))}function nh(e,t){return typeof e=="function"?e(t):e}function Vp(e){return e.split("-")[0]}function X1(e){return e.split("-")[1]}function Q9(e){return e==="x"?"y":"x"}function U9(e){return e==="y"?"height":"width"}function td(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function F9(e){return Q9(td(e))}function f3e(e,t,n){n===void 0&&(n=!1);const r=X1(e),i=F9(e),s=U9(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=EC(a)),[a,EC(a)]}function h3e(e){const t=EC(e);return[h4(e),t,h4(t)]}function h4(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const GH=["left","right"],WH=["right","left"],p3e=["top","bottom"],m3e=["bottom","top"];function g3e(e,t,n){switch(e){case"top":case"bottom":return n?t?WH:GH:t?GH:WH;case"left":case"right":return t?p3e:m3e;default:return[]}}function b3e(e,t,n,r){const i=X1(e);let s=g3e(Vp(e),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),t&&(s=s.concat(s.map(h4)))),s}function EC(e){const t=Vp(e);return d3e[t]+e.slice(t.length)}function y3e(e){var t,n,r,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function Oce(e){return typeof e!="number"?y3e(e):{top:e,right:e,bottom:e,left:e}}function kC(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function YH(e,t,n){let{reference:r,floating:i}=e;const s=td(t),a=F9(t),l=U9(a),c=Vp(t),u=s==="y",d=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,h=r[l]/2-i[l]/2;let m;switch(c){case"top":m={x:d,y:r.y-i.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-i.width,y:f};break;default:m={x:r.x,y:r.y}}const g=X1(t);return g&&(m[a]+=h*(g==="end"?1:-1)*(n&&u?-1:1)),m}async function O3e(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:a,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:m=0}=nh(t,e),g=Oce(m),y=l[h?f==="floating"?"reference":"floating":f],O=kC(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:u,rootBoundary:d,strategy:c})),v=f==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),w=await(s.isElement==null?void 0:s.isElement(x))&&await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1},S=kC(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:x,strategy:c}):v);return{top:(O.top-S.top+g.top)/w.y,bottom:(S.bottom-O.bottom+g.bottom)/w.y,left:(O.left-S.left+g.left)/w.x,right:(S.right-O.right+g.right)/w.x}}const x3e=50,v3e=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:O3e},c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:d,y:f}=YH(u,r,c),h=r,m=0;const g={};for(let b=0;b({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:a,elements:l,middlewareData:c}=t,{element:u,padding:d=0}=nh(e,t)||{};if(u==null)return{};const f=Oce(d),h={x:n,y:r},m=F9(i),g=U9(m),b=await a.getDimensions(u),y=m==="y",O=y?"top":"left",v=y?"bottom":"right",x=y?"clientHeight":"clientWidth",w=s.reference[g]+s.reference[m]-h[m]-s.floating[g],S=h[m]-s.reference[m],E=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let k=E?E[x]:0;(!k||!await(a.isElement==null?void 0:a.isElement(E)))&&(k=l.floating[x]||s.floating[g]);const _=w/2-S/2,C=k/2-b[g]/2-1,T=zp(f[O],C),A=zp(f[v],C),j=k-b[g]-A,L=k/2-b[g]/2+_,I=yce(T,L,j),M=!c.arrow&&X1(i)!=null&&L!==I&&s.reference[g]/2-(LI<=0)){var A,j;const I=(((A=s.flip)==null?void 0:A.index)||0)+1,M=k[I];if(M&&(!(f==="alignment"?v!==td(M):!1)||T.every(Q=>td(Q.placement)===v?Q.overflows[0]>0:!0)))return{data:{index:I,overflows:T},reset:{placement:M}};let N=(j=T.filter(D=>D.overflows[0]<=0).sort((D,Q)=>D.overflows[1]-Q.overflows[1])[0])==null?void 0:j.placement;if(!N)switch(m){case"bestFit":{var L;const D=(L=T.filter(Q=>{if(E){const F=td(Q.placement);return F===v||F==="y"}return!0}).map(Q=>[Q.placement,Q.overflows.filter(F=>F>0).reduce((F,$)=>F+$,0)]).sort((Q,F)=>Q[1]-F[1])[0])==null?void 0:L[0];D&&(N=D);break}case"initialPlacement":N=l;break}if(i!==N)return{reset:{placement:N}}}return{}}}};function ZH(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function KH(e){return u3e.some(t=>e[t]>=0)}const E3e=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=nh(e,t);switch(i){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=ZH(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:KH(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),l=ZH(a,n.floating);return{data:{escapedOffsets:l,escaped:KH(l)}}}default:return{}}}}},xce=new Set(["left","top"]);async function k3e(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=Vp(n),l=X1(n),c=td(n)==="y",u=xce.has(a)?-1:1,d=s&&c?-1:1,f=nh(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof g=="number"&&(m=l==="end"?g*-1:g),c?{x:m*d,y:h*u}:{x:h*u,y:m*d}}const _3e=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:a,middlewareData:l}=t,c=await k3e(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:s+c.y,data:{...c,placement:a}}}}},T3e=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:v=>{let{x,y:w}=v;return{x,y:w}}},...u}=nh(e,t),d={x:n,y:r},f=await s.detectOverflow(t,u),h=td(i),m=Q9(h);let g=d[m],b=d[h];const y=(v,x)=>yce(x+f[v==="y"?"top":"left"],x,x-f[v==="y"?"bottom":"right"]);a&&(g=y(m,g)),l&&(b=y(h,b));const O=c.fn({...t,[m]:g,[h]:b});return{...O,data:{x:O.x-n,y:O.y-r,enabled:{[m]:a,[h]:l}}}}}},C3e=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:i,y:s,placement:a,rects:l,middlewareData:c}=t,{offset:u=0,mainAxis:d=!0,crossAxis:f=!0}=nh(e,t),h={x:i,y:s},m=td(a),g=Q9(m);let b=h[g],y=h[m];const O=nh(u,t),v=typeof O=="number"?{mainAxis:O,crossAxis:0}:{mainAxis:(n=O.mainAxis)!=null?n:0,crossAxis:(r=O.crossAxis)!=null?r:0};if(d){const S=g==="y"?"height":"width",E=l.reference[g]-l.floating[S]+v.mainAxis,k=l.reference[g]+l.reference[S]-v.mainAxis;bk&&(b=k)}if(f){var x,w;const S=g==="y"?"width":"height",E=xce.has(Vp(a)),k=l.reference[m]-l.floating[S]+(E&&((x=c.offset)==null?void 0:x[m])||0)+(E?0:v.crossAxis),_=l.reference[m]+l.reference[S]+(E?0:((w=c.offset)==null?void 0:w[m])||0)-(E?v.crossAxis:0);y_&&(y=_)}return{[g]:b,[m]:y}}}},A3e=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:s}=t,{apply:a=()=>{},...l}=nh(e,t),c=await i.detectOverflow(t,l),u=Vp(n),d=X1(n),f=td(n)==="y",{width:h,height:m}=r.floating;let g,b;u==="top"||u==="bottom"?(g=u,b=d===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(b=u,g=d==="end"?"top":"bottom");const y=m-c.top-c.bottom,O=h-c.left-c.right,v=zp(m-c[g],y),x=zp(h-c[b],O),w=t.middlewareData.shift,S=!w;let E=v,k=x;w!=null&&w.enabled.x&&(k=O),w!=null&&w.enabled.y&&(E=y),S&&!d&&(f?k=h-2*Mf(c.left,c.right):E=m-2*Mf(c.top,c.bottom)),await a({...t,availableWidth:k,availableHeight:E});const _=await i.getDimensions(s.floating);return h!==_.width||m!==_.height?{reset:{rects:!0}}:{}}}};function zN(){return typeof window<"u"}function G1(e){return vce(e)?(e.nodeName||"").toLowerCase():"#document"}function Ka(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function mh(e){var t;return(t=(vce(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function vce(e){return zN()?e instanceof Node||e instanceof Ka(e).Node:!1}function md(e){return zN()?e instanceof Element||e instanceof Ka(e).Element:!1}function kd(e){return zN()?e instanceof HTMLElement||e instanceof Ka(e).HTMLElement:!1}function JH(e){return!zN()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ka(e).ShadowRoot}function VN(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=gd(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function N3e(e){return/^(table|td|th)$/.test(G1(e))}function HN(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const j3e=/transform|translate|scale|rotate|perspective|filter/,R3e=/paint|layout|strict|content/,km=e=>!!e&&e!=="none";let E5;function z9(e){const t=md(e)?gd(e):e;return km(t.transform)||km(t.translate)||km(t.scale)||km(t.rotate)||km(t.perspective)||!V9()&&(km(t.backdropFilter)||km(t.filter))||j3e.test(t.willChange||"")||R3e.test(t.contain||"")}function I3e(e){let t=Mg(e);for(;kd(t)&&!Sw(t);){if(z9(t))return t;if(HN(t))return null;t=Mg(t)}return null}function V9(){return E5==null&&(E5=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),E5}function Sw(e){return/^(html|body|#document)$/.test(G1(e))}function gd(e){return Ka(e).getComputedStyle(e)}function qN(e){return md(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Mg(e){if(G1(e)==="html")return e;const t=e.assignedSlot||e.parentNode||JH(e)&&e.host||mh(e);return JH(t)?t.host:t}function wce(e){const t=Mg(e);return Sw(t)?(e.ownerDocument||e).body:kd(t)&&VN(t)?t:wce(t)}function Ew(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=wce(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),a=Ka(i);if(s){const l=p4(a);return t.concat(a,a.visualViewport||[],VN(i)?i:[],l&&n?Ew(l):[])}else return t.concat(i,Ew(i,[],n))}function p4(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Sce(e){const t=gd(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=kd(e),s=i?e.offsetWidth:n,a=i?e.offsetHeight:r,l=SC(n)!==s||SC(r)!==a;return l&&(n=s,r=a),{width:n,height:r,$:l}}function H9(e){return md(e)?e:e.contextElement}function py(e){const t=H9(e);if(!kd(t))return Lf(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=Sce(t);let a=(s?SC(n.width):n.width)/r,l=(s?SC(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const D3e=Lf(0);function Ece(e){const t=Ka(e);return!V9()||!t.visualViewport?D3e:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function P3e(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Ka(e)}function Lg(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=H9(e);let a=Lf(1);t&&(r?md(r)&&(a=py(r)):a=py(e));const l=P3e(s,n,r)?Ece(s):Lf(0);let c=(i.left+l.x)/a.x,u=(i.top+l.y)/a.y,d=i.width/a.x,f=i.height/a.y;if(s&&r){const h=Ka(s),m=md(r)?Ka(r):r;let g=h,b=p4(g);for(;b&&m!==g;){const y=py(b),O=b.getBoundingClientRect(),v=gd(b),x=O.left+(b.clientLeft+parseFloat(v.paddingLeft))*y.x,w=O.top+(b.clientTop+parseFloat(v.paddingTop))*y.y;c*=y.x,u*=y.y,d*=y.x,f*=y.y,c+=x,u+=w,g=Ka(b),b=p4(g)}}return kC({width:d,height:f,x:c,y:u})}function XN(e,t){const n=qN(e).scrollLeft;return t?t.left+n:Lg(mh(e)).left+n}function kce(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-XN(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function M3e(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",a=mh(r),l=t?HN(t.floating):!1;if(r===a||l&&s)return n;let c={scrollLeft:0,scrollTop:0},u=Lf(1);const d=Lf(0),f=kd(r);if((f||!s)&&((G1(r)!=="body"||VN(a))&&(c=qN(r)),f)){const m=Lg(r);u=py(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const h=a&&!f&&!s?kce(a,c):Lf(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function L3e(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function $3e(e){const t=qN(e),n=e.ownerDocument.body,r=Mf(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Mf(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-t.scrollLeft+XN(e);const a=-t.scrollTop;return gd(n).direction==="rtl"&&(s+=Mf(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:s,y:a}}const B3e=25;function Q3e(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=Ka(e),s=mh(e),a=i.visualViewport;let l=s.clientWidth,c=s.clientHeight,u=0,d=0;if(a){const h=!V9()||t==="fixed";r?h||(u=-a.offsetLeft,d=-a.offsetTop):(l=a.width,c=a.height,h&&(u=a.offsetLeft,d=a.offsetTop))}if(XN(s)<=0){const h=s.ownerDocument,m=h.body,g=getComputedStyle(m),b=h.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,y=Math.abs(s.clientWidth-m.clientWidth-b),O=getComputedStyle(s).scrollbarGutter==="stable both-edges"?y/2:y;O<=B3e&&(l-=O)}return{width:l,height:c,x:u,y:d}}function U3e(e,t){const n=Lg(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=py(e),a=e.clientWidth*s.x,l=e.clientHeight*s.y,c=i*s.x,u=r*s.y;return{width:a,height:l,x:c,y:u}}function eq(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=Q3e(e,n,t);else if(t==="document")r=$3e(mh(e));else if(md(t))r=U3e(t,n);else{const i=Ece(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return kC(r)}function F3e(e,t){const n=t.get(e);if(n)return n;let r=Ew(e,[],!1).filter(l=>md(l)&&G1(l)!=="body"),i=null;const s=gd(e).position==="fixed";let a=s?Mg(e):e;for(;md(a)&&!Sw(a);){const l=gd(a),c=z9(a),u=i?i.position:s?"fixed":"";!c&&(u==="fixed"||u==="absolute"&&l.position==="static")?r=r.filter(f=>f!==a):i=l,a=Mg(a)}return t.set(e,r),r}function z3e(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?HN(t)?[]:F3e(t,this._c):[].concat(n),r],l=eq(t,a[0],i);let c=l.top,u=l.right,d=l.bottom,f=l.left;for(let h=1;h{l(!1,1e-7)},1e3)}k=!1}try{r=new IntersectionObserver(_,{...E,root:s.ownerDocument})}catch{r=new IntersectionObserver(_,E)}r.observe(e)}const c=Ka(e),u=()=>l(n);return c.addEventListener("resize",u),l(!0),()=>{c.removeEventListener("resize",u),a()}}function Y3e(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=H9(e),d=i||s?[...u?Ew(u):[],...t?Ew(t):[]]:[];d.forEach(O=>{i&&O.addEventListener("scroll",n),s&&O.addEventListener("resize",n)});const f=u&&l?W3e(u,n,s):null;let h=-1,m=null;a&&(m=new ResizeObserver(O=>{let[v]=O;v&&v.target===u&&m&&t&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var x;(x=m)==null||x.observe(t)})),n()}),u&&!c&&m.observe(u),t&&m.observe(t));let g,b=c?Lg(e):null;c&&y();function y(){const O=Lg(e);b&&!Tce(b,O)&&n(),b=O,g=requestAnimationFrame(y)}return n(),()=>{var O;d.forEach(v=>{i&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),f==null||f(),(O=m)==null||O.disconnect(),m=null,c&&cancelAnimationFrame(g)}}const Z3e=_3e,K3e=T3e,J3e=S3e,eMe=A3e,tMe=E3e,nq=w3e,nMe=C3e,rMe=(e,t,n)=>{const r=new Map,i=n??{},s={...G3e,...i.platform,_c:r};return v3e(e,t,{...i,platform:s})};var iMe=typeof document<"u",sMe=function(){},W_=iMe?p.useLayoutEffect:sMe;function _C(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!_C(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!_C(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Cce(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function rq(e,t){const n=Cce(e);return Math.round(t*n)/n}function _5(e){const t=p.useRef(e);return W_(()=>{t.current=e}),t}function aMe(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:a}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[d,f]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=p.useState(r);_C(h,r)||m(r);const[g,b]=p.useState(null),[y,O]=p.useState(null),v=p.useCallback(Q=>{Q!==E.current&&(E.current=Q,b(Q))},[]),x=p.useCallback(Q=>{Q!==k.current&&(k.current=Q,O(Q))},[]),w=s||g,S=a||y,E=p.useRef(null),k=p.useRef(null),_=p.useRef(d),C=c!=null,T=_5(c),A=_5(i),j=_5(u),L=p.useCallback(()=>{if(!E.current||!k.current)return;const Q={placement:t,strategy:n,middleware:h};A.current&&(Q.platform=A.current),rMe(E.current,k.current,Q).then(F=>{const $={...F,isPositioned:j.current!==!1};I.current&&!_C(_.current,$)&&(_.current=$,Cr.flushSync(()=>{f($)}))})},[h,t,n,A,j]);W_(()=>{u===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,f(Q=>({...Q,isPositioned:!1})))},[u]);const I=p.useRef(!1);W_(()=>(I.current=!0,()=>{I.current=!1}),[]),W_(()=>{if(w&&(E.current=w),S&&(k.current=S),w&&S){if(T.current)return T.current(w,S,L);L()}},[w,S,L,T,C]);const M=p.useMemo(()=>({reference:E,floating:k,setReference:v,setFloating:x}),[v,x]),N=p.useMemo(()=>({reference:w,floating:S}),[w,S]),D=p.useMemo(()=>{const Q={position:n,left:0,top:0};if(!N.floating)return Q;const F=rq(N.floating,d.x),$=rq(N.floating,d.y);return l?{...Q,transform:"translate("+F+"px, "+$+"px)",...Cce(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:$}},[n,l,N.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:L,refs:M,elements:N,floatingStyles:D}),[d,L,M,N,D])}const oMe=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?nq({element:r.current,padding:i}).fn(n):{}:r?nq({element:r,padding:i}).fn(n):{}}}},lMe=(e,t)=>{const n=Z3e(e);return{name:n.name,fn:n.fn,options:[e,t]}},cMe=(e,t)=>{const n=K3e(e);return{name:n.name,fn:n.fn,options:[e,t]}},uMe=(e,t)=>({fn:nMe(e).fn,options:[e,t]}),dMe=(e,t)=>{const n=J3e(e);return{name:n.name,fn:n.fn,options:[e,t]}},fMe=(e,t)=>{const n=eMe(e);return{name:n.name,fn:n.fn,options:[e,t]}},hMe=(e,t)=>{const n=tMe(e);return{name:n.name,fn:n.fn,options:[e,t]}},pMe=(e,t)=>{const n=oMe(e);return{name:n.name,fn:n.fn,options:[e,t]}};var mMe=Object.defineProperty,Cp=(e,t)=>mMe(e,"name",{value:t,configurable:!0}),Ace="Popper",[Nce,W1]=rl(Ace),[gMe,jce]=Nce(Ace),bMe=Cp(e=>{const{__scopePopper:t,children:n}=e,[r,i]=p.useState(null),[s,a]=p.useState(void 0);return o.jsx(gMe,{scope:t,anchor:r,onAnchorChange:i,placementState:s,setPlacementState:a,children:n})},"Popper"),yMe="PopperAnchor",OMe=p.forwardRef(Cp(function(t,n){const{__scopePopper:r,virtualRef:i,...s}=t,a=jce(yMe,r),l=p.useRef(null),c=a.onAnchorChange,u=p.useCallback(b=>{l.current=b,b&&c(b)},[c]),d=zr(n,u),f=p.useRef(null);p.useEffect(()=>{if(!i)return;const b=f.current;f.current=i.current,b!==f.current&&c(f.current)});const h=a.placementState&&GN(a.placementState),m=h==null?void 0:h[0],g=h==null?void 0:h[1];return i?null:o.jsx(pi.div,{"data-radix-popper-side":m,"data-radix-popper-align":g,...s,ref:d})},"PopperAnchor")),Rce="PopperContent",[xMe,oMt]=Nce(Rce),vMe=p.forwardRef(Cp(function(t,n){var q,X,K,de,xe,Me,Ae;const{__scopePopper:r,side:i="bottom",sideOffset:s=0,align:a="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:g="optimized",onPlaced:b,...y}=t,O=jce(Rce,r),[v,x]=p.useState(null),w=zr(n,x),[S,E]=p.useState(null),k=KS(S),_=(k==null?void 0:k.width)??0,C=(k==null?void 0:k.height)??0,T=i+(a!=="center"?"-"+a:""),A=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},j=Array.isArray(d)?d:[d],L=j.length>0,I={padding:A,boundary:j.filter(Ice),altBoundary:L},{refs:M,floatingStyles:N,placement:D,isPositioned:Q,middlewareData:F}=aMe({strategy:"fixed",placement:T,whileElementsMounted:Cp((...He)=>Y3e(...He,{animationFrame:g==="always"}),"whileElementsMounted"),elements:{reference:O.anchor},middleware:[lMe({mainAxis:s+C,alignmentAxis:l}),u&&cMe({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?uMe():void 0,...I}),u&&dMe({...I}),fMe({...I,apply:Cp(({elements:He,rects:et,availableWidth:Te,availableHeight:Re})=>{const{width:he,height:me}=et.reference,Se=He.floating.style;Se.setProperty("--radix-popper-available-width",`${Te}px`),Se.setProperty("--radix-popper-available-height",`${Re}px`),Se.setProperty("--radix-popper-anchor-width",`${he}px`),Se.setProperty("--radix-popper-anchor-height",`${me}px`)},"apply")}),S&&pMe({element:S,padding:c}),wMe({arrowWidth:_,arrowHeight:C}),m&&hMe({strategy:"referenceHidden",...I,boundary:L?I.boundary:void 0})]}),$=O.setPlacementState;Ic(()=>($(D),()=>{$(void 0)}),[D,$]);const[H,z]=GN(D),B=yu(b);Ic(()=>{Q&&(B==null||B())},[Q,B]);const V=(q=F.arrow)==null?void 0:q.x,Z=(X=F.arrow)==null?void 0:X.y,ce=((K=F.arrow)==null?void 0:K.centerOffset)!==0,[be,ie]=p.useState();return Ic(()=>{v&&ie(window.getComputedStyle(v).zIndex)},[v]),o.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...N,transform:Q?N.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:be,"--radix-popper-transform-origin":[(de=F.transformOrigin)==null?void 0:de.x,(xe=F.transformOrigin)==null?void 0:xe.y].join(" "),...((Me=F.hide)==null?void 0:Me.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:o.jsx(xMe,{scope:r,placedSide:H,placedAlign:z,onArrowChange:E,arrowX:V,arrowY:Z,shouldHideArrow:ce,children:o.jsx(pi.div,{"data-side":H,"data-align":z,...y,ref:w,style:{...y.style,animation:Q?(Ae=y.style)==null?void 0:Ae.animation:"none"}})})})},"PopperContent"));function Ice(e){return e!==null}Cp(Ice,"isNotNull");var wMe=Cp(e=>({name:"transformOrigin",options:e,fn(t){var y,O,v;const{placement:n,rects:r,middlewareData:i}=t,a=((y=i.arrow)==null?void 0:y.centerOffset)!==0,l=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[u,d]=GN(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((O=i.arrow)==null?void 0:O.x)??0)+l/2,m=(((v=i.arrow)==null?void 0:v.y)??0)+c/2;let g="",b="";return u==="bottom"?(g=a?f:`${h}px`,b=`${-c}px`):u==="top"?(g=a?f:`${h}px`,b=`${r.floating.height+c}px`):u==="right"?(g=`${-c}px`,b=a?f:`${m}px`):u==="left"&&(g=`${r.floating.width+c}px`,b=a?f:`${m}px`),{data:{x:g,y:b}}}}),"transformOrigin");function GN(e){const[t,n="center"]=e.split("-");return[t,n]}Cp(GN,"getSideAndAlignFromPlacement");var WN=bMe,q9=OMe,X9=vMe,SMe=Object.defineProperty,G9=(e,t)=>SMe(e,"name",{value:t,configurable:!0}),T5=!1;function Dce(){const[e,t]=p.useState(T5);return p.useEffect(()=>{T5||(T5=!0,t(!0))},[]),e}G9(Dce,"useIsHydrated");var Pce=r0[" useSyncExternalStore ".trim().toString()];function Mce(){return()=>{}}G9(Mce,"subscribe");function Lce(){return Pce(Mce,()=>!0,()=>!1)}G9(Lce,"useIsHydratedModern");var EMe=typeof Pce=="function"?Lce:Dce,kMe=Object.defineProperty,f0=(e,t)=>kMe(e,"name",{value:t,configurable:!0}),C5="rovingFocusGroup.onEntryFocus",_Me={bubbles:!1,cancelable:!0},YN="RovingFocusGroup",[m4,$ce,TMe]=A9(YN),[CMe,Y1]=rl(YN,[TMe]),[AMe,NMe]=CMe(YN),jMe=p.forwardRef(f0(function(t,n){return o.jsx(m4.Provider,{scope:t.__scopeRovingFocusGroup,children:o.jsx(m4.Slot,{scope:t.__scopeRovingFocusGroup,children:o.jsx(RMe,{...t,ref:n})})})},"RovingFocusGroup")),RMe=p.forwardRef(f0(function(t,n){const{__scopeRovingFocusGroup:r,orientation:i,loop:s=!1,dir:a,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...h}=t,m=p.useRef(null),g=zr(n,m),b=ZS(a),[y,O]=Bc({prop:l,defaultProp:c??null,onChange:u,caller:YN}),[v,x]=p.useState(!1),w=yu(d),S=$ce(r),E=p.useRef(!1),[k,_]=p.useState(0);return p.useEffect(()=>{const C=m.current;if(C)return C.addEventListener(C5,w),()=>C.removeEventListener(C5,w)},[w]),o.jsx(AMe,{scope:r,orientation:i,dir:b,loop:s,currentTabStopId:y,onItemFocus:p.useCallback(C=>O(C),[O]),onItemShiftTab:p.useCallback(()=>x(!0),[]),onFocusableItemAdd:p.useCallback(()=>_(C=>C+1),[]),onFocusableItemRemove:p.useCallback(()=>_(C=>C-1),[]),children:o.jsx(pi.div,{tabIndex:v||k===0?-1:0,"data-orientation":i,...h,ref:g,style:{outline:"none",...t.style},onMouseDown:mn(t.onMouseDown,()=>{E.current=!0}),onFocus:mn(t.onFocus,C=>{const T=!E.current;if(C.target===C.currentTarget&&T&&!v){const A=new CustomEvent(C5,_Me);if(C.currentTarget.dispatchEvent(A),!A.defaultPrevented){const j=S().filter(D=>D.focusable),L=j.find(D=>D.active),I=j.find(D=>D.id===y),N=[L,I,...j].filter(Boolean).map(D=>D.ref.current);W9(N,f)}}E.current=!1}),onBlur:mn(t.onBlur,()=>x(!1))})})},"RovingFocusGroupImpl")),IMe="RovingFocusGroupItem",DMe=p.forwardRef(f0(function(t,n){const{__scopeRovingFocusGroup:r,focusable:i=!0,active:s=!1,tabStopId:a,children:l,...c}=t,u=Fp(),d=a||u,f=NMe(IMe,r),h=f.currentTabStopId===d,m=$ce(r),{onFocusableItemAdd:g,onFocusableItemRemove:b,currentTabStopId:y}=f,O=EMe();return Ic(()=>{if(!(!O||!i))return g(),()=>b()},[O,i,g,b]),p.useEffect(()=>{if(!(O||!i))return g(),()=>b()},[O,i,g,b]),o.jsx(m4.ItemSlot,{scope:r,id:d,focusable:i,active:s,children:o.jsx(pi.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...c,ref:n,onMouseDown:mn(t.onMouseDown,v=>{i?f.onItemFocus(d):v.preventDefault()}),onFocus:mn(t.onFocus,()=>f.onItemFocus(d)),onKeyDown:mn(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const x=Qce(v,f.orientation,f.dir);if(x!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let S=m().filter(E=>E.focusable).map(E=>E.ref.current);if(x==="last")S.reverse();else if(x==="prev"||x==="next"){x==="prev"&&S.reverse();const E=S.indexOf(v.currentTarget);S=f.loop?Uce(S,E+1):S.slice(E+1)}setTimeout(()=>W9(S))}}),children:typeof l=="function"?l({isCurrentTabStop:h,hasTabStop:y!=null}):l})})},"RovingFocusGroupItem")),PMe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Bce(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}f0(Bce,"getDirectionAwareKey");function Qce(e,t,n){const r=Bce(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return PMe[r]}f0(Qce,"getFocusIntent");function W9(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}f0(W9,"focusFirst");function Uce(e,t){return e.map((n,r)=>e[(t+r)%e.length])}f0(Uce,"wrapArray");var Y9=jMe,Z9=DMe,MMe=Object.defineProperty,Ir=(e,t)=>MMe(e,"name",{value:t,configurable:!0}),g4=["Enter"," "],LMe=["ArrowDown","PageUp","Home"],Fce=["ArrowUp","PageDown","End"],$Me=[...LMe,...Fce],BMe={ltr:[...g4,"ArrowRight"],rtl:[...g4,"ArrowLeft"]},QMe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ZN="Menu",[kw,UMe,FMe]=A9(ZN),[h0,zce]=rl(ZN,[FMe,W1,Y1]),KN=W1(),Vce=Y1(),[Hce,um]=h0(ZN),[zMe,JS]=h0(ZN),VMe=Ir(e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:a=!0}=e,l=KN(t),[c,u]=p.useState(null),d=p.useRef(!1),f=yu(s),h=ZS(i);return p.useEffect(()=>{const m=Ir(()=>{d.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},"handleKeyDown"),g=Ir(()=>d.current=!1,"handlePointer");return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),p.useEffect(()=>{if(!n)return;const m=Ir(()=>f(!1),"handleBlur");return window.addEventListener("blur",m),()=>window.removeEventListener("blur",m)},[n,f]),o.jsx(WN,{...l,children:o.jsx(Hce,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:o.jsx(zMe,{scope:t,onClose:p.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:a,children:r})})})},"Menu"),qce=p.forwardRef(Ir(function(t,n){const{__scopeMenu:r,...i}=t,s=KN(r);return o.jsx(q9,{...s,...i,ref:n})},"MenuAnchor")),Xce="MenuPortal",[HMe,Gce]=h0(Xce,{forceMount:void 0}),qMe=Ir(e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=um(Xce,t);return o.jsx(HMe,{scope:t,forceMount:n,children:o.jsx(Ed,{present:n||s.open,children:o.jsx(D9,{asChild:!0,container:i,children:r})})})},"MenuPortal"),pu="MenuContent",[XMe,K9]=h0(pu),GMe=p.forwardRef(Ir(function(t,n){const r=Gce(pu,t.__scopeMenu),{forceMount:i=r.forceMount,...s}=t,a=um(pu,t.__scopeMenu),l=JS(pu,t.__scopeMenu);return o.jsx(kw.Provider,{scope:t.__scopeMenu,children:o.jsx(Ed,{present:i||a.open,children:o.jsx(kw.Slot,{scope:t.__scopeMenu,children:l.modal?o.jsx(WMe,{...s,ref:n}):o.jsx(YMe,{...s,ref:n})})})})},"MenuContent")),WMe=p.forwardRef(Ir(function(t,n){const r=um(pu,t.__scopeMenu),i=p.useRef(null),s=zr(n,i);return p.useEffect(()=>{const a=i.current;if(a)return mce(a)},[]),o.jsx(J9,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:mn(t.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),YMe=p.forwardRef(Ir(function(t,n){const r=um(pu,t.__scopeMenu);return o.jsx(J9,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),ZMe=Jf("MenuContent.ScrollLock"),J9=p.forwardRef(Ir(function(t,n){const{__scopeMenu:r,loop:i=!1,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:l,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:m,onDismiss:g,disableOutsideScroll:b,...y}=t,O=um(pu,r),v=JS(pu,r),x=KN(r),w=Vce(r),S=UMe(r),[E,k]=p.useState(null),_=p.useRef(null),C=zr(n,_,O.onContentChange),T=p.useRef(0),A=p.useRef(""),j=p.useRef(0),L=p.useRef(null),I=p.useRef("right"),M=p.useRef(0),N=b?M9:p.Fragment,D=b?{as:ZMe,allowPinchZoom:!0}:void 0,Q=Ir($=>{var ie,q;const H=A.current+$,z=S().filter(X=>!X.disabled),B=document.activeElement,V=(ie=z.find(X=>X.ref.current===B))==null?void 0:ie.textValue,Z=z.map(X=>X.textValue),ce=nue(Z,H,V),be=(q=z.find(X=>X.textValue===ce))==null?void 0:q.ref.current;Ir(function X(K){A.current=K,window.clearTimeout(T.current),K!==""&&(T.current=window.setTimeout(()=>X(""),1e3))},"updateSearch")(H),be&&setTimeout(()=>be.focus())},"handleTypeaheadSearch");p.useEffect(()=>()=>window.clearTimeout(T.current),[]),UN();const F=p.useCallback($=>{var z,B;return I.current===((z=L.current)==null?void 0:z.side)&&iue($,(B=L.current)==null?void 0:B.area)},[]);return o.jsx(XMe,{scope:r,searchRef:A,onItemEnter:p.useCallback($=>{F($)&&$.preventDefault()},[F]),onItemLeave:p.useCallback($=>{var H;F($)||((H=_.current)==null||H.focus(),k(null))},[F]),onTriggerLeave:p.useCallback($=>{F($)&&$.preventDefault()},[F]),pointerGraceTimerRef:j,onPointerGraceIntentChange:p.useCallback($=>{L.current=$},[]),children:o.jsx(N,{...D,children:o.jsx(ece,{asChild:!0,trapped:s,onMountAutoFocus:mn(a,$=>{var H;$.preventDefault(),(H=_.current)==null||H.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:o.jsx(j9,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:m,onDismiss:g,children:o.jsx(Y9,{asChild:!0,...w,dir:v.dir,orientation:"vertical",loop:i,currentTabStopId:E,onCurrentTabStopIdChange:k,onEntryFocus:mn(u,$=>{v.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:o.jsx(X9,{role:"menu","aria-orientation":"vertical","data-state":t7(O.open),"data-radix-menu-content":"",dir:v.dir,...x,...y,ref:C,style:{outline:"none",...y.style},onKeyDown:mn(y.onKeyDown,$=>{const z=$.target.closest("[data-radix-menu-content]")===$.currentTarget,B=$.ctrlKey||$.altKey||$.metaKey,V=$.key.length===1;z&&($.key==="Tab"&&$.preventDefault(),!B&&V&&Q($.key));const Z=_.current;if($.target!==Z||!$Me.includes($.key))return;$.preventDefault();const be=S().filter(ie=>!ie.disabled).map(ie=>ie.ref.current);Fce.includes($.key)&&be.reverse(),eue(be)}),onBlur:mn(t.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(T.current),A.current="")}),onPointerMove:mn(t.onPointerMove,e1($=>{const H=$.target,z=M.current!==$.clientX;if($.currentTarget.contains(H)&&z){const B=$.clientX>M.current?"right":"left";I.current=B,M.current=$.clientX}}))})})})})})})},"MenuContentImpl")),KMe=p.forwardRef(Ir(function(t,n){const{__scopeMenu:r,...i}=t;return o.jsx(pi.div,{role:"group",...i,ref:n})},"MenuGroup")),b4="MenuItem",iq="menu.itemSelect",e7=p.forwardRef(Ir(function(t,n){const{disabled:r=!1,onSelect:i,...s}=t,a=p.useRef(null),l=JS(b4,t.__scopeMenu),c=K9(b4,t.__scopeMenu),u=zr(n,a),d=p.useRef(!1),f=Ir(()=>{const h=a.current;if(!r&&h){const m=new CustomEvent(iq,{bubbles:!0,cancelable:!0});h.addEventListener(iq,g=>i==null?void 0:i(g),{once:!0}),C9(h,m),m.defaultPrevented?d.current=!1:l.onClose()}},"handleSelect");return o.jsx(Wce,{...s,ref:u,disabled:r,onClick:mn(t.onClick,f),onPointerDown:h=>{var m;(m=t.onPointerDown)==null||m.call(t,h),d.current=!0},onPointerUp:mn(t.onPointerUp,h=>{var m;d.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:mn(t.onKeyDown,h=>{r||h.target!==h.currentTarget||c.searchRef.current!==""&&h.key===" "||g4.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})},"MenuItem")),Wce=p.forwardRef(Ir(function(t,n){const{__scopeMenu:r,disabled:i=!1,textValue:s,...a}=t,l=K9(b4,r),c=Vce(r),u=p.useRef(null),d=zr(n,u),[f,h]=p.useState(!1),[m,g]=p.useState("");return p.useEffect(()=>{const b=u.current;b&&g((b.textContent??"").trim())},[a.children]),o.jsx(kw.ItemSlot,{scope:r,disabled:i,textValue:s??m,children:o.jsx(Z9,{asChild:!0,...c,focusable:!i,children:o.jsx(pi.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...a,ref:d,onPointerMove:mn(t.onPointerMove,e1(b=>{i?l.onItemLeave(b):(l.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:mn(t.onPointerLeave,e1(b=>l.onItemLeave(b))),onFocus:mn(t.onFocus,()=>h(!0)),onBlur:mn(t.onBlur,()=>h(!1))})})})},"MenuItemImpl")),JMe=p.forwardRef(Ir(function(t,n){const{checked:r=!1,onCheckedChange:i,...s}=t;return o.jsx(Zce,{scope:t.__scopeMenu,checked:r,children:o.jsx(e7,{role:"menuitemcheckbox","aria-checked":_w(r)?"mixed":r,...s,ref:n,"data-state":JN(r),onSelect:mn(s.onSelect,()=>i==null?void 0:i(_w(r)?!0:!r),{checkForDefaultPrevented:!1})})})},"MenuCheckboxItem")),e4e="MenuRadioGroup",[t4e,n4e]=h0(e4e,{value:void 0,onValueChange:Ir(()=>{},"onValueChange")}),r4e=p.forwardRef(Ir(function(t,n){const{value:r,onValueChange:i,...s}=t,a=yu(i);return o.jsx(t4e,{scope:t.__scopeMenu,value:r,onValueChange:a,children:o.jsx(KMe,{...s,ref:n})})},"MenuRadioGroup")),i4e="MenuRadioItem",s4e=p.forwardRef(Ir(function(t,n){const{value:r,...i}=t,s=n4e(i4e,t.__scopeMenu),a=r===s.value;return o.jsx(Zce,{scope:t.__scopeMenu,checked:a,children:o.jsx(e7,{role:"menuitemradio","aria-checked":a,...i,ref:n,"data-state":JN(a),onSelect:mn(i.onSelect,()=>{var l;return(l=s.onValueChange)==null?void 0:l.call(s,r)},{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),Yce="MenuItemIndicator",[Zce,a4e]=h0(Yce,{checked:!1}),o4e=p.forwardRef(Ir(function(t,n){const{__scopeMenu:r,forceMount:i,...s}=t,a=a4e(Yce,r);return o.jsx(Ed,{present:i||_w(a.checked)||a.checked===!0,children:o.jsx(pi.span,{...s,ref:n,"data-state":JN(a.checked)})})},"MenuItemIndicator")),l4e=p.forwardRef(Ir(function(t,n){const{__scopeMenu:r,...i}=t;return o.jsx(pi.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})},"MenuSeparator")),Kce="MenuSub",[c4e,Jce]=h0(Kce),u4e=Ir(e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=um(Kce,t),a=KN(t),[l,c]=p.useState(null),[u,d]=p.useState(null),f=yu(i);return p.useEffect(()=>(s.open===!1&&f(!1),()=>f(!1)),[s.open,f]),o.jsx(WN,{...a,children:o.jsx(Hce,{scope:t,open:r,onOpenChange:f,content:u,onContentChange:d,children:o.jsx(c4e,{scope:t,contentId:Fp(),triggerId:Fp(),trigger:l,onTriggerChange:c,children:n})})})},"MenuSub"),e2="MenuSubTrigger",d4e=p.forwardRef(Ir(function(t,n){const r=um(e2,t.__scopeMenu),i=JS(e2,t.__scopeMenu),s=Jce(e2,t.__scopeMenu),a=K9(e2,t.__scopeMenu),l=p.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=a,d={__scopeMenu:t.__scopeMenu},f=p.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);p.useEffect(()=>f,[f]),p.useEffect(()=>{const m=c.current;return()=>{window.clearTimeout(m),u(null)}},[c,u]);const h=zr(n,s.onTriggerChange);return o.jsx(qce,{asChild:!0,...d,children:o.jsx(Wce,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":r.open?s.contentId:void 0,"data-state":t7(r.open),...t,ref:h,onClick:m=>{var g;(g=t.onClick)==null||g.call(t,m),!(t.disabled||m.defaultPrevented)&&(m.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:mn(t.onPointerMove,e1(m=>{a.onItemEnter(m),!m.defaultPrevented&&!t.disabled&&!r.open&&!l.current&&(a.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),f()},100))})),onPointerLeave:mn(t.onPointerLeave,e1(m=>{var b,y;f();const g=(b=r.content)==null?void 0:b.getBoundingClientRect();if(g){const O=(y=r.content)==null?void 0:y.dataset.side,v=O==="right",x=v?-5:5,w=g[v?"left":"right"],S=g[v?"right":"left"];a.onPointerGraceIntentChange({area:[{x:m.clientX+x,y:m.clientY},{x:w,y:g.top},{x:S,y:g.top},{x:S,y:g.bottom},{x:w,y:g.bottom}],side:O}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(m),m.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:mn(t.onKeyDown,m=>{var b;t.disabled||m.target!==m.currentTarget||a.searchRef.current!==""&&m.key===" "||BMe[i.dir].includes(m.key)&&(r.onOpenChange(!0),(b=r.content)==null||b.focus(),m.preventDefault())})})})},"MenuSubTrigger")),f4e="MenuSubContent",h4e=p.forwardRef(Ir(function(t,n){const r=Gce(pu,t.__scopeMenu),{forceMount:i=r.forceMount,align:s="start",...a}=t,l=um(pu,t.__scopeMenu),c=JS(pu,t.__scopeMenu),u=Jce(f4e,t.__scopeMenu),d=p.useRef(null),f=zr(n,d);return o.jsx(kw.Provider,{scope:t.__scopeMenu,children:o.jsx(Ed,{present:i||l.open,children:o.jsx(kw.Slot,{scope:t.__scopeMenu,children:o.jsx(J9,{id:u.contentId,"aria-labelledby":u.triggerId,...a,ref:f,align:s,side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:h=>{var m;c.isUsingKeyboardRef.current&&((m=d.current)==null||m.focus()),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:mn(t.onFocusOutside,h=>{h.target!==u.trigger&&l.onOpenChange(!1)}),onEscapeKeyDown:mn(t.onEscapeKeyDown,h=>{c.onClose(),h.preventDefault()}),onKeyDown:mn(t.onKeyDown,h=>{var b;const m=h.currentTarget.contains(h.target),g=QMe[c.dir].includes(h.key);m&&g&&(l.onOpenChange(!1),(b=u.trigger)==null||b.focus(),h.preventDefault())})})})})})},"MenuSubContent"));function t7(e){return e?"open":"closed"}Ir(t7,"getOpenState");function _w(e){return e==="indeterminate"}Ir(_w,"isIndeterminate");function JN(e){return _w(e)?"indeterminate":e?"checked":"unchecked"}Ir(JN,"getCheckedState");function eue(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Ir(eue,"focusFirst");function tue(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Ir(tue,"wrapArray");function nue(e,t,n){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let a=tue(e,Math.max(s,0));i.length===1&&(a=a.filter(u=>u!==n));const c=a.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}Ir(nue,"getNextMatch");function rue(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,a=t.length-1;sr!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(i=!i)}return i}Ir(rue,"isPointInPolygon");function iue(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return rue(n,t)}Ir(iue,"isPointerInGraceArea");function e1(e){return t=>t.pointerType==="mouse"?e(t):void 0}Ir(e1,"whenMouse");var p4e=VMe,m4e=qce,g4e=qMe,b4e=GMe,y4e=e7,O4e=JMe,x4e=r4e,v4e=s4e,w4e=o4e,S4e=l4e,E4e=u4e,k4e=d4e,_4e=h4e,T4e=Object.defineProperty,Hl=(e,t)=>T4e(e,"name",{value:t,configurable:!0}),n7="DropdownMenu",[C4e,lMt]=rl(n7,[zce]),ql=zce(),[A4e,sue]=C4e(n7),N4e=Hl(e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:a,modal:l=!0}=e,c=ql(t),u=p.useRef(null),[d,f]=Bc({prop:i,defaultProp:s??!1,onChange:a,caller:n7});return o.jsx(A4e,{scope:t,triggerId:Fp(),triggerRef:u,contentId:Fp(),open:d,onOpenChange:f,onOpenToggle:p.useCallback(()=>f(h=>!h),[f]),modal:l,children:o.jsx(p4e,{...c,open:d,onOpenChange:f,dir:r,modal:l,children:n})})},"DropdownMenu"),j4e="DropdownMenuTrigger",R4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,disabled:i=!1,...s}=t,a=sue(j4e,r),l=ql(r),c=zr(n,a.triggerRef);return o.jsx(m4e,{asChild:!0,...l,children:o.jsx(pi.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...s,ref:c,onPointerDown:mn(t.onPointerDown,u=>{!i&&u.button===0&&u.ctrlKey===!1&&(a.onOpenToggle(),a.open||u.preventDefault())}),onKeyDown:mn(t.onKeyDown,u=>{i||(["Enter"," "].includes(u.key)&&a.onOpenToggle(),u.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),I4e=Hl(e=>{const{__scopeDropdownMenu:t,...n}=e,r=ql(t);return o.jsx(g4e,{...r,...n})},"DropdownMenuPortal"),D4e="DropdownMenuContent",P4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=sue(D4e,r),a=ql(r),l=p.useRef(!1);return o.jsx(b4e,{id:s.contentId,"aria-labelledby":s.triggerId,...a,...i,ref:n,onCloseAutoFocus:mn(t.onCloseAutoFocus,c=>{var u;l.current||(u=s.triggerRef.current)==null||u.focus(),l.current=!1,c.preventDefault()}),onInteractOutside:mn(t.onInteractOutside,c=>{const u=c.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,f=u.button===2||d;(!s.modal||f)&&(l.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),M4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(y4e,{...s,...i,ref:n})},"DropdownMenuItem")),L4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(O4e,{...s,...i,ref:n})},"DropdownMenuCheckboxItem")),$4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(x4e,{...s,...i,ref:n})},"DropdownMenuRadioGroup")),B4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(v4e,{...s,...i,ref:n})},"DropdownMenuRadioItem")),Q4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(w4e,{...s,...i,ref:n})},"DropdownMenuItemIndicator")),U4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(S4e,{...s,...i,ref:n})},"DropdownMenuSeparator")),F4e=Hl(e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,a=ql(t),[l,c]=Bc({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return o.jsx(E4e,{...a,open:l,onOpenChange:c,children:n})},"DropdownMenuSub"),z4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(k4e,{...s,...i,ref:n})},"DropdownMenuSubTrigger")),V4e=p.forwardRef(Hl(function(t,n){const{__scopeDropdownMenu:r,...i}=t,s=ql(r);return o.jsx(_4e,{...s,...i,ref:n,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuSubContent")),H4e=N4e,q4e=R4e,aue=I4e,X4e=P4e,oue=M4e,G4e=L4e,W4e=$4e,Y4e=B4e,lue=Q4e,Z4e=U4e,K4e=F4e,J4e=z4e,eLe=V4e,tLe=Object.defineProperty,dm=(e,t)=>tLe(e,"name",{value:t,configurable:!0}),r7="Popover",[cue,cMt]=rl(r7,[W1]),i7=W1(),[nLe,Z1]=cue(r7),rLe=dm(e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:a=!1}=e,l=i7(t),c=p.useRef(null),[u,d]=p.useState(!1),[f,h]=Bc({prop:r,defaultProp:i??!1,onChange:s,caller:r7});return o.jsx(WN,{...l,children:o.jsx(nLe,{scope:t,contentId:Fp(),triggerRef:c,open:f,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(m=>!m),[h]),hasCustomAnchor:u,onCustomAnchorAdd:p.useCallback(()=>d(!0),[]),onCustomAnchorRemove:p.useCallback(()=>d(!1),[]),modal:a,children:n})})},"Popover"),iLe="PopoverTrigger",sLe=p.forwardRef(dm(function(t,n){const{__scopePopover:r,...i}=t,s=Z1(iLe,r),a=i7(r),l=zr(n,s.triggerRef),c=o.jsx(pi.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s7(s.open),...i,ref:l,onClick:mn(t.onClick,s.onOpenToggle)});return s.hasCustomAnchor?c:o.jsx(q9,{asChild:!0,...a,children:c})},"PopoverTrigger")),uue="PopoverPortal",[aLe,oLe]=cue(uue,{forceMount:void 0}),lLe=dm(e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,s=Z1(uue,t);return o.jsx(aLe,{scope:t,forceMount:n,children:o.jsx(Ed,{present:n||s.open,children:o.jsx(D9,{asChild:!0,container:i,children:r})})})},"PopoverPortal"),Tw="PopoverContent",cLe=p.forwardRef(dm(function(t,n){const r=oLe(Tw,t.__scopePopover),{forceMount:i=r.forceMount,...s}=t,a=Z1(Tw,t.__scopePopover);return o.jsx(Ed,{present:i||a.open,children:a.modal?o.jsx(dLe,{...s,ref:n}):o.jsx(fLe,{...s,ref:n})})},"PopoverContent")),uLe=Jf("PopoverContent.RemoveScroll"),dLe=p.forwardRef(dm(function(t,n){const r=Z1(Tw,t.__scopePopover),i=p.useRef(null),s=zr(n,i),a=p.useRef(!1);return p.useEffect(()=>{const l=i.current;if(l)return mce(l)},[]),o.jsx(M9,{as:uLe,allowPinchZoom:!0,children:o.jsx(due,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:mn(t.onCloseAutoFocus,l=>{var c;l.preventDefault(),a.current||(c=r.triggerRef.current)==null||c.focus()}),onPointerDownOutside:mn(t.onPointerDownOutside,l=>{const c=l.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;a.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:mn(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),fLe=p.forwardRef(dm(function(t,n){const r=Z1(Tw,t.__scopePopover),i=p.useRef(!1),s=p.useRef(!1);return o.jsx(due,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var l,c;(l=t.onCloseAutoFocus)==null||l.call(t,a),a.defaultPrevented||(i.current||(c=r.triggerRef.current)==null||c.focus(),a.preventDefault()),i.current=!1,s.current=!1},onInteractOutside:a=>{var u,d;(u=t.onInteractOutside)==null||u.call(t,a),a.defaultPrevented||(i.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const l=a.target;((d=r.triggerRef.current)==null?void 0:d.contains(l))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})},"PopoverContentNonModal")),due=p.forwardRef(dm(function(t,n){const{__scopePopover:r,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,...h}=t,m=Z1(Tw,r),g=i7(r);return UN(),o.jsx(ece,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:s,onUnmountAutoFocus:a,children:o.jsx(j9,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:f,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onDismiss:()=>m.onOpenChange(!1),deferPointerDownOutside:!0,children:o.jsx(X9,{"data-state":s7(m.open),role:"dialog",id:m.contentId,...g,...h,ref:n,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})},"PopoverContentImpl"));function s7(e){return e?"open":"closed"}dm(s7,"getState");var fue=rLe,hue=sLe,pue=lLe,mue=cLe,hLe=Object.defineProperty,Ja=(e,t)=>hLe(e,"name",{value:t,configurable:!0}),gue="Radio",[pLe,bue]=rl(gue),[mLe,ej]=pLe(gue);function yue(e){const{__scopeRadio:t,checked:n=!1,children:r,disabled:i,form:s,name:a,onCheck:l,required:c,value:u="on",internal_do_not_use_render:d}=e,[f,h]=p.useState(null),[m,g]=p.useState(null),b=p.useRef(!1),[y,O]=p.useReducer(w=>w+1,0),v=f?!!s||!!f.closest("form"):!0,x={checked:n,disabled:i,required:c,name:a,form:s,value:u,control:f,setControl:h,hasConsumerStoppedPropagationRef:b,userInteractionCount:y,onUserInteraction:O,isFormControl:v,bubbleInput:m,setBubbleInput:g,onCheck:Ja(()=>l==null?void 0:l(),"onCheck")};return o.jsx(mLe,{scope:t,...x,children:Oue(d)?d(x):r})}Ja(yue,"RadioProvider");var gLe="RadioTrigger",bLe=p.forwardRef(Ja(function({__scopeRadio:t,onClick:n,...r},i){const{checked:s,disabled:a,value:l,setControl:c,onCheck:u,hasConsumerStoppedPropagationRef:d,onUserInteraction:f,isFormControl:h,bubbleInput:m}=ej(gLe,t),g=zr(i,c);return o.jsx(pi.button,{type:"button",role:"radio","aria-checked":s,"data-state":a7(s),"data-disabled":a?"":void 0,disabled:a,value:l,...r,ref:g,onClick:mn(n,b=>{s||(f(),u()),m&&h&&(d.current=b.isPropagationStopped(),d.current||b.stopPropagation())})})},"RadioTrigger")),yLe="RadioIndicator",OLe=p.forwardRef(Ja(function(t,n){const{__scopeRadio:r,forceMount:i,...s}=t,a=ej(yLe,r);return o.jsx(Ed,{present:i||a.checked,children:o.jsx(pi.span,{"data-state":a7(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:n})})},"RadioIndicator")),xLe="RadioBubbleInput",vLe=p.forwardRef(Ja(function({__scopeRadio:t,onClick:n,...r},i){const{control:s,checked:a,required:l,disabled:c,name:u,value:d,form:f,bubbleInput:h,setBubbleInput:m,hasConsumerStoppedPropagationRef:g,userInteractionCount:b}=ej(xLe,t),y=zr(i,m),O=KS(s),v=p.useRef(!1),x=p.useRef(a),w=p.useRef(b);p.useEffect(()=>{const E=h;if(!E)return;const k=window.HTMLInputElement.prototype,C=Object.getOwnPropertyDescriptor(k,"checked").set,T=b!==w.current;w.current=b;const A=x.current!==a;x.current=a;const j=!(T&&g.current);if(A&&C){v.current=!T;const L=new Event("click",{bubbles:j});C.call(E,a),E.dispatchEvent(L),v.current=!1}},[h,a,g,b]);const S=p.useRef(a);return o.jsx(pi.input,{type:"radio","aria-hidden":!0,defaultChecked:S.current,required:l,disabled:c,name:u,value:d,form:f,...r,tabIndex:-1,ref:y,onClick:mn(n,E=>{v.current&&E.stopPropagation()}),style:{...r.style,...O,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"RadioBubbleInput"));function Oue(e){return typeof e=="function"}Ja(Oue,"isFunction");function a7(e){return e?"checked":"unchecked"}Ja(a7,"getState");var wLe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],o7="RadioGroup",[SLe,uMt]=rl(o7,[Y1,bue]),xue=Y1(),tj=bue(),[ELe,kLe]=SLe(o7),_Le=p.forwardRef(Ja(function(t,n){const{__scopeRadioGroup:r,name:i,form:s,defaultValue:a,value:l,required:c=!1,disabled:u=!1,orientation:d,dir:f,loop:h=!0,onValueChange:m,...g}=t,b=xue(r),y=ZS(f),[O,v]=Bc({prop:l,defaultProp:a??null,onChange:m,caller:o7}),[x,w]=p.useState(null),S=zr(n,w),E=p.useRef(O);return p.useEffect(()=>{const k=s?x==null?void 0:x.ownerDocument.getElementById(s):x==null?void 0:x.closest("form");if(k instanceof HTMLFormElement){const _=Ja(()=>v(E.current),"reset");return k.addEventListener("reset",_),()=>k.removeEventListener("reset",_)}},[x,s,v]),o.jsx(ELe,{scope:r,name:i,form:s,required:c,disabled:u,value:O,onValueChange:v,children:o.jsx(Y9,{asChild:!0,...b,orientation:d,dir:y,loop:h,children:o.jsx(pi.div,{role:"radiogroup","aria-required":c,"aria-orientation":d,"data-disabled":u?"":void 0,dir:y,...g,ref:S})})})},"RadioGroup")),TLe="RadioGroupItemProvider",CLe="RadioGroupItemTrigger";function vue(e){const{__scopeRadioGroup:t,value:n,disabled:r,children:i,internal_do_not_use_render:s}=e,a=kLe(TLe,t),l=tj(t),c=a.disabled||r;return o.jsx(yue,{...l,checked:a.value===n,disabled:c,required:a.required,name:a.name,form:a.form,value:n,onCheck:()=>a.onValueChange(n),internal_do_not_use_render:s,children:i})}Ja(vue,"RadioGroupItemProvider");var ALe=p.forwardRef(Ja(function(t,n){const{__scopeRadioGroup:r,...i}=t,s=xue(r),a=tj(r),{checked:l,disabled:c}=ej(CLe,a.__scopeRadio),u=p.useRef(null),d=zr(n,u),f=p.useRef(!1);return p.useEffect(()=>{const h=Ja(g=>{wLe.includes(g.key)&&(f.current=!0)},"handleKeyDown"),m=Ja(()=>f.current=!1,"handleKeyUp");return document.addEventListener("keydown",h),document.addEventListener("keyup",m),()=>{document.removeEventListener("keydown",h),document.removeEventListener("keyup",m)}},[]),o.jsx(Z9,{asChild:!0,...s,focusable:!c,active:l,children:o.jsx(bLe,{...a,...i,ref:d,onKeyDown:mn(i.onKeyDown,h=>{h.key==="Enter"&&h.preventDefault()}),onFocus:mn(i.onFocus,()=>{var h;f.current&&((h=u.current)==null||h.click())})})})},"RadioGroupItemTrigger")),NLe=p.forwardRef(Ja(function(t,n){const{__scopeRadioGroup:r,value:i,disabled:s,...a}=t;return o.jsx(vue,{__scopeRadioGroup:r,value:i,disabled:s,internal_do_not_use_render:({isFormControl:l})=>o.jsxs(o.Fragment,{children:[o.jsx(ALe,{...a,ref:n,__scopeRadioGroup:r}),l&&o.jsx(jLe,{__scopeRadioGroup:r})]})})},"RadioGroupItem")),jLe=p.forwardRef(Ja(function(t,n){const{__scopeRadioGroup:r,...i}=t,s=tj(r);return o.jsx(vLe,{...s,...i,ref:n})},"RadioGroupItemBubbleInput")),RLe=p.forwardRef(Ja(function(t,n){const{__scopeRadioGroup:r,...i}=t,s=tj(r);return o.jsx(OLe,{...s,...i,ref:n})},"RadioGroupIndicator")),ILe=Object.defineProperty,Hp=(e,t)=>ILe(e,"name",{value:t,configurable:!0}),l7="Switch",[DLe,dMt]=rl(l7),[PLe,c7]=DLe(l7);function wue(e){const{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:s,form:a,name:l,onCheckedChange:c,required:u,value:d="on",internal_do_not_use_render:f}=e,[h,m]=Bc({prop:n,defaultProp:i??!1,onChange:c,caller:l7}),[g,b]=p.useState(null),[y,O]=p.useState(null),v=p.useRef(!1),[x,w]=p.useReducer(k=>k+1,0),S=g?!!a||!!g.closest("form"):!0,E={checked:h,setChecked:m,disabled:s,control:g,setControl:b,name:l,form:a,value:d,hasConsumerStoppedPropagationRef:v,userInteractionCount:x,onUserInteraction:w,required:u,defaultChecked:i,isFormControl:S,bubbleInput:y,setBubbleInput:O};return o.jsx(PLe,{scope:t,...E,children:Sue(f)?f(E):r})}Hp(wue,"SwitchProvider");var MLe="SwitchTrigger",LLe=p.forwardRef(Hp(function({__scopeSwitch:t,onClick:n,...r},i){const{control:s,form:a,value:l,disabled:c,checked:u,required:d,setControl:f,setChecked:h,hasConsumerStoppedPropagationRef:m,onUserInteraction:g,isFormControl:b,bubbleInput:y}=c7(MLe,t),O=zr(i,f),v=p.useRef(u);return p.useEffect(()=>{const x=a?s==null?void 0:s.ownerDocument.getElementById(a):s==null?void 0:s.form;if(x instanceof HTMLFormElement){const w=Hp(()=>h(v.current),"reset");return x.addEventListener("reset",w),()=>x.removeEventListener("reset",w)}},[s,a,h]),o.jsx(pi.button,{type:"button",role:"switch","aria-checked":u,"aria-required":d,"data-state":u7(u),"data-disabled":c?"":void 0,disabled:c,value:l,...r,ref:O,onClick:mn(n,x=>{g(),h(w=>!w),y&&b&&(m.current=x.isPropagationStopped(),m.current||x.stopPropagation())})})},"SwitchTrigger")),$Le=p.forwardRef(Hp(function(t,n){const{__scopeSwitch:r,name:i,checked:s,defaultChecked:a,required:l,disabled:c,value:u,onCheckedChange:d,form:f,...h}=t;return o.jsx(wue,{__scopeSwitch:r,checked:s,defaultChecked:a,disabled:c,required:l,onCheckedChange:d,name:i,form:f,value:u,internal_do_not_use_render:({isFormControl:m})=>o.jsxs(o.Fragment,{children:[o.jsx(LLe,{...h,ref:n,__scopeSwitch:r}),m&&o.jsx(FLe,{__scopeSwitch:r})]})})},"Switch")),BLe="SwitchThumb",QLe=p.forwardRef(Hp(function(t,n){const{__scopeSwitch:r,...i}=t,s=c7(BLe,r);return o.jsx(pi.span,{"data-state":u7(s.checked),"data-disabled":s.disabled?"":void 0,...i,ref:n})},"SwitchThumb")),ULe="SwitchBubbleInput",FLe=p.forwardRef(Hp(function({__scopeSwitch:t,onClick:n,...r},i){const{control:s,hasConsumerStoppedPropagationRef:a,userInteractionCount:l,checked:c,defaultChecked:u,required:d,disabled:f,name:h,value:m,form:g,bubbleInput:b,setBubbleInput:y}=c7(ULe,t),O=zr(i,y),v=KS(s),x=p.useRef(!1),w=p.useRef(c),S=p.useRef(l);p.useEffect(()=>{const k=b;if(!k)return;const _=window.HTMLInputElement.prototype,T=Object.getOwnPropertyDescriptor(_,"checked").set,A=l!==S.current;S.current=l;const j=w.current!==c;w.current=c;const L=!(A&&a.current);if(j&&T){x.current=!A;const I=new Event("click",{bubbles:L});T.call(k,c),k.dispatchEvent(I),x.current=!1}},[b,c,a,l]);const E=p.useRef(c);return o.jsx(pi.input,{type:"checkbox","aria-hidden":!0,defaultChecked:u??E.current,required:d,disabled:f,name:h,value:m,form:g,...r,tabIndex:-1,ref:O,onClick:mn(n,k=>{x.current&&k.stopPropagation()}),style:{...r.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"SwitchBubbleInput"));function Sue(e){return typeof e=="function"}Hp(Sue,"isFunction");function u7(e){return e?"checked":"unchecked"}Hp(u7,"getState");var zLe=Object.defineProperty,VLe=(e,t)=>zLe(e,"name",{value:t,configurable:!0}),HLe="Toggle",qLe=p.forwardRef(VLe(function(t,n){const{pressed:r,defaultPressed:i,onPressedChange:s,...a}=t,[l,c]=Bc({prop:r,onChange:s,defaultProp:i??!1,caller:HLe});return o.jsx(pi.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":t.disabled?"":void 0,...a,ref:n,onClick:mn(t.onClick,()=>{t.disabled||c(!l)})})},"Toggle")),XLe=Object.defineProperty,qp=(e,t)=>XLe(e,"name",{value:t,configurable:!0}),K1="ToggleGroup",[Eue,fMt]=rl(K1,[Y1]),kue=Y1(),GLe=p.forwardRef(qp(function(t,n){const{type:r,...i}=t;if(r==="single"){const s=i;return o.jsx(WLe,{role:"radiogroup",...s,ref:n})}if(r==="multiple"){const s=i;return o.jsx(YLe,{role:"toolbar",...s,ref:n})}throw new Error(`Missing prop \`type\` expected on \`${K1}\``)},"ToggleGroup")),[_ue,Tue]=Eue(K1),WLe=p.forwardRef(qp(function(t,n){const{value:r,defaultValue:i,onValueChange:s=qp(()=>{},"onValueChange"),...a}=t,[l,c]=Bc({prop:r,defaultProp:i??"",onChange:s,caller:K1});return o.jsx(_ue,{scope:t.__scopeToggleGroup,type:"single",value:p.useMemo(()=>l?[l]:[],[l]),onItemActivate:c,onItemDeactivate:p.useCallback(()=>c(""),[c]),children:o.jsx(Cue,{...a,ref:n})})},"ToggleGroupImplSingle")),YLe=p.forwardRef(qp(function(t,n){const{value:r,defaultValue:i,onValueChange:s=qp(()=>{},"onValueChange"),...a}=t,[l,c]=Bc({prop:r,defaultProp:i??[],onChange:s,caller:K1}),u=p.useCallback(f=>c((h=[])=>[...h,f]),[c]),d=p.useCallback(f=>c((h=[])=>h.filter(m=>m!==f)),[c]);return o.jsx(_ue,{scope:t.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:u,onItemDeactivate:d,children:o.jsx(Cue,{...a,ref:n})})},"ToggleGroupImplMultiple")),[ZLe,KLe]=Eue(K1),Cue=p.forwardRef(qp(function(t,n){const{__scopeToggleGroup:r,disabled:i=!1,rovingFocus:s=!0,orientation:a,dir:l,loop:c=!0,...u}=t,d=kue(r),f=ZS(l),h={dir:f,...u};return o.jsx(ZLe,{scope:r,rovingFocus:s,disabled:i,children:s?o.jsx(Y9,{asChild:!0,...d,orientation:a,dir:f,loop:c,children:o.jsx(pi.div,{...h,ref:n})}):o.jsx(pi.div,{...h,ref:n})})},"ToggleGroupImpl")),y4="ToggleGroupItem",JLe=p.forwardRef(qp(function(t,n){const r=Tue(y4,t.__scopeToggleGroup),i=KLe(y4,t.__scopeToggleGroup),s=kue(t.__scopeToggleGroup),a=r.value.includes(t.value),l=i.disabled||t.disabled,c={...t,pressed:a,disabled:l},u=p.useRef(null);return i.rovingFocus?o.jsx(Z9,{asChild:!0,...s,focusable:!l,active:a,ref:u,children:o.jsx(sq,{...c,ref:n})}):o.jsx(sq,{...c,ref:n})},"ToggleGroupItem")),sq=p.forwardRef(qp(function(t,n){const{__scopeToggleGroup:r,value:i,...s}=t,a=Tue(y4,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},c=a.type==="single"?l:void 0;return o.jsx(qLe,{...c,...s,ref:n,onPressedChange:u=>{u?a.onItemActivate(i):a.onItemDeactivate(i)}})},"ToggleGroupItemImpl")),e6e=Object.defineProperty,ga=(e,t)=>e6e(e,"name",{value:t,configurable:!0}),[d7,hMt]=rl("Tooltip",[W1]),f7=W1(),t6e="TooltipProvider",n6e=700,O4="tooltip.open",[r6e,h7]=d7(t6e),i6e=ga(e=>{const{__scopeTooltip:t,delayDuration:n=n6e,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,a=p.useRef(!0),l=p.useRef(!1),c=p.useRef(0);return p.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),o.jsx(r6e,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:p.useCallback(()=>{r<=0||(window.clearTimeout(c.current),a.current=!1)},[r]),onClose:p.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,r))},[r]),isPointerInTransitRef:l,onPointerInTransitChange:p.useCallback(u=>{l.current=u},[]),disableHoverableContent:i,children:s})},"TooltipProvider"),x4="Tooltip",[s6e,eE]=d7(x4),a6e=ga(e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:a,delayDuration:l}=e,c=h7(x4,e.__scopeTooltip),u=f7(t),[d,f]=p.useState(null),[h,m]=p.useState(void 0),g=Fp(),b=p.useRef(0),y=a??c.disableHoverableContent,O=l??c.delayDuration,v=p.useRef(!1),[x,w]=Bc({prop:r,defaultProp:i??!1,onChange:ga(T=>{T?(c.onOpen(),document.dispatchEvent(new CustomEvent(O4))):c.onClose(),s==null||s(T)},"onChange"),caller:x4}),S=p.useMemo(()=>x?v.current?"delayed-open":"instant-open":"closed",[x]),E=p.useCallback(()=>{window.clearTimeout(b.current),b.current=0,v.current=!1,w(!0)},[w]),k=p.useCallback(()=>{window.clearTimeout(b.current),b.current=0,w(!1)},[w]),_=p.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{v.current=!0,w(!0),b.current=0},O)},[O,w]);p.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]);const C=h??g;return o.jsx(WN,{...u,children:o.jsx(s6e,{scope:t,contentId:C,setContentId:m,open:x,stateAttribute:S,trigger:d,onTriggerChange:f,onTriggerEnter:p.useCallback(()=>{c.isOpenDelayedRef.current?_():E()},[c.isOpenDelayedRef,_,E]),onTriggerLeave:p.useCallback(()=>{y?k():(window.clearTimeout(b.current),b.current=0)},[k,y]),onOpen:E,onClose:k,disableHoverableContent:y,children:n})})},"Tooltip"),aq="TooltipTrigger",o6e=p.forwardRef(ga(function(t,n){const{__scopeTooltip:r,...i}=t,s=eE(aq,r),a=h7(aq,r),l=f7(r),c=p.useRef(null),u=zr(n,c,s.onTriggerChange),d=p.useRef(!1),f=p.useRef(!1),h=p.useCallback(()=>d.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),o.jsx(q9,{asChild:!0,...l,children:o.jsx(pi.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...i,ref:u,onPointerMove:mn(t.onPointerMove,m=>{m.pointerType!=="touch"&&!f.current&&!a.isPointerInTransitRef.current&&(s.onTriggerEnter(),f.current=!0)}),onPointerLeave:mn(t.onPointerLeave,()=>{s.onTriggerLeave(),f.current=!1}),onPointerDown:mn(t.onPointerDown,()=>{s.open&&s.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:mn(t.onFocus,()=>{d.current||s.onOpen()}),onBlur:mn(t.onBlur,s.onClose),onClick:mn(t.onClick,s.onClose)})})},"TooltipTrigger")),Aue="TooltipPortal",[l6e,c6e]=d7(Aue,{forceMount:void 0}),u6e=ga(e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=eE(Aue,t);return o.jsx(l6e,{scope:t,forceMount:n,children:o.jsx(Ed,{present:n||s.open,children:o.jsx(D9,{asChild:!0,container:i,children:r})})})},"TooltipPortal"),Cw="TooltipContent",d6e=p.forwardRef(ga(function(t,n){const r=c6e(Cw,t.__scopeTooltip),{forceMount:i=r.forceMount,side:s="top",...a}=t,l=eE(Cw,t.__scopeTooltip);return o.jsx(Ed,{present:i||l.open,children:l.disableHoverableContent?o.jsx(Nue,{side:s,...a,ref:n}):o.jsx(f6e,{side:s,...a,ref:n})})},"TooltipContent")),f6e=p.forwardRef(ga(function(t,n){const r=eE(Cw,t.__scopeTooltip),i=h7(Cw,t.__scopeTooltip),s=p.useRef(null),a=zr(n,s),[l,c]=p.useState(null),{trigger:u,onClose:d}=r,f=s.current,{onPointerInTransitChange:h}=i,m=p.useCallback(()=>{c(null),h(!1)},[h]),g=p.useCallback((b,y)=>{const O=b.currentTarget,v={x:b.clientX,y:b.clientY},x=jue(v,O.getBoundingClientRect()),w=Rue(v,x),S=Iue(y.getBoundingClientRect()),E=Pue([...w,...S]);c(E),h(!0)},[h]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(u&&f){const b=ga(O=>g(O,f),"handleTriggerLeave"),y=ga(O=>g(O,u),"handleContentLeave");return u.addEventListener("pointerleave",b),f.addEventListener("pointerleave",y),()=>{u.removeEventListener("pointerleave",b),f.removeEventListener("pointerleave",y)}}},[u,f,g,m]),p.useEffect(()=>{if(l){const b=ga(y=>{const O=y.target,v={x:y.clientX,y:y.clientY},x=(u==null?void 0:u.contains(O))||(f==null?void 0:f.contains(O)),w=!Due(v,l);x?m():w&&(m(),d())},"handleTrackPointerGrace");return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[u,f,l,d,m]),o.jsx(Nue,{...t,ref:a})},"TooltipContentHoverable")),h6e=jle("TooltipContent"),Nue=p.forwardRef(ga(function(t,n){const{__scopeTooltip:r,children:i,"aria-label":s,id:a,onEscapeKeyDown:l,onPointerDownOutside:c,...u}=t,d=eE(Cw,r),f=f7(r),{onClose:h}=d;p.useEffect(()=>(document.addEventListener(O4,h),()=>document.removeEventListener(O4,h)),[h]),p.useEffect(()=>{if(d.trigger){const g=ga(b=>{b.target instanceof Node&&b.target.contains(d.trigger)&&h()},"handleScroll");return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[d.trigger,h]);const{setContentId:m}=d;return Ic(()=>(m(a),()=>{m(void 0)}),[a,m]),o.jsx(j9,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:h,children:o.jsxs(X9,{"data-state":d.stateAttribute,role:s?void 0:"tooltip",id:s?void 0:d.contentId,...f,...u,ref:n,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[o.jsx(h6e,{children:i}),s?o.jsx(PDe,{id:d.contentId,role:"tooltip",children:s}):null]})})},"TooltipContentImpl"));function jue(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}ga(jue,"getExitSideFromRect");function Rue(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}ga(Rue,"getPaddedExitPoints");function Iue(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}ga(Iue,"getPointsFromRect");function Due(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,a=t.length-1;sr!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(i=!i)}return i}ga(Due,"isPointInPolygon");function Pue(e){const t=e.slice();return t.sort((n,r)=>n.xr.x?1:n.yr.y?1:0),Mue(t)}ga(Pue,"getHull");function Mue(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}ga(Mue,"getHullPresorted");var p6e=i6e,m6e=a6e,Lue=o6e,g6e=u6e,b6e=d6e;const y6e=()=>{var e;return typeof ClipboardItem<"u"&&!!((e=navigator.clipboard)!=null&&e.write)};function O6e(e){const{"text/plain":t,...n}=e;return new ClipboardItem({...n,...t?{"text/plain":new Blob([t],{type:"text/plain"})}:null})}async function x6e(e,t=document.body){if(typeof e=="string")return oq(e,t);try{return y6e()?(await navigator.clipboard.write([O6e(e)]),!0):e["text/plain"]?oq(e["text/plain"],t):!1}catch{return!1}}async function oq(e,t=document.body){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.opacity="0",t.appendChild(n),n.focus(),n.select();let r=!1;try{r=document.execCommand("copy")}catch{}return t.removeChild(n),r}function Xp(e){const t=p.useRef(e);return t.current=e,t}let t1=[],t2=!1;const lq=e=>{var t,n;if(e.key==="Escape"){const[r]=t1;r&&(e.preventDefault(),(n=(t=r.callback).current)==null||n.call(t))}},$ue=()=>{t1.length>0&&!t2?(document.body.addEventListener("keydown",lq),t2=!0):t1.length===0&&t2&&(document.body.removeEventListener("keydown",lq),t2=!1)},v6e=e=>{t1.unshift(e),$ue()},w6e=({id:e})=>{t1=t1.filter(t=>t.id!==e),$ue()},tE=(e,t)=>{const n=p.useId(),r=Xp(t);p.useEffect(()=>{if(!e)return;const i={id:n,callback:r};return v6e(i),()=>w6e(i)},[n,e,r])},S6e="_Tooltip_16g2y_1",E6e="_TriggerDecorator_16g2y_73",Bue={Tooltip:S6e,TriggerDecorator:E6e},vo=e=>{const{ref:t,children:n,content:r,forceOpen:i=r===null?!1:void 0,maxWidth:s=300,openDelay:a=150,interactive:l=!1,compact:c=!1,preventUnintentionalClickToClose:u,align:d,alignOffset:f=0,side:h,sideOffset:m=5,gutterSize:g="md",contentClassName:b,onPointerDown:y,onClick:O,...v}=e,[x,w]=p.useState(!1),[S,E]=p.useState(!1);k9(()=>E(!1),S?400:null);const k=i??x,_=T=>{typeof i!="boolean"&&(w(T),u&&E(T))},C=T=>{u&&S&&(T.preventDefault(),T.stopPropagation())};return o.jsxs(Que,{open:k,delayDuration:a,onOpenChange:_,disableHoverableContent:!l,children:[o.jsx(Lue,{asChild:!0,children:o.jsx(Ale,{...v,ref:t,onPointerDown:T=>{C(T),y==null||y(T)},onClick:T=>{C(T),O==null||O(T)},children:n})}),o.jsx(Uue,{maxWidth:s,compact:c,align:d,alignOffset:f,side:h,sideOffset:m,gutterSize:g,className:b,children:r})]})},Que=({children:e,open:t,onOpenChange:n,...r})=>(tE(t,()=>{n(!1)}),o.jsx(p6e,{children:o.jsx(m6e,{open:t,onOpenChange:n,...r,children:e})})),Uue=({children:e,maxWidth:t=300,compact:n=!1,clickable:r=void 0,alignOffset:i=0,sideOffset:s=5,gutterSize:a="md",className:l,style:c,...u})=>o.jsx(g6e,{children:o.jsx(b6e,{...u,className:ur(Bue.Tooltip,l),"data-compact":n,"data-clickable":r,"data-gutter-size":a,alignOffset:i,sideOffset:s,collisionPadding:15,hideWhenDetached:!0,style:{...c,maxWidth:t},onEscapeKeyDown:Df,children:e})}),k6e=({children:e,asChild:t=!0,...n})=>o.jsx(Lue,{asChild:t,...n,children:e}),_6e=e=>{const{children:t,className:n,focusable:r=!0,ref:i,...s}=e,a=typeof t=="string";return o.jsx(Ale,{ref:i,...s,className:ur(Bue.TriggerDecorator,n),tabIndex:r?0:void 0,children:a?o.jsx("span",{children:t}):t})};vo.Root=Que;vo.Content=Uue;vo.Trigger=k6e;vo.TriggerDecorator=_6e;const T6e=50,cq=48;function C6e(e){return(e.events??[]).flatMap(t=>{var i,s;const r=(((i=t.content)==null?void 0:i.parts)??[]).map(a=>typeof a.text=="string"?a.text:"").filter(Boolean).join("");return r?[{text:r,role:t.author??((s=t.content)==null?void 0:s.role)??"",ts:t.timestamp}]:[]})}function A6e(e){var t,n;for(const r of e.events??[])if(r.author==="user"||((t=r.content)==null?void 0:t.role)==="user"){const i=(((n=r.content)==null?void 0:n.parts)??[]).map(s=>s.text).find(Boolean);if(i)return i}return"未命名会话"}function N6e(e,t,n){const r=Math.max(0,t-cq),i=Math.min(e.length,t+n+cq);return(r>0?"…":"")+e.slice(r,i).trim()+(i{var c;if((c=l.events)!=null&&c.length)return l;try{return await PN(t,e,l.id)}catch{return l}})),a=[];for(const l of s)for(const{text:c,role:u,ts:d}of C6e(l)){const f=c.toLowerCase().indexOf(r);if(f!==-1){a.push({type:"session",appId:t,sessionId:l.id,title:A6e(l),snippet:N6e(c,f,r.length),role:u,ts:d??l.lastUpdateTime});break}}return a.sort((l,c)=>(c.ts??0)-(l.ts??0)),a.slice(0,T6e)}async function R6e(e,t){if(!e||!t.trim())return{results:[]};let n;try{n=await goe(e,t.trim())}catch(a){const l=String(a);return{results:[],note:l.includes("404")?"网络搜索接口未就绪(后端未启用 /web/search)。":`网络搜索失败:${l}`}}const{mounted:r,results:i,error:s}=n;return r?s?{results:[],note:s}:{results:i.map((a,l)=>({type:"web",index:l,title:a.title,url:a.url,siteName:a.siteName,summary:a.summary}))}:{results:[],note:"当前 Agent 未挂载 web_search 工具。"}}async function I6e(e,t,n,r){if(!t||!r.trim())return{results:[]};const i=await moe(t,e,r.trim(),n);if(!i.mounted)return{results:[],note:e==="knowledge"?"该 Agent 未挂载知识库。":"该 Agent 未挂载长期记忆。"};if(i.error)return{results:[],note:i.error};const s=i.sourceName??(e==="knowledge"?"知识库":"长期记忆");return{results:i.results.map((a,l)=>e==="knowledge"?{type:"knowledge",index:l,content:a.content,sourceName:s,sourceType:i.sourceType}:{type:"memory",index:l,content:a.content,sourceName:s,sourceType:i.sourceType,author:a.author,ts:a.timestamp})}}async function D6e(e,t,n){return e==="session"?{results:await j6e(n.userId,n.appId,t)}:e==="web"?R6e(n.appId,t):I6e(e,n.appId,n.userId,t)}function Fue({mirrored:e=!1}){return o.jsxs("g",{opacity:"0.5",transform:e?"translate(20 0) scale(-1 1)":void 0,children:[o.jsx("path",{className:"sidebar-panel-glyph__divider",d:"M5.938 6.833c.11 0 .249.102.249.292v6.042c0 .19-.14.291-.249.291s-.248-.101-.248-.291V7.125c0-.19.139-.292.248-.292Z",strokeWidth:"1.167"}),o.jsx("path",{className:"sidebar-panel-glyph__frame",d:"M14.5 3.75h-9a3 3 0 0 0-3 3v6.857a3 3 0 0 0 3 3h9a3 3 0 0 0 3-3V6.75a3 3 0 0 0-3-3Z",strokeWidth:"1.667",strokeLinecap:"round",strokeLinejoin:"round"})]})}function P6e(e){return o.jsx("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",...e,children:o.jsx(Fue,{})})}function M6e(e){return o.jsx("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",...e,children:o.jsx(Fue,{mirrored:!0})})}function L6e(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"M12 8.333c.368 0 .667.299.667.667v2h2a.667.667 0 0 1 0 1.333h-2v2a.667.667 0 0 1-1.334 0v-2h-2a.667.667 0 0 1 0-1.333h2V9c0-.368.299-.667.667-.667ZM7.667 1c3.49 0 6.383 2.554 6.913 5.896a.667.667 0 0 1-1.317.208 5.667 5.667 0 1 0-9.708 4.424.67.67 0 0 1 .07.12.667.667 0 0 1-.13.834l-.95.853 4.788-.002a.667.667 0 0 1 0 1.334l-5.657.002c-.917 0-1.35-1.131-.67-1.744l1.163-1.045A6.97 6.97 0 0 1 .667 8c0-3.866 3.134-7 7-7Z",fill:"currentColor"})})}function $6e(e){return o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.333",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"7.333",cy:"7.333",r:"5.333"}),o.jsx("path",{d:"m11.133 11.133 2.867 2.867"})]})}function B6e(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"M8 0.667c4.05 0 7.334 3.283 7.334 7.333 0 4.05-3.284 7.334-7.334 7.334S0.667 12.05 0.667 8 3.95 0.667 8 0.667Zm0 1.333a6 6 0 1 0 0 12A6 6 0 0 0 8 2ZM6.167 6c.368 0 .667.299.667.667v2a.667.667 0 0 1-1.334 0v-2c0-.368.299-.667.667-.667Zm3.666 0c.368 0 .667.299.667.667v2a.667.667 0 0 1-1.333 0v-2c0-.368.298-.667.666-.667Z",fill:"currentColor"})})}function zue(e){return o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M7.58 2.6a.667.667 0 0 0-.667-.667h-.666a.667.667 0 0 0-.667.667v10.667c0 .368.299.666.667.666h.666a.667.667 0 0 0 .667-.666V2.6Zm1.333 10.667A2 2 0 0 1 6.913 15.267h-.666a2 2 0 0 1-2-2V2.6a2 2 0 0 1 2-2h.666a2 2 0 0 1 2 2v10.667Z",fill:"currentColor"}),o.jsx("path",{d:"M11.88 5.045a.667.667 0 0 0-.801-.514l-.653.136a.667.667 0 0 0-.504.786l1.85 8.092c.081.358.44.589.8.514l.653-.137a.667.667 0 0 0 .504-.786L11.88 5.045Zm3.155 7.82a2 2 0 0 1-1.512 2.358l-.653.136a2 2 0 0 1-2.403-1.541L8.617 5.726a2 2 0 0 1 1.513-2.358l.652-.136a2 2 0 0 1 2.404 1.541l1.849 8.092Z",fill:"currentColor"}),o.jsx("path",{d:"M4.247 2.6a.667.667 0 0 0-.667-.667h-.667a.667.667 0 0 0-.666.667v10.667c0 .368.298.666.666.666h.667a.667.667 0 0 0 .667-.666V2.6ZM5.58 13.267a2 2 0 0 1-2 2h-.667a2 2 0 0 1-2-2V2.6a2 2 0 0 1 2-2h.667a2 2 0 0 1 2 2v10.667Z",fill:"currentColor"})]})}function Q6e({className:e="icon"}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M16.4 10.7a5.7 5.7 0 1 1-1.67-4.03"}),o.jsx("path",{d:"M15.25 15.25 19.6 19.6"})]})}function U6e({open:e}){return o.jsx("svg",{className:`search-source-chevron ${e?"open":""}`,viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:"m3.25 4.75 2.75 2.5 2.75-2.5"})})}function F6e({active:e=!1,onClick:t}){return o.jsxs("button",{className:`new-chat${e?" is-active":""}`,onClick:t,"aria-label":"搜索","aria-current":e?"page":void 0,title:"搜索",children:[o.jsx($6e,{className:"icon"}),o.jsx("span",{className:"sidebar-nav-label",children:"搜索"})]})}function z6e(e,t,n){const r=!!e,i=new Set((t==null?void 0:t.searchSources)??[]),s=a=>r?n?"正在检测 Agent 能力":`当前 Agent 未挂载${a}`:"请选择 Agent";return[{id:"session",label:"会话",ready:r,unavailableLabel:"请选择 Agent"},{id:"web",label:"网络",ready:r&&i.has("web"),description:"通过 web_search 工具检索",unavailableLabel:s(" web_search 工具")},{id:"knowledge",label:"知识库",ready:r&&i.has("knowledge"),unavailableLabel:s("知识库")},{id:"memory",label:"长期记忆",ready:r&&i.has("memory"),unavailableLabel:s("长期记忆")}]}function TC(e){return{context_search:"Context Search",local:"本地",mem0:"Mem0",milvus:"Milvus",opensearch:"OpenSearch",openviking:"OpenViking",redis:"Redis",tos_vector:"TOS Vector",viking:"VikingDB"}[e.toLowerCase()]??e}function uq(e){return e?new Date(e*1e3).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):""}function V6e({userId:e,appId:t,agentInfo:n,capabilitiesLoading:r,agentLabel:i,onOpenSession:s}){var M,N;const[a,l]=p.useState("session"),[c,u]=p.useState(""),[d,f]=p.useState([]),[h,m]=p.useState(),[g,b]=p.useState(!1),[y,O]=p.useState(!1),[v,x]=p.useState(!1),w=p.useRef(0),S=p.useRef(null),E=z6e(t,n,r),k=E.find(D=>D.id===a),_=a==="knowledge"?(M=n==null?void 0:n.components)==null?void 0:M.find(D=>D.source==="knowledgebase"||D.kind==="knowledgebase"):a==="memory"?(N=n==null?void 0:n.components)==null?void 0:N.find(D=>D.source==="long_term_memory"||D.kind==="memory"):void 0;p.useEffect(()=>{w.current+=1,l("session"),f([]),m(void 0),O(!1),b(!1),x(!1)},[t]),p.useEffect(()=>{if(!v)return;function D(Q){var F;(F=S.current)!=null&&F.contains(Q.target)||x(!1)}return document.addEventListener("pointerdown",D),()=>document.removeEventListener("pointerdown",D)},[v]);async function C(D,Q){var z;const F=D.trim();if(!F||!((z=E.find(B=>B.id===Q))!=null&&z.ready))return;const $=++w.current;b(!0),O(!0);let H;try{H=await D6e(Q,F,{userId:e,appId:t})}catch(B){const V=B instanceof Error?B.message:String(B);H={results:[],note:`搜索失败:${V}`}}$===w.current&&(f(H.results),m(H.note),b(!1))}function T(D){w.current+=1,u(D),f([]),m(void 0),O(!1),b(!1)}function A(D){w.current+=1,l(D),x(!1),f([]),m(void 0),O(!1),b(!1)}const j=!!(k!=null&&k.ready),L=t?a==="web"?"在网络中检索":a==="knowledge"?`在 ${(_==null?void 0:_.name)??"当前 Agent 的知识库"} 中检索`:a==="memory"?`在 ${(_==null?void 0:_.name)??"当前用户的长期记忆"} 中检索`:"在当前 Agent 的会话中检索":"请先选择 Agent",I=_!=null&&_.backend?TC(_.backend):"";return o.jsxs("div",{className:"search",children:[o.jsxs("div",{className:"search-box",children:[o.jsxs("div",{className:"search-source-picker-wrap",ref:S,children:[o.jsxs("button",{className:"search-source-picker",type:"button","aria-label":`搜索类型:${(k==null?void 0:k.label)??"未选择"}`,"aria-haspopup":"listbox","aria-expanded":v,onClick:()=>x(D=>!D),children:[o.jsx("span",{children:(k==null?void 0:k.label)??"搜索类型"}),I&&o.jsx("small",{children:I}),o.jsx(U6e,{open:v})]}),v&&o.jsx("div",{className:"search-source-menu",role:"listbox","aria-label":"选择搜索类型",children:E.map(D=>{var $,H;const Q=D.id==="knowledge"?($=n==null?void 0:n.components)==null?void 0:$.find(z=>z.source==="knowledgebase"||z.kind==="knowledgebase"):D.id==="memory"?(H=n==null?void 0:n.components)==null?void 0:H.find(z=>z.source==="long_term_memory"||z.kind==="memory"):void 0,F=Q?[Q.name,Q.backend?TC(Q.backend):""].filter(Boolean).join(" · "):D.ready?D.description:D.unavailableLabel;return o.jsxs("button",{type:"button",role:"option","aria-selected":a===D.id,disabled:!D.ready,onClick:()=>A(D.id),children:[o.jsx("span",{children:D.label}),F&&o.jsx("small",{children:F})]},D.id)})})]}),o.jsx("span",{className:"search-box-divider","aria-hidden":!0}),o.jsx("input",{className:"search-input",value:c,onChange:D=>T(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),C(c,a))},placeholder:L,disabled:!j,autoFocus:!0}),o.jsx("button",{className:"search-go",onClick:()=>void C(c,a),disabled:!c.trim()||g,"aria-label":"搜索",children:g?o.jsx(lr,{className:"icon spin"}):o.jsx(Q6e,{className:"icon"})})]}),o.jsx("div",{className:"search-results",children:j?y?g?null:h?o.jsx("div",{className:"search-empty",children:h}):d.length===0&&y?o.jsxs("div",{className:"search-empty",children:["未找到匹配「",c.trim(),"」的结果。"]}):d.map((D,Q)=>o.jsx(H6e,{result:D,agentLabel:i,onOpen:s},Q)):o.jsx("div",{className:"search-empty",children:a==="web"?"输入关键词后回车或点击按钮,通过 web_search 工具检索。":a==="knowledge"?"输入问题,检索当前 Agent 挂载的知识库。":a==="memory"?"输入线索,检索当前用户跨会话保存的长期记忆。":"输入关键词后回车或点击按钮,搜索当前 Agent 的会话。"}):o.jsx("div",{className:"search-empty",children:t?r?"正在读取当前 Agent 的检索能力…":(k==null?void 0:k.unavailableLabel)??"当前 Agent 未挂载该数据源":"选择一个 Agent 后,即可检索会话、网络及其挂载的数据源。"})})]})}function H6e({result:e,agentLabel:t,onOpen:n}){switch(e.type){case"session":return o.jsxs("button",{className:"search-result",onClick:()=>n(e.appId,e.sessionId),children:[o.jsx(Lae,{className:"search-result-icon"}),o.jsxs("div",{className:"search-result-body",children:[o.jsxs("div",{className:"search-result-head",children:[o.jsx("span",{className:"search-result-title",children:e.title}),o.jsxs("span",{className:"search-result-meta",children:[t(e.appId),e.ts?` · ${uq(e.ts)}`:""]})]}),o.jsx("div",{className:"search-result-snippet",children:e.snippet})]})]});case"web":return o.jsxs("a",{className:"search-result",href:e.url||void 0,target:"_blank",rel:"noreferrer noopener",children:[o.jsx(jN,{className:"search-result-icon"}),o.jsxs("div",{className:"search-result-body",children:[o.jsxs("div",{className:"search-result-head",children:[o.jsx("span",{className:"search-result-title",children:e.title||e.url}),o.jsxs("span",{className:"search-result-meta",children:[e.siteName,e.url&&o.jsx(Dg,{className:"search-result-ext"})]})]}),e.summary&&o.jsx("div",{className:"search-result-snippet",children:e.summary})]})]});case"knowledge":return o.jsxs("div",{className:"search-result search-result-static",children:[o.jsx(dq,{source:"knowledge"}),o.jsxs("div",{className:"search-result-body",children:[o.jsxs("div",{className:"search-result-head",children:[o.jsxs("span",{className:"search-result-title",children:["知识片段 ",e.index+1]}),o.jsxs("span",{className:"search-result-meta",children:[e.sourceName,e.sourceType?` · ${TC(e.sourceType)}`:""]})]}),o.jsx("div",{className:"search-result-snippet search-result-snippet-expanded",children:e.content})]})]});case"memory":return o.jsxs("div",{className:"search-result search-result-static",children:[o.jsx(dq,{source:"memory"}),o.jsxs("div",{className:"search-result-body",children:[o.jsxs("div",{className:"search-result-head",children:[o.jsxs("span",{className:"search-result-title",children:["记忆片段 ",e.index+1]}),o.jsxs("span",{className:"search-result-meta",children:[e.sourceName,e.sourceType?` · ${TC(e.sourceType)}`:"",e.ts?` · ${uq(e.ts)}`:""]})]}),o.jsx("div",{className:"search-result-snippet search-result-snippet-expanded",children:e.content})]})]});default:return null}}function dq({source:e,className:t="search-result-icon"}){return e==="knowledge"?o.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[o.jsx("path",{d:"M5 5.5h10.5A3.5 3.5 0 0 1 19 9v9.5H8.5A3.5 3.5 0 0 1 5 15V5.5Z"}),o.jsx("path",{d:"M8.25 9h7.5M8.25 12.25h6"})]}):o.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[o.jsx("path",{d:"M12 4.5a7.5 7.5 0 1 0 7.5 7.5"}),o.jsx("path",{d:"M12 8a4 4 0 1 0 4 4M12 11.3a.7.7 0 1 0 0 1.4.7.7 0 0 0 0-1.4Z"})]})}function q6e({filled:e=!1,...t}){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:e?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[o.jsx("rect",{x:"3.5",y:"9.3",width:"4.5",height:"10.2",rx:"1.5"}),o.jsx("path",{d:"M8 10.2 11.3 4.8c.5-.8 1.7-.45 1.7.5v3.8h4.2a2.1 2.1 0 0 1 2.04 2.6l-1.4 5.75A2.1 2.1 0 0 1 15.8 19H8"})]})}function X6e({filled:e=!1,...t}){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:e?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[o.jsx("rect",{x:"3.5",y:"4.5",width:"4.5",height:"10.2",rx:"1.5"}),o.jsx("path",{d:"M8 13.8 11.3 19.2c.5.8 1.7.45 1.7-.5v-3.8h4.2a2.1 2.1 0 0 0 2.04-2.6l-1.4-5.75A2.1 2.1 0 0 0 15.8 5H8"})]})}function Vue(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M5.25 4.25h9.5a2.5 2.5 0 0 1 2.5 2.5v3.5"}),o.jsx("path",{d:"M13.25 17.75h-8a2.5 2.5 0 0 1-2.5-2.5v-8a3 3 0 0 1 3-3"}),o.jsx("path",{d:"M7 8.25h5.5M7 11.75h3.25"}),o.jsx("path",{d:"m13.35 16.65.42-2.16 4.76-4.76a1.35 1.35 0 0 1 1.91 1.91l-4.76 4.76-2.33.25Z"}),o.jsx("path",{d:"m17.65 10.6 1.9 1.9"})]})}const nj="/assets/media/logo-DCsNZy-k.svg",p7="data:image/svg+xml,%3csvg%20width='28'%20height='23'%20viewBox='0%200%2028%2023'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M17.1957%209.44218C17.0253%209.58161%2016.7774%209.47317%2016.7774%209.24079V8.01696V0.611967C16.7774%200.395085%2016.514%200.271152%2016.3591%200.410576L6.04172%209.16334C5.87132%209.30276%205.62345%209.19432%205.62345%208.96194V2.98218C5.62345%202.81178%205.48403%202.67235%205.31362%202.67235H0.309832C0.139424%202.67235%200%202.81178%200%202.98218V21.7115C0%2021.9284%200.263357%2022.0524%200.418273%2021.9129L10.7202%2013.1602C10.8906%2013.0207%2011.1385%2013.1292%2011.1385%2013.3616V22.0059C11.1385%2022.2228%2011.4018%2022.3467%2011.5567%2022.2073L21.8586%2013.4545C22.0291%2013.3151%2022.2769%2013.4235%2022.2769%2013.6559V19.6357C22.2769%2019.8061%2022.4163%2019.9455%2022.5868%2019.9455H27.5905C27.7609%2019.9455%2027.9004%2019.8061%2027.9004%2019.6357V0.890816C27.9004%200.673934%2027.637%200.550001%2027.4821%200.689425L17.1957%209.44218Z'%20fill='%230066FC'/%3e%3c/svg%3e",fq="(max-width: 860px)";function hq({title:e}){const t=p.useRef(null),[n,r]=p.useState({left:!1,right:!1}),i=()=>{const s=t.current;if(!s)return;const a={left:s.scrollLeft>1,right:s.scrollLeft+s.clientWidthl.left===a.left&&l.right===a.right?l:a)};return p.useLayoutEffect(()=>{const s=t.current;if(!s)return;i();const a=new ResizeObserver(i);return a.observe(s),s.firstElementChild&&a.observe(s.firstElementChild),()=>a.disconnect()},[e]),o.jsx("span",{ref:t,className:`history-title${n.left?" has-left-fade":""}${n.right?" has-right-fade":""}`,onScroll:i,onPointerEnter:i,children:o.jsx("span",{className:"history-title-text",children:e})})}function G6e(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"7",cy:"7",r:"2.25"}),o.jsx("circle",{cx:"17",cy:"7",r:"2.25"}),o.jsx("circle",{cx:"7",cy:"17",r:"2.25"}),o.jsx("circle",{cx:"17",cy:"17",r:"2.25"})]})}function W6e(e){let t=2166136261;for(const r of e)t^=r.charCodeAt(0),t=Math.imul(t,16777619);const n=t>>>0;return{"--avatar-hue-a":194+n%22,"--avatar-hue-b":214+(n>>>6)%25,"--avatar-hue-c":176+(n>>>12)%25,"--avatar-x":`${22+(n>>>18)%55}%`,"--avatar-y":`${18+(n>>>24)%58}%`}}const Y6e={admin:"管理员",developer:"开发者",user:"普通用户"};function Z6e({activePage:e,access:t,userInfo:n,onAgentKitCli:r,onDeveloperResources:i,onSystemInfo:s,onIssueFeedback:a,onLogout:l}){const[c,u]=p.useState(!1),[d,f]=p.useState("");if(!n)return null;const h=vIe(n)||"用户",m=typeof n.email=="string"?n.email.trim():"",g=W6e(h),b=wIe(n),y=b===d?"":b;return o.jsxs("div",{className:"sidebar-user",children:[o.jsxs("div",{className:"sidebar-user-row",children:[o.jsxs("button",{type:"button",className:"sidebar-user-btn",onClick:()=>u(O=>!O),title:h,children:[o.jsx("span",{className:`account-avatar${y?" has-image":""}`,style:g,"aria-hidden":"true",children:y?o.jsx("img",{className:"account-avatar-image",src:y,alt:"","aria-hidden":"true",referrerPolicy:"no-referrer",onError:()=>f(y)}):null}),o.jsx("span",{className:"sidebar-user-identity",children:o.jsx("span",{className:"sidebar-user-name",children:h})})]}),o.jsxs("div",{className:"sidebar-user-shortcuts","aria-label":"快捷入口",children:[o.jsx(vo,{compact:!0,content:"体验 AgentKit CLI",children:o.jsx("button",{type:"button",className:"sidebar-user-shortcut",onClick:r,"aria-label":"体验 AgentKit CLI",children:o.jsx(bRe,{className:"icon"})})}),o.jsx(vo,{compact:!0,content:"开发者资源",children:o.jsx("button",{type:"button",className:`sidebar-user-shortcut${e==="developer-resources"?" is-active":""}`,onClick:i,"aria-label":"开发者资源","aria-current":e==="developer-resources"?"page":void 0,children:o.jsx(sRe,{className:"icon"})})})]})]}),c&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-scrim",onClick:()=>u(!1)}),o.jsxs("div",{className:"account-pop sidebar-user-pop",children:[o.jsxs("div",{className:"account-head",children:[o.jsx("span",{className:`account-avatar account-avatar--lg${y?" has-image":""}`,style:g,"aria-hidden":"true",children:y?o.jsx("img",{className:"account-avatar-image",src:y,alt:"","aria-hidden":"true",referrerPolicy:"no-referrer",onError:()=>f(y)}):null}),o.jsxs("div",{className:"account-id",children:[o.jsxs("div",{className:"account-name-row",children:[o.jsx("div",{className:"account-name",children:h}),o.jsx(ta,{color:"secondary",size:"sm",variant:"soft",pill:!0,children:Y6e[t.role]})]}),m&&m!==h&&o.jsx("div",{className:"account-sub",children:m})]})]}),o.jsxs("button",{type:"button",className:"account-action",onClick:()=>{u(!1),s()},children:[o.jsx(wd,{className:"icon"})," 系统信息"]}),o.jsxs("button",{type:"button",className:"account-action",onClick:()=>{u(!1),a()},children:[o.jsx(Vue,{className:"icon"})," 问题反馈"]}),o.jsxs("button",{type:"button",className:"account-action",onClick:()=>{u(!1),l()},children:[o.jsx(JRe,{className:"icon"})," 退出登录"]})]})]})]})}function K6e({branding:e,cloudProvider:t,sessions:n,currentSessionId:r,activePage:i,features:s,access:a,streamingSids:l,evaluatingSids:c,sandboxHistory:u,onNewChat:d,onSearch:f,onQuickCreate:h,onLibrary:m,onAddAgent:g,onMyAgents:b,onWorkspace:y,onApplications:O,onCronJobs:v,onAgentKitCli:x,onDeveloperResources:w,onSystemInfo:S,onIssueFeedback:E,onPickSession:k,onDeleteSession:_,userInfo:C,onLogout:T}){const A=$=>(s==null?void 0:s[$])!==!1,[j,L]=p.useState(null),I=p.useRef(typeof window<"u"&&window.matchMedia(fq).matches),[M,N]=p.useState(I.current),D=n.map($=>({id:$.id,title:QN($.events),createdAt:($.lastUpdateTime??0)*1e3})).sort(($,H)=>H.createdAt-$.createdAt),Q=()=>{I.current=!1,N($=>!$),L(null)};p.useEffect(()=>{const $=window.matchMedia(fq),H=z=>{z.matches?N(B=>B||(I.current=!0,!0)):I.current&&(I.current=!1,N(!1))};return $.addEventListener("change",H),()=>$.removeEventListener("change",H)},[]);const F=t==="byteplus"?p7:nj;return o.jsxs("aside",{className:`sidebar ${M?"is-collapsed":""}`,children:[o.jsxs("div",{className:"sidebar-top",children:[o.jsxs("div",{className:"sidebar-brand-row",children:[o.jsxs("button",{type:"button",className:"brand",onClick:d,"aria-label":"返回首页",title:"返回首页",children:[o.jsx("img",{className:"brand-logo",src:e.logoUrl||F,width:20,height:20,alt:"","aria-hidden":!0}),o.jsx("span",{className:"brand-title",children:e.title})]}),o.jsx("button",{type:"button",className:"sidebar-collapse-toggle",onClick:Q,"aria-label":M?"展开侧边栏":"收起侧边栏",title:M?"展开侧边栏":"收起侧边栏",children:M?o.jsx(M6e,{className:"icon"}):o.jsx(P6e,{className:"icon"})})]}),o.jsxs("nav",{className:"sidebar-nav","aria-label":"主导航",children:[A("newChat")&&o.jsxs("button",{className:`new-chat new-chat--conversation${i==="new-chat"?" is-active":""}`,onClick:d,"aria-label":"新会话","aria-current":i==="new-chat"?"page":void 0,title:"新会话",children:[o.jsx(L6e,{className:"icon"}),o.jsx("span",{className:"sidebar-nav-label",children:"新会话"})]}),A("search")&&o.jsx(F6e,{active:i==="search",onClick:f}),o.jsxs("button",{className:`new-chat new-chat--agents${i==="agents"?" is-active":""}`,onClick:b,"aria-label":"智能体","aria-current":i==="agents"?"page":void 0,title:"智能体",children:[o.jsx(B6e,{className:"icon"}),o.jsx("span",{className:"sidebar-nav-label",children:"智能体"})]}),o.jsxs("button",{className:`new-chat new-chat--workspaces${i==="workspaces"?" is-active":""}`,onClick:y,"aria-label":"工作区","aria-current":i==="workspaces"?"page":void 0,title:"工作区",children:[o.jsx(IRe,{className:"icon"}),o.jsx("span",{className:"sidebar-nav-label",children:"工作区"})]}),o.jsxs("button",{className:`new-chat new-chat--library${i==="library"?" is-active":""}`,onClick:m,"aria-label":"资源库","aria-current":i==="library"?"page":void 0,title:"资源库",children:[o.jsx(zue,{className:"icon"}),o.jsx("span",{className:"sidebar-nav-label",children:"资源库"})]}),o.jsxs("button",{className:`new-chat new-chat--cronjobs${i==="cronjobs"?" is-active":""}`,onClick:v,"aria-label":"定时任务","aria-current":i==="cronjobs"?"page":void 0,title:"定时任务",children:[o.jsx(K8,{className:"icon"}),o.jsx("span",{className:"sidebar-nav-label",children:"定时任务"})]}),o.jsxs("button",{className:`new-chat new-chat--applications${i==="applications"?" is-active":""}`,onClick:O,"aria-label":"自动化","aria-current":i==="applications"?"page":void 0,title:"自动化",children:[o.jsx(G6e,{className:"icon"}),o.jsx("span",{className:"sidebar-nav-label",children:"自动化"})]})]})]}),A("history")&&o.jsxs("div",{className:"sidebar-history",children:[o.jsxs("div",{className:"history-head",children:[o.jsx("span",{children:"历史会话"}),A("newChat")&&o.jsx("button",{type:"button",className:"history-new-chat",onClick:(u==null?void 0:u.onNew)??d,disabled:u==null?void 0:u.newDisabled,"aria-label":"新建会话",title:"新建会话",children:o.jsx(yo,{className:"icon"})})]}),o.jsx("div",{className:"history-list",children:u?o.jsxs(o.Fragment,{children:[u.loading&&u.threads.length===0?o.jsx("div",{className:"history-empty",role:"status",children:"正在加载历史会话…"}):null,u.error?o.jsx("div",{className:"history-error",role:"alert",children:u.error}):null,!u.loading&&!u.error&&u.threads.length===0?o.jsx("div",{className:"history-empty",children:"暂无会话"}):null,u.threads.map($=>{const H=$.id===u.currentThreadId,z=$.name||$.preview||`Thread ${$.id.slice(0,8)}`,B=$.id===u.busyThreadId;return o.jsxs("div",{className:`history-item ${H?"active":""}`,children:[o.jsxs("button",{type:"button",className:"history-item-btn",onClick:()=>u.onSelect($.id),"aria-current":H?"page":void 0,title:z,disabled:B,children:[o.jsx(hq,{title:z}),H?o.jsx("span",{className:"history-current-badge",children:"当前"}):null]}),o.jsx("button",{type:"button",className:"history-more","aria-label":`管理历史会话:${z}`,title:"更多",disabled:B,onClick:()=>L(V=>V===$.id?null:$.id),children:o.jsx(yH,{className:"icon"})}),j===$.id?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-scrim",onClick:()=>L(null)}),o.jsx("div",{className:"history-menu",children:o.jsxs("button",{type:"button",className:"menu-item menu-item--danger",onClick:()=>{L(null),u.onDelete($)},children:[o.jsx(Up,{className:"icon"})," 删除"]})})]}):null]},$.id)}),u.hasMore?o.jsx("button",{type:"button",className:"history-load-more",disabled:u.loading,onClick:u.onLoadMore,children:u.loading?"加载中…":"加载更多"}):null]}):o.jsxs(o.Fragment,{children:[D.length===0?o.jsx("div",{className:"history-empty",children:"暂无会话"}):null,D.map($=>{const H=$.id===r,z=(l==null?void 0:l.has($.id))===!0,B=!z&&(c==null?void 0:c.has($.id))===!0;return o.jsxs("div",{className:`history-item ${H?"active":""}`,children:[o.jsxs("button",{className:"history-item-btn",onClick:()=>k($.id),"aria-current":H?"page":void 0,title:$.title,children:[o.jsx(hq,{title:$.title}),B&&o.jsxs("span",{className:"history-evaluating-status",title:"正在自动评测",children:[o.jsx("span",{className:"history-evaluating","aria-hidden":"true"}),"评测中"]})]}),o.jsxs("div",{className:"history-action-slot",children:[z?o.jsx(WS,{className:"history-streaming-indicator",size:12,role:"status","aria-label":"正在生成"}):null,o.jsx("button",{type:"button",className:"history-more","aria-label":`管理历史会话:${$.title}`,title:"更多",onClick:()=>L(V=>V===$.id?null:$.id),children:o.jsx(yH,{className:"icon"})})]}),j===$.id&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-scrim",onClick:()=>L(null)}),o.jsx("div",{className:"history-menu",children:o.jsxs("button",{type:"button",className:"menu-item menu-item--danger",onClick:()=>{L(null),_($.id)},children:[o.jsx(Up,{className:"icon"})," 删除"]})})]})]},$.id)})]})})]}),o.jsx("div",{className:"sidebar-footer",children:o.jsx(Z6e,{activePage:i,access:a,userInfo:C,onAgentKitCli:x,onDeveloperResources:w,onSystemInfo:S,onIssueFeedback:E,onLogout:T})})]})}function qs(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n{}};function rj(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Y_.prototype=rj.prototype={constructor:Y_,on:function(e,t){var n=this._,r=e$e(e+"",n),i,s=-1,a=r.length;if(arguments.length<2){for(;++s0)for(var n=new Array(i),r=0,i,s;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),mq.hasOwnProperty(t)?{space:mq[t],local:e}:e}function n$e(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===v4&&t.documentElement.namespaceURI===v4?t.createElement(e):t.createElementNS(n,e)}}function r$e(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Hue(e){var t=ij(e);return(t.local?r$e:n$e)(t)}function i$e(){}function m7(e){return e==null?i$e:function(){return this.querySelector(e)}}function s$e(e){typeof e!="function"&&(e=m7(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=x&&(x=v+1);!(S=y[x])&&++x=0;)(a=r[i])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function N$e(e){e||(e=j$e);function t(f,h){return f&&h?e(f.__data__,h.__data__):!f-!h}for(var n=this._groups,r=n.length,i=new Array(r),s=0;st?1:e>=t?0:NaN}function R$e(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function I$e(){return Array.from(this)}function D$e(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?H$e:typeof t=="function"?X$e:q$e)(e,t,n??"")):n1(this.node(),e)}function n1(e,t){return e.style.getPropertyValue(t)||Yue(e).getComputedStyle(e,null).getPropertyValue(t)}function W$e(e){return function(){delete this[e]}}function Y$e(e,t){return function(){this[e]=t}}function Z$e(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function K$e(e,t){return arguments.length>1?this.each((t==null?W$e:typeof t=="function"?Z$e:Y$e)(e,t)):this.node()[e]}function Zue(e){return e.trim().split(/^|\s+/)}function g7(e){return e.classList||new Kue(e)}function Kue(e){this._node=e,this._names=Zue(e.getAttribute("class")||"")}Kue.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 Jue(e,t){for(var n=g7(e),r=-1,i=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function _8e(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,s;n()=>e;function w4(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:s,x:a,y:l,dx:c,dy:u,dispatch:d}){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:i,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}w4.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function M8e(e){return!e.ctrlKey&&!e.button}function L8e(){return this.parentNode}function $8e(e,t){return t??{x:e.x,y:e.y}}function B8e(){return navigator.maxTouchPoints||"ontouchstart"in this}function sde(){var e=M8e,t=L8e,n=$8e,r=B8e,i={},s=rj("start","drag","end"),a=0,l,c,u,d,f=0;function h(w){w.on("mousedown.drag",m).filter(r).on("touchstart.drag",y).on("touchmove.drag",O,P8e).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(w,S){if(!(d||!e.call(this,w,S))){var E=x(this,t.call(this,w,S),w,S,"mouse");E&&(Tl(w.view).on("mousemove.drag",g,Aw).on("mouseup.drag",b,Aw),rde(w.view),A5(w),u=!1,l=w.clientX,c=w.clientY,E("start",w))}}function g(w){if(my(w),!u){var S=w.clientX-l,E=w.clientY-c;u=S*S+E*E>f}i.mouse("drag",w)}function b(w){Tl(w.view).on("mousemove.drag mouseup.drag",null),ide(w.view,u),my(w),i.mouse("end",w)}function y(w,S){if(e.call(this,w,S)){var E=w.changedTouches,k=t.call(this,w,S),_=E.length,C,T;for(C=0;C<_;++C)(T=x(this,k,w,S,E[C].identifier,E[C]))&&(A5(w),T("start",w,E[C]))}}function O(w){var S=w.changedTouches,E=S.length,k,_;for(k=0;k>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?r2(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?r2(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=U8e.exec(e))?new Ho(t[1],t[2],t[3],1):(t=F8e.exec(e))?new Ho(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=z8e.exec(e))?r2(t[1],t[2],t[3],t[4]):(t=V8e.exec(e))?r2(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=H8e.exec(e))?wq(t[1],t[2]/100,t[3]/100,1):(t=q8e.exec(e))?wq(t[1],t[2]/100,t[3]/100,t[4]):gq.hasOwnProperty(e)?Oq(gq[e]):e==="transparent"?new Ho(NaN,NaN,NaN,0):null}function Oq(e){return new Ho(e>>16&255,e>>8&255,e&255,1)}function r2(e,t,n,r){return r<=0&&(e=t=n=NaN),new Ho(e,t,n,r)}function W8e(e){return e instanceof rE||(e=$g(e)),e?(e=e.rgb(),new Ho(e.r,e.g,e.b,e.opacity)):new Ho}function S4(e,t,n,r){return arguments.length===1?W8e(e):new Ho(e,t,n,r??1)}function Ho(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}b7(Ho,S4,ade(rE,{brighter(e){return e=e==null?AC:Math.pow(AC,e),new Ho(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Nw:Math.pow(Nw,e),new Ho(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ho(vg(this.r),vg(this.g),vg(this.b),NC(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:xq,formatHex:xq,formatHex8:Y8e,formatRgb:vq,toString:vq}));function xq(){return`#${ig(this.r)}${ig(this.g)}${ig(this.b)}`}function Y8e(){return`#${ig(this.r)}${ig(this.g)}${ig(this.b)}${ig((isNaN(this.opacity)?1:this.opacity)*255)}`}function vq(){const e=NC(this.opacity);return`${e===1?"rgb(":"rgba("}${vg(this.r)}, ${vg(this.g)}, ${vg(this.b)}${e===1?")":`, ${e})`}`}function NC(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function vg(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ig(e){return e=vg(e),(e<16?"0":"")+e.toString(16)}function wq(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ou(e,t,n,r)}function ode(e){if(e instanceof ou)return new ou(e.h,e.s,e.l,e.opacity);if(e instanceof rE||(e=$g(e)),!e)return new ou;if(e instanceof ou)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),a=NaN,l=s-i,c=(s+i)/2;return l?(t===s?a=(n-r)/l+(n0&&c<1?0:a,new ou(a,l,c,e.opacity)}function Z8e(e,t,n,r){return arguments.length===1?ode(e):new ou(e,t,n,r??1)}function ou(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}b7(ou,Z8e,ade(rE,{brighter(e){return e=e==null?AC:Math.pow(AC,e),new ou(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Nw:Math.pow(Nw,e),new ou(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,i=2*n-r;return new Ho(N5(e>=240?e-240:e+120,i,r),N5(e,i,r),N5(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new ou(Sq(this.h),i2(this.s),i2(this.l),NC(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=NC(this.opacity);return`${e===1?"hsl(":"hsla("}${Sq(this.h)}, ${i2(this.s)*100}%, ${i2(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Sq(e){return e=(e||0)%360,e<0?e+360:e}function i2(e){return Math.max(0,Math.min(1,e||0))}function N5(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 sj=e=>()=>e;function lde(e,t){return function(n){return e+n*t}}function K8e(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 pMt(e,t){var n=t-e;return n?lde(e,n>180||n<-180?n-360*Math.round(n/360):n):sj(isNaN(e)?t:e)}function J8e(e){return(e=+e)==1?cde:function(t,n){return n-t?K8e(t,n,e):sj(isNaN(t)?n:t)}}function cde(e,t){var n=t-e;return n?lde(e,n):sj(isNaN(e)?t:e)}const jC=function e(t){var n=J8e(t);function r(i,s){var a=n((i=S4(i)).r,(s=S4(s)).r),l=n(i.g,s.g),c=n(i.b,s.b),u=cde(i.opacity,s.opacity);return function(d){return i.r=a(d),i.g=l(d),i.b=c(d),i.opacity=u(d),i+""}}return r.gamma=e,r}(1);function e9e(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(s){for(i=0;in&&(s=t.slice(n,s),l[a]?l[a]+=s:l[++a]=s),(r=r[0])===(i=i[0])?l[a]?l[a]+=i:l[++a]=i:(l[++a]=null,c.push({i:a,x:Hu(r,i)})),n=j5.lastIndex;return n180?d+=360:d-u>180&&(u+=360),h.push({i:f.push(i(f)+"rotate(",null,r)-2,x:Hu(u,d)})):d&&f.push(i(f)+"rotate("+d+r)}function l(u,d,f,h){u!==d?h.push({i:f.push(i(f)+"skewX(",null,r)-2,x:Hu(u,d)}):d&&f.push(i(f)+"skewX("+d+r)}function c(u,d,f,h,m,g){if(u!==f||d!==h){var b=m.push(i(m)+"scale(",null,",",null,")");g.push({i:b-4,x:Hu(u,f)},{i:b-2,x:Hu(d,h)})}else(f!==1||h!==1)&&m.push(i(m)+"scale("+f+","+h+")")}return function(u,d){var f=[],h=[];return u=e(u),d=e(d),s(u.translateX,u.translateY,d.translateX,d.translateY,f,h),a(u.rotate,d.rotate,f,h),l(u.skewX,d.skewX,f,h),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,h),u=d=null,function(m){for(var g=-1,b=h.length,y;++g=0&&e._call.call(void 0,t),e=e._next;--r1}function _q(){Bg=(IC=Rw.now())+aj,r1=Fx=0;try{m9e()}finally{r1=0,b9e(),Bg=0}}function g9e(){var e=Rw.now(),t=e-IC;t>hde&&(aj-=t,IC=e)}function b9e(){for(var e,t=RC,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:RC=n);zx=e,_4(r)}function _4(e){if(!r1){Fx&&(Fx=clearTimeout(Fx));var t=e-Bg;t>24?(e<1/0&&(Fx=setTimeout(_q,e-Rw.now()-aj)),tx&&(tx=clearInterval(tx))):(tx||(IC=Rw.now(),tx=setInterval(g9e,hde)),r1=1,pde(_q))}}function Tq(e,t,n){var r=new DC;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var y9e=rj("start","end","cancel","interrupt"),O9e=[],gde=0,Cq=1,T4=2,K_=3,Aq=4,C4=5,J_=6;function oj(e,t,n,r,i,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;x9e(e,n,{name:t,index:r,group:i,on:y9e,tween:O9e,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:gde})}function O7(e,t){var n=_u(e,t);if(n.state>gde)throw new Error("too late; already scheduled");return n}function _d(e,t){var n=_u(e,t);if(n.state>K_)throw new Error("too late; already running");return n}function _u(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function x9e(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=mde(s,0,n.time);function s(u){n.state=Cq,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,f,h,m;if(n.state!==Cq)return c();for(d in r)if(m=r[d],m.name===n.name){if(m.state===K_)return Tq(a);m.state===Aq?(m.state=J_,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[d]):+dT4&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function Y9e(e,t,n){var r,i,s=W9e(t)?O7:_d;return function(){var a=s(this,e),l=a.on;l!==r&&(i=(r=l).copy()).on(t,n),a.on=i}}function Z9e(e,t){var n=this._id;return arguments.length<2?_u(this.node(),n).on.on(e):this.each(Y9e(n,e,t))}function K9e(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function J9e(){return this.on("end.remove",K9e(this._id))}function e7e(e){var t=this._name,n=this._id;typeof e!="function"&&(e=m7(e));for(var r=this._groups,i=r.length,s=new Array(i),a=0;a()=>e;function k7e(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){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:i}})}function _f(e,t,n){this.k=e,this.x=t,this.y=n}_f.prototype={constructor:_f,scale:function(e){return e===1?this:new _f(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new _f(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 lj=new _f(1,0,0);xde.prototype=_f.prototype;function xde(e){for(;!e.__zoom;)if(!(e=e.parentNode))return lj;return e.__zoom}function R5(e){e.stopImmediatePropagation()}function nx(e){e.preventDefault(),e.stopImmediatePropagation()}function _7e(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function T7e(){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 Nq(){return this.__zoom||lj}function C7e(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function A7e(){return navigator.maxTouchPoints||"ontouchstart"in this}function N7e(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function vde(){var e=_7e,t=T7e,n=N7e,r=C7e,i=A7e,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=Z_,u=rj("start","zoom","end"),d,f,h,m=500,g=150,b=0,y=10;function O(I){I.property("__zoom",Nq).on("wheel.zoom",_,{passive:!1}).on("mousedown.zoom",C).on("dblclick.zoom",T).filter(i).on("touchstart.zoom",A).on("touchmove.zoom",j).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}O.transform=function(I,M,N,D){var Q=I.selection?I.selection():I;Q.property("__zoom",Nq),I!==Q?S(I,M,N,D):Q.interrupt().each(function(){E(this,arguments).event(D).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},O.scaleBy=function(I,M,N,D){O.scaleTo(I,function(){var Q=this.__zoom.k,F=typeof M=="function"?M.apply(this,arguments):M;return Q*F},N,D)},O.scaleTo=function(I,M,N,D){O.transform(I,function(){var Q=t.apply(this,arguments),F=this.__zoom,$=N==null?w(Q):typeof N=="function"?N.apply(this,arguments):N,H=F.invert($),z=typeof M=="function"?M.apply(this,arguments):M;return n(x(v(F,z),$,H),Q,a)},N,D)},O.translateBy=function(I,M,N,D){O.transform(I,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof N=="function"?N.apply(this,arguments):N),t.apply(this,arguments),a)},null,D)},O.translateTo=function(I,M,N,D,Q){O.transform(I,function(){var F=t.apply(this,arguments),$=this.__zoom,H=D==null?w(F):typeof D=="function"?D.apply(this,arguments):D;return n(lj.translate(H[0],H[1]).scale($.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof N=="function"?-N.apply(this,arguments):-N),F,a)},D,Q)};function v(I,M){return M=Math.max(s[0],Math.min(s[1],M)),M===I.k?I:new _f(M,I.x,I.y)}function x(I,M,N){var D=M[0]-N[0]*I.k,Q=M[1]-N[1]*I.k;return D===I.x&&Q===I.y?I:new _f(I.k,D,Q)}function w(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function S(I,M,N,D){I.on("start.zoom",function(){E(this,arguments).event(D).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(D).end()}).tween("zoom",function(){var Q=this,F=arguments,$=E(Q,F).event(D),H=t.apply(Q,F),z=N==null?w(H):typeof N=="function"?N.apply(Q,F):N,B=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),V=Q.__zoom,Z=typeof M=="function"?M.apply(Q,F):M,ce=c(V.invert(z).concat(B/V.k),Z.invert(z).concat(B/Z.k));return function(be){if(be===1)be=Z;else{var ie=ce(be),q=B/ie[2];be=new _f(q,z[0]-ie[0]*q,z[1]-ie[1]*q)}$.zoom(null,be)}})}function E(I,M,N){return!N&&I.__zooming||new k(I,M)}function k(I,M){this.that=I,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(I,M),this.taps=0}k.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,M){return this.mouse&&I!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var M=Tl(this.that).datum();u.call(I,this.that,new k7e(I,{sourceEvent:this.sourceEvent,target:O,transform:this.that.__zoom,dispatch:u}),M)}};function _(I,...M){if(!e.apply(this,arguments))return;var N=E(this,M).event(I),D=this.__zoom,Q=Math.max(s[0],Math.min(s[1],D.k*Math.pow(2,r.apply(this,arguments)))),F=iu(I);if(N.wheel)(N.mouse[0][0]!==F[0]||N.mouse[0][1]!==F[1])&&(N.mouse[1]=D.invert(N.mouse[0]=F)),clearTimeout(N.wheel);else{if(D.k===Q)return;N.mouse=[F,D.invert(F)],eT(this),N.start()}nx(I),N.wheel=setTimeout($,g),N.zoom("mouse",n(x(v(D,Q),N.mouse[0],N.mouse[1]),N.extent,a));function $(){N.wheel=null,N.end()}}function C(I,...M){if(h||!e.apply(this,arguments))return;var N=I.currentTarget,D=E(this,M,!0).event(I),Q=Tl(I.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",B,!0),F=iu(I,N),$=I.clientX,H=I.clientY;rde(I.view),R5(I),D.mouse=[F,this.__zoom.invert(F)],eT(this),D.start();function z(V){if(nx(V),!D.moved){var Z=V.clientX-$,ce=V.clientY-H;D.moved=Z*Z+ce*ce>b}D.event(V).zoom("mouse",n(x(D.that.__zoom,D.mouse[0]=iu(V,N),D.mouse[1]),D.extent,a))}function B(V){Q.on("mousemove.zoom mouseup.zoom",null),ide(V.view,D.moved),nx(V),D.event(V).end()}}function T(I,...M){if(e.apply(this,arguments)){var N=this.__zoom,D=iu(I.changedTouches?I.changedTouches[0]:I,this),Q=N.invert(D),F=N.k*(I.shiftKey?.5:2),$=n(x(v(N,F),D,Q),t.apply(this,M),a);nx(I),l>0?Tl(this).transition().duration(l).call(S,$,D,I):Tl(this).call(O.transform,$,D,I)}}function A(I,...M){if(e.apply(this,arguments)){var N=I.touches,D=N.length,Q=E(this,M,I.changedTouches.length===D).event(I),F,$,H,z;for(R5(I),$=0;$`Seems like you have not used zustand provider 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.`},Iw=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],wde=["Enter"," ","Escape"],Sde={"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 i1;(function(e){e.Strict="strict",e.Loose="loose"})(i1||(i1={}));var wg;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(wg||(wg={}));var Dw;(function(e){e.Partial="partial",e.Full="full"})(Dw||(Dw={}));const Ede={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var ip;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ip||(ip={}));var Pw;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Pw||(Pw={}));var zt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(zt||(zt={}));const jq={[zt.Left]:zt.Right,[zt.Right]:zt.Left,[zt.Top]:zt.Bottom,[zt.Bottom]:zt.Top};function kde(e){return e===null?null:e?"valid":"invalid"}const _de=e=>"id"in e&&"source"in e&&"target"in e,j7e=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),v7=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),iE=(e,t=[0,0])=>{const{width:n,height:r}=gh(e),i=e.origin??t,s=n*i[0],a=r*i[1];return{x:e.position.x-s,y:e.position.y-a}},R7e=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,i)=>{const s=typeof i=="string";let a=!t.nodeLookup&&!s?i:void 0;t.nodeLookup&&(a=s?t.nodeLookup.get(i):v7(i)?i:t.nodeLookup.get(i.id));const l=a?PC(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return cj(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return uj(n)},sE=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(i=>{(t.filter===void 0||t.filter(i))&&(n=cj(n,PC(i)),r=!0)}),r?uj(n):{x:0,y:0,width:0,height:0}},w7=(e,t,[n,r,i]=[0,0,1],s=!1,a=!1)=>{const l={...J1(t,[n,r,i]),width:t.width/i,height:t.height/i},c=[];for(const u of e.values()){const{measured:d,selectable:f=!0,hidden:h=!1}=u;if(a&&!f||h)continue;const m=d.width??u.width??u.initialWidth??null,g=d.height??u.height??u.initialHeight??null,b=Mw(l,a1(u)),y=(m??0)*(g??0),O=s&&b>0;(!u.internals.handleBounds||O||b>=y||u.dragging)&&c.push(u)}return c},I7e=(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 D7e(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(i=>i.id)):null;return e.forEach(i=>{i.measured.width&&i.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!i.hidden)&&(!r||r.has(i.id))&&n.set(i.id,i)}),n}async function P7e({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:s},a){if(e.size===0)return!0;const l=D7e(e,a),c=sE(l),u=E7(c,t,n,(a==null?void 0:a.minZoom)??i,(a==null?void 0:a.maxZoom)??s,(a==null?void 0:a.padding)??.1);return await r.setViewport(u,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),!0}function Tde({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:s}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:c,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},d=a.origin??r;let f=a.extent||i;if(a.extent==="parent"&&!a.expandParent)if(!l)s==null||s("005",Ou.error005());else{const m=l.measured.width,g=l.measured.height;m&&g&&(f=[[c,u],[c+m,u+g]])}else l&&Ug(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const h=Ug(f)?Qg(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(s==null||s("015",Ou.error015())),{position:{x:h.x-c+(a.measured.width??0)*d[0],y:h.y-u+(a.measured.height??0)*d[1]},positionAbsolute:h}}async function M7e({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){const s=new Set(e.map(h=>h.id)),a=[];for(const h of n){if(h.deletable===!1)continue;const m=s.has(h.id),g=!m&&h.parentId&&a.find(b=>b.id===h.parentId);(m||g)&&a.push(h)}const l=new Set(t.map(h=>h.id)),c=r.filter(h=>h.deletable!==!1),d=I7e(a,c);for(const h of c)l.has(h.id)&&!d.find(g=>g.id===h.id)&&d.push(h);if(!i)return{edges:d,nodes:a};const f=await i({nodes:a,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:a}:{edges:[],nodes:[]}:f}const s1=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Qg=(e={x:0,y:0},t,n)=>({x:s1(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:s1(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Cde(e,t,n){const{width:r,height:i}=gh(n),{x:s,y:a}=n.internals.positionAbsolute;return Qg(e,[[s,a],[s+r,a+i]],t)}const Rq=(e,t,n)=>en?-s1(Math.abs(e-n),1,t)/t:0,S7=(e,t,n=15,r=40)=>{const i=Rq(e.x,r,t.width-r)*n,s=Rq(e.y,r,t.height-r)*n;return[i,s]},cj=(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)}),A4=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),uj=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),a1=(e,t=[0,0])=>{var i,s;const{x:n,y:r}=v7(e)?e.internals.positionAbsolute:iE(e,t);return{x:n,y:r,width:((i=e.measured)==null?void 0:i.width)??e.width??e.initialWidth??0,height:((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0}},PC=(e,t=[0,0])=>{var i,s;const{x:n,y:r}=v7(e)?e.internals.positionAbsolute:iE(e,t);return{x:n,y:r,x2:n+(((i=e.measured)==null?void 0:i.width)??e.width??e.initialWidth??0),y2:r+(((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0)}},Ade=(e,t)=>uj(cj(A4(e),A4(t))),Mw=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},Iq=e=>cu(e.width)&&cu(e.height)&&cu(e.x)&&cu(e.y),cu=e=>!isNaN(e)&&isFinite(e),Nde=(e,t)=>(n,r)=>{},aE=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),J1=({x:e,y:t},[n,r,i],s=!1,a=[1,1])=>{const l={x:(e-n)/i,y:(t-r)/i};return s?aE(l,a):l},o1=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function G0(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 L7e(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=G0(e,n),i=G0(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e=="object"){const r=G0(e.top??e.y??0,n),i=G0(e.bottom??e.y??0,n),s=G0(e.left??e.x??0,t),a=G0(e.right??e.x??0,t);return{top:r,right:a,bottom:i,left:s,x:s+a,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function $7e(e,t,n,r,i,s){const{x:a,y:l}=o1(e,[t,n,r]),{x:c,y:u}=o1({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=i-c,f=s-u;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(d),bottom:Math.floor(f)}}const E7=(e,t,n,r,i,s)=>{const a=L7e(s,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),d=s1(u,r,i),f=e.x+e.width/2,h=e.y+e.height/2,m=t/2-f*d,g=n/2-h*d,b=$7e(e,m,g,d,t,n),y={left:Math.min(b.left-a.left,0),top:Math.min(b.top-a.top,0),right:Math.min(b.right-a.right,0),bottom:Math.min(b.bottom-a.bottom,0)};return{x:m-y.left+y.right,y:g-y.top+y.bottom,zoom:d}},Lw=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ug(e){return e!=null&&e!=="parent"}function gh(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 k7(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 jde(e,t={width:0,height:0},n,r,i){const s={...e},a=r.get(n);if(a){const l=a.origin||i;s.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],s.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return s}function Dq(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function B7e(){let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}}function Q7e(e){return{...Sde,...e||{}}}function Tv(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){const{x:s,y:a}=uu(e),l=J1({x:s-((i==null?void 0:i.left)??0),y:a-((i==null?void 0:i.top)??0)},r),{x:c,y:u}=n?aE(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const _7=e=>({width:e.offsetWidth,height:e.offsetHeight}),Rde=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},U7e=["INPUT","SELECT","TEXTAREA"];function Ide(e){var r,i;const t=((i=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:i[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:U7e.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Dde=e=>"clientX"in e,uu=(e,t)=>{var s,a;const n=Dde(e),r=n?e.clientX:(s=e.touches)==null?void 0:s[0].clientX,i=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:i-((t==null?void 0:t.top)??0)}},Pq=(e,t,n,r,i)=>{const s=t.querySelectorAll(`.${e}`);return!s||!s.length?null:Array.from(s).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:i,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,..._7(a)}})};function Pde({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:s,targetControlX:a,targetControlY:l}){const c=e*.125+i*.375+a*.375+n*.125,u=t*.125+s*.375+l*.375+r*.125,d=Math.abs(c-e),f=Math.abs(u-t);return[c,u,d,f]}function o2(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Mq({pos:e,x1:t,y1:n,x2:r,y2:i,c:s}){switch(e){case zt.Left:return[t-o2(t-r,s),n];case zt.Right:return[t+o2(r-t,s),n];case zt.Top:return[t,n-o2(n-i,s)];case zt.Bottom:return[t,n+o2(i-n,s)]}}function Mde({sourceX:e,sourceY:t,sourcePosition:n=zt.Bottom,targetX:r,targetY:i,targetPosition:s=zt.Top,curvature:a=.25}){const[l,c]=Mq({pos:n,x1:e,y1:t,x2:r,y2:i,c:a}),[u,d]=Mq({pos:s,x1:r,y1:i,x2:e,y2:t,c:a}),[f,h,m,g]=Pde({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${l},${c} ${u},${d} ${r},${i}`,f,h,m,g]}function Lde({sourceX:e,sourceY:t,targetX:n,targetY:r}){const i=Math.abs(n-e)/2,s=n0}const V7e=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,H7e=(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)),q7e=(e,t,n={})=>{var s;if(!e.source||!e.target)return(s=n.onError)==null||s.call(n,"006",Ou.error006()),t;const r=n.getEdgeId||V7e;let i;return _de(e)?i={...e}:i={...e,id:r(e)},H7e(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function $de({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[i,s,a,l]=Lde({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,s,a,l]}const Lq={[zt.Left]:{x:-1,y:0},[zt.Right]:{x:1,y:0},[zt.Top]:{x:0,y:-1},[zt.Bottom]:{x:0,y:1}},X7e=({source:e,sourcePosition:t=zt.Bottom,target:n})=>t===zt.Left||t===zt.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function G7e({source:e,sourcePosition:t=zt.Bottom,target:n,targetPosition:r=zt.Top,center:i,offset:s,stepPosition:a}){const l=Lq[t],c=Lq[r],u={x:e.x+l.x*s,y:e.y+l.y*s},d={x:n.x+c.x*s,y:n.y+c.y*s},f=X7e({source:u,sourcePosition:t,target:d}),h=f.x!==0?"x":"y",m=f[h];let g=[],b,y;const O={x:0,y:0},v={x:0,y:0},[,,x,w]=Lde({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[h]*c[h]===-1){h==="x"?(b=i.x??u.x+(d.x-u.x)*a,y=i.y??(u.y+d.y)/2):(b=i.x??(u.x+d.x)/2,y=i.y??u.y+(d.y-u.y)*a);const _=[{x:b,y:u.y},{x:b,y:d.y}],C=[{x:u.x,y},{x:d.x,y}];l[h]===m?g=h==="x"?_:C:g=h==="x"?C:_}else{const _=[{x:u.x,y:d.y}],C=[{x:d.x,y:u.y}];if(h==="x"?g=l.x===m?C:_:g=l.y===m?_:C,t===r){const I=Math.abs(e[h]-n[h]);if(I<=s){const M=Math.min(s-1,s-I);l[h]===m?O[h]=(u[h]>e[h]?-1:1)*M:v[h]=(d[h]>n[h]?-1:1)*M}}if(t!==r){const I=h==="x"?"y":"x",M=l[h]===c[I],N=u[I]>d[I],D=u[I]=L?(b=(T.x+A.x)/2,y=g[0].y):(b=g[0].x,y=(T.y+A.y)/2)}const S={x:u.x+O.x,y:u.y+O.y},E={x:d.x+v.x,y:d.y+v.y};return[[e,...S.x!==g[0].x||S.y!==g[0].y?[S]:[],...g,...E.x!==g[g.length-1].x||E.y!==g[g.length-1].y?[E]:[],n],b,y,x,w]}function W7e(e,t,n,r){const i=Math.min($q(e,t)/2,$q(t,n)/2,r),{x:s,y:a}=t;if(e.x===s&&s===n.x||e.y===a&&a===n.y)return`L${s} ${a}`;if(e.y===a){const u=e.xn.id===t):e[0])||null}function N4(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function Z7e(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){const s=new Set;return e.reduce((a,l)=>([l.markerStart||r,l.markerEnd||i].forEach(c=>{if(c&&typeof c=="object"){const u=N4(c,t);s.has(u)||(a.push({id:u,color:c.color||n,...c}),s.add(u))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const Bde=1e3,K7e=10,T7={nodeOrigin:[0,0],nodeExtent:Iw,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},J7e={...T7,checkEquality:!0};function C7(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function eBe(e,t,n){const r=C7(T7,n);for(const i of e.values())if(i.parentId)N7(i,e,t,r);else{const s=iE(i,r.nodeOrigin),a=Ug(i.extent)?i.extent:r.nodeExtent,l=Qg(s,a,gh(i));i.internals.positionAbsolute=l}}function tBe(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const i of e.handles){const s={id:i.id,width:i.width??1,height:i.height??1,nodeId:e.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?n.push(s):i.type==="target"&&r.push(s)}return{source:n,target:r}}function A7(e){return e==="manual"}function j4(e,t,n,r={}){var d,f;const i=C7(J7e,r),s={i:0},a=new Map(t),l=i!=null&&i.elevateNodesOnSelect&&!A7(i.zIndexMode)?Bde:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const h of e){let m=a.get(h.id);if(i.checkEquality&&h===(m==null?void 0:m.internals.userNode))t.set(h.id,m);else{const g=iE(h,i.nodeOrigin),b=Ug(h.extent)?h.extent:i.nodeExtent,y=Qg(g,b,gh(h));m={...i.defaults,...h,measured:{width:(d=h.measured)==null?void 0:d.width,height:(f=h.measured)==null?void 0:f.height},internals:{positionAbsolute:y,handleBounds:tBe(h,m),z:Qde(h,l,i.zIndexMode),userNode:h}},t.set(h.id,m)}(m.measured===void 0||m.measured.width===void 0||m.measured.height===void 0)&&!m.hidden&&(c=!1),h.parentId&&N7(m,t,n,r,s),u||(u=h.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function nBe(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 N7(e,t,n,r,i){const{elevateNodesOnSelect:s,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=C7(T7,r),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}nBe(e,n),i&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++i.i,d.internals.z=d.internals.z+i.i*K7e),i&&d.internals.rootParentIndex!==void 0&&(i.i=d.internals.rootParentIndex);const f=s&&!A7(c)?Bde:0,{x:h,y:m,z:g}=rBe(e,d,a,l,f,c),{positionAbsolute:b}=e.internals,y=h!==b.x||m!==b.y;(y||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:h,y:m}:b,z:g}})}function Qde(e,t,n){const r=cu(e.zIndex)?e.zIndex:0;return A7(n)?r:r+(e.selected?t:0)}function rBe(e,t,n,r,i,s){const{x:a,y:l}=t.internals.positionAbsolute,c=gh(e),u=iE(e,n),d=Ug(e.extent)?Qg(u,e.extent,c):u;let f=Qg({x:a+d.x,y:l+d.y},r,c);e.extent==="parent"&&(f=Cde(f,c,t));const h=Qde(e,i,s),m=t.internals.z??0;return{x:f.x,y:f.y,z:m>=h?m+1:h}}function j7(e,t,n,r=[0,0]){var a;const i=[],s=new Map;for(const l of e){const c=t.get(l.parentId);if(!c)continue;const u=((a=s.get(l.parentId))==null?void 0:a.expandedRect)??a1(c),d=Ade(u,l.rect);s.set(l.parentId,{expandedRect:d,parent:c})}return s.size>0&&s.forEach(({expandedRect:l,parent:c},u)=>{var x;const d=c.internals.positionAbsolute,f=gh(c),h=c.origin??r,m=l.x0||g>0||O||v)&&(i.push({id:u,type:"position",position:{x:c.position.x-m+O,y:c.position.y-g+v}}),(x=n.get(u))==null||x.forEach(w=>{e.some(S=>S.id===w.id)||i.push({id:w.id,type:"position",position:{x:w.position.x+m,y:w.position.y+g}})})),(f.width0){const m=j7(h,t,n,i);u.push(...m)}return{changes:u,updatedInternals:c}}async function sBe({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:s}){if(!t||!e.x&&!e.y)return!1;const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,s]],r);return!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2])}function Fq(e,t,n,r,i,s){let a=i;const l=r.get(a)||new Map;r.set(a,l.set(n,t)),a=`${i}-${e}`;const c=r.get(a)||new Map;if(r.set(a,c.set(n,t)),s){a=`${i}-${e}-${s}`;const u=r.get(a)||new Map;r.set(a,u.set(n,t))}}function Ude(e,t,n){e.clear(),t.clear();for(const r of n){const{source:i,target:s,sourceHandle:a=null,targetHandle:l=null}=r,c={edgeId:r.id,source:i,target:s,sourceHandle:a,targetHandle:l},u=`${i}-${a}--${s}-${l}`,d=`${s}-${l}--${i}-${a}`;Fq("source",c,d,e,i,a),Fq("target",c,u,e,s,l),t.set(r.id,r)}}function Fde(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Fde(n,t):!1}function zq(e,t,n){var i;let r=e;do{if((i=r==null?void 0:r.matches)!=null&&i.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function aBe(e,t,n,r){const i=new Map;for(const[s,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!Fde(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(s);l&&i.set(s,{id:s,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return i}function I5({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const i=[];for(const[u,d]of t){const f=(a=n.get(u))==null?void 0:a.internals.userNode;f&&i.push({...f,position:d.position,dragging:r})}if(!e)return[i[0],i];const s=(l=n.get(e))==null?void 0:l.internals.userNode;return[s?{...s,position:((c=t.get(e))==null?void 0:c.position)||s.position,dragging:r}:i[0],i]}function oBe({dragItems:e,snapGrid:t,x:n,y:r}){const i=e.values().next().value;if(!i)return null;const s={x:n-i.distance.x,y:r-i.distance.y},a=aE(s,t);return{x:a.x-s.x,y:a.y-s.y}}function lBe({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let s={x:null,y:null},a=0,l=new Map,c=!1,u={x:0,y:0},d=null,f=!1,h=null,m=!1,g=!1,b=null;function y({noDragClassName:v,handleSelector:x,domNode:w,isSelectable:S,nodeId:E,nodeClickDistance:k=0}){h=Tl(w);function _({x:j,y:L}){const{nodeLookup:I,nodeExtent:M,snapGrid:N,snapToGrid:D,nodeOrigin:Q,onNodeDrag:F,onSelectionDrag:$,onError:H,updateNodePositions:z}=t();s={x:j,y:L};let B=!1;const V=l.size>1,Z=V&&M?A4(sE(l)):null,ce=V&&D?oBe({dragItems:l,snapGrid:N,x:j,y:L}):null;for(const[be,ie]of l){if(!I.has(be))continue;let q={x:j-ie.distance.x,y:L-ie.distance.y};D&&(q=ce?{x:Math.round(q.x+ce.x),y:Math.round(q.y+ce.y)}:aE(q,N));let X=null;if(V&&M&&!ie.extent&&Z){const{positionAbsolute:xe}=ie.internals,Me=xe.x-Z.x+M[0][0],Ae=xe.x+ie.measured.width-Z.x2+M[1][0],He=xe.y-Z.y+M[0][1],et=xe.y+ie.measured.height-Z.y2+M[1][1];X=[[Me,He],[Ae,et]]}const{position:K,positionAbsolute:de}=Tde({nodeId:be,nextPosition:q,nodeLookup:I,nodeExtent:X||M,nodeOrigin:Q,onError:H});B=B||ie.position.x!==K.x||ie.position.y!==K.y,ie.position=K,ie.internals.positionAbsolute=de}if(g=g||B,!!B&&(z(l,!0),b&&(r||F||!E&&$))){const[be,ie]=I5({nodeId:E,dragItems:l,nodeLookup:I});r==null||r(b,l,be,ie),F==null||F(b,be,ie),E||$==null||$(b,ie)}}async function C(){if(!d)return;const{transform:j,panBy:L,autoPanSpeed:I,autoPanOnNodeDrag:M}=t();if(!M){c=!1,cancelAnimationFrame(a);return}const[N,D]=S7(u,d,I);(N!==0||D!==0)&&(s.x=(s.x??0)-N/j[2],s.y=(s.y??0)-D/j[2],await L({x:N,y:D})&&_(s)),a=requestAnimationFrame(C)}function T(j){var V;const{nodeLookup:L,multiSelectionActive:I,nodesDraggable:M,transform:N,snapGrid:D,snapToGrid:Q,selectNodesOnDrag:F,onNodeDragStart:$,onSelectionDragStart:H,unselectNodesAndEdges:z}=t();f=!0,(!F||!S)&&!I&&E&&((V=L.get(E))!=null&&V.selected||z()),S&&F&&E&&(e==null||e(E));const B=Tv(j.sourceEvent,{transform:N,snapGrid:D,snapToGrid:Q,containerBounds:d});if(s=B,l=aBe(L,M,B,E),l.size>0&&(n||$||!E&&H)){const[Z,ce]=I5({nodeId:E,dragItems:l,nodeLookup:L});n==null||n(j.sourceEvent,l,Z,ce),$==null||$(j.sourceEvent,Z,ce),E||H==null||H(j.sourceEvent,ce)}}const A=sde().clickDistance(k).on("start",j=>{const{domNode:L,nodeDragThreshold:I,transform:M,snapGrid:N,snapToGrid:D}=t();d=(L==null?void 0:L.getBoundingClientRect())||null,m=!1,g=!1,b=j.sourceEvent,I===0&&T(j),s=Tv(j.sourceEvent,{transform:M,snapGrid:N,snapToGrid:D,containerBounds:d}),u=uu(j.sourceEvent,d)}).on("drag",j=>{const{autoPanOnNodeDrag:L,transform:I,snapGrid:M,snapToGrid:N,nodeDragThreshold:D,nodeLookup:Q}=t(),F=Tv(j.sourceEvent,{transform:I,snapGrid:M,snapToGrid:N,containerBounds:d});if(b=j.sourceEvent,(j.sourceEvent.type==="touchmove"&&j.sourceEvent.touches.length>1||E&&!Q.has(E))&&(m=!0),!m){if(!c&&L&&f&&(c=!0,C()),!f){const $=uu(j.sourceEvent,d),H=$.x-u.x,z=$.y-u.y;Math.sqrt(H*H+z*z)>D&&T(j)}(s.x!==F.xSnapped||s.y!==F.ySnapped)&&l&&f&&(u=uu(j.sourceEvent,d),_(F))}}).on("end",j=>{if(!f||m){m&&l.size>0&&t().updateNodePositions(l,!1);return}if(c=!1,f=!1,cancelAnimationFrame(a),l.size>0){const{nodeLookup:L,updateNodePositions:I,onNodeDragStop:M,onSelectionDragStop:N}=t();if(g&&(I(l,!1),g=!1),i||M||!E&&N){const[D,Q]=I5({nodeId:E,dragItems:l,nodeLookup:L,dragging:!1});i==null||i(j.sourceEvent,l,D,Q),M==null||M(j.sourceEvent,D,Q),E||N==null||N(j.sourceEvent,Q)}}}).filter(j=>{const L=j.target;return!j.button&&(!v||!zq(L,`.${v}`,w))&&(!x||zq(L,x,w))});h.call(A)}function O(){h==null||h.on(".drag",null)}return{update:y,destroy:O}}function cBe(e,t,n){const r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const s of t.values())Mw(i,a1(s))>0&&r.push(s);return r}const uBe=250;function dBe(e,t,n,r){var l,c;let i=[],s=1/0;const a=cBe(e,n,t+uBe);for(const u of a){const d=[...((l=u.internals.handleBounds)==null?void 0:l.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of d){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:h,y:m}=Fg(u,f,f.position,!0),g=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(m-e.y,2));g>t||(g1){const u=r.type==="source"?"target":"source";return i.find(d=>d.type===u)??i[0]}return i[0]}function zde(e,t,n,r,i,s=!1){var u,d,f;const a=r.get(e);if(!a)return null;const l=i==="strict"?(u=a.internals.handleBounds)==null?void 0:u[t]:[...((d=a.internals.handleBounds)==null?void 0:d.source)??[],...((f=a.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?l==null?void 0:l.find(h=>h.id===n):l==null?void 0:l[0])??null;return c&&s?{...c,...Fg(a,c,c.position,!0)}:c}function Vde(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function fBe(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Hde=()=>!0;function hBe(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:s,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:f,panBy:h,cancelConnection:m,onConnectStart:g,onConnect:b,onConnectEnd:y,isValidConnection:O=Hde,onReconnectEnd:v,updateConnection:x,getTransform:w,getFromHandle:S,autoPanSpeed:E,dragThreshold:k=1,handleDomNode:_}){const C=Rde(e.target);let T=0,A;const{x:j,y:L}=uu(e),I=Vde(s,_),M=l==null?void 0:l.getBoundingClientRect();let N=!1;if(!M||!I)return;const D=zde(i,I,r,c,t);if(!D)return;let Q=uu(e,M),F=!1,$=null,H=!1,z=null;function B(){if(!d||!M)return;const[K,de]=S7(Q,M,E);h({x:K,y:de}),T=requestAnimationFrame(B)}const V={...D,nodeId:i,type:I,position:D.position},Z=c.get(i);let be={inProgress:!0,isValid:null,from:Fg(Z,V,zt.Left,!0),fromHandle:V,fromPosition:V.position,fromNode:Z,to:Q,toHandle:null,toPosition:jq[V.position],toNode:null,pointer:Q};function ie(){N=!0,x(be),g==null||g(e,{nodeId:i,handleId:r,handleType:I})}k===0&&ie();function q(K){if(!N){const{x:et,y:Te}=uu(K),Re=et-j,he=Te-L;if(!(Re*Re+he*he>k*k))return;ie()}if(!S()||!V){X(K);return}const de=w();Q=uu(K,M),A=dBe(J1(Q,de,!1,[1,1]),n,c,V),F||(B(),F=!0);const xe=qde(K,{handle:A,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:a?"target":"source",isValidConnection:O,doc:C,lib:u,flowId:f,nodeLookup:c});z=xe.handleDomNode,$=xe.connection,H=fBe(!!A,xe.isValid);const Me=c.get(i),Ae=Me?Fg(Me,V,zt.Left,!0):be.from,He={...be,from:Ae,isValid:H,to:xe.toHandle&&H?o1({x:xe.toHandle.x,y:xe.toHandle.y},de):Q,toHandle:xe.toHandle,toPosition:H&&xe.toHandle?xe.toHandle.position:jq[V.position],toNode:xe.toHandle?c.get(xe.toHandle.nodeId):null,pointer:Q};x(He),be=He}function X(K){if(!("touches"in K&&K.touches.length>0)){if(N){(A||z)&&$&&H&&(b==null||b($));const{inProgress:de,...xe}=be,Me={...xe,toPosition:be.toHandle?be.toPosition:null};y==null||y(K,Me),s&&(v==null||v(K,Me))}m(),cancelAnimationFrame(T),F=!1,H=!1,$=null,z=null,C.removeEventListener("mousemove",q),C.removeEventListener("mouseup",X),C.removeEventListener("touchmove",q),C.removeEventListener("touchend",X)}}C.addEventListener("mousemove",q),C.addEventListener("mouseup",X),C.addEventListener("touchmove",q),C.addEventListener("touchend",X)}function qde(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:s,doc:a,lib:l,flowId:c,isValidConnection:u=Hde,nodeLookup:d}){const f=s==="target",h=t?a.querySelector(`.${l}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:m,y:g}=uu(e),b=a.elementFromPoint(m,g),y=b!=null&&b.classList.contains(`${l}-flow__handle`)?b:h,O={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const v=Vde(void 0,y),x=y.getAttribute("data-nodeid"),w=y.getAttribute("data-handleid"),S=y.classList.contains("connectable"),E=y.classList.contains("connectableend");if(!x||!v)return O;const k={source:f?x:r,sourceHandle:f?w:i,target:f?r:x,targetHandle:f?i:w};O.connection=k;const C=S&&E&&(n===i1.Strict?f&&v==="source"||!f&&v==="target":x!==r||w!==i);O.isValid=C&&u(k),O.toHandle=zde(x,v,w,d,n,!0)}return O}const R4={onPointerDown:hBe,isValid:qde};function pBe({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const i=Tl(e);function s({translateExtent:l,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:h=!0,inversePan:m=!1}){const g=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const w=n(),S=x.sourceEvent.ctrlKey&&Lw()?10:1,E=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*d,k=w[2]*Math.pow(2,E*S);t.scaleTo(k)};let b=[0,0];const y=x=>{(x.sourceEvent.type==="mousedown"||x.sourceEvent.type==="touchstart")&&(b=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY])},O=x=>{const w=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!t)return;const S=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],E=[S[0]-b[0],S[1]-b[1]];b=S;const k=r()*Math.max(w[2],Math.log(w[2]))*(m?-1:1),_={x:w[0]-E[0]*k,y:w[1]-E[1]*k},C=[[0,0],[c,u]];t.setViewportConstrained({x:_.x,y:_.y,zoom:w[2]},C,l)},v=vde().on("start",y).on("zoom",f?O:null).on("zoom.wheel",h?g:null);i.call(v,{})}function a(){i.on("zoom",null)}return{update:s,destroy:a,pointer:iu}}const dj=e=>({x:e.x,y:e.y,zoom:e.k}),D5=({x:e,y:t,zoom:n})=>lj.translate(e,t).scale(n),Vb=(e,t)=>e.target.closest(`.${t}`),Xde=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),mBe=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,P5=(e,t=0,n=mBe,r=()=>{})=>{const i=typeof t=="number"&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on("end",r):e},Gde=e=>{const t=e.ctrlKey&&Lw()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function gBe({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:s,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(Vb(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&a){const y=iu(d),O=Gde(d),v=f*Math.pow(2,O);r.scaleTo(n,v,y,d);return}const h=d.deltaMode===1?20:1;let m=i===wg.Vertical?0:d.deltaX*h,g=i===wg.Horizontal?0:d.deltaY*h;!Lw()&&d.shiftKey&&i!==wg.Vertical&&(m=d.deltaY*h,g=0),r.translateBy(n,-(m/f)*s,-(g/f)*s,{internal:!0});const b=dj(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(d,b),e.panScrollTimeout=setTimeout(()=>{u==null||u(d,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(d,b))}}function bBe({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){const s=r.type==="wheel",a=!t&&s&&!r.ctrlKey,l=Vb(r,e);if(r.ctrlKey&&s&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,i)}}function yBe({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var s,a,l;if((s=r.sourceEvent)!=null&&s.internal)return;const i=dj(r.transform);e.mouseButton=((a=r.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=i,((l=r.sourceEvent)==null?void 0:l.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,i))}}function OBe({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return s=>{var a,l;e.usedRightMouseButton=!!(n&&Xde(t,e.mouseButton??0)),(a=s.sourceEvent)!=null&&a.sync||r([s.transform.x,s.transform.y,s.transform.k]),i&&!((l=s.sourceEvent)!=null&&l.internal)&&(i==null||i(s.sourceEvent,dj(s.transform)))}}function xBe({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:s}){return a=>{var l;if(!((l=a.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,s&&Xde(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&s(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){const c=dj(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i==null||i(a.sourceEvent,c)},n?150:0)}}}function vBe({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:d}){return f=>{var y;const h=e||t,m=n&&f.ctrlKey,g=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Vb(f,`${u}-flow__node`)||Vb(f,`${u}-flow__edge`)))return!0;if(!r&&!h&&!i&&!s&&!n||a||d&&!g||Vb(f,l)&&g||Vb(f,c)&&(!g||i&&g&&!e)||!n&&f.ctrlKey&&g)return!1;if(!n&&f.type==="touchstart"&&((y=f.touches)==null?void 0:y.length)>1)return f.preventDefault(),!1;if(!h&&!i&&!m&&g||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const b=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||g)&&b}}function wBe({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:s,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),f=vde().scaleExtent([t,n]).translateExtent(r),h=Tl(e).call(f);v({x:i.x,y:i.y,zoom:s1(i.zoom,t,n)},[[0,0],[d.width,d.height]],r);const m=h.on("wheel.zoom"),g=h.on("dblclick.zoom");f.wheelDelta(Gde);async function b(A,j){return h?new Promise(L=>{f==null||f.interpolate((j==null?void 0:j.interpolate)==="linear"?_v:Z_).transform(P5(h,j==null?void 0:j.duration,j==null?void 0:j.ease,()=>L(!0)),A)}):!1}function y({noWheelClassName:A,noPanClassName:j,onPaneContextMenu:L,userSelectionActive:I,panOnScroll:M,panOnDrag:N,panOnScrollMode:D,panOnScrollSpeed:Q,preventScrolling:F,zoomOnPinch:$,zoomOnScroll:H,zoomOnDoubleClick:z,zoomActivationKeyPressed:B,lib:V,onTransformChange:Z,connectionInProgress:ce,paneClickDistance:be,selectionOnDrag:ie}){I&&!u.isZoomingOrPanning&&O();const q=M&&!B&&!I;f.clickDistance(ie?1/0:!cu(be)||be<0?0:be);const X=q?gBe({zoomPanValues:u,noWheelClassName:A,d3Selection:h,d3Zoom:f,panOnScrollMode:D,panOnScrollSpeed:Q,zoomOnPinch:$,onPanZoomStart:a,onPanZoom:s,onPanZoomEnd:l}):bBe({noWheelClassName:A,preventScrolling:F,d3ZoomHandler:m});h.on("wheel.zoom",X,{passive:!1});const K=yBe({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",K);const de=OBe({zoomPanValues:u,panOnDrag:N,onPaneContextMenu:!!L,onPanZoom:s,onTransformChange:Z});f.on("zoom",de);const xe=xBe({zoomPanValues:u,panOnDrag:N,panOnScroll:M,onPaneContextMenu:L,onPanZoomEnd:l,onDraggingChange:c});f.on("end",xe);const Me=vBe({zoomActivationKeyPressed:B,panOnDrag:N,zoomOnScroll:H,panOnScroll:M,zoomOnDoubleClick:z,zoomOnPinch:$,userSelectionActive:I,noPanClassName:j,noWheelClassName:A,lib:V,connectionInProgress:ce});f.filter(Me),z?h.on("dblclick.zoom",g):h.on("dblclick.zoom",null)}function O(){f.on("zoom",null)}async function v(A,j,L){const I=D5(A),M=f==null?void 0:f.constrain()(I,j,L);return M&&await b(M),M}async function x(A,j){const L=D5(A);return await b(L,j),L}function w(A){if(h){const j=D5(A),L=h.property("__zoom");(L.k!==A.zoom||L.x!==A.x||L.y!==A.y)&&(f==null||f.transform(h,j,null,{sync:!0}))}}function S(){const A=h?xde(h.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}async function E(A,j){return h?new Promise(L=>{f==null||f.interpolate((j==null?void 0:j.interpolate)==="linear"?_v:Z_).scaleTo(P5(h,j==null?void 0:j.duration,j==null?void 0:j.ease,()=>L(!0)),A)}):!1}async function k(A,j){return h?new Promise(L=>{f==null||f.interpolate((j==null?void 0:j.interpolate)==="linear"?_v:Z_).scaleBy(P5(h,j==null?void 0:j.duration,j==null?void 0:j.ease,()=>L(!0)),A)}):!1}function _(A){f==null||f.scaleExtent(A)}function C(A){f==null||f.translateExtent(A)}function T(A){const j=!cu(A)||A<0?0:A;f==null||f.clickDistance(j)}return{update:y,destroy:O,setViewport:x,setViewportConstrained:v,getViewport:S,scaleTo:E,scaleBy:k,setScaleExtent:_,setTranslateExtent:C,syncViewport:w,setClickDistance:T}}var l1;(function(e){e.Line="line",e.Handle="handle"})(l1||(l1={}));function SBe({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:s}){const a=e-t,l=n-r,c=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&i&&(c[0]=c[0]*-1),l&&s&&(c[1]=c[1]*-1),c}function Vq(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),i=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:i}}function Lh(e,t){return Math.max(0,t-e)}function $h(e,t){return Math.max(0,e-t)}function l2(e,t,n){return Math.max(0,t-e,e-n)}function Hq(e,t){return e?!t:t}function EBe(e,t,n,r,i,s,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:f}=t,h=d&&f,{xSnapped:m,ySnapped:g}=n,{minWidth:b,maxWidth:y,minHeight:O,maxHeight:v}=r,{x,y:w,width:S,height:E,aspectRatio:k}=e;let _=Math.floor(d?m-e.pointerX:0),C=Math.floor(f?g-e.pointerY:0);const T=S+(c?-_:_),A=E+(u?-C:C),j=-s[0]*S,L=-s[1]*E;let I=l2(T,b,y),M=l2(A,O,v);if(a){let Q=0,F=0;c&&_<0?Q=Lh(x+_+j,a[0][0]):!c&&_>0&&(Q=$h(x+T+j,a[1][0])),u&&C<0?F=Lh(w+C+L,a[0][1]):!u&&C>0&&(F=$h(w+A+L,a[1][1])),I=Math.max(I,Q),M=Math.max(M,F)}if(l){let Q=0,F=0;c&&_>0?Q=$h(x+_,l[0][0]):!c&&_<0&&(Q=Lh(x+T,l[1][0])),u&&C>0?F=$h(w+C,l[0][1]):!u&&C<0&&(F=Lh(w+A,l[1][1])),I=Math.max(I,Q),M=Math.max(M,F)}if(i){if(d){const Q=l2(T/k,O,v)*k;if(I=Math.max(I,Q),a){let F=0;!c&&!u||c&&!u&&h?F=$h(w+L+T/k,a[1][1])*k:F=Lh(w+L+(c?_:-_)/k,a[0][1])*k,I=Math.max(I,F)}if(l){let F=0;!c&&!u||c&&!u&&h?F=Lh(w+T/k,l[1][1])*k:F=$h(w+(c?_:-_)/k,l[0][1])*k,I=Math.max(I,F)}}if(f){const Q=l2(A*k,b,y)/k;if(M=Math.max(M,Q),a){let F=0;!c&&!u||u&&!c&&h?F=$h(x+A*k+j,a[1][0])/k:F=Lh(x+(u?C:-C)*k+j,a[0][0])/k,M=Math.max(M,F)}if(l){let F=0;!c&&!u||u&&!c&&h?F=Lh(x+A*k,l[1][0])/k:F=$h(x+(u?C:-C)*k,l[0][0])/k,M=Math.max(M,F)}}}C=C+(C<0?M:-M),_=_+(_<0?I:-I),i&&(h?T>A*k?C=(Hq(c,u)?-_:_)/k:_=(Hq(c,u)?-C:C)*k:d?(C=_/k,u=c):(_=C*k,c=u));const N=c?x+_:x,D=u?w+C:w;return{width:S+(c?-_:_),height:E+(u?-C:C),x:s[0]*_*(c?-1:1)+N,y:s[1]*C*(u?-1:1)+D}}const Wde={width:0,height:0,x:0,y:0},kBe={...Wde,pointerX:0,pointerY:0,aspectRatio:1};function _Be(e,t,n){const r=t.position.x+e.position.x,i=t.position.y+e.position.y,s=e.measured.width??0,a=e.measured.height??0,l=n[0]*s,c=n[1]*a;return[[r-l,i-c],[r+s-l,i+a-c]]}function TBe({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){const s=Tl(e);let a={controlDirection:Vq("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:d,keepAspectRatio:f,resizeDirection:h,onResizeStart:m,onResize:g,onResizeEnd:b,shouldResize:y}){let O={...Wde},v={...kBe};a={boundaries:d,resizeDirection:h,keepAspectRatio:f,controlDirection:Vq(u)};let x,w=null,S=[],E,k,_,C=!1;const T=sde().on("start",A=>{const{nodeLookup:j,transform:L,snapGrid:I,snapToGrid:M,nodeOrigin:N,paneDomNode:D}=n();if(x=j.get(t),!x)return;w=(D==null?void 0:D.getBoundingClientRect())??null;const{xSnapped:Q,ySnapped:F}=Tv(A.sourceEvent,{transform:L,snapGrid:I,snapToGrid:M,containerBounds:w});O={width:x.measured.width??0,height:x.measured.height??0,x:x.position.x??0,y:x.position.y??0},v={...O,pointerX:Q,pointerY:F,aspectRatio:O.width/O.height},E=void 0,k=Ug(x.extent)?x.extent:void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(E=j.get(x.parentId)),E&&x.extent==="parent"&&(k=[[0,0],[E.measured.width,E.measured.height]]),S=[],_=void 0;for(const[$,H]of j)if(H.parentId===t&&(S.push({id:$,position:{...H.position},extent:H.extent}),H.extent==="parent"||H.expandParent)){const z=_Be(H,x,H.origin??N);_?_=[[Math.min(z[0][0],_[0][0]),Math.min(z[0][1],_[0][1])],[Math.max(z[1][0],_[1][0]),Math.max(z[1][1],_[1][1])]]:_=z}m==null||m(A,{...O})}).on("drag",A=>{const{transform:j,snapGrid:L,snapToGrid:I,nodeOrigin:M}=n(),N=Tv(A.sourceEvent,{transform:j,snapGrid:L,snapToGrid:I,containerBounds:w}),D=[];if(!x)return;const{x:Q,y:F,width:$,height:H}=O,z={},B=x.origin??M,{width:V,height:Z,x:ce,y:be}=EBe(v,a.controlDirection,N,a.boundaries,a.keepAspectRatio,B,k,_),ie=V!==$,q=Z!==H,X=ce!==Q&&ie,K=be!==F&&q;if(!X&&!K&&!ie&&!q)return;if((X||K||B[0]===1||B[1]===1)&&(z.x=X?ce:O.x,z.y=K?be:O.y,O.x=z.x,O.y=z.y,S.length>0)){const Ae=ce-Q,He=be-F;for(const et of S)et.position={x:et.position.x-Ae+B[0]*(V-$),y:et.position.y-He+B[1]*(Z-H)},D.push(et)}if((ie||q)&&(z.width=ie&&(!a.resizeDirection||a.resizeDirection==="horizontal")?V:O.width,z.height=q&&(!a.resizeDirection||a.resizeDirection==="vertical")?Z:O.height,O.width=z.width,O.height=z.height),E&&x.expandParent){const Ae=B[0]*(z.width??0);z.x&&z.x{C&&(b==null||b(A,{...O}),i==null||i({...O}),C=!1)});s.call(T)}function c(){s.on(".drag",null)}return{update:l,destroy:c}}var Yde={exports:{}},Zde={},Kde={exports:{}},Jde={};/** * @license React * use-sync-external-store-shim.production.js * @@ -502,7 +502,7 @@ ${r}`}}async function u9(e,t=!1){const n=await wt(`/web/model-api-keys${t?"?refr ${Ga(l,t)}`).join(` `);if(!(e instanceof wj))return(e instanceof Error?qx(e.message):"")||t;const n=qx(e.message)||t,r=[Number.isFinite(e.status)?`状态码:${e.status}`:"",e.errorCode?`错误码:${qx(e.errorCode)}`:"",e.requestId?`请求 ID:${qx(e.requestId)}`:""].filter(Boolean).join(" · "),i=YX(e.diagnostics),s=YX(e.detail);return[n,r,i?`诊断:${i}`:"",s&&s!==n?`详情:${s}`:""].filter(Boolean).join(` -`)}function rT(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim();return""}function QGe(e){return Array.isArray(e)?e.map(t=>{const n=Lc(t),r=rT(n.msg,n.message);if(!r)return"";const i=Array.isArray(n.loc)?n.loc.filter(s=>typeof s=="string"||typeof s=="number").map(String).join("."):"";return i?`${i}: ${r}`:r}).filter(Boolean).join("; "):""}function UGe(e,t=!0){const n=Lc(e),r=Object.prototype.hasOwnProperty.call(n,"detail")?n.detail:typeof e=="string"?e:void 0,i=Lc(r);return{message:typeof r=="string"?t?r.trim():"":rT(i.message,n.message,QGe(r)),errorCode:rT(i.errorCode,n.errorCode),requestId:rT(i.requestId,i.request_id,i.RequestId,n.requestId,n.request_id),diagnostics:i.diagnostics??n.diagnostics,detail:r,payload:e}}function Lc(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function _r(e){return typeof e=="string"?e:""}function Uw(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function K7(e){const t=Lc(e);return{id:_r(t.id),name:_r(t.name),description:_r(t.description),providerType:_r(t.providerType),providerKnowledgeId:_r(t.providerKnowledgeId),projectName:_r(t.projectName),region:_r(t.region),status:_r(t.status),createdAt:_r(t.createdAt),updatedAt:_r(t.updatedAt),ownerId:_r(t.ownerId),ownerLabel:_r(t.ownerLabel),canManage:t.canManage===!0}}function gE(e){const t=Lc(e);return{id:_r(t.id),name:_r(t.name),type:_r(t.type),sizeBytes:Uw(t.sizeBytes,0),status:_r(t.status),url:_r(t.url),tosPath:_r(t.tosPath),metadata:Lc(t.metadata),createdAt:_r(t.createdAt),updatedAt:_r(t.updatedAt),sourceMarkdown:_r(t.sourceMarkdown)}}function FGe(e){const t=Lc(e),n=t.attachment,r=Lc(n);return{id:_r(t.id),title:_r(t.title),content:_r(t.content),attachmentUrl:_r(t.attachmentUrl)||_r(r.url)||_r(r.previewUrl),attachmentType:_r(t.attachmentType)||_r(r.type)||_r(r.mimeType),attachment:n,tableFields:t.tableFields}}async function Tu(e,t={},n=_o){var f;const r=fh(t.headers);r.set("accept","application/json"),t.body&&!(t.body instanceof FormData)&&r.set("content-type","application/json");const i=await fetch(e,{...t,headers:r,signal:nl(t.signal,n)});if(i.ok)return i.status===204?void 0:i.json();const s=await i.text();let a=s,l=!1;if(s)try{a=JSON.parse(s),l=!0}catch{}const c=((f=i.headers.get("content-type"))==null?void 0:f.toLowerCase())||"",u=UGe(a,l||c.startsWith("text/plain")),d=i.status===401?"请先登录后再访问知识库":i.status===403?"你没有权限操作这个知识库":i.status===404?"知识库或知识内容不存在":i.status===409?"知识库当前状态不允许执行此操作":`知识库请求失败 (${i.status})`;throw new wj(u.message||d,i.status,{errorCode:u.errorCode,requestId:u.requestId,diagnostics:u.diagnostics,detail:u.detail,payload:u.payload,rawBody:s})}function y0(e){const t=new URLSearchParams;e.trim()&&t.set("region",e.trim());const n=t.toString();return n?`?${n}`:""}async function zGe(e){var i;const t=new URLSearchParams({region:e.region,pageSize:String(e.pageSize??30)});(i=e.projectName)!=null&&i.trim()&&t.set("projectName",e.projectName.trim()),e.nextToken&&t.set("nextToken",e.nextToken);const n=await Tu(`/web/knowledge-bases?${t.toString()}`,{signal:e.signal}),r=Lc(n);return{items:Array.isArray(r.items)?r.items.map(K7):[],nextToken:_r(r.nextToken)}}function VGe(e){return`${e.region}\0${e.id}`}async function HGe(e){var l;const t=[...new Set(e.regions.map(c=>c.trim()).filter(Boolean))],n=e.nextTokens?t.filter(c=>{var u;return!!((u=e.nextTokens)!=null&&u[c])}):t;if(n.length===0)return{items:[],nextTokens:{},failures:[]};const r=await Promise.allSettled(n.map(async c=>{var u;return{region:c,page:await zGe({region:c,projectName:e.projectName,nextToken:(u=e.nextTokens)==null?void 0:u[c],pageSize:e.pageSize,signal:e.signal})}}));if((l=e.signal)!=null&&l.aborted)throw new DOMException("Aborted","AbortError");const i=[],s={},a=new Map;if(r.forEach((c,u)=>{var f;const d=n[u];if(c.status==="rejected"){const h=(f=e.nextTokens)==null?void 0:f[d];h&&(s[d]=h),i.push({region:d,error:c.reason instanceof Error?c.reason:new Error("读取知识库失败")});return}c.value.page.nextToken&&(s[d]=c.value.page.nextToken),c.value.page.items.forEach(h=>{const m=h.region?h:{...h,region:d};a.set(VGe(m),m)})}),i.length===n.length)throw new Yhe(i);return{items:[...a.values()],nextTokens:s,failures:i}}function qGe(e){return Tu("/web/knowledge-bases",{method:"POST",body:JSON.stringify(e)},Zi).then(K7)}function XGe(e,t,n){return Tu(`/web/knowledge-bases/${encodeURIComponent(e)}${y0(t)}`,{method:"PATCH",body:JSON.stringify(n)}).then(K7)}function GGe(e,t){return Tu(`/web/knowledge-bases/${encodeURIComponent(e)}${y0(t)}`,{method:"DELETE"},Zi)}async function WGe(e,t){var s;const n=new URLSearchParams({region:t.region,offset:String(t.offset??0),limit:String(t.limit??30)});(s=t.documentType)!=null&&s.trim()&&n.set("documentType",t.documentType.trim());const r=await Tu(`/web/knowledge-bases/${encodeURIComponent(e)}/documents?${n.toString()}`,{signal:t.signal}),i=Lc(r);return{items:Array.isArray(i.items)?i.items.map(gE):[],offset:Uw(i.offset,0),limit:Uw(i.limit,t.limit??30),hasMore:i.hasMore===!0}}async function YGe(e,t,n){const r=new URLSearchParams({region:n.region,offset:String(n.offset??0),limit:String(n.limit??20)}),i=await Tu(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/${encodeURIComponent(t)}/preview?${r.toString()}`,{signal:n.signal}),s=Lc(i);return{document:gE(s.document),chunks:Array.isArray(s.chunks)?s.chunks.map(FGe):[],sourceMarkdown:_r(s.sourceMarkdown),offset:Uw(s.offset,0),limit:Uw(s.limit,n.limit??20),hasMore:s.hasMore===!0}}function ZGe(e,t,n){return Tu(`/web/knowledge-bases/${encodeURIComponent(e)}/documents${y0(t)}`,{method:"POST",body:JSON.stringify(n)},Zi).then(gE)}async function KGe(e,t,n){const r=await Tu(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/web-preview${y0(t)}`,{method:"POST",body:JSON.stringify({sourceType:"url",url:n.url})},Zi),i=Lc(r);return{name:_r(i.name),url:_r(i.url),sourceMarkdown:_r(i.sourceMarkdown)}}function JGe(e,t,n){var i,s;const r=new FormData;return r.set("file",n.file),(i=n.name)!=null&&i.trim()&&r.set("name",n.name.trim()),(s=n.documentType)!=null&&s.trim()&&r.set("documentType",n.documentType.trim()),n.metadata&&r.set("metadata",JSON.stringify(n.metadata)),Tu(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/upload${y0(t)}`,{method:"POST",body:r},Zi).then(gE)}function eWe(e,t,n,r){return Tu(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/${encodeURIComponent(t)}${y0(n)}`,{method:"PATCH",body:JSON.stringify(r)}).then(gE)}function tWe(e,t,n){return Tu(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/${encodeURIComponent(t)}${y0(n)}`,{method:"DELETE"},Zi)}function bE({className:e="",title:t,status:n,description:r,metadata:i,detailAction:s,action:a,auxiliaryAction:l}){return o.jsxs(W7,{className:`library-resource-card ${e}`.trim(),activateLabel:`${s.label} ${t}`,onActivate:s.disabled?void 0:s.onClick,footer:o.jsx(Uhe,{items:i.map(c=>({label:c.label,value:c.value,title:c.title,hideLabel:!0}))}),actions:o.jsxs(o.Fragment,{children:[l?o.jsx(X4,{className:"library-resource-card__auxiliary-action",label:`${l.label} ${t}`,tone:"secondary",disabled:l.disabled,title:l.title??l.label,onClick:l.onClick,children:l.icon}):null,a?o.jsx(X4,{label:`${a.label} ${t}`,icon:a.icon,disabled:a.disabled,title:a.title,onClick:a.onClick}):null]}),children:[o.jsx(Y7,{leading:o.jsx(d1,{seed:t}),title:t,titleText:t,status:n}),o.jsx(Z7,{title:r,children:r})]})}function hMt(){}function ZX(e){const t=[],n=String(e||"");let r=n.indexOf(","),i=0,s=!1;for(;!s;){r===-1&&(r=n.length,s=!0);const a=n.slice(i,r).trim();(a||!s)&&t.push(a),i=r+1,r=n.indexOf(",",i)}return t}function Khe(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const nWe=/[$_\p{ID_Start}]/u,rWe=/[$_\u{200C}\u{200D}\p{ID_Continue}]/u,iWe=/[-$_\u{200C}\u{200D}\p{ID_Continue}]/u,sWe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,aWe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Jhe={};function pMt(e){return e?nWe.test(String.fromCodePoint(e)):!1}function mMt(e,t){const r=(t||Jhe).jsx?iWe:rWe;return e?r.test(String.fromCodePoint(e)):!1}function KX(e,t){return(Jhe.jsx?aWe:sWe).test(e)}const oWe=/[ \t\n\f\r]/g;function lWe(e){return typeof e=="object"?e.type==="text"?JX(e.value):!1:JX(e)}function JX(e){return e.replace(oWe,"")===""}let yE=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};yE.prototype.normal={};yE.prototype.property={};yE.prototype.space=void 0;function epe(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new yE(n,r,t)}function Fw(e){return e.toLowerCase()}class il{constructor(t,n){this.attribute=n,this.property=t}}il.prototype.attribute="";il.prototype.booleanish=!1;il.prototype.boolean=!1;il.prototype.commaOrSpaceSeparated=!1;il.prototype.commaSeparated=!1;il.prototype.defined=!1;il.prototype.mustUseProperty=!1;il.prototype.number=!1;il.prototype.overloadedBoolean=!1;il.prototype.property="";il.prototype.spaceSeparated=!1;il.prototype.space=void 0;let cWe=0;const Yn=O0(),$s=O0(),W4=O0(),xt=O0(),ki=O0(),xy=O0(),yl=O0();function O0(){return 2**++cWe}const Y4=Object.freeze(Object.defineProperty({__proto__:null,boolean:Yn,booleanish:$s,commaOrSpaceSeparated:yl,commaSeparated:xy,number:xt,overloadedBoolean:W4,spaceSeparated:ki},Symbol.toStringTag,{value:"Module"})),Z5=Object.keys(Y4);class J7 extends il{constructor(t,n,r,i){let s=-1;if(super(t,n),eG(this,"space",i),typeof r=="number")for(;++s4&&n.slice(0,4)==="data"&&pWe.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(tG,gWe);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!tG.test(s)){let a=s.replace(hWe,mWe);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=J7}return new i(r,t)}function mWe(e){return"-"+e.toLowerCase()}function gWe(e){return e.charAt(1).toUpperCase()}const OE=epe([tpe,uWe,ipe,spe,ape],"html"),hm=epe([tpe,dWe,ipe,spe,ape],"svg");function nG(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function ope(e){return e.join(" ").trim()}var eB={},rG=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,bWe=/\n/g,yWe=/^\s*/,OWe=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,xWe=/^:\s*/,vWe=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,wWe=/^[;\s]*/,SWe=/^\s+|\s+$/g,EWe=` +`)}function rT(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim();return""}function QGe(e){return Array.isArray(e)?e.map(t=>{const n=Lc(t),r=rT(n.msg,n.message);if(!r)return"";const i=Array.isArray(n.loc)?n.loc.filter(s=>typeof s=="string"||typeof s=="number").map(String).join("."):"";return i?`${i}: ${r}`:r}).filter(Boolean).join("; "):""}function UGe(e,t=!0){const n=Lc(e),r=Object.prototype.hasOwnProperty.call(n,"detail")?n.detail:typeof e=="string"?e:void 0,i=Lc(r);return{message:typeof r=="string"?t?r.trim():"":rT(i.message,n.message,QGe(r)),errorCode:rT(i.errorCode,n.errorCode),requestId:rT(i.requestId,i.request_id,i.RequestId,n.requestId,n.request_id),diagnostics:i.diagnostics??n.diagnostics,detail:r,payload:e}}function Lc(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function _r(e){return typeof e=="string"?e:""}function Uw(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function K7(e){const t=Lc(e);return{id:_r(t.id),name:_r(t.name),description:_r(t.description),providerType:_r(t.providerType),providerKnowledgeId:_r(t.providerKnowledgeId),projectName:_r(t.projectName),region:_r(t.region),status:_r(t.status),createdAt:_r(t.createdAt),updatedAt:_r(t.updatedAt),ownerId:_r(t.ownerId),ownerLabel:_r(t.ownerLabel),canManage:t.canManage===!0}}function gE(e){const t=Lc(e);return{id:_r(t.id),name:_r(t.name),type:_r(t.type),sizeBytes:Uw(t.sizeBytes,0),status:_r(t.status),url:_r(t.url),tosPath:_r(t.tosPath),metadata:Lc(t.metadata),createdAt:_r(t.createdAt),updatedAt:_r(t.updatedAt),sourceMarkdown:_r(t.sourceMarkdown)}}function FGe(e){const t=Lc(e),n=t.attachment,r=Lc(n);return{id:_r(t.id),title:_r(t.title),content:_r(t.content),attachmentUrl:_r(t.attachmentUrl)||_r(r.url)||_r(r.previewUrl),attachmentType:_r(t.attachmentType)||_r(r.type)||_r(r.mimeType),attachment:n,tableFields:t.tableFields}}async function Tu(e,t={},n=_o){var f;const r=fh(t.headers);r.set("accept","application/json"),t.body&&!(t.body instanceof FormData)&&r.set("content-type","application/json");const i=await fetch(e,{...t,headers:r,signal:nl(t.signal,n)});if(i.ok)return i.status===204?void 0:i.json();const s=await i.text();let a=s,l=!1;if(s)try{a=JSON.parse(s),l=!0}catch{}const c=((f=i.headers.get("content-type"))==null?void 0:f.toLowerCase())||"",u=UGe(a,l||c.startsWith("text/plain")),d=i.status===401?"请先登录后再访问知识库":i.status===403?"你没有权限操作这个知识库":i.status===404?"知识库或知识内容不存在":i.status===409?"知识库当前状态不允许执行此操作":`知识库请求失败 (${i.status})`;throw new wj(u.message||d,i.status,{errorCode:u.errorCode,requestId:u.requestId,diagnostics:u.diagnostics,detail:u.detail,payload:u.payload,rawBody:s})}function y0(e){const t=new URLSearchParams;e.trim()&&t.set("region",e.trim());const n=t.toString();return n?`?${n}`:""}async function zGe(e){var i;const t=new URLSearchParams({region:e.region,pageSize:String(e.pageSize??30)});(i=e.projectName)!=null&&i.trim()&&t.set("projectName",e.projectName.trim()),e.nextToken&&t.set("nextToken",e.nextToken);const n=await Tu(`/web/knowledge-bases?${t.toString()}`,{signal:e.signal}),r=Lc(n);return{items:Array.isArray(r.items)?r.items.map(K7):[],nextToken:_r(r.nextToken)}}function VGe(e){return`${e.region}\0${e.id}`}async function HGe(e){var l;const t=[...new Set(e.regions.map(c=>c.trim()).filter(Boolean))],n=e.nextTokens?t.filter(c=>{var u;return!!((u=e.nextTokens)!=null&&u[c])}):t;if(n.length===0)return{items:[],nextTokens:{},failures:[]};const r=await Promise.allSettled(n.map(async c=>{var u;return{region:c,page:await zGe({region:c,projectName:e.projectName,nextToken:(u=e.nextTokens)==null?void 0:u[c],pageSize:e.pageSize,signal:e.signal})}}));if((l=e.signal)!=null&&l.aborted)throw new DOMException("Aborted","AbortError");const i=[],s={},a=new Map;if(r.forEach((c,u)=>{var f;const d=n[u];if(c.status==="rejected"){const h=(f=e.nextTokens)==null?void 0:f[d];h&&(s[d]=h),i.push({region:d,error:c.reason instanceof Error?c.reason:new Error("读取知识库失败")});return}c.value.page.nextToken&&(s[d]=c.value.page.nextToken),c.value.page.items.forEach(h=>{const m=h.region?h:{...h,region:d};a.set(VGe(m),m)})}),i.length===n.length)throw new Yhe(i);return{items:[...a.values()],nextTokens:s,failures:i}}function qGe(e){return Tu("/web/knowledge-bases",{method:"POST",body:JSON.stringify(e)},Zi).then(K7)}function XGe(e,t,n){return Tu(`/web/knowledge-bases/${encodeURIComponent(e)}${y0(t)}`,{method:"PATCH",body:JSON.stringify(n)}).then(K7)}function GGe(e,t){return Tu(`/web/knowledge-bases/${encodeURIComponent(e)}${y0(t)}`,{method:"DELETE"},Zi)}async function WGe(e,t){var s;const n=new URLSearchParams({region:t.region,offset:String(t.offset??0),limit:String(t.limit??30)});(s=t.documentType)!=null&&s.trim()&&n.set("documentType",t.documentType.trim());const r=await Tu(`/web/knowledge-bases/${encodeURIComponent(e)}/documents?${n.toString()}`,{signal:t.signal}),i=Lc(r);return{items:Array.isArray(i.items)?i.items.map(gE):[],offset:Uw(i.offset,0),limit:Uw(i.limit,t.limit??30),hasMore:i.hasMore===!0}}async function YGe(e,t,n){const r=new URLSearchParams({region:n.region,offset:String(n.offset??0),limit:String(n.limit??20)}),i=await Tu(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/${encodeURIComponent(t)}/preview?${r.toString()}`,{signal:n.signal}),s=Lc(i);return{document:gE(s.document),chunks:Array.isArray(s.chunks)?s.chunks.map(FGe):[],sourceMarkdown:_r(s.sourceMarkdown),offset:Uw(s.offset,0),limit:Uw(s.limit,n.limit??20),hasMore:s.hasMore===!0}}function ZGe(e,t,n){return Tu(`/web/knowledge-bases/${encodeURIComponent(e)}/documents${y0(t)}`,{method:"POST",body:JSON.stringify(n)},Zi).then(gE)}async function KGe(e,t,n){const r=await Tu(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/web-preview${y0(t)}`,{method:"POST",body:JSON.stringify({sourceType:"url",url:n.url})},Zi),i=Lc(r);return{name:_r(i.name),url:_r(i.url),sourceMarkdown:_r(i.sourceMarkdown)}}function JGe(e,t,n){var i,s;const r=new FormData;return r.set("file",n.file),(i=n.name)!=null&&i.trim()&&r.set("name",n.name.trim()),(s=n.documentType)!=null&&s.trim()&&r.set("documentType",n.documentType.trim()),n.metadata&&r.set("metadata",JSON.stringify(n.metadata)),Tu(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/upload${y0(t)}`,{method:"POST",body:r},Zi).then(gE)}function eWe(e,t,n,r){return Tu(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/${encodeURIComponent(t)}${y0(n)}`,{method:"PATCH",body:JSON.stringify(r)}).then(gE)}function tWe(e,t,n){return Tu(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/${encodeURIComponent(t)}${y0(n)}`,{method:"DELETE"},Zi)}function bE({className:e="",title:t,status:n,description:r,metadata:i,detailAction:s,action:a,auxiliaryAction:l}){return o.jsxs(W7,{className:`library-resource-card ${e}`.trim(),activateLabel:`${s.label} ${t}`,onActivate:s.disabled?void 0:s.onClick,footer:o.jsx(Uhe,{items:i.map(c=>({label:c.label,value:c.value,title:c.title,hideLabel:!0}))}),actions:o.jsxs(o.Fragment,{children:[l?o.jsx(X4,{className:"library-resource-card__auxiliary-action",label:`${l.label} ${t}`,tone:"secondary",disabled:l.disabled,title:l.title??l.label,onClick:l.onClick,children:l.icon}):null,a?o.jsx(X4,{label:`${a.label} ${t}`,icon:a.icon,disabled:a.disabled,title:a.title,onClick:a.onClick}):null]}),children:[o.jsx(Y7,{leading:o.jsx(d1,{seed:t}),title:t,titleText:t,status:n}),o.jsx(Z7,{title:r,children:r})]})}function gMt(){}function ZX(e){const t=[],n=String(e||"");let r=n.indexOf(","),i=0,s=!1;for(;!s;){r===-1&&(r=n.length,s=!0);const a=n.slice(i,r).trim();(a||!s)&&t.push(a),i=r+1,r=n.indexOf(",",i)}return t}function Khe(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const nWe=/[$_\p{ID_Start}]/u,rWe=/[$_\u{200C}\u{200D}\p{ID_Continue}]/u,iWe=/[-$_\u{200C}\u{200D}\p{ID_Continue}]/u,sWe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,aWe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Jhe={};function bMt(e){return e?nWe.test(String.fromCodePoint(e)):!1}function yMt(e,t){const r=(t||Jhe).jsx?iWe:rWe;return e?r.test(String.fromCodePoint(e)):!1}function KX(e,t){return(Jhe.jsx?aWe:sWe).test(e)}const oWe=/[ \t\n\f\r]/g;function lWe(e){return typeof e=="object"?e.type==="text"?JX(e.value):!1:JX(e)}function JX(e){return e.replace(oWe,"")===""}let yE=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};yE.prototype.normal={};yE.prototype.property={};yE.prototype.space=void 0;function epe(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new yE(n,r,t)}function Fw(e){return e.toLowerCase()}class il{constructor(t,n){this.attribute=n,this.property=t}}il.prototype.attribute="";il.prototype.booleanish=!1;il.prototype.boolean=!1;il.prototype.commaOrSpaceSeparated=!1;il.prototype.commaSeparated=!1;il.prototype.defined=!1;il.prototype.mustUseProperty=!1;il.prototype.number=!1;il.prototype.overloadedBoolean=!1;il.prototype.property="";il.prototype.spaceSeparated=!1;il.prototype.space=void 0;let cWe=0;const Yn=O0(),$s=O0(),W4=O0(),xt=O0(),ki=O0(),xy=O0(),yl=O0();function O0(){return 2**++cWe}const Y4=Object.freeze(Object.defineProperty({__proto__:null,boolean:Yn,booleanish:$s,commaOrSpaceSeparated:yl,commaSeparated:xy,number:xt,overloadedBoolean:W4,spaceSeparated:ki},Symbol.toStringTag,{value:"Module"})),Z5=Object.keys(Y4);class J7 extends il{constructor(t,n,r,i){let s=-1;if(super(t,n),eG(this,"space",i),typeof r=="number")for(;++s4&&n.slice(0,4)==="data"&&pWe.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(tG,gWe);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!tG.test(s)){let a=s.replace(hWe,mWe);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=J7}return new i(r,t)}function mWe(e){return"-"+e.toLowerCase()}function gWe(e){return e.charAt(1).toUpperCase()}const OE=epe([tpe,uWe,ipe,spe,ape],"html"),hm=epe([tpe,dWe,ipe,spe,ape],"svg");function nG(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function ope(e){return e.join(" ").trim()}var eB={},rG=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,bWe=/\n/g,yWe=/^\s*/,OWe=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,xWe=/^:\s*/,vWe=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,wWe=/^[;\s]*/,SWe=/^\s+|\s+$/g,EWe=` `,iG="/",sG="*",Wm="",kWe="comment",_We="declaration";function TWe(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(g){var b=g.match(bWe);b&&(n+=b.length);var y=g.lastIndexOf(EWe);r=~y?g.length-y:r+g.length}function s(){var g={line:n,column:r};return function(b){return b.position=new a(g),u(),b}}function a(g){this.start=g,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function l(g){var b=new Error(t.source+":"+n+":"+r+": "+g);if(b.reason=g,b.filename=t.source,b.line=n,b.column=r,b.source=e,!t.silent)throw b}function c(g){var b=g.exec(e);if(b){var y=b[0];return i(y),e=e.slice(y.length),b}}function u(){c(yWe)}function d(g){var b;for(g=g||[];b=f();)b!==!1&&g.push(b);return g}function f(){var g=s();if(!(iG!=e.charAt(0)||sG!=e.charAt(1))){for(var b=2;Wm!=e.charAt(b)&&(sG!=e.charAt(b)||iG!=e.charAt(b+1));)++b;if(b+=2,Wm===e.charAt(b-1))return l("End of comment missing");var y=e.slice(2,b-2);return r+=2,i(y),e=e.slice(b),r+=2,g({type:kWe,comment:y})}}function h(){var g=s(),b=c(OWe);if(b){if(f(),!c(xWe))return l("property missing ':'");var y=c(vWe),O=g({type:_We,property:aG(b[0].replace(rG,Wm)),value:y?aG(y[0].replace(rG,Wm)):Wm});return c(wWe),O}}function m(){var g=[];d(g);for(var b;b=h();)b!==!1&&(g.push(b),d(g));return g}return u(),m()}function aG(e){return e?e.replace(SWe,Wm):Wm}var CWe=TWe,AWe=op&&op.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(eB,"__esModule",{value:!0});eB.default=jWe;const NWe=AWe(CWe);function jWe(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,NWe.default)(e),i=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:a,value:l}=s;i?t(a,l,s):l&&(n=n||{},n[a]=l)}),n}var Ej={};Object.defineProperty(Ej,"__esModule",{value:!0});Ej.camelCase=void 0;var RWe=/^--[a-zA-Z0-9_-]+$/,IWe=/-([a-z])/g,DWe=/^[^-]+$/,PWe=/^-(webkit|moz|ms|o|khtml)-/,MWe=/^-(ms)-/,LWe=function(e){return!e||DWe.test(e)||RWe.test(e)},$We=function(e,t){return t.toUpperCase()},oG=function(e,t){return"".concat(t,"-")},BWe=function(e,t){return t===void 0&&(t={}),LWe(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(MWe,oG):e=e.replace(PWe,oG),e.replace(IWe,$We))};Ej.camelCase=BWe;var QWe=op&&op.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},UWe=QWe(eB),FWe=Ej;function Z4(e,t){var n={};return!e||typeof e!="string"||(0,UWe.default)(e,function(r,i){r&&i&&(n[(0,FWe.camelCase)(r,t)]=i)}),n}Z4.default=Z4;var zWe=Z4;const VWe=N1(zWe),kj=lpe("end"),Td=lpe("start");function lpe(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function HWe(e){const t=Td(e),n=kj(e);if(t&&n)return{start:t,end:n}}function jv(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?lG(e.position):"start"in e||"end"in e?lG(e):"line"in e||"column"in e?K4(e):""}function K4(e){return cG(e&&e.line)+":"+cG(e&&e.column)}function lG(e){return K4(e&&e.start)+"-"+K4(e&&e.end)}function cG(e){return e&&typeof e=="number"?e:1}class no extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?s.ruleId=r:(s.source=r.slice(0,c),s.ruleId=r.slice(c+1))}if(!s.place&&s.ancestors&&s.ancestors){const c=s.ancestors[s.ancestors.length-1];c&&(s.place=c.position)}const l=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=jv(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}no.prototype.file="";no.prototype.name="";no.prototype.reason="";no.prototype.message="";no.prototype.stack="";no.prototype.column=void 0;no.prototype.line=void 0;no.prototype.ancestors=void 0;no.prototype.cause=void 0;no.prototype.fatal=void 0;no.prototype.place=void 0;no.prototype.ruleId=void 0;no.prototype.source=void 0;const tB={}.hasOwnProperty,qWe=new Map,XWe=/[A-Z]/g,GWe=new Set(["table","tbody","thead","tfoot","tr"]),WWe=new Set(["td","th"]),cpe="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function YWe(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=iYe(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=rYe(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?hm:OE,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=upe(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function upe(e,t,n){if(t.type==="element")return ZWe(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return KWe(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return eYe(e,t,n);if(t.type==="mdxjsEsm")return JWe(e,t);if(t.type==="root")return tYe(e,t,n);if(t.type==="text")return nYe(e,t)}function ZWe(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=hm,e.schema=i),e.ancestors.push(t);const s=fpe(e,t.tagName,!1),a=sYe(e,t);let l=rB(e,t);return GWe.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!lWe(c):!0})),dpe(e,a,s,t),nB(a,l),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function KWe(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}zw(e,t.position)}function JWe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);zw(e,t.position)}function eYe(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=hm,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:fpe(e,t.name,!0),a=aYe(e,t),l=rB(e,t);return dpe(e,a,s,t),nB(a,l),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function tYe(e,t,n){const r={};return nB(r,rB(e,t)),e.create(t,e.Fragment,r,n)}function nYe(e,t){return t.value}function dpe(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function nB(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function rYe(e,t,n){return r;function r(i,s,a,l){const u=Array.isArray(a.children)?n:t;return l?u(s,a,l):u(s,a)}}function iYe(e,t){return n;function n(r,i,s,a){const l=Array.isArray(s.children),c=Td(r);return t(i,s,a,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function sYe(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&tB.call(t.properties,i)){const s=oYe(e,i,t.properties[i]);if(s){const[a,l]=s;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&WWe.has(t.tagName)?r=l:n[a]=l}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function aYe(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const a=s.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else zw(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,s=e.evaluater.evaluateExpression(l.expression)}else zw(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function rB(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:qWe;for(;++ri?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s0?(Ll(e,e.length,0,t),e):t}const fG={}.hasOwnProperty;function ppe(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function mu(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const mo=pm(/[A-Za-z]/),Za=pm(/[\dA-Za-z]/),gYe=pm(/[#-'*+\--9=?A-Z^-~]/);function XC(e){return e!==null&&(e<32||e===127)}const J4=pm(/\d/),bYe=pm(/[\dA-Fa-f]/),yYe=pm(/[!-/:-@[-`{-~]/);function vn(e){return e!==null&&e<-2}function wi(e){return e!==null&&(e<0||e===32)}function br(e){return e===-2||e===-1||e===32}const _j=pm(new RegExp("\\p{P}|\\p{S}","u")),Hg=pm(/\s/);function pm(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function lO(e){const t=[];let n=-1,r=0,i=0;for(;++n55295&&s<57344){const l=e.charCodeAt(n+1);s<56320&&l>56319&&l<57344?(a=String.fromCharCode(s,l),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Rr(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(c){return br(c)?(e.enter(n),l(c)):t(c)}function l(c){return br(c)&&s++a))return;const k=t.events.length;let _=k,C,T;for(;_--;)if(t.events[_][0]==="exit"&&t.events[_][1].type==="chunkFlow"){if(C){T=t.events[_][1].end;break}C=!0}for(O(r),E=k;Ex;){const S=n[w];t.containerState=S[1],S[0].exit.call(t,e)}n.length=x}function v(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function SYe(e,t,n){return Rr(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function f1(e){if(e===null||wi(e)||Hg(e))return 1;if(_j(e))return 2}function Tj(e,t,n){const r=[];let i=-1;for(;++i1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};pG(f,-c),pG(h,c),a={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},s={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Oc(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Oc(u,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),u=Oc(u,Tj(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Oc(u,[["exit",s,t],["enter",l,t],["exit",l,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Oc(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,Ll(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n0&&br(E)?Rr(e,v,"linePrefix",s+1)(E):v(E)}function v(E){return E===null||vn(E)?e.check(mG,b,w)(E):(e.enter("codeFlowValue"),x(E))}function x(E){return E===null||vn(E)?(e.exit("codeFlowValue"),v(E)):(e.consume(E),x)}function w(E){return e.exit("codeFenced"),t(E)}function S(E,k,_){let C=0;return T;function T(M){return E.enter("lineEnding"),E.consume(M),E.exit("lineEnding"),A}function A(M){return E.enter("codeFencedFence"),br(M)?Rr(E,j,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):j(M)}function j(M){return M===l?(E.enter("codeFencedFenceSequence"),L(M)):_(M)}function L(M){return M===l?(C++,E.consume(M),L):C>=a?(E.exit("codeFencedFenceSequence"),br(M)?Rr(E,I,"whitespace")(M):I(M)):_(M)}function I(M){return M===null||vn(M)?(E.exit("codeFencedFence"),k(M)):_(M)}}}function PYe(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const J5={name:"codeIndented",tokenize:LYe},MYe={partial:!0,tokenize:$Ye};function LYe(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),Rr(e,s,"linePrefix",5)(u)}function s(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):vn(u)?e.attempt(MYe,a,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||vn(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function $Ye(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):vn(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):Rr(e,s,"linePrefix",5)(a)}function s(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):vn(a)?i(a):n(a)}}const BYe={name:"codeText",previous:UYe,resolve:QYe,tokenize:FYe};function QYe(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&ax(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),ax(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ax(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function xpe(e,t,n,r,i,s,a,l,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return f;function f(O){return O===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(O),e.exit(s),h):O===null||O===32||O===41||XC(O)?n(O):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),b(O))}function h(O){return O===62?(e.enter(s),e.consume(O),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),m(O))}function m(O){return O===62?(e.exit("chunkString"),e.exit(l),h(O)):O===null||O===60||vn(O)?n(O):(e.consume(O),O===92?g:m)}function g(O){return O===60||O===62||O===92?(e.consume(O),m):m(O)}function b(O){return!d&&(O===null||O===41||wi(O))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(O)):d999||m===null||m===91||m===93&&!c||m===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(m):m===93?(e.exit(s),e.enter(i),e.consume(m),e.exit(i),e.exit(r),t):vn(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(m))}function f(m){return m===null||m===91||m===93||vn(m)||l++>999?(e.exit("chunkString"),d(m)):(e.consume(m),c||(c=!br(m)),m===92?h:f)}function h(m){return m===91||m===92||m===93?(e.consume(m),l++,f):f(m)}}function wpe(e,t,n,r,i,s){let a;return l;function l(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),a=h===40?41:h,c):n(h)}function c(h){return h===a?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(s),u(h))}function u(h){return h===a?(e.exit(s),c(a)):h===null?n(h):vn(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Rr(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===a||h===null||vn(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?f:d)}function f(h){return h===a||h===92?(e.consume(h),d):d(h)}}function Rv(e,t){let n;return r;function r(i){return vn(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):br(i)?Rr(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const YYe={name:"definition",tokenize:KYe},ZYe={partial:!0,tokenize:JYe};function KYe(e,t,n){const r=this;let i;return s;function s(m){return e.enter("definition"),a(m)}function a(m){return vpe.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function l(m){return i=mu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),c):n(m)}function c(m){return wi(m)?Rv(e,u)(m):u(m)}function u(m){return xpe(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function d(m){return e.attempt(ZYe,f,f)(m)}function f(m){return br(m)?Rr(e,h,"whitespace")(m):h(m)}function h(m){return m===null||vn(m)?(e.exit("definition"),r.parser.defined.push(i),t(m)):n(m)}}function JYe(e,t,n){return r;function r(l){return wi(l)?Rv(e,i)(l):n(l)}function i(l){return wpe(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function s(l){return br(l)?Rr(e,a,"whitespace")(l):a(l)}function a(l){return l===null||vn(l)?t(l):n(l)}}const eZe={name:"hardBreakEscape",tokenize:tZe};function tZe(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return vn(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const nZe={name:"headingAtx",resolve:rZe,tokenize:iZe};function rZe(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Ll(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function iZe(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&r++<6?(e.consume(d),a):d===null||wi(d)?(e.exit("atxHeadingSequence"),l(d)):n(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||vn(d)?(e.exit("atxHeading"),t(d)):br(d)?Rr(e,l,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),l(d))}function u(d){return d===null||d===35||wi(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),u)}}const sZe=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],bG=["pre","script","style","textarea"],aZe={concrete:!0,name:"htmlFlow",resolveTo:cZe,tokenize:uZe},oZe={partial:!0,tokenize:fZe},lZe={partial:!0,tokenize:dZe};function cZe(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function uZe(e,t,n){const r=this;let i,s,a,l,c;return u;function u(B){return d(B)}function d(B){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(B),f}function f(B){return B===33?(e.consume(B),h):B===47?(e.consume(B),s=!0,b):B===63?(e.consume(B),i=3,r.interrupt?t:$):mo(B)?(e.consume(B),a=String.fromCharCode(B),y):n(B)}function h(B){return B===45?(e.consume(B),i=2,m):B===91?(e.consume(B),i=5,l=0,g):mo(B)?(e.consume(B),i=4,r.interrupt?t:$):n(B)}function m(B){return B===45?(e.consume(B),r.interrupt?t:$):n(B)}function g(B){const V="CDATA[";return B===V.charCodeAt(l++)?(e.consume(B),l===V.length?r.interrupt?t:j:g):n(B)}function b(B){return mo(B)?(e.consume(B),a=String.fromCharCode(B),y):n(B)}function y(B){if(B===null||B===47||B===62||wi(B)){const V=B===47,Z=a.toLowerCase();return!V&&!s&&bG.includes(Z)?(i=1,r.interrupt?t(B):j(B)):sZe.includes(a.toLowerCase())?(i=6,V?(e.consume(B),O):r.interrupt?t(B):j(B)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):s?v(B):x(B))}return B===45||Za(B)?(e.consume(B),a+=String.fromCharCode(B),y):n(B)}function O(B){return B===62?(e.consume(B),r.interrupt?t:j):n(B)}function v(B){return br(B)?(e.consume(B),v):T(B)}function x(B){return B===47?(e.consume(B),T):B===58||B===95||mo(B)?(e.consume(B),w):br(B)?(e.consume(B),x):T(B)}function w(B){return B===45||B===46||B===58||B===95||Za(B)?(e.consume(B),w):S(B)}function S(B){return B===61?(e.consume(B),E):br(B)?(e.consume(B),S):x(B)}function E(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),c=B,k):br(B)?(e.consume(B),E):_(B)}function k(B){return B===c?(e.consume(B),c=null,C):B===null||vn(B)?n(B):(e.consume(B),k)}function _(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||wi(B)?S(B):(e.consume(B),_)}function C(B){return B===47||B===62||br(B)?x(B):n(B)}function T(B){return B===62?(e.consume(B),A):n(B)}function A(B){return B===null||vn(B)?j(B):br(B)?(e.consume(B),A):n(B)}function j(B){return B===45&&i===2?(e.consume(B),N):B===60&&i===1?(e.consume(B),D):B===62&&i===4?(e.consume(B),H):B===63&&i===3?(e.consume(B),$):B===93&&i===5?(e.consume(B),F):vn(B)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(oZe,z,L)(B)):B===null||vn(B)?(e.exit("htmlFlowData"),L(B)):(e.consume(B),j)}function L(B){return e.check(lZe,I,z)(B)}function I(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),M}function M(B){return B===null||vn(B)?L(B):(e.enter("htmlFlowData"),j(B))}function N(B){return B===45?(e.consume(B),$):j(B)}function D(B){return B===47?(e.consume(B),a="",Q):j(B)}function Q(B){if(B===62){const V=a.toLowerCase();return bG.includes(V)?(e.consume(B),H):j(B)}return mo(B)&&a.length<8?(e.consume(B),a+=String.fromCharCode(B),Q):j(B)}function F(B){return B===93?(e.consume(B),$):j(B)}function $(B){return B===62?(e.consume(B),H):B===45&&i===2?(e.consume(B),$):j(B)}function H(B){return B===null||vn(B)?(e.exit("htmlFlowData"),z(B)):(e.consume(B),H)}function z(B){return e.exit("htmlFlow"),t(B)}}function dZe(e,t,n){const r=this;return i;function i(a){return vn(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function fZe(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(xE,t,n)}}const hZe={name:"htmlText",tokenize:pZe};function pZe(e,t,n){const r=this;let i,s,a;return l;function l($){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume($),c}function c($){return $===33?(e.consume($),u):$===47?(e.consume($),S):$===63?(e.consume($),x):mo($)?(e.consume($),_):n($)}function u($){return $===45?(e.consume($),d):$===91?(e.consume($),s=0,g):mo($)?(e.consume($),v):n($)}function d($){return $===45?(e.consume($),m):n($)}function f($){return $===null?n($):$===45?(e.consume($),h):vn($)?(a=f,D($)):(e.consume($),f)}function h($){return $===45?(e.consume($),m):f($)}function m($){return $===62?N($):$===45?h($):f($)}function g($){const H="CDATA[";return $===H.charCodeAt(s++)?(e.consume($),s===H.length?b:g):n($)}function b($){return $===null?n($):$===93?(e.consume($),y):vn($)?(a=b,D($)):(e.consume($),b)}function y($){return $===93?(e.consume($),O):b($)}function O($){return $===62?N($):$===93?(e.consume($),O):b($)}function v($){return $===null||$===62?N($):vn($)?(a=v,D($)):(e.consume($),v)}function x($){return $===null?n($):$===63?(e.consume($),w):vn($)?(a=x,D($)):(e.consume($),x)}function w($){return $===62?N($):x($)}function S($){return mo($)?(e.consume($),E):n($)}function E($){return $===45||Za($)?(e.consume($),E):k($)}function k($){return vn($)?(a=k,D($)):br($)?(e.consume($),k):N($)}function _($){return $===45||Za($)?(e.consume($),_):$===47||$===62||wi($)?C($):n($)}function C($){return $===47?(e.consume($),N):$===58||$===95||mo($)?(e.consume($),T):vn($)?(a=C,D($)):br($)?(e.consume($),C):N($)}function T($){return $===45||$===46||$===58||$===95||Za($)?(e.consume($),T):A($)}function A($){return $===61?(e.consume($),j):vn($)?(a=A,D($)):br($)?(e.consume($),A):C($)}function j($){return $===null||$===60||$===61||$===62||$===96?n($):$===34||$===39?(e.consume($),i=$,L):vn($)?(a=j,D($)):br($)?(e.consume($),j):(e.consume($),I)}function L($){return $===i?(e.consume($),i=void 0,M):$===null?n($):vn($)?(a=L,D($)):(e.consume($),L)}function I($){return $===null||$===34||$===39||$===60||$===61||$===96?n($):$===47||$===62||wi($)?C($):(e.consume($),I)}function M($){return $===47||$===62||wi($)?C($):n($)}function N($){return $===62?(e.consume($),e.exit("htmlTextData"),e.exit("htmlText"),t):n($)}function D($){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume($),e.exit("lineEnding"),Q}function Q($){return br($)?Rr(e,F,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):F($)}function F($){return e.enter("htmlTextData"),a($)}}const aB={name:"labelEnd",resolveAll:yZe,resolveTo:OZe,tokenize:xZe},mZe={tokenize:vZe},gZe={tokenize:wZe},bZe={tokenize:SZe};function yZe(e){let t=-1;const n=[];for(;++t=3&&(u===null||vn(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===i?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),br(u)?Rr(e,l,"whitespace")(u):l(u))}}const Mo={continuation:{tokenize:IZe},exit:PZe,name:"list",tokenize:RZe},NZe={partial:!0,tokenize:MZe},jZe={partial:!0,tokenize:DZe};function RZe(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return l;function l(m){const g=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:J4(m)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),m===42||m===45?e.check(iT,n,u)(m):u(m);if(!r.interrupt||m===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(m)}return n(m)}function c(m){return J4(m)&&++a<10?(e.consume(m),c):(!r.interrupt||a<2)&&(r.containerState.marker?m===r.containerState.marker:m===41||m===46)?(e.exit("listItemValue"),u(m)):n(m)}function u(m){return e.enter("listItemMarker"),e.consume(m),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||m,e.check(xE,r.interrupt?n:d,e.attempt(NZe,h,f))}function d(m){return r.containerState.initialBlankLine=!0,s++,h(m)}function f(m){return br(m)?(e.enter("listItemPrefixWhitespace"),e.consume(m),e.exit("listItemPrefixWhitespace"),h):n(m)}function h(m){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(m)}}function IZe(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(xE,i,s);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Rr(e,t,"listItemIndent",r.containerState.size+1)(l)}function s(l){return r.containerState.furtherBlankLines||!br(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(jZe,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,Rr(e,e.attempt(Mo,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function DZe(e,t,n){const r=this;return Rr(e,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(s):n(s)}}function PZe(e){e.exit(this.containerState.type)}function MZe(e,t,n){const r=this;return Rr(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!br(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const yG={name:"setextUnderline",resolveTo:LZe,tokenize:$Ze};function LZe(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",a,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function $Ze(e,t,n){const r=this;let i;return s;function s(u){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),i=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===i?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),br(u)?Rr(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||vn(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const BZe={tokenize:QZe};function QZe(e){const t=this,n=e.attempt(xE,r,e.attempt(this.parser.constructs.flowInitial,i,Rr(e,e.attempt(this.parser.constructs.flow,i,e.attempt(HYe,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const UZe={resolveAll:Epe()},FZe=Spe("string"),zZe=Spe("text");function Spe(e){return{resolveAll:Epe(e==="text"?VZe:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,a,l);return a;function a(d){return u(d)?s(d):l(d)}function l(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),s(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const f=i[d];let h=-1;if(f)for(;++h-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}s>0&&a.push(e[i].slice(0,s))}return a}function rKe(e,t){let n=-1;const r=[];let i;for(;++n0){const _e=Pe.tokenStack[Pe.tokenStack.length-1];(_e[1]||xG).call(Pe,void 0,_e[0])}for(ue.position={start:Bh(re.length>0?re[0][1].start:{line:1,column:1,offset:0}),end:Bh(re.length>0?re[re.length-2][1].end:{line:1,column:1,offset:0})},W=-1;++W30)throw new Error("ECharts option nesting is too deep");if(typeof e=="number"&&!Number.isFinite(e))throw new Error("ECharts option contains a non-finite number");if(typeof e=="string"&&Hot.test(e.trim()))throw new Error("ECharts option contains an external resource");if(Array.isArray(e)){for(const n of e)iA(n,t+1);return}if(Wx(e))for(const[n,r]of Object.entries(e)){if(Vot.has(n))throw new Error("ECharts option contains an unsafe key");iA(r,t+1)}}function qot(e){var r;const t=e.trim(),n=t.match(/^(?:(?:const|let|var)\s+)?option\s*=\s*([\s\S]*?)\s*;?$/);return((r=n==null?void 0:n[1])==null?void 0:r.trim())||t}function Xot(e,t){let n=1,r="",i=!1,s=!1,a=!1;for(let l=t+1;lr+2)throw new Error("Invalid ECharts gradient argument count");const i=n.slice(0,r).map(Got),s=n[r],a=n[r+1]??!1;if(!Array.isArray(s)||typeof a!="boolean")throw new Error("Invalid ECharts gradient data");return e==="linear"?{type:e,x:i[0],y:i[1],x2:i[2],y2:i[3],colorStops:s,global:a}:{type:e,x:i[0],y:i[1],r:i[2],colorStops:s,global:a}}function Yot(e,t){const n=/^(?:new\s+)?echarts\.graphic\.(LinearGradient|RadialGradient)\s*\(/;let r="",i=!1,s=!1,a=!1;for(let l=t;lzot)throw new Error("ECharts option is too large");const n=Zot(qot(e));let r;try{r=Nge.parse(n)}catch(a){throw/\bfunction\s*\(|=>/.test(n)?new Error("ECharts function callbacks are not supported"):a}if(!Wx(r))throw new Error("ECharts option must be a data object");iA(r);const i={...r};i.aria={...Wx(i.aria)?i.aria:{},enabled:!0};const s=i.tooltip;return Wx(s)?i.tooltip={...s,renderMode:"richText"}:Array.isArray(s)&&(i.tooltip=s.map(a=>Wx(a)?{...a,renderMode:"richText"}:a)),t&&(i.animation=!1),i}let OD;function Jot(){return OD??(OD=dd(()=>import("../visualizations/echarts/index-CGT341lL.js"),[]).catch(e=>{throw OD=void 0,e})),OD}function elt({source:e}){const t=p.useRef(null),[n,r]=p.useState(!1),[i,s]=p.useState("");return p.useEffect(()=>{let a=!1,l,c,u;r(!1);try{u=Kot(e,window.matchMedia("(prefers-reduced-motion: reduce)").matches),s("")}catch{s("ECharts 配置不是有效且安全的数据对象,请切换到代码检查内容。");return}return Jot().then(d=>{const f=t.current;a||!f||(l=d.init(f,void 0,{renderer:"svg"}),l.setOption(u,{notMerge:!0}),typeof ResizeObserver<"u"&&(c=new ResizeObserver(()=>l==null?void 0:l.resize()),c.observe(f)),r(!0))}).catch(()=>{l==null||l.dispose(),l=void 0,a||s("图表暂时无法渲染,请切换到代码检查内容。")}),()=>{a=!0,c==null||c.disconnect(),l==null||l.dispose()}},[e]),o.jsxs("div",{className:`echarts-diagram${i?" echarts-diagram--error":""}`,role:"img","aria-label":"ECharts 图表预览","aria-busy":!n&&!i,children:[o.jsx("div",{ref:t,className:"echarts-diagram__canvas",hidden:!!i}),!n&&!i?o.jsx("div",{className:"echarts-diagram__state","aria-live":"polite",children:o.jsx(En,{duration:2.2,spread:15,children:"正在渲染图表…"})}):null,i?o.jsx("p",{className:"echarts-diagram__error",role:"alert",children:i}):null]})}const tlt=p.memo(elt);let IW,DW=Promise.resolve(),nlt=0;function rlt(){return IW??(IW=dd(async()=>{const{default:e}=await import("../visualizations/mermaid/mermaid.core-B_GhFya9.js").then(t=>t.ay);return{default:e}},__vite__mapDeps([0,1])).then(({default:e})=>(e.initialize({startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,theme:"neutral"}),e))),IW}function ilt(e){const t=DW.then(async()=>{const n=await rlt(),r=`mermaid-diagram-${nlt+=1}`;return n.render(r,e)});return DW=t.then(()=>{},()=>{}),t}function slt({source:e}){const t=p.useRef(null),[n,r]=p.useState(null),[i,s]=p.useState(!1);return p.useEffect(()=>{let a=!1;return r(null),s(!1),ilt(e).then(l=>{a||r(l)}).catch(()=>{a||s(!0)}),()=>{a=!0}},[e]),p.useEffect(()=>{!(n!=null&&n.bindFunctions)||!t.current||n.bindFunctions(t.current)},[n]),i?o.jsx("div",{className:"mermaid-diagram mermaid-diagram--error",children:o.jsx("p",{className:"mermaid-diagram__error",role:"alert",children:"图表暂时无法渲染,请切换到代码查看 Mermaid 内容。"})}):n?o.jsx("div",{ref:t,className:"mermaid-diagram",role:"img","aria-label":"Mermaid 图表预览",dangerouslySetInnerHTML:{__html:n.svg}}):o.jsx("div",{className:"mermaid-diagram mermaid-diagram--loading","aria-live":"polite",children:o.jsx(En,{duration:2.2,spread:15,children:"正在渲染图表…"})})}const alt=p.memo(slt),olt="_SegmentedControl_1sl7d_1",llt="_SegmentedControlOption_1sl7d_140",clt="_SegmentedControlThumb_1sl7d_219",mL={SegmentedControl:olt,SegmentedControlOption:llt,SegmentedControlThumb:clt},Fs=({value:e,onChange:t,children:n,block:r,pill:i=!0,size:s="md",gutterSize:a,className:l,onClick:c,...u})=>{const d=p.useRef(null),f=p.useRef(null),h=p.useCallback(g=>{const b=d.current,y=f.current;if(!b||!y)return;const O=b==null?void 0:b.querySelector('[data-state="on"]');if(!O)return;const v=b.clientWidth;let x=Math.floor(O.clientWidth);const w=O.offsetLeft;if(v-(x+w)<2&&(x=x-1),y.style.width=`${Math.floor(x)}px`,y.style.transform=`translateX(${w}px)`,b.scrollWidth>v){const S=v*.15,E=b.scrollLeft,k=O.offsetLeft,_=k+x;(kE+v-S)&&g&&O.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})}},[]);Ele({ref:d,onResize:()=>{const g=f.current;if(!g)return;const b=g.style.transition;g.style.transition="",h(!1),g.style.transition=b}}),p.useLayoutEffect(()=>{const g=d.current,b=f.current;!g||!b||(h(!!b.style.transition),b.style.transition||wC(()=>{b.style.transition="width 300ms var(--cubic-enter), transform 300ms var(--cubic-enter)"}))},[h,e,s,a,i]);const m=g=>{g&&t&&t(g)};return o.jsxs(GLe,{ref:d,className:ur(mL.SegmentedControl,l),type:"single",value:e,loop:!1,onValueChange:m,onClick:c,"data-block":r?"":void 0,"data-pill":i?"":void 0,"data-size":s,"data-gutter-size":a,...u,children:[o.jsx("div",{className:mL.SegmentedControlThumb,ref:f}),n]})},ult=({children:e,...t})=>o.jsx(JLe,{className:mL.SegmentedControlOption,...t,onPointerEnter:_9,children:o.jsx("span",{className:"relative",children:e})});Fs.Option=ult;function dlt({children:e,label:t,language:n,source:r,streaming:i=!1}){const[s,a]=p.useState("preview"),l=i?"code":s;return o.jsxs("section",{className:"visualization-card","aria-label":`${t} 图表`,children:[o.jsx("div",{className:"visualization-card__toolbar",children:o.jsxs(Fs,{className:"visualization-card__tabs",value:l,size:"sm",gutterSize:"sm",pill:!1,"aria-label":`${t} 显示方式`,onChange:c=>{i||a(c)},children:[o.jsx(Fs.Option,{value:"preview",disabled:i,children:"预览"}),o.jsx(Fs.Option,{value:"code",children:"代码"})]})}),o.jsx("div",{className:"visualization-card__body",children:l==="code"?o.jsx("pre",{className:"visualization-card__code",children:o.jsx("code",{className:`language-${n}`,children:r})}):e})]})}const flt=p.memo(dlt);function hlt(e){const t=e==null?void 0:e.trim().toLowerCase();if(t==="mermaid")return"mermaid";if(t==="echart"||t==="echarts")return"echarts"}const jge=[".mp4",".webm",".mov",".m4v",".ogg",".avi"];function gL(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(gL).join(""):p.isValidElement(e)?gL(e.props.children):""}function plt(e){var r;const t=p.Children.toArray(e)[0];if(!p.isValidElement(t))return;const n=(r=t.props.className)==null?void 0:r.split(/\s+/).find(i=>i.startsWith("language-"));return hlt(n==null?void 0:n.slice(9))}function Rge(e){if(!e)return!1;try{const t=e.toLowerCase();return jge.some(n=>t.includes(n))}catch{return!1}}function mlt(e){var r;const t=(r=e==null?void 0:e.properties)==null?void 0:r.href;if(!t)return!1;if(Rge(t))return!0;const n=e==null?void 0:e.children;if(n&&Array.isArray(n)){const i=n.map(s=>(s==null?void 0:s.value)||"").join("").toLowerCase();return jge.some(s=>i.includes(s))}return!1}function glt({text:e,className:t,allowRawHtml:n=!0,streaming:r=!1}){const[i,s]=p.useState(null),a=(u,d)=>{if(u.src)return u.src;if(d){const f=m=>{var g;if(!m)return null;if(m.type==="source"&&((g=m.properties)!=null&&g.src))return m.properties.src;if(m.children)for(const b of m.children){const y=f(b);if(y)return y}return null},h=f({children:d});if(h)return h}return""},l=u=>{try{const f=new URL(u).pathname.split("/");return f[f.length-1]||"video.mp4"}catch{return"video.mp4"}},c=u=>u?Array.isArray(u)?u.map(d=>(d==null?void 0:d.value)||"").join("")||"video":(u==null?void 0:u.value)||"video":"video";return o.jsxs("div",{className:t?`md ${t}`:"md",children:[o.jsx(RJe,{remarkPlugins:[Xtt],rehypePlugins:n?[Aot,hW]:[hW],components:{pre:({node:u,children:d,...f})=>{const h=plt(d);if(h==="mermaid"||h==="echarts"){const m=gL(d).replace(/\n$/,"");return o.jsx(flt,{label:h==="mermaid"?"Mermaid":"ECharts",language:h,source:m,streaming:r,children:h==="mermaid"?o.jsx(alt,{source:m}):o.jsx(tlt,{source:m})})}return o.jsx("pre",{...f,children:d})},a:({node:u,...d})=>{const f=d.href;if(f&&(Rge(f)||mlt(u))){const h=f,m=c(u==null?void 0:u.children);return o.jsxs("div",{className:"video-container",children:[o.jsxs("button",{type:"button",className:"video-preview-trigger","aria-label":`点击播放视频: ${m}`,onClick:()=>s({src:h,title:m}),children:[o.jsx("video",{src:h,playsInline:!0,className:"video-thumbnail",preload:"metadata"}),o.jsx("span",{className:"video-preview-hint","aria-hidden":"true",children:o.jsx(uy,{})})]}),o.jsx("div",{className:"video-caption",children:o.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"video-link-text",children:m})})]})}return o.jsx("a",{...d,target:"_blank",rel:"noopener noreferrer"})},img:({node:u,src:d,alt:f,...h})=>{const m=o.jsx("img",{...h,src:d,alt:f??"",loading:"lazy"});return d?o.jsx(Eae,{src:d,children:o.jsxs("button",{type:"button",className:"image-preview-trigger","aria-label":`放大预览:${f||"图片"}`,children:[m,o.jsx("span",{className:"image-preview-hint","aria-hidden":"true",children:o.jsx(uy,{})})]})}):m},video:({node:u,src:d,children:f,...h})=>{const m=a({src:d},f);return m?o.jsx("div",{className:"video-container",children:o.jsxs("button",{type:"button",className:"video-preview-trigger","aria-label":"点击放大视频",onClick:()=>s({src:m}),children:[o.jsx("video",{src:m,...h,playsInline:!0,className:"video-thumbnail",children:f}),o.jsx("span",{className:"video-preview-hint","aria-hidden":"true",children:o.jsx(uy,{})})]})}):o.jsx("video",{src:d,controls:!0,playsInline:!0,className:"video-inline",...h,children:f})}},children:e}),i&&o.jsx("div",{className:"video-viewer-backdrop",role:"dialog","aria-modal":"true","aria-label":"视频预览",onClick:()=>s(null),children:o.jsxs("div",{className:"video-viewer",onClick:u=>u.stopPropagation(),children:[o.jsxs("div",{className:"video-viewer-header",children:[o.jsx("div",{className:"video-viewer-title",children:i.title||l(i.src)}),o.jsxs("nav",{className:"video-viewer-nav",children:[o.jsx("a",{href:i.src,download:i.title||l(i.src),"aria-label":"下载视频",title:"下载视频",className:"video-viewer-download",children:o.jsx(NN,{})}),o.jsx("button",{type:"button",className:"video-viewer-close","aria-label":"关闭",onClick:()=>s(null),children:o.jsx(Oa,{})})]})]}),o.jsx("div",{className:"video-viewer-body",children:o.jsx("video",{src:i.src,controls:!0,autoPlay:!0,playsInline:!0,className:"video-fullscreen"})})]})})]})}const xu=p.memo(glt),blt="未知来源",ylt="未知创建者";function Qv(e){return(e==null?void 0:e.trim())||blt}function Ige(e){return(e==null?void 0:e.trim())||ylt}function Olt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M5 5.5A2.5 2.5 0 0 1 7.5 3H19v16H7.5A2.5 2.5 0 0 0 5 21.5v-16Z"}),o.jsx("path",{d:"M5 18.5A2.5 2.5 0 0 1 7.5 16H19"}),o.jsx("path",{d:"M9 7h6M9 10h4"})]})}function xlt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M6 3h8l4 4v14H6V3Z"}),o.jsx("path",{d:"M14 3v5h5M9 12h6M9 16h6"})]})}function vlt(e){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m7 7 10 10M17 7 7 17"})})}function wlt(e){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"M12 5v14M5 12h14"})})}function _E({title:e,children:t,onClose:n,busy:r=!1,className:i=""}){const s=p.useId(),a=p.useRef(null),l=p.useRef(null),c=p.useRef(r),u=p.useRef(n);return p.useEffect(()=>{c.current=r,u.current=n},[r,n]),p.useEffect(()=>{var m;const d=document.activeElement instanceof HTMLElement?document.activeElement:null,f=document.body.style.overflow;document.body.style.overflow="hidden",(m=a.current)==null||m.focus();const h=g=>{if(g.key==="Escape"&&!c.current){u.current();return}if(g.key!=="Tab")return;const b=l.current;if(!b)return;const y=Array.from(b.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], audio[controls], video[controls], iframe, [tabindex]:not([tabindex="-1"])')).filter(x=>x.getClientRects().length>0);if(y.length===0){g.preventDefault();return}const O=y[0],v=y[y.length-1];g.shiftKey&&(document.activeElement===O||!b.contains(document.activeElement))?(g.preventDefault(),v.focus()):!g.shiftKey&&(document.activeElement===v||!b.contains(document.activeElement))&&(g.preventDefault(),O.focus())};return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h),document.body.style.overflow=f,d!=null&&d.isConnected&&d.focus()}},[]),Cr.createPortal(o.jsx("div",{className:"knowledge-dialog-backdrop",onMouseDown:d=>{d.target===d.currentTarget&&!r&&n()},children:o.jsxs("section",{ref:l,className:`knowledge-dialog${i?` ${i}`:""}`,role:"dialog","aria-modal":"true","aria-labelledby":s,"aria-busy":r||void 0,children:[o.jsxs("header",{className:"knowledge-dialog__header",children:[o.jsx("h2",{id:s,children:e}),o.jsx("button",{ref:a,type:"button",onClick:n,disabled:r,"aria-label":"关闭",children:o.jsx(vlt,{})})]}),t]})}),document.body)}function Gw({message:e}){return e?o.jsx("div",{className:"knowledge-form-error",role:"alert",children:e}):null}function bL(e){return e instanceof DOMException&&e.name==="AbortError"}function Slt(e){if(!e)return"";const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t):e}const Dge=[".jpg",".jpeg",".png"].join(","),Elt=new Set(Dge.split(",")),Pge=[".pdf",".pptx",".docx",".xlsx",".txt"].join(","),klt=new Set(Pge.split(",")),_lt=200*1024*1024;function yL(e){const t=e.lastIndexOf(".");return t<0?"":e.slice(t).toLocaleLowerCase()}function Tlt(e,t){return e.size>_lt?"单个文件不能超过 200 MB":t==="image"?Elt.has(yL(e.name))?"":"请选择 PNG、JPG 或 JPEG 图片":klt.has(yL(e.name))?"":"请选择 PDF、PPTX、DOCX、XLSX 或 TXT 文件"}function AB(e){return e<=0?"-":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function OL(e){var i;const t=e.type.trim().replace(/^\./,"");if(t)return t.toUpperCase();const n=e.name.trim(),r=n.includes(".")?(i=n.split(".").pop())==null?void 0:i.trim():"";return r?r.toUpperCase():"-"}function Clt({region:e,onClose:t,onCreated:n}){const[r,i]=p.useState(""),[s,a]=p.useState(""),[l,c]=p.useState(!1),[u,d]=p.useState(!1),[f,h]=p.useState(""),m=r.trim(),g=!!(m&&!/^[A-Za-z][A-Za-z0-9_]{0,47}$/.test(m)),b=async y=>{if(y.preventDefault(),c(!0),!m||g)return;d(!0),h("");const O={name:m,description:s.trim()||void 0,region:e};try{n(await qGe(O))}catch(v){h(Ga(v,"创建知识库失败"))}finally{d(!1)}};return o.jsx(_E,{title:"新建知识库",onClose:t,busy:u,children:o.jsxs("form",{onSubmit:y=>void b(y),children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsxs("label",{children:[o.jsx("span",{children:"名称"}),o.jsx("input",{autoFocus:!0,value:r,maxLength:48,"aria-invalid":l&&g||void 0,"aria-describedby":"knowledge-name-help",onBlur:()=>c(!0),onChange:y=>i(y.target.value)})]}),o.jsx("p",{id:"knowledge-name-help",className:`knowledge-dialog__note${l&&g?" is-error":""}`,role:l&&g?"alert":void 0,children:l&&g?"名称必须以字母开头,且只能包含字母、数字和下划线。":"以字母开头,仅支持字母、数字和下划线,最多 48 个字符。"}),o.jsxs("label",{children:[o.jsx("span",{children:"描述(可选)"}),o.jsx("textarea",{value:s,maxLength:80,onChange:y=>a(y.target.value)})]}),o.jsx(Gw,{message:f})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:t,disabled:u,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:u||!m||g,children:u?"创建中":"创建"})]})]})})}function Alt({item:e,onClose:t,onUpdated:n}){const[r,i]=p.useState(e.description),[s,a]=p.useState(!1),[l,c]=p.useState(""),u=async d=>{d.preventDefault(),a(!0),c("");try{n(await XGe(e.id,e.region,{description:r.trim()}))}catch(f){c(Ga(f,"更新知识库失败"))}finally{a(!1)}};return o.jsx(_E,{title:"编辑知识库",onClose:t,busy:s,children:o.jsxs("form",{onSubmit:d=>void u(d),children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsxs("label",{children:[o.jsx("span",{children:"名称"}),o.jsx("input",{value:e.name,disabled:!0})]}),o.jsxs("label",{children:[o.jsx("span",{children:"描述"}),o.jsx("textarea",{autoFocus:!0,value:r,maxLength:80,onChange:d=>i(d.target.value)})]}),o.jsx("p",{className:"knowledge-dialog__note",children:"AgentKit 当前仅支持更新知识库描述。"}),o.jsx(Gw,{message:l})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:t,disabled:s,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:s,children:s?"保存中":"保存"})]})]})})}function Mge(e){if(!e.trim())return{};const t=JSON.parse(e);if(!t||Array.isArray(t)||typeof t!="object")throw new Error("Metadata 必须是 JSON 对象");return t}function Nlt({base:e,onClose:t,onCreated:n,onAssociationInvalid:r}){const[i,s]=p.useState("document"),[a,l]=p.useState(""),[c,u]=p.useState(""),[d,f]=p.useState(""),[h,m]=p.useState(null),[g,b]=p.useState(!1),[y,O]=p.useState("{}"),[v,x]=p.useState(""),[w,S]=p.useState(""),[E,k]=p.useState(null),_=p.useRef(null),C=p.useRef(null),T=p.useRef(null),A=p.useRef(0),j=!!v;p.useEffect(()=>{var D;E&&!j&&((D=T.current)==null||D.focus())},[j,E]);const L=D=>{j||D===i||(s(D),m(null),f(""),l(""),u(""),S(""),k(null),b(!1),A.current=0,_.current&&(_.current.value=""))},I=D=>{if(!D||i==="web")return;const Q=Tlt(D,i);if(Q){m(null),l(""),u(""),S(Q);return}m(D),S(""),l(D.name.replace(/\.[^.]+$/,"")),u(yL(D.name).slice(1))},M=async D=>{if(D.preventDefault(),i==="web"?!d.trim():!h)return;let Q;try{Q=Mge(y)}catch(F){S(Ga(F,"Metadata 格式错误"));return}x(i==="web"?E?"save":"preview":"upload"),S("");try{if(i==="web")if(E){const F={sourceType:"url",metadata:E.metadata,url:E.preview.url,sourceTitle:E.preview.name,sourceMarkdown:E.preview.sourceMarkdown};await ZGe(e.id,e.region,F),n()}else{const F=await KGe(e.id,e.region,{url:d.trim()});if(!F.sourceMarkdown.trim())throw new Error("网页没有可预览的 Markdown 内容");k({preview:F,metadata:Q})}else h&&(await JGe(e.id,e.region,{file:h,name:a.trim()||void 0,documentType:c.trim()||void 0,metadata:Q}),n())}catch(F){F instanceof wj&&F.errorCode===Whe?r(F):S(Ga(F,i==="web"?E?"添加网页失败":"生成网页预览失败":"上传文件失败"))}finally{x("")}},N=()=>{j||(k(null),S(""),requestAnimationFrame(()=>{var D;return(D=C.current)==null?void 0:D.focus()}))};return o.jsx(_E,{title:E?"预览网页内容":"添加数据",onClose:t,busy:j,className:E?"knowledge-dialog--preview knowledge-dialog--web-confirm":"",children:o.jsx("form",{onSubmit:D=>void M(D),children:E?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"knowledge-preview knowledge-web-preview",children:[o.jsxs("div",{className:"knowledge-preview__meta",children:[o.jsx("strong",{title:E.preview.name,children:E.preview.name}),o.jsx("a",{href:E.preview.url,target:"_blank",rel:"noopener noreferrer",children:"打开原网页"})]}),o.jsx("div",{className:"knowledge-preview__body","aria-live":"polite",children:o.jsx("div",{className:"knowledge-preview__markdown-shell",children:o.jsx(xu,{text:E.preview.sourceMarkdown,allowRawHtml:!1,className:"knowledge-preview__markdown"})})}),w?o.jsx("div",{className:"knowledge-web-preview__error",children:o.jsx(Gw,{message:w})}):null]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",className:"is-back",onClick:N,disabled:j,children:"返回修改"}),o.jsx("button",{type:"button",onClick:t,disabled:j,children:"取消"}),o.jsx("button",{ref:T,type:"submit",className:"is-primary",disabled:j,children:v==="save"?"添加中":"确认添加"})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsx("div",{className:"knowledge-source-tabs",role:"tablist","aria-label":"知识来源",children:[["image","图片"],["document","文档文件"],["web","在线网页"]].map(([D,Q])=>o.jsx("button",{type:"button",role:"tab",id:`knowledge-source-${D}-tab`,"aria-controls":`knowledge-source-${D}-panel`,"aria-selected":i===D,tabIndex:i===D?0:-1,className:i===D?"is-active":"",disabled:j,onClick:()=>L(D),onKeyDown:F=>{const $=["image","document","web"];if(!["ArrowLeft","ArrowRight","Home","End"].includes(F.key))return;F.preventDefault();const H=$.indexOf(D),z=F.key==="Home"?$[0]:F.key==="End"?$[$.length-1]:$[(H+(F.key==="ArrowRight"?1:-1)+$.length)%$.length];L(z),requestAnimationFrame(()=>{var B;return(B=document.getElementById(`knowledge-source-${z}-tab`))==null?void 0:B.focus()})},children:Q},D))}),o.jsx("div",{id:`knowledge-source-${i}-panel`,className:"knowledge-source-panel",role:"tabpanel","aria-labelledby":`knowledge-source-${i}-tab`,children:i==="web"?o.jsxs(o.Fragment,{children:[o.jsxs("label",{children:[o.jsx("span",{children:"网页 URL"}),o.jsx("input",{ref:C,autoFocus:!0,type:"url",value:d,disabled:j,onChange:D=>{f(D.target.value),S("")},placeholder:"https://example.com/article"})]}),o.jsx("div",{className:"knowledge-upload-status",role:"status","aria-live":"polite",children:v==="preview"?o.jsx(En,{children:"正在抓取网页并生成 Markdown 预览"}):null})]}):o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:_,className:"knowledge-upload-input",type:"file","aria-label":"选择知识文件",accept:i==="image"?Dge:Pge,disabled:j,onChange:D=>{var Q;I(((Q=D.currentTarget.files)==null?void 0:Q[0])??null),D.currentTarget.value=""}}),o.jsxs("button",{type:"button",className:`knowledge-upload-dropzone${g?" is-dragging":""}${h?" is-ready":""}`,disabled:j,onClick:()=>{var D;return(D=_.current)==null?void 0:D.click()},onDragEnter:D=>{D.preventDefault(),!j&&(A.current+=1,b(!0))},onDragOver:D=>{D.preventDefault(),j||(D.dataTransfer.dropEffect="copy")},onDragLeave:D=>{D.preventDefault(),A.current=Math.max(0,A.current-1),A.current===0&&b(!1)},onDrop:D=>{var Q;D.preventDefault(),A.current=0,b(!1),j||I(((Q=D.dataTransfer.files)==null?void 0:Q[0])??null)},children:[o.jsx("strong",{children:h?h.name:"选择文件或拖拽到这里"}),o.jsx("span",{children:h?`${AB(h.size)} · 点击可重新选择`:i==="image"?"支持 PNG、JPG 和 JPEG,单个文件不超过 200 MB":"支持 PDF、PPTX、DOCX、XLSX 和 TXT,单个文件不超过 200 MB"})]}),o.jsx("div",{className:"knowledge-upload-status",role:"status","aria-live":"polite",children:j?o.jsx(En,{children:"正在上传文件并添加到知识库"}):null})]})}),i!=="web"?o.jsxs("div",{className:"knowledge-dialog__fields",children:[o.jsxs("label",{children:[o.jsx("span",{children:"名称(可选)"}),o.jsx("input",{value:a,disabled:j,maxLength:256,onChange:D=>l(D.target.value)})]}),o.jsxs("label",{children:[o.jsx("span",{children:"类型(可选)"}),o.jsx("input",{value:c,disabled:j,maxLength:64,onChange:D=>u(D.target.value),placeholder:"pdf、docx、png"})]})]}):null,o.jsxs("label",{children:[o.jsx("span",{children:"Metadata(JSON)"}),o.jsx("textarea",{className:"is-code",value:y,disabled:j,onChange:D=>O(D.target.value),spellCheck:!1})]}),o.jsx(Gw,{message:w})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:t,disabled:j,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:j||(i==="web"?!d.trim():!h),children:j?i==="web"?"生成中":"上传中":i==="web"?"生成预览":"上传文件"})]})]})})})}function jlt({base:e,item:t,onClose:n,onUpdated:r}){const[i,s]=p.useState(()=>JSON.stringify(t.metadata??{},null,2)),[a,l]=p.useState(!1),[c,u]=p.useState(""),d=async f=>{f.preventDefault();let h;try{h=Mge(i)}catch(m){u(Ga(m,"Metadata 格式错误"));return}l(!0),u("");try{r(await eWe(e.id,t.id,e.region,{metadata:h}))}catch(m){u(Ga(m,"更新知识失败"))}finally{l(!1)}};return o.jsx(_E,{title:"编辑知识 Metadata",onClose:n,busy:a,children:o.jsxs("form",{onSubmit:f=>void d(f),children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsxs("label",{children:[o.jsx("span",{children:"知识"}),o.jsx("input",{value:t.name||t.id,disabled:!0})]}),o.jsxs("label",{children:[o.jsx("span",{children:"Metadata(JSON)"}),o.jsx("textarea",{autoFocus:!0,className:"is-code knowledge-metadata-editor",value:i,onChange:f=>s(f.target.value),spellCheck:!1})]}),o.jsx(Gw,{message:c})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:n,disabled:a,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:a,children:a?"保存中":"保存"})]})]})})}const Lge=new Set(["avif","bmp","gif","jpeg","jpg","png","svg","webp"]),$ge=new Set(["aac","flac","m4a","mp3","ogg","wav","webm"]),Bge=new Set(["m4v","mov","mp4","mpeg","mpg","ogg","webm"]),Rlt=new Set(["pdf"]),Ilt=new Set(["doc","docx","ppt","pptx","xls","xlsx"]),Dlt=new Set(["creating","indexing","pending","processing","queued","submitted"]),Plt=new Set(["error","failed","unavailable"]);function PW(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function _2(e){if(e==null||e==="")return"-";if(["string","number","boolean"].includes(typeof e))return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function Mlt(e){if(Array.isArray(e)){if(e.length===0)return null;const r=e.map(PW);if(r.some(i=>Object.keys(i).length>0)){const i=[...new Set(r.flatMap(s=>Object.keys(s)))];return{columns:i,rows:r.map(s=>i.map(a=>_2(s[a])))}}return{columns:["值"],rows:e.map(i=>[_2(i)])}}const t=PW(e),n=Object.entries(t);if(n.length===0)return null;if(n.every(([,r])=>Array.isArray(r))){const r=n.map(([s])=>s),i=Math.max(...n.map(([,s])=>s.length));return{columns:r,rows:Array.from({length:i},(s,a)=>n.map(([,l])=>_2(l[a])))}}return{columns:["字段","值"],rows:n.map(([r,i])=>[r,_2(i)])}}function Qge(e){const t=e.trim();if(!t||t.startsWith("//"))return"";if(t.startsWith("/"))return t;try{const n=new URL(t);return["http:","https:"].includes(n.protocol)?n.href:""}catch{return""}}function Llt(e){const t=Qge(e);return t.startsWith("http://")||t.startsWith("https://")?t:""}function $lt(e){var i;const t=e.attachmentType.trim().toLocaleLowerCase();if(t==="image"||t==="doc-image"||t.startsWith("image/"))return"image";if(t==="audio"||t.startsWith("audio/"))return"audio";if(t==="video"||t.startsWith("video/"))return"video";if(t==="pdf"||t==="application/pdf")return"pdf";const n=e.attachmentUrl.split(/[?#]/,1)[0],r=n.includes(".")?((i=n.split(".").pop())==null?void 0:i.toLocaleLowerCase())??"":"";return Lge.has(r)?"image":$ge.has(r)?"audio":Bge.has(r)?"video":Rlt.has(r)?"pdf":t||r?"file":"none"}function Blt(e){const t=e.status.trim().toLocaleLowerCase();if(Dlt.has(t))return{title:"数据正在处理中",detail:"知识库完成解析后即可预览,请稍后重新加载。"};if(Plt.has(t))return{title:"数据解析失败",detail:"请检查源文件或网页地址后重新添加,也可以重新加载最新状态。"};const n=OL(e).toLocaleLowerCase();return n==="pdf"||Ilt.has(n)?{title:"暂时没有可预览的解析内容",detail:"此类文件会在知识库完成解析后显示文本、表格或页面图片。"}:Lge.has(n)||$ge.has(n)||Bge.has(n)?{title:"暂时没有可预览的媒体内容",detail:"知识库尚未返回可访问的媒体预览,请稍后重新加载。"}:{title:"暂无可预览的数据内容",detail:"知识库尚未返回解析结果,请稍后重新加载。"}}function Qlt({chunk:e}){const[t,n]=p.useState(!1),r=Qge(e.attachmentUrl),i=$lt(e);return!r||i==="none"?null:t?o.jsx("div",{className:"knowledge-preview__attachment-error",children:"附件无法预览,请稍后重试。"}):i==="image"?o.jsx("img",{className:"knowledge-preview__image",src:r,alt:e.title||"知识数据图片",loading:"lazy",onError:()=>n(!0)}):i==="audio"?o.jsx("audio",{className:"knowledge-preview__audio",src:r,controls:!0,preload:"metadata",onError:()=>n(!0),children:"当前浏览器不支持音频预览。"}):i==="video"?o.jsx("video",{className:"knowledge-preview__video",src:r,controls:!0,playsInline:!0,preload:"metadata",onError:()=>n(!0),children:"当前浏览器不支持视频预览。"}):i==="pdf"?o.jsxs("div",{className:"knowledge-preview__pdf",children:[o.jsx("iframe",{src:r,title:e.title?`${e.title} PDF 预览`:"PDF 预览",sandbox:"",referrerPolicy:"no-referrer",onError:()=>n(!0)}),o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:"无法显示时,在新窗口打开 PDF"})]}):o.jsxs("div",{className:"knowledge-preview__file-fallback",children:[o.jsx("p",{children:"当前格式暂不支持直接在线预览,已优先显示解析后的内容。"}),o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:"打开原文件"})]})}function Ult({base:e,item:t,onClose:n}){const[r,i]=p.useState([]),[s,a]=p.useState(t),[l,c]=p.useState(""),[u,d]=p.useState(!0),[f,h]=p.useState(!1),[m,g]=p.useState(!1),[b,y]=p.useState(""),O=p.useRef(0),v=p.useRef(null),x=p.useCallback(async(k=0)=>{var T;(T=v.current)==null||T.abort();const _=new AbortController;v.current=_;const C=O.current+1;O.current=C,k>0?h(!0):d(!0),y(""),k===0&&(i([]),g(!1));try{const A=await YGe(e.id,t.id,{region:e.region,offset:k,signal:_.signal});if(O.current!==C)return;a(A.document.id?A.document:t),c(A.sourceMarkdown||A.document.sourceMarkdown),i(j=>k>0?[...j,...A.chunks]:A.chunks),g(A.hasMore)}catch(A){!bL(A)&&O.current===C&&y(Ga(A,"加载数据预览失败"))}finally{O.current===C&&(d(!1),h(!1))}},[e.id,e.region,t]);p.useEffect(()=>(x(),()=>{var k;(k=v.current)==null||k.abort(),O.current+=1}),[x]);const w=Llt(s.url||t.url),S=Blt(s),E=s.metadata._veadk_content_format==="markdown";return o.jsx(_E,{title:s.name||t.name||t.id,onClose:n,className:"knowledge-dialog--preview",children:o.jsxs("div",{className:"knowledge-preview",children:[s.sizeBytes>0||w?o.jsxs("div",{className:"knowledge-preview__meta",children:[s.sizeBytes>0?o.jsx("span",{children:AB(s.sizeBytes)}):null,w?o.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",children:"打开原网页"}):null]}):null,o.jsx("div",{className:"knowledge-preview__body","aria-live":"polite",children:l?o.jsx("div",{className:"knowledge-preview__markdown-shell",children:o.jsx(xu,{text:l,allowRawHtml:!1,className:"knowledge-preview__markdown"})}):u?o.jsx("div",{className:"knowledge-preview__state",role:"status",children:o.jsx(En,{as:"span",duration:2.4,children:"正在加载数据预览"})}):b&&r.length===0?o.jsxs("div",{className:"knowledge-preview__state is-error",role:"alert",children:[o.jsx("p",{children:b}),o.jsx("button",{type:"button",onClick:()=>void x(),children:"重试"})]}):r.length===0?o.jsxs("div",{className:"knowledge-preview__state",children:[o.jsx("p",{children:S.title}),o.jsx("span",{children:w?"您可以打开原网页查看来源内容。":S.detail}),o.jsx("button",{type:"button",onClick:()=>void x(),children:"重新加载"})]}):o.jsxs("div",{className:"knowledge-preview__chunks",children:[r.map((k,_)=>{const C=Mlt(k.tableFields),T=k.id||`${_}:${k.title}`;return o.jsxs("article",{className:"knowledge-preview__chunk",children:[o.jsx("header",{children:o.jsx("h3",{children:k.title||`片段 ${_+1}`})}),k.content?E?o.jsx(xu,{text:k.content,allowRawHtml:!1,className:"knowledge-preview__markdown"}):o.jsx("p",{className:"knowledge-preview__content",children:k.content}):null,C?o.jsx("div",{className:"knowledge-preview__table-wrap",children:o.jsxs("table",{children:[o.jsx("thead",{children:o.jsx("tr",{children:C.columns.map((A,j)=>o.jsx("th",{scope:"col",children:A},`${A}:${j}`))})}),o.jsx("tbody",{children:C.rows.map((A,j)=>o.jsx("tr",{children:A.map((L,I)=>o.jsx("td",{children:L},I))},j))})]})}):null,o.jsx(Qlt,{chunk:k})]},T)}),b?o.jsx("div",{className:"knowledge-preview__more-error",role:"alert",children:b}):null,m?o.jsx("button",{type:"button",className:"knowledge-preview__load-more",disabled:f,onClick:()=>void x(r.length),children:f?o.jsx(En,{as:"span",duration:2.4,children:"正在加载更多"}):"加载更多"}):null]})})]})})}function Flt({cloudProvider:e,region:t,active:n=!0,activationRevision:r=0,onDetailChange:i,toolbarLeading:s,toolbarFilters:a}){const[l,c]=p.useState([]),[u,d]=p.useState({}),[f,h]=p.useState([]),[m,g]=p.useState(""),[b,y]=p.useState("overview"),[O,v]=p.useState(""),[x,w]=p.useState(""),[S,E]=p.useState(!0),[k,_]=p.useState(!1),[C,T]=p.useState(""),[A,j]=p.useState([]),[L,I]=p.useState(!1),[M,N]=p.useState(""),[D,Q]=p.useState(""),[F,$]=p.useState(""),[H,z]=p.useState(!1),[B,V]=p.useState(!1),[Z,ce]=p.useState(!1),[be,ie]=p.useState(null),[q,X]=p.useState(null),[K,de]=p.useState(null),[xe,Me]=p.useState(null),[Ae,He]=p.useState(null),[et,Te]=p.useState(!1),Re=p.useRef(0),he=p.useRef(0),me=p.useRef([]),Se=p.useRef(!1),ke=p.useRef(!1),nt=p.useRef(null),Qe=p.useRef(null),re=p.useRef({}),ue=p.useRef(!1),Pe=p.useRef(null),Ge=p.useRef(null),W=p.useRef(null),_e=p.useRef(null),rt=p.useMemo(()=>[t],[t]),Ve=p.useCallback(we=>`${we.region}\0${we.id}`,[]),We=l.find(we=>Ve(we)===m)??null,ot=!!(We&&F===Ve(We));p.useEffect(()=>{i==null||i(!!We)},[i,We]),p.useEffect(()=>{y("overview"),w("")},[m]);const St=p.useMemo(()=>{const we=O.trim().toLocaleLowerCase();return we?l.filter(Fe=>[Fe.name,Fe.description,Fe.ownerLabel,Fe.providerKnowledgeId].some(dt=>dt.toLocaleLowerCase().includes(we))):l},[l,O]),Vt=p.useMemo(()=>{const we=x.trim().toLocaleLowerCase();return we?A.filter(Fe=>[Fe.name,Fe.id,OL(Fe)].some(dt=>dt.toLocaleLowerCase().includes(we))):A},[x,A]);p.useEffect(()=>{X(null)},[We==null?void 0:We.id,We==null?void 0:We.region]);const _t=p.useCallback(async(we=!1)=>{var Tt;if(we&&(ue.current||Object.keys(re.current).length===0))return;(Tt=nt.current)==null||Tt.abort();const Fe=new AbortController;nt.current=Fe;const dt=Re.current+1;Re.current=dt,ue.current=!0,we?_(!0):E(!0),T(""),we||h([]);try{const Pt=await HGe({regions:rt,nextTokens:we?re.current:void 0,signal:Fe.signal});if(Re.current!==dt)return;c(ln=>we?[...ln,...Pt.items.filter(le=>!ln.some(Wt=>Ve(Wt)===Ve(le)))]:Pt.items),re.current=Pt.nextTokens,d(Pt.nextTokens);const nn=Pt.failures.map(({region:ln,error:le})=>`${Zf(ln,e)}:${Ga(le,"加载失败")}`);h(ln=>we?[...new Set([...ln,...nn])]:nn),we||g(ln=>Pt.items.some(le=>Ve(le)===ln)?ln:"")}catch(Pt){if(bL(Pt))return;Re.current===dt&&(we?h(nn=>[...new Set([...nn,Ga(Pt,"加载更多知识库失败")])]):T(Ga(Pt,"加载知识库失败")))}finally{Re.current===dt&&(ue.current=!1,E(!1),_(!1))}},[Ve,e,rt]),Ne=p.useCallback(async(we,Fe=!1)=>{var Pt;if(Fe&&Se.current)return;(Pt=Qe.current)==null||Pt.abort();const dt=new AbortController;Qe.current=dt;const Tt=he.current+1;he.current=Tt,Fe||(me.current=[],ke.current=!1,j([]),z(!1),Q("")),Se.current=!0,I(!0),Fe?Q(""):N("");try{const nn=await WGe(we.id,{region:we.region,offset:Fe?me.current.length:0,signal:dt.signal});if(he.current!==Tt)return;$(Le=>Le===Ve(we)?"":Le);const ln=me.current,le=Fe?[...ln,...nn.items.filter(Le=>!Le.id||!ln.some(Rt=>Rt.id===Le.id))]:nn.items,Wt=nn.hasMore&&(!Fe||le.length>ln.length);me.current=le,ke.current=Wt,j(le),z(Wt)}catch(nn){if(bL(nn))return;he.current===Tt&&(nn instanceof wj&&nn.errorCode===Whe&&($(Ve(we)),ie(le=>le&&Ve(le)===Ve(we)?null:le)),Fe?Q(Ga(nn,"加载更多数据失败")):N(Ga(nn,"加载数据失败")))}finally{he.current===Tt&&(Se.current=!1,I(!1))}},[Ve]);p.useEffect(()=>{var we;(we=nt.current)==null||we.abort(),Re.current+=1,ue.current=!1,re.current={},c([]),d({}),h([]),g(""),$(""),T(""),E(!0)},[e]),p.useEffect(()=>{if(n)return _t(),()=>{var we;(we=nt.current)==null||we.abort(),Re.current+=1,ue.current=!1}},[n,r,_t]),p.useEffect(()=>{var we,Fe;if(!n){(we=Qe.current)==null||we.abort(),he.current+=1,Se.current=!1;return}if(!We){(Fe=Qe.current)==null||Fe.abort(),he.current+=1,me.current=[],Se.current=!1,ke.current=!1,j([]),z(!1),Q("");return}return Ne(We),()=>{var dt;(dt=Qe.current)==null||dt.abort(),he.current+=1,Se.current=!1}},[n,r,We==null?void 0:We.id,We==null?void 0:We.region]);const $e=n&&!We&&!O.trim()&&!S&&!k&&!C&&Object.keys(u).length>0;p.useEffect(()=>{const we=Ge.current,Fe=Pe.current;if(!we||!Fe||!$e)return;const dt=new IntersectionObserver(([Tt])=>{Tt.isIntersecting&&_t(!0)},{root:Fe,rootMargin:"240px 0px",threshold:.01});return dt.observe(we),()=>dt.disconnect()},[$e,_t]);const mt=()=>{const we=Pe.current;!we||!$e||we.scrollHeight-we.scrollTop-we.clientHeight<=240&&_t(!0)},Ht=!!(We&&A.length>0&&H&&!L&&!D);p.useEffect(()=>{const we=_e.current,Fe=W.current;if(!We||!we||!Fe||!Ht)return;const dt=new IntersectionObserver(([Tt])=>{Tt.isIntersecting&&Ne(We,!0)},{root:W.current,rootMargin:"240px 0px",threshold:.01});return dt.observe(we),()=>dt.disconnect()},[Ht,Ne,We==null?void 0:We.id,We==null?void 0:We.region]);const qe=()=>{const we=W.current;if(!We||!we||!ke.current||Se.current||D)return;const{scrollHeight:Fe,scrollTop:dt,clientHeight:Tt}=we;Fe-dt-Tt<=240&&Ne(We,!0)},ye=we=>{c(Fe=>Fe.map(dt=>Ve(dt)===Ve(we)?we:dt))},Ue=async()=>{if(xe){Te(!0);try{await GGe(xe.id,xe.region),c(we=>we.filter(Fe=>Ve(Fe)!==Ve(xe))),$(we=>we===Ve(xe)?"":we),m===Ve(xe)&&g(""),Me(null)}catch(we){T(Ga(we,"删除知识库失败")),Me(null)}finally{Te(!1)}}},it=async()=>{if(!(!We||!Ae)){Te(!0);try{await tWe(We.id,Ae.id,We.region);const we=me.current.filter(Fe=>Fe.id!==Ae.id);me.current=we,j(we),He(null)}catch(we){N(Ga(we,"删除知识失败")),He(null)}finally{Te(!1)}}};return o.jsxs("section",{className:`knowledge-library${We?" is-detail":" resource-collection"}`,"aria-label":"知识库",children:[We?o.jsx(hE,{className:"knowledge-library__detail",title:We.name,description:We.description||"暂无描述",identitySeed:We.name,backLabel:"返回知识库列表",onBack:()=>g(""),sections:[{key:"overview",label:"概览",content:o.jsx("section",{className:"knowledge-overview",children:o.jsxs(G7,{className:"knowledge-overview__summary",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"Provider"}),o.jsx("dd",{children:We.providerType||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"Knowledge ID"}),o.jsx("dd",{className:"knowledge-keyboard-reveal",tabIndex:0,title:We.providerKnowledgeId,children:We.providerKnowledgeId||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"项目"}),o.jsx("dd",{children:We.projectName||"default"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"创建者"}),o.jsx("dd",{children:Qv(We.ownerLabel)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"更新时间"}),o.jsx("dd",{children:Slt(We.updatedAt)||"-"})]})]})})},{key:"data",label:"数据",content:o.jsx("section",{className:"knowledge-documents",children:o.jsx("div",{className:`knowledge-documents__body${A.length>0?" is-table":""}`,"aria-live":"polite",children:L&&A.length===0?o.jsx(bd,{}):M&&A.length===0?o.jsxs("div",{className:"knowledge-library__state is-error",role:"alert",children:[o.jsx("p",{children:M}),ot&&We.canManage?o.jsx("button",{type:"button",onClick:()=>Me(We),children:"删除失效关联"}):o.jsx("button",{type:"button",onClick:()=>void Ne(We),children:"重试"})]}):A.length===0?o.jsxs("div",{className:"knowledge-library__state",children:[o.jsx(xlt,{}),o.jsx("p",{children:"这个知识库还没有数据"}),We.canManage&&o.jsx("button",{type:"button",onClick:()=>ie(We),children:"添加第一项数据"})]}):o.jsx(uGe,{rows:Vt,rowKey:we=>we.id,rowLabel:we=>we.name||we.id,columns:[{key:"name",header:"名称",className:"is-primary-column",render:we=>o.jsx("span",{title:we.name||we.id,children:we.name||we.id})},{key:"format",header:"格式",className:"is-compact-column",render:we=>OL(we)},{key:"size",header:"大小",className:"is-compact-column",render:we=>AB(we.sizeBytes)}],searchValue:x,onSearchChange:w,searchPlaceholder:"搜索数据",searchLabel:"搜索知识库数据",primaryAction:We.canManage?{label:ot?"关联已失效":"添加数据",disabled:ot,title:ot?"底层 Provider 知识库已不存在":void 0,onClick:()=>ie(We)}:void 0,rowActions:we=>[{label:"预览",onSelect:()=>X(we)},...We.canManage?[{label:"编辑",onSelect:()=>de(we)},{label:"删除",onSelect:()=>He(we),danger:!0}]:[]],scrollRef:W,onScroll:qe,busy:L,emptyLabel:"没有匹配的数据",footer:L?o.jsxs("div",{className:"knowledge-document-pagination",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),o.jsx("span",{children:"正在加载更多数据"})]}):D?o.jsxs("div",{className:"knowledge-document-pagination is-error",role:"alert",children:[o.jsx("span",{children:D}),o.jsx("button",{type:"button",onClick:()=>void Ne(We,!0),children:"重试加载"})]}):H?o.jsx("div",{ref:_e,className:"knowledge-document-pagination",role:"status","aria-live":"polite",children:"继续下滑加载更多"}):null})})})}],activeSectionKey:b,navigationLabel:"知识库详情",onSectionChange:y,actions:We.canManage?o.jsxs(o.Fragment,{children:[o.jsx(Nt,{type:"button",color:"danger",variant:"soft",size:"lg",pill:!1,onClick:()=>Me(We),children:"删除"}),o.jsx(Nt,{type:"button",color:"primary",size:"lg",pill:!1,onClick:()=>ce(!0),children:"编辑"})]}):void 0}):o.jsxs(o.Fragment,{children:[o.jsxs(g0,{className:"knowledge-library__toolbar library-resource-toolbar",children:[s,o.jsxs("div",{className:"resource-toolbar__actions",children:[a,o.jsx(Gp,{value:O,onChange:we=>v(we.target.value),placeholder:"搜索知识库","aria-label":"搜索知识库"})]})]}),o.jsxs(b0,{ref:Pe,"aria-live":"polite",onScroll:mt,children:[f.length>0&&!S&&o.jsxs("div",{className:"knowledge-region-warning",role:"status",children:[o.jsx("span",{children:"部分知识库暂时无法加载,已展示其余可用内容。"}),o.jsx("button",{type:"button",onClick:()=>void _t(),children:"重试"})]}),S&&l.length===0?o.jsx(bd,{}):C?o.jsxs("div",{className:"knowledge-library__state is-error",role:"alert",children:[o.jsx("p",{children:C}),o.jsx("button",{type:"button",onClick:()=>void _t(),children:"重试"})]}):St.length===0&&O.trim()?o.jsxs("div",{className:"knowledge-library__state",children:[o.jsx(Olt,{}),o.jsx("p",{children:"没有匹配的知识库"})]}):o.jsxs(aO,{children:[O.trim()?null:o.jsx(Vg,{"aria-label":"新建知识库",icon:o.jsx(wlt,{}),onClick:()=>V(!0),children:"新建知识库"}),St.map(we=>o.jsx(bE,{className:"knowledge-card",title:we.name,description:we.description||"暂无描述",metadata:[{label:"创建者",value:Qv(we.ownerLabel),title:Qv(we.ownerLabel)},{label:"项目",value:we.projectName||"default",title:we.projectName||"default"}],action:{label:F===Ve(we)?"关联已失效":"添加数据",icon:"plus",disabled:!we.canManage||F===Ve(we),title:we.canManage?F===Ve(we)?"底层 Provider 知识库已不存在":void 0:"您没有管理此知识库的权限",onClick:()=>ie(we)},detailAction:{label:"查看详情",onClick:()=>g(Ve(we))}},Ve(we)))]}),$e||k?o.jsx("div",{ref:Ge,className:"my-agent-load-more",role:"status","aria-live":"polite",children:k?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),o.jsx("span",{children:"正在加载更多知识库"})]}):$e?o.jsx("span",{children:"继续下滑加载更多"}):null}):null]})]}),B&&o.jsx(Clt,{region:t,onClose:()=>V(!1),onCreated:we=>{c(Fe=>[we,...Fe]),g(Ve(we)),V(!1)}}),We&&Z&&o.jsx(Alt,{item:We,onClose:()=>ce(!1),onUpdated:we=>{ye(we),ce(!1)}}),We&&q&&o.jsx(Ult,{base:We,item:q,onClose:()=>X(null)}),be&&o.jsx(Nlt,{base:be,onClose:()=>ie(null),onAssociationInvalid:we=>{$(Ve(be)),We&&Ve(We)===Ve(be)&&N(Ga(we,"知识库关联已失效")),ie(null)},onCreated:()=>{We&&Ve(We)===Ve(be)&&Ne(We),ie(null)}}),We&&K&&o.jsx(jlt,{base:We,item:K,onClose:()=>de(null),onUpdated:we=>{const Fe=me.current.map(dt=>dt.id===we.id?we:dt);me.current=Fe,j(Fe),de(null)}}),xe&&o.jsx(zl,{title:"删除知识库?",description:`将删除 ${xe.name} 的 AgentKit 关联;如果它由 Studio 创建,也会同时删除 Provider 资源。此操作无法撤销。`,confirmLabel:et?"删除中":"删除",variant:"danger",busy:et,onCancel:()=>Me(null),onConfirm:()=>void Ue()}),Ae&&o.jsx(zl,{title:"删除知识?",description:`将从 Provider 知识库中删除 ${Ae.name||Ae.id},此操作无法撤销。`,confirmLabel:et?"删除中":"删除",variant:"danger",busy:et,onCancel:()=>He(null),onConfirm:()=>void it()})]})}const zlt="_EmptyMessage_1r5gu_1",Vlt="_IconBadge_1r5gu_16",Hlt="_Title_1r5gu_54",qlt="_Description_1r5gu_69",Xlt="_ActionRow_1r5gu_77",TE={EmptyMessage:zlt,IconBadge:Vlt,Title:Hlt,Description:qlt,ActionRow:Xlt},xn=({children:e,className:t,fill:n="static"})=>o.jsx("div",{className:ur(TE.EmptyMessage,t),"data-fill":n,children:e}),Glt=({size:e="md",color:t="secondary",children:n,className:r})=>o.jsx("div",{className:ur(TE.IconBadge,r),"data-size":e,"data-color":t,children:n}),Wlt=({children:e,className:t,color:n="secondary"})=>o.jsx("div",{className:ur(TE.Title,t),"data-color":n,children:e}),Ylt=({children:e,className:t})=>o.jsx("div",{className:ur(TE.Description,t),children:e}),Zlt=({children:e,className:t})=>o.jsx("div",{className:ur(TE.ActionRow,t),children:e});xn.Icon=Glt;xn.Title=Wlt;xn.Description=Ylt;xn.ActionRow=Zlt;const Klt="/web/skill-management";class Jlt extends Error{constructor(t,n,r="SKILL_MANAGEMENT_ERROR",i="",s,a=""){super(t),this.status=n,this.code=r,this.statusText=i,this.originalError=s,this.rawResponse=a,this.name="SkillManagementApiError"}}async function yh(e,t={},n=_o){return fetch(xo(`${Klt}${e}`),{...t,headers:fh(t.headers),signal:nl(t.signal,n)})}async function Uge(e,t){let n=t,r="SKILL_MANAGEMENT_ERROR",i;const s=await e.text().catch(()=>"");try{const a=JSON.parse(s);typeof a.detail=="string"?n=a.detail:a.detail&&(n=a.detail.message||t,r=a.detail.code||r,i=a.detail.originalError)}catch{s.trim()&&(n=`${t}:${s.trim()}`)}return new Jlt(n,e.status,r,e.statusText,i,s)}async function Oh(e,t){if(!e.ok)throw await Uge(e,t);return e.json()}async function ect(e){const t=new URLSearchParams({region:e.region,page:String(e.page),page_size:String(e.pageSize)});return e.project&&t.set("project",e.project),Oh(await yh(`/spaces?${t}`,{signal:e.signal}),"读取 Skill 空间失败")}async function tct(e){return Oh(await yh("/spaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),"创建 Skill 空间失败")}async function nct(e){return Oh(await yh(`/spaces/${encodeURIComponent(e.spaceId)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,description:e.description,region:e.region})}),"更新 Skill 空间失败")}async function rct(e){const t=new URLSearchParams({region:e.region});await Oh(await yh(`/spaces/${encodeURIComponent(e.spaceId)}?${t}`,{method:"DELETE"}),"删除 Skill 空间失败")}async function ict(e){const t=new URLSearchParams({region:e.region});return e.project&&t.set("project",e.project),Oh(await yh(`/spaces/${encodeURIComponent(e.spaceId)}/skills?${t}`,{method:"POST",headers:{"Content-Type":"application/zip"},body:e.file},Zi),"上传 Skill 失败")}async function sct(e){return Oh(await yh("/validate",{method:"POST",headers:{"Content-Type":"application/zip"},body:e},Zi),"校验 Skill 失败")}async function act(e){const t=new URLSearchParams({region:e.region});await Oh(await yh(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}?${t}`,{method:"DELETE"}),"删除 Skill 失败")}async function oct(e){const t=new URLSearchParams({region:e.region});e.version&&t.set("version",e.version),e.skillSpaceName&&t.set("skill_space_name",e.skillSpaceName),e.skillName&&t.set("skill_name",e.skillName);const n=await Oh(await yh(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}/files?${t}`),"读取 Skill 文件失败");return Array.isArray(n.files)?n.files:[]}async function lct(e){var l;const t=new URLSearchParams({region:e.region});e.version&&t.set("version",e.version),e.skillSpaceName&&t.set("skill_space_name",e.skillSpaceName),e.skillName&&t.set("skill_name",e.skillName);const n=await yh(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}/archive?${t}`,{},Zi);n.ok||await Oh(n,"下载 Skill 失败");const i=((l=(n.headers.get("content-disposition")||"").match(/filename="([^"]+)"/))==null?void 0:l[1])||`${e.fallbackName}.zip`,s=URL.createObjectURL(await n.blob()),a=document.createElement("a");a.href=s,a.download=i,a.click(),URL.revokeObjectURL(s)}async function Pj(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:nl(void 0,_o)});if(!t.ok)throw await Uge(t,"AgentKit Skills 请求失败");return t.json()}async function Fge(){return(await Pj("/web/skill-spaces")).items||[]}async function zge(e,t){const n=t?`?region=${encodeURIComponent(t)}`:"";return(await Pj(`/web/skill-spaces/${encodeURIComponent(e)}/skills${n}`)).items||[]}async function cct(e,t){const n=new URLSearchParams({region:t.region,page:String(t.page),page_size:String(t.pageSize)});return t.project&&n.set("project",t.project),Pj(`/web/skill-spaces/${encodeURIComponent(e)}/skills?${n.toString()}`)}async function uct(e,t,n,r,i,s,a){const l=[];n&&l.push(`version=${encodeURIComponent(n)}`),r&&l.push(`region=${encodeURIComponent(r)}`),i&&l.push(`project=${encodeURIComponent(i)}`),s&&l.push(`skill_name=${encodeURIComponent(s)}`),a&&l.push(`skill_space_name=${encodeURIComponent(a)}`);const c=l.length>0?`?${l.join("&")}`:"";return Pj(`/web/skill-spaces/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}${c}`)}function dct(e,t){return{source:"skillspace",id:`ss:${e.id}/${t.skillId}/${t.version}`,name:t.skillName,description:t.skillDescription,folder:t.skillName,skillSpaceId:e.id,skillSpaceName:e.name,skillSpaceRegion:e.region,skillId:t.skillId,version:t.version}}function fct(e,t,n="volcengine"){return n==="byteplus"?"":`https://console.volcengine.com/agentkit/${(t||"cn-beijing")==="cn-beijing"?"cn":"cn-shanghai"}/skillspace/detail/${encodeURIComponent(e)}`}const hct="/web/skill-workbench";class xL extends Error{constructor(t,n,r="SKILL_WORKBENCH_ERROR",i=!1,s="",a,l=""){super(t),this.status=n,this.code=r,this.retryable=i,this.statusText=s,this.originalError=a,this.rawResponse=l,this.name="SkillWorkbenchApiError"}}function Dc(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}格式错误。`);return e}function MW(e,t){if(e!=null){if(typeof e!="string"||!e.trim()||e.trim().length>256)throw new Error(`${t}格式错误。`);return e.trim()}}function pct(e){if(e!=null){if(e==="pending"||e==="ready"||e==="failed"||e==="unknown")return e;throw new Error("Skill 恢复点状态格式错误。")}}async function yd(e,t={},n=_o){return fetch(xo(`${hct}${e}`),{...t,headers:fh(t.headers),signal:nl(t.signal,n)})}async function NB(e,t){var r;const n=await e.text().catch(()=>"");try{const i=Dc(JSON.parse(n),"错误响应"),s=i.detail&&typeof i.detail=="object"?Dc(i.detail,"错误详情"):i;return new xL(typeof s.message=="string"?s.message:t,e.status,typeof s.code=="string"?s.code:"SKILL_WORKBENCH_ERROR",s.retryable===!0,e.statusText,s.originalError&&typeof s.originalError=="object"?s.originalError:void 0,n)}catch{const i=((r=e.headers.get("content-type"))==null?void 0:r.split(";",1)[0])||"Content-Type 缺失";return new xL(`${t}(HTTP ${e.status},Content-Type: ${i})。请检查代理或网关配置。`,e.status,"SKILL_WORKBENCH_ERROR",!1,e.statusText,void 0,n)}}async function Yp(e,t){if(!e.ok)throw await NB(e,t);const n=e.headers.get("content-type")??"";if(!n.includes("application/json")){const r=n.split(";",1)[0]||"Content-Type 缺失";throw new Error(`${t}:服务端返回非 JSON 响应(HTTP ${e.status},Content-Type: ${r}),请检查代理或网关配置。`)}return e.json()}function mct(e){return Array.isArray(e)?e.map(t=>{const n=Dc(t,"Skill 会话活动"),r=n.kind,i=n.status;if(typeof n.id!="string"||!["status","thinking","message","tool"].includes(String(r))||!["running","done"].includes(String(i)))throw new Error("Skill 会话活动格式错误。");if(r==="tool"){if(typeof n.name!="string")throw new Error("Skill 工具活动格式错误。");return{id:n.id,kind:r,status:i,name:n.name,...n.input!==void 0?{args:n.input}:{},...n.output!==void 0?{response:n.output}:{}}}if(typeof n.text!="string")throw new Error("Skill 文本活动格式错误。");return{id:n.id,kind:r,status:i,text:n.text}}):[]}function gct(e){if(e==null)return;const t=Dc(e,"Skill 发布结果");if(typeof t.revision!="number"||typeof t.skillId!="string"||typeof t.version!="string"||!Array.isArray(t.skillSpaceIds)||!t.skillSpaceIds.every(n=>typeof n=="string")||t.disposition!=="create-new"&&t.disposition!=="update-source"||!HS(t.region)||typeof t.projectName!="string")throw new Error("Skill 发布结果格式错误。");return{revision:t.revision,skillId:t.skillId,version:t.version,skillSpaceIds:t.skillSpaceIds,disposition:t.disposition,region:t.region,projectName:t.projectName}}function Ww(e){const t=Dc(e,"Skill 会话");if(typeof t.jobId!="string"||t.operation!=="create"&&t.operation!=="optimize"||typeof t.intent!="string"||typeof t.revision!="number"||typeof t.state!="string")throw new Error("Skill 会话格式错误。");const n=Array.isArray(t.files)?t.files.flatMap(l=>{const c=Dc(l,"Skill 文件");return typeof c.path=="string"&&typeof c.size=="number"?[{path:c.path,size:c.size}]:[]}):[];if(!["running","ready","failed","cancelled","expired","published"].includes(t.state))throw new Error("Skill 会话状态无法识别。");const i=MW(t.toolId,"Tool ID"),s=MW(t.sessionId,"Session ID"),a=pct(t.recoveryStatus);return{jobId:t.jobId,operation:t.operation,intent:t.intent,...typeof t.model=="string"?{model:t.model}:{},...typeof t.style=="string"?{style:t.style}:{},...typeof t.requestedName=="string"?{requestedName:t.requestedName}:{},revision:t.revision,...i?{toolId:i}:{},...s?{sessionId:s}:{},...typeof t.sessionTtlSeconds=="number"?{sessionTtlSeconds:t.sessionTtlSeconds}:{},...typeof t.expiresAt=="string"?{expiresAt:t.expiresAt}:{},...typeof t.recoveryAvailable=="boolean"?{recoveryAvailable:t.recoveryAvailable}:{},...a?{recoveryStatus:a}:{},...typeof t.recoveredFromSnapshot=="boolean"?{recoveredFromSnapshot:t.recoveredFromSnapshot}:{},state:t.state,stage:typeof t.stage=="string"?t.stage:"generating",activities:mct(t.activities),files:n,...t.source&&typeof t.source=="object"?{source:t.source}:{},...typeof t.name=="string"?{name:t.name}:{},...typeof t.description=="string"?{description:t.description}:{},...typeof t.skillMd=="string"?{skillMd:t.skillMd}:{},...typeof t.error=="string"?{error:t.error}:{},...t.validation&&typeof t.validation=="object"?{validation:t.validation}:{},...t.publication?{publication:gct(t.publication)}:{}}}async function Mj(e){const t=Dc(await Yp(await yd("/capabilities",{signal:e}),"读取 Skill 工作台能力失败"),"Skill 工作台能力");return{enabled:t.enabled===!0,reason:typeof t.reason=="string"?t.reason:"",operations:Array.isArray(t.operations)?t.operations.filter(n=>n==="create"||n==="optimize"):[],models:Array.isArray(t.models)?t.models.flatMap(n=>{if(!n||typeof n!="object")return[];const r=n;return typeof r.id=="string"&&typeof r.label=="string"?[{id:r.id,label:r.label}]:[]}):[],styles:t.styles&&typeof t.styles=="object"&&!Array.isArray(t.styles)?Object.fromEntries(Object.entries(t.styles).filter(n=>typeof n[1]=="string")):{},...typeof t.maxUploadBytes=="number"?{maxUploadBytes:t.maxUploadBytes}:{}}}async function bct(e){if(e.file){const n=new URLSearchParams({operation:"optimize",intent:e.intent});e.jobId&&n.set("job_id",e.jobId),e.model&&n.set("model",e.model),e.style&&n.set("style",e.style),e.name&&n.set("name",e.name);const r=await yd(`/tasks/from-upload?${n}`,{method:"POST",body:e.file,headers:{"Content-Type":"application/zip"},signal:e.signal},Zi);return Ww(await Yp(r,"开始优化 Skill 失败"))}const t=await yd("/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation:e.operation,intent:e.intent,...e.model?{model:e.model}:{},...e.style?{style:e.style}:{},...e.name?{name:e.name}:{},...e.jobId?{jobId:e.jobId}:{},...e.source?{source:{kind:"skill-center",skillId:e.source.skillId,skillName:e.source.name,version:e.source.version,region:e.source.region,projectName:e.source.projectName,skillSpaceId:e.source.skillSpaceId,skillSpaceName:e.source.skillSpaceName}}:{}}),signal:e.signal},Zi);return Ww(await Yp(t,"开始 Skill 会话失败"))}async function yct(e,t){return Ww(await Yp(await yd(`/tasks/${encodeURIComponent(e)}`,{signal:t}),"读取 Skill 会话失败"))}async function xD(e,t,n){const r=new URLSearchParams;r.set("expected_revision",String(t));const i=Dc(await Yp(await yd(`/tasks/${encodeURIComponent(e)}/artifact?${r.toString()}`,{signal:n}),"读取 Skill 产物失败"),"Skill 产物");if(i.jobId!==e||i.revision!==t||!Number.isSafeInteger(i.revision)||i.revision<1||typeof i.sha256!="string"||!/^[0-9a-f]{64}$/.test(i.sha256)||typeof i.name!="string"||typeof i.description!="string"||!Array.isArray(i.files))throw new Error("Skill 产物格式错误。");const s=i.files.map(a=>{const l=Dc(a,"Skill 产物文件");if(typeof l.path!="string"||typeof l.size!="number"||typeof l.content!="string")throw new Error("Skill 产物文件格式错误。");return{path:l.path,size:l.size,content:l.content}});return{jobId:i.jobId,revision:i.revision,sha256:i.sha256,name:i.name,description:i.description,files:s}}async function vD(e){const t=await yd(`/tasks/${encodeURIComponent(e.jobId)}/refinements`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({intent:e.intent,expectedRevision:e.expectedRevision})},Zi);return Ww(await Yp(t,"继续调整 Skill 失败"))}async function Oct(e){const t=await yd(`/tasks/${encodeURIComponent(e.jobId)}/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedRevision:e.expectedRevision})});return Ww(await Yp(t,"停止当前 Skill 任务失败"))}async function xct(e){const t=await yd(`/tasks/${encodeURIComponent(e.jobId)}/publish-stream`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},body:JSON.stringify({disposition:e.disposition,expectedRevision:e.expectedRevision,expectedArtifactSha256:e.expectedArtifactSha256,skillSpaceIds:e.skillSpaceIds??[],projectName:e.projectName,region:e.region}),signal:e.signal},0);if(!t.ok)throw await NB(t,"发布 Skill 失败");if(!(t.headers.get("content-type")??"").includes("application/x-ndjson"))throw new Error("发布 Skill 失败:服务端返回了非 NDJSON 响应。");if(!t.body)throw new Error("发布 Skill 失败:服务端没有返回进度流。");const r=new Set(["preparing","uploading","registering","activating","publishing"]);let i=null,s="";const a=new TextDecoder,l=t.body.getReader(),c=u=>{var h;if(!u.trim())return;const d=Dc(JSON.parse(u),"发布进度");if(d.type==="progress"){if(typeof d.phase!="string"||!r.has(d.phase)||typeof d.message!="string")throw new Error("发布进度格式错误。");(h=e.onProgress)==null||h.call(e,{phase:d.phase,message:d.message});return}if(d.type==="error"){const m=Dc(d.error,"发布错误");throw new xL(typeof m.message=="string"?m.message:"发布 Skill 失败",500,typeof m.code=="string"?m.code:"SKILL_PUBLISH_FAILED",m.retryable===!0,"",m.originalError&&typeof m.originalError=="object"?m.originalError:void 0,JSON.stringify(d.error))}if(d.type!=="complete")throw new Error("未知的发布进度事件。");const f=Dc(d.result,"发布结果");if(typeof f.skillId!="string"||typeof f.version!="string"||!Array.isArray(f.skillSpaceIds)||!f.skillSpaceIds.every(m=>typeof m=="string")||f.disposition!=="create-new"&&f.disposition!=="update-source"||!HS(f.region)||typeof f.projectName!="string")throw new Error("发布结果格式错误。");i={skillId:f.skillId,version:f.version,skillSpaceIds:f.skillSpaceIds,disposition:f.disposition,region:f.region,projectName:f.projectName}};for(;;){const{value:u,done:d}=await l.read();s+=a.decode(u,{stream:!d});const f=s.split(` -`);if(s=f.pop()??"",f.forEach(c),d)break}if(c(s),!i)throw new Error("发布进度流提前结束,无法确认发布结果。请刷新技能中心确认状态。");return i}async function vct(e){await Yp(await yd(`/tasks/${encodeURIComponent(e)}`,{method:"DELETE"}),"删除 Skill 会话失败")}async function wct(e,t,n){var c;const r=new URLSearchParams;r.set("expected_revision",String(t)),r.set("expected_sha256",n);const i=await yd(`/tasks/${encodeURIComponent(e)}/download?${r.toString()}`,{},Zi);if(!i.ok)throw await NB(i,"下载 Skill 失败");const a=((c=(i.headers.get("content-disposition")??"").match(/filename="([^"]+)"/))==null?void 0:c[1])??"skill.zip",l=URL.createObjectURL(await i.blob());try{const u=document.createElement("a");u.href=l,u.download=a,u.click()}finally{URL.revokeObjectURL(l)}}const Sct={formatDate(e){const t=e.value??e.date??e.timestamp;if(t==null)return"";const n=new Date(t);return isNaN(n.getTime())?String(t):n.toLocaleString()}};function Ect(e,t){if(!t||t==="/")return e;const n=t.replace(/^\//,"").split("/").map(i=>i.replace(/~1/g,"/").replace(/~0/g,"~"));let r=e;for(const i of n){if(r==null||typeof r!="object")return;r=r[i]}return r}function kct(e){return typeof e=="object"&&e!==null&&typeof e.path=="string"}function _ct(e){return typeof e=="object"&&e!==null&&typeof e.call=="string"}function jB(e,t){if(kct(e))return Ect(t,e.path);if(_ct(e)){const n=Sct[e.call],r={};for(const[i,s]of Object.entries(e.args??{}))r[i]=jB(s,t);return n?n(r):`[unknown fn: ${e.call}]`}return e}function Tct(e,t){const n=jB(e,t);return n==null?"":typeof n=="string"?n:String(n)}const Vge=new Map;function S0(e,t){Vge.set(e,t)}function Cct(e){return Vge.get(e)}function Act(e,t,n){const r=t.replace(/^\//,"").split("/").map(s=>s.replace(/~1/g,"/").replace(/~0/g,"~"));let i=e;for(let s=0;sjB(r,e.dataModel),resolveString:r=>Tct(r,e.dataModel),dispatchAction:t,render:r=>{if(!r)return null;const i=e.components[r];if(!i)return null;const s=Cct(i.component)??Nct;return o.jsx(s,{node:i,ctx:n},r)}};return o.jsx("div",{className:"a2ui-surface","data-a2ui-surface":e.surfaceId,children:n.render(e.rootId)})}function qge(e){const t=p.useRef(null),n=p.useRef(!0),r=28,i=p.useCallback(()=>{const s=t.current;s&&(n.current=s.scrollHeight-s.scrollTop-s.clientHeight{const s=t.current;s&&n.current&&(s.scrollTop=s.scrollHeight)},[e]),{ref:t,onScroll:i}}function Lj({value:e,skillPrefix:t="/",onRemoveSkill:n,onRemoveAgent:r}){return e.skills.length===0&&!e.targetAgent?null:o.jsxs("div",{className:"invocation-chips","aria-label":"本轮调用上下文",children:[e.skills.map(i=>o.jsxs("span",{className:"invocation-chip invocation-chip--skill",title:i.description,children:[o.jsx(xw,{"aria-hidden":!0}),o.jsxs("span",{children:[t,i.name]}),n?o.jsx("button",{type:"button",onClick:()=>n(i.name),"aria-label":`移除技能 ${i.name}`,children:o.jsx(Oa,{})}):null]},i.name)),e.targetAgent?o.jsxs("span",{className:"invocation-chip invocation-chip--agent",title:e.targetAgent.description,children:[o.jsx(Rae,{"aria-hidden":!0}),o.jsx("span",{children:e.targetAgent.name}),r?o.jsx("button",{type:"button",onClick:r,"aria-label":`移除 Agent ${e.targetAgent.name}`,children:o.jsx(Oa,{})}):null]}):null]})}function RB(e=""){return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e==="application/pdf"?"pdf":e==="text/markdown"?"markdown":"text"}function Xge(e){var n,r,i,s;const t=RB(e.mimeType);return t==="pdf"?"PDF":t==="markdown"?"MD":t==="video"?((r=(n=e.mimeType)==null?void 0:n.split("/")[1])==null?void 0:r.toUpperCase())??"VIDEO":t==="image"?((s=(i=e.mimeType)==null?void 0:i.split("/")[1])==null?void 0:s.toUpperCase())??"IMAGE":"TXT"}function Gge(e){return e?e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:""}function Wge(e,t){return e.previewUrl?e.previewUrl:e.data?`data:${e.mimeType??"application/octet-stream"};base64,${e.data}`:e.uri?doe(t,e.uri):""}function Rct({kind:e}){return e==="image"?o.jsx(r9,{}):e==="video"?o.jsx(Pae,{}):e==="pdf"?o.jsx(HRe,{}):o.jsx(t9,{})}function $j({appName:e,items:t,compact:n=!1,onRemove:r}){const[i,s]=p.useState(null);return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`media-grid${n?" media-grid--compact":""}`,children:t.map(a=>{const l=RB(a.mimeType),c=Wge(a,e),u=a.status==="uploading"||a.status==="error"||!c,d=o.jsxs("button",{type:"button",className:"media-card-main",disabled:u,onClick:l==="image"?void 0:()=>s(a),"aria-label":`预览 ${a.name??"附件"}`,children:[l==="image"&&c?o.jsx("img",{className:"media-card-image",src:c,alt:a.name??"图片",loading:"lazy"}):l==="video"&&c?o.jsxs("div",{className:"media-card-video-container",children:[o.jsx("video",{className:"media-card-video",src:c,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}),o.jsx("span",{className:"media-card-video-play",children:o.jsx(rIe,{})})]}):o.jsx("span",{className:"media-card-icon",children:o.jsx(Rct,{kind:l})}),o.jsxs("span",{className:"media-card-copy",children:[o.jsx("span",{className:"media-card-name",children:a.name??"附件"}),o.jsxs("span",{className:"media-card-meta",children:[o.jsx("span",{className:"media-card-type",children:Xge(a)}),a.status==="uploading"?o.jsxs(o.Fragment,{children:[o.jsx(lr,{className:"media-card-spinner"})," 上传中"]}):a.status==="error"?a.error??"上传失败":Gge(a.sizeBytes)]})]}),!n&&a.status!=="uploading"&&a.status!=="error"?o.jsx(uy,{className:"media-card-open"}):null]});return o.jsxs(oi.div,{className:`media-card media-card--${l}${a.status==="error"?" media-card--error":""}`,layout:!0,initial:{opacity:0,scale:.985,y:4},animate:{opacity:1,scale:1,y:0},children:[l==="image"&&!u?o.jsx(Eae,{src:c,children:d}):d,r?o.jsx("button",{type:"button",className:"media-card-remove","aria-label":`移除 ${a.name??"附件"}`,onClick:()=>r(a.id),children:o.jsx(Oa,{})}):null]},a.id)})}),o.jsx(hu,{children:i?o.jsx(Ict,{appName:e,item:i,onClose:()=>s(null)}):null})]})}function Ict({appName:e,item:t,onClose:n}){const r=p.useMemo(()=>Wge(t,e),[e,t]),i=RB(t.mimeType),[s,a]=p.useState(""),[l,c]=p.useState(i==="text"||i==="markdown"),[u,d]=p.useState("");return p.useEffect(()=>{const f=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[n]),p.useEffect(()=>{if(i!=="text"&&i!=="markdown")return;const f=new AbortController;return c(!0),d(""),fetch(r,{signal:f.signal}).then(h=>{if(!h.ok)throw new Error(`HTTP ${h.status}`);return h.text()}).then(a).catch(h=>{f.signal.aborted||d(h instanceof Error?h.message:String(h))}).finally(()=>{f.signal.aborted||c(!1)}),()=>f.abort()},[i,r]),o.jsx(oi.div,{className:"media-viewer-backdrop",role:"dialog","aria-modal":"true","aria-label":t.name??"附件预览",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onMouseDown:f=>{f.target===f.currentTarget&&n()},children:o.jsxs(oi.div,{className:"media-viewer",initial:{opacity:0,y:18,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.99},transition:{type:"spring",stiffness:420,damping:30},children:[o.jsxs("header",{className:"media-viewer-header",children:[o.jsxs("div",{children:[o.jsx("strong",{children:t.name??"附件"}),o.jsxs("span",{children:[Xge(t),t.sizeBytes?` · ${Gge(t.sizeBytes)}`:""]})]}),o.jsxs("nav",{children:[o.jsx("a",{href:r,download:t.name,"aria-label":"下载",children:o.jsx(NN,{})}),o.jsx("button",{type:"button",onClick:n,"aria-label":"关闭",children:o.jsx(Oa,{})})]})]}),o.jsxs("div",{className:`media-viewer-body media-viewer-body--${i}`,children:[i==="image"?o.jsx("img",{src:r,alt:t.name??"图片"}):null,i==="video"?o.jsx("div",{className:"media-viewer-video-wrapper",children:o.jsx("video",{src:r,controls:!0,autoPlay:!0,playsInline:!0,preload:"auto",className:"media-viewer-video"})}):null,i==="pdf"?o.jsx("iframe",{src:r,title:t.name??"PDF"}):null,l?o.jsxs("div",{className:"media-viewer-loading",children:[o.jsx(lr,{})," 正在读取文档…"]}):null,!l&&u?o.jsxs("div",{className:"media-viewer-loading",children:["文档加载失败:",u]}):null,!l&&i==="markdown"?o.jsx("div",{className:"media-document",children:o.jsx(xu,{text:s})}):null,!l&&i==="text"?o.jsx("pre",{className:"media-document media-document--plain",children:s}):null]})]})})}function Dct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"10.25",cy:"10.25",r:"6.25"}),o.jsx("path",{d:"M4.15 10.25h12.2M10.25 4c1.65 1.72 2.5 3.8 2.5 6.25s-.85 4.53-2.5 6.25M10.25 4c-1.65 1.72-2.5 3.8-2.5 6.25s.85 4.53 2.5 6.25M14.8 14.8 20 20"})]})}function Pct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"3.25",y:"5.25",width:"15.5",height:"13.5",rx:"2.25"}),o.jsx("circle",{cx:"8.1",cy:"9.3",r:"1.35"}),o.jsx("path",{d:"m4.7 16.5 3.65-3.7 2.45 2.25 2.2-2.2 4.35 4.1"}),o.jsx("path",{d:"m19.4 2.75.48 1.37 1.37.48-1.37.48-.48 1.37-.48-1.37-1.37-.48 1.37-.48.48-1.37Z",fill:"currentColor",stroke:"none"})]})}function IB(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{className:"video-generate-icon__body",d:"M3.25 9h17.5v7.35a2.4 2.4 0 0 1-2.4 2.4H5.65a2.4 2.4 0 0 1-2.4-2.4V9Z"}),o.jsxs("g",{className:"video-generate-icon__clapper",children:[o.jsx("path",{d:"M3.25 9V7.65a2.4 2.4 0 0 1 2.4-2.4h12.7a2.4 2.4 0 0 1 2.4 2.4V9H3.25Z"}),o.jsx("path",{d:"M6.75 5.25 9.3 9M12 5.25 14.55 9M17.25 5.25 19.8 9"})]}),o.jsx("path",{d:"m10.25 11.45 4 2.55-4 2.55v-5.1Z"})]})}function Mct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M4.25 5.25h15.5v10.5H4.25zM8.25 19.75h7.5M12 15.75v4"}),o.jsx("path",{d:"m7.25 12.75 2.35-2.4 2.15 1.65 3.4-3.6 1.6 1.55"}),o.jsx("circle",{cx:"7.25",cy:"8.4",r:".7",fill:"currentColor",stroke:"none"})]})}function Lct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M5 7.4c0-1.55 3.13-2.8 7-2.8s7 1.25 7 2.8-3.13 2.8-7 2.8-7-1.25-7-2.8Z"}),o.jsx("path",{d:"M5 7.4v4.55c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8V7.4M5 11.95v4.55c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8v-4.55"}),o.jsx("path",{d:"M8.2 12.25h.01M8.2 16.8h.01"})]})}function $ct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M4.25 4.25h4.5v15.5h-4.5zM8.75 5.75h5v14h-5zM13.75 4.25h4.1v10.25h-4.1z"}),o.jsx("path",{d:"M5.75 7h1.5M10.25 8.25h2M10.25 11h2M15.15 7h1.3"}),o.jsx("circle",{cx:"17.45",cy:"17.35",r:"2.45"}),o.jsx("path",{d:"m19.25 19.15 1.55 1.55"})]})}function Bct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M4.25 6.25h6.25c1 0 1.5.55 1.5 1.45v11.05c0-.9-.5-1.45-1.5-1.45H4.25V6.25Z"}),o.jsx("path",{d:"M19.75 9.1v8.2H13.5c-1 0-1.5.55-1.5 1.45V7.7c0-.9.5-1.45 1.5-1.45h2.15"}),o.jsx("path",{d:"m19 3.2.58 1.62 1.62.58-1.62.58L19 7.6l-.58-1.62-1.62-.58 1.62-.58L19 3.2Z",fill:"currentColor",stroke:"none"})]})}function Qct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"m4.2 8.4 1.15 10.2h13.3L19.8 8.4"}),o.jsx("path",{d:"M4.2 8.4h15.6L17.9 5H6.1L4.2 8.4Z"}),o.jsx("path",{d:"M7.2 12.2c1.1-1 2.25 1.25 3.4.25 1.05-.9 2.15 1.3 3.3.25"}),o.jsx("path",{d:"m8.2 15.1 1.45 1.35 1.45-1.35M13.55 16.45h2.35"})]})}function Uct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"6",cy:"6.25",r:"2.25"}),o.jsx("circle",{cx:"18",cy:"6.25",r:"2.25"}),o.jsx("circle",{cx:"12",cy:"17.75",r:"2.25"}),o.jsx("path",{d:"m7.7 7.75 2.7 7.55M16.3 7.75l-2.7 7.55M8.25 6.25h7.5"})]})}function LW(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"9",cy:"8",r:"3"}),o.jsx("path",{d:"M3.75 18.75c.45-3.05 2.2-4.65 5.25-4.65s4.8 1.6 5.25 4.65"}),o.jsx("path",{d:"M17.75 4.25v5.5M15 7h5.5M16 13.25h4.25M18.125 11.125v4.25"})]})}function Fct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"4",y:"4.25",width:"16",height:"5",rx:"1.5"}),o.jsx("rect",{x:"4",y:"14.75",width:"16",height:"5",rx:"1.5"}),o.jsx("path",{d:"M7.25 6.75h.01M7.25 17.25h.01M10 6.75h6.5M10 17.25h6.5"})]})}function zct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M6 3.75h8l4 4v12.5H6V3.75Z"}),o.jsx("path",{d:"M14 3.75v4h4M8.75 11h6.5M8.75 14.25h6.5M8.75 17.5h4"})]})}function Vct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"3.75",y:"4.5",width:"16.5",height:"15",rx:"2.5"}),o.jsx("path",{d:"m7.5 9 2.75 2.5L7.5 14M12.5 14h4"}),o.jsx("path",{d:"M3.75 7.5h16.5",opacity:".62"})]})}function DB(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m6 3.25 4.5 4.75L6 12.75"})})}function Hct({definition:e,label:t,done:n,open:r,onToggle:i}){const s=e.icon,a=t??(n?e.doneLabel:e.runningLabel);return o.jsxs("button",{type:"button",className:`builtin-tool-head${n?" is-done":" is-running"}`,"data-tool-tone":e.tone,onClick:i,"aria-expanded":r,children:[o.jsx("span",{className:"builtin-tool-icon","aria-hidden":"true",children:o.jsx(s,{})}),n?o.jsx("span",{className:"builtin-tool-label",children:a}):o.jsx(En,{className:"builtin-tool-label",duration:2.4,spread:18,"aria-live":"polite",children:a}),o.jsx(DB,{className:`builtin-tool-chevron${r?" is-open":""}`})]})}function $l(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function yn(e){return typeof e=="string"?e:""}function $W(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function kc(e){return Array.isArray(e)?e:[]}function vL(e){let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch{return{}}const n=$l(t)??{};return $l(n.result)??n}function Bj(e){if(typeof e=="string")try{return Bj(JSON.parse(e))}catch{return e}const t=$l(e);if(!t)return"";const n=$l(t.result);return yn(t.error)||yn(t.message)||yn(n==null?void 0:n.error)||yn(n==null?void 0:n.message)}function qct(e){if(e.kind==="tool")return"tool";if(e.kind==="knowledge_base")return"knowledge_base";const t=$l(e.metadata),n=yn(t==null?void 0:t.source_type).toLowerCase(),r=yn(e.source).toLowerCase();return n==="skillhub"||r.startsWith("skill_hub:")?"skill_hub":"skill_space"}function Xct(e){return e==="veadk_builtin_tools"?"工具":e==="agentkit_knowledge"?"AgentKit 知识库":e.startsWith("skill_hub:")?`Skill Hub ${e.slice(10)}`:e.startsWith("skill_space:")?`AgentKit 技能中心 ${e.slice(12)}`:e||"未知来源"}function Gct(e){return e==="veadk_builtin_tools"?"tool":e==="agentkit_knowledge"?"knowledge_base":e.startsWith("skill_hub:")?"skill_hub":"skill_space"}function Wct(e){const t=vL(e),n=$l(t.capabilities)??{},r=kc(t.resources).flatMap(s=>{const a=$l(s);if(!a)return[];const l=a.kind==="tool"?"tool":a.kind==="knowledge_base"?"knowledge_base":"skill";return[{ref:yn(a.ref),kind:l,category:qct(a),name:yn(a.name)||yn(a.ref)||"未命名资源",description:yn(a.description),source:yn(a.source),version:yn(a.version)}]}),i=kc(t.sources).flatMap(s=>{const a=$l(s);if(!a)return[];const l=yn(a.source),c=yn(a.status),u=c==="error"?"error":c==="skipped"?"skipped":"ok";return[{source:l,category:Gct(l),label:Xct(l),status:u,count:$W(a.count),message:yn(a.message),searchKeywords:kc(a.search_keywords).map(yn).filter(Boolean)}]});return{collectionId:yn(t.collection_id),capabilities:{googleAdkVersion:yn(n.google_adk_version),agentTypes:kc(n.agent_types).map(yn).filter(Boolean),maxOrchestrationDepth:$W(n.max_orchestration_depth)},resources:r,sources:i,counts:{all:r.length,skill_hub:r.filter(s=>s.category==="skill_hub").length,skill_space:r.filter(s=>s.category==="skill_space").length,knowledge_base:r.filter(s=>s.category==="knowledge_base").length,tool:r.filter(s=>s.category==="tool").length}}}function Yct(e,t){return{resources:e.resources.filter(n=>n.category===t),sources:e.sources.filter(n=>n.category===t)}}function Yge(e,t){const n=vL(e),r=vL(t),i=new Map(kc(r.results).flatMap(u=>{const d=$l(u),f=yn(d==null?void 0:d.name);return d&&f?[[f,d]]:[]})),s=kc(n.agents).flatMap(u=>{const d=$l(u),f=yn(d==null?void 0:d.name);return d&&f?[d]:[]}),a=new Set(s.map(u=>yn(u.name))),l=[...i.entries()].filter(([u])=>!a.has(u)).map(([u])=>({name:u})),c=[...s,...l].map(u=>{const d=yn(u.name),f=kc(u.nodes).flatMap(E=>{const k=$l(E);return k?[k]:[]}),h=yn(u.root_node),m=f.find(E=>yn(E.id)===h),g=f.filter(E=>yn(E.id)!==h).map(E=>({id:yn(E.id)||"未命名 Agent",type:yn(E.type)||"llm",description:yn(E.description)})),b=i.get(d),y=yn(b==null?void 0:b.status),O=y==="failed"?"failed":y==="completed"?"completed":"running",v=BW(b==null?void 0:b.resources),x=v.length>0?v:BW(f.flatMap(E=>kc(E.resources))),w=QW(b==null?void 0:b.python_tools),S=w.length>0?w:QW(f.flatMap(E=>kc(E.python_tools)));return{name:d,description:yn(b==null?void 0:b.description)||yn(m==null?void 0:m.description)||yn(u.task),task:yn(u.task),rootType:yn(b==null?void 0:b.root_type)||yn(m==null?void 0:m.type)||"llm",nodeCount:f.length,subAgentCount:g.length,resourceCount:x.length,pythonToolCount:S.length,skills:x.filter(E=>E.kind==="skill"),knowledgeBases:x.filter(E=>E.kind==="knowledge_base"),builtinTools:x.filter(E=>E.kind==="tool"),pythonTools:S,subAgents:g,status:O,output:yn(b==null?void 0:b.output),error:yn(b==null?void 0:b.error)}});return{collectionId:yn(r.collection_id)||yn(n.collection_id),agents:c,completedCount:c.filter(u=>u.status==="completed").length,failedCount:c.filter(u=>u.status==="failed").length,runningCount:c.filter(u=>u.status==="running").length}}function Zct(e,t){return!!Bj(t)||Yge(e,t).failedCount>0}function BW(e){const t=new Set;return kc(e).flatMap(n=>{const r=$l(n),i=yn(r?r.ref:n);if(!i||t.has(i))return[];t.add(i);const s=yn(r==null?void 0:r.kind),a=s==="tool"||i.startsWith("veadk_tool:")?"tool":s==="knowledge_base"||i.startsWith("agentkit_kb:")?"knowledge_base":"skill",l=i.split(":");return[{ref:i,kind:a,name:yn(r==null?void 0:r.name)||l[l.length-1]||i,description:yn(r==null?void 0:r.description),version:yn(r==null?void 0:r.version),source:yn(r==null?void 0:r.source)}]})}function QW(e){const t=new Set;return kc(e).flatMap(n=>{const r=$l(n),i=yn(r==null?void 0:r.name),s=yn(r==null?void 0:r.code),a=`${i}\0${s}`;return!r||!i||t.has(a)?[]:(t.add(a),[{name:i,description:yn(r.description),code:s,entrypoint:yn(r.entrypoint)||i,dependencies:kc(r.dependencies).map(yn).filter(Boolean)}])})}function Kct({branch:e}){return o.jsxs("div",{className:`branch-compare__body${e.status==="running"?" is-streaming":""}`,"aria-live":"polite",children:[e.content?o.jsx(xu,{text:e.content,streaming:e.status==="running"}):null,e.status==="running"?o.jsx("span",{className:"branch-compare__caret","aria-hidden":"true"}):null,e.error?o.jsx("p",{className:"branch-compare__error",children:e.error}):null]})}function Jct({args:e,response:t,status:n,onBranchSelect:r}){const i=p.useMemo(()=>vle(e,t,n),[e,t,n]),[s,a]=p.useState(0);return o.jsxs("section",{className:"branch-compare","aria-label":"分支对比",children:[o.jsx("div",{className:"branch-compare__tabs",role:"tablist","aria-label":"选择方向",children:i.branches.map((l,c)=>o.jsx("button",{className:`branch-compare__tab${s===c?" is-active":""}`,type:"button",role:"tab","aria-selected":s===c,"aria-controls":`branch-compare-panel-${c}`,onClick:()=>a(c),children:o.jsx(ta,{color:"info",size:"sm",variant:"soft",children:l.label})},`${l.label}:${c}`))}),o.jsx("div",{className:"branch-compare__branches",children:i.branches.map((l,c)=>o.jsxs("article",{className:`branch-compare__branch${s===c?" is-active":""}`,id:`branch-compare-panel-${c}`,role:"tabpanel",children:[o.jsx("header",{className:"branch-compare__head",children:o.jsx(ta,{color:"info",size:"sm",variant:"soft",children:l.label})}),o.jsx(Kct,{branch:l}),o.jsx("footer",{className:"branch-compare__footer",children:o.jsx(Nt,{type:"button",color:"info",variant:"ghost",size:"sm",pill:!1,disabled:l.status!=="completed",onClick:()=>r==null?void 0:r(l),children:"继续这个方向"})})]},`${l.label}:${c}`))})]})}function Zge({controlled:e,default:t,name:n,state:r="value"}){const{current:i}=p.useRef(e!==void 0),[s,a]=p.useState(t),l=i?e:s,c=p.useCallback(u=>{i||a(u)},[]);return[l,c]}const PB={...r0},UW={};function qg(e,t){const n=p.useRef(UW);return n.current===UW&&(n.current=e(t)),n}const wD=PB.useInsertionEffect,eut=wD&&wD!==PB.useLayoutEffect?wD:e=>e();function ja(e){const t=qg(tut).current;return t.next=e,eut(t.effect),t.trampoline}function tut(){const e={next:void 0,callback:nut,trampoline:(...t)=>{var n;return(n=e.callback)==null?void 0:n.call(e,...t)},effect:()=>{e.callback=e.next}};return e}function nut(){}const rut=()=>{},Zo=typeof document<"u"?p.useLayoutEffect:rut,Kge=p.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function iut(){return p.useContext(Kge)}function sut(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,s=ja(i),[,a]=p.useState(!1),l=qg(out).current,c=qg(aut).current,u=p.useRef(0),d=p.useRef(!0),f=p.useRef([]),h=p.useRef(null),m=ja(()=>{d.current||(d.current=!0,a(S=>!S))}),g=ja((S,E)=>{c.set(S,E),m()}),b=ja(S=>{c.delete(S),m()}),y=ja(S=>{const E=new Map;return n.current.length=0,r&&(r.current.length=0),S.forEach(k=>{var _,C;E.set(k.element,{...k.registration.metadata??{},index:k.index}),n.current[k.index]=k.element,r&&(r.current[k.index]=k.registration.label!==void 0?k.registration.label:((C=(_=k.registration.textRef)==null?void 0:_.current)==null?void 0:C.textContent)??k.element.textContent)}),u.current=n.current.length,E});function O(S){var _;if((_=h.current)==null||_.disconnect(),h.current=null,typeof MutationObserver!="function"||S.length<2)return;const E=new MutationObserver(C=>{if(!uut(C))return;let T=null;for(const A of S)if(A.isConnected){if(T&&Jge(T,A)>0){E.disconnect(),m();return}T=A}});h.current=E;const k=new Set;for(let C=1;CE.observe(C,{childList:!0}))}const v=ja(()=>{const[S,E]=lut(c),k=y(S);O(E),f.current=S,d.current=!1,l.forEach(_=>_(k)),s(k)});Zo(()=>(d.current||y(f.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,y]),Zo(()=>{d.current&&v()}),Zo(()=>()=>{var S;(S=h.current)==null||S.disconnect(),d.current=!0},[]);const x=ja(S=>(l.add(S),()=>{l.delete(S)})),w=p.useMemo(()=>({register:g,unregister:b,subscribeMapChange:x,nextIndexRef:u}),[g,b,x,u]);return o.jsx(Kge.Provider,{value:w,children:t})}function aut(){return new Map}function out(){return new Set}function lut(e){const t=new Set,n=[],r=[];e.forEach((s,a)=>{if(!a.isConnected)return;const l=s.index,c={index:l??-1,element:a,registration:s};l===null?r.push(c):l>=0&&(t.add(l),n.push(c))});let i=0;return r.sort((s,a)=>Jge(s.element,a.element)),r.forEach(s=>{for(;t.has(i);)i+=1;s.index=i,n.push(s),i+=1}),t.size>0&&n.sort((s,a)=>s.index-a.index),[n,r.map(s=>s.element)]}function cut(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function uut(e){for(const t of e)for(let n=0;ns.searchParams.append("args[]",a)),`${t} error #${r}; visit ${s} for the full message.`}}const CE=dut("https://base-ui.com/production-error","Base UI"),e0e=p.createContext(void 0);function t0e(){const e=p.useContext(e0e);if(e===void 0)throw new Error(CE(10));return e}function sA(e,t,n,r){const i=qg(n0e).current;return hut(i,e,t,n,r)&&r0e(i,[e,t,n,r]),i.callback}function fut(e){const t=qg(n0e).current;return put(t,e)&&r0e(t,e),t.callback}function n0e(){return{callback:null,cleanup:null,refs:[]}}function hut(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function put(e,t){return e.refs.length!==t.length||e.refs.some((n,r)=>n!==t[r])}function r0e(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const r=Array(t.length).fill(null);for(let i=0;i{for(let i=0;i=e}function FW(e){if(!p.isValidElement(e))return null;const t=e,n=t.props;return(gut(19)?n==null?void 0:n.ref:t.ref)??null}function wL(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}const but=Object.freeze([]),Gb=Object.freeze({});function yut(e,t){const n={};for(const r in e){const i=e[r];if(t!=null&&t.hasOwnProperty(r)){const s=t[r](i);s!=null&&Object.assign(n,s);continue}i===!0?n[`data-${r.toLowerCase()}`]="":i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Out(e,t){return typeof e=="function"?e(t):e}function i0e(e,t){return typeof e=="function"?e(t):e}const MB={};function LB(e,t,n,r,i){if(!n&&!r&&!e)return aA(t);let s=aA(e);return t&&(s=lT(s,t)),n&&(s=lT(s,n)),r&&(s=lT(s,r)),s}function xut(e){if(e.length===0)return MB;if(e.length===1)return aA(e[0]);let t=aA(e[0]);for(let n=1;n=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function $B(e){return typeof e=="function"}function a0e(e,t){return $B(e)?e(t):e??MB}function Sut(e,t){return t?e?(...n)=>{const r=n[0];if(c0e(r)){const s=r;oA(s);const a=t(...n);return s.baseUIHandlerPrevented||e==null||e(...n),a}const i=t(...n);return e==null||e(...n),i}:o0e(t):e}function o0e(e){return e&&((...t)=>{const n=t[0];return c0e(n)&&oA(n),e(...t)})}function oA(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function l0e(e,t){return t?e?t+" "+e:t:e}function c0e(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function AE(e,t,n={}){const r=t.render,i=Eut(t,n);if(n.enabled===!1)return null;const s=n.state??Gb;return Tut(e,r,i,s)}function Eut(e,t={}){const{className:n,style:r,render:i}=e,{state:s=Gb,ref:a,props:l,stateAttributesMapping:c,enabled:u=!0}=t,d=u?Out(n,s):void 0,f=u?i0e(r,s):void 0,h=u?yut(s,c):Gb,m=u&&l?kut(l):void 0,g=u?wL(h,m)??{}:Gb;return typeof document<"u"&&(u?Array.isArray(a)?g.ref=fut([g.ref,FW(i),...a]):g.ref=sA(g.ref,FW(i),a):sA(null,null)),u?(d!==void 0&&(g.className=l0e(g.className,d)),f!==void 0&&(g.style=wL(g.style,f)),g):Gb}function kut(e){return Array.isArray(e)?xut(e):LB(void 0,e)}const _ut=Symbol.for("react.lazy");function Tut(e,t,n,r){if(t){if(typeof t=="function")return t(n,r);const i=LB(n,t.props);i.ref=n.ref;let s=t;return(s==null?void 0:s.$$typeof)===_ut&&(s=p.Children.toArray(t)[0]),p.cloneElement(s,i)}if(e&&typeof e=="string")return Cut(e,n);throw new Error(CE(8))}function Cut(e,t){return e==="button"?p.createElement("button",{type:"button",...t,key:t.key}):e==="img"?p.createElement("img",{alt:"",...t,key:t.key}):p.createElement(e,t)}const Aut={value:()=>null},u0e=p.forwardRef(function(t,n){const{render:r,className:i,disabled:s=!1,hiddenUntilFound:a,keepMounted:l,loopFocus:c,onValueChange:u,multiple:d=!1,orientation:f="vertical",value:h,defaultValue:m,style:g,...b}=t,y=p.useMemo(()=>{if(h===void 0)return m??[]},[h,m]),O=p.useRef([]),[v,x]=Zge({controlled:h,default:y,name:"Accordion",state:"value"}),w=ja((_,C,T)=>{if(d)if(C){const A=v.slice();if(A.push(_),u==null||u(A,T),T.isCanceled)return;x(A)}else{const A=v.filter(j=>j!==_);if(u==null||u(A,T),T.isCanceled)return;x(A)}else{const A=v[0]===_?[]:[_];if(u==null||u(A,T),T.isCanceled)return;x(A)}}),S=p.useMemo(()=>({value:v,disabled:s,orientation:f}),[v,s,f]),E=p.useMemo(()=>({disabled:s,handleValueChange:w,hiddenUntilFound:a??!1,keepMounted:l??!1,state:S,value:v}),[s,w,a,l,S,v]),k=AE("div",t,{state:S,ref:n,props:b,stateAttributesMapping:Aut});return o.jsx(e0e.Provider,{value:E,children:o.jsx(sut,{elementsRef:O,children:k})})});let zW=0;function Nut(e,t="mui"){const[n,r]=p.useState(e),i=e||n;return p.useEffect(()=>{n==null&&(zW+=1,r(`${t}-${zW}`))},[n,t]),i}const VW=PB.useId;function jut(e,t){if(VW!==void 0){const n=VW();return`${t}-${n}`}return Nut(e,t)}function SL(e){return jut(e,"base-ui")}const Rut="none",Iut="trigger-press";function d0e(e,t,n,r){let i=!1,s=!1;const a=Gb;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){s=!0},get isCanceled(){return i},get isPropagationAllowed(){return s},trigger:n,...a}}function Dut(e){p.useEffect(e,but)}const T2=null;let Put=class{constructor(){kr(this,"callbacks",[]);kr(this,"callbacksCount",0);kr(this,"nextId",1);kr(this,"startId",1);kr(this,"isScheduled",!1);kr(this,"tick",t=>{var i;this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let s=0;s=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}},C2=new Put;class kl{constructor(){kr(this,"currentId",T2);kr(this,"cancel",()=>{this.currentId!==T2&&(C2.cancel(this.currentId),this.currentId=T2)});kr(this,"disposeEffect",()=>this.cancel)}static create(){return new kl}static request(t){return C2.request(t)}static cancel(t){return C2.cancel(t)}request(t){this.cancel(),this.currentId=C2.request(()=>{this.currentId=T2,t()})}}function Mut(){const e=qg(kl.create).current;return Dut(e.disposeEffect),e}function Lut(e,t=!1,n=!1){const[r,i]=p.useState(e&&t?"idle":void 0),[s,a]=p.useState(e);return e&&!s&&(a(!0),i("starting")),!e&&s&&r!=="ending"&&!n&&i("ending"),!e&&!s&&r==="ending"&&i(void 0),Zo(()=>{if(!e&&s&&r!=="ending"&&n){const l=kl.request(()=>{i("ending")});return()=>{kl.cancel(l)}}},[e,s,r,n]),Zo(()=>{if(!e||t)return;const l=kl.request(()=>{i(void 0)});return()=>{kl.cancel(l)}},[t,e]),Zo(()=>{if(!e||!t)return;e&&s&&r!=="idle"&&i("starting");const l=kl.request(()=>{i("idle")});return()=>{kl.cancel(l)}},[t,e,s,r]),{mounted:s,setMounted:a,transitionStatus:r}}function $ut(e){const{open:t,defaultOpen:n,onOpenChange:r,disabled:i}=e,[s,a]=Zge({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:l,setMounted:c,transitionStatus:u}=Lut(s,!0,!0),d=SL(),[f,h]=p.useState(),m=f===null?void 0:f??d,g=ja(b=>{const y=!s,O=d0e(Iut,b.nativeEvent);r(y,O),!O.isCanceled&&a(y)});return p.useMemo(()=>({defaultPanelId:d,disabled:i,handleTrigger:g,mounted:l,open:s,panelId:m,setMounted:c,setOpen:a,setPanelIdState:h,transitionStatus:u}),[d,i,g,l,s,m,c,a,h,u])}const f0e=p.createContext(void 0);function h0e(){const e=p.useContext(f0e);if(e===void 0)throw new Error(CE(15));return e}function But(e={}){const{guess:t,label:n,metadata:r,textRef:i,index:s}=e,{register:a,unregister:l,subscribeMapChange:c,nextIndexRef:u}=iut(),d=p.useRef(-1),[f,h]=p.useState(s==null&&t?()=>{if(d.current===-1){const y=u.current;u.current+=1,d.current=y}return d.current}:-1),m=s??f,g=p.useRef(null),b=p.useCallback(y=>{const O=g.current;O&&l(O),g.current=y,y&&a(y,{metadata:r??null,index:s??null,label:n,textRef:i})},[s,a,l,r,n,i]);return Zo(()=>{if(s==null)return c(y=>{var v;const O=g.current?(v=y.get(g.current))==null?void 0:v.index:null;O!=null&&h(O)})},[s,c]),{ref:b,index:m}}const p0e=p.createContext(void 0);function BB(){const e=p.useContext(p0e);if(e===void 0)throw new Error(CE(9));return e}let HW=function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e}({});const Qut={"data-starting-style":""},Uut={"data-ending-style":""},Fut={transitionStatus(e){return e==="starting"?Qut:e==="ending"?Uut:null}};let QB=function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=HW.startingStyle]="startingStyle",e[e.endingStyle=HW.endingStyle]="endingStyle",e}({}),zut=function(e){return e.panelOpen="data-panel-open",e}({});const Vut={[QB.open]:""},Hut={[QB.closed]:""},qut={open(e){return e?{[zut.panelOpen]:""}:null}},Xut={open(e){return e?Vut:Hut}};let Gut=function(e){return e.index="data-index",e.disabled="data-disabled",e.open="data-open",e}({});const UB={...Xut,index:e=>({[Gut.index]:String(e)}),...Fut,value:()=>null},m0e=p.forwardRef(function(t,n){const{className:r,disabled:i=!1,onOpenChange:s,render:a,value:l,style:c,...u}=t,{ref:d,index:f}=But(),h=sA(n,d),{disabled:m,handleValueChange:g,state:b,value:y}=t0e(),O=SL(),v=l??O,x=i||m,w=y.indexOf(v)!==-1,S=ja((N,D)=>{s==null||s(N,D),!D.isCanceled&&g(v,N,D)}),E=$ut({open:w,onOpenChange:S,disabled:x}),k=p.useMemo(()=>({open:E.open,disabled:E.disabled,transitionStatus:E.transitionStatus}),[E.open,E.disabled,E.transitionStatus]),_=p.useMemo(()=>({...E,onOpenChange:S,state:k}),[E,k,S]),C=p.useMemo(()=>({...b,hidden:!w&&!E.mounted,index:f,disabled:x,open:w}),[E.mounted,x,f,w,b]),T=SL(),[A,j]=p.useState(),L=A===null?void 0:A??T,I=p.useMemo(()=>({defaultTriggerId:T,open:w,state:C,setTriggerId:j,triggerId:L}),[T,w,C,j,L]),M=AE("div",t,{state:C,ref:h,props:u,stateAttributesMapping:UB});return o.jsx(f0e.Provider,{value:_,children:o.jsx(p0e.Provider,{value:I,children:M})})}),g0e=p.forwardRef(function(t,n){const{render:r,className:i,style:s,...a}=t,{state:l}=BB();return AE("h3",t,{state:l,ref:n,props:a,stateAttributesMapping:UB})}),Wut=p.createContext(void 0);function Yut(e=!1){const t=p.useContext(Wut);if(t===void 0&&!e)throw new Error(CE(16));return t}function Zut(e){const{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:s}=e,a=r&&t!==!1,l=r&&t===!1;return{props:p.useMemo(()=>{const u={onKeyDown(d){n&&t&&d.key!=="Tab"&&d.preventDefault()}};return r||(u.tabIndex=i,!s&&n&&(u.tabIndex=t?i:-1)),(s&&(t||a)||!s&&n)&&(u["aria-disabled"]=n),s&&(!t||l)&&(u.disabled=n),u},[r,n,t,a,l,s,i])}}function SD(e,t,{detail:n=0}={}){e.dispatchEvent(new(Ka(e)).PointerEvent("click",{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function Kut(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:s}=e,a=p.useRef(null),l=Yut(!0),c=s??l!==void 0,{props:u}=Zut({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),d=p.useCallback(()=>{const m=a.current;ED(m)&&c&&t&&u.disabled===void 0&&m.disabled&&(m.disabled=!1)},[t,u.disabled,c]);Zo(d,[d]);const f=p.useCallback((m={})=>{const{onClick:g,onMouseDown:b,onKeyUp:y,onKeyDown:O,onPointerDown:v,...x}=m;return LB({onClick(w){if(t){w.preventDefault();return}g==null||g(w)},onMouseDown(w){t||b==null||b(w)},onKeyDown(w){if(t||(oA(w),O==null||O(w),w.baseUIHandlerPrevented))return;const S=w.target===w.currentTarget,E=w.currentTarget,k=ED(E),_=!i&&Jut(E),C=S&&(i?k:!_),T=w.key==="Enter",A=w.key===" ",j=E.getAttribute("role"),L=(j==null?void 0:j.startsWith("menuitem"))||j==="option"||j==="gridcell";if(S&&c&&A){if(w.defaultPrevented&&L)return;w.preventDefault(),(!i||k)&&(w.preventBaseUIHandler(),SD(E,w));return}if(!C||i||!A&&!T){S&&_&&A&&w.preventDefault();return}w.defaultPrevented||(w.preventDefault(),T&&(w.preventBaseUIHandler(),SD(E,w)))},onKeyUp(w){if(!t){if(oA(w),y==null||y(w),w.target===w.currentTarget&&i&&c&&ED(w.currentTarget)&&w.key===" "){w.preventDefault();return}w.baseUIHandlerPrevented||w.target===w.currentTarget&&!i&&!c&&!w.defaultPrevented&&w.key===" "&&(w.preventBaseUIHandler(),SD(w.currentTarget,w))}},onPointerDown(w){if(t){w.preventDefault();return}v==null||v(w)}},i?{type:"button"}:{role:"button"},u,x)},[t,u,c,i]),h=ja(m=>{a.current=m,d()});return{getButtonProps:f,buttonRef:h}}function ED(e){return kd(e)&&e.tagName==="BUTTON"}function Jut(e){return kd(e)&&e.tagName==="A"&&!!e.href}const b0e=p.forwardRef(function(t,n){const{disabled:r,className:i,id:s,render:a,nativeButton:l=!0,style:c,...u}=t,{panelId:d,open:f,handleTrigger:h,disabled:m}=h0e(),g=r||m,{getButtonProps:b,buttonRef:y}=Kut({disabled:g,focusableWhenDisabled:!0,native:l}),{defaultTriggerId:O,state:v,setTriggerId:x}=BB(),w=s||void 0,S=w??O;return Zo(()=>(x(_=>w??(_===null?void 0:_)),()=>{x(_=>_===w?null:_)}),[w,x]),AE("button",t,{state:v,ref:[n,y],props:[{"aria-controls":f?d:void 0,"aria-expanded":f,id:S,onClick:h},u,b],stateAttributesMapping:qut})});function edt(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function tdt(e){const t=qg(ndt,e).current;return t.next=e,Zo(t.effect),t}function ndt(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function rdt(e){return e==null?e:"current"in e?e.current:e}function y0e(e,t=!1){const n=Mut();return ja((r,i=null)=>{n.cancel();const s=rdt(e);if(s==null)return;const a=s,l=()=>{Cr.flushSync(r)};if(typeof a.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){r();return}function c(){Promise.all(a.getAnimations().map(u=>u.finished)).then(()=>{i!=null&&i.aborted||l()},()=>{if(i!=null&&i.aborted)return;if(a.getAnimations().some(d=>d.pending||d.playState!=="finished")){c();return}l()})}if(t){const u="data-starting-style";if(!a.hasAttribute(u)){n.request(c);return}const d=new MutationObserver(()=>{a.hasAttribute(u)||(d.disconnect(),c())});d.observe(a,{attributes:!0,attributeFilter:[u]}),i==null||i.addEventListener("abort",()=>d.disconnect(),{once:!0});return}n.request(c)})}function idt(e){const{enabled:t=!0,open:n,ref:r,onComplete:i}=e,s=ja(i),a=y0e(r,n);p.useEffect(()=>{if(!t)return;const l=new AbortController;return a(s,l.signal),()=>{l.abort()}},[t,n,s,a])}const dx={height:void 0,width:void 0};function sdt(e){const{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:s,onOpenChange:a,open:l,setMounted:c,setOpen:u,transitionStatus:d}=e,f=p.useRef(null),h=p.useRef(null),[m,g]=p.useState(dx),b=p.useRef(dx),y=p.useRef(!1),O=p.useRef(l),v=p.useRef(!1),[x,w]=p.useState(!1),S=p.useRef(null),E=sA(t,f),k=tdt(l),_=y0e(f),C=!l&&!s,T=x?"idle":d,A=l&&(O.current||v.current),j=!l&&s&&h.current==="css-animation"&&m.height===void 0&&m.width===void 0?b.current:m,L=n&&C&&h.current!=="css-animation",I=ja((F,$=!0)=>{$&&(b.current=F),g(F)}),M=ja(()=>{var F;(F=S.current)==null||F.call(S),S.current=null}),N=ja(F=>{M(),S.current=()=>{S.current=null,F()}}),D=ja(()=>{l&&s&&h.current==="css-animation"&&(v.current=!0)});Zo(()=>{!x||d==="starting"||w(!1)},[x,d]),p.useEffect(()=>()=>{D(),M()},[D,M]),Zo(()=>{const F=f.current;if(!F)return;!l&&S.current&&M();const $=adt(F,A);if(h.current=$,l&&d==="idle"&&O.current&&$==="css-animation"){b.current=J0(F);return}if(l&&d==="starting"){const B=y.current;if(y.current=!1,$==="none"){I(J0(F)),w(!0);return}if($==="css-transition"){const ce=odt(F);if(I(J0(F)),!B)return ce;const be=A2(F,"transition-duration","0s");return N(be),w(!0),ce}I(J0(F));const V=A2(F,"animation-name","none");if(!B){V();return}const Z=A2(F,"animation-duration","0s");V(),N(Z),w(!0);return}if(!l&&s&&(d==="idle"||d==="starting")){if(O.current=!1,v.current=!1,$==="none"){I(dx,!1),c(!1);return}I(J0(F));return}if(d!=="ending")return;if($==="none"){c(!1);return}const H=J0(F);if(!(H.height>0||H.width>0)){c(!1);return}I(H),$==="css-animation"&&A2(F,"animation-name","none")()},[s,l,M,I,c,N,A,d]),idt({enabled:l&&s&&T==="idle",open:!0,ref:f,onComplete(){l&&I(dx,!1)}}),p.useEffect(()=>{if(l||!s||T!=="ending"||!f.current)return;const $=new AbortController;let H=-1;function z(){k.current||(c(!1),I(dx,!1))}return H=kl.request(()=>{_(z,$.signal)}),()=>{kl.cancel(H),$.abort()}},[k,s,l,T,_,I,c]),Zo(()=>{const F=f.current;!F||!n||!C||F.setAttribute("hidden","until-found")},[C,n]),p.useEffect(function(){const $=f.current;if(!$)return;function H(z){const B=d0e(Rut,z);a(!0,B),!B.isCanceled&&(y.current=!0,u(!0))}return edt($,"beforematch",H)},[a,u]);const Q=i||n||s||l;return{height:j.height,props:{...L?{[QB.startingStyle]:""}:void 0,hidden:C,id:r},ref:E,shouldPreventOpenAnimation:A,shouldRender:Q,transitionStatus:T,width:j.width}}function J0(e){return{height:e.scrollHeight,width:e.scrollWidth}}function adt(e,t){const n=Ka(e).getComputedStyle(e),r=(n.animationName.split(",").map(s=>s.trim()).some(s=>s!==""&&s!=="none")||t)&&qW(n.animationDuration),i=qW(n.transitionDuration);return r&&i||i?"css-transition":r?"css-animation":"none"}function qW(e){return e.split(",").map(t=>t.trim()).some(t=>t!==""&&Number.parseFloat(t)>0)}function A2(e,t,n){const r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===""){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function odt(e){const t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(i=>{e.style.setProperty(i,"initial","important")});function n(){Object.entries(t).forEach(([i,s])=>{if(s===""){e.style.removeProperty(i);return}e.style.setProperty(i,s)})}const r=kl.request(n);return()=>{kl.cancel(r),n()}}let XW=function(e){return e.accordionPanelHeight="--accordion-panel-height",e.accordionPanelWidth="--accordion-panel-width",e}({});const O0e=p.forwardRef(function(t,n){const{className:r,hiddenUntilFound:i,keepMounted:s,id:a,render:l,style:c,...u}=t,{hiddenUntilFound:d,keepMounted:f}=t0e(),{defaultPanelId:h,mounted:m,onOpenChange:g,open:b,setMounted:y,setOpen:O,setPanelIdState:v,transitionStatus:x}=h0e(),w=i??d,S=s??f,E=a||void 0,k=a??h;Zo(()=>(v($=>E??($===null?void 0:$)),()=>{v($=>$===E?null:$)}),[E,v]);const{height:_,props:C,ref:T,shouldPreventOpenAnimation:A,shouldRender:j,transitionStatus:L,width:I}=sdt({externalRef:n,hiddenUntilFound:w,id:k,keepMounted:S,mounted:m,onOpenChange:g,open:b,setMounted:y,setOpen:O,transitionStatus:x}),{state:M,triggerId:N}=BB(),D={...M,transitionStatus:L},Q=i0e(c,D),F=AE("div",{...t,style:void 0},{state:D,ref:T,props:[C,{"aria-labelledby":N,role:"region",style:{[XW.accordionPanelHeight]:_===void 0?"auto":`${_}px`,[XW.accordionPanelWidth]:I===void 0?"auto":`${I}px`}},u,Q?{style:Q}:void 0,A?{style:{animationName:"none"}}:void 0],stateAttributesMapping:UB});return j?F:null}),ldt=(e,t)=>{const n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=cdt(r,n.getBoundingClientRect()),s=udt(r,i),a=ddt(t.getBoundingClientRect());return hdt([...s,...a])};function cdt(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function udt(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function ddt(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function fdt(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,a=t.length-1;sr!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(i=!i)}return i}function hdt(e){const t=e.slice();return t.sort((n,r)=>n.xr.x?1:n.yr.y?1:0),pdt(t)}function pdt(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}const mdt="_Transition_1wdpp_1",gdt="_Popover_1wdpp_3",x0e={Transition:mdt,Popover:gdt},v0e=p.createContext(null),Qj=()=>{const e=p.use(v0e);if(!e)throw new Error("Popover components must be wrapped in ");return e},jp=({open:e,onOpenChange:t,showOnHover:n=!1,hoverOpenDelay:r=150,children:i})=>{const[s,a]=p.useState(!1),[l,c]=p.useState(!1),u=p.useRef(null),d=p.useRef(null),f=p.useRef(void 0),h=p.useRef(!1),m=p.useRef(!1),g=e??s,[b,y]=p.useState(!1);k9(()=>y(!1),b?500:null);const O=Xp(t),v=Xp(k=>{var _,C;clearTimeout(f.current),g!==k&&(k||(c(!1),n&&h.current&&((_=u.current)==null||_.focus()),h.current=!1),(C=O.current)==null||C.call(O,k),a(k),n&&y(k))}),x=p.useCallback(k=>{v.current(k)},[v]),w=p.useCallback(()=>{f.current=setTimeout(()=>x(!0),r)},[x,r]),S=p.useCallback(()=>{clearTimeout(f.current)},[]);p.useEffect(()=>()=>{clearTimeout(f.current)},[]);const E=p.useMemo(()=>({open:g,setOpen:x,shake:l,setShake:c,showOnHover:n,temporarilyPreventClickToClose:b,onTriggerEnter:w,onTriggerLeave:S,isPointerInTransitRef:m,triggerRef:u,contentRef:d,hoverOpenFocusedWithTab:h}),[g,x,l,c,n,b,h,m,w,S]);return o.jsx(v0e,{value:E,children:o.jsx(fue,{open:g,onOpenChange:x,modal:!1,children:i})})},bdt=({children:e,onPointerDown:t,onClick:n})=>{const{setOpen:r,showOnHover:i,temporarilyPreventClickToClose:s,onTriggerEnter:a,onTriggerLeave:l,isPointerInTransitRef:c,triggerRef:u,contentRef:d}=Qj(),f=p.useRef(!1),h=b=>{!(b.currentTarget.nodeName.toLocaleLowerCase()==="a")&&s&&(b.preventDefault(),b.stopPropagation())},m=b=>{b.pointerType!=="touch"&&!f.current&&!c.current&&(a(),f.current=!0)},g=()=>{f.current&&(l(),f.current=!1)};return o.jsx(hue,{asChild:!0,ref:u,onPointerDown:b=>{h(b),t==null||t(b)},onClick:b=>{h(b),n==null||n(b)},onPointerMove:i?m:void 0,onPointerLeave:i?g:void 0,onFocus:i?()=>r(!0):void 0,onBlur:i?()=>{setTimeout(()=>{var b;(b=d.current)!=null&&b.contains(document.activeElement)||r(!1)},50)}:void 0,children:e})},w0e=({children:e,avoidCollisions:t,width:n,minWidth:r,maxWidth:i,side:s,sideOffset:a=8,align:l,alignOffset:c,translucent:u,className:d,autoFocus:f=!0})=>{const{showOnHover:h,shake:m,contentRef:g}=Qj(),b=y=>{const O=g.current;if(O&&y.target===O&&y.key==="Tab"&&y.shiftKey){y.preventDefault(),y.stopPropagation();const v=Tle(O),x=v[v.length-1];x==null||x.focus()}};return p.useEffect(()=>{const y=g.current;!y||!f||y!=null&&y.contains(document.activeElement)||h||y.focus({preventScroll:!0})},[g,h,f]),o.jsx(mue,{forceMount:!0,ref:g,className:ur(x0e.Popover,d),style:d0({"popover-width":n,"popover-min-width":r,"popover-max-width":i}),onCloseAutoFocus:h?Df:void 0,"data-animate":m?"shake":void 0,"data-translucent":u?"true":void 0,side:s,sideOffset:a,align:l,alignOffset:c??(l==="center"?0:-5),avoidCollisions:t??!0,hideWhenDetached:!0,collisionPadding:20,onOpenAutoFocus:Df,onEscapeKeyDown:Df,onKeyDown:b,children:e})},ydt=e=>{const{setOpen:t,triggerRef:n,contentRef:r,isPointerInTransitRef:i,hoverOpenFocusedWithTab:s}=Qj(),[a,l]=p.useState(null),c=p.useCallback(()=>{l(null),i.current=!1},[i]),u=p.useCallback((d,f)=>{const h=ldt(d,f);l(h),i.current=!0},[i]);return p.useEffect(()=>()=>c(),[c]),p.useEffect(()=>{const d=n.current,f=r.current;if(!d||!f)return;const h=g=>u(g,f),m=g=>u(g,d);return d.addEventListener("pointerleave",h),f.addEventListener("pointerleave",m),()=>{d.removeEventListener("pointerleave",h),f.removeEventListener("pointerleave",m)}},[r,n,u,c]),p.useEffect(()=>{if(!a)return;const d=f=>{const h=n.current,m=r.current,g=f.target,b={x:f.clientX,y:f.clientY},y=(h==null?void 0:h.contains(g))||(m==null?void 0:m.contains(g)),O=!fdt(b,a),v=g.hasAttribute("aria-haspopup");y?c():(O||v)&&(c(),t(!1))};return document.addEventListener("pointermove",d),()=>document.removeEventListener("pointermove",d)},[a,t,c,n,r]),p.useEffect(()=>{const d=f=>{if(r.current&&f.key==="Tab"&&!f.shiftKey){const[h]=Tle(r.current);h&&(f.preventDefault(),h.focus(),s.current=!0,document.removeEventListener("keydown",d))}};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[r,s]),o.jsx(w0e,{...e})},Odt=e=>{const{open:t,showOnHover:n,setOpen:r}=Qj();return tE(t,()=>{r(!1)}),o.jsx(pue,{forceMount:!0,children:o.jsx(rO,{enterDuration:600,exitDuration:300,className:x0e.Transition,disableAnimations:!0,children:t&&(n?o.jsx(ydt,{...e},"popover-hover"):o.jsx(w0e,{...e},"popover"))})})};jp.Trigger=bdt;jp.Content=Odt;const xdt=[{value:"skill_hub",label:"Skill Hub"},{value:"skill_space",label:"AgentKit 技能中心"},{value:"knowledge_base",label:"知识库"},{value:"tool",label:"工具"}],S0e={llm:"LLM Agent",sequential:"顺序 Agent",parallel:"并行 Agent",loop:"循环 Agent",workflow:"Workflow"};function E0e(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m4 6 4 4 4-4"})})}function k0e({label:e}){return o.jsx("div",{className:"create-agent-card__loading",role:"status","aria-label":e,children:[0,1,2].map(t=>o.jsxs("div",{className:"create-agent-card__skeleton-row","aria-hidden":"true",children:[o.jsx("span",{}),o.jsx("span",{})]},t))})}function vdt(e){return e.kind==="tool"?"内置工具":e.kind==="knowledge_base"?"知识库":e.source.startsWith("skill_hub:")?"Skill Hub":e.source.startsWith("skill_space:")?"AgentKit 技能中心":"Skill"}function kD({label:e,resources:t}){return t.length===0?null:o.jsxs("section",{className:"create-agent-card__popover-section",children:[o.jsx("h4",{children:e}),o.jsx("div",{className:"create-agent-card__popover-list",children:t.map(n=>o.jsxs("div",{className:"create-agent-card__popover-item",children:[o.jsxs("div",{className:"create-agent-card__popover-item-heading",children:[o.jsx("strong",{children:n.name}),o.jsx(ta,{color:"secondary",size:"sm",variant:"soft",children:vdt(n)})]}),n.description?o.jsx("p",{children:n.description}):null]},n.ref))})]})}function wdt({tools:e}){return e.length===0?null:o.jsxs("section",{className:"create-agent-card__popover-section",children:[o.jsx("h4",{children:"自写工具"}),o.jsx(u0e,{children:e.map((t,n)=>o.jsxs(m0e,{className:"create-agent-card__python-tool",value:`${t.name}:${n}`,children:[o.jsx(g0e,{className:"create-agent-card__python-tool-header",children:o.jsxs(b0e,{className:"create-agent-card__python-tool-trigger",children:[o.jsxs("span",{children:[o.jsx("strong",{children:t.name}),t.description?o.jsx("small",{children:t.description}):null]}),o.jsxs("span",{className:"create-agent-card__python-tool-meta",children:[o.jsx(ta,{color:"secondary",size:"sm",variant:"soft",children:"自写工具"}),o.jsx(E0e,{className:"create-agent-card__python-tool-chevron"})]})]})}),o.jsxs(O0e,{className:"create-agent-card__python-tool-panel",children:[t.dependencies.length>0?o.jsxs("div",{className:"create-agent-card__python-tool-dependencies",children:["依赖:",t.dependencies.join(", ")]}):null,o.jsx("pre",{tabIndex:0,"aria-label":`${t.name} 完整代码`,children:o.jsx("code",{children:t.code})})]})]},`${t.name}:${n}`))})]})}function Sdt({agents:e}){return e.length===0?null:o.jsxs("section",{className:"create-agent-card__popover-section",children:[o.jsx("h4",{children:"Sub Agent"}),o.jsx("div",{className:"create-agent-card__popover-list",children:e.map(t=>o.jsxs("div",{className:"create-agent-card__popover-item",children:[o.jsxs("div",{className:"create-agent-card__popover-item-heading",children:[o.jsx("strong",{children:t.id}),o.jsx(ta,{color:"secondary",size:"sm",variant:"soft",children:S0e[t.type]??t.type})]}),t.description?o.jsx("p",{children:t.description}):null]},t.id))})]})}function N2({label:e,count:t,icon:n,children:r}){const i=o.jsxs("button",{className:"create-agent-card__resource-metric",type:"button",disabled:t===0,"aria-label":`${e} ${t} 项`,children:[n,o.jsx("span",{children:t})]});return t===0?i:o.jsxs(jp,{showOnHover:!0,hoverOpenDelay:120,children:[o.jsx(jp.Trigger,{children:i}),o.jsx(jp.Content,{side:"top",align:"start",minWidth:"auto",maxWidth:360,className:"create-agent-card__resource-popover",children:r})]})}function Edt({response:e,status:t}){const n=p.useMemo(()=>Wct(e),[e]),r=p.useMemo(()=>xdt.map(a=>{const l=Yct(n,a.value);return{...a,...l,searchKeywords:[...new Set(l.sources.flatMap(c=>c.searchKeywords))]}}),[n]),i=t==="failed",s=i?Bj(e):"";return o.jsx("section",{className:"create-agent-tool-card","aria-label":"召回资源信息",children:t==="running"?o.jsx(k0e,{label:"正在检索资源"}):i?o.jsxs("div",{className:"create-agent-card__message is-error",role:"alert",children:[o.jsx("span",{className:"create-agent-card__message-title",children:"资源检索未完成"}),o.jsx("span",{children:s||"请检查资源服务配置后重试。"})]}):o.jsx(u0e,{className:"create-agent-card__accordion",children:r.map(a=>o.jsxs(m0e,{className:"create-agent-card__accordion-item",value:a.value,children:[o.jsx(g0e,{className:"create-agent-card__accordion-header",children:o.jsxs(b0e,{className:"create-agent-card__accordion-trigger",children:[o.jsx("span",{children:a.label}),o.jsxs("span",{className:"create-agent-card__accordion-meta",children:[o.jsx(ta,{color:"secondary",size:"sm",variant:"soft",children:a.sources.length===0?a.value==="skill_hub"?"未检索":"未配置":a.resources.length}),o.jsx(E0e,{className:"create-agent-card__accordion-chevron"})]})]})}),o.jsx(O0e,{className:"create-agent-card__accordion-content",children:o.jsxs("div",{className:"create-agent-card__accordion-scroll",role:"region","aria-label":`${a.label}资源列表`,tabIndex:0,children:[a.value==="skill_hub"&&a.searchKeywords.length>0?o.jsxs("div",{className:"create-agent-card__search-keywords",children:[o.jsx("span",{children:"检索关键词"}),o.jsx("span",{children:a.searchKeywords.join("、")})]}):null,a.resources.length>0?o.jsx("div",{className:"create-agent-card__resource-list",children:a.resources.map(l=>o.jsx("div",{className:"create-agent-card__resource",children:o.jsxs("div",{className:"create-agent-card__resource-main",children:[o.jsxs("div",{className:"create-agent-card__resource-title",children:[o.jsx("span",{className:"create-agent-card__resource-name",children:l.name}),l.version?o.jsx(ta,{className:"create-agent-card__resource-version",color:"secondary",size:"sm",variant:"soft",children:l.version}):null]}),l.description?o.jsx("p",{children:l.description}):null]})},l.ref))}):o.jsxs("div",{className:"create-agent-card__empty-category",children:[o.jsx("p",{children:a.sources.length===0?a.value==="skill_hub"?"未提供检索关键词,本次未检索 Skill Hub。":`未配置 ${a.label},本次未检索该来源。`:"本次检索未返回该类别的资源。"}),a.sources.filter(l=>l.message).map(l=>o.jsx("p",{className:"create-agent-card__raw-source-error",children:l.message},l.source))]})]})})]},a.value))},n.collectionId||"collected-resources")})}function kdt({args:e,response:t,status:n}){const r=p.useMemo(()=>Yge(e,t),[e,t]),i=n==="failed"?Bj(t):"";return o.jsxs("section",{className:"create-agent-tool-card is-agent-results","aria-label":"创建 Agent 结果",children:[i?o.jsxs("div",{className:"create-agent-card__message is-error",role:"alert",children:[o.jsx("span",{className:"create-agent-card__message-title",children:"Agent 创建未完成"}),o.jsx("span",{children:i})]}):null,r.agents.length>0?o.jsx("div",{className:"create-agent-card__agent-grid",children:r.agents.map(s=>{const a=n==="failed"?"failed":s.status,l=s.error||a==="failed"&&i,c=s.builtinTools.length+s.pythonTools.length;return o.jsxs(W7,{className:`create-agent-card__agent-card${l?" is-error":""}`,children:[o.jsx(Y7,{leading:o.jsx(d1,{seed:s.name}),title:s.name,titleText:s.name,status:o.jsx(ta,{color:"secondary",size:"sm",variant:"soft",children:S0e[s.rootType]??s.rootType})}),s.description?o.jsx(Z7,{children:s.description}):null,l?o.jsx("div",{className:"create-agent-card__agent-result is-error",role:"alert",children:l}):null,o.jsxs("div",{className:"create-agent-card__agent-resources","aria-label":`${s.name} 具备的资源`,children:[o.jsx(N2,{label:"Skill",count:s.skills.length,icon:o.jsx(L_,{"aria-hidden":"true"}),children:o.jsx(kD,{label:"Skill",resources:s.skills})}),o.jsx(N2,{label:"知识库",count:s.knowledgeBases.length,icon:o.jsx(zue,{"aria-hidden":"true"}),children:o.jsx(kD,{label:"知识库",resources:s.knowledgeBases})}),o.jsxs(N2,{label:"工具",count:c,icon:o.jsx(kRe,{"aria-hidden":"true"}),children:[o.jsx(kD,{label:"内置工具",resources:s.builtinTools}),o.jsx(wdt,{tools:s.pythonTools})]}),o.jsx(N2,{label:"Sub Agent",count:s.subAgentCount,icon:o.jsx(TRe,{"aria-hidden":"true"}),children:o.jsx(Sdt,{agents:s.subAgents})})]})]},s.name)})}):n==="running"?o.jsx(k0e,{label:"正在创建 Agent"}):o.jsxs("div",{className:"create-agent-card__message",children:[o.jsx("span",{className:"create-agent-card__message-title",children:"没有可展示的 Agent"}),o.jsx("span",{children:"工具返回中未包含 Agent 配置或执行结果。"})]})]})}const _dt={web_search:{name:"web_search",runningLabel:"正在进行网络搜索",doneLabel:"已完成网络搜索",tone:"search",icon:Dct},run_code:{name:"run_code",runningLabel:"正在 AgentKit 沙箱中执行代码",doneLabel:"已在 AgentKit 沙箱中完成代码执行",tone:"sandbox",icon:Qct},list_envs:{name:"list_envs",runningLabel:"正在查看可用环境",doneLabel:"已读取可用环境",tone:"resources",icon:Fct},get_env_manifest:{name:"get_env_manifest",runningLabel:"正在读取环境 Manifest",doneLabel:"已读取环境 Manifest",tone:"knowledge",icon:zct},execute_in_sandbox:{name:"execute_in_sandbox",runningLabel:"正在环境中执行命令",doneLabel:"已在环境中完成命令执行",tone:"sandbox",icon:Vct},image_generate:{name:"image_generate",runningLabel:"正在生成图片",doneLabel:"已完成图片生成",tone:"image",icon:Pct},video_generate:{name:"video_generate",runningLabel:"正在生成视频",doneLabel:"已完成视频生成",tone:"video",icon:IB},ppt_generate:{name:"ppt_generate",runningLabel:"正在生成 PPT",doneLabel:"已完成 PPT 生成",tone:"presentation",icon:Mct},load_memory:{name:"load_memory",runningLabel:"正在检索长期记忆",doneLabel:"已完成记忆检索",tone:"memory",icon:Lct},load_knowledgebase:{name:"load_knowledgebase",runningLabel:"正在检索知识库",doneLabel:"已完成知识库检索",tone:"knowledge",icon:$ct},load_skill:{name:"load_skill",runningLabel:"正在加载技能",doneLabel:"已加载技能",tone:"skill",icon:Bct},collect_resources:{name:"collect_resources",runningLabel:"正在收集可用资源",doneLabel:"已完成资源收集",failedLabel:"资源收集失败",tone:"resources",icon:Uct,detailRenderer:Edt},create_agents:{name:"create_agents",runningLabel:"正在创建并运行 Agent",doneLabel:"已完成 Agent 创建",failedLabel:"Agent 创建失败",tone:"agent",icon:LW,detailRenderer:kdt},branch_compare:{name:"branch_compare",runningLabel:"",doneLabel:"",failedLabel:"",tone:"search",icon:LW,detailRenderer:Jct,hideHeader:!0}};function Tdt(e){return _dt[e]}function _0e(e){return o.jsx("svg",{viewBox:"0 0 111 117",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"M0 5.6016C7.82288e-05 0.621244 6.02226 -1.87314 9.54395 1.64847L40.1289 32.2334L68.5732 3.7891C69.5834 2.77903 70.9533 2.21099 72.3818 2.21097H82.7031C82.7917 2.20658 82.8806 2.20414 82.9697 2.20414H104.775C109.574 2.20427 111.977 8.00691 108.584 11.4004L64.916 55.0664C64.3075 55.8528 63.9436 56.7647 63.8242 57.6993C63.7142 56.4884 63.1964 55.3069 62.2695 54.3799L45.4082 37.5186H45.4072L40.124 32.2354L17.832 54.5284C16.7671 55.5933 16.2416 56.993 16.2549 58.3887C16.2417 59.7843 16.7672 61.1842 17.832 62.2491L39.9287 84.3467L9.54395 114.733C6.0223 118.255 0.000223474 115.761 0 110.78V5.6016ZM63.8018 58.8702C63.8962 59.9086 64.2936 60.9229 64.9961 61.7735L108.591 105.368C111.984 108.762 109.58 114.564 104.781 114.564H94.4336C94.3543 114.568 94.274 114.569 94.1934 114.569H72.3877C70.9592 114.569 69.5892 114.002 68.5791 112.992L39.9336 84.3467L58.4531 65.8282L58.4453 65.8203L62.2695 61.9981C63.1476 61.12 63.6567 60.0136 63.8018 58.8702Z",fill:"currentColor"})})}function Cdt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M6 3h8l4 4v14H6Z"}),o.jsx("path",{d:"M14 3v5h5"}),o.jsx("path",{d:"m10 12-2 2 2 2M14 12l2 2-2 2"})]})}function Adt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M12 3 19 6v5c0 4.6-2.8 7.8-7 10-4.2-2.2-7-5.4-7-10V6l7-3Z"}),o.jsx("path",{d:"m9 12 2 2 4-4"})]})}function Ndt(e,t){const n=new Map(e.map(a=>[a.path,a.content])),r=new Map(t.map(a=>[a.path,a.content])),i=new Set([...n.keys(),...r.keys()]),s=[];for(const a of[...i].sort((l,c)=>l.localeCompare(c))){const l=n.get(a),c=r.get(a);l!==c&&s.push({path:a,status:l===void 0?"added":c===void 0?"deleted":"modified",before:l??"",after:c??""})}return s}function jdt(e){return e==="added"?"新增":e==="deleted"?"删除":"修改"}function mm(e){return{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,...e}}function T0e(e){return o.jsx("svg",{...mm(e),children:o.jsx("path",{d:"m9 7-5 5 5 5M15 7l5 5-5 5M13.5 4l-3 16"})})}function _D(e){return o.jsx("svg",{...mm(e),children:o.jsx("path",{d:"M6.5 3.75h7l4 4V20.25h-11zM13.5 3.75v4h4M9 12h6M9 15.5h4.5"})})}function Rdt(e){return o.jsx("svg",{...mm(e),children:o.jsx("path",{d:"M3.75 7.25h6l1.75 2h8.75v9.25H3.75zM3.75 7.25V5.5h5l1.5 1.75"})})}function Idt(e){return o.jsx("svg",{...mm(e),children:o.jsx("path",{d:"m9 5 7 7-7 7"})})}function C0e(e){return o.jsx("svg",{...mm(e),children:o.jsx("path",{d:"m6.5 6.5 11 11M17.5 6.5l-11 11"})})}function Ddt(e){return o.jsxs("svg",{...mm(e),children:[o.jsx("circle",{cx:"12",cy:"12",r:"3.25"}),o.jsx("path",{d:"M12 2.75v2M12 19.25v2M2.75 12h2M19.25 12h2M5.45 5.45l1.4 1.4M17.15 17.15l1.4 1.4M18.55 5.45l-1.4 1.4M6.85 17.15l-1.4 1.4"})]})}function Pdt(e){return o.jsx("svg",{...mm(e),children:o.jsx("path",{d:"M19.25 15.25A8 8 0 0 1 8.75 4.75a8 8 0 1 0 10.5 10.5Z"})})}function Mdt(e){return o.jsxs("svg",{...mm(e),children:[o.jsx("path",{d:"M19.25 8.25V4.5l-1.8 1.8a7.5 7.5 0 1 0 1.8 7.65"}),o.jsx("path",{d:"M19.25 4.5H15.5"})]})}const Ldt=p.lazy(()=>dd(()=>Promise.resolve().then(()=>rve),void 0)),$dt=p.lazy(()=>dd(()=>import("../chunks/CodeDiffEditor-Cv7h6eVb.js"),[])),A0e="veadk-code-workspace-theme";function Bdt(e){const t={name:"",children:new Map};for(const n of e){const r=n.path.split("/").filter(Boolean);let i=t;r.forEach((s,a)=>{let l=i.children.get(s);l||(l={name:s,children:new Map},i.children.set(s,l)),a===r.length-1&&(l.path=n.path),i=l})}return t}function Qdt(e,t=!1){return[...e.children.values()].sort((n,r)=>{const i=n.children.size>0&&n.path===void 0,s=r.children.size>0&&r.path===void 0;return i!==s?t?i?1:-1:i?-1:1:n.name.localeCompare(r.name)})}function Udt(){if(typeof window>"u")return"light";try{return window.localStorage.getItem(A0e)==="dark"?"dark":"light"}catch{return"light"}}function Fdt(e){return e===""?0:e.split(` +`||c==="\r")&&(s=!1);continue}if(a){c==="*"&&u==="/"&&(a=!1,l+=1);continue}if(r){i?i=!1:c==="\\"?i=!0:c===r&&(r="");continue}if(c==="/"&&u==="/"){s=!0,l+=1;continue}if(c==="/"&&u==="*"){a=!0,l+=1;continue}if(c==="'"||c==='"'){r=c;continue}const d=e.slice(l).match(n);if(d)return{index:l,openingIndex:l+d[0].lastIndexOf("("),type:d[1]==="LinearGradient"?"linear":"radial"}}}function Zot(e){let t=e,n=0;for(;;){const r=Yot(t,n);if(!r)return t;const i=Xot(t,r.openingIndex),s=t.slice(r.openingIndex+1,i),a=JSON.stringify(Wot(r.type,s));t=`${t.slice(0,r.index)}${a}${t.slice(i+1)}`,n=r.index+a.length}}function Kot(e,t=!1){if(e.length>zot)throw new Error("ECharts option is too large");const n=Zot(qot(e));let r;try{r=Nge.parse(n)}catch(a){throw/\bfunction\s*\(|=>/.test(n)?new Error("ECharts function callbacks are not supported"):a}if(!Wx(r))throw new Error("ECharts option must be a data object");iA(r);const i={...r};i.aria={...Wx(i.aria)?i.aria:{},enabled:!0};const s=i.tooltip;return Wx(s)?i.tooltip={...s,renderMode:"richText"}:Array.isArray(s)&&(i.tooltip=s.map(a=>Wx(a)?{...a,renderMode:"richText"}:a)),t&&(i.animation=!1),i}let OD;function Jot(){return OD??(OD=dd(()=>import("../visualizations/echarts/index-CGT341lL.js"),[]).catch(e=>{throw OD=void 0,e})),OD}function elt({source:e}){const t=p.useRef(null),[n,r]=p.useState(!1),[i,s]=p.useState("");return p.useEffect(()=>{let a=!1,l,c,u;r(!1);try{u=Kot(e,window.matchMedia("(prefers-reduced-motion: reduce)").matches),s("")}catch{s("ECharts 配置不是有效且安全的数据对象,请切换到代码检查内容。");return}return Jot().then(d=>{const f=t.current;a||!f||(l=d.init(f,void 0,{renderer:"svg"}),l.setOption(u,{notMerge:!0}),typeof ResizeObserver<"u"&&(c=new ResizeObserver(()=>l==null?void 0:l.resize()),c.observe(f)),r(!0))}).catch(()=>{l==null||l.dispose(),l=void 0,a||s("图表暂时无法渲染,请切换到代码检查内容。")}),()=>{a=!0,c==null||c.disconnect(),l==null||l.dispose()}},[e]),o.jsxs("div",{className:`echarts-diagram${i?" echarts-diagram--error":""}`,role:"img","aria-label":"ECharts 图表预览","aria-busy":!n&&!i,children:[o.jsx("div",{ref:t,className:"echarts-diagram__canvas",hidden:!!i}),!n&&!i?o.jsx("div",{className:"echarts-diagram__state","aria-live":"polite",children:o.jsx(En,{duration:2.2,spread:15,children:"正在渲染图表…"})}):null,i?o.jsx("p",{className:"echarts-diagram__error",role:"alert",children:i}):null]})}const tlt=p.memo(elt);let IW,DW=Promise.resolve(),nlt=0;function rlt(){return IW??(IW=dd(async()=>{const{default:e}=await import("../visualizations/mermaid/mermaid.core-u1Q_qVDs.js").then(t=>t.ay);return{default:e}},__vite__mapDeps([0,1])).then(({default:e})=>(e.initialize({startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,theme:"neutral"}),e))),IW}function ilt(e){const t=DW.then(async()=>{const n=await rlt(),r=`mermaid-diagram-${nlt+=1}`;return n.render(r,e)});return DW=t.then(()=>{},()=>{}),t}function slt({source:e}){const t=p.useRef(null),[n,r]=p.useState(null),[i,s]=p.useState(!1);return p.useEffect(()=>{let a=!1;return r(null),s(!1),ilt(e).then(l=>{a||r(l)}).catch(()=>{a||s(!0)}),()=>{a=!0}},[e]),p.useEffect(()=>{!(n!=null&&n.bindFunctions)||!t.current||n.bindFunctions(t.current)},[n]),i?o.jsx("div",{className:"mermaid-diagram mermaid-diagram--error",children:o.jsx("p",{className:"mermaid-diagram__error",role:"alert",children:"图表暂时无法渲染,请切换到代码查看 Mermaid 内容。"})}):n?o.jsx("div",{ref:t,className:"mermaid-diagram",role:"img","aria-label":"Mermaid 图表预览",dangerouslySetInnerHTML:{__html:n.svg}}):o.jsx("div",{className:"mermaid-diagram mermaid-diagram--loading","aria-live":"polite",children:o.jsx(En,{duration:2.2,spread:15,children:"正在渲染图表…"})})}const alt=p.memo(slt),olt="_SegmentedControl_1sl7d_1",llt="_SegmentedControlOption_1sl7d_140",clt="_SegmentedControlThumb_1sl7d_219",mL={SegmentedControl:olt,SegmentedControlOption:llt,SegmentedControlThumb:clt},Fs=({value:e,onChange:t,children:n,block:r,pill:i=!0,size:s="md",gutterSize:a,className:l,onClick:c,...u})=>{const d=p.useRef(null),f=p.useRef(null),h=p.useCallback(g=>{const b=d.current,y=f.current;if(!b||!y)return;const O=b==null?void 0:b.querySelector('[data-state="on"]');if(!O)return;const v=b.clientWidth;let x=Math.floor(O.clientWidth);const w=O.offsetLeft;if(v-(x+w)<2&&(x=x-1),y.style.width=`${Math.floor(x)}px`,y.style.transform=`translateX(${w}px)`,b.scrollWidth>v){const S=v*.15,E=b.scrollLeft,k=O.offsetLeft,_=k+x;(kE+v-S)&&g&&O.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})}},[]);Ele({ref:d,onResize:()=>{const g=f.current;if(!g)return;const b=g.style.transition;g.style.transition="",h(!1),g.style.transition=b}}),p.useLayoutEffect(()=>{const g=d.current,b=f.current;!g||!b||(h(!!b.style.transition),b.style.transition||wC(()=>{b.style.transition="width 300ms var(--cubic-enter), transform 300ms var(--cubic-enter)"}))},[h,e,s,a,i]);const m=g=>{g&&t&&t(g)};return o.jsxs(GLe,{ref:d,className:ur(mL.SegmentedControl,l),type:"single",value:e,loop:!1,onValueChange:m,onClick:c,"data-block":r?"":void 0,"data-pill":i?"":void 0,"data-size":s,"data-gutter-size":a,...u,children:[o.jsx("div",{className:mL.SegmentedControlThumb,ref:f}),n]})},ult=({children:e,...t})=>o.jsx(JLe,{className:mL.SegmentedControlOption,...t,onPointerEnter:_9,children:o.jsx("span",{className:"relative",children:e})});Fs.Option=ult;function dlt({children:e,label:t,language:n,source:r,streaming:i=!1}){const[s,a]=p.useState("preview"),l=i?"code":s;return o.jsxs("section",{className:"visualization-card","aria-label":`${t} 图表`,children:[o.jsx("div",{className:"visualization-card__toolbar",children:o.jsxs(Fs,{className:"visualization-card__tabs",value:l,size:"sm",gutterSize:"sm",pill:!1,"aria-label":`${t} 显示方式`,onChange:c=>{i||a(c)},children:[o.jsx(Fs.Option,{value:"preview",disabled:i,children:"预览"}),o.jsx(Fs.Option,{value:"code",children:"代码"})]})}),o.jsx("div",{className:"visualization-card__body",children:l==="code"?o.jsx("pre",{className:"visualization-card__code",children:o.jsx("code",{className:`language-${n}`,children:r})}):e})]})}const flt=p.memo(dlt);function hlt(e){const t=e==null?void 0:e.trim().toLowerCase();if(t==="mermaid")return"mermaid";if(t==="echart"||t==="echarts")return"echarts"}const jge=[".mp4",".webm",".mov",".m4v",".ogg",".avi"];function gL(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(gL).join(""):p.isValidElement(e)?gL(e.props.children):""}function plt(e){var r;const t=p.Children.toArray(e)[0];if(!p.isValidElement(t))return;const n=(r=t.props.className)==null?void 0:r.split(/\s+/).find(i=>i.startsWith("language-"));return hlt(n==null?void 0:n.slice(9))}function Rge(e){if(!e)return!1;try{const t=e.toLowerCase();return jge.some(n=>t.includes(n))}catch{return!1}}function mlt(e){var r;const t=(r=e==null?void 0:e.properties)==null?void 0:r.href;if(!t)return!1;if(Rge(t))return!0;const n=e==null?void 0:e.children;if(n&&Array.isArray(n)){const i=n.map(s=>(s==null?void 0:s.value)||"").join("").toLowerCase();return jge.some(s=>i.includes(s))}return!1}function glt({text:e,className:t,allowRawHtml:n=!0,streaming:r=!1}){const[i,s]=p.useState(null),a=(u,d)=>{if(u.src)return u.src;if(d){const f=m=>{var g;if(!m)return null;if(m.type==="source"&&((g=m.properties)!=null&&g.src))return m.properties.src;if(m.children)for(const b of m.children){const y=f(b);if(y)return y}return null},h=f({children:d});if(h)return h}return""},l=u=>{try{const f=new URL(u).pathname.split("/");return f[f.length-1]||"video.mp4"}catch{return"video.mp4"}},c=u=>u?Array.isArray(u)?u.map(d=>(d==null?void 0:d.value)||"").join("")||"video":(u==null?void 0:u.value)||"video":"video";return o.jsxs("div",{className:t?`md ${t}`:"md",children:[o.jsx(RJe,{remarkPlugins:[Xtt],rehypePlugins:n?[Aot,hW]:[hW],components:{pre:({node:u,children:d,...f})=>{const h=plt(d);if(h==="mermaid"||h==="echarts"){const m=gL(d).replace(/\n$/,"");return o.jsx(flt,{label:h==="mermaid"?"Mermaid":"ECharts",language:h,source:m,streaming:r,children:h==="mermaid"?o.jsx(alt,{source:m}):o.jsx(tlt,{source:m})})}return o.jsx("pre",{...f,children:d})},a:({node:u,...d})=>{const f=d.href;if(f&&(Rge(f)||mlt(u))){const h=f,m=c(u==null?void 0:u.children);return o.jsxs("div",{className:"video-container",children:[o.jsxs("button",{type:"button",className:"video-preview-trigger","aria-label":`点击播放视频: ${m}`,onClick:()=>s({src:h,title:m}),children:[o.jsx("video",{src:h,playsInline:!0,className:"video-thumbnail",preload:"metadata"}),o.jsx("span",{className:"video-preview-hint","aria-hidden":"true",children:o.jsx(uy,{})})]}),o.jsx("div",{className:"video-caption",children:o.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"video-link-text",children:m})})]})}return o.jsx("a",{...d,target:"_blank",rel:"noopener noreferrer"})},img:({node:u,src:d,alt:f,...h})=>{const m=o.jsx("img",{...h,src:d,alt:f??"",loading:"lazy"});return d?o.jsx(Eae,{src:d,children:o.jsxs("button",{type:"button",className:"image-preview-trigger","aria-label":`放大预览:${f||"图片"}`,children:[m,o.jsx("span",{className:"image-preview-hint","aria-hidden":"true",children:o.jsx(uy,{})})]})}):m},video:({node:u,src:d,children:f,...h})=>{const m=a({src:d},f);return m?o.jsx("div",{className:"video-container",children:o.jsxs("button",{type:"button",className:"video-preview-trigger","aria-label":"点击放大视频",onClick:()=>s({src:m}),children:[o.jsx("video",{src:m,...h,playsInline:!0,className:"video-thumbnail",children:f}),o.jsx("span",{className:"video-preview-hint","aria-hidden":"true",children:o.jsx(uy,{})})]})}):o.jsx("video",{src:d,controls:!0,playsInline:!0,className:"video-inline",...h,children:f})}},children:e}),i&&o.jsx("div",{className:"video-viewer-backdrop",role:"dialog","aria-modal":"true","aria-label":"视频预览",onClick:()=>s(null),children:o.jsxs("div",{className:"video-viewer",onClick:u=>u.stopPropagation(),children:[o.jsxs("div",{className:"video-viewer-header",children:[o.jsx("div",{className:"video-viewer-title",children:i.title||l(i.src)}),o.jsxs("nav",{className:"video-viewer-nav",children:[o.jsx("a",{href:i.src,download:i.title||l(i.src),"aria-label":"下载视频",title:"下载视频",className:"video-viewer-download",children:o.jsx(NN,{})}),o.jsx("button",{type:"button",className:"video-viewer-close","aria-label":"关闭",onClick:()=>s(null),children:o.jsx(Oa,{})})]})]}),o.jsx("div",{className:"video-viewer-body",children:o.jsx("video",{src:i.src,controls:!0,autoPlay:!0,playsInline:!0,className:"video-fullscreen"})})]})})]})}const xu=p.memo(glt),blt="未知来源",ylt="未知创建者";function Qv(e){return(e==null?void 0:e.trim())||blt}function Ige(e){return(e==null?void 0:e.trim())||ylt}function Olt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M5 5.5A2.5 2.5 0 0 1 7.5 3H19v16H7.5A2.5 2.5 0 0 0 5 21.5v-16Z"}),o.jsx("path",{d:"M5 18.5A2.5 2.5 0 0 1 7.5 16H19"}),o.jsx("path",{d:"M9 7h6M9 10h4"})]})}function xlt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M6 3h8l4 4v14H6V3Z"}),o.jsx("path",{d:"M14 3v5h5M9 12h6M9 16h6"})]})}function vlt(e){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m7 7 10 10M17 7 7 17"})})}function wlt(e){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"M12 5v14M5 12h14"})})}function _E({title:e,children:t,onClose:n,busy:r=!1,className:i=""}){const s=p.useId(),a=p.useRef(null),l=p.useRef(null),c=p.useRef(r),u=p.useRef(n);return p.useEffect(()=>{c.current=r,u.current=n},[r,n]),p.useEffect(()=>{var m;const d=document.activeElement instanceof HTMLElement?document.activeElement:null,f=document.body.style.overflow;document.body.style.overflow="hidden",(m=a.current)==null||m.focus();const h=g=>{if(g.key==="Escape"&&!c.current){u.current();return}if(g.key!=="Tab")return;const b=l.current;if(!b)return;const y=Array.from(b.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], audio[controls], video[controls], iframe, [tabindex]:not([tabindex="-1"])')).filter(x=>x.getClientRects().length>0);if(y.length===0){g.preventDefault();return}const O=y[0],v=y[y.length-1];g.shiftKey&&(document.activeElement===O||!b.contains(document.activeElement))?(g.preventDefault(),v.focus()):!g.shiftKey&&(document.activeElement===v||!b.contains(document.activeElement))&&(g.preventDefault(),O.focus())};return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h),document.body.style.overflow=f,d!=null&&d.isConnected&&d.focus()}},[]),Cr.createPortal(o.jsx("div",{className:"knowledge-dialog-backdrop",onMouseDown:d=>{d.target===d.currentTarget&&!r&&n()},children:o.jsxs("section",{ref:l,className:`knowledge-dialog${i?` ${i}`:""}`,role:"dialog","aria-modal":"true","aria-labelledby":s,"aria-busy":r||void 0,children:[o.jsxs("header",{className:"knowledge-dialog__header",children:[o.jsx("h2",{id:s,children:e}),o.jsx("button",{ref:a,type:"button",onClick:n,disabled:r,"aria-label":"关闭",children:o.jsx(vlt,{})})]}),t]})}),document.body)}function Gw({message:e}){return e?o.jsx("div",{className:"knowledge-form-error",role:"alert",children:e}):null}function bL(e){return e instanceof DOMException&&e.name==="AbortError"}function Slt(e){if(!e)return"";const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t):e}const Dge=[".jpg",".jpeg",".png"].join(","),Elt=new Set(Dge.split(",")),Pge=[".pdf",".pptx",".docx",".xlsx",".txt"].join(","),klt=new Set(Pge.split(",")),_lt=200*1024*1024;function yL(e){const t=e.lastIndexOf(".");return t<0?"":e.slice(t).toLocaleLowerCase()}function Tlt(e,t){return e.size>_lt?"单个文件不能超过 200 MB":t==="image"?Elt.has(yL(e.name))?"":"请选择 PNG、JPG 或 JPEG 图片":klt.has(yL(e.name))?"":"请选择 PDF、PPTX、DOCX、XLSX 或 TXT 文件"}function AB(e){return e<=0?"-":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function OL(e){var i;const t=e.type.trim().replace(/^\./,"");if(t)return t.toUpperCase();const n=e.name.trim(),r=n.includes(".")?(i=n.split(".").pop())==null?void 0:i.trim():"";return r?r.toUpperCase():"-"}function Clt({region:e,onClose:t,onCreated:n}){const[r,i]=p.useState(""),[s,a]=p.useState(""),[l,c]=p.useState(!1),[u,d]=p.useState(!1),[f,h]=p.useState(""),m=r.trim(),g=!!(m&&!/^[A-Za-z][A-Za-z0-9_]{0,47}$/.test(m)),b=async y=>{if(y.preventDefault(),c(!0),!m||g)return;d(!0),h("");const O={name:m,description:s.trim()||void 0,region:e};try{n(await qGe(O))}catch(v){h(Ga(v,"创建知识库失败"))}finally{d(!1)}};return o.jsx(_E,{title:"新建知识库",onClose:t,busy:u,children:o.jsxs("form",{onSubmit:y=>void b(y),children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsxs("label",{children:[o.jsx("span",{children:"名称"}),o.jsx("input",{autoFocus:!0,value:r,maxLength:48,"aria-invalid":l&&g||void 0,"aria-describedby":"knowledge-name-help",onBlur:()=>c(!0),onChange:y=>i(y.target.value)})]}),o.jsx("p",{id:"knowledge-name-help",className:`knowledge-dialog__note${l&&g?" is-error":""}`,role:l&&g?"alert":void 0,children:l&&g?"名称必须以字母开头,且只能包含字母、数字和下划线。":"以字母开头,仅支持字母、数字和下划线,最多 48 个字符。"}),o.jsxs("label",{children:[o.jsx("span",{children:"描述(可选)"}),o.jsx("textarea",{value:s,maxLength:80,onChange:y=>a(y.target.value)})]}),o.jsx(Gw,{message:f})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:t,disabled:u,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:u||!m||g,children:u?"创建中":"创建"})]})]})})}function Alt({item:e,onClose:t,onUpdated:n}){const[r,i]=p.useState(e.description),[s,a]=p.useState(!1),[l,c]=p.useState(""),u=async d=>{d.preventDefault(),a(!0),c("");try{n(await XGe(e.id,e.region,{description:r.trim()}))}catch(f){c(Ga(f,"更新知识库失败"))}finally{a(!1)}};return o.jsx(_E,{title:"编辑知识库",onClose:t,busy:s,children:o.jsxs("form",{onSubmit:d=>void u(d),children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsxs("label",{children:[o.jsx("span",{children:"名称"}),o.jsx("input",{value:e.name,disabled:!0})]}),o.jsxs("label",{children:[o.jsx("span",{children:"描述"}),o.jsx("textarea",{autoFocus:!0,value:r,maxLength:80,onChange:d=>i(d.target.value)})]}),o.jsx("p",{className:"knowledge-dialog__note",children:"AgentKit 当前仅支持更新知识库描述。"}),o.jsx(Gw,{message:l})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:t,disabled:s,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:s,children:s?"保存中":"保存"})]})]})})}function Mge(e){if(!e.trim())return{};const t=JSON.parse(e);if(!t||Array.isArray(t)||typeof t!="object")throw new Error("Metadata 必须是 JSON 对象");return t}function Nlt({base:e,onClose:t,onCreated:n,onAssociationInvalid:r}){const[i,s]=p.useState("document"),[a,l]=p.useState(""),[c,u]=p.useState(""),[d,f]=p.useState(""),[h,m]=p.useState(null),[g,b]=p.useState(!1),[y,O]=p.useState("{}"),[v,x]=p.useState(""),[w,S]=p.useState(""),[E,k]=p.useState(null),_=p.useRef(null),C=p.useRef(null),T=p.useRef(null),A=p.useRef(0),j=!!v;p.useEffect(()=>{var D;E&&!j&&((D=T.current)==null||D.focus())},[j,E]);const L=D=>{j||D===i||(s(D),m(null),f(""),l(""),u(""),S(""),k(null),b(!1),A.current=0,_.current&&(_.current.value=""))},I=D=>{if(!D||i==="web")return;const Q=Tlt(D,i);if(Q){m(null),l(""),u(""),S(Q);return}m(D),S(""),l(D.name.replace(/\.[^.]+$/,"")),u(yL(D.name).slice(1))},M=async D=>{if(D.preventDefault(),i==="web"?!d.trim():!h)return;let Q;try{Q=Mge(y)}catch(F){S(Ga(F,"Metadata 格式错误"));return}x(i==="web"?E?"save":"preview":"upload"),S("");try{if(i==="web")if(E){const F={sourceType:"url",metadata:E.metadata,url:E.preview.url,sourceTitle:E.preview.name,sourceMarkdown:E.preview.sourceMarkdown};await ZGe(e.id,e.region,F),n()}else{const F=await KGe(e.id,e.region,{url:d.trim()});if(!F.sourceMarkdown.trim())throw new Error("网页没有可预览的 Markdown 内容");k({preview:F,metadata:Q})}else h&&(await JGe(e.id,e.region,{file:h,name:a.trim()||void 0,documentType:c.trim()||void 0,metadata:Q}),n())}catch(F){F instanceof wj&&F.errorCode===Whe?r(F):S(Ga(F,i==="web"?E?"添加网页失败":"生成网页预览失败":"上传文件失败"))}finally{x("")}},N=()=>{j||(k(null),S(""),requestAnimationFrame(()=>{var D;return(D=C.current)==null?void 0:D.focus()}))};return o.jsx(_E,{title:E?"预览网页内容":"添加数据",onClose:t,busy:j,className:E?"knowledge-dialog--preview knowledge-dialog--web-confirm":"",children:o.jsx("form",{onSubmit:D=>void M(D),children:E?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"knowledge-preview knowledge-web-preview",children:[o.jsxs("div",{className:"knowledge-preview__meta",children:[o.jsx("strong",{title:E.preview.name,children:E.preview.name}),o.jsx("a",{href:E.preview.url,target:"_blank",rel:"noopener noreferrer",children:"打开原网页"})]}),o.jsx("div",{className:"knowledge-preview__body","aria-live":"polite",children:o.jsx("div",{className:"knowledge-preview__markdown-shell",children:o.jsx(xu,{text:E.preview.sourceMarkdown,allowRawHtml:!1,className:"knowledge-preview__markdown"})})}),w?o.jsx("div",{className:"knowledge-web-preview__error",children:o.jsx(Gw,{message:w})}):null]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",className:"is-back",onClick:N,disabled:j,children:"返回修改"}),o.jsx("button",{type:"button",onClick:t,disabled:j,children:"取消"}),o.jsx("button",{ref:T,type:"submit",className:"is-primary",disabled:j,children:v==="save"?"添加中":"确认添加"})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsx("div",{className:"knowledge-source-tabs",role:"tablist","aria-label":"知识来源",children:[["image","图片"],["document","文档文件"],["web","在线网页"]].map(([D,Q])=>o.jsx("button",{type:"button",role:"tab",id:`knowledge-source-${D}-tab`,"aria-controls":`knowledge-source-${D}-panel`,"aria-selected":i===D,tabIndex:i===D?0:-1,className:i===D?"is-active":"",disabled:j,onClick:()=>L(D),onKeyDown:F=>{const $=["image","document","web"];if(!["ArrowLeft","ArrowRight","Home","End"].includes(F.key))return;F.preventDefault();const H=$.indexOf(D),z=F.key==="Home"?$[0]:F.key==="End"?$[$.length-1]:$[(H+(F.key==="ArrowRight"?1:-1)+$.length)%$.length];L(z),requestAnimationFrame(()=>{var B;return(B=document.getElementById(`knowledge-source-${z}-tab`))==null?void 0:B.focus()})},children:Q},D))}),o.jsx("div",{id:`knowledge-source-${i}-panel`,className:"knowledge-source-panel",role:"tabpanel","aria-labelledby":`knowledge-source-${i}-tab`,children:i==="web"?o.jsxs(o.Fragment,{children:[o.jsxs("label",{children:[o.jsx("span",{children:"网页 URL"}),o.jsx("input",{ref:C,autoFocus:!0,type:"url",value:d,disabled:j,onChange:D=>{f(D.target.value),S("")},placeholder:"https://example.com/article"})]}),o.jsx("div",{className:"knowledge-upload-status",role:"status","aria-live":"polite",children:v==="preview"?o.jsx(En,{children:"正在抓取网页并生成 Markdown 预览"}):null})]}):o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:_,className:"knowledge-upload-input",type:"file","aria-label":"选择知识文件",accept:i==="image"?Dge:Pge,disabled:j,onChange:D=>{var Q;I(((Q=D.currentTarget.files)==null?void 0:Q[0])??null),D.currentTarget.value=""}}),o.jsxs("button",{type:"button",className:`knowledge-upload-dropzone${g?" is-dragging":""}${h?" is-ready":""}`,disabled:j,onClick:()=>{var D;return(D=_.current)==null?void 0:D.click()},onDragEnter:D=>{D.preventDefault(),!j&&(A.current+=1,b(!0))},onDragOver:D=>{D.preventDefault(),j||(D.dataTransfer.dropEffect="copy")},onDragLeave:D=>{D.preventDefault(),A.current=Math.max(0,A.current-1),A.current===0&&b(!1)},onDrop:D=>{var Q;D.preventDefault(),A.current=0,b(!1),j||I(((Q=D.dataTransfer.files)==null?void 0:Q[0])??null)},children:[o.jsx("strong",{children:h?h.name:"选择文件或拖拽到这里"}),o.jsx("span",{children:h?`${AB(h.size)} · 点击可重新选择`:i==="image"?"支持 PNG、JPG 和 JPEG,单个文件不超过 200 MB":"支持 PDF、PPTX、DOCX、XLSX 和 TXT,单个文件不超过 200 MB"})]}),o.jsx("div",{className:"knowledge-upload-status",role:"status","aria-live":"polite",children:j?o.jsx(En,{children:"正在上传文件并添加到知识库"}):null})]})}),i!=="web"?o.jsxs("div",{className:"knowledge-dialog__fields",children:[o.jsxs("label",{children:[o.jsx("span",{children:"名称(可选)"}),o.jsx("input",{value:a,disabled:j,maxLength:256,onChange:D=>l(D.target.value)})]}),o.jsxs("label",{children:[o.jsx("span",{children:"类型(可选)"}),o.jsx("input",{value:c,disabled:j,maxLength:64,onChange:D=>u(D.target.value),placeholder:"pdf、docx、png"})]})]}):null,o.jsxs("label",{children:[o.jsx("span",{children:"Metadata(JSON)"}),o.jsx("textarea",{className:"is-code",value:y,disabled:j,onChange:D=>O(D.target.value),spellCheck:!1})]}),o.jsx(Gw,{message:w})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:t,disabled:j,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:j||(i==="web"?!d.trim():!h),children:j?i==="web"?"生成中":"上传中":i==="web"?"生成预览":"上传文件"})]})]})})})}function jlt({base:e,item:t,onClose:n,onUpdated:r}){const[i,s]=p.useState(()=>JSON.stringify(t.metadata??{},null,2)),[a,l]=p.useState(!1),[c,u]=p.useState(""),d=async f=>{f.preventDefault();let h;try{h=Mge(i)}catch(m){u(Ga(m,"Metadata 格式错误"));return}l(!0),u("");try{r(await eWe(e.id,t.id,e.region,{metadata:h}))}catch(m){u(Ga(m,"更新知识失败"))}finally{l(!1)}};return o.jsx(_E,{title:"编辑知识 Metadata",onClose:n,busy:a,children:o.jsxs("form",{onSubmit:f=>void d(f),children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsxs("label",{children:[o.jsx("span",{children:"知识"}),o.jsx("input",{value:t.name||t.id,disabled:!0})]}),o.jsxs("label",{children:[o.jsx("span",{children:"Metadata(JSON)"}),o.jsx("textarea",{autoFocus:!0,className:"is-code knowledge-metadata-editor",value:i,onChange:f=>s(f.target.value),spellCheck:!1})]}),o.jsx(Gw,{message:c})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:n,disabled:a,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:a,children:a?"保存中":"保存"})]})]})})}const Lge=new Set(["avif","bmp","gif","jpeg","jpg","png","svg","webp"]),$ge=new Set(["aac","flac","m4a","mp3","ogg","wav","webm"]),Bge=new Set(["m4v","mov","mp4","mpeg","mpg","ogg","webm"]),Rlt=new Set(["pdf"]),Ilt=new Set(["doc","docx","ppt","pptx","xls","xlsx"]),Dlt=new Set(["creating","indexing","pending","processing","queued","submitted"]),Plt=new Set(["error","failed","unavailable"]);function PW(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function _2(e){if(e==null||e==="")return"-";if(["string","number","boolean"].includes(typeof e))return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function Mlt(e){if(Array.isArray(e)){if(e.length===0)return null;const r=e.map(PW);if(r.some(i=>Object.keys(i).length>0)){const i=[...new Set(r.flatMap(s=>Object.keys(s)))];return{columns:i,rows:r.map(s=>i.map(a=>_2(s[a])))}}return{columns:["值"],rows:e.map(i=>[_2(i)])}}const t=PW(e),n=Object.entries(t);if(n.length===0)return null;if(n.every(([,r])=>Array.isArray(r))){const r=n.map(([s])=>s),i=Math.max(...n.map(([,s])=>s.length));return{columns:r,rows:Array.from({length:i},(s,a)=>n.map(([,l])=>_2(l[a])))}}return{columns:["字段","值"],rows:n.map(([r,i])=>[r,_2(i)])}}function Qge(e){const t=e.trim();if(!t||t.startsWith("//"))return"";if(t.startsWith("/"))return t;try{const n=new URL(t);return["http:","https:"].includes(n.protocol)?n.href:""}catch{return""}}function Llt(e){const t=Qge(e);return t.startsWith("http://")||t.startsWith("https://")?t:""}function $lt(e){var i;const t=e.attachmentType.trim().toLocaleLowerCase();if(t==="image"||t==="doc-image"||t.startsWith("image/"))return"image";if(t==="audio"||t.startsWith("audio/"))return"audio";if(t==="video"||t.startsWith("video/"))return"video";if(t==="pdf"||t==="application/pdf")return"pdf";const n=e.attachmentUrl.split(/[?#]/,1)[0],r=n.includes(".")?((i=n.split(".").pop())==null?void 0:i.toLocaleLowerCase())??"":"";return Lge.has(r)?"image":$ge.has(r)?"audio":Bge.has(r)?"video":Rlt.has(r)?"pdf":t||r?"file":"none"}function Blt(e){const t=e.status.trim().toLocaleLowerCase();if(Dlt.has(t))return{title:"数据正在处理中",detail:"知识库完成解析后即可预览,请稍后重新加载。"};if(Plt.has(t))return{title:"数据解析失败",detail:"请检查源文件或网页地址后重新添加,也可以重新加载最新状态。"};const n=OL(e).toLocaleLowerCase();return n==="pdf"||Ilt.has(n)?{title:"暂时没有可预览的解析内容",detail:"此类文件会在知识库完成解析后显示文本、表格或页面图片。"}:Lge.has(n)||$ge.has(n)||Bge.has(n)?{title:"暂时没有可预览的媒体内容",detail:"知识库尚未返回可访问的媒体预览,请稍后重新加载。"}:{title:"暂无可预览的数据内容",detail:"知识库尚未返回解析结果,请稍后重新加载。"}}function Qlt({chunk:e}){const[t,n]=p.useState(!1),r=Qge(e.attachmentUrl),i=$lt(e);return!r||i==="none"?null:t?o.jsx("div",{className:"knowledge-preview__attachment-error",children:"附件无法预览,请稍后重试。"}):i==="image"?o.jsx("img",{className:"knowledge-preview__image",src:r,alt:e.title||"知识数据图片",loading:"lazy",onError:()=>n(!0)}):i==="audio"?o.jsx("audio",{className:"knowledge-preview__audio",src:r,controls:!0,preload:"metadata",onError:()=>n(!0),children:"当前浏览器不支持音频预览。"}):i==="video"?o.jsx("video",{className:"knowledge-preview__video",src:r,controls:!0,playsInline:!0,preload:"metadata",onError:()=>n(!0),children:"当前浏览器不支持视频预览。"}):i==="pdf"?o.jsxs("div",{className:"knowledge-preview__pdf",children:[o.jsx("iframe",{src:r,title:e.title?`${e.title} PDF 预览`:"PDF 预览",sandbox:"",referrerPolicy:"no-referrer",onError:()=>n(!0)}),o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:"无法显示时,在新窗口打开 PDF"})]}):o.jsxs("div",{className:"knowledge-preview__file-fallback",children:[o.jsx("p",{children:"当前格式暂不支持直接在线预览,已优先显示解析后的内容。"}),o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:"打开原文件"})]})}function Ult({base:e,item:t,onClose:n}){const[r,i]=p.useState([]),[s,a]=p.useState(t),[l,c]=p.useState(""),[u,d]=p.useState(!0),[f,h]=p.useState(!1),[m,g]=p.useState(!1),[b,y]=p.useState(""),O=p.useRef(0),v=p.useRef(null),x=p.useCallback(async(k=0)=>{var T;(T=v.current)==null||T.abort();const _=new AbortController;v.current=_;const C=O.current+1;O.current=C,k>0?h(!0):d(!0),y(""),k===0&&(i([]),g(!1));try{const A=await YGe(e.id,t.id,{region:e.region,offset:k,signal:_.signal});if(O.current!==C)return;a(A.document.id?A.document:t),c(A.sourceMarkdown||A.document.sourceMarkdown),i(j=>k>0?[...j,...A.chunks]:A.chunks),g(A.hasMore)}catch(A){!bL(A)&&O.current===C&&y(Ga(A,"加载数据预览失败"))}finally{O.current===C&&(d(!1),h(!1))}},[e.id,e.region,t]);p.useEffect(()=>(x(),()=>{var k;(k=v.current)==null||k.abort(),O.current+=1}),[x]);const w=Llt(s.url||t.url),S=Blt(s),E=s.metadata._veadk_content_format==="markdown";return o.jsx(_E,{title:s.name||t.name||t.id,onClose:n,className:"knowledge-dialog--preview",children:o.jsxs("div",{className:"knowledge-preview",children:[s.sizeBytes>0||w?o.jsxs("div",{className:"knowledge-preview__meta",children:[s.sizeBytes>0?o.jsx("span",{children:AB(s.sizeBytes)}):null,w?o.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",children:"打开原网页"}):null]}):null,o.jsx("div",{className:"knowledge-preview__body","aria-live":"polite",children:l?o.jsx("div",{className:"knowledge-preview__markdown-shell",children:o.jsx(xu,{text:l,allowRawHtml:!1,className:"knowledge-preview__markdown"})}):u?o.jsx("div",{className:"knowledge-preview__state",role:"status",children:o.jsx(En,{as:"span",duration:2.4,children:"正在加载数据预览"})}):b&&r.length===0?o.jsxs("div",{className:"knowledge-preview__state is-error",role:"alert",children:[o.jsx("p",{children:b}),o.jsx("button",{type:"button",onClick:()=>void x(),children:"重试"})]}):r.length===0?o.jsxs("div",{className:"knowledge-preview__state",children:[o.jsx("p",{children:S.title}),o.jsx("span",{children:w?"您可以打开原网页查看来源内容。":S.detail}),o.jsx("button",{type:"button",onClick:()=>void x(),children:"重新加载"})]}):o.jsxs("div",{className:"knowledge-preview__chunks",children:[r.map((k,_)=>{const C=Mlt(k.tableFields),T=k.id||`${_}:${k.title}`;return o.jsxs("article",{className:"knowledge-preview__chunk",children:[o.jsx("header",{children:o.jsx("h3",{children:k.title||`片段 ${_+1}`})}),k.content?E?o.jsx(xu,{text:k.content,allowRawHtml:!1,className:"knowledge-preview__markdown"}):o.jsx("p",{className:"knowledge-preview__content",children:k.content}):null,C?o.jsx("div",{className:"knowledge-preview__table-wrap",children:o.jsxs("table",{children:[o.jsx("thead",{children:o.jsx("tr",{children:C.columns.map((A,j)=>o.jsx("th",{scope:"col",children:A},`${A}:${j}`))})}),o.jsx("tbody",{children:C.rows.map((A,j)=>o.jsx("tr",{children:A.map((L,I)=>o.jsx("td",{children:L},I))},j))})]})}):null,o.jsx(Qlt,{chunk:k})]},T)}),b?o.jsx("div",{className:"knowledge-preview__more-error",role:"alert",children:b}):null,m?o.jsx("button",{type:"button",className:"knowledge-preview__load-more",disabled:f,onClick:()=>void x(r.length),children:f?o.jsx(En,{as:"span",duration:2.4,children:"正在加载更多"}):"加载更多"}):null]})})]})})}function Flt({cloudProvider:e,region:t,active:n=!0,activationRevision:r=0,onDetailChange:i,toolbarLeading:s,toolbarFilters:a}){const[l,c]=p.useState([]),[u,d]=p.useState({}),[f,h]=p.useState([]),[m,g]=p.useState(""),[b,y]=p.useState("overview"),[O,v]=p.useState(""),[x,w]=p.useState(""),[S,E]=p.useState(!0),[k,_]=p.useState(!1),[C,T]=p.useState(""),[A,j]=p.useState([]),[L,I]=p.useState(!1),[M,N]=p.useState(""),[D,Q]=p.useState(""),[F,$]=p.useState(""),[H,z]=p.useState(!1),[B,V]=p.useState(!1),[Z,ce]=p.useState(!1),[be,ie]=p.useState(null),[q,X]=p.useState(null),[K,de]=p.useState(null),[xe,Me]=p.useState(null),[Ae,He]=p.useState(null),[et,Te]=p.useState(!1),Re=p.useRef(0),he=p.useRef(0),me=p.useRef([]),Se=p.useRef(!1),ke=p.useRef(!1),nt=p.useRef(null),Qe=p.useRef(null),re=p.useRef({}),ue=p.useRef(!1),Pe=p.useRef(null),Ge=p.useRef(null),W=p.useRef(null),_e=p.useRef(null),rt=p.useMemo(()=>[t],[t]),Ve=p.useCallback(we=>`${we.region}\0${we.id}`,[]),We=l.find(we=>Ve(we)===m)??null,ot=!!(We&&F===Ve(We));p.useEffect(()=>{i==null||i(!!We)},[i,We]),p.useEffect(()=>{y("overview"),w("")},[m]);const St=p.useMemo(()=>{const we=O.trim().toLocaleLowerCase();return we?l.filter(Fe=>[Fe.name,Fe.description,Fe.ownerLabel,Fe.providerKnowledgeId].some(dt=>dt.toLocaleLowerCase().includes(we))):l},[l,O]),Vt=p.useMemo(()=>{const we=x.trim().toLocaleLowerCase();return we?A.filter(Fe=>[Fe.name,Fe.id,OL(Fe)].some(dt=>dt.toLocaleLowerCase().includes(we))):A},[x,A]);p.useEffect(()=>{X(null)},[We==null?void 0:We.id,We==null?void 0:We.region]);const _t=p.useCallback(async(we=!1)=>{var Tt;if(we&&(ue.current||Object.keys(re.current).length===0))return;(Tt=nt.current)==null||Tt.abort();const Fe=new AbortController;nt.current=Fe;const dt=Re.current+1;Re.current=dt,ue.current=!0,we?_(!0):E(!0),T(""),we||h([]);try{const Pt=await HGe({regions:rt,nextTokens:we?re.current:void 0,signal:Fe.signal});if(Re.current!==dt)return;c(ln=>we?[...ln,...Pt.items.filter(le=>!ln.some(Wt=>Ve(Wt)===Ve(le)))]:Pt.items),re.current=Pt.nextTokens,d(Pt.nextTokens);const nn=Pt.failures.map(({region:ln,error:le})=>`${Zf(ln,e)}:${Ga(le,"加载失败")}`);h(ln=>we?[...new Set([...ln,...nn])]:nn),we||g(ln=>Pt.items.some(le=>Ve(le)===ln)?ln:"")}catch(Pt){if(bL(Pt))return;Re.current===dt&&(we?h(nn=>[...new Set([...nn,Ga(Pt,"加载更多知识库失败")])]):T(Ga(Pt,"加载知识库失败")))}finally{Re.current===dt&&(ue.current=!1,E(!1),_(!1))}},[Ve,e,rt]),Ne=p.useCallback(async(we,Fe=!1)=>{var Pt;if(Fe&&Se.current)return;(Pt=Qe.current)==null||Pt.abort();const dt=new AbortController;Qe.current=dt;const Tt=he.current+1;he.current=Tt,Fe||(me.current=[],ke.current=!1,j([]),z(!1),Q("")),Se.current=!0,I(!0),Fe?Q(""):N("");try{const nn=await WGe(we.id,{region:we.region,offset:Fe?me.current.length:0,signal:dt.signal});if(he.current!==Tt)return;$(Le=>Le===Ve(we)?"":Le);const ln=me.current,le=Fe?[...ln,...nn.items.filter(Le=>!Le.id||!ln.some(Rt=>Rt.id===Le.id))]:nn.items,Wt=nn.hasMore&&(!Fe||le.length>ln.length);me.current=le,ke.current=Wt,j(le),z(Wt)}catch(nn){if(bL(nn))return;he.current===Tt&&(nn instanceof wj&&nn.errorCode===Whe&&($(Ve(we)),ie(le=>le&&Ve(le)===Ve(we)?null:le)),Fe?Q(Ga(nn,"加载更多数据失败")):N(Ga(nn,"加载数据失败")))}finally{he.current===Tt&&(Se.current=!1,I(!1))}},[Ve]);p.useEffect(()=>{var we;(we=nt.current)==null||we.abort(),Re.current+=1,ue.current=!1,re.current={},c([]),d({}),h([]),g(""),$(""),T(""),E(!0)},[e]),p.useEffect(()=>{if(n)return _t(),()=>{var we;(we=nt.current)==null||we.abort(),Re.current+=1,ue.current=!1}},[n,r,_t]),p.useEffect(()=>{var we,Fe;if(!n){(we=Qe.current)==null||we.abort(),he.current+=1,Se.current=!1;return}if(!We){(Fe=Qe.current)==null||Fe.abort(),he.current+=1,me.current=[],Se.current=!1,ke.current=!1,j([]),z(!1),Q("");return}return Ne(We),()=>{var dt;(dt=Qe.current)==null||dt.abort(),he.current+=1,Se.current=!1}},[n,r,We==null?void 0:We.id,We==null?void 0:We.region]);const $e=n&&!We&&!O.trim()&&!S&&!k&&!C&&Object.keys(u).length>0;p.useEffect(()=>{const we=Ge.current,Fe=Pe.current;if(!we||!Fe||!$e)return;const dt=new IntersectionObserver(([Tt])=>{Tt.isIntersecting&&_t(!0)},{root:Fe,rootMargin:"240px 0px",threshold:.01});return dt.observe(we),()=>dt.disconnect()},[$e,_t]);const mt=()=>{const we=Pe.current;!we||!$e||we.scrollHeight-we.scrollTop-we.clientHeight<=240&&_t(!0)},Ht=!!(We&&A.length>0&&H&&!L&&!D);p.useEffect(()=>{const we=_e.current,Fe=W.current;if(!We||!we||!Fe||!Ht)return;const dt=new IntersectionObserver(([Tt])=>{Tt.isIntersecting&&Ne(We,!0)},{root:W.current,rootMargin:"240px 0px",threshold:.01});return dt.observe(we),()=>dt.disconnect()},[Ht,Ne,We==null?void 0:We.id,We==null?void 0:We.region]);const qe=()=>{const we=W.current;if(!We||!we||!ke.current||Se.current||D)return;const{scrollHeight:Fe,scrollTop:dt,clientHeight:Tt}=we;Fe-dt-Tt<=240&&Ne(We,!0)},ye=we=>{c(Fe=>Fe.map(dt=>Ve(dt)===Ve(we)?we:dt))},Ue=async()=>{if(xe){Te(!0);try{await GGe(xe.id,xe.region),c(we=>we.filter(Fe=>Ve(Fe)!==Ve(xe))),$(we=>we===Ve(xe)?"":we),m===Ve(xe)&&g(""),Me(null)}catch(we){T(Ga(we,"删除知识库失败")),Me(null)}finally{Te(!1)}}},it=async()=>{if(!(!We||!Ae)){Te(!0);try{await tWe(We.id,Ae.id,We.region);const we=me.current.filter(Fe=>Fe.id!==Ae.id);me.current=we,j(we),He(null)}catch(we){N(Ga(we,"删除知识失败")),He(null)}finally{Te(!1)}}};return o.jsxs("section",{className:`knowledge-library${We?" is-detail":" resource-collection"}`,"aria-label":"知识库",children:[We?o.jsx(hE,{className:"knowledge-library__detail",title:We.name,description:We.description||"暂无描述",identitySeed:We.name,backLabel:"返回知识库列表",onBack:()=>g(""),sections:[{key:"overview",label:"概览",content:o.jsx("section",{className:"knowledge-overview",children:o.jsxs(G7,{className:"knowledge-overview__summary",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"Provider"}),o.jsx("dd",{children:We.providerType||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"Knowledge ID"}),o.jsx("dd",{className:"knowledge-keyboard-reveal",tabIndex:0,title:We.providerKnowledgeId,children:We.providerKnowledgeId||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"项目"}),o.jsx("dd",{children:We.projectName||"default"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"创建者"}),o.jsx("dd",{children:Qv(We.ownerLabel)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"更新时间"}),o.jsx("dd",{children:Slt(We.updatedAt)||"-"})]})]})})},{key:"data",label:"数据",content:o.jsx("section",{className:"knowledge-documents",children:o.jsx("div",{className:`knowledge-documents__body${A.length>0?" is-table":""}`,"aria-live":"polite",children:L&&A.length===0?o.jsx(bd,{}):M&&A.length===0?o.jsxs("div",{className:"knowledge-library__state is-error",role:"alert",children:[o.jsx("p",{children:M}),ot&&We.canManage?o.jsx("button",{type:"button",onClick:()=>Me(We),children:"删除失效关联"}):o.jsx("button",{type:"button",onClick:()=>void Ne(We),children:"重试"})]}):A.length===0?o.jsxs("div",{className:"knowledge-library__state",children:[o.jsx(xlt,{}),o.jsx("p",{children:"这个知识库还没有数据"}),We.canManage&&o.jsx("button",{type:"button",onClick:()=>ie(We),children:"添加第一项数据"})]}):o.jsx(uGe,{rows:Vt,rowKey:we=>we.id,rowLabel:we=>we.name||we.id,columns:[{key:"name",header:"名称",className:"is-primary-column",render:we=>o.jsx("span",{title:we.name||we.id,children:we.name||we.id})},{key:"format",header:"格式",className:"is-compact-column",render:we=>OL(we)},{key:"size",header:"大小",className:"is-compact-column",render:we=>AB(we.sizeBytes)}],searchValue:x,onSearchChange:w,searchPlaceholder:"搜索数据",searchLabel:"搜索知识库数据",primaryAction:We.canManage?{label:ot?"关联已失效":"添加数据",disabled:ot,title:ot?"底层 Provider 知识库已不存在":void 0,onClick:()=>ie(We)}:void 0,rowActions:we=>[{label:"预览",onSelect:()=>X(we)},...We.canManage?[{label:"编辑",onSelect:()=>de(we)},{label:"删除",onSelect:()=>He(we),danger:!0}]:[]],scrollRef:W,onScroll:qe,busy:L,emptyLabel:"没有匹配的数据",footer:L?o.jsxs("div",{className:"knowledge-document-pagination",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),o.jsx("span",{children:"正在加载更多数据"})]}):D?o.jsxs("div",{className:"knowledge-document-pagination is-error",role:"alert",children:[o.jsx("span",{children:D}),o.jsx("button",{type:"button",onClick:()=>void Ne(We,!0),children:"重试加载"})]}):H?o.jsx("div",{ref:_e,className:"knowledge-document-pagination",role:"status","aria-live":"polite",children:"继续下滑加载更多"}):null})})})}],activeSectionKey:b,navigationLabel:"知识库详情",onSectionChange:y,actions:We.canManage?o.jsxs(o.Fragment,{children:[o.jsx(Nt,{type:"button",color:"danger",variant:"soft",size:"lg",pill:!1,onClick:()=>Me(We),children:"删除"}),o.jsx(Nt,{type:"button",color:"primary",size:"lg",pill:!1,onClick:()=>ce(!0),children:"编辑"})]}):void 0}):o.jsxs(o.Fragment,{children:[o.jsxs(g0,{className:"knowledge-library__toolbar library-resource-toolbar",children:[s,o.jsxs("div",{className:"resource-toolbar__actions",children:[a,o.jsx(Gp,{value:O,onChange:we=>v(we.target.value),placeholder:"搜索知识库","aria-label":"搜索知识库"})]})]}),o.jsxs(b0,{ref:Pe,"aria-live":"polite",onScroll:mt,children:[f.length>0&&!S&&o.jsxs("div",{className:"knowledge-region-warning",role:"status",children:[o.jsx("span",{children:"部分知识库暂时无法加载,已展示其余可用内容。"}),o.jsx("button",{type:"button",onClick:()=>void _t(),children:"重试"})]}),S&&l.length===0?o.jsx(bd,{}):C?o.jsxs("div",{className:"knowledge-library__state is-error",role:"alert",children:[o.jsx("p",{children:C}),o.jsx("button",{type:"button",onClick:()=>void _t(),children:"重试"})]}):St.length===0&&O.trim()?o.jsxs("div",{className:"knowledge-library__state",children:[o.jsx(Olt,{}),o.jsx("p",{children:"没有匹配的知识库"})]}):o.jsxs(aO,{children:[O.trim()?null:o.jsx(Vg,{"aria-label":"新建知识库",icon:o.jsx(wlt,{}),onClick:()=>V(!0),children:"新建知识库"}),St.map(we=>o.jsx(bE,{className:"knowledge-card",title:we.name,description:we.description||"暂无描述",metadata:[{label:"创建者",value:Qv(we.ownerLabel),title:Qv(we.ownerLabel)},{label:"项目",value:we.projectName||"default",title:we.projectName||"default"}],action:{label:F===Ve(we)?"关联已失效":"添加数据",icon:"plus",disabled:!we.canManage||F===Ve(we),title:we.canManage?F===Ve(we)?"底层 Provider 知识库已不存在":void 0:"您没有管理此知识库的权限",onClick:()=>ie(we)},detailAction:{label:"查看详情",onClick:()=>g(Ve(we))}},Ve(we)))]}),$e||k?o.jsx("div",{ref:Ge,className:"my-agent-load-more",role:"status","aria-live":"polite",children:k?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),o.jsx("span",{children:"正在加载更多知识库"})]}):$e?o.jsx("span",{children:"继续下滑加载更多"}):null}):null]})]}),B&&o.jsx(Clt,{region:t,onClose:()=>V(!1),onCreated:we=>{c(Fe=>[we,...Fe]),g(Ve(we)),V(!1)}}),We&&Z&&o.jsx(Alt,{item:We,onClose:()=>ce(!1),onUpdated:we=>{ye(we),ce(!1)}}),We&&q&&o.jsx(Ult,{base:We,item:q,onClose:()=>X(null)}),be&&o.jsx(Nlt,{base:be,onClose:()=>ie(null),onAssociationInvalid:we=>{$(Ve(be)),We&&Ve(We)===Ve(be)&&N(Ga(we,"知识库关联已失效")),ie(null)},onCreated:()=>{We&&Ve(We)===Ve(be)&&Ne(We),ie(null)}}),We&&K&&o.jsx(jlt,{base:We,item:K,onClose:()=>de(null),onUpdated:we=>{const Fe=me.current.map(dt=>dt.id===we.id?we:dt);me.current=Fe,j(Fe),de(null)}}),xe&&o.jsx(zl,{title:"删除知识库?",description:`将删除 ${xe.name} 的 AgentKit 关联;如果它由 Studio 创建,也会同时删除 Provider 资源。此操作无法撤销。`,confirmLabel:et?"删除中":"删除",variant:"danger",busy:et,onCancel:()=>Me(null),onConfirm:()=>void Ue()}),Ae&&o.jsx(zl,{title:"删除知识?",description:`将从 Provider 知识库中删除 ${Ae.name||Ae.id},此操作无法撤销。`,confirmLabel:et?"删除中":"删除",variant:"danger",busy:et,onCancel:()=>He(null),onConfirm:()=>void it()})]})}const zlt="_EmptyMessage_1r5gu_1",Vlt="_IconBadge_1r5gu_16",Hlt="_Title_1r5gu_54",qlt="_Description_1r5gu_69",Xlt="_ActionRow_1r5gu_77",TE={EmptyMessage:zlt,IconBadge:Vlt,Title:Hlt,Description:qlt,ActionRow:Xlt},xn=({children:e,className:t,fill:n="static"})=>o.jsx("div",{className:ur(TE.EmptyMessage,t),"data-fill":n,children:e}),Glt=({size:e="md",color:t="secondary",children:n,className:r})=>o.jsx("div",{className:ur(TE.IconBadge,r),"data-size":e,"data-color":t,children:n}),Wlt=({children:e,className:t,color:n="secondary"})=>o.jsx("div",{className:ur(TE.Title,t),"data-color":n,children:e}),Ylt=({children:e,className:t})=>o.jsx("div",{className:ur(TE.Description,t),children:e}),Zlt=({children:e,className:t})=>o.jsx("div",{className:ur(TE.ActionRow,t),children:e});xn.Icon=Glt;xn.Title=Wlt;xn.Description=Ylt;xn.ActionRow=Zlt;const Klt="/web/skill-management";class Jlt extends Error{constructor(t,n,r="SKILL_MANAGEMENT_ERROR",i="",s,a=""){super(t),this.status=n,this.code=r,this.statusText=i,this.originalError=s,this.rawResponse=a,this.name="SkillManagementApiError"}}async function yh(e,t={},n=_o){return fetch(xo(`${Klt}${e}`),{...t,headers:fh(t.headers),signal:nl(t.signal,n)})}async function Uge(e,t){let n=t,r="SKILL_MANAGEMENT_ERROR",i;const s=await e.text().catch(()=>"");try{const a=JSON.parse(s);typeof a.detail=="string"?n=a.detail:a.detail&&(n=a.detail.message||t,r=a.detail.code||r,i=a.detail.originalError)}catch{s.trim()&&(n=`${t}:${s.trim()}`)}return new Jlt(n,e.status,r,e.statusText,i,s)}async function Oh(e,t){if(!e.ok)throw await Uge(e,t);return e.json()}async function ect(e){const t=new URLSearchParams({region:e.region,page:String(e.page),page_size:String(e.pageSize)});return e.project&&t.set("project",e.project),Oh(await yh(`/spaces?${t}`,{signal:e.signal}),"读取 Skill 空间失败")}async function tct(e){return Oh(await yh("/spaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),"创建 Skill 空间失败")}async function nct(e){return Oh(await yh(`/spaces/${encodeURIComponent(e.spaceId)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,description:e.description,region:e.region})}),"更新 Skill 空间失败")}async function rct(e){const t=new URLSearchParams({region:e.region});await Oh(await yh(`/spaces/${encodeURIComponent(e.spaceId)}?${t}`,{method:"DELETE"}),"删除 Skill 空间失败")}async function ict(e){const t=new URLSearchParams({region:e.region});return e.project&&t.set("project",e.project),Oh(await yh(`/spaces/${encodeURIComponent(e.spaceId)}/skills?${t}`,{method:"POST",headers:{"Content-Type":"application/zip"},body:e.file},Zi),"上传 Skill 失败")}async function sct(e){return Oh(await yh("/validate",{method:"POST",headers:{"Content-Type":"application/zip"},body:e},Zi),"校验 Skill 失败")}async function act(e){const t=new URLSearchParams({region:e.region});await Oh(await yh(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}?${t}`,{method:"DELETE"}),"删除 Skill 失败")}async function oct(e){const t=new URLSearchParams({region:e.region});e.version&&t.set("version",e.version),e.skillSpaceName&&t.set("skill_space_name",e.skillSpaceName),e.skillName&&t.set("skill_name",e.skillName);const n=await Oh(await yh(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}/files?${t}`),"读取 Skill 文件失败");return Array.isArray(n.files)?n.files:[]}async function lct(e){var l;const t=new URLSearchParams({region:e.region});e.version&&t.set("version",e.version),e.skillSpaceName&&t.set("skill_space_name",e.skillSpaceName),e.skillName&&t.set("skill_name",e.skillName);const n=await yh(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}/archive?${t}`,{},Zi);n.ok||await Oh(n,"下载 Skill 失败");const i=((l=(n.headers.get("content-disposition")||"").match(/filename="([^"]+)"/))==null?void 0:l[1])||`${e.fallbackName}.zip`,s=URL.createObjectURL(await n.blob()),a=document.createElement("a");a.href=s,a.download=i,a.click(),URL.revokeObjectURL(s)}async function Pj(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:nl(void 0,_o)});if(!t.ok)throw await Uge(t,"AgentKit Skills 请求失败");return t.json()}async function Fge(){return(await Pj("/web/skill-spaces")).items||[]}async function zge(e,t){const n=t?`?region=${encodeURIComponent(t)}`:"";return(await Pj(`/web/skill-spaces/${encodeURIComponent(e)}/skills${n}`)).items||[]}async function cct(e,t){const n=new URLSearchParams({region:t.region,page:String(t.page),page_size:String(t.pageSize)});return t.project&&n.set("project",t.project),Pj(`/web/skill-spaces/${encodeURIComponent(e)}/skills?${n.toString()}`)}async function uct(e,t,n,r,i,s,a){const l=[];n&&l.push(`version=${encodeURIComponent(n)}`),r&&l.push(`region=${encodeURIComponent(r)}`),i&&l.push(`project=${encodeURIComponent(i)}`),s&&l.push(`skill_name=${encodeURIComponent(s)}`),a&&l.push(`skill_space_name=${encodeURIComponent(a)}`);const c=l.length>0?`?${l.join("&")}`:"";return Pj(`/web/skill-spaces/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}${c}`)}function dct(e,t){return{source:"skillspace",id:`ss:${e.id}/${t.skillId}/${t.version}`,name:t.skillName,description:t.skillDescription,folder:t.skillName,skillSpaceId:e.id,skillSpaceName:e.name,skillSpaceRegion:e.region,skillId:t.skillId,version:t.version}}function fct(e,t,n="volcengine"){return n==="byteplus"?"":`https://console.volcengine.com/agentkit/${(t||"cn-beijing")==="cn-beijing"?"cn":"cn-shanghai"}/skillspace/detail/${encodeURIComponent(e)}`}const hct="/web/skill-workbench";class xL extends Error{constructor(t,n,r="SKILL_WORKBENCH_ERROR",i=!1,s="",a,l=""){super(t),this.status=n,this.code=r,this.retryable=i,this.statusText=s,this.originalError=a,this.rawResponse=l,this.name="SkillWorkbenchApiError"}}function Dc(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}格式错误。`);return e}function MW(e,t){if(e!=null){if(typeof e!="string"||!e.trim()||e.trim().length>256)throw new Error(`${t}格式错误。`);return e.trim()}}function pct(e){if(e!=null){if(e==="pending"||e==="ready"||e==="failed"||e==="unknown")return e;throw new Error("Skill 恢复点状态格式错误。")}}async function yd(e,t={},n=_o){return fetch(xo(`${hct}${e}`),{...t,headers:fh(t.headers),signal:nl(t.signal,n)})}async function NB(e,t){var r;const n=await e.text().catch(()=>"");try{const i=Dc(JSON.parse(n),"错误响应"),s=i.detail&&typeof i.detail=="object"?Dc(i.detail,"错误详情"):i;return new xL(typeof s.message=="string"?s.message:t,e.status,typeof s.code=="string"?s.code:"SKILL_WORKBENCH_ERROR",s.retryable===!0,e.statusText,s.originalError&&typeof s.originalError=="object"?s.originalError:void 0,n)}catch{const i=((r=e.headers.get("content-type"))==null?void 0:r.split(";",1)[0])||"Content-Type 缺失";return new xL(`${t}(HTTP ${e.status},Content-Type: ${i})。请检查代理或网关配置。`,e.status,"SKILL_WORKBENCH_ERROR",!1,e.statusText,void 0,n)}}async function Yp(e,t){if(!e.ok)throw await NB(e,t);const n=e.headers.get("content-type")??"";if(!n.includes("application/json")){const r=n.split(";",1)[0]||"Content-Type 缺失";throw new Error(`${t}:服务端返回非 JSON 响应(HTTP ${e.status},Content-Type: ${r}),请检查代理或网关配置。`)}return e.json()}function mct(e){return Array.isArray(e)?e.map(t=>{const n=Dc(t,"Skill 会话活动"),r=n.kind,i=n.status;if(typeof n.id!="string"||!["status","thinking","message","tool"].includes(String(r))||!["running","done"].includes(String(i)))throw new Error("Skill 会话活动格式错误。");if(r==="tool"){if(typeof n.name!="string")throw new Error("Skill 工具活动格式错误。");return{id:n.id,kind:r,status:i,name:n.name,...n.input!==void 0?{args:n.input}:{},...n.output!==void 0?{response:n.output}:{}}}if(typeof n.text!="string")throw new Error("Skill 文本活动格式错误。");return{id:n.id,kind:r,status:i,text:n.text}}):[]}function gct(e){if(e==null)return;const t=Dc(e,"Skill 发布结果");if(typeof t.revision!="number"||typeof t.skillId!="string"||typeof t.version!="string"||!Array.isArray(t.skillSpaceIds)||!t.skillSpaceIds.every(n=>typeof n=="string")||t.disposition!=="create-new"&&t.disposition!=="update-source"||!HS(t.region)||typeof t.projectName!="string")throw new Error("Skill 发布结果格式错误。");return{revision:t.revision,skillId:t.skillId,version:t.version,skillSpaceIds:t.skillSpaceIds,disposition:t.disposition,region:t.region,projectName:t.projectName}}function Ww(e){const t=Dc(e,"Skill 会话");if(typeof t.jobId!="string"||t.operation!=="create"&&t.operation!=="optimize"||typeof t.intent!="string"||typeof t.revision!="number"||typeof t.state!="string")throw new Error("Skill 会话格式错误。");const n=Array.isArray(t.files)?t.files.flatMap(l=>{const c=Dc(l,"Skill 文件");return typeof c.path=="string"&&typeof c.size=="number"?[{path:c.path,size:c.size}]:[]}):[];if(!["running","ready","failed","cancelled","expired","published"].includes(t.state))throw new Error("Skill 会话状态无法识别。");const i=MW(t.toolId,"Tool ID"),s=MW(t.sessionId,"Session ID"),a=pct(t.recoveryStatus);return{jobId:t.jobId,operation:t.operation,intent:t.intent,...typeof t.model=="string"?{model:t.model}:{},...typeof t.style=="string"?{style:t.style}:{},...typeof t.requestedName=="string"?{requestedName:t.requestedName}:{},revision:t.revision,...i?{toolId:i}:{},...s?{sessionId:s}:{},...typeof t.sessionTtlSeconds=="number"?{sessionTtlSeconds:t.sessionTtlSeconds}:{},...typeof t.expiresAt=="string"?{expiresAt:t.expiresAt}:{},...typeof t.recoveryAvailable=="boolean"?{recoveryAvailable:t.recoveryAvailable}:{},...a?{recoveryStatus:a}:{},...typeof t.recoveredFromSnapshot=="boolean"?{recoveredFromSnapshot:t.recoveredFromSnapshot}:{},state:t.state,stage:typeof t.stage=="string"?t.stage:"generating",activities:mct(t.activities),files:n,...t.source&&typeof t.source=="object"?{source:t.source}:{},...typeof t.name=="string"?{name:t.name}:{},...typeof t.description=="string"?{description:t.description}:{},...typeof t.skillMd=="string"?{skillMd:t.skillMd}:{},...typeof t.error=="string"?{error:t.error}:{},...t.validation&&typeof t.validation=="object"?{validation:t.validation}:{},...t.publication?{publication:gct(t.publication)}:{}}}async function Mj(e){const t=Dc(await Yp(await yd("/capabilities",{signal:e}),"读取 Skill 工作台能力失败"),"Skill 工作台能力");return{enabled:t.enabled===!0,reason:typeof t.reason=="string"?t.reason:"",operations:Array.isArray(t.operations)?t.operations.filter(n=>n==="create"||n==="optimize"):[],models:Array.isArray(t.models)?t.models.flatMap(n=>{if(!n||typeof n!="object")return[];const r=n;return typeof r.id=="string"&&typeof r.label=="string"?[{id:r.id,label:r.label}]:[]}):[],styles:t.styles&&typeof t.styles=="object"&&!Array.isArray(t.styles)?Object.fromEntries(Object.entries(t.styles).filter(n=>typeof n[1]=="string")):{},...typeof t.maxUploadBytes=="number"?{maxUploadBytes:t.maxUploadBytes}:{}}}async function bct(e){if(e.file){const n=new URLSearchParams({operation:"optimize",intent:e.intent});e.jobId&&n.set("job_id",e.jobId),e.model&&n.set("model",e.model),e.style&&n.set("style",e.style),e.name&&n.set("name",e.name);const r=await yd(`/tasks/from-upload?${n}`,{method:"POST",body:e.file,headers:{"Content-Type":"application/zip"},signal:e.signal},Zi);return Ww(await Yp(r,"开始优化 Skill 失败"))}const t=await yd("/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation:e.operation,intent:e.intent,...e.model?{model:e.model}:{},...e.style?{style:e.style}:{},...e.name?{name:e.name}:{},...e.jobId?{jobId:e.jobId}:{},...e.source?{source:{kind:"skill-center",skillId:e.source.skillId,skillName:e.source.name,version:e.source.version,region:e.source.region,projectName:e.source.projectName,skillSpaceId:e.source.skillSpaceId,skillSpaceName:e.source.skillSpaceName}}:{}}),signal:e.signal},Zi);return Ww(await Yp(t,"开始 Skill 会话失败"))}async function yct(e,t){return Ww(await Yp(await yd(`/tasks/${encodeURIComponent(e)}`,{signal:t}),"读取 Skill 会话失败"))}async function xD(e,t,n){const r=new URLSearchParams;r.set("expected_revision",String(t));const i=Dc(await Yp(await yd(`/tasks/${encodeURIComponent(e)}/artifact?${r.toString()}`,{signal:n}),"读取 Skill 产物失败"),"Skill 产物");if(i.jobId!==e||i.revision!==t||!Number.isSafeInteger(i.revision)||i.revision<1||typeof i.sha256!="string"||!/^[0-9a-f]{64}$/.test(i.sha256)||typeof i.name!="string"||typeof i.description!="string"||!Array.isArray(i.files))throw new Error("Skill 产物格式错误。");const s=i.files.map(a=>{const l=Dc(a,"Skill 产物文件");if(typeof l.path!="string"||typeof l.size!="number"||typeof l.content!="string")throw new Error("Skill 产物文件格式错误。");return{path:l.path,size:l.size,content:l.content}});return{jobId:i.jobId,revision:i.revision,sha256:i.sha256,name:i.name,description:i.description,files:s}}async function vD(e){const t=await yd(`/tasks/${encodeURIComponent(e.jobId)}/refinements`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({intent:e.intent,expectedRevision:e.expectedRevision})},Zi);return Ww(await Yp(t,"继续调整 Skill 失败"))}async function Oct(e){const t=await yd(`/tasks/${encodeURIComponent(e.jobId)}/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedRevision:e.expectedRevision})});return Ww(await Yp(t,"停止当前 Skill 任务失败"))}async function xct(e){const t=await yd(`/tasks/${encodeURIComponent(e.jobId)}/publish-stream`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},body:JSON.stringify({disposition:e.disposition,expectedRevision:e.expectedRevision,expectedArtifactSha256:e.expectedArtifactSha256,skillSpaceIds:e.skillSpaceIds??[],projectName:e.projectName,region:e.region}),signal:e.signal},0);if(!t.ok)throw await NB(t,"发布 Skill 失败");if(!(t.headers.get("content-type")??"").includes("application/x-ndjson"))throw new Error("发布 Skill 失败:服务端返回了非 NDJSON 响应。");if(!t.body)throw new Error("发布 Skill 失败:服务端没有返回进度流。");const r=new Set(["preparing","uploading","registering","activating","publishing"]);let i=null,s="";const a=new TextDecoder,l=t.body.getReader(),c=u=>{var h;if(!u.trim())return;const d=Dc(JSON.parse(u),"发布进度");if(d.type==="progress"){if(typeof d.phase!="string"||!r.has(d.phase)||typeof d.message!="string")throw new Error("发布进度格式错误。");(h=e.onProgress)==null||h.call(e,{phase:d.phase,message:d.message});return}if(d.type==="error"){const m=Dc(d.error,"发布错误");throw new xL(typeof m.message=="string"?m.message:"发布 Skill 失败",500,typeof m.code=="string"?m.code:"SKILL_PUBLISH_FAILED",m.retryable===!0,"",m.originalError&&typeof m.originalError=="object"?m.originalError:void 0,JSON.stringify(d.error))}if(d.type!=="complete")throw new Error("未知的发布进度事件。");const f=Dc(d.result,"发布结果");if(typeof f.skillId!="string"||typeof f.version!="string"||!Array.isArray(f.skillSpaceIds)||!f.skillSpaceIds.every(m=>typeof m=="string")||f.disposition!=="create-new"&&f.disposition!=="update-source"||!HS(f.region)||typeof f.projectName!="string")throw new Error("发布结果格式错误。");i={skillId:f.skillId,version:f.version,skillSpaceIds:f.skillSpaceIds,disposition:f.disposition,region:f.region,projectName:f.projectName}};for(;;){const{value:u,done:d}=await l.read();s+=a.decode(u,{stream:!d});const f=s.split(` +`);if(s=f.pop()??"",f.forEach(c),d)break}if(c(s),!i)throw new Error("发布进度流提前结束,无法确认发布结果。请刷新技能中心确认状态。");return i}async function vct(e){await Yp(await yd(`/tasks/${encodeURIComponent(e)}`,{method:"DELETE"}),"删除 Skill 会话失败")}async function wct(e,t,n){var c;const r=new URLSearchParams;r.set("expected_revision",String(t)),r.set("expected_sha256",n);const i=await yd(`/tasks/${encodeURIComponent(e)}/download?${r.toString()}`,{},Zi);if(!i.ok)throw await NB(i,"下载 Skill 失败");const a=((c=(i.headers.get("content-disposition")??"").match(/filename="([^"]+)"/))==null?void 0:c[1])??"skill.zip",l=URL.createObjectURL(await i.blob());try{const u=document.createElement("a");u.href=l,u.download=a,u.click()}finally{URL.revokeObjectURL(l)}}const Sct={formatDate(e){const t=e.value??e.date??e.timestamp;if(t==null)return"";const n=new Date(t);return isNaN(n.getTime())?String(t):n.toLocaleString()}};function Ect(e,t){if(!t||t==="/")return e;const n=t.replace(/^\//,"").split("/").map(i=>i.replace(/~1/g,"/").replace(/~0/g,"~"));let r=e;for(const i of n){if(r==null||typeof r!="object")return;r=r[i]}return r}function kct(e){return typeof e=="object"&&e!==null&&typeof e.path=="string"}function _ct(e){return typeof e=="object"&&e!==null&&typeof e.call=="string"}function jB(e,t){if(kct(e))return Ect(t,e.path);if(_ct(e)){const n=Sct[e.call],r={};for(const[i,s]of Object.entries(e.args??{}))r[i]=jB(s,t);return n?n(r):`[unknown fn: ${e.call}]`}return e}function Tct(e,t){const n=jB(e,t);return n==null?"":typeof n=="string"?n:String(n)}const Vge=new Map;function S0(e,t){Vge.set(e,t)}function Cct(e){return Vge.get(e)}function Act(e,t,n){const r=t.replace(/^\//,"").split("/").map(s=>s.replace(/~1/g,"/").replace(/~0/g,"~"));let i=e;for(let s=0;sjB(r,e.dataModel),resolveString:r=>Tct(r,e.dataModel),dispatchAction:t,render:r=>{if(!r)return null;const i=e.components[r];if(!i)return null;const s=Cct(i.component)??Nct;return o.jsx(s,{node:i,ctx:n},r)}};return o.jsx("div",{className:"a2ui-surface","data-a2ui-surface":e.surfaceId,children:n.render(e.rootId)})}function qge(e){const t=p.useRef(null),n=p.useRef(!0),r=28,i=p.useCallback(()=>{const s=t.current;s&&(n.current=s.scrollHeight-s.scrollTop-s.clientHeight{const s=t.current;s&&n.current&&(s.scrollTop=s.scrollHeight)},[e]),{ref:t,onScroll:i}}function Lj({value:e,skillPrefix:t="/",onRemoveSkill:n,onRemoveAgent:r}){return e.skills.length===0&&!e.targetAgent?null:o.jsxs("div",{className:"invocation-chips","aria-label":"本轮调用上下文",children:[e.skills.map(i=>o.jsxs("span",{className:"invocation-chip invocation-chip--skill",title:i.description,children:[o.jsx(xw,{"aria-hidden":!0}),o.jsxs("span",{children:[t,i.name]}),n?o.jsx("button",{type:"button",onClick:()=>n(i.name),"aria-label":`移除技能 ${i.name}`,children:o.jsx(Oa,{})}):null]},i.name)),e.targetAgent?o.jsxs("span",{className:"invocation-chip invocation-chip--agent",title:e.targetAgent.description,children:[o.jsx(Rae,{"aria-hidden":!0}),o.jsx("span",{children:e.targetAgent.name}),r?o.jsx("button",{type:"button",onClick:r,"aria-label":`移除 Agent ${e.targetAgent.name}`,children:o.jsx(Oa,{})}):null]}):null]})}function RB(e=""){return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e==="application/pdf"?"pdf":e==="text/markdown"?"markdown":"text"}function Xge(e){var n,r,i,s;const t=RB(e.mimeType);return t==="pdf"?"PDF":t==="markdown"?"MD":t==="video"?((r=(n=e.mimeType)==null?void 0:n.split("/")[1])==null?void 0:r.toUpperCase())??"VIDEO":t==="image"?((s=(i=e.mimeType)==null?void 0:i.split("/")[1])==null?void 0:s.toUpperCase())??"IMAGE":"TXT"}function Gge(e){return e?e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:""}function Wge(e,t){return e.previewUrl?e.previewUrl:e.data?`data:${e.mimeType??"application/octet-stream"};base64,${e.data}`:e.uri?doe(t,e.uri):""}function Rct({kind:e}){return e==="image"?o.jsx(r9,{}):e==="video"?o.jsx(Pae,{}):e==="pdf"?o.jsx(HRe,{}):o.jsx(t9,{})}function $j({appName:e,items:t,compact:n=!1,onRemove:r}){const[i,s]=p.useState(null);return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`media-grid${n?" media-grid--compact":""}`,children:t.map(a=>{const l=RB(a.mimeType),c=Wge(a,e),u=a.status==="uploading"||a.status==="error"||!c,d=o.jsxs("button",{type:"button",className:"media-card-main",disabled:u,onClick:l==="image"?void 0:()=>s(a),"aria-label":`预览 ${a.name??"附件"}`,children:[l==="image"&&c?o.jsx("img",{className:"media-card-image",src:c,alt:a.name??"图片",loading:"lazy"}):l==="video"&&c?o.jsxs("div",{className:"media-card-video-container",children:[o.jsx("video",{className:"media-card-video",src:c,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}),o.jsx("span",{className:"media-card-video-play",children:o.jsx(rIe,{})})]}):o.jsx("span",{className:"media-card-icon",children:o.jsx(Rct,{kind:l})}),o.jsxs("span",{className:"media-card-copy",children:[o.jsx("span",{className:"media-card-name",children:a.name??"附件"}),o.jsxs("span",{className:"media-card-meta",children:[o.jsx("span",{className:"media-card-type",children:Xge(a)}),a.status==="uploading"?o.jsxs(o.Fragment,{children:[o.jsx(lr,{className:"media-card-spinner"})," 上传中"]}):a.status==="error"?a.error??"上传失败":Gge(a.sizeBytes)]})]}),!n&&a.status!=="uploading"&&a.status!=="error"?o.jsx(uy,{className:"media-card-open"}):null]});return o.jsxs(oi.div,{className:`media-card media-card--${l}${a.status==="error"?" media-card--error":""}`,layout:!0,initial:{opacity:0,scale:.985,y:4},animate:{opacity:1,scale:1,y:0},children:[l==="image"&&!u?o.jsx(Eae,{src:c,children:d}):d,r?o.jsx("button",{type:"button",className:"media-card-remove","aria-label":`移除 ${a.name??"附件"}`,onClick:()=>r(a.id),children:o.jsx(Oa,{})}):null]},a.id)})}),o.jsx(hu,{children:i?o.jsx(Ict,{appName:e,item:i,onClose:()=>s(null)}):null})]})}function Ict({appName:e,item:t,onClose:n}){const r=p.useMemo(()=>Wge(t,e),[e,t]),i=RB(t.mimeType),[s,a]=p.useState(""),[l,c]=p.useState(i==="text"||i==="markdown"),[u,d]=p.useState("");return p.useEffect(()=>{const f=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[n]),p.useEffect(()=>{if(i!=="text"&&i!=="markdown")return;const f=new AbortController;return c(!0),d(""),fetch(r,{signal:f.signal}).then(h=>{if(!h.ok)throw new Error(`HTTP ${h.status}`);return h.text()}).then(a).catch(h=>{f.signal.aborted||d(h instanceof Error?h.message:String(h))}).finally(()=>{f.signal.aborted||c(!1)}),()=>f.abort()},[i,r]),o.jsx(oi.div,{className:"media-viewer-backdrop",role:"dialog","aria-modal":"true","aria-label":t.name??"附件预览",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onMouseDown:f=>{f.target===f.currentTarget&&n()},children:o.jsxs(oi.div,{className:"media-viewer",initial:{opacity:0,y:18,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.99},transition:{type:"spring",stiffness:420,damping:30},children:[o.jsxs("header",{className:"media-viewer-header",children:[o.jsxs("div",{children:[o.jsx("strong",{children:t.name??"附件"}),o.jsxs("span",{children:[Xge(t),t.sizeBytes?` · ${Gge(t.sizeBytes)}`:""]})]}),o.jsxs("nav",{children:[o.jsx("a",{href:r,download:t.name,"aria-label":"下载",children:o.jsx(NN,{})}),o.jsx("button",{type:"button",onClick:n,"aria-label":"关闭",children:o.jsx(Oa,{})})]})]}),o.jsxs("div",{className:`media-viewer-body media-viewer-body--${i}`,children:[i==="image"?o.jsx("img",{src:r,alt:t.name??"图片"}):null,i==="video"?o.jsx("div",{className:"media-viewer-video-wrapper",children:o.jsx("video",{src:r,controls:!0,autoPlay:!0,playsInline:!0,preload:"auto",className:"media-viewer-video"})}):null,i==="pdf"?o.jsx("iframe",{src:r,title:t.name??"PDF"}):null,l?o.jsxs("div",{className:"media-viewer-loading",children:[o.jsx(lr,{})," 正在读取文档…"]}):null,!l&&u?o.jsxs("div",{className:"media-viewer-loading",children:["文档加载失败:",u]}):null,!l&&i==="markdown"?o.jsx("div",{className:"media-document",children:o.jsx(xu,{text:s})}):null,!l&&i==="text"?o.jsx("pre",{className:"media-document media-document--plain",children:s}):null]})]})})}function Dct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"10.25",cy:"10.25",r:"6.25"}),o.jsx("path",{d:"M4.15 10.25h12.2M10.25 4c1.65 1.72 2.5 3.8 2.5 6.25s-.85 4.53-2.5 6.25M10.25 4c-1.65 1.72-2.5 3.8-2.5 6.25s.85 4.53 2.5 6.25M14.8 14.8 20 20"})]})}function Pct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"3.25",y:"5.25",width:"15.5",height:"13.5",rx:"2.25"}),o.jsx("circle",{cx:"8.1",cy:"9.3",r:"1.35"}),o.jsx("path",{d:"m4.7 16.5 3.65-3.7 2.45 2.25 2.2-2.2 4.35 4.1"}),o.jsx("path",{d:"m19.4 2.75.48 1.37 1.37.48-1.37.48-.48 1.37-.48-1.37-1.37-.48 1.37-.48.48-1.37Z",fill:"currentColor",stroke:"none"})]})}function IB(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{className:"video-generate-icon__body",d:"M3.25 9h17.5v7.35a2.4 2.4 0 0 1-2.4 2.4H5.65a2.4 2.4 0 0 1-2.4-2.4V9Z"}),o.jsxs("g",{className:"video-generate-icon__clapper",children:[o.jsx("path",{d:"M3.25 9V7.65a2.4 2.4 0 0 1 2.4-2.4h12.7a2.4 2.4 0 0 1 2.4 2.4V9H3.25Z"}),o.jsx("path",{d:"M6.75 5.25 9.3 9M12 5.25 14.55 9M17.25 5.25 19.8 9"})]}),o.jsx("path",{d:"m10.25 11.45 4 2.55-4 2.55v-5.1Z"})]})}function Mct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M4.25 5.25h15.5v10.5H4.25zM8.25 19.75h7.5M12 15.75v4"}),o.jsx("path",{d:"m7.25 12.75 2.35-2.4 2.15 1.65 3.4-3.6 1.6 1.55"}),o.jsx("circle",{cx:"7.25",cy:"8.4",r:".7",fill:"currentColor",stroke:"none"})]})}function Lct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M5 7.4c0-1.55 3.13-2.8 7-2.8s7 1.25 7 2.8-3.13 2.8-7 2.8-7-1.25-7-2.8Z"}),o.jsx("path",{d:"M5 7.4v4.55c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8V7.4M5 11.95v4.55c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8v-4.55"}),o.jsx("path",{d:"M8.2 12.25h.01M8.2 16.8h.01"})]})}function $ct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M4.25 4.25h4.5v15.5h-4.5zM8.75 5.75h5v14h-5zM13.75 4.25h4.1v10.25h-4.1z"}),o.jsx("path",{d:"M5.75 7h1.5M10.25 8.25h2M10.25 11h2M15.15 7h1.3"}),o.jsx("circle",{cx:"17.45",cy:"17.35",r:"2.45"}),o.jsx("path",{d:"m19.25 19.15 1.55 1.55"})]})}function Bct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M4.25 6.25h6.25c1 0 1.5.55 1.5 1.45v11.05c0-.9-.5-1.45-1.5-1.45H4.25V6.25Z"}),o.jsx("path",{d:"M19.75 9.1v8.2H13.5c-1 0-1.5.55-1.5 1.45V7.7c0-.9.5-1.45 1.5-1.45h2.15"}),o.jsx("path",{d:"m19 3.2.58 1.62 1.62.58-1.62.58L19 7.6l-.58-1.62-1.62-.58 1.62-.58L19 3.2Z",fill:"currentColor",stroke:"none"})]})}function Qct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"m4.2 8.4 1.15 10.2h13.3L19.8 8.4"}),o.jsx("path",{d:"M4.2 8.4h15.6L17.9 5H6.1L4.2 8.4Z"}),o.jsx("path",{d:"M7.2 12.2c1.1-1 2.25 1.25 3.4.25 1.05-.9 2.15 1.3 3.3.25"}),o.jsx("path",{d:"m8.2 15.1 1.45 1.35 1.45-1.35M13.55 16.45h2.35"})]})}function Uct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"6",cy:"6.25",r:"2.25"}),o.jsx("circle",{cx:"18",cy:"6.25",r:"2.25"}),o.jsx("circle",{cx:"12",cy:"17.75",r:"2.25"}),o.jsx("path",{d:"m7.7 7.75 2.7 7.55M16.3 7.75l-2.7 7.55M8.25 6.25h7.5"})]})}function LW(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"9",cy:"8",r:"3"}),o.jsx("path",{d:"M3.75 18.75c.45-3.05 2.2-4.65 5.25-4.65s4.8 1.6 5.25 4.65"}),o.jsx("path",{d:"M17.75 4.25v5.5M15 7h5.5M16 13.25h4.25M18.125 11.125v4.25"})]})}function Fct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"4",y:"4.25",width:"16",height:"5",rx:"1.5"}),o.jsx("rect",{x:"4",y:"14.75",width:"16",height:"5",rx:"1.5"}),o.jsx("path",{d:"M7.25 6.75h.01M7.25 17.25h.01M10 6.75h6.5M10 17.25h6.5"})]})}function zct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M6 3.75h8l4 4v12.5H6V3.75Z"}),o.jsx("path",{d:"M14 3.75v4h4M8.75 11h6.5M8.75 14.25h6.5M8.75 17.5h4"})]})}function Vct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"3.75",y:"4.5",width:"16.5",height:"15",rx:"2.5"}),o.jsx("path",{d:"m7.5 9 2.75 2.5L7.5 14M12.5 14h4"}),o.jsx("path",{d:"M3.75 7.5h16.5",opacity:".62"})]})}function DB(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m6 3.25 4.5 4.75L6 12.75"})})}function Hct({definition:e,label:t,done:n,open:r,onToggle:i}){const s=e.icon,a=t??(n?e.doneLabel:e.runningLabel);return o.jsxs("button",{type:"button",className:`builtin-tool-head${n?" is-done":" is-running"}`,"data-tool-tone":e.tone,onClick:i,"aria-expanded":r,children:[o.jsx("span",{className:"builtin-tool-icon","aria-hidden":"true",children:o.jsx(s,{})}),n?o.jsx("span",{className:"builtin-tool-label",children:a}):o.jsx(En,{className:"builtin-tool-label",duration:2.4,spread:18,"aria-live":"polite",children:a}),o.jsx(DB,{className:`builtin-tool-chevron${r?" is-open":""}`})]})}function $l(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function yn(e){return typeof e=="string"?e:""}function $W(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function kc(e){return Array.isArray(e)?e:[]}function vL(e){let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch{return{}}const n=$l(t)??{};return $l(n.result)??n}function Bj(e){if(typeof e=="string")try{return Bj(JSON.parse(e))}catch{return e}const t=$l(e);if(!t)return"";const n=$l(t.result);return yn(t.error)||yn(t.message)||yn(n==null?void 0:n.error)||yn(n==null?void 0:n.message)}function qct(e){if(e.kind==="tool")return"tool";if(e.kind==="knowledge_base")return"knowledge_base";const t=$l(e.metadata),n=yn(t==null?void 0:t.source_type).toLowerCase(),r=yn(e.source).toLowerCase();return n==="skillhub"||r.startsWith("skill_hub:")?"skill_hub":"skill_space"}function Xct(e){return e==="veadk_builtin_tools"?"工具":e==="agentkit_knowledge"?"AgentKit 知识库":e.startsWith("skill_hub:")?`Skill Hub ${e.slice(10)}`:e.startsWith("skill_space:")?`AgentKit 技能中心 ${e.slice(12)}`:e||"未知来源"}function Gct(e){return e==="veadk_builtin_tools"?"tool":e==="agentkit_knowledge"?"knowledge_base":e.startsWith("skill_hub:")?"skill_hub":"skill_space"}function Wct(e){const t=vL(e),n=$l(t.capabilities)??{},r=kc(t.resources).flatMap(s=>{const a=$l(s);if(!a)return[];const l=a.kind==="tool"?"tool":a.kind==="knowledge_base"?"knowledge_base":"skill";return[{ref:yn(a.ref),kind:l,category:qct(a),name:yn(a.name)||yn(a.ref)||"未命名资源",description:yn(a.description),source:yn(a.source),version:yn(a.version)}]}),i=kc(t.sources).flatMap(s=>{const a=$l(s);if(!a)return[];const l=yn(a.source),c=yn(a.status),u=c==="error"?"error":c==="skipped"?"skipped":"ok";return[{source:l,category:Gct(l),label:Xct(l),status:u,count:$W(a.count),message:yn(a.message),searchKeywords:kc(a.search_keywords).map(yn).filter(Boolean)}]});return{collectionId:yn(t.collection_id),capabilities:{googleAdkVersion:yn(n.google_adk_version),agentTypes:kc(n.agent_types).map(yn).filter(Boolean),maxOrchestrationDepth:$W(n.max_orchestration_depth)},resources:r,sources:i,counts:{all:r.length,skill_hub:r.filter(s=>s.category==="skill_hub").length,skill_space:r.filter(s=>s.category==="skill_space").length,knowledge_base:r.filter(s=>s.category==="knowledge_base").length,tool:r.filter(s=>s.category==="tool").length}}}function Yct(e,t){return{resources:e.resources.filter(n=>n.category===t),sources:e.sources.filter(n=>n.category===t)}}function Yge(e,t){const n=vL(e),r=vL(t),i=new Map(kc(r.results).flatMap(u=>{const d=$l(u),f=yn(d==null?void 0:d.name);return d&&f?[[f,d]]:[]})),s=kc(n.agents).flatMap(u=>{const d=$l(u),f=yn(d==null?void 0:d.name);return d&&f?[d]:[]}),a=new Set(s.map(u=>yn(u.name))),l=[...i.entries()].filter(([u])=>!a.has(u)).map(([u])=>({name:u})),c=[...s,...l].map(u=>{const d=yn(u.name),f=kc(u.nodes).flatMap(E=>{const k=$l(E);return k?[k]:[]}),h=yn(u.root_node),m=f.find(E=>yn(E.id)===h),g=f.filter(E=>yn(E.id)!==h).map(E=>({id:yn(E.id)||"未命名 Agent",type:yn(E.type)||"llm",description:yn(E.description)})),b=i.get(d),y=yn(b==null?void 0:b.status),O=y==="failed"?"failed":y==="completed"?"completed":"running",v=BW(b==null?void 0:b.resources),x=v.length>0?v:BW(f.flatMap(E=>kc(E.resources))),w=QW(b==null?void 0:b.python_tools),S=w.length>0?w:QW(f.flatMap(E=>kc(E.python_tools)));return{name:d,description:yn(b==null?void 0:b.description)||yn(m==null?void 0:m.description)||yn(u.task),task:yn(u.task),rootType:yn(b==null?void 0:b.root_type)||yn(m==null?void 0:m.type)||"llm",nodeCount:f.length,subAgentCount:g.length,resourceCount:x.length,pythonToolCount:S.length,skills:x.filter(E=>E.kind==="skill"),knowledgeBases:x.filter(E=>E.kind==="knowledge_base"),builtinTools:x.filter(E=>E.kind==="tool"),pythonTools:S,subAgents:g,status:O,output:yn(b==null?void 0:b.output),error:yn(b==null?void 0:b.error)}});return{collectionId:yn(r.collection_id)||yn(n.collection_id),agents:c,completedCount:c.filter(u=>u.status==="completed").length,failedCount:c.filter(u=>u.status==="failed").length,runningCount:c.filter(u=>u.status==="running").length}}function Zct(e,t){return!!Bj(t)||Yge(e,t).failedCount>0}function BW(e){const t=new Set;return kc(e).flatMap(n=>{const r=$l(n),i=yn(r?r.ref:n);if(!i||t.has(i))return[];t.add(i);const s=yn(r==null?void 0:r.kind),a=s==="tool"||i.startsWith("veadk_tool:")?"tool":s==="knowledge_base"||i.startsWith("agentkit_kb:")?"knowledge_base":"skill",l=i.split(":");return[{ref:i,kind:a,name:yn(r==null?void 0:r.name)||l[l.length-1]||i,description:yn(r==null?void 0:r.description),version:yn(r==null?void 0:r.version),source:yn(r==null?void 0:r.source)}]})}function QW(e){const t=new Set;return kc(e).flatMap(n=>{const r=$l(n),i=yn(r==null?void 0:r.name),s=yn(r==null?void 0:r.code),a=`${i}\0${s}`;return!r||!i||t.has(a)?[]:(t.add(a),[{name:i,description:yn(r.description),code:s,entrypoint:yn(r.entrypoint)||i,dependencies:kc(r.dependencies).map(yn).filter(Boolean)}])})}function Kct({branch:e}){return o.jsxs("div",{className:`branch-compare__body${e.status==="running"?" is-streaming":""}`,"aria-live":"polite",children:[e.content?o.jsx(xu,{text:e.content,streaming:e.status==="running"}):null,e.status==="running"?o.jsx("span",{className:"branch-compare__caret","aria-hidden":"true"}):null,e.error?o.jsx("p",{className:"branch-compare__error",children:e.error}):null]})}function Jct({args:e,response:t,status:n,onBranchSelect:r}){const i=p.useMemo(()=>vle(e,t,n),[e,t,n]),[s,a]=p.useState(0);return o.jsxs("section",{className:"branch-compare","aria-label":"分支对比",children:[o.jsx("div",{className:"branch-compare__tabs",role:"tablist","aria-label":"选择方向",children:i.branches.map((l,c)=>o.jsx("button",{className:`branch-compare__tab${s===c?" is-active":""}`,type:"button",role:"tab","aria-selected":s===c,"aria-controls":`branch-compare-panel-${c}`,onClick:()=>a(c),children:o.jsx(ta,{color:"info",size:"sm",variant:"soft",children:l.label})},`${l.label}:${c}`))}),o.jsx("div",{className:"branch-compare__branches",children:i.branches.map((l,c)=>o.jsxs("article",{className:`branch-compare__branch${s===c?" is-active":""}`,id:`branch-compare-panel-${c}`,role:"tabpanel",children:[o.jsx("header",{className:"branch-compare__head",children:o.jsx(ta,{color:"info",size:"sm",variant:"soft",children:l.label})}),o.jsx(Kct,{branch:l}),o.jsx("footer",{className:"branch-compare__footer",children:o.jsx(Nt,{type:"button",color:"info",variant:"ghost",size:"sm",pill:!1,disabled:l.status!=="completed",onClick:()=>r==null?void 0:r(l),children:"继续这个方向"})})]},`${l.label}:${c}`))})]})}function Zge({controlled:e,default:t,name:n,state:r="value"}){const{current:i}=p.useRef(e!==void 0),[s,a]=p.useState(t),l=i?e:s,c=p.useCallback(u=>{i||a(u)},[]);return[l,c]}const PB={...r0},UW={};function qg(e,t){const n=p.useRef(UW);return n.current===UW&&(n.current=e(t)),n}const wD=PB.useInsertionEffect,eut=wD&&wD!==PB.useLayoutEffect?wD:e=>e();function ja(e){const t=qg(tut).current;return t.next=e,eut(t.effect),t.trampoline}function tut(){const e={next:void 0,callback:nut,trampoline:(...t)=>{var n;return(n=e.callback)==null?void 0:n.call(e,...t)},effect:()=>{e.callback=e.next}};return e}function nut(){}const rut=()=>{},Zo=typeof document<"u"?p.useLayoutEffect:rut,Kge=p.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function iut(){return p.useContext(Kge)}function sut(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,s=ja(i),[,a]=p.useState(!1),l=qg(out).current,c=qg(aut).current,u=p.useRef(0),d=p.useRef(!0),f=p.useRef([]),h=p.useRef(null),m=ja(()=>{d.current||(d.current=!0,a(S=>!S))}),g=ja((S,E)=>{c.set(S,E),m()}),b=ja(S=>{c.delete(S),m()}),y=ja(S=>{const E=new Map;return n.current.length=0,r&&(r.current.length=0),S.forEach(k=>{var _,C;E.set(k.element,{...k.registration.metadata??{},index:k.index}),n.current[k.index]=k.element,r&&(r.current[k.index]=k.registration.label!==void 0?k.registration.label:((C=(_=k.registration.textRef)==null?void 0:_.current)==null?void 0:C.textContent)??k.element.textContent)}),u.current=n.current.length,E});function O(S){var _;if((_=h.current)==null||_.disconnect(),h.current=null,typeof MutationObserver!="function"||S.length<2)return;const E=new MutationObserver(C=>{if(!uut(C))return;let T=null;for(const A of S)if(A.isConnected){if(T&&Jge(T,A)>0){E.disconnect(),m();return}T=A}});h.current=E;const k=new Set;for(let C=1;CE.observe(C,{childList:!0}))}const v=ja(()=>{const[S,E]=lut(c),k=y(S);O(E),f.current=S,d.current=!1,l.forEach(_=>_(k)),s(k)});Zo(()=>(d.current||y(f.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,y]),Zo(()=>{d.current&&v()}),Zo(()=>()=>{var S;(S=h.current)==null||S.disconnect(),d.current=!0},[]);const x=ja(S=>(l.add(S),()=>{l.delete(S)})),w=p.useMemo(()=>({register:g,unregister:b,subscribeMapChange:x,nextIndexRef:u}),[g,b,x,u]);return o.jsx(Kge.Provider,{value:w,children:t})}function aut(){return new Map}function out(){return new Set}function lut(e){const t=new Set,n=[],r=[];e.forEach((s,a)=>{if(!a.isConnected)return;const l=s.index,c={index:l??-1,element:a,registration:s};l===null?r.push(c):l>=0&&(t.add(l),n.push(c))});let i=0;return r.sort((s,a)=>Jge(s.element,a.element)),r.forEach(s=>{for(;t.has(i);)i+=1;s.index=i,n.push(s),i+=1}),t.size>0&&n.sort((s,a)=>s.index-a.index),[n,r.map(s=>s.element)]}function cut(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function uut(e){for(const t of e)for(let n=0;ns.searchParams.append("args[]",a)),`${t} error #${r}; visit ${s} for the full message.`}}const CE=dut("https://base-ui.com/production-error","Base UI"),e0e=p.createContext(void 0);function t0e(){const e=p.useContext(e0e);if(e===void 0)throw new Error(CE(10));return e}function sA(e,t,n,r){const i=qg(n0e).current;return hut(i,e,t,n,r)&&r0e(i,[e,t,n,r]),i.callback}function fut(e){const t=qg(n0e).current;return put(t,e)&&r0e(t,e),t.callback}function n0e(){return{callback:null,cleanup:null,refs:[]}}function hut(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function put(e,t){return e.refs.length!==t.length||e.refs.some((n,r)=>n!==t[r])}function r0e(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const r=Array(t.length).fill(null);for(let i=0;i{for(let i=0;i=e}function FW(e){if(!p.isValidElement(e))return null;const t=e,n=t.props;return(gut(19)?n==null?void 0:n.ref:t.ref)??null}function wL(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}const but=Object.freeze([]),Gb=Object.freeze({});function yut(e,t){const n={};for(const r in e){const i=e[r];if(t!=null&&t.hasOwnProperty(r)){const s=t[r](i);s!=null&&Object.assign(n,s);continue}i===!0?n[`data-${r.toLowerCase()}`]="":i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Out(e,t){return typeof e=="function"?e(t):e}function i0e(e,t){return typeof e=="function"?e(t):e}const MB={};function LB(e,t,n,r,i){if(!n&&!r&&!e)return aA(t);let s=aA(e);return t&&(s=lT(s,t)),n&&(s=lT(s,n)),r&&(s=lT(s,r)),s}function xut(e){if(e.length===0)return MB;if(e.length===1)return aA(e[0]);let t=aA(e[0]);for(let n=1;n=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function $B(e){return typeof e=="function"}function a0e(e,t){return $B(e)?e(t):e??MB}function Sut(e,t){return t?e?(...n)=>{const r=n[0];if(c0e(r)){const s=r;oA(s);const a=t(...n);return s.baseUIHandlerPrevented||e==null||e(...n),a}const i=t(...n);return e==null||e(...n),i}:o0e(t):e}function o0e(e){return e&&((...t)=>{const n=t[0];return c0e(n)&&oA(n),e(...t)})}function oA(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function l0e(e,t){return t?e?t+" "+e:t:e}function c0e(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function AE(e,t,n={}){const r=t.render,i=Eut(t,n);if(n.enabled===!1)return null;const s=n.state??Gb;return Tut(e,r,i,s)}function Eut(e,t={}){const{className:n,style:r,render:i}=e,{state:s=Gb,ref:a,props:l,stateAttributesMapping:c,enabled:u=!0}=t,d=u?Out(n,s):void 0,f=u?i0e(r,s):void 0,h=u?yut(s,c):Gb,m=u&&l?kut(l):void 0,g=u?wL(h,m)??{}:Gb;return typeof document<"u"&&(u?Array.isArray(a)?g.ref=fut([g.ref,FW(i),...a]):g.ref=sA(g.ref,FW(i),a):sA(null,null)),u?(d!==void 0&&(g.className=l0e(g.className,d)),f!==void 0&&(g.style=wL(g.style,f)),g):Gb}function kut(e){return Array.isArray(e)?xut(e):LB(void 0,e)}const _ut=Symbol.for("react.lazy");function Tut(e,t,n,r){if(t){if(typeof t=="function")return t(n,r);const i=LB(n,t.props);i.ref=n.ref;let s=t;return(s==null?void 0:s.$$typeof)===_ut&&(s=p.Children.toArray(t)[0]),p.cloneElement(s,i)}if(e&&typeof e=="string")return Cut(e,n);throw new Error(CE(8))}function Cut(e,t){return e==="button"?p.createElement("button",{type:"button",...t,key:t.key}):e==="img"?p.createElement("img",{alt:"",...t,key:t.key}):p.createElement(e,t)}const Aut={value:()=>null},u0e=p.forwardRef(function(t,n){const{render:r,className:i,disabled:s=!1,hiddenUntilFound:a,keepMounted:l,loopFocus:c,onValueChange:u,multiple:d=!1,orientation:f="vertical",value:h,defaultValue:m,style:g,...b}=t,y=p.useMemo(()=>{if(h===void 0)return m??[]},[h,m]),O=p.useRef([]),[v,x]=Zge({controlled:h,default:y,name:"Accordion",state:"value"}),w=ja((_,C,T)=>{if(d)if(C){const A=v.slice();if(A.push(_),u==null||u(A,T),T.isCanceled)return;x(A)}else{const A=v.filter(j=>j!==_);if(u==null||u(A,T),T.isCanceled)return;x(A)}else{const A=v[0]===_?[]:[_];if(u==null||u(A,T),T.isCanceled)return;x(A)}}),S=p.useMemo(()=>({value:v,disabled:s,orientation:f}),[v,s,f]),E=p.useMemo(()=>({disabled:s,handleValueChange:w,hiddenUntilFound:a??!1,keepMounted:l??!1,state:S,value:v}),[s,w,a,l,S,v]),k=AE("div",t,{state:S,ref:n,props:b,stateAttributesMapping:Aut});return o.jsx(e0e.Provider,{value:E,children:o.jsx(sut,{elementsRef:O,children:k})})});let zW=0;function Nut(e,t="mui"){const[n,r]=p.useState(e),i=e||n;return p.useEffect(()=>{n==null&&(zW+=1,r(`${t}-${zW}`))},[n,t]),i}const VW=PB.useId;function jut(e,t){if(VW!==void 0){const n=VW();return`${t}-${n}`}return Nut(e,t)}function SL(e){return jut(e,"base-ui")}const Rut="none",Iut="trigger-press";function d0e(e,t,n,r){let i=!1,s=!1;const a=Gb;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){s=!0},get isCanceled(){return i},get isPropagationAllowed(){return s},trigger:n,...a}}function Dut(e){p.useEffect(e,but)}const T2=null;let Put=class{constructor(){kr(this,"callbacks",[]);kr(this,"callbacksCount",0);kr(this,"nextId",1);kr(this,"startId",1);kr(this,"isScheduled",!1);kr(this,"tick",t=>{var i;this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let s=0;s=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}},C2=new Put;class kl{constructor(){kr(this,"currentId",T2);kr(this,"cancel",()=>{this.currentId!==T2&&(C2.cancel(this.currentId),this.currentId=T2)});kr(this,"disposeEffect",()=>this.cancel)}static create(){return new kl}static request(t){return C2.request(t)}static cancel(t){return C2.cancel(t)}request(t){this.cancel(),this.currentId=C2.request(()=>{this.currentId=T2,t()})}}function Mut(){const e=qg(kl.create).current;return Dut(e.disposeEffect),e}function Lut(e,t=!1,n=!1){const[r,i]=p.useState(e&&t?"idle":void 0),[s,a]=p.useState(e);return e&&!s&&(a(!0),i("starting")),!e&&s&&r!=="ending"&&!n&&i("ending"),!e&&!s&&r==="ending"&&i(void 0),Zo(()=>{if(!e&&s&&r!=="ending"&&n){const l=kl.request(()=>{i("ending")});return()=>{kl.cancel(l)}}},[e,s,r,n]),Zo(()=>{if(!e||t)return;const l=kl.request(()=>{i(void 0)});return()=>{kl.cancel(l)}},[t,e]),Zo(()=>{if(!e||!t)return;e&&s&&r!=="idle"&&i("starting");const l=kl.request(()=>{i("idle")});return()=>{kl.cancel(l)}},[t,e,s,r]),{mounted:s,setMounted:a,transitionStatus:r}}function $ut(e){const{open:t,defaultOpen:n,onOpenChange:r,disabled:i}=e,[s,a]=Zge({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:l,setMounted:c,transitionStatus:u}=Lut(s,!0,!0),d=SL(),[f,h]=p.useState(),m=f===null?void 0:f??d,g=ja(b=>{const y=!s,O=d0e(Iut,b.nativeEvent);r(y,O),!O.isCanceled&&a(y)});return p.useMemo(()=>({defaultPanelId:d,disabled:i,handleTrigger:g,mounted:l,open:s,panelId:m,setMounted:c,setOpen:a,setPanelIdState:h,transitionStatus:u}),[d,i,g,l,s,m,c,a,h,u])}const f0e=p.createContext(void 0);function h0e(){const e=p.useContext(f0e);if(e===void 0)throw new Error(CE(15));return e}function But(e={}){const{guess:t,label:n,metadata:r,textRef:i,index:s}=e,{register:a,unregister:l,subscribeMapChange:c,nextIndexRef:u}=iut(),d=p.useRef(-1),[f,h]=p.useState(s==null&&t?()=>{if(d.current===-1){const y=u.current;u.current+=1,d.current=y}return d.current}:-1),m=s??f,g=p.useRef(null),b=p.useCallback(y=>{const O=g.current;O&&l(O),g.current=y,y&&a(y,{metadata:r??null,index:s??null,label:n,textRef:i})},[s,a,l,r,n,i]);return Zo(()=>{if(s==null)return c(y=>{var v;const O=g.current?(v=y.get(g.current))==null?void 0:v.index:null;O!=null&&h(O)})},[s,c]),{ref:b,index:m}}const p0e=p.createContext(void 0);function BB(){const e=p.useContext(p0e);if(e===void 0)throw new Error(CE(9));return e}let HW=function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e}({});const Qut={"data-starting-style":""},Uut={"data-ending-style":""},Fut={transitionStatus(e){return e==="starting"?Qut:e==="ending"?Uut:null}};let QB=function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=HW.startingStyle]="startingStyle",e[e.endingStyle=HW.endingStyle]="endingStyle",e}({}),zut=function(e){return e.panelOpen="data-panel-open",e}({});const Vut={[QB.open]:""},Hut={[QB.closed]:""},qut={open(e){return e?{[zut.panelOpen]:""}:null}},Xut={open(e){return e?Vut:Hut}};let Gut=function(e){return e.index="data-index",e.disabled="data-disabled",e.open="data-open",e}({});const UB={...Xut,index:e=>({[Gut.index]:String(e)}),...Fut,value:()=>null},m0e=p.forwardRef(function(t,n){const{className:r,disabled:i=!1,onOpenChange:s,render:a,value:l,style:c,...u}=t,{ref:d,index:f}=But(),h=sA(n,d),{disabled:m,handleValueChange:g,state:b,value:y}=t0e(),O=SL(),v=l??O,x=i||m,w=y.indexOf(v)!==-1,S=ja((N,D)=>{s==null||s(N,D),!D.isCanceled&&g(v,N,D)}),E=$ut({open:w,onOpenChange:S,disabled:x}),k=p.useMemo(()=>({open:E.open,disabled:E.disabled,transitionStatus:E.transitionStatus}),[E.open,E.disabled,E.transitionStatus]),_=p.useMemo(()=>({...E,onOpenChange:S,state:k}),[E,k,S]),C=p.useMemo(()=>({...b,hidden:!w&&!E.mounted,index:f,disabled:x,open:w}),[E.mounted,x,f,w,b]),T=SL(),[A,j]=p.useState(),L=A===null?void 0:A??T,I=p.useMemo(()=>({defaultTriggerId:T,open:w,state:C,setTriggerId:j,triggerId:L}),[T,w,C,j,L]),M=AE("div",t,{state:C,ref:h,props:u,stateAttributesMapping:UB});return o.jsx(f0e.Provider,{value:_,children:o.jsx(p0e.Provider,{value:I,children:M})})}),g0e=p.forwardRef(function(t,n){const{render:r,className:i,style:s,...a}=t,{state:l}=BB();return AE("h3",t,{state:l,ref:n,props:a,stateAttributesMapping:UB})}),Wut=p.createContext(void 0);function Yut(e=!1){const t=p.useContext(Wut);if(t===void 0&&!e)throw new Error(CE(16));return t}function Zut(e){const{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:s}=e,a=r&&t!==!1,l=r&&t===!1;return{props:p.useMemo(()=>{const u={onKeyDown(d){n&&t&&d.key!=="Tab"&&d.preventDefault()}};return r||(u.tabIndex=i,!s&&n&&(u.tabIndex=t?i:-1)),(s&&(t||a)||!s&&n)&&(u["aria-disabled"]=n),s&&(!t||l)&&(u.disabled=n),u},[r,n,t,a,l,s,i])}}function SD(e,t,{detail:n=0}={}){e.dispatchEvent(new(Ka(e)).PointerEvent("click",{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function Kut(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:s}=e,a=p.useRef(null),l=Yut(!0),c=s??l!==void 0,{props:u}=Zut({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),d=p.useCallback(()=>{const m=a.current;ED(m)&&c&&t&&u.disabled===void 0&&m.disabled&&(m.disabled=!1)},[t,u.disabled,c]);Zo(d,[d]);const f=p.useCallback((m={})=>{const{onClick:g,onMouseDown:b,onKeyUp:y,onKeyDown:O,onPointerDown:v,...x}=m;return LB({onClick(w){if(t){w.preventDefault();return}g==null||g(w)},onMouseDown(w){t||b==null||b(w)},onKeyDown(w){if(t||(oA(w),O==null||O(w),w.baseUIHandlerPrevented))return;const S=w.target===w.currentTarget,E=w.currentTarget,k=ED(E),_=!i&&Jut(E),C=S&&(i?k:!_),T=w.key==="Enter",A=w.key===" ",j=E.getAttribute("role"),L=(j==null?void 0:j.startsWith("menuitem"))||j==="option"||j==="gridcell";if(S&&c&&A){if(w.defaultPrevented&&L)return;w.preventDefault(),(!i||k)&&(w.preventBaseUIHandler(),SD(E,w));return}if(!C||i||!A&&!T){S&&_&&A&&w.preventDefault();return}w.defaultPrevented||(w.preventDefault(),T&&(w.preventBaseUIHandler(),SD(E,w)))},onKeyUp(w){if(!t){if(oA(w),y==null||y(w),w.target===w.currentTarget&&i&&c&&ED(w.currentTarget)&&w.key===" "){w.preventDefault();return}w.baseUIHandlerPrevented||w.target===w.currentTarget&&!i&&!c&&!w.defaultPrevented&&w.key===" "&&(w.preventBaseUIHandler(),SD(w.currentTarget,w))}},onPointerDown(w){if(t){w.preventDefault();return}v==null||v(w)}},i?{type:"button"}:{role:"button"},u,x)},[t,u,c,i]),h=ja(m=>{a.current=m,d()});return{getButtonProps:f,buttonRef:h}}function ED(e){return kd(e)&&e.tagName==="BUTTON"}function Jut(e){return kd(e)&&e.tagName==="A"&&!!e.href}const b0e=p.forwardRef(function(t,n){const{disabled:r,className:i,id:s,render:a,nativeButton:l=!0,style:c,...u}=t,{panelId:d,open:f,handleTrigger:h,disabled:m}=h0e(),g=r||m,{getButtonProps:b,buttonRef:y}=Kut({disabled:g,focusableWhenDisabled:!0,native:l}),{defaultTriggerId:O,state:v,setTriggerId:x}=BB(),w=s||void 0,S=w??O;return Zo(()=>(x(_=>w??(_===null?void 0:_)),()=>{x(_=>_===w?null:_)}),[w,x]),AE("button",t,{state:v,ref:[n,y],props:[{"aria-controls":f?d:void 0,"aria-expanded":f,id:S,onClick:h},u,b],stateAttributesMapping:qut})});function edt(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function tdt(e){const t=qg(ndt,e).current;return t.next=e,Zo(t.effect),t}function ndt(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function rdt(e){return e==null?e:"current"in e?e.current:e}function y0e(e,t=!1){const n=Mut();return ja((r,i=null)=>{n.cancel();const s=rdt(e);if(s==null)return;const a=s,l=()=>{Cr.flushSync(r)};if(typeof a.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){r();return}function c(){Promise.all(a.getAnimations().map(u=>u.finished)).then(()=>{i!=null&&i.aborted||l()},()=>{if(i!=null&&i.aborted)return;if(a.getAnimations().some(d=>d.pending||d.playState!=="finished")){c();return}l()})}if(t){const u="data-starting-style";if(!a.hasAttribute(u)){n.request(c);return}const d=new MutationObserver(()=>{a.hasAttribute(u)||(d.disconnect(),c())});d.observe(a,{attributes:!0,attributeFilter:[u]}),i==null||i.addEventListener("abort",()=>d.disconnect(),{once:!0});return}n.request(c)})}function idt(e){const{enabled:t=!0,open:n,ref:r,onComplete:i}=e,s=ja(i),a=y0e(r,n);p.useEffect(()=>{if(!t)return;const l=new AbortController;return a(s,l.signal),()=>{l.abort()}},[t,n,s,a])}const dx={height:void 0,width:void 0};function sdt(e){const{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:s,onOpenChange:a,open:l,setMounted:c,setOpen:u,transitionStatus:d}=e,f=p.useRef(null),h=p.useRef(null),[m,g]=p.useState(dx),b=p.useRef(dx),y=p.useRef(!1),O=p.useRef(l),v=p.useRef(!1),[x,w]=p.useState(!1),S=p.useRef(null),E=sA(t,f),k=tdt(l),_=y0e(f),C=!l&&!s,T=x?"idle":d,A=l&&(O.current||v.current),j=!l&&s&&h.current==="css-animation"&&m.height===void 0&&m.width===void 0?b.current:m,L=n&&C&&h.current!=="css-animation",I=ja((F,$=!0)=>{$&&(b.current=F),g(F)}),M=ja(()=>{var F;(F=S.current)==null||F.call(S),S.current=null}),N=ja(F=>{M(),S.current=()=>{S.current=null,F()}}),D=ja(()=>{l&&s&&h.current==="css-animation"&&(v.current=!0)});Zo(()=>{!x||d==="starting"||w(!1)},[x,d]),p.useEffect(()=>()=>{D(),M()},[D,M]),Zo(()=>{const F=f.current;if(!F)return;!l&&S.current&&M();const $=adt(F,A);if(h.current=$,l&&d==="idle"&&O.current&&$==="css-animation"){b.current=J0(F);return}if(l&&d==="starting"){const B=y.current;if(y.current=!1,$==="none"){I(J0(F)),w(!0);return}if($==="css-transition"){const ce=odt(F);if(I(J0(F)),!B)return ce;const be=A2(F,"transition-duration","0s");return N(be),w(!0),ce}I(J0(F));const V=A2(F,"animation-name","none");if(!B){V();return}const Z=A2(F,"animation-duration","0s");V(),N(Z),w(!0);return}if(!l&&s&&(d==="idle"||d==="starting")){if(O.current=!1,v.current=!1,$==="none"){I(dx,!1),c(!1);return}I(J0(F));return}if(d!=="ending")return;if($==="none"){c(!1);return}const H=J0(F);if(!(H.height>0||H.width>0)){c(!1);return}I(H),$==="css-animation"&&A2(F,"animation-name","none")()},[s,l,M,I,c,N,A,d]),idt({enabled:l&&s&&T==="idle",open:!0,ref:f,onComplete(){l&&I(dx,!1)}}),p.useEffect(()=>{if(l||!s||T!=="ending"||!f.current)return;const $=new AbortController;let H=-1;function z(){k.current||(c(!1),I(dx,!1))}return H=kl.request(()=>{_(z,$.signal)}),()=>{kl.cancel(H),$.abort()}},[k,s,l,T,_,I,c]),Zo(()=>{const F=f.current;!F||!n||!C||F.setAttribute("hidden","until-found")},[C,n]),p.useEffect(function(){const $=f.current;if(!$)return;function H(z){const B=d0e(Rut,z);a(!0,B),!B.isCanceled&&(y.current=!0,u(!0))}return edt($,"beforematch",H)},[a,u]);const Q=i||n||s||l;return{height:j.height,props:{...L?{[QB.startingStyle]:""}:void 0,hidden:C,id:r},ref:E,shouldPreventOpenAnimation:A,shouldRender:Q,transitionStatus:T,width:j.width}}function J0(e){return{height:e.scrollHeight,width:e.scrollWidth}}function adt(e,t){const n=Ka(e).getComputedStyle(e),r=(n.animationName.split(",").map(s=>s.trim()).some(s=>s!==""&&s!=="none")||t)&&qW(n.animationDuration),i=qW(n.transitionDuration);return r&&i||i?"css-transition":r?"css-animation":"none"}function qW(e){return e.split(",").map(t=>t.trim()).some(t=>t!==""&&Number.parseFloat(t)>0)}function A2(e,t,n){const r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===""){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function odt(e){const t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(i=>{e.style.setProperty(i,"initial","important")});function n(){Object.entries(t).forEach(([i,s])=>{if(s===""){e.style.removeProperty(i);return}e.style.setProperty(i,s)})}const r=kl.request(n);return()=>{kl.cancel(r),n()}}let XW=function(e){return e.accordionPanelHeight="--accordion-panel-height",e.accordionPanelWidth="--accordion-panel-width",e}({});const O0e=p.forwardRef(function(t,n){const{className:r,hiddenUntilFound:i,keepMounted:s,id:a,render:l,style:c,...u}=t,{hiddenUntilFound:d,keepMounted:f}=t0e(),{defaultPanelId:h,mounted:m,onOpenChange:g,open:b,setMounted:y,setOpen:O,setPanelIdState:v,transitionStatus:x}=h0e(),w=i??d,S=s??f,E=a||void 0,k=a??h;Zo(()=>(v($=>E??($===null?void 0:$)),()=>{v($=>$===E?null:$)}),[E,v]);const{height:_,props:C,ref:T,shouldPreventOpenAnimation:A,shouldRender:j,transitionStatus:L,width:I}=sdt({externalRef:n,hiddenUntilFound:w,id:k,keepMounted:S,mounted:m,onOpenChange:g,open:b,setMounted:y,setOpen:O,transitionStatus:x}),{state:M,triggerId:N}=BB(),D={...M,transitionStatus:L},Q=i0e(c,D),F=AE("div",{...t,style:void 0},{state:D,ref:T,props:[C,{"aria-labelledby":N,role:"region",style:{[XW.accordionPanelHeight]:_===void 0?"auto":`${_}px`,[XW.accordionPanelWidth]:I===void 0?"auto":`${I}px`}},u,Q?{style:Q}:void 0,A?{style:{animationName:"none"}}:void 0],stateAttributesMapping:UB});return j?F:null}),ldt=(e,t)=>{const n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=cdt(r,n.getBoundingClientRect()),s=udt(r,i),a=ddt(t.getBoundingClientRect());return hdt([...s,...a])};function cdt(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function udt(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function ddt(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function fdt(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,a=t.length-1;sr!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(i=!i)}return i}function hdt(e){const t=e.slice();return t.sort((n,r)=>n.xr.x?1:n.yr.y?1:0),pdt(t)}function pdt(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}const mdt="_Transition_1wdpp_1",gdt="_Popover_1wdpp_3",x0e={Transition:mdt,Popover:gdt},v0e=p.createContext(null),Qj=()=>{const e=p.use(v0e);if(!e)throw new Error("Popover components must be wrapped in ");return e},jp=({open:e,onOpenChange:t,showOnHover:n=!1,hoverOpenDelay:r=150,children:i})=>{const[s,a]=p.useState(!1),[l,c]=p.useState(!1),u=p.useRef(null),d=p.useRef(null),f=p.useRef(void 0),h=p.useRef(!1),m=p.useRef(!1),g=e??s,[b,y]=p.useState(!1);k9(()=>y(!1),b?500:null);const O=Xp(t),v=Xp(k=>{var _,C;clearTimeout(f.current),g!==k&&(k||(c(!1),n&&h.current&&((_=u.current)==null||_.focus()),h.current=!1),(C=O.current)==null||C.call(O,k),a(k),n&&y(k))}),x=p.useCallback(k=>{v.current(k)},[v]),w=p.useCallback(()=>{f.current=setTimeout(()=>x(!0),r)},[x,r]),S=p.useCallback(()=>{clearTimeout(f.current)},[]);p.useEffect(()=>()=>{clearTimeout(f.current)},[]);const E=p.useMemo(()=>({open:g,setOpen:x,shake:l,setShake:c,showOnHover:n,temporarilyPreventClickToClose:b,onTriggerEnter:w,onTriggerLeave:S,isPointerInTransitRef:m,triggerRef:u,contentRef:d,hoverOpenFocusedWithTab:h}),[g,x,l,c,n,b,h,m,w,S]);return o.jsx(v0e,{value:E,children:o.jsx(fue,{open:g,onOpenChange:x,modal:!1,children:i})})},bdt=({children:e,onPointerDown:t,onClick:n})=>{const{setOpen:r,showOnHover:i,temporarilyPreventClickToClose:s,onTriggerEnter:a,onTriggerLeave:l,isPointerInTransitRef:c,triggerRef:u,contentRef:d}=Qj(),f=p.useRef(!1),h=b=>{!(b.currentTarget.nodeName.toLocaleLowerCase()==="a")&&s&&(b.preventDefault(),b.stopPropagation())},m=b=>{b.pointerType!=="touch"&&!f.current&&!c.current&&(a(),f.current=!0)},g=()=>{f.current&&(l(),f.current=!1)};return o.jsx(hue,{asChild:!0,ref:u,onPointerDown:b=>{h(b),t==null||t(b)},onClick:b=>{h(b),n==null||n(b)},onPointerMove:i?m:void 0,onPointerLeave:i?g:void 0,onFocus:i?()=>r(!0):void 0,onBlur:i?()=>{setTimeout(()=>{var b;(b=d.current)!=null&&b.contains(document.activeElement)||r(!1)},50)}:void 0,children:e})},w0e=({children:e,avoidCollisions:t,width:n,minWidth:r,maxWidth:i,side:s,sideOffset:a=8,align:l,alignOffset:c,translucent:u,className:d,autoFocus:f=!0})=>{const{showOnHover:h,shake:m,contentRef:g}=Qj(),b=y=>{const O=g.current;if(O&&y.target===O&&y.key==="Tab"&&y.shiftKey){y.preventDefault(),y.stopPropagation();const v=Tle(O),x=v[v.length-1];x==null||x.focus()}};return p.useEffect(()=>{const y=g.current;!y||!f||y!=null&&y.contains(document.activeElement)||h||y.focus({preventScroll:!0})},[g,h,f]),o.jsx(mue,{forceMount:!0,ref:g,className:ur(x0e.Popover,d),style:d0({"popover-width":n,"popover-min-width":r,"popover-max-width":i}),onCloseAutoFocus:h?Df:void 0,"data-animate":m?"shake":void 0,"data-translucent":u?"true":void 0,side:s,sideOffset:a,align:l,alignOffset:c??(l==="center"?0:-5),avoidCollisions:t??!0,hideWhenDetached:!0,collisionPadding:20,onOpenAutoFocus:Df,onEscapeKeyDown:Df,onKeyDown:b,children:e})},ydt=e=>{const{setOpen:t,triggerRef:n,contentRef:r,isPointerInTransitRef:i,hoverOpenFocusedWithTab:s}=Qj(),[a,l]=p.useState(null),c=p.useCallback(()=>{l(null),i.current=!1},[i]),u=p.useCallback((d,f)=>{const h=ldt(d,f);l(h),i.current=!0},[i]);return p.useEffect(()=>()=>c(),[c]),p.useEffect(()=>{const d=n.current,f=r.current;if(!d||!f)return;const h=g=>u(g,f),m=g=>u(g,d);return d.addEventListener("pointerleave",h),f.addEventListener("pointerleave",m),()=>{d.removeEventListener("pointerleave",h),f.removeEventListener("pointerleave",m)}},[r,n,u,c]),p.useEffect(()=>{if(!a)return;const d=f=>{const h=n.current,m=r.current,g=f.target,b={x:f.clientX,y:f.clientY},y=(h==null?void 0:h.contains(g))||(m==null?void 0:m.contains(g)),O=!fdt(b,a),v=g.hasAttribute("aria-haspopup");y?c():(O||v)&&(c(),t(!1))};return document.addEventListener("pointermove",d),()=>document.removeEventListener("pointermove",d)},[a,t,c,n,r]),p.useEffect(()=>{const d=f=>{if(r.current&&f.key==="Tab"&&!f.shiftKey){const[h]=Tle(r.current);h&&(f.preventDefault(),h.focus(),s.current=!0,document.removeEventListener("keydown",d))}};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[r,s]),o.jsx(w0e,{...e})},Odt=e=>{const{open:t,showOnHover:n,setOpen:r}=Qj();return tE(t,()=>{r(!1)}),o.jsx(pue,{forceMount:!0,children:o.jsx(rO,{enterDuration:600,exitDuration:300,className:x0e.Transition,disableAnimations:!0,children:t&&(n?o.jsx(ydt,{...e},"popover-hover"):o.jsx(w0e,{...e},"popover"))})})};jp.Trigger=bdt;jp.Content=Odt;const xdt=[{value:"skill_hub",label:"Skill Hub"},{value:"skill_space",label:"AgentKit 技能中心"},{value:"knowledge_base",label:"知识库"},{value:"tool",label:"工具"}],S0e={llm:"LLM Agent",sequential:"顺序 Agent",parallel:"并行 Agent",loop:"循环 Agent",workflow:"Workflow"};function E0e(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m4 6 4 4 4-4"})})}function k0e({label:e}){return o.jsx("div",{className:"create-agent-card__loading",role:"status","aria-label":e,children:[0,1,2].map(t=>o.jsxs("div",{className:"create-agent-card__skeleton-row","aria-hidden":"true",children:[o.jsx("span",{}),o.jsx("span",{})]},t))})}function vdt(e){return e.kind==="tool"?"内置工具":e.kind==="knowledge_base"?"知识库":e.source.startsWith("skill_hub:")?"Skill Hub":e.source.startsWith("skill_space:")?"AgentKit 技能中心":"Skill"}function kD({label:e,resources:t}){return t.length===0?null:o.jsxs("section",{className:"create-agent-card__popover-section",children:[o.jsx("h4",{children:e}),o.jsx("div",{className:"create-agent-card__popover-list",children:t.map(n=>o.jsxs("div",{className:"create-agent-card__popover-item",children:[o.jsxs("div",{className:"create-agent-card__popover-item-heading",children:[o.jsx("strong",{children:n.name}),o.jsx(ta,{color:"secondary",size:"sm",variant:"soft",children:vdt(n)})]}),n.description?o.jsx("p",{children:n.description}):null]},n.ref))})]})}function wdt({tools:e}){return e.length===0?null:o.jsxs("section",{className:"create-agent-card__popover-section",children:[o.jsx("h4",{children:"自写工具"}),o.jsx(u0e,{children:e.map((t,n)=>o.jsxs(m0e,{className:"create-agent-card__python-tool",value:`${t.name}:${n}`,children:[o.jsx(g0e,{className:"create-agent-card__python-tool-header",children:o.jsxs(b0e,{className:"create-agent-card__python-tool-trigger",children:[o.jsxs("span",{children:[o.jsx("strong",{children:t.name}),t.description?o.jsx("small",{children:t.description}):null]}),o.jsxs("span",{className:"create-agent-card__python-tool-meta",children:[o.jsx(ta,{color:"secondary",size:"sm",variant:"soft",children:"自写工具"}),o.jsx(E0e,{className:"create-agent-card__python-tool-chevron"})]})]})}),o.jsxs(O0e,{className:"create-agent-card__python-tool-panel",children:[t.dependencies.length>0?o.jsxs("div",{className:"create-agent-card__python-tool-dependencies",children:["依赖:",t.dependencies.join(", ")]}):null,o.jsx("pre",{tabIndex:0,"aria-label":`${t.name} 完整代码`,children:o.jsx("code",{children:t.code})})]})]},`${t.name}:${n}`))})]})}function Sdt({agents:e}){return e.length===0?null:o.jsxs("section",{className:"create-agent-card__popover-section",children:[o.jsx("h4",{children:"Sub Agent"}),o.jsx("div",{className:"create-agent-card__popover-list",children:e.map(t=>o.jsxs("div",{className:"create-agent-card__popover-item",children:[o.jsxs("div",{className:"create-agent-card__popover-item-heading",children:[o.jsx("strong",{children:t.id}),o.jsx(ta,{color:"secondary",size:"sm",variant:"soft",children:S0e[t.type]??t.type})]}),t.description?o.jsx("p",{children:t.description}):null]},t.id))})]})}function N2({label:e,count:t,icon:n,children:r}){const i=o.jsxs("button",{className:"create-agent-card__resource-metric",type:"button",disabled:t===0,"aria-label":`${e} ${t} 项`,children:[n,o.jsx("span",{children:t})]});return t===0?i:o.jsxs(jp,{showOnHover:!0,hoverOpenDelay:120,children:[o.jsx(jp.Trigger,{children:i}),o.jsx(jp.Content,{side:"top",align:"start",minWidth:"auto",maxWidth:360,className:"create-agent-card__resource-popover",children:r})]})}function Edt({response:e,status:t}){const n=p.useMemo(()=>Wct(e),[e]),r=p.useMemo(()=>xdt.map(a=>{const l=Yct(n,a.value);return{...a,...l,searchKeywords:[...new Set(l.sources.flatMap(c=>c.searchKeywords))]}}),[n]),i=t==="failed",s=i?Bj(e):"";return o.jsx("section",{className:"create-agent-tool-card","aria-label":"召回资源信息",children:t==="running"?o.jsx(k0e,{label:"正在检索资源"}):i?o.jsxs("div",{className:"create-agent-card__message is-error",role:"alert",children:[o.jsx("span",{className:"create-agent-card__message-title",children:"资源检索未完成"}),o.jsx("span",{children:s||"请检查资源服务配置后重试。"})]}):o.jsx(u0e,{className:"create-agent-card__accordion",children:r.map(a=>o.jsxs(m0e,{className:"create-agent-card__accordion-item",value:a.value,children:[o.jsx(g0e,{className:"create-agent-card__accordion-header",children:o.jsxs(b0e,{className:"create-agent-card__accordion-trigger",children:[o.jsx("span",{children:a.label}),o.jsxs("span",{className:"create-agent-card__accordion-meta",children:[o.jsx(ta,{color:"secondary",size:"sm",variant:"soft",children:a.sources.length===0?a.value==="skill_hub"?"未检索":"未配置":a.resources.length}),o.jsx(E0e,{className:"create-agent-card__accordion-chevron"})]})]})}),o.jsx(O0e,{className:"create-agent-card__accordion-content",children:o.jsxs("div",{className:"create-agent-card__accordion-scroll",role:"region","aria-label":`${a.label}资源列表`,tabIndex:0,children:[a.value==="skill_hub"&&a.searchKeywords.length>0?o.jsxs("div",{className:"create-agent-card__search-keywords",children:[o.jsx("span",{children:"检索关键词"}),o.jsx("span",{children:a.searchKeywords.join("、")})]}):null,a.resources.length>0?o.jsx("div",{className:"create-agent-card__resource-list",children:a.resources.map(l=>o.jsx("div",{className:"create-agent-card__resource",children:o.jsxs("div",{className:"create-agent-card__resource-main",children:[o.jsxs("div",{className:"create-agent-card__resource-title",children:[o.jsx("span",{className:"create-agent-card__resource-name",children:l.name}),l.version?o.jsx(ta,{className:"create-agent-card__resource-version",color:"secondary",size:"sm",variant:"soft",children:l.version}):null]}),l.description?o.jsx("p",{children:l.description}):null]})},l.ref))}):o.jsxs("div",{className:"create-agent-card__empty-category",children:[o.jsx("p",{children:a.sources.length===0?a.value==="skill_hub"?"未提供检索关键词,本次未检索 Skill Hub。":`未配置 ${a.label},本次未检索该来源。`:"本次检索未返回该类别的资源。"}),a.sources.filter(l=>l.message).map(l=>o.jsx("p",{className:"create-agent-card__raw-source-error",children:l.message},l.source))]})]})})]},a.value))},n.collectionId||"collected-resources")})}function kdt({args:e,response:t,status:n}){const r=p.useMemo(()=>Yge(e,t),[e,t]),i=n==="failed"?Bj(t):"";return o.jsxs("section",{className:"create-agent-tool-card is-agent-results","aria-label":"创建 Agent 结果",children:[i?o.jsxs("div",{className:"create-agent-card__message is-error",role:"alert",children:[o.jsx("span",{className:"create-agent-card__message-title",children:"Agent 创建未完成"}),o.jsx("span",{children:i})]}):null,r.agents.length>0?o.jsx("div",{className:"create-agent-card__agent-grid",children:r.agents.map(s=>{const a=n==="failed"?"failed":s.status,l=s.error||a==="failed"&&i,c=s.builtinTools.length+s.pythonTools.length;return o.jsxs(W7,{className:`create-agent-card__agent-card${l?" is-error":""}`,children:[o.jsx(Y7,{leading:o.jsx(d1,{seed:s.name}),title:s.name,titleText:s.name,status:o.jsx(ta,{color:"secondary",size:"sm",variant:"soft",children:S0e[s.rootType]??s.rootType})}),s.description?o.jsx(Z7,{children:s.description}):null,l?o.jsx("div",{className:"create-agent-card__agent-result is-error",role:"alert",children:l}):null,o.jsxs("div",{className:"create-agent-card__agent-resources","aria-label":`${s.name} 具备的资源`,children:[o.jsx(N2,{label:"Skill",count:s.skills.length,icon:o.jsx(L_,{"aria-hidden":"true"}),children:o.jsx(kD,{label:"Skill",resources:s.skills})}),o.jsx(N2,{label:"知识库",count:s.knowledgeBases.length,icon:o.jsx(zue,{"aria-hidden":"true"}),children:o.jsx(kD,{label:"知识库",resources:s.knowledgeBases})}),o.jsxs(N2,{label:"工具",count:c,icon:o.jsx(kRe,{"aria-hidden":"true"}),children:[o.jsx(kD,{label:"内置工具",resources:s.builtinTools}),o.jsx(wdt,{tools:s.pythonTools})]}),o.jsx(N2,{label:"Sub Agent",count:s.subAgentCount,icon:o.jsx(TRe,{"aria-hidden":"true"}),children:o.jsx(Sdt,{agents:s.subAgents})})]})]},s.name)})}):n==="running"?o.jsx(k0e,{label:"正在创建 Agent"}):o.jsxs("div",{className:"create-agent-card__message",children:[o.jsx("span",{className:"create-agent-card__message-title",children:"没有可展示的 Agent"}),o.jsx("span",{children:"工具返回中未包含 Agent 配置或执行结果。"})]})]})}const _dt={web_search:{name:"web_search",runningLabel:"正在进行网络搜索",doneLabel:"已完成网络搜索",tone:"search",icon:Dct},run_code:{name:"run_code",runningLabel:"正在 AgentKit 沙箱中执行代码",doneLabel:"已在 AgentKit 沙箱中完成代码执行",tone:"sandbox",icon:Qct},list_envs:{name:"list_envs",runningLabel:"正在查看可用环境",doneLabel:"已读取可用环境",tone:"resources",icon:Fct},get_env_manifest:{name:"get_env_manifest",runningLabel:"正在读取环境 Manifest",doneLabel:"已读取环境 Manifest",tone:"knowledge",icon:zct},execute_in_sandbox:{name:"execute_in_sandbox",runningLabel:"正在环境中执行命令",doneLabel:"已在环境中完成命令执行",tone:"sandbox",icon:Vct},image_generate:{name:"image_generate",runningLabel:"正在生成图片",doneLabel:"已完成图片生成",tone:"image",icon:Pct},video_generate:{name:"video_generate",runningLabel:"正在生成视频",doneLabel:"已完成视频生成",tone:"video",icon:IB},ppt_generate:{name:"ppt_generate",runningLabel:"正在生成 PPT",doneLabel:"已完成 PPT 生成",tone:"presentation",icon:Mct},load_memory:{name:"load_memory",runningLabel:"正在检索长期记忆",doneLabel:"已完成记忆检索",tone:"memory",icon:Lct},load_knowledgebase:{name:"load_knowledgebase",runningLabel:"正在检索知识库",doneLabel:"已完成知识库检索",tone:"knowledge",icon:$ct},load_skill:{name:"load_skill",runningLabel:"正在加载技能",doneLabel:"已加载技能",tone:"skill",icon:Bct},collect_resources:{name:"collect_resources",runningLabel:"正在收集可用资源",doneLabel:"已完成资源收集",failedLabel:"资源收集失败",tone:"resources",icon:Uct,detailRenderer:Edt},create_agents:{name:"create_agents",runningLabel:"正在创建并运行 Agent",doneLabel:"已完成 Agent 创建",failedLabel:"Agent 创建失败",tone:"agent",icon:LW,detailRenderer:kdt},branch_compare:{name:"branch_compare",runningLabel:"",doneLabel:"",failedLabel:"",tone:"search",icon:LW,detailRenderer:Jct,hideHeader:!0}};function Tdt(e){return _dt[e]}function _0e(e){return o.jsx("svg",{viewBox:"0 0 111 117",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"M0 5.6016C7.82288e-05 0.621244 6.02226 -1.87314 9.54395 1.64847L40.1289 32.2334L68.5732 3.7891C69.5834 2.77903 70.9533 2.21099 72.3818 2.21097H82.7031C82.7917 2.20658 82.8806 2.20414 82.9697 2.20414H104.775C109.574 2.20427 111.977 8.00691 108.584 11.4004L64.916 55.0664C64.3075 55.8528 63.9436 56.7647 63.8242 57.6993C63.7142 56.4884 63.1964 55.3069 62.2695 54.3799L45.4082 37.5186H45.4072L40.124 32.2354L17.832 54.5284C16.7671 55.5933 16.2416 56.993 16.2549 58.3887C16.2417 59.7843 16.7672 61.1842 17.832 62.2491L39.9287 84.3467L9.54395 114.733C6.0223 118.255 0.000223474 115.761 0 110.78V5.6016ZM63.8018 58.8702C63.8962 59.9086 64.2936 60.9229 64.9961 61.7735L108.591 105.368C111.984 108.762 109.58 114.564 104.781 114.564H94.4336C94.3543 114.568 94.274 114.569 94.1934 114.569H72.3877C70.9592 114.569 69.5892 114.002 68.5791 112.992L39.9336 84.3467L58.4531 65.8282L58.4453 65.8203L62.2695 61.9981C63.1476 61.12 63.6567 60.0136 63.8018 58.8702Z",fill:"currentColor"})})}function Cdt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M6 3h8l4 4v14H6Z"}),o.jsx("path",{d:"M14 3v5h5"}),o.jsx("path",{d:"m10 12-2 2 2 2M14 12l2 2-2 2"})]})}function Adt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M12 3 19 6v5c0 4.6-2.8 7.8-7 10-4.2-2.2-7-5.4-7-10V6l7-3Z"}),o.jsx("path",{d:"m9 12 2 2 4-4"})]})}function Ndt(e,t){const n=new Map(e.map(a=>[a.path,a.content])),r=new Map(t.map(a=>[a.path,a.content])),i=new Set([...n.keys(),...r.keys()]),s=[];for(const a of[...i].sort((l,c)=>l.localeCompare(c))){const l=n.get(a),c=r.get(a);l!==c&&s.push({path:a,status:l===void 0?"added":c===void 0?"deleted":"modified",before:l??"",after:c??""})}return s}function jdt(e){return e==="added"?"新增":e==="deleted"?"删除":"修改"}function mm(e){return{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,...e}}function T0e(e){return o.jsx("svg",{...mm(e),children:o.jsx("path",{d:"m9 7-5 5 5 5M15 7l5 5-5 5M13.5 4l-3 16"})})}function _D(e){return o.jsx("svg",{...mm(e),children:o.jsx("path",{d:"M6.5 3.75h7l4 4V20.25h-11zM13.5 3.75v4h4M9 12h6M9 15.5h4.5"})})}function Rdt(e){return o.jsx("svg",{...mm(e),children:o.jsx("path",{d:"M3.75 7.25h6l1.75 2h8.75v9.25H3.75zM3.75 7.25V5.5h5l1.5 1.75"})})}function Idt(e){return o.jsx("svg",{...mm(e),children:o.jsx("path",{d:"m9 5 7 7-7 7"})})}function C0e(e){return o.jsx("svg",{...mm(e),children:o.jsx("path",{d:"m6.5 6.5 11 11M17.5 6.5l-11 11"})})}function Ddt(e){return o.jsxs("svg",{...mm(e),children:[o.jsx("circle",{cx:"12",cy:"12",r:"3.25"}),o.jsx("path",{d:"M12 2.75v2M12 19.25v2M2.75 12h2M19.25 12h2M5.45 5.45l1.4 1.4M17.15 17.15l1.4 1.4M18.55 5.45l-1.4 1.4M6.85 17.15l-1.4 1.4"})]})}function Pdt(e){return o.jsx("svg",{...mm(e),children:o.jsx("path",{d:"M19.25 15.25A8 8 0 0 1 8.75 4.75a8 8 0 1 0 10.5 10.5Z"})})}function Mdt(e){return o.jsxs("svg",{...mm(e),children:[o.jsx("path",{d:"M19.25 8.25V4.5l-1.8 1.8a7.5 7.5 0 1 0 1.8 7.65"}),o.jsx("path",{d:"M19.25 4.5H15.5"})]})}const Ldt=p.lazy(()=>dd(()=>Promise.resolve().then(()=>rve),void 0)),$dt=p.lazy(()=>dd(()=>import("../chunks/CodeDiffEditor-B-C-CiRH.js"),[])),A0e="veadk-code-workspace-theme";function Bdt(e){const t={name:"",children:new Map};for(const n of e){const r=n.path.split("/").filter(Boolean);let i=t;r.forEach((s,a)=>{let l=i.children.get(s);l||(l={name:s,children:new Map},i.children.set(s,l)),a===r.length-1&&(l.path=n.path),i=l})}return t}function Qdt(e,t=!1){return[...e.children.values()].sort((n,r)=>{const i=n.children.size>0&&n.path===void 0,s=r.children.size>0&&r.path===void 0;return i!==s?t?i?1:-1:i?-1:1:n.name.localeCompare(r.name)})}function Udt(){if(typeof window>"u")return"light";try{return window.localStorage.getItem(A0e)==="dark"?"dark":"light"}catch{return"light"}}function Fdt(e){return e===""?0:e.split(` `).length}function Yw({project:e,open:t,onClose:n,onChange:r,readOnly:i=!1,comparison:s}){var j;const a=p.useId(),l=p.useRef(null),c=p.useRef(null),u=p.useRef(n),[d,f]=p.useState(Udt),h=p.useMemo(()=>s?Ndt(s.baseProject.files,e.files):[],[s,e.files]),m=p.useMemo(()=>s?h.map(L=>({path:L.path,content:L.status==="deleted"?L.before:L.after})):e.files,[h,s,e.files]),g=p.useMemo(()=>new Map(h.map(L=>[L.path,L.status])),[h]),[b,y]=p.useState(((j=m[0])==null?void 0:j.path)??null),[O,v]=p.useState(new Set),x=p.useMemo(()=>Bdt(m),[m]),w=m.find(L=>L.path===b)??null,S=h.find(L=>L.path===b)??null;if(u.current=n,p.useEffect(()=>{try{window.localStorage.setItem(A0e,d)}catch{}},[d]),p.useEffect(()=>{var N;if(!t)return;const L=document.body.style.overflow,I=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",(N=c.current)==null||N.focus();const M=D=>{if(D.key==="Escape"){D.preventDefault(),u.current();return}if(D.key!=="Tab"||!l.current)return;const Q=[...l.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')].filter(H=>H.offsetParent!==null);if(Q.length===0)return;const F=Q[0],$=Q[Q.length-1];D.shiftKey&&document.activeElement===F?(D.preventDefault(),$.focus()):!D.shiftKey&&document.activeElement===$&&(D.preventDefault(),F.focus())};return window.addEventListener("keydown",M),()=>{document.body.style.overflow=L,window.removeEventListener("keydown",M),I!=null&&I.isConnected&&I.focus()}},[t]),p.useEffect(()=>{w||m.length===0||y(m[0].path)},[m,w]),!t)return null;function E(L){v(I=>{const M=new Set(I);return M.has(L)?M.delete(L):M.add(L),M})}function k(L){return L?o.jsx("span",{className:`code-browser-change is-${L}`,children:jdt(L)}):null}function _(L,I,M){return Qdt(L,I===0).map(N=>{const D=M?`${M}/${N.name}`:N.name;if(!(N.children.size>0&&N.path===void 0)&&N.path){const $=g.get(N.path);return o.jsxs("button",{type:"button",className:`code-browser-file${b===N.path?" is-active":""}`,style:{paddingLeft:`${12+I*16}px`},onClick:()=>y(N.path??null),title:N.path,"aria-pressed":b===N.path,children:[o.jsx(_D,{}),o.jsx("span",{children:N.name}),k($)]},D)}const F=O.has(D);return o.jsxs("div",{children:[o.jsxs("button",{type:"button",className:"code-browser-folder",style:{paddingLeft:`${10+I*16}px`},onClick:()=>E(D),"aria-expanded":!F,children:[o.jsx(Idt,{className:F?"":"is-open"}),o.jsx(Rdt,{}),o.jsx("span",{children:N.name})]}),!F&&_(N,I+1,D)]},D)})}function C(L){!w||s||r({...e,files:e.files.map(I=>I.path===w.path?{...I,content:L}:I)})}const T=d==="light"?"dark":"light",A=s?"两个版本的源码没有差异":"从左侧选择文件以查看代码";return Cr.createPortal(o.jsx("div",{className:"code-browser-backdrop",onMouseDown:L=>{L.target===L.currentTarget&&n()},children:o.jsxs("section",{ref:l,className:`code-browser-dialog is-${d}`,role:"dialog","aria-modal":"true","aria-labelledby":a,children:[o.jsxs("header",{className:"code-browser-head",children:[o.jsxs("div",{className:"code-browser-title-wrap",children:[o.jsx("span",{className:"code-browser-title-icon",children:o.jsx(T0e,{})}),o.jsxs("div",{children:[o.jsx("h2",{id:a,children:s?"版本对比":"源码工作区"}),o.jsx("p",{title:e.name,children:e.name||"Agent 项目"})]})]}),o.jsxs("div",{className:"code-browser-head-actions",children:[o.jsx("button",{type:"button",className:"code-browser-icon-button",onClick:()=>f(T),"aria-label":"切换源码主题",title:`切换为${T==="dark"?"深色":"浅色"}主题`,children:d==="light"?o.jsx(Pdt,{}):o.jsx(Ddt,{})}),o.jsx("button",{ref:c,type:"button",className:"code-browser-icon-button",onClick:n,"aria-label":"关闭源码工作区",title:"关闭",children:o.jsx(C0e,{})})]})]}),o.jsxs("div",{className:"code-browser-workspace",children:[o.jsxs("aside",{className:"code-browser-sidebar","aria-label":s?"变更文件":"项目文件",children:[o.jsxs("div",{className:"code-browser-sidebar-head",children:[o.jsx("span",{children:s?"变更":"文件"}),o.jsx("span",{children:m.length})]}),o.jsx("div",{className:"code-browser-tree",children:m.length>0?_(x,0,""):o.jsx("div",{className:"code-browser-empty",children:A})})]}),o.jsxs("main",{className:"code-browser-main",children:[o.jsx("div",{className:"code-browser-tabs",role:"tablist","aria-label":"打开的文件",children:w?o.jsxs("div",{className:"code-browser-tab",role:"tab","aria-selected":"true",children:[o.jsx(_D,{}),o.jsx("span",{children:w.path.split("/").pop()}),k(S==null?void 0:S.status)]}):null}),o.jsxs("div",{className:"code-browser-path",children:[o.jsx(_D,{}),o.jsx("span",{children:(w==null?void 0:w.path)??"未选择文件"})]}),s?o.jsxs("div",{className:"code-browser-diff-labels","aria-label":"对比方向",children:[o.jsx("span",{children:s.baseLabel??"优化前"}),o.jsx("span",{children:s.targetLabel??"优化后"})]}):null,o.jsx("div",{className:"code-browser-editor",children:w?o.jsx(p.Suspense,{fallback:o.jsx("div",{className:"code-browser-empty",children:"正在加载编辑器…"}),children:S?o.jsx($dt,{before:S.before,after:S.after,path:S.path,theme:d}):o.jsx(Ldt,{value:w.content,path:w.path,onChange:C,readOnly:i,theme:d})}):o.jsx("div",{className:"code-browser-empty",children:A})}),o.jsxs("footer",{className:"code-browser-statusbar",children:[o.jsx("span",{children:s?`${h.length} 个文件有变更`:`${e.files.length} 个文件`}),o.jsx("span",{children:w?`${Fdt(w.content)} 行 · UTF-8`:"UTF-8"})]})]})]})]})}),document.body)}function zdt({project:e,onChange:t,className:n="",label:r="查看源码"}){const[i,s]=p.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:`code-browser-trigger ${n}`.trim(),onClick:()=>s(!0),"aria-label":"查看和编辑项目源码",title:r,children:[o.jsx(T0e,{}),o.jsx("span",{children:r})]}),o.jsx(Yw,{project:e,open:i,onClose:()=>s(!1),onChange:t})]})}const N0e="send_a2ui_json_to_client",Vdt=28,Hdt=3e3;function qdt(e,t,n){let r=t;for(let i=0;i65535?2:1}return r}function Xdt(e){return e<=4?1:Math.min(18,Math.max(2,Math.ceil(e/6)))}function j0e(e,t,n,r){const[i,s]=p.useState(()=>t?"":e),a=p.useRef(i),l=p.useRef(e),c=p.useRef(null),u=p.useRef(0),d=p.useRef(n);return l.current=e,d.current=n,p.useEffect(()=>{const f=a.current,h=window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(!t||h||!e.startsWith(f)){c.current!==null&&window.cancelAnimationFrame(c.current),c.current=null,f!==e&&(a.current=e,s(e));return}if(f===e||c.current!==null)return;const m=g=>{const b=l.current,y=a.current;if(!b.startsWith(y)){a.current=b,s(b),c.current=null;return}if(g-u.current{var f;(f=d.current)==null||f.call(d)},[i]),p.useEffect(()=>{i===e&&(r==null||r())},[i,r,e]),p.useEffect(()=>()=>{c.current!==null&&(window.cancelAnimationFrame(c.current),c.current=null)},[]),i}function Gdt(){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:o.jsx("path",{d:"M14.3 5.25a4.6 4.6 0 0 0-5.55 5.55L3.6 15.95a1.8 1.8 0 0 0 0 2.55l1.9 1.9a1.8 1.8 0 0 0 2.55 0l5.15-5.15a4.6 4.6 0 0 0 5.55-5.55l-2.9 2.9-2.45-.55-.55-2.45 2.9-2.9a4.6 4.6 0 0 0-1.45-1.45Z"})})}function Wdt(){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"m4.5 7 1.8 1.8L9.5 5.5"}),o.jsx("path",{d:"M12 7h7.5"}),o.jsx("path",{d:"m4.5 13 1.8 1.8 3.2-3.3"}),o.jsx("path",{d:"M12 13h7.5"}),o.jsx("path",{d:"M5 19h4"}),o.jsx("path",{d:"M12 19h7.5"})]})}function Ydt(e,t){if(e!=="load_skill"||t==null||typeof t!="object"||Array.isArray(t))return;const n=t.skill_name;if(!(typeof n!="string"||!n.trim()))return`使用 ${n.trim()} 技能`}function R0e({text:e,done:t,answerStarted:n=!1,streaming:r=!1,onStreamFrame:i}){const[s,a]=p.useState(!(t||n)),l=p.useRef(!1);p.useEffect(()=>{l.current||a(!(t||n))},[n,t]);const c=()=>{l.current=!0,a(m=>!m)},u=e.replace(/^\s+/,""),d=j0e(u,!t||r,i),{ref:f,onScroll:h}=qge(d);return o.jsxs("div",{className:"block-thinking",children:[o.jsxs("button",{className:"think-head",onClick:c,type:"button",children:[o.jsx("span",{className:"think-icon","aria-hidden":"true",children:o.jsx(_0e,{className:`thinking-logo ${t?"":"is-active"}`})}),t?o.jsx("span",{className:"think-label think-label--done",children:"已完成思考"}):o.jsx(En,{className:"think-label",duration:2.4,spread:18,children:"思考中"}),o.jsx(VS,{className:`chev ${s?"open":""}`})]}),o.jsx("div",{className:`think-collapse ${s&&d?"open":""}`,children:o.jsx("div",{className:"think-collapse-inner",children:o.jsx("div",{className:"think-body scroll",ref:f,onScroll:h,children:d})})})]})}function Zdt({text:e}){return o.jsx("div",{className:"block-progress",role:"status","aria-live":"polite","aria-atomic":"true",children:o.jsxs("div",{className:"think-head progress-head",children:[o.jsx("span",{className:"think-icon","aria-hidden":"true",children:o.jsx(_0e,{className:"thinking-logo is-active"})}),o.jsx(En,{className:"think-label",duration:2.4,spread:18,children:e})]})})}function Kdt({value:e,onResolve:t,onResolveComparison:n,onDownload:r,onDeploy:i}){const[s,a]=p.useState(e.files?e:null),[l,c]=p.useState(!1),[u,d]=p.useState(!1),[f,h]=p.useState(null),[m,g]=p.useState(null),[b,y]=p.useState(""),[O,v]=p.useState(null),x=new Date(e.validatedAt),w=e.validatedAt?Number.isNaN(x.getTime())?e.validatedAt:x.toLocaleString("zh-CN",{hour12:!1}):"刚刚";p.useEffect(()=>{if(!O)return;const T=window.setTimeout(()=>v(null),Hdt);return()=>window.clearTimeout(T)},[O]);async function S(){if(s)return s;if(!t)throw new Error("暂时无法读取生成的源码,请稍后重试。");const T=await t(e);return a(T),T}async function E(){g("source"),y(""),v(null);try{await S(),c(!0)}catch(T){y(T instanceof Error?T.message:String(T))}finally{g(null)}}async function k(){if(r){g("download"),y(""),v(null);try{await r(e),v({message:"已开始下载"})}catch(T){y(T instanceof Error?T.message:String(T))}finally{g(null)}}}async function _(){if(n){g("compare"),y(""),v(null);try{const T=f??await n(e);h(T),d(!0)}catch(T){y(T instanceof Error?T.message:String(T))}finally{g(null)}}}async function C(){g("deploy"),y(""),v(null);try{i==null||i(await S())}catch(T){y(T instanceof Error?T.message:String(T))}finally{g(null)}}return o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:`delivery-card${e.verified?" is-verified":" is-unverified"}`,"aria-label":e.verified?"已验证交付物":"生成的 Agent 源码",children:[o.jsxs("header",{className:"delivery-card-header",children:[o.jsx("span",{className:"delivery-card-icon",children:e.verified?o.jsx(Adt,{}):o.jsx(Cdt,{})}),o.jsxs("div",{children:[o.jsx("strong",{children:e.verified?"已验证交付物":"生成的 Agent 源码"}),o.jsx("span",{children:e.agentName})]})]}),o.jsxs("dl",{className:"delivery-card-grid",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"入口"}),o.jsx("dd",{children:o.jsx("code",{children:e.entryPoint})})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"文件数"}),o.jsx("dd",{children:e.fileCount})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"大小"}),o.jsxs("dd",{children:[(e.artifactSize/1024).toFixed(1)," KiB"]})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e.verified?"验证时间":"生成时间"}),o.jsx("dd",{children:w})]})]}),o.jsxs("p",{className:"delivery-card-gates",children:[e.verified?`${e.gateSummary.length} 项检查通过`:"源码已准备好,可部署"," ·"," ",o.jsx("code",{children:e.artifactSha256.slice(0,12)})]}),e.verified?null:o.jsx("p",{className:"delivery-card-guidance",children:"源码已准备好,可查看、下载或部署;部署前请确认 Runtime 配置。"}),o.jsxs("div",{className:"delivery-card-actions",children:[o.jsxs("button",{type:"button",className:"delivery-card-secondary",onClick:()=>void E(),disabled:!t||m!==null,children:[m==="source"?o.jsx(lr,{className:"spin","aria-hidden":"true"}):null,"查看源码"]}),e.projectId&&e.versionId&&e.parentVersionId?o.jsxs("button",{type:"button",className:"delivery-card-secondary",onClick:()=>void _(),disabled:!n||m!==null,children:[m==="compare"?o.jsx(lr,{className:"spin","aria-hidden":"true"}):null,m==="compare"?"正在准备…":"查看本次变更"]}):null,o.jsxs("button",{type:"button",className:"delivery-card-secondary",onClick:()=>void k(),disabled:!r||m!==null,"aria-busy":m==="download",children:[m==="download"?o.jsx(lr,{className:"spin","aria-hidden":"true"}):null,m==="download"?"正在准备…":"下载源码"]}),o.jsxs("button",{type:"button",onClick:()=>void C(),disabled:!e.deployable||!i||!t||m!==null,title:e.deployable?void 0:"源码尚未准备好",children:[m==="deploy"?o.jsx(lr,{className:"spin","aria-hidden":"true"}):null,"手动部署到 Runtime"]})]}),b?o.jsx("p",{className:"delivery-card-error",role:"alert",children:b}):null,O?o.jsx("p",{className:"delivery-card-status",role:"status","aria-live":"polite",children:O.message}):null]}),o.jsx(Yw,{project:{name:e.agentName,files:(s==null?void 0:s.files)??[]},open:l,onClose:()=>c(!1),onChange:()=>{},readOnly:!0}),o.jsx(Yw,{project:{name:(f==null?void 0:f.target.agentName)??e.agentName,files:(f==null?void 0:f.target.files)??[]},comparison:f?{baseProject:{name:f.base.agentName,files:f.base.files??[]},baseLabel:"优化前",targetLabel:"优化后"}:void 0,open:u,onClose:()=>d(!1),onChange:()=>{},readOnly:!0})]})}function I0e(){return o.jsx(R0e,{text:"",done:!1})}const Jdt=p.memo(function({text:t,streaming:n,onStreamFrame:r,onStreamComplete:i}){const s=j0e(t,n,r,i);return s?o.jsx("div",{className:"bubble",children:o.jsx(xu,{text:s,streaming:n})}):null}),eft={pending:"待处理",in_progress:"进行中",completed:"已完成",failed:"未完成"};function tft({title:e,summary:t,items:n,done:r}){const[i,s]=p.useState(!r),a=p.useRef(!1);p.useEffect(()=>{a.current||s(!r)},[r]);const l=()=>{a.current=!0,s(c=>!c)};return o.jsxs("div",{className:"block-plan",children:[o.jsxs("button",{className:"plan-head",type:"button",onClick:l,"aria-expanded":n.length>0?i:void 0,disabled:n.length===0,children:[o.jsx("span",{className:"plan-icon","aria-hidden":"true",children:o.jsx(Wdt,{})}),r?o.jsx("span",{className:"plan-title",children:e}):o.jsx(En,{className:"plan-title",duration:2.2,spread:15,children:e}),t?o.jsx("span",{className:"plan-summary",children:t}):null,n.length>0?o.jsx(DB,{className:`plan-chevron${i?" is-open":""}`}):null]}),o.jsx("div",{className:`think-collapse ${i&&n.length>0?"open":""}`,children:o.jsx("div",{className:"think-collapse-inner",children:n.length>0?o.jsx("ol",{className:"plan-items",children:n.map((c,u)=>o.jsxs("li",{"data-status":c.status,children:[o.jsx("span",{className:"plan-item-marker","aria-hidden":"true"}),o.jsx("span",{className:"plan-item-text",children:c.text}),o.jsx("small",{children:eft[c.status]})]},`${u}:${c.text}`))}):null})})]})}function nft(e){if(!e||typeof e!="object")return[];const t=e,n=t.result;let r=[];if(Array.isArray(t.studio_artifacts))r=t.studio_artifacts;else if(n&&typeof n=="object"){const i=n.studio_artifacts;Array.isArray(i)&&(r=i)}return r.flatMap(i=>{if(!i||typeof i!="object")return[];const s=i;return typeof s.name=="string"&&typeof s.contentUrl=="string"?[{name:s.name,contentUrl:s.contentUrl}]:[]})}function rft({name:e,args:t,response:n,done:r,status:i,defaultOpen:s=!1,retrying:a=!1,onBranchSelect:l}){const u=e==="create_agents"&&r&&Zct(t,n)?"failed":i??(r?"completed":"running"),d=e==="create_agents"&&u==="failed"&&a,f=Tdt(e),h=f==null?void 0:f.detailRenderer,m=(f==null?void 0:f.hideHeader)===!0,g=m||s||!!h,[b,y]=p.useState(g),O=p.useRef(!1);p.useEffect(()=>{!O.current&&g&&y(!0)},[g]);const v=()=>{O.current=!0,y(k=>!k)},x=e===N0e?"渲染 UI":e,w=nft(n),S=n==null?null:typeof n=="string"?n:JSON.stringify(n,null,2),E=S&&S.length>2e3?S.slice(0,2e3)+` …(已截断)`:S;return o.jsxs(oi.div,{className:`block-tool${f?" block-tool--builtin":""}`,"data-status":u,initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[f&&!m?o.jsx(Hct,{definition:f,label:d?"Agent 正在调整":u==="failed"?f.failedLabel:Ydt(e,t),done:r,open:b,onToggle:v}):f?null:o.jsxs("button",{className:"tool-head tool-head--generic",onClick:v,type:"button","aria-expanded":b,children:[o.jsx("span",{className:"tool-icon tool-icon--generic","aria-hidden":"true",children:o.jsx(Gdt,{})}),r?o.jsx("span",{className:"tool-name",children:x}):o.jsx(En,{className:"tool-name",duration:2.2,spread:15,children:x}),o.jsx(DB,{className:`tool-chevron${b?" is-open":""}`})]}),o.jsx("div",{className:`${m?"":"think-collapse "}${b?"open":""}`,children:o.jsx("div",{className:"think-collapse-inner",children:h?o.jsx(h,{args:t,response:n,status:u,onBranchSelect:l}):o.jsxs("div",{className:"tool-detail",children:[t!=null&&o.jsxs("div",{className:"tool-section",children:[o.jsx("div",{className:"tool-section-label",children:"参数"}),o.jsx("pre",{className:"tool-args",children:JSON.stringify(t,null,2)})]}),E!=null&&o.jsxs("div",{className:"tool-section",children:[o.jsx("div",{className:"tool-section-label",children:"返回"}),o.jsx("pre",{className:"tool-args tool-result",children:E})]}),w.length>0&&o.jsxs("div",{className:"tool-section",children:[o.jsx("div",{className:"tool-section-label",children:"产物"}),o.jsx("div",{className:"studio-tool-artifacts",children:w.map(k=>o.jsxs("a",{href:k.contentUrl,download:k.name,children:["下载 ",k.name]},`${k.contentUrl}:${k.name}`))})]})]})})})]})}function ift({block:e,onDownload:t,onPreview:n}){const[r,i]=p.useState(""),[s,a]=p.useState(""),[l,c]=p.useState(null);p.useEffect(()=>()=>{l&&URL.revokeObjectURL(l.url)},[l]);const u=()=>c(null),d=async(m,g)=>{if(t){i(`download:${m}`),a("");try{await t(m,g)}catch(b){a(b instanceof Error?b.message:String(b))}finally{i("")}}},f=async(m,g,b)=>{if(n){i(`preview:${b}`),a("");try{const y=await n(m,g);c({name:b,url:y})}catch(y){a(y instanceof Error?y.message:String(y))}finally{i("")}}},h=e.files.filter(m=>!m.filename.endsWith(".preview.webp"));return o.jsxs("div",{className:"artifact-list",children:[h.map(m=>{const g=`${m.filename.replace(/\.pptx$/i,"")}.preview.webp`,b=e.files.find(y=>y.filename===g);return o.jsxs("div",{className:"artifact-card",children:[o.jsx("span",{className:"artifact-card__icon","aria-hidden":"true",children:o.jsx(t9,{})}),o.jsxs("span",{className:"artifact-card__copy",children:[o.jsx("span",{className:"artifact-card__name",children:m.filename}),o.jsx("span",{className:"artifact-card__hint",children:"PowerPoint 演示文稿"})]}),o.jsxs("span",{className:"artifact-card__actions",children:[b&&o.jsxs("button",{className:"artifact-card__action",type:"button",disabled:!n||r!=="",onClick:()=>void f(b.filename,b.version,m.filename),children:[r===`preview:${m.filename}`?o.jsx(lr,{className:"spin"}):o.jsx(FRe,{}),"预览"]}),o.jsxs("button",{className:"artifact-card__action artifact-card__action--primary",type:"button",disabled:!t||r!=="",onClick:()=>void d(m.filename,m.version),children:[r===`download:${m.filename}`?o.jsx(lr,{className:"spin"}):o.jsx(NN,{}),"下载"]})]})]},`${m.filename}:${m.version}`)}),s&&o.jsx("div",{className:"artifact-card__error",children:s}),l&&o.jsxs("div",{className:"artifact-preview",role:"dialog","aria-modal":"true","aria-label":`${l.name} 预览`,children:[o.jsx("button",{className:"artifact-preview__backdrop",type:"button","aria-label":"关闭预览",onClick:u}),o.jsxs("div",{className:"artifact-preview__panel",children:[o.jsxs("div",{className:"artifact-preview__header",children:[o.jsx("span",{children:l.name}),o.jsx("button",{type:"button","aria-label":"关闭预览",onClick:u,children:o.jsx(Oa,{})})]}),o.jsx("div",{className:"artifact-preview__canvas",children:o.jsx("img",{src:l.url,alt:`${l.name} 幻灯片预览`})})]})]})]})}function sft({block:e,onAuth:t}){const[n,r]=p.useState(e.done?"done":"idle"),[i,s]=p.useState(""),a=e.label||"MCP 工具集",l=(()=>{try{return e.authUri?new URL(e.authUri).host:""}catch{return""}})(),c=async()=>{if(t){s(""),r("authorizing");try{await t(e),r("done")}catch(d){s(d instanceof Error?d.message:String(d)),r("idle")}}};return e.done||n==="done"?o.jsxs(oi.div,{className:"auth-card-collapsed",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},children:[o.jsx(xH,{className:"auth-card-icon auth-card-icon--done"}),o.jsxs("span",{children:["已授权 · ",a]})]}):o.jsxs(oi.div,{className:"auth-card",initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[o.jsxs("div",{className:"auth-card-head",children:[o.jsx(xH,{className:"auth-card-icon"}),o.jsxs("span",{className:"auth-card-title",children:[a," 需要授权"]})]}),o.jsxs("p",{className:"auth-card-desc",children:["工具集 ",o.jsx("code",{className:"auth-card-code",children:a})," 使用 OAuth 保护, 需登录授权后方可调用。",l&&o.jsxs(o.Fragment,{children:[" ","将跳转至 ",o.jsx("code",{className:"auth-card-code",children:l})," 完成登录,"]}),"授权完成后对话自动继续。"]}),o.jsx("button",{className:"auth-card-btn",onClick:c,disabled:n==="authorizing"||!e.authUri,children:n==="authorizing"?o.jsxs(o.Fragment,{children:[o.jsx(lr,{className:"cw-i spin"})," 等待授权…"]}):o.jsx(o.Fragment,{children:"去授权"})}),!e.authUri&&o.jsx("div",{className:"auth-card-err",children:"未在事件中找到授权地址。"}),i&&o.jsx("div",{className:"auth-card-err",children:i})]})}function Uj({blocks:e,appName:t="",streaming:n=!1,onStreamFrame:r,onStreamComplete:i,onAction:s,onAuth:a,onArtifactDownload:l,onArtifactPreview:c,onResolveDelivery:u,onResolveDeliveryComparison:d,onDownloadDelivery:f,onDeployDelivery:h,onBranchSelect:m}){const g=e.reduce((b,y,O)=>y.kind==="text"?O:b,-1);return o.jsx(o.Fragment,{children:e.map((b,y)=>{switch(b.kind){case"progress":return o.jsx(Zdt,{text:b.text},"build-progress");case"thinking":{const O=e.slice(y+1).some(v=>v.kind==="text"&&!!v.text.trim());return o.jsx(R0e,{text:b.text,done:b.done,answerStarted:O,streaming:n,onStreamFrame:r},y)}case"text":{const O=b.text.replace(/^\s+/,"");return O?o.jsx(Jdt,{text:O,streaming:n,onStreamFrame:r,onStreamComplete:y===g?i:void 0},y):null}case"plan":return o.jsx(tft,{title:b.title,summary:b.summary,items:b.items,done:b.done},y);case"attachment":return o.jsx($j,{appName:t,items:b.files},y);case"artifact":return o.jsx(ift,{block:b,onDownload:l,onPreview:c},y);case"delivery":return o.jsx(Kdt,{value:b.value,onResolve:u,onResolveComparison:d,onDownload:f,onDeploy:h},y);case"invocation":return o.jsx(Lj,{value:b.value},y);case"tool":{if(b.name===N0e&&b.done)return null;const O=b.name==="create_agents"&&e.slice(y+1).some(v=>v.kind==="tool"&&v.name==="create_agents");return o.jsx(rft,{name:b.name,args:b.args,response:b.response,done:b.done,status:b.status,defaultOpen:b.defaultOpen,retrying:b.name==="create_agents"&&(n||O),onBranchSelect:m},y)}case"agent-transfer":return null;case"auth":return o.jsx(sft,{block:b,onAuth:a},y);case"a2ui":return Hge(b.messages).filter(O=>O.components[O.rootId]).map(O=>o.jsx(oi.div,{initial:{opacity:0,y:8,scale:.985},animate:{opacity:1,y:0,scale:1},transition:{type:"spring",stiffness:380,damping:30},children:o.jsx(jct,{surface:O,onAction:s})},`${y}-${O.surfaceId}`));default:return null}})})}const aft=()=>{};function oft(e){if(e.kind==="message")return{kind:"text",text:e.text};if(e.kind==="thinking")return{kind:"thinking",text:e.text,done:e.status==="done"};if(e.kind==="tool")return{kind:"tool",name:e.name,args:e.args,response:e.response,done:e.status==="done"};throw new Error("不支持的 Skill 对话活动")}function lft({activities:e}){const t=p.useMemo(()=>e.filter(n=>n.kind!=="status").map(oft),[e]);return t.length===0?null:o.jsx("div",{className:"skill-conversation","aria-label":"Skill 生成对话","aria-live":"polite",children:o.jsx(Uj,{blocks:t,onAction:aft})})}function GW(){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:o.jsx("path",{d:"m7 9 5 5 5-5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function cT({label:e,value:t,options:n,onChange:r,disabled:i=!1,allowCustom:s=!1,required:a=!1,placeholder:l="请选择",error:c}){const u=p.useId(),d=p.useId(),f=p.useId(),h=p.useRef(null),m=p.useRef(null),g=p.useRef(null),b=p.useRef(null),y=p.useRef([]),O=n.findIndex(L=>L.value===t),v=t.trim().toLocaleLowerCase(),x=s&&v?n.filter(L=>L.value.toLocaleLowerCase().includes(v)||L.label.toLocaleLowerCase().includes(v)):n,[w,S]=p.useState(!1),[E,k]=p.useState(Math.max(0,O)),_=O>=0?n[O]:void 0,C=i||!s&&n.length===0,T=(L=!1)=>{S(!1),L&&window.requestAnimationFrame(()=>{var I,M;return s?(I=g.current)==null?void 0:I.focus():(M=m.current)==null?void 0:M.focus()})},A=L=>{C||x.length!==0&&(k(Math.min(Math.max(L,0),x.length-1)),S(!0))};p.useEffect(()=>{if(!w)return;const L=b.current,I=s?void 0:window.requestAnimationFrame(()=>{var Q;(Q=y.current[E])==null||Q.focus()}),M=Q=>{if(!L)return;const F=L.scrollTop<=0,$=L.scrollTop+L.clientHeight>=L.scrollHeight-1;(L.scrollHeight<=L.clientHeight||Q.deltaY<0&&F||Q.deltaY>0&&$)&&Q.preventDefault(),Q.stopPropagation()},N=Q=>{var F;Q.target instanceof Node&&!((F=h.current)!=null&&F.contains(Q.target))&&T()},D=Q=>{Q.key==="Escape"&&T(!0)};return L==null||L.addEventListener("wheel",M,{passive:!1}),window.addEventListener("pointerdown",N),window.addEventListener("keydown",D),()=>{I!==void 0&&window.cancelAnimationFrame(I),L==null||L.removeEventListener("wheel",M),window.removeEventListener("pointerdown",N),window.removeEventListener("keydown",D)}},[E,s,w]);const j=L=>{var M;if(x.length===0)return;const I=(L+x.length)%x.length;k(I),(M=y.current[I])==null||M.focus()};return o.jsxs("div",{ref:h,className:`skill-config-select${w?" is-open":""}`,onBlur:L=>{var I;(!L.relatedTarget||!((I=h.current)!=null&&I.contains(L.relatedTarget)))&&T()},children:[o.jsxs("span",{id:d,className:"skill-config-select__label",children:[e,a?o.jsx("span",{className:"skill-required-mark","aria-hidden":"true",children:"*"}):null]}),s?o.jsxs("div",{className:`skill-config-select__trigger is-editable${i?" is-disabled":""}`,"aria-expanded":w,children:[o.jsx("input",{ref:g,value:t,disabled:i,role:"combobox","aria-autocomplete":"list","aria-expanded":w,"aria-controls":w?u:void 0,"aria-labelledby":d,"aria-required":a,"aria-invalid":!!c,"aria-describedby":c?f:void 0,placeholder:l,onChange:L=>{r(L.target.value),k(0),n.length>0&&S(!0)},onClick:()=>{!w&&x.length>0&&A(0)},onKeyDown:L=>{var I,M;if(!(L.nativeEvent.isComposing||L.keyCode===229))if(L.key==="ArrowDown")L.preventDefault(),w?(I=y.current[E])==null||I.focus():A(0);else if(L.key==="ArrowUp")L.preventDefault(),w?(M=y.current[x.length-1])==null||M.focus():A(x.length-1);else if(L.key==="Enter"&&w){L.preventDefault();const N=x[E];N&&r(N.value),T()}else L.key==="Escape"&&(L.preventDefault(),T())}}),o.jsx("button",{type:"button",className:"skill-config-select__toggle",disabled:i||n.length===0,"aria-label":w?"收起模型选项":"展开模型选项",onClick:()=>{w?T():A(0)},children:o.jsx(GW,{})})]}):o.jsxs("button",{ref:m,type:"button",className:"skill-config-select__trigger",disabled:C,"aria-haspopup":"listbox","aria-expanded":w,"aria-controls":w?u:void 0,"aria-labelledby":d,"aria-required":a,onClick:()=>{w?T():A(O>=0?O:0)},onKeyDown:L=>{L.key==="ArrowDown"?(L.preventDefault(),A(O>=0?O:0)):L.key==="ArrowUp"&&(L.preventDefault(),A(O>=0?O:n.length-1))},children:[o.jsx("span",{className:_?void 0:"is-placeholder",title:_==null?void 0:_.label,children:(_==null?void 0:_.label)||(n.length===0?"暂无可用选项":l)}),o.jsx(GW,{})]}),w?o.jsxs("div",{ref:b,id:u,className:"skill-config-select__menu",role:"listbox","aria-labelledby":d,children:[x.length===0?o.jsx("div",{className:"skill-config-select__empty",role:"status",children:"没有匹配项,可直接使用当前模型 ID"}):null,x.map((L,I)=>{const M=L.value===t;return o.jsx("button",{ref:N=>{y.current[I]=N},type:"button",role:"option","aria-selected":M,tabIndex:I===E?0:-1,className:`skill-config-select__option${M?" is-selected":""}`,title:L.label,onFocus:()=>k(I),onClick:()=>{r(L.value),T(!0)},onKeyDown:N=>{N.key==="Enter"||N.key===" "?(N.preventDefault(),r(L.value),T(!0)):N.key==="ArrowDown"?(N.preventDefault(),j(I+1)):N.key==="ArrowUp"?(N.preventDefault(),j(I-1)):N.key==="Home"?(N.preventDefault(),j(0)):N.key==="End"&&(N.preventDefault(),j(n.length-1))},children:L.label},L.value)})]}):null,c?o.jsx("span",{id:f,className:"skill-config-select__error",role:"alert",children:c}):null]})}function ua(e,t){return e instanceof Error?e:typeof e=="string"&&e.trim()?new Error(e.trim()):new Error(t)}function zo({error:e}){var i,s,a,l,c;const t=e,n=(s=(i=t.originalError)==null?void 0:i.message)==null?void 0:s.trim(),r=[typeof t.status=="number"?`HTTP ${t.status}${t.statusText?` ${t.statusText}`:""}`:"",t.code?`错误码:${t.code}`:"",(a=t.originalError)!=null&&a.type?`错误类型:${t.originalError.type}`:"",(l=t.originalError)!=null&&l.repr&&t.originalError.repr!==n?`异常表示:${t.originalError.repr}`:"",(c=t.rawResponse)!=null&&c.trim()?`服务端原始响应: ${t.rawResponse.trim()}`:""].filter(Boolean);return o.jsxs("div",{className:"skill-error-details",children:[o.jsx("div",{className:"skill-error-details__summary",children:e.message}),n?o.jsxs("div",{className:"skill-error-details__original",children:["原始错误:",n]}):null,r.length>0?o.jsxs("details",{children:[o.jsx("summary",{children:"详细信息"}),o.jsx("pre",{children:r.join(` @@ -697,7 +697,7 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus `,i=e.state.doc.line(i.number+(n?1:-1)),s=e.bidiSpans(i),u=e.visualLineSide(i,!n)}if(c){if(!c(d))return l}else{if(!r)return u;c=r(d)}l=u}}function zpt(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return s=>{let a=r(s);return i==Yi.Space&&(i=a),i==a}}function Vpt(e,t,n,r){let i=t.head,s=n?1:-1;if(i==(n?e.state.doc.length:0))return Je.cursor(i,t.assoc);let a=t.goalColumn,l,c=e.contentDOM.getBoundingClientRect(),u=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),d=e.documentTop;if(u)a==null&&(a=u.left-c.left),l=s<0?u.top:u.bottom;else{let g=e.viewState.lineBlockAt(i);a==null&&(a=Math.min(c.right-c.left,e.defaultCharacterWidth*(i-g.from))),l=(s<0?g.top:g.bottom)+d}let f=c.left+a,h=e.viewState.heightOracle.textHeight>>1,m=r??h;for(let g=0;;g+=h){let b=l+(m+g)*s,y=r6(e,{x:f,y:b},!1,s);if(n?b>c.bottom:bl:v{if(t>s&&ti(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:Je.cursor(r,re.viewState.docHeight)return new Zu(e.state.doc.length,-1);if(u=e.elementAtHeight(c),r==null)break;if(u.type==Ba.Text){if(r<0?u.toe.viewport.to)break;let h=e.docView.coordsAt(r<0?u.from:u.to,r>0?-1:1);if(h&&(r<0?h.top<=c+s:h.bottom>=c+s))break}let f=e.viewState.heightOracle.textHeight/2;c=r>0?u.bottom+f:u.top-f}if(e.viewport.from>=u.to||e.viewport.to<=u.from){if(n)return null;if(u.type==Ba.Text){let f=Upt(e,i,u,a,l);return new Zu(f,f==u.from?1:-1)}}if(u.type!=Ba.Text)return c<(u.top+u.bottom)/2?new Zu(u.from,1):new Zu(u.to,-1);let d=e.docView.lineAt(u.from,2);return(!d||d.length!=u.length)&&(d=e.docView.lineAt(u.from,-2)),new Hpt(e,a,l,e.textDirectionAt(u.from)).scanTile(d,u.from)}class Hpt{constructor(t,n,r,i){this.view=t,this.x=n,this.y=r,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(t){return(!this.line||this.line.from>t||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+i.from>1;t:if(a.has(b)){let O=i+Math.floor(Math.random()*g);for(let v=0;v1)){if(v.bottomthis.y)(!u||u.top>v.top)&&(u=v),x=-1;else{let w=v.left>this.x?this.x-v.left:v.right(g+g+b)/3)return this.y=c.bottom-1,this.scan(t,n,!0);if(u&&u.top<(g+b+b)/3)return this.y=u.top+1,this.scan(t,n,!0)}let m=(l?this.dirAt(t[d],1):this.baseDir)==xi.LTR;return{i:d,after:this.x>(h.left+h.right)/2==m}}scanText(t,n){let r=[];for(let s=0;s{let a=r[s]-n,l=r[s+1]-n;return oS(t.dom,a,l).getClientRects()});return i.after?new Zu(r[i.i+1],-1):new Zu(r[i.i],1)}scanTile(t,n){if(!t.length)return new Zu(n,1);if(t.children.length==1){let l=t.children[0];if(l.isText())return this.scanText(l,n);if(l.isComposite())return this.scanTile(l,n)}let r=[n];for(let l=0,c=n;l{let c=t.children[l];return c.flags&48?null:(c.dom.nodeType==1?c.dom:oS(c.dom,0,c.length)).getClientRects()}),s=t.children[i.i],a=r[i.i];return s.isText()?this.scanText(s,a):s.isComposite()?this.scanTile(s,a):i.after?new Zu(r[i.i+1],-1):new Zu(a,1)}}const xb="￿";class qpt{constructor(t,n){this.points=t,this.view=n,this.text="",this.lineSeparator=n.state.facet(vr.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=xb}readRange(t,n){if(!t)return this;let r=t.parentNode;for(let i=t;;){this.findPointBefore(r,i);let s=this.text.length;this.readNode(i);let a=hs.get(i),l=i.nextSibling;if(l==n){a!=null&&a.breakAfter&&!l&&r!=this.view.contentDOM&&this.lineBreak();break}let c=hs.get(l);(a&&c?a.breakAfter:(a?a.breakAfter:mA(i))||mA(l)&&(i.nodeName!="BR"||a!=null&&a.isWidget())&&this.text.length>s)&&!Gpt(l,n)&&this.lineBreak(),i=l}return this.findPointBefore(r,n),this}readTextNode(t){let n=t.nodeValue;for(let r of this.points)r.node==t&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,a=1,l;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,r),a=this.lineSeparator.length):(l=i.exec(n))&&(s=l.index,a=l[0].length),this.append(n.slice(r,s<0?n.length:s)),s<0)break;if(this.lineBreak(),a>1)for(let c of this.points)c.node==t&&c.pos>this.text.length&&(c.pos-=a-1);r=s+a}}readNode(t){let n=hs.get(t),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(t,r.length);for(let i=r.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.value)}else t.nodeType==3?this.readTextNode(t):t.nodeName=="BR"?t.nextSibling&&this.lineBreak():t.nodeType==1&&this.readRange(t.firstChild,null)}findPointBefore(t,n){for(let r of this.points)r.node==t&&t.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(t,n){for(let r of this.points)(t.nodeType==3?r.node==t:t.contains(r.node))&&(r.pos=this.text.length+(Xpt(t,r.node,r.offset)?n:0))}}function Xpt(e,t,n){for(;;){if(!t||n-1;let{impreciseHead:s,impreciseAnchor:a}=t.docView,l=t.state.selection;if(t.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=vye(t.docView.tile,n,r,0))){let c=s||a?[]:Zpt(t),u=new qpt(c,t);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=Kpt(c,this.bounds.from)}else{let c=t.observer.selectionRange,u=s&&s.node==c.focusNode&&s.offset==c.focusOffset||!YL(t.contentDOM,c.focusNode)?l.main.head:t.docView.posFromDOM(c.focusNode,c.focusOffset),d=a&&a.node==c.anchorNode&&a.offset==c.anchorOffset||!YL(t.contentDOM,c.anchorNode)?l.main.anchor:t.docView.posFromDOM(c.anchorNode,c.anchorOffset),f=t.viewport;if(($t.ios||$t.chrome)&&u!=d&&Math.min(u,d)<=l.main.from&&Math.max(u,d)>=l.main.to&&(f.from>0||f.to-1&&l.ranges.length>1)this.newSel=l.replaceRange(Je.range(d,u));else if(t.lineWrapping&&d==u&&!(l.main.empty&&l.main.head==u)&&t.inputState.lastTouchTime>Date.now()-100){let h=t.coordsAtPos(u,-1),m=0;h&&(m=t.inputState.lastTouchY<=h.bottom?-1:1),this.newSel=Je.create([Je.cursor(u,m)])}else this.newSel=Je.single(d,u)}}}function vye(e,t,n,r){if(e.isComposite()){let i=-1,s=-1,a=-1,l=-1;for(let c=0,u=r,d=r;cn)return vye(f,t,n,u);if(h>=t&&i==-1&&(i=c,s=u),u>n&&f.dom.parentNode==e.dom){a=c,l=d;break}d=h,u=h+f.breakAfter}return{from:s,to:l<0?r+e.length:l,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:a=0?e.children[a].dom:null}}else return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function wye(e,t){let n,{newSel:r}=t,{state:i}=e,s=i.selection.main,a=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:l,to:c}=t.bounds,u=s.from,d=null;(a===8||$t.android&&t.text.length=l&&s.to<=c&&(t.typeOver||f!=t.text)&&f.slice(0,s.from-l)==t.text.slice(0,s.from-l)&&f.slice(s.to-l)==t.text.slice(h=t.text.length-(f.length-(s.to-l)))?n={from:s.from,to:s.to,insert:Br.of(t.text.slice(s.from-l,h).split(xb))}:(m=Sye(f,t.text,u-l,d))&&($t.chrome&&a==13&&m.toB==m.from+2&&t.text.slice(m.from,m.toB)==xb+xb&&m.toB--,n={from:l+m.from,to:l+m.toA,insert:Br.of(t.text.slice(m.from,m.toB).split(xb))})}else r&&(!e.hasFocus&&i.facet(xf)||OA(r,s))&&(r=null);if(!n&&!r)return!1;if(($t.mac||$t.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=Je.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:Br.of([n.insert.toString().replace("."," ")])}):i.doc.lineAt(s.from).toDate.now()-50?n={from:s.from,to:s.to,insert:i.toText(e.inputState.insertingText)}:$t.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==` `&&e.lineWrapping&&(r&&(r=Je.single(r.main.anchor-1,r.main.head-1)),n={from:s.from,to:s.to,insert:Br.of([" "])}),n)return xQ(e,n,r,a);if(r&&!OA(r,s)){let l=!1,c="select";return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin=="select"&&(l=!0),c=e.inputState.lastSelectionOrigin,c=="select.pointer"&&(r=xye(i.facet($E).map(u=>u(e)),r))),e.dispatch({selection:r,scrollIntoView:l,userEvent:c}),!0}else return!1}function xQ(e,t,n,r=-1){if($t.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if($t.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&_y(e.contentDOM,"Enter",13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.lengthi.head)&&_y(e.contentDOM,"Backspace",8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&_y(e.contentDOM,"Delete",46)))return!0;let s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a,l=()=>a||(a=Ypt(e,t,n));return e.state.facet(lye).some(c=>c(e,t.from,t.to,s,l))||e.dispatch(l()),!0}function Ypt(e,t,n){let r,i=e.state,s=i.selection.main,a=-1;if(t.from==t.to&&t.froms.to){let c=t.fromf(e)),u,c);t.from==d&&(a=d)}if(a>-1)r={changes:t,selection:Je.cursor(t.from+t.insert.length,-1)};else if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let c=s.fromt.to?i.sliceDoc(t.to,s.to):"";r=i.replaceSelection(e.state.toText(c+t.insert.sliceString(0,void 0,e.state.lineBreak)+u))}else{let c=i.changes(t),u=n&&n.main.to<=c.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=s.to+10&&t.to>=s.to-10){let d=e.state.sliceDoc(t.from,t.to),f,h=n&&Oye(e,n.main.head);if(h){let g=t.insert.length-(t.to-t.from);f={from:h.from,to:h.to-g}}else f=e.state.doc.lineAt(s.head);let m=s.to-t.to;r=i.changeByRange(g=>{if(g.from==s.from&&g.to==s.to)return{changes:c,range:u||g.map(c)};let b=g.to-m,y=b-d.length;if(e.state.sliceDoc(y,b)!=d||b>=f.from&&y<=f.to)return{range:g};let O=i.changes({from:y,to:b,insert:t.insert}),v=g.to-s.to;return{changes:O,range:u?Je.range(Math.max(0,u.anchor+v),Math.max(0,u.head+v)):g.map(O)}})}else r={changes:c,selection:u&&i.selection.replaceRange(u)}}let l="input.type";return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,l+=".compose",e.inputState.compositionFirstChange&&(l+=".start",e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:l,scrollIntoView:!0})}function Sye(e,t,n,r){let i=Math.min(e.length,t.length),s=0;for(;s0&&l>0&&e.charCodeAt(a-1)==t.charCodeAt(l-1);)a--,l--;if(r=="end"){let c=Math.max(0,s-Math.min(a,l));n-=a+c-s}if(a=a?s-n:0;s-=c,l=s+(l-a),a=s}else if(l=l?s-n:0;s-=c,a=s+(a-l),l=s}return{from:s,toA:a,toB:l}}function Zpt(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}=e.observer.selectionRange;return n&&(t.push(new LY(n,r)),(i!=n||s!=r)&&t.push(new LY(i,s))),t}function Kpt(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n>-1&&r>-1?Je.single(n+t,r+t):null}function OA(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class Jpt{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,$t.safari&&t.contentDOM.addEventListener("input",()=>null),$t.gecko&&mmt(t.contentDOM.ownerDocument)}handleEvent(t){!lmt(this.view,t)||this.ignoreDuringComposition(t)||t.type=="keydown"&&this.keydown(t)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t))}runHandlers(t,n){let r=this.handlers[t];if(r){for(let i of r.observers)i(this.view,n);for(let i of r.handlers){if(n.defaultPrevented)break;if(i(this.view,n)){n.preventDefault();break}}}}ensureHandlers(t){let n=tmt(t),r=this.handlers,i=this.view.contentDOM;for(let s in n)if(s!="scroll"){let a=!n[s].handlers.length,l=r[s];l&&a!=!l.handlers.length&&(i.removeEventListener(s,this.handleEvent),l=null),l||i.addEventListener(s,this.handleEvent,{passive:a})}for(let s in r)s!="scroll"&&!n[s]&&i.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&t.keyCode!=27&&kye.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),$t.android&&$t.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;if($t.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&(Eye.some(n=>n.keyCode==t.keyCode)&&!t.ctrlKey||nmt.indexOf(t.key)>-1&&t.ctrlKey)){let n={ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey,shiftKey:t.shiftKey};return n.shiftKey&&$t.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&emt(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:t.key,keyCode:t.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),250),!0}return t.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(t){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&t&&t.from0?!0:$t.safari&&!$t.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function emt(e){return e.visualViewport?e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85:!1}function $Y(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(i){Go(n.state,i)}}}function tmt(e){let t=Object.create(null);function n(r){return t[r]||(t[r]={observers:[],handlers:[]})}for(let r of e){let i=r.spec,s=i&&i.plugin.domEventHandlers,a=i&&i.plugin.domEventObservers;if(s)for(let l in s){let c=s[l];c&&n(l).handlers.push($Y(r.value,c))}if(a)for(let l in a){let c=a[l];c&&n(l).observers.push($Y(r.value,c))}}for(let r in wu)n(r).handlers.push(wu[r]);for(let r in Eo)n(r).observers.push(Eo[r]);return t}const Eye=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],nmt="dthko",kye=[16,17,18,20,91,92,224,225],U2=6;function F2(e){return Math.max(0,e)*.7+8}function rmt(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}class imt{constructor(t,n,r,i){this.view=t,this.startEvent=n,this.style=r,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=Gbe(t.contentDOM),this.atoms=t.state.facet($E).map(a=>a(t));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=t.state.facet(vr.allowMultipleSelections)&&smt(t,n),this.dragging=omt(t,n)&&Cye(n)==1?null:!1}start(t){this.dragging===!1&&this.select(t)}move(t){if(t.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&rmt(this.startEvent,t)<10)return;this.select(this.lastEvent=t);let n=0,r=0,i=0,s=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=OQ(this.view);t.clientX-c.left<=i+U2?n=-F2(i-t.clientX):t.clientX+c.right>=a-U2&&(n=F2(t.clientX-a)),t.clientY-c.top<=s+U2?r=-F2(s-t.clientY):t.clientY+c.bottom>=l-U2&&(r=F2(t.clientY-l)),this.setScrollSpeed(n,r)}up(t){this.dragging==null&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,n){this.scrollSpeed={x:t,y:n},t||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:n}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(t||n)&&this.view.win.scrollBy(t,n),this.dragging===!1&&this.select(this.lastEvent)}select(t){let{view:n}=this,r=xye(this.atoms,this.style.get(t,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}function smt(e,t){let n=e.state.facet(iye);return n.length?n[0](t):$t.mac?t.metaKey:t.ctrlKey}function amt(e,t){let n=e.state.facet(sye);return n.length?n[0](t):$t.mac?!t.altKey:!t.ctrlKey}function omt(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=sS(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let s=0;s=t.clientX&&a.top<=t.clientY&&a.bottom>=t.clientY)return!0}return!1}function lmt(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=hs.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}const wu=Object.create(null),Eo=Object.create(null),_ye=$t.ie&&$t.ie_version<15||$t.ios&&$t.webkit_version<604;function cmt(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),Tye(e,n.value)},50)}function nR(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function Tye(e,t){t=nR(e.state,mQ,t);let{state:n}=e,r,i=1,s=n.toText(t),a=s.lines==n.selection.ranges.length;if(i6!=null&&n.selection.ranges.every(c=>c.empty)&&i6==s.toString()){let c=-1;r=n.changeByRange(u=>{let d=n.doc.lineAt(u.from);if(d.from==c)return{range:u};c=d.from;let f=n.toText((a?s.line(i++).text:t)+n.lineBreak);return{changes:{from:d.from,insert:f},range:Je.cursor(u.from+f.length)}})}else a?r=n.changeByRange(c=>{let u=s.line(i++);return{changes:{from:c.from,to:c.to,insert:u.text},range:Je.cursor(c.from+u.length)}}):r=n.replaceSelection(s);e.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}Eo.scroll=e=>{let t=e.inputState;t.lastScrollTop=e.scrollDOM.scrollTop,t.lastScrollLeft=e.scrollDOM.scrollLeft,$t.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())};Eo.wheel=Eo.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()};wu.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1);Eo.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")};Eo.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")};Eo.touchend=(e,t)=>{e.inputState.touchActive=!1};wu.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(aye))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=dmt(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new imt(e,t,n,r)),r&&e.observer.ignore(()=>{Wbe(e.contentDOM);let s=e.root.activeElement;s&&!s.contains(e.contentDOM)&&s.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin("select.pointer");return!1};function BY(e,t,n,r){if(r==1)return Je.cursor(t,n);if(r==2)return Qpt(e.state,t,n);{let i=e.docView.lineAt(t,n),s=e.state.doc.lineAt(i?i.posAtEnd:t),a=i?i.posAtStart:s.from,l=i?i.posAtEnd:s.to;return lDate.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(UY+1)%3:1}function dmt(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=Cye(t),i=e.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),i=i.map(s.changes))},get(s,a,l){let c=e.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),u,d=BY(e,c.pos,c.assoc,r);if(n.pos!=c.pos&&!a){let f=BY(e,n.pos,n.assoc,r),h=Math.min(f.from,d.from),m=Math.max(f.to,d.to);d=h1&&(u=fmt(i,c.pos))?u:l?i.addRange(d):Je.create([d])}}}function fmt(e,t){for(let n=0;n=t)return Je.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}wu.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let i=e.docView.tile.nearest(t.target);if(i&&i.isWidget()){let s=i.posAtStart,a=s+i.length;(s>=n.to||a<=n.from)&&(n=Je.undirectionalRange(s,a))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",nR(e.state,gQ,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1};wu.dragend=e=>(e.inputState.draggedContent=null,!1);function zY(e,t,n,r){if(n=nR(e.state,mQ,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:s}=e.inputState,a=r&&s&&amt(e,t)?{from:s.from,to:s.to}:null,l={from:i,insert:n},c=e.state.changes(a?[a,l]:l);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:a?"move.drop":"input.drop"}),e.inputState.draggedContent=null}wu.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,s=()=>{++i==n.length&&zY(e,t,r.filter(a=>a!=null).join(e.state.lineBreak),!1)};for(let a=0;a{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(r[a]=l.result),s()},l.readAsText(n[a])}return!0}else{let r=t.dataTransfer.getData("Text");if(r)return zY(e,t,r,!0),!0}return!1};wu.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=_ye?null:t.clipboardData;return n?(Tye(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(cmt(e),!1)};function hmt(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function pmt(e){let t=[],n=[],r=!1;for(let i of e.selection.ranges)i.empty||(t.push(e.sliceDoc(i.from,i.to)),n.push(i));if(!t.length){let i=-1;for(let{from:s}of e.selection.ranges){let a=e.doc.lineAt(s);a.number>i&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),i=a.number}r=!0}return{text:nR(e,gQ,t.join(e.lineBreak)),ranges:n,linewise:r}}let i6=null;wu.copy=wu.cut=(e,t)=>{if(!Hv(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=pmt(e.state);if(!n&&!i)return!1;i6=i?n:null,t.type=="cut"&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=_ye?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(hmt(e,n),!1)};const Aye=Ad.define();function Nye(e,t){let n=[];for(let r of e.facet(cye)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:Aye.of(!0)}):null}function jye(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=Nye(e.state,t);n?e.dispatch(n):e.update([])}},10)}Eo.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),jye(e)};Eo.blur=e=>{e.observer.clearSelectionRange(),jye(e)};Eo.compositionstart=Eo.compositionupdate=e=>{e.observer.editContext||(e.inputState.compositionFirstChange==null&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))};Eo.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,$t.chrome&&$t.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))};Eo.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()};wu.beforeinput=(e,t)=>{var n,r;if((t.inputType=="insertText"||t.inputType=="insertCompositionText")&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType=="insertReplacementText"&&e.observer.editContext){let s=(n=t.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),a=t.getTargetRanges();if(s&&a.length){let l=a[0],c=e.posAtDOM(l.startContainer,l.startOffset),u=e.posAtDOM(l.endContainer,l.endOffset);return xQ(e,{from:c,to:u,insert:e.state.toText(s)},null),!0}}let i;if($t.chrome&&$t.android&&(i=Eye.find(s=>s.inputType==t.inputType))&&(e.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var a;(((a=window.visualViewport)===null||a===void 0?void 0:a.height)||0)>s+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return $t.ios&&t.inputType=="deleteContentForward"&&e.observer.flushSoon(),$t.safari&&t.inputType=="insertText"&&e.inputState.composing>=0&&setTimeout(()=>Eo.compositionend(e,t),20),!1};const VY=new Set;function mmt(e){VY.has(e)||(VY.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}const HY=["pre-wrap","normal","pre-line","break-spaces"];let v1=!1;function qY(){v1=!1}class gmt{constructor(t){this.lineWrapping=t,this.doc=Br.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-t-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return HY.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let n=!1;for(let r=0;r-1,c=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=n,this.charWidth=r,this.textHeight=i,this.lineLength=s,c){this.heightSamples={};for(let u=0;u0}set outdated(t){this.flags=(t?2:0)|this.flags&-3}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>gT&&(v1=!0),this.height=t)}replace(t,n,r){return So.of(r)}decomposeLeft(t,n){n.push(this)}decomposeRight(t,n){n.push(this)}applyChanges(t,n,r,i){let s=this,a=r.doc;for(let l=i.length-1;l>=0;l--){let{fromA:c,toA:u,fromB:d,toB:f}=i[l],h=s.lineAt(c,_i.ByPosNoHeight,r.setDoc(n),0,0),m=h.to>=u?h:s.lineAt(u,_i.ByPosNoHeight,r,0,0);for(f+=m.to-u,u=m.to;l>0&&h.from<=i[l-1].toA;)c=i[l-1].fromA,d=i[l-1].fromB,l--,cs*2){let l=t[n-1];l.break?t.splice(--n,1,l.left,null,l.right):t.splice(--n,1,l.left,l.right),r+=1+l.break,i-=l.size}else if(s>i*2){let l=t[r];l.break?t.splice(r,1,l.left,null,l.right):t.splice(r,1,l.left,l.right),r+=2+l.break,s-=l.size}else break;else if(i=s&&a(this.lineAt(0,_i.ByPos,r,i,s))}setMeasuredHeight(t){let n=t.heights[t.index++];n<0?(this.spaceAbove=-n,n=t.heights[t.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(t,n=0,r=!1,i){return i&&i.from<=n&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class vl extends Rye{constructor(t,n,r){super(t,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(t,n){return new lu(n,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof vl||i instanceof Na&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Na?i=new vl(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):So.of(r)}updateHeight(t,n=0,r=!1,i){return i&&i.from<=n&&i.more?this.setMeasuredHeight(i):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Na extends So{constructor(t){super(t,0)}heightMetrics(t,n){let r=t.doc.lineAt(n).number,i=t.doc.lineAt(n+this.length).number,s=i-r+1,a,l=0;if(t.lineWrapping){let c=Math.min(this.height,t.lineHeight*s);a=c/s,this.length>s+1&&(l=(this.height-c)/(this.length-s-1))}else a=this.height/s;return{firstLine:r,lastLine:i,perLine:a,perChar:l}}blockAt(t,n,r,i){let{firstLine:s,lastLine:a,perLine:l,perChar:c}=this.heightMetrics(n,i);if(n.lineWrapping){let u=i+(t0){let s=r[r.length-1];s instanceof Na?r[r.length-1]=new Na(s.length+i):r.push(null,new Na(i-1))}if(t>0){let s=r[0];s instanceof Na?r[0]=new Na(t+s.length):r.unshift(new Na(t-1),null)}return So.of(r)}decomposeLeft(t,n){n.push(new Na(t-1),null)}decomposeRight(t,n){n.push(null,new Na(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let s=n+this.length;if(i&&i.from<=n+this.length&&i.more){let a=[],l=Math.max(n,i.from),c=-1;for(i.from>n&&a.push(new Na(i.from-n-1).updateHeight(t,n));l<=s&&i.more;){let d=t.doc.lineAt(l).length;a.length&&a.push(null);let f=i.heights[i.index++],h=0;f<0&&(h=-f,f=i.heights[i.index++]),c==-1?c=f:Math.abs(f-c)>=gT&&(c=-2);let m=new vl(d,f,h);m.outdated=!1,a.push(m),l+=d+1}l<=s&&a.push(null,new Na(s-l).updateHeight(t,l));let u=So.of(a);return(c<0||Math.abs(u.height-this.height)>=gT||Math.abs(c-this.heightMetrics(t,n).perLine)>=gT)&&(v1=!0),xA(this,u)}else(r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Omt extends So{constructor(t,n,r){super(t.length+n+r.length,t.height+r.height,n|(t.outdated||r.outdated?2:0)),this.left=t,this.right=r,this.size=t.size+r.size}get break(){return this.flags&1}blockAt(t,n,r,i){let s=r+this.left.height;return tl))return u;let d=n==_i.ByPosNoHeight?_i.ByPosNoHeight:_i.ByPos;return c?u.join(this.right.lineAt(l,d,r,a,l)):this.left.lineAt(l,d,r,i,s).join(u)}forEachLine(t,n,r,i,s,a){let l=i+this.left.height,c=s+this.left.length+this.break;if(this.break)t=c&&this.right.forEachLine(t,n,r,l,c,a);else{let u=this.lineAt(c,_i.ByPos,r,i,s);t=t&&u.from<=n&&a(u),n>u.to&&this.right.forEachLine(u.to+1,n,r,l,c,a)}}replace(t,n,r){let i=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(t-i,n-i,r));let s=[];t>0&&this.decomposeLeft(t,s);let a=s.length;for(let l of r)s.push(l);if(t>0&&XY(s,a-1),n=r&&n.push(null)),t>r&&this.right.decomposeLeft(t-r,n)}decomposeRight(t,n){let r=this.left.length,i=r+this.break;if(t>=i)return this.right.decomposeRight(t-i,n);t2*n.size||n.size>2*t.size?So.of(this.break?[t,null,n]:[t,n]):(this.left=xA(this.left,t),this.right=xA(this.right,n),this.setHeight(t.height+n.height),this.outdated=t.outdated||n.outdated,this.size=t.size+n.size,this.length=t.length+this.break+n.length,this)}updateHeight(t,n=0,r=!1,i){let{left:s,right:a}=this,l=n+s.length+this.break,c=null;return i&&i.from<=n+s.length&&i.more?c=s=s.updateHeight(t,n,r,i):s.updateHeight(t,n,r),i&&i.from<=l+a.length&&i.more?c=a=a.updateHeight(t,l,r,i):a.updateHeight(t,l,r),c?this.balanced(s,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function XY(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof Na&&(r=e[t+1])instanceof Na&&e.splice(t-1,3,new Na(n.length+1+r.length))}const xmt=5;class vQ{constructor(t,n){this.pos=t,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof vl?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new vl(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(t,n,r){if(t=xmt)&&this.addLineDeco(i,s,a)}else n>t&&this.span(t,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:t,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=n,this.writtenTot&&this.nodes.push(new vl(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,n){let r=new Na(n-t);return this.oracle.doc.lineAt(t).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof vl)return t;let n=new vl(0,-1,0);return this.nodes.push(n),n}addBlock(t){this.enterLine();let n=t.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,n&&n.endSide>0&&(this.covering=t)}addLineDeco(t,n,r){let i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,t),i.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(t){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof vl)&&!this.isCovered?this.nodes.push(new vl(0,-1,0)):(this.writtenTod.clientHeight||d.scrollWidth>d.clientWidth)&&f.overflow!="visible"){let h=d.getBoundingClientRect();s=Math.max(s,h.left),a=Math.min(a,h.right),l=Math.max(l,h.top),c=Math.min(u==e.parentNode?i.innerHeight:c,h.bottom)}u=f.position=="absolute"||f.position=="fixed"?d.offsetParent:d.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-n.left,right:Math.max(s,a)-n.left,top:l-(n.top+t),bottom:Math.max(l,c)-(n.top+t)}}function Emt(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left0&&t.top0}function kmt(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class FD{constructor(t,n,r,i){this.from=t,this.to=n,this.size=r,this.displaySize=i}static same(t,n){if(t.length!=n.length)return!1;for(let r=0;rtypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new gmt(r),this.stateDeco=YY(n),this.heightMap=So.empty().applyChanges(this.stateDeco,Br.empty,this.heightOracle.setDoc(n.doc),[new Cc(0,0,0,n.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=dn.set(this.lineGaps.map(i=>i.draw(this,!1))),this.scrollParent=t.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let i=r?n.head:n.anchor;if(!t.some(({from:s,to:a})=>i>=s&&i<=a)){let{from:s,to:a}=this.lineBlockAt(i);t.push(new z2(s,a))}}return this.viewports=t.sort((r,i)=>r.from-i.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?WY:new wQ(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(Jx(t,this.scaler))})}update(t,n=null){this.state=t.state;let r=this.stateDeco;this.stateDeco=YY(this.state);let i=t.changedRanges,s=Cc.extendWithRanges(i,vmt(r,this.stateDeco,t?t.changes:Js.empty(this.state.doc.length))),a=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);qY(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=a||v1)&&(t.flags|=2),l?(this.scrollAnchorPos=t.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let c=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(n&&(n.range.headc.to)||!this.viewportIsAppropriate(c))&&(c=this.getViewport(0,n));let u=c.from!=this.viewport.from||c.to!=this.viewport.to;this.viewport=c,t.flags|=this.updateForViewport(),(u||!t.changes.empty||t.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(t.selectionSet||t.focusChanged)&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(dye)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:t}=this,n=t.contentDOM,r=window.getComputedStyle(n),i=this.heightOracle,s=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?xi.RTL:xi.LTR;let a=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=n.getBoundingClientRect(),c=a||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,d=0;if(l.width&&l.height){let{scaleX:S,scaleY:E}=Xbe(n,l);(S>.005&&Math.abs(this.scaleX-S)>.005||E>.005&&Math.abs(this.scaleY-E)>.005)&&(this.scaleX=S,this.scaleY=E,u|=16,a=c=!0)}let f=(parseInt(r.paddingTop)||0)*this.scaleY,h=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=h)&&(this.paddingTop=f,this.paddingBottom=h,u|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(i.lineWrapping&&(c=!0),this.editorWidth=t.scrollDOM.clientWidth,u|=16);let m=Gbe(this.view.contentDOM,!1).y;m!=this.scrollParent&&(this.scrollParent=m,this.scrollAnchorHeight=-1,this.scrollOffset=0);let g=this.getScrollOffset();this.scrollOffset!=g&&(this.scrollAnchorHeight=-1,this.scrollOffset=g),this.scrolledToBottom=Ybe(this.scrollParent||t.win);let b=(this.printing?kmt:Smt)(n,this.paddingTop),y=b.top-this.pixelViewport.top,O=b.bottom-this.pixelViewport.bottom;this.pixelViewport=b;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(c=!0)),!this.inView&&!this.scrollTarget&&!Emt(t.dom))return 0;let x=l.width;if((this.contentDOMWidth!=x||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=t.scrollDOM.clientHeight,u|=16),c){let S=t.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(S)&&(a=!0),a||i.lineWrapping&&Math.abs(x-this.contentDOMWidth)>i.charWidth){let{lineHeight:E,charWidth:k,textHeight:_}=t.docView.measureTextSize();a=E>0&&i.refresh(s,E,k,_,Math.max(5,x/k),S),a&&(t.docView.minWidth=0,u|=16)}y>0&&O>0?d=Math.max(y,O):y<0&&O<0&&(d=Math.min(y,O)),qY();for(let E of this.viewports){let k=E.from==this.viewport.from?S:t.docView.measureVisibleLineHeights(E);this.heightMap=(a?So.empty().applyChanges(this.stateDeco,Br.empty,this.heightOracle,[new Cc(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(i,0,a,new bmt(E.from,k))}v1&&(u|=2)}let w=!this.viewportIsAppropriate(this.viewport,d)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return w&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(d,this.scrollTarget),u|=this.updateForViewport()),(u&2||w)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,t)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,n){let r=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),i=this.heightMap,s=this.heightOracle,{visibleTop:a,visibleBottom:l}=this,c=new z2(i.lineAt(a-r*1e3,_i.ByHeight,s,0,0).from,i.lineAt(l+(1-r)*1e3,_i.ByHeight,s,0,0).to);if(n){let{head:u}=n.range;if(uc.to){let d=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=i.lineAt(u,_i.ByPos,s,0,0),h;n.y=="center"?h=(f.top+f.bottom)/2-d/2:n.y=="start"||n.y=="nearest"&&u=l+Math.max(10,Math.min(r,250)))&&i>a-2*1e3&&s>1,a=i<<1;if(this.defaultTextDirection!=xi.LTR&&!r)return[];let l=[],c=(d,f,h,m)=>{if(f-dd&&OO.from>=h.from&&O.to<=h.to&&Math.abs(O.from-d)O.fromv));if(!y){if(fx.from<=f&&x.to>=f)){let x=n.moveToLineBoundary(Je.cursor(f),!1,!0).head;x>d&&(f=x)}let O=this.gapSize(h,d,f,m),v=r||O<2e6?O:2e6;y=new FD(d,f,O,v)}l.push(y)},u=d=>{if(d.length2e6)for(let E of t)E.from>=d.from&&E.fromd.from&&c(d.from,m,d,f),gn.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];gr.spans(n,this.viewport.from,this.viewport.to,{span(s,a){r.push({from:s,to:a})},point(){}},20);let i=0;if(r.length!=this.visibleRanges.length)i=12;else for(let s=0;s=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(n=>n.from<=t&&n.to>=t)||Jx(this.heightMap.lineAt(t,_i.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=t&&n.bottom>=t)||Jx(this.heightMap.lineAt(this.scaler.fromDOM(t),_i.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(t){let n=this.lineBlockAtHeight(t+8);return n.from>=this.viewport.from||this.viewportLines[0].top-t>200?n:this.viewportLines[0]}elementAtHeight(t){return Jx(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class z2{constructor(t,n){this.from=t,this.to=n}}function Tmt(e,t,n){let r=[],i=e,s=0;return gr.spans(n,e,t,{span(){},point(a,l){a>i&&(r.push({from:i,to:a}),s+=a-i),i=l}},20),i=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let i=0;;i++){let{from:s,to:a}=t[i],l=a-s;if(r<=l)return s+r;r-=l}}function H2(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function Cmt(e,t){for(let n of e)if(t(n))return n}const WY={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function YY(e){let t=e.facet(Jj).filter(r=>typeof r!="function"),n=e.facet(yQ).filter(r=>typeof r!="function");return n.length&&t.push(gr.join(n)),t}class wQ{constructor(t,n,r){let i=0,s=0,a=0;this.viewports=r.map(({from:l,to:c})=>{let u=n.lineAt(l,_i.ByPos,t,0,0).top,d=n.lineAt(c,_i.ByPos,t,0,0).bottom;return i+=d-u,{from:l,to:c,top:u,bottom:d,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(n.height-i);for(let l of this.viewports)l.domTop=a+(l.top-s)*this.scale,a=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(t){for(let n=0,r=0,i=0;;n++){let s=nn.from==t.viewports[r].from&&n.to==t.viewports[r].to):!1}}function Jx(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new lu(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(i=>Jx(i,t)):e._content)}const q2=Qt.define({combine:e=>e.join(" ")}),s6=Qt.define({combine:e=>e.indexOf(!0)>-1}),a6=Jp.newName(),Iye=Jp.newName(),Dye=Jp.newName(),Pye={"&light":"."+Iye,"&dark":"."+Dye};function o6(e,t,n){return new Jp(t,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return e;if(!n||!n[i])throw new RangeError(`Unsupported selector: ${i}`);return n[i]}):e+" "+r}})}const Amt=o6("."+a6,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Pye),Nmt={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},zD=$t.ie&&$t.ie_version<=11;class jmt{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new apt,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);($t.ie&&$t.ie_version<=11||$t.ios&&t.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&$t.android&&t.constructor.EDIT_CONTEXT!==!1&&!($t.chrome&&$t.chrome_version<126)&&(this.editContext=new Imt(t),t.state.facet(xf)&&(t.contentDOM.editContext=this.editContext.editContext)),zD&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){(t.type=="change"||!t.type)&&!t.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((n,r)=>n!=t[r]))){this.gapIntersection.disconnect();for(let n of t)this.gapIntersection.observe(n);this.gaps=t}}onSelectionChange(t){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,i=this.selectionRange;if(r.state.facet(xf)?r.root.activeElement!=this.dom:!Hv(this.dom,i))return;let s=i.anchorNode&&r.docView.tile.nearest(i.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(t)){n||(this.selectionChanged=!1);return}($t.ie&&$t.ie_version<=11||$t.android&&$t.chrome)&&!r.state.selection.main.empty&&i.focusNode&&Xv(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,n=sS(t.root);if(!n)return!1;let r=$t.safari&&t.root.nodeType==11&&t.root.activeElement==this.dom&&Rmt(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=Hv(this.dom,r);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&_y(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||t=="Enter")&&(this.delayedAndroidKey={key:t,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let n=-1,r=-1,i=!1;for(let s of t){let a=this.readMutation(s);a&&(a.typeOver&&(i=!0),n==-1?{from:n,to:r}=a:(n=Math.min(a.from,n),r=Math.max(a.to,r)))}return{from:n,to:r,typeOver:i}}readChange(){let{from:t,to:n,typeOver:r}=this.processRecords(),i=this.selectionChanged&&Hv(this.dom,this.selectionRange);if(t<0&&!i)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Wpt(this.view,t,n,r);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=wye(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!OA(this.view.state.selection,n.newSel.main))&&this.view.update([]),i}readMutation(t){let n=this.view.docView.tile.nearest(t.target);if(!n||n.isWidget())return null;if(n.markDirty(t.type=="attributes"),t.type=="childList"){let r=ZY(n,t.previousSibling||t.target.previousSibling,-1),i=ZY(n,t.nextSibling||t.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:i?n.posBefore(i):n.posAtEnd,typeOver:!1}}else return t.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(xf)!=t.state.facet(xf)&&(t.view.contentDOM.editContext=t.state.facet(xf)?this.editContext.editContext:null))}destroy(){var t,n,r;this.stop(),(t=this.intersection)===null||t===void 0||t.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function ZY(e,t,n){for(;t;){let r=hs.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i!=e.dom?i:n>0?t.nextSibling:t.previousSibling}return null}function KY(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,s=t.endOffset,a=e.docView.domAtPos(e.state.selection.main.anchor,1);return Xv(a.node,a.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function Rmt(e,t){if(t.getComposedRanges){let i=t.getComposedRanges(e.root)[0];if(i)return KY(e,i)}let n=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",r,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",r,!0),n?KY(e,n):null}class Imt{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let n=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=r=>{let i=t.state.selection.main,{anchor:s,head:a}=i,l=this.toEditorPos(r.updateRangeStart),c=this.toEditorPos(r.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:l,drifted:!1});let u=c-l>r.text.length;l==this.from&&sthis.to&&(c=s);let d=Sye(t.state.sliceDoc(l,c),r.text,(u?i.from:i.to)-l,u?"end":null);if(!d){let h=Je.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));OA(h,i)||t.dispatch({selection:h,userEvent:"select"});return}let f={from:d.from+l,to:d.toA+l,insert:Br.of(r.text.slice(d.from,d.toB).split(` `))};if(($t.mac||$t.android)&&f.from==a-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:c,insert:Br.of([r.text.replace("."," ")])}),this.pendingContextChange=f,!t.state.readOnly){let h=this.to-this.from+(f.to-f.from+f.insert.length);xQ(t,f,Je.single(this.toEditorPos(r.selectionStart,h),this.toEditorPos(r.selectionEnd,h)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),f.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let i=[],s=null;for(let a=this.toEditorPos(r.rangeStart),l=this.toEditorPos(r.rangeEnd);a{let i=[];for(let s of r.getTextFormats()){let a=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(a)&&!/none/i.test(l)){let c=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(c{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(t.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let i=sS(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let n=0,r=!1,i=this.pendingContextChange;return t.changes.iterChanges((s,a,l,c,u)=>{if(r)return;let d=u.length-(a-s);if(i&&a>=i.to)if(i.from==s&&i.to==a&&i.insert.eq(u)){i=this.pendingContextChange=null,n+=d,this.to+=d;return}else i=null,this.revertPending(t.state);if(s+=n,a+=n,a<=this.from)this.from+=d,this.to+=d;else if(sthis.to||this.to-this.from+u.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(a),u.toString()),this.to+=d}n+=d}),i&&!r&&this.revertPending(t.state),!r}update(t){let n=this.pendingContextChange,r=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(r.from,r.to)&&t.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||n)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:n}=t.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(t.doc.length,n+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),t.doc.sliceString(n.from,n.to))}setSelection(t){let{main:n}=t.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(t){let{head:n}=t.selection.main;return!(this.from>0&&n-this.from<500||this.to1e4*3)}toEditorPos(t,n=this.to-this.from){t=Math.min(t,n);let r=this.composing;return r&&r.drifted?r.editorBase+(t-r.contextBase):t+this.from}toContextPos(t){let n=this.composing;return n&&n.drifted?n.contextBase+(t-n.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class Ct{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:r}=t;this.dispatchTransactions=t.dispatchTransactions||r&&(i=>i.forEach(s=>r(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=t.root||opt(t.parent)||document,this.viewState=new GY(this,t.state||vr.create(t)),t.scrollTo&&t.scrollTo.is(Q2)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Kb).map(i=>new LD(i));for(let i of this.plugins)i.update(this);this.observer=new jmt(this),this.inputState=new Jpt(this),this.inputState.ensureHandlers(this.plugins),this.docView=new PY(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...t){let n=t.length==1&&t[0]instanceof Vs?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(n,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,s=this.state;for(let h of t){if(h.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=h.state}if(this.destroyed){this.viewState.state=s;return}let a=this.hasFocus,l=0,c=null;t.some(h=>h.annotation(Aye))?(this.inputState.notifiedFocused=a,l=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,c=Nye(s,a),c||(l=1));let u=this.observer.delayedAndroidKey,d=null;if(u?(this.observer.clearDelayedAndroidKey(),d=this.observer.readChange(),(d&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(d=null)):this.observer.clear(),s.facet(vr.phrases)!=this.state.facet(vr.phrases))return this.setState(s);i=gA.create(this,s,t),i.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let h of t){if(f&&(f=f.map(h.changes)),h.scrollIntoView){let{main:m}=h.state.selection,{x:g,y:b}=this.state.facet(Ct.cursorScrollMargin);f=new Ty(m.empty?m:Je.cursor(m.head,m.head>m.anchor?-1:1),"nearest","nearest",b,g)}for(let m of h.effects)m.is(Q2)&&(f=m.value.clip(this.state))}this.viewState.update(i,f),this.bidiCache=vA.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Kx)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(q2)!=i.state.facet(q2)&&(this.viewState.mustMeasureContent=!0),(n||r||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let h of this.state.facet(e6))try{h(i)}catch(m){Go(this.state,m,"update listener")}(c||d)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),d&&!wye(this,d)&&u.force&&_y(this.contentDOM,u.key,u.keyCode)})}setState(t){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new GY(this,t),this.plugins=t.facet(Kb).map(r=>new LD(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new PY(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(t){let n=t.startState.facet(Kb),r=t.state.facet(Kb);if(n!=r){let i=[];for(let s of r){let a=n.indexOf(s);if(a<0)i.push(new LD(s));else{let l=this.plugins[a];l.mustUpdate=t,i.push(l)}}for(let s of this.plugins)s.mustUpdate!=t&&s.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=t;for(let i=0;i-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:a}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(a<0)if(Ybe(r||this.win))s=-1,a=this.viewState.heightMap.height;else{let m=this.viewState.scrollAnchorAt(i);s=m.from,a=m.top}this.updateState=1;let c=this.viewState.measure();if(!c&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];c&4||([this.measureRequests,u]=[u,this.measureRequests]);let d=u.map(m=>{try{return m.read(this)}catch(g){return Go(this.state,g),JY}}),f=gA.create(this,this.state,[]),h=!1;f.flags|=c,n?n.flags|=c:n=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),h=this.docView.update(f),h&&this.docViewUpdate());for(let m=0;m1||g<-1)&&!($t.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i=i+g,r?r.scrollTop+=g:this.win.scrollBy(0,g),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let l of this.state.facet(e6))l(n)}get themeClasses(){return a6+" "+(this.state.facet(s6)?Dye:Iye)+" "+this.state.facet(q2)}updateAttrs(){let t=eZ(this,pye,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(xf)?"true":"false",class:"cm-content",style:`${$t.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),eZ(this,bQ,n);let r=this.observer.ignore(()=>{let i=AY(this.contentDOM,this.contentAttrs,n),s=AY(this.dom,this.editorAttrs,t);return i||s});return this.editorAttrs=t,this.contentAttrs=n,r}showAnnouncements(t){let n=!0;for(let r of t)for(let i of r.effects)if(i.is(Ct.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(Kx);let t=this.state.facet(Ct.cspNonce);Jp.mount(this.root,this.styleModules.concat(Amt).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let n=0;nr.plugin==t)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,n,r){return UD(this,t,MY(this,t,n,r))}moveByGroup(t,n){return UD(this,t,MY(this,t,n,r=>zpt(this,t.head,r)))}visualLineSide(t,n){let r=this.bidiSpans(t),i=this.textDirectionAt(t.from),s=r[n?r.length-1:0];return Je.cursor(s.side(n,i)+t.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return Fpt(this,t,n,r)}moveVertically(t,n,r){return UD(this,t,Vpt(this,t,n,r))}domAtPos(t,n=1){return this.docView.domAtPos(t,n)}posAtDOM(t,n=0){return this.docView.posFromDOM(t,n)}posAtCoords(t,n=!0){this.readMeasured();let r=r6(this,t,n);return r&&r.pos}posAndSideAtCoords(t,n=!0){return this.readMeasured(),r6(this,t,n)}coordsAtPos(t,n=1){this.readMeasured();let r=this.state.doc.lineAt(t),i=this.bidiSpans(r),s=i[id.find(i,t-r.from,-1,n)];return this.docView.coordsAt(t,n,s.dir==xi.RTL)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(uye)||tthis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Dmt)return nye(t.length);let n=this.textDirectionAt(t.from),r;for(let s of this.bidiCache)if(s.from==t.from&&s.dir==n&&(s.fresh||tye(s.isolates,r=RY(this,t))))return s.order;r||(r=RY(this,t));let i=mpt(t.text,n,r);return this.bidiCache.push(new vA(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||$t.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Wbe(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,n={}){var r,i,s,a;return Q2.of(new Ty(typeof t=="number"?Je.cursor(t):t,(r=n.y)!==null&&r!==void 0?r:"nearest",(i=n.x)!==null&&i!==void 0?i:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(a=n.xMargin)!==null&&a!==void 0?a:5))}scrollSnapshot(){let{scrollTop:t,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(t);return Q2.of(new Ty(Je.cursor(r.from),"start","start",r.top-t,n,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return ps.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return ps.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=Jp.newName(),i=[q2.of(r),Kx.of(o6(`.${r}`,t))];return n&&n.dark&&i.push(s6.of(!0)),i}static baseTheme(t){return xh.lowest(Kx.of(o6("."+a6,t,Pye)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&hs.get(r)||hs.get(t);return((n=i==null?void 0:i.root)===null||n===void 0?void 0:n.view)||null}}Ct.styleModule=Kx;Ct.inputHandler=lye;Ct.clipboardInputFilter=mQ;Ct.clipboardOutputFilter=gQ;Ct.scrollHandler=fye;Ct.focusChangeEffect=cye;Ct.perLineTextDirection=uye;Ct.exceptionSink=oye;Ct.updateListener=e6;Ct.editable=xf;Ct.mouseSelectionStyle=aye;Ct.dragMovesSelection=sye;Ct.clickAddsSelectionRange=iye;Ct.decorations=Jj;Ct.blockWrappers=mye;Ct.outerDecorations=yQ;Ct.atomicRanges=$E;Ct.bidiIsolatedRanges=gye;Ct.cursorScrollMargin=Qt.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r=="number"?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}});Ct.scrollMargins=bye;Ct.darkTheme=s6;Ct.cspNonce=Qt.define({combine:e=>e.length?e[0]:""});Ct.contentAttributes=bQ;Ct.editorAttributes=pye;Ct.lineWrapping=Ct.contentAttributes.of({class:"cm-lineWrapping"});Ct.announce=jn.define();const Dmt=4096,JY={};class vA{constructor(t,n,r,i,s,a){this.from=t,this.to=n,this.dir=r,this.isolates=i,this.fresh=s,this.order=a}static update(t,n){if(n.empty&&!t.some(s=>s.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:xi.LTR;for(let s=Math.max(0,t.length-10);s=0;i--){let s=r[i],a=typeof s=="function"?s(e):s;a&&fQ(a,n)}return n}const Pmt=$t.mac?"mac":$t.windows?"win":$t.linux?"linux":"key";function Mmt(e,t){const n=e.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,s,a,l;for(let c=0;cr.concat(i),[]))),n}function $mt(e,t,n){return Lye(Mye(e.state),t,e,n)}let ap=null;const Bmt=4e3;function Qmt(e,t=Pmt){let n=Object.create(null),r=Object.create(null),i=(a,l)=>{let c=r[a];if(c==null)r[a]=l;else if(c!=l)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},s=(a,l,c,u,d)=>{var f,h;let m=n[a]||(n[a]=Object.create(null)),g=l.split(/ (?!$)/).map(O=>Mmt(O,t));for(let O=1;O{let w=ap={view:x,prefix:v,scope:a};return setTimeout(()=>{ap==w&&(ap=null)},Bmt),!0}]})}let b=g.join(" ");i(b,!1);let y=m[b]||(m[b]={preventDefault:!1,stopPropagation:!1,run:((h=(f=m._any)===null||f===void 0?void 0:f.run)===null||h===void 0?void 0:h.slice())||[]});c&&y.run.push(c),u&&(y.preventDefault=!0),d&&(y.stopPropagation=!0)};for(let a of e){let l=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let u of l){let d=n[u]||(n[u]=Object.create(null));d._any||(d._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=a;for(let h in d)d[h].run.push(m=>f(m,l6))}let c=a[t]||a.key;if(c)for(let u of l)s(u,c,a.run,a.preventDefault,a.stopPropagation),a.shift&&s(u,"Shift-"+c,a.shift,a.preventDefault,a.stopPropagation)}return n}let l6=null;function Lye(e,t,n,r){l6=t;let i=ept(t),s=Uo(i,0),a=Yu(s)==i.length&&i!=" ",l="",c=!1,u=!1,d=!1;ap&&ap.view==n&&ap.scope==r&&(l=ap.prefix+" ",kye.indexOf(t.keyCode)<0&&(u=!0,ap=null));let f=new Set,h=y=>{if(y){for(let O of y.run)if(!f.has(O)&&(f.add(O),O(n)))return y.stopPropagation&&(d=!0),!0;y.preventDefault&&(y.stopPropagation&&(d=!0),u=!0)}return!1},m=e[r],g,b;return m&&(h(m[l+X2(i,t,!a)])?c=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!($t.windows&&t.ctrlKey&&t.altKey)&&!($t.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(g=em[t.keyCode])&&g!=i?(h(m[l+X2(g,t,!0)])||t.shiftKey&&(b=rS[t.keyCode])!=i&&b!=g&&h(m[l+X2(b,t,!1)]))&&(c=!0):a&&t.shiftKey&&h(m[l+X2(i,t,!0)])&&(c=!0),!c&&h(m._any)&&(c=!0)),u&&(c=!0),c&&d&&t.stopPropagation(),l6=null,c}class kg{constructor(t,n,r,i,s){this.className=t,this.left=n,this.top=r,this.width=i,this.height=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,n){return n.className!=this.className?!1:(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width!=null&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let s=$ye(t);return[new kg(n,i.left-s.left,i.top-s.top,null,i.bottom-i.top)]}else return Umt(t,n,r)}}function $ye(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==xi.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function nZ(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let s=e.dom.getBoundingClientRect(),a=(i.top+i.bottom)/2,l=e.posAtCoords({x:s.left+1,y:a}),c=e.posAtCoords({x:s.right-1,y:a});return l==null||c==null?r:{from:Math.max(r.from,Math.min(l,c)),to:Math.min(r.to,Math.max(l,c))}}function Umt(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),s=e.textDirection==xi.LTR,a=e.contentDOM,l=a.getBoundingClientRect(),c=$ye(e),u=a.querySelector(".cm-line"),d=u&&window.getComputedStyle(u),f=l.left+(d?parseInt(d.paddingLeft)+Math.min(0,parseInt(d.textIndent)):0),h=l.right-(d?parseInt(d.paddingRight):0),m=n6(e,r,1),g=n6(e,i,-1),b=m.type==Ba.Text?m:null,y=g.type==Ba.Text?g:null;if(b&&(e.lineWrapping||m.widgetLineBreaks)&&(b=nZ(e,r,1,b)),y&&(e.lineWrapping||g.widgetLineBreaks)&&(y=nZ(e,i,-1,y)),b&&y&&b.from==y.from&&b.to==y.to)return v(x(n.from,n.to,b));{let S=b?x(n.from,null,b):w(m,!1),E=y?x(null,n.to,y):w(g,!0),k=[];return(b||m).to<(y||g).from-(b&&y?1:0)||m.widgetLineBreaks>1&&S.bottom+e.defaultLineHeight/2j&&I.from=N)break;$>M&&A(Math.max(F,M),S==null&&F<=j,Math.min($,N),E==null&&$>=L,Q.dir)}if(M=D.to+1,M>=N)break}return T.length==0&&A(j,S==null,L,E==null,e.textDirection),{top:_,bottom:C,horizontal:T}}function w(S,E){let k=l.top+(E?S.top:S.bottom);return{top:k,bottom:k,horizontal:[]}}}function Fmt(e,t){return e.constructor==t.constructor&&e.eq(t)}class zmt{constructor(t,n){this.view=t,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,t)}update(t){t.startState.facet(bT)!=t.state.facet(bT)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){this.layer.updateOnDocViewUpdate!==!1&&t.requestMeasure(this.measureReq)}setOrder(t){let n=0,r=t.facet(bT);for(;n!Fmt(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let i of t)i.update&&n&&i.constructor&&this.drawn[r].constructor&&i.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(i.draw(),n);for(;n;){let i=n.nextSibling;n.remove(),n=i}this.drawn=t,$t.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const bT=Qt.define();function Bye(e){return[ps.define(t=>new zmt(t,e)),bT.of(e)]}const w1=Qt.define({combine(e){return Nd(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function Vmt(e={}){return[w1.of(e),Hmt,qmt,Xmt,dye.of(!0)]}function Qye(e){return e.startState.facet(w1)!=e.state.facet(w1)}const Hmt=Bye({above:!0,markers(e){let{state:t}=e,n=t.facet(w1),r=[];for(let i of t.selection.ranges){let s=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(s&&$t.ios&&n.iosSelectionHandles)){let a=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=i.empty?i:Je.cursor(i.head,i.assoc);for(let c of kg.forRange(e,a,l))r.push(c)}}return r},update(e,t){e.transactions.some(r=>r.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Qye(e);return n&&rZ(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){rZ(t.state,e)},class:"cm-cursorLayer"});function rZ(e,t){t.style.animationDuration=e.facet(w1).cursorBlinkRate+"ms"}const qmt=Bye({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let i of r)if(!i.empty)for(let s of kg.forRange(e,"cm-selectionBackground",i))t.push(s);if($t.ios&&!n.empty&&e.state.facet(w1).iosSelectionHandles){for(let i of kg.forRange(e,"cm-selectionHandle cm-selectionHandle-start",Je.cursor(n.from,1)))t.push(i);for(let i of kg.forRange(e,"cm-selectionHandle cm-selectionHandle-end",Je.cursor(n.to,1)))t.push(i)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||Qye(e)},class:"cm-selectionLayer"}),Xmt=xh.highest(Ct.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Uye=jn.define({map(e,t){return e==null?null:t.mapPos(e)}}),ev=Qa.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(Uye)?r.value:n,e)}}),Gmt=ps.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(ev);n==null?this.cursor!=null&&((t=this.cursor)===null||t===void 0||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(ev)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(ev),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(ev)!=e&&this.view.dispatch({effects:Uye.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Wmt(){return[ev,Gmt]}function iZ(e,t,n,r,i){t.lastIndex=0;for(let s=e.iterRange(n,r),a=n,l;!s.next().done;a+=s.value.length)if(!s.lineBreak)for(;l=t.exec(s.value);)i(a+l.index,l)}function Ymt(e,t){let n=e.visibleRanges;if(n.length==1&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let r=[];for(let{from:i,to:s}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),s=Math.min(e.state.doc.lineAt(s).to,s+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=s:r.push({from:i,to:s});return r}class Zmt{constructor(t){const{regexp:n,decoration:r,decorate:i,boundary:s,maxLength:a=1e3}=t;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,i)this.addMatch=(l,c,u,d)=>i(d,u,u+l[0].length,l,c);else if(typeof r=="function")this.addMatch=(l,c,u,d)=>{let f=r(l,c,u);f&&d(u,u+l[0].length,f)};else if(r)this.addMatch=(l,c,u,d)=>d(u,u+l[0].length,r);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=a}createDeco(t){let n=new sh,r=n.add.bind(n);for(let{from:i,to:s}of Ymt(t,this.maxLength))iZ(t.state.doc,this.regexp,i,s,(a,l)=>this.addMatch(l,t,a,r));return n.finish()}updateDeco(t,n){let r=1e9,i=-1;return t.docChanged&&t.changes.iterChanges((s,a,l,c)=>{c>=t.view.viewport.from&&l<=t.view.viewport.to&&(r=Math.min(l,r),i=Math.max(c,i))}),t.viewportMoved||i-r>1e3?this.createDeco(t.view):i>-1?this.updateRange(t.view,n.map(t.changes),r,i):n}updateRange(t,n,r,i){for(let s of t.visibleRanges){let a=Math.max(s.from,r),l=Math.min(s.to,i);if(l>=a){let c=t.state.doc.lineAt(a),u=c.toc.from;a--)if(this.boundary.test(c.text[a-1-c.from])){d=a;break}for(;lh.push(O.range(b,y));if(c==u)for(this.regexp.lastIndex=d-c.from;(m=this.regexp.exec(c.text))&&m.indexthis.addMatch(y,t,b,g));n=n.update({filterFrom:d,filterTo:f,filter:(b,y)=>bf,add:h})}}return n}}const c6=/x/.unicode!=null?"gu":"g",Kmt=new RegExp(`[\0-\b ---Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,c6),Jmt={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let VD=null;function egt(){var e;if(VD==null&&typeof document<"u"&&document.body){let t=document.body.style;VD=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return VD||!1}const yT=Qt.define({combine(e){let t=Nd(e,{render:null,specialChars:Kmt,addSpecialChars:null});return(t.replaceTabs=!egt())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,c6)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,c6)),t}});function tgt(e={}){return[yT.of(e),ngt()]}let sZ=null;function ngt(){return sZ||(sZ=ps.fromClass(class{constructor(e){this.view=e,this.decorations=dn.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(yT)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Zmt({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,s=Uo(t[0],0);if(s==9){let a=i.lineAt(r),l=n.state.tabSize,c=vu(a.text,l,r-a.from);return dn.replace({widget:new agt((l-c%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=dn.replace({widget:new sgt(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(yT);e.startState.facet(yT)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))}const rgt="•";function igt(e){return e>=32?rgt:e==10?"␤":String.fromCharCode(9216+e)}class sgt extends Nu{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=igt(this.code),r=t.state.phrase("Control character")+" "+(Jmt[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,r,n);if(i)return i;let s=document.createElement("span");return s.textContent=n,s.title=r,s.setAttribute("aria-label",r),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class agt extends Nu{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function ogt(){return cgt}const lgt=dn.line({class:"cm-activeLine"}),cgt=ps.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(lgt.range(i.from)),t=i.from)}return dn.set(n)}},{decorations:e=>e.decorations});class ugt extends Nu{constructor(t){super(),this.content=t}toDOM(t){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(t){let n=t.firstChild?qv(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=aS(n[0],r.direction!="rtl"),s=parseInt(r.lineHeight);return i.bottom-i.top>s*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+s}:i}ignoreEvent(){return!1}}function dgt(e){let t=ps.fromClass(class{constructor(n){this.view=n,this.placeholder=e?dn.set([dn.widget({widget:new ugt(e),side:1}).range(0)]):dn.none}get decorations(){return this.view.state.doc.length?dn.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,Ct.contentAttributes.of({"aria-placeholder":e})]:t}const u6=2e3;function fgt(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),s=[];if(t.off>u6||n.off>u6||t.col<0||n.col<0){let a=Math.min(t.off,n.off),l=Math.max(t.off,n.off);for(let c=r;c<=i;c++){let u=e.doc.line(c);u.length<=l&&s.push(Je.range(u.from+a,u.to+l))}}else{let a=Math.min(t.col,n.col),l=Math.max(t.col,n.col);for(let c=r;c<=i;c++){let u=e.doc.line(c),d=zL(u.text,a,e.tabSize,!0);if(d<0)s.push(Je.cursor(u.to));else{let f=zL(u.text,l,e.tabSize);s.push(Je.range(u.from+d,u.from+f))}}}return s}function hgt(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function aZ(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,s=i>u6?-1:i==r.length?hgt(e,t.clientX):vu(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:s,off:i}}function pgt(e,t){let n=aZ(e,t),r=e.state.selection;return n?{update(i){if(i.docChanged){let s=i.changes.mapPos(i.startState.doc.line(n.line).from),a=i.state.doc.lineAt(s);n={line:a.number,col:n.col,off:Math.min(n.off,a.length)},r=r.map(i.changes)}},get(i,s,a){let l=aZ(e,i);if(!l)return r;let c=fgt(e.state,n,l);return c.length?a?Je.create(c.concat(r.ranges)):Je.create(c):r}}:null}function mgt(e){let t=n=>n.altKey&&n.button==0;return Ct.mouseSelectionStyle.of((n,r)=>t(r)?pgt(n,r):null)}const ggt={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},bgt={style:"cursor: crosshair"};function ygt(e={}){let[t,n]=ggt[e.key||"Alt"],r=ps.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==t||n(i))},keyup(i){(i.keyCode==t||!n(i))&&this.set(!1)},mousemove(i){this.set(n(i))}}});return[r,Ct.contentAttributes.of(i=>{var s;return!((s=i.plugin(r))===null||s===void 0)&&s.isDown?bgt:null})]}const G2="-10000px";class Fye{constructor(t,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=t.state.facet(n),this.tooltips=this.input.filter(a=>a);let s=null;this.tooltipViews=this.tooltips.map(a=>s=r(a,s))}update(t,n){var r;let i=t.state.facet(this.facet),s=i.filter(c=>c);if(i===this.input){for(let c of this.tooltipViews)c.update&&c.update(t);return!1}let a=[],l=n?[]:null;for(let c=0;cn[u]=c),n.length=l.length),this.input=i,this.tooltips=s,this.tooltipViews=a,!0}}function Ogt(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const HD=Qt.define({combine:e=>{var t,n,r;return{position:$t.ios?"absolute":((t=e.find(i=>i.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((n=e.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=e.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||Ogt}}}),oZ=new WeakMap,SQ=ps.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(HD);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Fye(e,EQ,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(HD);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=G2,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(e=r.destroy)===null||e===void 0||e.call(r);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if($t.safari){let a=s.getBoundingClientRect();n=Math.abs(a.top+1e4)>1||Math.abs(a.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(e=s.width/this.parent.offsetWidth,t=s.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=OQ(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,a)=>{let l=this.manager.tooltipViews[a];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(HD).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:s}=e,a=[];for(let l=0;l=Math.min(n.bottom,r.bottom)||f.rightMath.min(n.right,r.right)+.1)){d.style.top=G2;continue}let m=c.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,g=m?7:0,b=h.right-h.left,y=(t=oZ.get(u))!==null&&t!==void 0?t:h.bottom-h.top,O=u.offset||vgt,v=this.view.textDirection==xi.LTR,x=h.width>r.right-r.left?v?r.left:r.right-h.width:v?Math.max(r.left,Math.min(f.left-(m?14:0)+O.x,r.right-b)):Math.min(Math.max(r.left,f.left-b+(m?14:0)-O.x),r.right-b),w=this.above[l];!c.strictSide&&(w?f.top-y-g-O.yr.bottom)&&w==r.bottom-f.bottom>f.top-r.top&&(w=this.above[l]=!w);let S=(w?f.top-r.top:r.bottom-f.bottom)-g;if(Sx&&_.topE&&(E=w?_.top-y-2-g:_.bottom+g+2);if(this.position=="absolute"?(d.style.top=(E-e.parent.top)/s+"px",lZ(d,(x-e.parent.left)/i)):(d.style.top=E/s+"px",lZ(d,x/i)),m){let _=f.left+(v?O.x:-O.x)-(x+14-7);m.style.left=_/i+"px"}u.overlap!==!0&&a.push({left:x,top:E,right:k,bottom:E+y}),d.classList.toggle("cm-tooltip-above",w),d.classList.toggle("cm-tooltip-below",!w),u.positioned&&u.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=G2}},{eventObservers:{scroll(){this.maybeMeasure()}}});function lZ(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const xgt=Ct.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),vgt={x:0,y:0},EQ=Qt.define({enables:[SQ,xgt]}),wA=Qt.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class rR{static create(t){return new rR(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Fye(t,wA,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(t,n){let r=t.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(t){for(let n of this.manager.tooltipViews)n.mount&&n.mount(t);this.mounted=!0}positioned(t){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let n of this.manager.tooltipViews)(t=n.destroy)===null||t===void 0||t.call(n)}passProp(t){let n;for(let r of this.manager.tooltipViews){let i=r[t];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const wgt=EQ.compute([wA],e=>{let t=e.facet(wA);return t.length===0?null:{pos:Math.min(...t.map(n=>n.pos)),end:Math.max(...t.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:rR.create,above:t[0].above,arrow:t.some(n=>n.arrow)}}),zye=Qt.define();class Sgt{constructor(t,n,r,i,s,a){this.view=t,this.source=n,this.field=r,this.locked=i,this.setHover=s,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(t){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;ta.bottom||n.xa.right+t.defaultCharacterWidth)return;let l=t.bidiSpans(t.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),c=l&&l.dir==xi.RTL?-1:1;s=n.x{if(l&&!(Array.isArray(l)&&!l.length)){let c=Array.isArray(l)?l:[l];i&&this.locked.set(c,i),t.dispatch({effects:this.setHover.of(c)})}};if(s&&"then"in s){let l=this.pending={pos:n};s.then(c=>{this.pending==l&&(this.pending=null,a(c))},c=>Go(t.state,c,"hover tooltip"))}else a(s)}get tooltip(){let t=this.view.plugin(SQ),n=t?t.manager.tooltips.findIndex(r=>r.create==rR.create):-1;return n>-1?t.manager.tooltipViews[n]:null}mousemove(t){var n,r;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&!this.locked.has(i)&&s&&!Egt(s.dom,t)||this.pending){let{pos:a}=i[0]||this.pending,l=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:a;(a==l?this.view.posAtCoords(this.lastMove)!=a:!kgt(this.view,a,l,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length&&!this.locked.has(n)){let{tooltip:r}=this;r&&r.dom.contains(t.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let n=r=>{t.removeEventListener("mouseleave",n);let{active:i}=this;i.length&&!this.locked.has(i)&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const W2=4;function Egt(e,t){let{left:n,right:r,top:i,bottom:s}=e.getBoundingClientRect(),a;if(a=e.querySelector(".cm-tooltip-arrow")){let l=a.getBoundingClientRect();i=Math.min(l.top,i),s=Math.max(l.bottom,s)}return t.clientX>=n-W2&&t.clientX<=r+W2&&t.clientY>=i-W2&&t.clientY<=s+W2}function kgt(e,t,n,r,i,s){let a=e.scrollDOM.getBoundingClientRect(),l=e.documentTop+e.documentPadding.top+e.contentHeight;if(a.left>r||a.righti||Math.min(a.bottom,l)=t&&c<=n}function _gt(e,t={}){let n=jn.define(),r=new WeakMap,i=Qa.define({create(){return[]},update(a,l){let c=r.get(a);if(a.length&&(t.hideOnChange&&(l.docChanged||l.selection)?a=[]:c&&c(l)?a=[]:t.hideOn&&(a=a.filter(u=>!t.hideOn(l,u)))),l.docChanged&&a.length){let u=[];for(let d of a){let f=l.changes.mapPos(d.pos,-1,Pa.TrackDel);if(f!=null){let h=Object.assign(Object.create(null),d);h.pos=f,h.end!=null&&(h.end=l.changes.mapPos(h.end)),u.push(h)}}a=u}for(let u of l.effects)u.is(n)&&(a=u.value,c=void 0),(u.is(Cgt)&&!u.value||u.value==i)&&(a=[]);return a.length&&c&&r.set(a,c),a},provide:a=>wA.from(a)});const s=ps.define(a=>new Sgt(a,e,i,r,n,t.hoverTime||300));return{active:i,extension:[i,s,zye.of(s),wgt]}}function Tgt(e,t,n,r={}){var i;let s=e.state.facet(zye).map(a=>e.plugin(a)).filter(a=>!!a);if(r.tooltip&&r.tooltip.active){let a=s.find(l=>l.field==r.tooltip.active);a&&(s=[a])}for(let a of s)a.activateHover(e,t,n,(i=r.until)!==null&&i!==void 0?i:()=>!1)}function Vye(e,t){let n=e.plugin(SQ);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const Cgt=jn.define(),cZ=Qt.define({combine(e){let t,n;for(let r of e)t=t||r.topContainer,n=n||r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function kQ(e,t){let n=e.plugin(Hye),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const Hye=ps.fromClass(class{constructor(e){this.input=e.state.facet(lS),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(cZ);this.top=new Y2(e,!0,t.topContainer),this.bottom=new Y2(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(e){let t=e.state.facet(cZ);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Y2(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Y2(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(lS);if(n!=this.input){let r=n.filter(c=>c),i=[],s=[],a=[],l=[];for(let c of r){let u=this.specs.indexOf(c),d;u<0?(d=c(e.view),l.push(d)):(d=this.panels[u],d.update&&d.update(e)),i.push(d),(d.top?s:a).push(d)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(a);for(let c of l)c.dom.classList.add("cm-panel"),c.mount&&c.mount()}else for(let r of this.panels)r.update&&r.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Ct.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class Y2{constructor(t,n,r){this.view=t,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let n of this.panels)n.destroy&&t.indexOf(n)<0&&n.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let t=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;t!=n.dom;)t=uZ(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=uZ(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function uZ(e){let t=e.nextSibling;return e.remove(),t}const lS=Qt.define({enables:Hye});function Agt(e,t){let n,r=new Promise(a=>n=a),i=a=>Ngt(a,t,n);e.state.field(qD,!1)?e.dispatch({effects:qye.of(i)}):e.dispatch({effects:jn.appendConfig.of(qD.init(()=>[i]))});let s=Xye.of(i);return{close:s,result:r.then(a=>((e.win.queueMicrotask||(c=>e.win.setTimeout(c,10)))(()=>{e.state.field(qD).indexOf(i)>-1&&e.dispatch({effects:s})}),a))}}const qD=Qa.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(qye)?e=[n.value].concat(e):n.is(Xye)&&(e=e.filter(r=>r!=n.value));return e},provide:e=>lS.computeN([e],t=>t.field(e))}),qye=jn.define(),Xye=jn.define();function Ngt(e,t,n){let r=t.content?t.content(e,()=>a(null)):null;if(!r){if(r=fi("form"),t.input){let l=fi("input",t.input);/^(text|password|number|email|tel|url)$/.test(l.type)&&l.classList.add("cm-textfield"),l.name||(l.name="input"),r.appendChild(fi("label",(t.label||"")+": ",l))}else r.appendChild(document.createTextNode(t.label||""));r.appendChild(document.createTextNode(" ")),r.appendChild(fi("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let i=r.nodeName=="FORM"?[r]:r.querySelectorAll("form");for(let l=0;l{u.keyCode==27?(u.preventDefault(),a(null)):u.keyCode==13&&(u.preventDefault(),a(c))}),c.addEventListener("submit",u=>{u.preventDefault(),a(c)})}let s=fi("div",r,fi("button",{onclick:()=>a(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));t.class&&(s.className=t.class),s.classList.add("cm-dialog");function a(l){s.contains(s.ownerDocument.activeElement)&&e.focus(),n(l)}return{dom:s,top:t.top,mount:()=>{if(t.focus){let l;typeof t.focus=="string"?l=r.querySelector(t.focus):l=r.querySelector("input")||r.querySelector("button"),l&&"select"in l?l.select():l&&"focus"in l&&l.focus()}}}}class oh extends Kp{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}oh.prototype.elementClass="";oh.prototype.toDOM=void 0;oh.prototype.mapMode=Pa.TrackBefore;oh.prototype.startSide=oh.prototype.endSide=-1;oh.prototype.point=!0;const OT=Qt.define(),jgt=Qt.define(),Rgt={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>gr.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Wv=Qt.define();function Igt(e){return[Gye(),Wv.of({...Rgt,...e})]}const dZ=Qt.define({combine:e=>e.some(t=>t)});function Gye(e){return[Dgt]}const Dgt=ps.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(Wv).map(t=>new hZ(e,t)),this.fixed=!e.state.facet(dZ);for(let t of this.gutters)t.config.side=="after"?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(dZ)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=gr.iter(this.view.state.facet(OT),this.view.viewport.from),r=[],i=this.gutters.map(s=>new Pgt(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(s.type)){let a=!0;for(let l of s.type)if(l.type==Ba.Text&&a){d6(n,r,l.from);for(let c of i)c.line(this.view,l,r);a=!1}else if(l.widget)for(let c of i)c.widget(this.view,l)}else if(s.type==Ba.Text){d6(n,r,s.from);for(let a of i)a.line(this.view,s,r)}else if(s.widget)for(let a of i)a.widget(this.view,s);for(let s of i)s.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(Wv),n=e.state.facet(Wv),r=e.docChanged||e.heightChanged||e.viewportChanged||!gr.eq(e.startState.facet(OT),e.state.facet(OT),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let i of this.gutters)i.update(e)&&(r=!0);else{r=!0;let i=[];for(let s of n){let a=t.indexOf(s);a<0?i.push(new hZ(this.view,s)):(this.gutters[a].update(e),i.push(this.gutters[a]))}for(let s of this.gutters)s.dom.remove(),i.indexOf(s)<0&&s.destroy();for(let s of i)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>Ct.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==xi.LTR?{left:r,right:i}:{right:r,left:i}})});function fZ(e){return Array.isArray(e)?e:[e]}function d6(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class Pgt{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=gr.iter(t.markers,n.from)}addElement(t,n,r){let{gutter:i}=this,s=(n.top-this.height)/t.scaleY,a=n.height/t.scaleY;if(this.i==i.elements.length){let l=new Wye(t,a,s,r);i.elements.push(l),i.dom.appendChild(l.dom)}else i.elements[this.i].update(t,a,s,r);this.height=n.bottom,this.i++}line(t,n,r){let i=[];d6(this.cursor,i,n.from),r.length&&(i=i.concat(r));let s=this.gutter.config.lineMarker(t,n,i);s&&i.unshift(s);let a=this.gutter;i.length==0&&!a.config.renderEmptyElements||this.addElement(t,n,i)}widget(t,n){let r=this.gutter.config.widgetMarker(t,n.widget,n),i=r?[r]:null;for(let s of t.state.facet(jgt)){let a=s(t,n.widget,n);a&&(i||(i=[])).push(a)}i&&this.addElement(t,n,i)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let n=t.elements.pop();t.dom.removeChild(n.dom),n.destroy()}}}class hZ{constructor(t,n){this.view=t,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,i=>{let s=i.target,a;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let c=s.getBoundingClientRect();a=(c.top+c.bottom)/2}else a=i.clientY;let l=t.lineBlockAtHeight(a-t.documentTop);n.domEventHandlers[r](t,l,i)&&i.preventDefault()});this.markers=fZ(n.markers(t)),n.initialSpacer&&(this.spacer=new Wye(t,0,0,[n.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let n=this.markers;if(this.markers=fZ(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],t);i!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[i])}let r=t.view.viewport;return!gr.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class Wye{constructor(t,n,r,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,n,r,i)}update(t,n,r,i){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Mgt(this.markers,i)||this.setMarkers(t,i)}setMarkers(t,n){let r="cm-gutterElement",i=this.dom.firstChild;for(let s=0,a=0;;){let l=a,c=ss(l,c,u)||a(l,c,u):a}return r}})}});class XD extends oh{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function GD(e,t){return e.state.facet(Jb).formatNumber(t,e.state)}const Bgt=Wv.compute([Jb],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(Lgt)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new XD(GD(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet($gt)){let s=i(t,n,r);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(Jb)!=t.state.facet(Jb),initialSpacer(t){return new XD(GD(t,pZ(t.state.doc.lines)))},updateSpacer(t,n){let r=GD(n.view,pZ(n.view.state.doc.lines));return r==t.number?t:new XD(r)},domEventHandlers:e.facet(Jb).domEventHandlers,side:"before"}));function Qgt(e={}){return[Jb.of(e),Gye(),Bgt]}function pZ(e){let t=9;for(;t{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(Ugt.range(i)))}return gr.of(t)});function zgt(){return Fgt}let Vgt=0,Xu=class f6{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=Vgt++}toString(){let{name:t}=this;for(let n of this.modified)n.name&&(t=`${n.name}(${t})`);return t}static define(t,n){let r=typeof t=="string"?t:"?";if(t instanceof f6&&(n=t),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new f6(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(t){let n=new SA(t);return r=>r.modified.indexOf(n)>-1?r:SA.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}},Hgt=0;class SA{constructor(t){this.name=t,this.instances=[],this.id=Hgt++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(l=>l.base==t&&qgt(n,l.modified));if(r)return r;let i=[],s=new Xu(t.name,i,t,n);for(let l of n)l.instances.push(s);let a=Xgt(n);for(let l of t.set)if(!l.modified.length)for(let c of a)i.push(SA.get(l,c));return s}}function qgt(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function Xgt(e){let t=[[]];for(let n=0;nr.length-n.length)}function vh(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],a=2,l=i;for(let f=0;;){if(l=="..."&&f>0&&f+3==i.length){a=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!h)throw new RangeError("Invalid path: "+i);if(s.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),f+=h[0].length,f==i.length)break;let m=i[f++];if(f==i.length&&m=="!"){a=0;break}if(m!="/")throw new RangeError("Invalid path: "+i);l=i.slice(f)}let c=s.length-1,u=s[c];if(!u)throw new RangeError("Invalid path: "+i);let d=new cS(r,a,c>0?s.slice(0,c):null);t[u]=d.sort(t[u])}}return Yye.add(t)}const Yye=new Nn({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let s=new cS(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}});let cS=class{constructor(t,n,r,i){this.tags=t,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth{let a=i;for(let l of s)for(let c of l.set){let u=n[c.id];if(u){a=a?a+" "+u:u;break}}return a},scope:r}}function Ggt(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function Wgt(e,t,n,r=0,i=e.length){let s=new Ygt(r,Array.isArray(t)?t:[t],n);s.highlightRange(e.cursor(),r,i,"",s.highlighters),s.flush(i)}class Ygt{constructor(t,n,r){this.at=t,this.highlighters=n,this.span=r,this.class=""}startSpan(t,n){n!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=n)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,n,r,i,s){let{type:a,from:l,to:c}=t;if(l>=r||c<=n)return;a.isTop&&(s=this.highlighters.filter(m=>!m.scope||m.scope(a)));let u=i,d=Zgt(t)||cS.empty,f=Ggt(s,d.tags);if(f&&(u&&(u+=" "),u+=f,d.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(n,l),u),d.opaque)return;let h=t.tree&&t.tree.prop(Nn.mounted);if(h&&h.overlay){let m=t.node.enter(h.overlay[0].from+l,1),g=this.highlighters.filter(y=>!y.scope||y.scope(h.tree.type)),b=t.firstChild();for(let y=0,O=l;;y++){let v=y=x||!t.nextSibling())););if(!v||x>r)break;O=v.to+l,O>n&&(this.highlightRange(m.cursor(),Math.max(n,v.from+l),Math.min(r,O),"",g),this.startSpan(Math.min(r,O),u))}b&&t.parent()}else if(t.firstChild()){h&&(i="");do if(!(t.to<=n)){if(t.from>=r)break;this.highlightRange(t,n,r,i,s),this.startSpan(Math.min(r,t.to),u)}while(t.nextSibling());t.parent()}}}function Zgt(e){let t=e.type.prop(Yye);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const jt=Xu.define,Z2=jt(),Kh=jt(),mZ=jt(Kh),gZ=jt(Kh),Jh=jt(),K2=jt(Jh),WD=jt(Jh),zu=jt(),Nm=jt(zu),Qu=jt(),Uu=jt(),h6=jt(),mx=jt(h6),J2=jt(),Y={comment:Z2,lineComment:jt(Z2),blockComment:jt(Z2),docComment:jt(Z2),name:Kh,variableName:jt(Kh),typeName:mZ,tagName:jt(mZ),propertyName:gZ,attributeName:jt(gZ),className:jt(Kh),labelName:jt(Kh),namespace:jt(Kh),macroName:jt(Kh),literal:Jh,string:K2,docString:jt(K2),character:jt(K2),attributeValue:jt(K2),number:WD,integer:jt(WD),float:jt(WD),bool:jt(Jh),regexp:jt(Jh),escape:jt(Jh),color:jt(Jh),url:jt(Jh),keyword:Qu,self:jt(Qu),null:jt(Qu),atom:jt(Qu),unit:jt(Qu),modifier:jt(Qu),operatorKeyword:jt(Qu),controlKeyword:jt(Qu),definitionKeyword:jt(Qu),moduleKeyword:jt(Qu),operator:Uu,derefOperator:jt(Uu),arithmeticOperator:jt(Uu),logicOperator:jt(Uu),bitwiseOperator:jt(Uu),compareOperator:jt(Uu),updateOperator:jt(Uu),definitionOperator:jt(Uu),typeOperator:jt(Uu),controlOperator:jt(Uu),punctuation:h6,separator:jt(h6),bracket:mx,angleBracket:jt(mx),squareBracket:jt(mx),paren:jt(mx),brace:jt(mx),content:zu,heading:Nm,heading1:jt(Nm),heading2:jt(Nm),heading3:jt(Nm),heading4:jt(Nm),heading5:jt(Nm),heading6:jt(Nm),contentSeparator:jt(zu),list:jt(zu),quote:jt(zu),emphasis:jt(zu),strong:jt(zu),link:jt(zu),monospace:jt(zu),strikethrough:jt(zu),inserted:jt(),deleted:jt(),changed:jt(),invalid:jt(),meta:J2,documentMeta:jt(J2),annotation:jt(J2),processingInstruction:jt(J2),definition:Xu.defineModifier("definition"),constant:Xu.defineModifier("constant"),function:Xu.defineModifier("function"),standard:Xu.defineModifier("standard"),local:Xu.defineModifier("local"),special:Xu.defineModifier("special")};for(let e in Y){let t=Y[e];t instanceof Xu&&(t.name=e)}Zye([{tag:Y.link,class:"tok-link"},{tag:Y.heading,class:"tok-heading"},{tag:Y.emphasis,class:"tok-emphasis"},{tag:Y.strong,class:"tok-strong"},{tag:Y.keyword,class:"tok-keyword"},{tag:Y.atom,class:"tok-atom"},{tag:Y.bool,class:"tok-bool"},{tag:Y.url,class:"tok-url"},{tag:Y.labelName,class:"tok-labelName"},{tag:Y.inserted,class:"tok-inserted"},{tag:Y.deleted,class:"tok-deleted"},{tag:Y.literal,class:"tok-literal"},{tag:Y.string,class:"tok-string"},{tag:Y.number,class:"tok-number"},{tag:[Y.regexp,Y.escape,Y.special(Y.string)],class:"tok-string2"},{tag:Y.variableName,class:"tok-variableName"},{tag:Y.local(Y.variableName),class:"tok-variableName tok-local"},{tag:Y.definition(Y.variableName),class:"tok-variableName tok-definition"},{tag:Y.special(Y.variableName),class:"tok-variableName2"},{tag:Y.definition(Y.propertyName),class:"tok-propertyName tok-definition"},{tag:Y.typeName,class:"tok-typeName"},{tag:Y.namespace,class:"tok-namespace"},{tag:Y.className,class:"tok-className"},{tag:Y.macroName,class:"tok-macroName"},{tag:Y.propertyName,class:"tok-propertyName"},{tag:Y.operator,class:"tok-operator"},{tag:Y.comment,class:"tok-comment"},{tag:Y.meta,class:"tok-meta"},{tag:Y.invalid,class:"tok-invalid"},{tag:Y.punctuation,class:"tok-punctuation"}]);var YD;const bp=new Nn;function iR(e){return Qt.define({combine:e?t=>t.concat(e):void 0})}const _Q=new Nn;class Al{constructor(t,n,r=[],i=""){this.data=t,this.name=i,vr.prototype.hasOwnProperty("tree")||Object.defineProperty(vr.prototype,"tree",{get(){return mi(this)}}),this.parser=n,this.extension=[nm.of(this),vr.languageData.of((s,a,l)=>{let c=bZ(s,a,l),u=c.type.prop(bp);if(!u)return[];let d=s.facet(u),f=c.type.prop(_Q);if(f){let h=c.resolve(a-c.from,l);for(let m of f)if(m.test(h,s)){let g=s.facet(m.facet);return m.type=="replace"?g:g.concat(d)}}return d})].concat(r)}isActiveAt(t,n,r=-1){return bZ(t,n,r).type.prop(bp)==this.data}findRegions(t){let n=t.facet(nm);if((n==null?void 0:n.data)==this.data)return[{from:0,to:t.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(s,a)=>{if(s.prop(bp)==this.data){r.push({from:a,to:a+s.length});return}let l=s.prop(Nn.mounted);if(l){if(l.tree.prop(bp)==this.data){if(l.overlay)for(let c of l.overlay)r.push({from:c.from+a,to:c.to+a});else r.push({from:a,to:a+s.length});return}else if(l.overlay){let c=r.length;if(i(l.tree,l.overlay[0].from+a),r.length>c)return}}for(let c=0;cr.isTop?n:void 0)]}),t.name)}configure(t,n){return new lh(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function mi(e){let t=e.field(Al.state,!1);return t?t.tree:cr.empty}class Kgt{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,n){let r=this.cursorPos-this.string.length;return t=this.cursorPos?this.doc.sliceString(t,n):this.string.slice(t-r,n-r)}}let gx=null;class Zg{constructor(t,n,r=[],i,s,a,l,c){this.parser=t,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=a,this.skipped=l,this.scheduleOn=c,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new Zg(t,n,[],cr.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Kgt(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=cr.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let i=Date.now()+t;t=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=t,this.tree=n,this.fragments=this.withoutTempSkipped(Uf.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=gx;gx=this;try{return t()}finally{gx=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=yZ(t,n.from,n.to);return t}changes(t,n){let{fragments:r,tree:i,treeLen:s,viewport:a,skipped:l}=this;if(this.takeTree(),!t.empty){let c=[];if(t.iterChangedRanges((u,d,f,h)=>c.push({fromA:u,toA:d,fromB:f,toB:h})),r=Uf.applyChanges(r,c),i=cr.empty,s=0,a={from:t.mapPos(a.from,-1),to:t.mapPos(a.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let d=t.mapPos(u.from,1),f=t.mapPos(u.to,-1);dt.from&&(this.fragments=yZ(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,n){this.skipped.push({from:t,to:n})}static getSkippingParser(t){return new class extends Yj{createParse(n,r,i){let s=i[0].from,a=i[i.length-1].to;return{parsedPos:s,advance(){let c=gx;if(c){for(let u of i)c.tempSkipped.push(u);t&&(c.scheduleOn=c.scheduleOn?Promise.all([c.scheduleOn,t]):t)}return this.parsedPos=a,new cr(Hs.none,[],[],a-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let n=this.fragments;return this.treeLen>=t&&n.length&&n[0].from==0&&n[0].to>=t}static get(){return gx}}function yZ(e,t,n){return Uf.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class S1{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new S1(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=Zg.create(t.facet(nm).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new S1(r)}}Al.state=Qa.define({create:S1.init,update(e,t){for(let n of t.effects)if(n.is(Al.setState))return n.value;return t.startState.facet(nm)!=t.state.facet(nm)?S1.init(t.state):e.apply(t)}});let Kye=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Kye=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const ZD=typeof navigator<"u"&&(!((YD=navigator.scheduling)===null||YD===void 0)&&YD.isInputPending)?()=>navigator.scheduling.isInputPending():null,Jgt=ps.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let n=this.view.state.field(Al.state).context;(n.updateViewport(t.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:t}=this.view,n=t.field(Al.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=Kye(this.work))}work(t){this.working=null;let n=Date.now();if(this.chunkEndi+1e3,c=s.context.work(()=>ZD&&ZD()||Date.now()>a,i+(l?0:1e5));this.chunkBudget-=Date.now()-n,(c||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Al.setState.of(new S1(s.context))})),this.chunkBudget>0&&!(c&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Go(this.view.state,n)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),nm=Qt.define({combine(e){return e.length?e[0]:null},enables:e=>[Al.state,Jgt,Ct.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class rm{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class EA{constructor(t,n,r,i,s,a=void 0){this.name=t,this.alias=n,this.extensions=r,this.filename=i,this.loadFunc=s,this.support=a,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");n=()=>Promise.resolve(r)}return new EA(t.name,(t.alias||[]).concat(t.name).map(i=>i.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(t,n){for(let i of t)if(i.filename&&i.filename.test(n))return i;let r=/\.([^.]+)$/.exec(n);if(r){for(let i of t)if(i.extensions.indexOf(r[1])>-1)return i}return null}static matchLanguageName(t,n,r=!0){n=n.toLowerCase();for(let i of t)if(i.alias.some(s=>s==n))return i;if(r)for(let i of t)for(let s of i.alias){let a=n.indexOf(s);if(a>-1&&(s.length>2||!/\w/.test(n[a-1])&&!/\w/.test(n[a+s.length])))return i}return null}}const e0t=Qt.define(),OO=Qt.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(n=>n!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function Kg(e){let t=e.facet(OO);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function uS(e,t){let n="",r=e.tabSize,i=e.facet(OO)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let s=0;s=t?t0t(e,n,t):null}class sR{constructor(t,n={}){this.state=t,this.options=n,this.unit=Kg(t)}lineAt(t,n=1){let r=this.state.doc.lineAt(t),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&i==t?{text:"",from:t}:(n<0?i-1&&(s+=a-this.countColumn(r,r.search(/\S|$/))),s}countColumn(t,n=t.length){return vu(t,this.state.tabSize,n)}lineIndent(t,n=1){let{text:r,from:i}=this.lineAt(t,n),s=this.options.overrideIndentation;if(s){let a=s(i);if(a>-1)return a}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const wh=new Nn;function t0t(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let a=i;a&&!(a.fromr.node.to||a.from==r.node.from&&a.type==r.node.type);a=a.parent)s.push(a);for(let a=s.length-1;a>=0;a--)r={node:s[a],next:r}}return Jye(r,e,n)}function Jye(e,t,n){for(let r=e;r;r=r.next){let i=r0t(r.node);if(i)return i(CQ.create(t,n,r))}return 0}function n0t(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function r0t(e){let t=e.type.prop(wh);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Nn.closedBy))){let i=e.lastChild,s=i&&r.indexOf(i.name)>-1;return a=>e1e(a,!0,1,void 0,s&&!n0t(a)?i.from:void 0)}return e.parent==null?i0t:null}function i0t(){return 0}class CQ extends sR{constructor(t,n,r){super(t.state,t.options),this.base=t,this.pos=n,this.context=r}get node(){return this.context.node}static create(t,n,r){return new CQ(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let n=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(s0t(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Jye(this.context.next,this.base,this.pos)}}function s0t(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function a0t(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,s=e.state.doc.lineAt(n.from),a=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let l=n.to;;){let c=t.childAfter(l);if(!c||c==r)return null;if(!c.type.isSkipped){if(c.from>=a)return null;let u=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+u}}l=c.to}}function Cy({closing:e,align:t=!0,units:n=1}){return r=>e1e(r,t,n,e)}function e1e(e,t,n,r,i){let s=e.textAfter,a=s.match(/^\s*/)[0].length,l=r&&s.slice(a,a+r.length)==r||i==e.pos+a,c=t?a0t(e):null;return c?l?e.column(c.from):e.column(c.to):e.baseIndent+(l?0:e.unit*n)}const o0t=e=>e.baseIndent;function Ay({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const l0t=200;function c0t(){return vr.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+l0t)return e;let s=n.sliceString(i.from,r);if(!t.some(u=>u.test(s)))return e;let{state:a}=e,l=-1,c=[];for(let{head:u}of a.selection.ranges){let d=a.doc.lineAt(u);if(d.from==l)continue;l=d.from;let f=TQ(a,d.from);if(f==null)continue;let h=/^\s*/.exec(d.text)[0],m=uS(a,f);h!=m&&c.push({from:d.from,to:d.from+h.length,insert:m})}return c.length?[e,{changes:c,sequential:!0}]:e})}const t1e=Qt.define(),Sh=new Nn;function BE(e){let t=e.firstChild,n=e.lastChild;return t&&t.ton)continue;if(s&&l.from=t&&u.to>n&&(s=u)}}return s}function d0t(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function kA(e,t,n){for(let r of e.facet(t1e)){let i=r(e,t,n);if(i)return i}return u0t(e,t,n)}function n1e(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const aR=jn.define({map:n1e}),QE=jn.define({map:n1e});function r1e(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(r=>r.from<=n&&r.to>=n)||t.push(e.lineBlockAt(n));return t}const Jg=Qa.define({create(){return dn.none},update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((r,i)=>e=OZ(e,r,i)),e=e.map(t.changes);let n=[];for(let r of t.effects)r.is(aR)&&!f0t(e,r.value.from,r.value.to)?n.push(r.value):r.is(QE)&&(e=e.update({filter:(i,s)=>r.value.from!=i||r.value.to!=s,filterFrom:r.value.from,filterTo:r.value.to}));if(n.length){let{preparePlaceholder:r}=t.state.facet(a1e),i=n.map(s=>(r?dn.replace({widget:new O0t(r(t.state,s))}):xZ).range(s.from,s.to));e=e.update({add:i})}return t.selection&&(e=OZ(e,t.selection.main.head)),e},provide:e=>Ct.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(r,i)=>{n.push(r,i)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n{it&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(i,s)=>i>=n||s<=t}):e}function _A(e,t,n){var r;let i=null;return(r=e.field(Jg,!1))===null||r===void 0||r.between(t,n,(s,a)=>{(!i||i.from>s)&&(i={from:s,to:a})}),i}function f0t(e,t,n){let r=!1;return e.between(t,t,(i,s)=>{i==t&&s==n&&(r=!0)}),r}function i1e(e,t){return e.field(Jg,!1)?t:t.concat(jn.appendConfig.of(o1e()))}const h0t=e=>{for(let t of r1e(e)){let n=kA(e.state,t.from,t.to);if(n)return e.dispatch({effects:i1e(e.state,[aR.of(n),s1e(e,n)])}),!0}return!1},p0t=e=>{if(!e.state.field(Jg,!1))return!1;let t=[];for(let n of r1e(e)){let r=_A(e.state,n.from,n.to);r&&t.push(QE.of(r),s1e(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function s1e(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return Ct.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const m0t=e=>{let{state:t}=e,n=[];for(let r=0;r{let t=e.state.field(Jg,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(QE.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},b0t=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:h0t},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:p0t},{key:"Ctrl-Alt-[",run:m0t},{key:"Ctrl-Alt-]",run:g0t}],y0t={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},a1e=Qt.define({combine(e){return Nd(e,y0t)}});function o1e(e){return[Jg,w0t]}function l1e(e,t){let{state:n}=e,r=n.facet(a1e),i=a=>{let l=e.lineBlockAt(e.posAtDOM(a.target)),c=_A(e.state,l.from,l.to);c&&e.dispatch({effects:QE.of(c)}),a.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let s=document.createElement("span");return s.textContent=r.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}const xZ=dn.replace({widget:new class extends Nu{toDOM(e){return l1e(e,null)}}});class O0t extends Nu{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return l1e(t,this.value)}}const x0t={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class KD extends oh{constructor(t,n){super(),this.config=t,this.open=n}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=t.state.phrase(this.open?"Fold line":"Unfold line"),n}}function v0t(e={}){let t={...x0t,...e},n=new KD(t,!0),r=new KD(t,!1),i=ps.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(nm)!=a.state.facet(nm)||a.startState.field(Jg,!1)!=a.state.field(Jg,!1)||mi(a.startState)!=mi(a.state)||t.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let l=new sh;for(let c of a.viewportLineBlocks){let u=_A(a.state,c.from,c.to)?r:kA(a.state,c.from,c.to)?n:null;u&&l.add(c.from,c.from,u)}return l.finish()}}),{domEventHandlers:s}=t;return[i,Igt({class:"cm-foldGutter",markers(a){var l;return((l=a.plugin(i))===null||l===void 0?void 0:l.markers)||gr.empty},initialSpacer(){return new KD(t,!1)},domEventHandlers:{...s,click:(a,l,c)=>{if(s.click&&s.click(a,l,c))return!0;let u=_A(a.state,l.from,l.to);if(u)return a.dispatch({effects:QE.of(u)}),!0;let d=kA(a.state,l.from,l.to);return d?(a.dispatch({effects:aR.of(d)}),!0):!1}}}),o1e()]}const w0t=Ct.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class UE{constructor(t,n){this.specs=t;let r;function i(l){let c=Jp.newName();return(r||(r=Object.create(null)))["."+c]=l,c}const s=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,a=n.scope;this.scope=a instanceof Al?l=>l.prop(bp)==a.data:a?l=>l==a:void 0,this.style=Zye(t.map(l=>({tag:l.tag,class:l.class||i(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new Jp(r):null,this.themeType=n.themeType}static define(t,n){return new UE(t,n||{})}}const p6=Qt.define(),c1e=Qt.define({combine(e){return e.length?[e[0]]:null}});function xT(e){let t=e.facet(p6);return t.length?t:e.facet(c1e)}function u1e(e,t){let n=[E0t],r;return e instanceof UE&&(e.module&&n.push(Ct.styleModule.of(e.module)),r=e.themeType),t!=null&&t.fallback?n.push(c1e.of(e)):r?n.push(p6.computeN([Ct.darkTheme],i=>i.facet(Ct.darkTheme)==(r=="dark")?[e]:[])):n.push(p6.of(e)),n}function AMt(e,t,n){let r=xT(e),i=null;if(r){for(let s of r)if(!s.scope||n){let a=s.style(t);a&&(i=i?i+" "+a:a)}}return i}class S0t{constructor(t){this.markCache=Object.create(null),this.tree=mi(t.state),this.decorations=this.buildDeco(t,xT(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=mi(t.state),r=xT(t.state),i=r!=xT(t.startState),{viewport:s}=t.view,a=t.changes.mapPos(this.decoratedTo,1);n.length=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=a):(n!=this.tree||t.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=s.to)}buildDeco(t,n){if(!n||!this.tree.length)return dn.none;let r=new sh;for(let{from:i,to:s}of t.visibleRanges)Wgt(this.tree,n,(a,l,c)=>{r.add(a,l,this.markCache[c]||(this.markCache[c]=dn.mark({class:c})))},i,s);return r.finish()}}const E0t=xh.high(ps.fromClass(S0t,{decorations:e=>e.decorations})),k0t=UE.define([{tag:Y.meta,color:"#404740"},{tag:Y.link,textDecoration:"underline"},{tag:Y.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Y.emphasis,fontStyle:"italic"},{tag:Y.strong,fontWeight:"bold"},{tag:Y.strikethrough,textDecoration:"line-through"},{tag:Y.keyword,color:"#708"},{tag:[Y.atom,Y.bool,Y.url,Y.contentSeparator,Y.labelName],color:"#219"},{tag:[Y.literal,Y.inserted],color:"#164"},{tag:[Y.string,Y.deleted],color:"#a11"},{tag:[Y.regexp,Y.escape,Y.special(Y.string)],color:"#e40"},{tag:Y.definition(Y.variableName),color:"#00f"},{tag:Y.local(Y.variableName),color:"#30a"},{tag:[Y.typeName,Y.namespace],color:"#085"},{tag:Y.className,color:"#167"},{tag:[Y.special(Y.variableName),Y.macroName],color:"#256"},{tag:Y.definition(Y.propertyName),color:"#00c"},{tag:Y.comment,color:"#940"},{tag:Y.invalid,color:"#f00"}]),_0t=Ct.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),d1e=1e4,f1e="()[]{}",h1e=Qt.define({combine(e){return Nd(e,{afterCursor:!0,brackets:f1e,maxScanDistance:d1e,renderMatch:A0t})}}),T0t=dn.mark({class:"cm-matchingBracket"}),C0t=dn.mark({class:"cm-nonmatchingBracket"});function A0t(e){let t=[],n=e.matched?T0t:C0t;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function vZ(e){let t=[],n=e.facet(h1e);for(let r of e.selection.ranges){if(!r.empty)continue;let i=sd(e,r.head,-1,n)||r.head>0&&sd(e,r.head-1,1,n)||n.afterCursor&&(sd(e,r.head,1,n)||r.heade.decorations}),j0t=[N0t,_0t];function R0t(e={}){return[h1e.of(e),j0t]}const p1e=new Nn;function m6(e,t,n){let r=e.prop(t<0?Nn.openedBy:Nn.closedBy);if(r)return r;if(e.name.length==1){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function g6(e){let t=e.type.prop(p1e);return t?t(e.node):e}function sd(e,t,n,r={}){let i=r.maxScanDistance||d1e,s=r.brackets||f1e,a=mi(e),l=a.resolveInner(t,n);for(let c=l;c;c=c.parent){let u=m6(c.type,n,s);if(u&&c.from0?t>=d.from&&td.from&&t<=d.to))return I0t(e,t,n,c,d,u,s)}}return D0t(e,t,n,a,l.type,i,s)}function I0t(e,t,n,r,i,s,a){let l=r.parent,c={from:i.from,to:i.to},u=0,d=l==null?void 0:l.cursor();if(d&&(n<0?d.childBefore(r.from):d.childAfter(r.to)))do if(n<0?d.to<=r.from:d.from>=r.to){if(u==0&&s.indexOf(d.type.name)>-1&&d.from0)return null;let u={from:n<0?t-1:t,to:n>0?t+1:t},d=e.doc.iterRange(t,n>0?e.doc.length:0),f=0;for(let h=0;!d.next().done&&h<=s;){let m=d.value;n<0&&(h+=m.length);let g=t+h*n;for(let b=n>0?0:m.length-1,y=n>0?m.length:-1;b!=y;b+=n){let O=a.indexOf(m[b]);if(!(O<0||r.resolveInner(g+b,1).type!=i))if(O%2==0==n>0)f++;else{if(f==1)return{start:u,end:{from:g+b,to:g+b+1},matched:O>>1==c>>1};f--}}n>0&&(h+=m.length)}return d.done?{start:u,matched:!1}:null}function wZ(e,t,n,r=0,i=0){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let s=i;for(let a=r;a=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.posn}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let n=this.string.indexOf(t,this.pos);if(n>-1)return this.pos=n,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPosr?a.toLowerCase():a,s=this.string.substr(this.pos,t.length);return i(s)==i(t)?(n!==!1&&(this.pos+=t.length),!0):null}else{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&n!==!1&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function P0t(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||M0t,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||jQ,mergeTokens:e.mergeTokens!==!1}}function M0t(e){if(typeof e!="object")return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}const SZ=new WeakMap;class AQ extends Al{constructor(t){let n=iR(t.languageData),r=P0t(t),i,s=new class extends Yj{createParse(a,l,c){return new $0t(i,a,l,c)}};super(n,s,[],t.name),this.topNode=U0t(n,this),i=this,this.streamParser=r,this.stateAfter=new Nn({perNode:!0}),this.tokenTable=t.tokenTable?new O1e(r.tokenTable):Q0t}static define(t){return new AQ(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=SZ.get(t.state),n!=null&&n1e4)return null;for(;s=r&&n+t.length<=i&&t.prop(e.stateAfter);if(s)return{state:e.streamParser.copyState(s),pos:n+t.length};for(let a=t.children.length-1;a>=0;a--){let l=t.children[a],c=n+t.positions[a],u=l instanceof cr&&c=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let s=t.children.length-1;s>=0;s--){let a=t.positions[s],l=t.children[s],c;if(an&&NQ(e,s.tree,0-s.offset,n,l),u;if(c&&c.pos<=r&&(u=g1e(e,s.tree,n+s.offset,c.pos+s.offset,!1)))return{state:c.state,tree:u}}return{state:e.streamParser.startState(i?Kg(i):4),tree:cr.empty}}let $0t=class{constructor(t,n,r,i){this.lang=t,this.input=n,this.fragments=r,this.ranges=i,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=i[i.length-1].to;let s=Zg.get(),a=i[0].from,{state:l,tree:c}=L0t(t,r,a,this.to,s==null?void 0:s.state);this.state=l,this.parsedPos=this.chunkStart=a+c.length;for(let u=0;uu.from<=s.viewport.from&&u.to>=s.viewport.from)&&(this.state=this.lang.streamParser.startState(Kg(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let t=Zg.get(),n=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),r=Math.min(n,this.chunkStart+512);for(t&&(r=Math.min(r,t.viewport.to));this.parsedPos=n?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,n),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let n=this.input.chunk(t);if(this.input.lineChunks)n==` +--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,c6),Jmt={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let VD=null;function egt(){var e;if(VD==null&&typeof document<"u"&&document.body){let t=document.body.style;VD=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return VD||!1}const yT=Qt.define({combine(e){let t=Nd(e,{render:null,specialChars:Kmt,addSpecialChars:null});return(t.replaceTabs=!egt())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,c6)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,c6)),t}});function tgt(e={}){return[yT.of(e),ngt()]}let sZ=null;function ngt(){return sZ||(sZ=ps.fromClass(class{constructor(e){this.view=e,this.decorations=dn.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(yT)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Zmt({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,s=Uo(t[0],0);if(s==9){let a=i.lineAt(r),l=n.state.tabSize,c=vu(a.text,l,r-a.from);return dn.replace({widget:new agt((l-c%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=dn.replace({widget:new sgt(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(yT);e.startState.facet(yT)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))}const rgt="•";function igt(e){return e>=32?rgt:e==10?"␤":String.fromCharCode(9216+e)}class sgt extends Nu{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=igt(this.code),r=t.state.phrase("Control character")+" "+(Jmt[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,r,n);if(i)return i;let s=document.createElement("span");return s.textContent=n,s.title=r,s.setAttribute("aria-label",r),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class agt extends Nu{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function ogt(){return cgt}const lgt=dn.line({class:"cm-activeLine"}),cgt=ps.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(lgt.range(i.from)),t=i.from)}return dn.set(n)}},{decorations:e=>e.decorations});class ugt extends Nu{constructor(t){super(),this.content=t}toDOM(t){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(t){let n=t.firstChild?qv(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=aS(n[0],r.direction!="rtl"),s=parseInt(r.lineHeight);return i.bottom-i.top>s*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+s}:i}ignoreEvent(){return!1}}function dgt(e){let t=ps.fromClass(class{constructor(n){this.view=n,this.placeholder=e?dn.set([dn.widget({widget:new ugt(e),side:1}).range(0)]):dn.none}get decorations(){return this.view.state.doc.length?dn.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,Ct.contentAttributes.of({"aria-placeholder":e})]:t}const u6=2e3;function fgt(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),s=[];if(t.off>u6||n.off>u6||t.col<0||n.col<0){let a=Math.min(t.off,n.off),l=Math.max(t.off,n.off);for(let c=r;c<=i;c++){let u=e.doc.line(c);u.length<=l&&s.push(Je.range(u.from+a,u.to+l))}}else{let a=Math.min(t.col,n.col),l=Math.max(t.col,n.col);for(let c=r;c<=i;c++){let u=e.doc.line(c),d=zL(u.text,a,e.tabSize,!0);if(d<0)s.push(Je.cursor(u.to));else{let f=zL(u.text,l,e.tabSize);s.push(Je.range(u.from+d,u.from+f))}}}return s}function hgt(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function aZ(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,s=i>u6?-1:i==r.length?hgt(e,t.clientX):vu(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:s,off:i}}function pgt(e,t){let n=aZ(e,t),r=e.state.selection;return n?{update(i){if(i.docChanged){let s=i.changes.mapPos(i.startState.doc.line(n.line).from),a=i.state.doc.lineAt(s);n={line:a.number,col:n.col,off:Math.min(n.off,a.length)},r=r.map(i.changes)}},get(i,s,a){let l=aZ(e,i);if(!l)return r;let c=fgt(e.state,n,l);return c.length?a?Je.create(c.concat(r.ranges)):Je.create(c):r}}:null}function mgt(e){let t=n=>n.altKey&&n.button==0;return Ct.mouseSelectionStyle.of((n,r)=>t(r)?pgt(n,r):null)}const ggt={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},bgt={style:"cursor: crosshair"};function ygt(e={}){let[t,n]=ggt[e.key||"Alt"],r=ps.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==t||n(i))},keyup(i){(i.keyCode==t||!n(i))&&this.set(!1)},mousemove(i){this.set(n(i))}}});return[r,Ct.contentAttributes.of(i=>{var s;return!((s=i.plugin(r))===null||s===void 0)&&s.isDown?bgt:null})]}const G2="-10000px";class Fye{constructor(t,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=t.state.facet(n),this.tooltips=this.input.filter(a=>a);let s=null;this.tooltipViews=this.tooltips.map(a=>s=r(a,s))}update(t,n){var r;let i=t.state.facet(this.facet),s=i.filter(c=>c);if(i===this.input){for(let c of this.tooltipViews)c.update&&c.update(t);return!1}let a=[],l=n?[]:null;for(let c=0;cn[u]=c),n.length=l.length),this.input=i,this.tooltips=s,this.tooltipViews=a,!0}}function Ogt(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const HD=Qt.define({combine:e=>{var t,n,r;return{position:$t.ios?"absolute":((t=e.find(i=>i.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((n=e.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=e.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||Ogt}}}),oZ=new WeakMap,SQ=ps.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(HD);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Fye(e,EQ,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(HD);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=G2,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(e=r.destroy)===null||e===void 0||e.call(r);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if($t.safari){let a=s.getBoundingClientRect();n=Math.abs(a.top+1e4)>1||Math.abs(a.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(e=s.width/this.parent.offsetWidth,t=s.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=OQ(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,a)=>{let l=this.manager.tooltipViews[a];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(HD).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:s}=e,a=[];for(let l=0;l=Math.min(n.bottom,r.bottom)||f.rightMath.min(n.right,r.right)+.1)){d.style.top=G2;continue}let m=c.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,g=m?7:0,b=h.right-h.left,y=(t=oZ.get(u))!==null&&t!==void 0?t:h.bottom-h.top,O=u.offset||vgt,v=this.view.textDirection==xi.LTR,x=h.width>r.right-r.left?v?r.left:r.right-h.width:v?Math.max(r.left,Math.min(f.left-(m?14:0)+O.x,r.right-b)):Math.min(Math.max(r.left,f.left-b+(m?14:0)-O.x),r.right-b),w=this.above[l];!c.strictSide&&(w?f.top-y-g-O.yr.bottom)&&w==r.bottom-f.bottom>f.top-r.top&&(w=this.above[l]=!w);let S=(w?f.top-r.top:r.bottom-f.bottom)-g;if(Sx&&_.topE&&(E=w?_.top-y-2-g:_.bottom+g+2);if(this.position=="absolute"?(d.style.top=(E-e.parent.top)/s+"px",lZ(d,(x-e.parent.left)/i)):(d.style.top=E/s+"px",lZ(d,x/i)),m){let _=f.left+(v?O.x:-O.x)-(x+14-7);m.style.left=_/i+"px"}u.overlap!==!0&&a.push({left:x,top:E,right:k,bottom:E+y}),d.classList.toggle("cm-tooltip-above",w),d.classList.toggle("cm-tooltip-below",!w),u.positioned&&u.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=G2}},{eventObservers:{scroll(){this.maybeMeasure()}}});function lZ(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const xgt=Ct.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),vgt={x:0,y:0},EQ=Qt.define({enables:[SQ,xgt]}),wA=Qt.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class rR{static create(t){return new rR(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Fye(t,wA,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(t,n){let r=t.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(t){for(let n of this.manager.tooltipViews)n.mount&&n.mount(t);this.mounted=!0}positioned(t){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let n of this.manager.tooltipViews)(t=n.destroy)===null||t===void 0||t.call(n)}passProp(t){let n;for(let r of this.manager.tooltipViews){let i=r[t];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const wgt=EQ.compute([wA],e=>{let t=e.facet(wA);return t.length===0?null:{pos:Math.min(...t.map(n=>n.pos)),end:Math.max(...t.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:rR.create,above:t[0].above,arrow:t.some(n=>n.arrow)}}),zye=Qt.define();class Sgt{constructor(t,n,r,i,s,a){this.view=t,this.source=n,this.field=r,this.locked=i,this.setHover=s,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(t){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;ta.bottom||n.xa.right+t.defaultCharacterWidth)return;let l=t.bidiSpans(t.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),c=l&&l.dir==xi.RTL?-1:1;s=n.x{if(l&&!(Array.isArray(l)&&!l.length)){let c=Array.isArray(l)?l:[l];i&&this.locked.set(c,i),t.dispatch({effects:this.setHover.of(c)})}};if(s&&"then"in s){let l=this.pending={pos:n};s.then(c=>{this.pending==l&&(this.pending=null,a(c))},c=>Go(t.state,c,"hover tooltip"))}else a(s)}get tooltip(){let t=this.view.plugin(SQ),n=t?t.manager.tooltips.findIndex(r=>r.create==rR.create):-1;return n>-1?t.manager.tooltipViews[n]:null}mousemove(t){var n,r;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&!this.locked.has(i)&&s&&!Egt(s.dom,t)||this.pending){let{pos:a}=i[0]||this.pending,l=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:a;(a==l?this.view.posAtCoords(this.lastMove)!=a:!kgt(this.view,a,l,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length&&!this.locked.has(n)){let{tooltip:r}=this;r&&r.dom.contains(t.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let n=r=>{t.removeEventListener("mouseleave",n);let{active:i}=this;i.length&&!this.locked.has(i)&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const W2=4;function Egt(e,t){let{left:n,right:r,top:i,bottom:s}=e.getBoundingClientRect(),a;if(a=e.querySelector(".cm-tooltip-arrow")){let l=a.getBoundingClientRect();i=Math.min(l.top,i),s=Math.max(l.bottom,s)}return t.clientX>=n-W2&&t.clientX<=r+W2&&t.clientY>=i-W2&&t.clientY<=s+W2}function kgt(e,t,n,r,i,s){let a=e.scrollDOM.getBoundingClientRect(),l=e.documentTop+e.documentPadding.top+e.contentHeight;if(a.left>r||a.righti||Math.min(a.bottom,l)=t&&c<=n}function _gt(e,t={}){let n=jn.define(),r=new WeakMap,i=Qa.define({create(){return[]},update(a,l){let c=r.get(a);if(a.length&&(t.hideOnChange&&(l.docChanged||l.selection)?a=[]:c&&c(l)?a=[]:t.hideOn&&(a=a.filter(u=>!t.hideOn(l,u)))),l.docChanged&&a.length){let u=[];for(let d of a){let f=l.changes.mapPos(d.pos,-1,Pa.TrackDel);if(f!=null){let h=Object.assign(Object.create(null),d);h.pos=f,h.end!=null&&(h.end=l.changes.mapPos(h.end)),u.push(h)}}a=u}for(let u of l.effects)u.is(n)&&(a=u.value,c=void 0),(u.is(Cgt)&&!u.value||u.value==i)&&(a=[]);return a.length&&c&&r.set(a,c),a},provide:a=>wA.from(a)});const s=ps.define(a=>new Sgt(a,e,i,r,n,t.hoverTime||300));return{active:i,extension:[i,s,zye.of(s),wgt]}}function Tgt(e,t,n,r={}){var i;let s=e.state.facet(zye).map(a=>e.plugin(a)).filter(a=>!!a);if(r.tooltip&&r.tooltip.active){let a=s.find(l=>l.field==r.tooltip.active);a&&(s=[a])}for(let a of s)a.activateHover(e,t,n,(i=r.until)!==null&&i!==void 0?i:()=>!1)}function Vye(e,t){let n=e.plugin(SQ);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const Cgt=jn.define(),cZ=Qt.define({combine(e){let t,n;for(let r of e)t=t||r.topContainer,n=n||r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function kQ(e,t){let n=e.plugin(Hye),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const Hye=ps.fromClass(class{constructor(e){this.input=e.state.facet(lS),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(cZ);this.top=new Y2(e,!0,t.topContainer),this.bottom=new Y2(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(e){let t=e.state.facet(cZ);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Y2(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Y2(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(lS);if(n!=this.input){let r=n.filter(c=>c),i=[],s=[],a=[],l=[];for(let c of r){let u=this.specs.indexOf(c),d;u<0?(d=c(e.view),l.push(d)):(d=this.panels[u],d.update&&d.update(e)),i.push(d),(d.top?s:a).push(d)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(a);for(let c of l)c.dom.classList.add("cm-panel"),c.mount&&c.mount()}else for(let r of this.panels)r.update&&r.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Ct.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class Y2{constructor(t,n,r){this.view=t,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let n of this.panels)n.destroy&&t.indexOf(n)<0&&n.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let t=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;t!=n.dom;)t=uZ(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=uZ(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function uZ(e){let t=e.nextSibling;return e.remove(),t}const lS=Qt.define({enables:Hye});function Agt(e,t){let n,r=new Promise(a=>n=a),i=a=>Ngt(a,t,n);e.state.field(qD,!1)?e.dispatch({effects:qye.of(i)}):e.dispatch({effects:jn.appendConfig.of(qD.init(()=>[i]))});let s=Xye.of(i);return{close:s,result:r.then(a=>((e.win.queueMicrotask||(c=>e.win.setTimeout(c,10)))(()=>{e.state.field(qD).indexOf(i)>-1&&e.dispatch({effects:s})}),a))}}const qD=Qa.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(qye)?e=[n.value].concat(e):n.is(Xye)&&(e=e.filter(r=>r!=n.value));return e},provide:e=>lS.computeN([e],t=>t.field(e))}),qye=jn.define(),Xye=jn.define();function Ngt(e,t,n){let r=t.content?t.content(e,()=>a(null)):null;if(!r){if(r=fi("form"),t.input){let l=fi("input",t.input);/^(text|password|number|email|tel|url)$/.test(l.type)&&l.classList.add("cm-textfield"),l.name||(l.name="input"),r.appendChild(fi("label",(t.label||"")+": ",l))}else r.appendChild(document.createTextNode(t.label||""));r.appendChild(document.createTextNode(" ")),r.appendChild(fi("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let i=r.nodeName=="FORM"?[r]:r.querySelectorAll("form");for(let l=0;l{u.keyCode==27?(u.preventDefault(),a(null)):u.keyCode==13&&(u.preventDefault(),a(c))}),c.addEventListener("submit",u=>{u.preventDefault(),a(c)})}let s=fi("div",r,fi("button",{onclick:()=>a(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));t.class&&(s.className=t.class),s.classList.add("cm-dialog");function a(l){s.contains(s.ownerDocument.activeElement)&&e.focus(),n(l)}return{dom:s,top:t.top,mount:()=>{if(t.focus){let l;typeof t.focus=="string"?l=r.querySelector(t.focus):l=r.querySelector("input")||r.querySelector("button"),l&&"select"in l?l.select():l&&"focus"in l&&l.focus()}}}}class oh extends Kp{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}oh.prototype.elementClass="";oh.prototype.toDOM=void 0;oh.prototype.mapMode=Pa.TrackBefore;oh.prototype.startSide=oh.prototype.endSide=-1;oh.prototype.point=!0;const OT=Qt.define(),jgt=Qt.define(),Rgt={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>gr.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Wv=Qt.define();function Igt(e){return[Gye(),Wv.of({...Rgt,...e})]}const dZ=Qt.define({combine:e=>e.some(t=>t)});function Gye(e){return[Dgt]}const Dgt=ps.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(Wv).map(t=>new hZ(e,t)),this.fixed=!e.state.facet(dZ);for(let t of this.gutters)t.config.side=="after"?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(dZ)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=gr.iter(this.view.state.facet(OT),this.view.viewport.from),r=[],i=this.gutters.map(s=>new Pgt(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(s.type)){let a=!0;for(let l of s.type)if(l.type==Ba.Text&&a){d6(n,r,l.from);for(let c of i)c.line(this.view,l,r);a=!1}else if(l.widget)for(let c of i)c.widget(this.view,l)}else if(s.type==Ba.Text){d6(n,r,s.from);for(let a of i)a.line(this.view,s,r)}else if(s.widget)for(let a of i)a.widget(this.view,s);for(let s of i)s.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(Wv),n=e.state.facet(Wv),r=e.docChanged||e.heightChanged||e.viewportChanged||!gr.eq(e.startState.facet(OT),e.state.facet(OT),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let i of this.gutters)i.update(e)&&(r=!0);else{r=!0;let i=[];for(let s of n){let a=t.indexOf(s);a<0?i.push(new hZ(this.view,s)):(this.gutters[a].update(e),i.push(this.gutters[a]))}for(let s of this.gutters)s.dom.remove(),i.indexOf(s)<0&&s.destroy();for(let s of i)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>Ct.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==xi.LTR?{left:r,right:i}:{right:r,left:i}})});function fZ(e){return Array.isArray(e)?e:[e]}function d6(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class Pgt{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=gr.iter(t.markers,n.from)}addElement(t,n,r){let{gutter:i}=this,s=(n.top-this.height)/t.scaleY,a=n.height/t.scaleY;if(this.i==i.elements.length){let l=new Wye(t,a,s,r);i.elements.push(l),i.dom.appendChild(l.dom)}else i.elements[this.i].update(t,a,s,r);this.height=n.bottom,this.i++}line(t,n,r){let i=[];d6(this.cursor,i,n.from),r.length&&(i=i.concat(r));let s=this.gutter.config.lineMarker(t,n,i);s&&i.unshift(s);let a=this.gutter;i.length==0&&!a.config.renderEmptyElements||this.addElement(t,n,i)}widget(t,n){let r=this.gutter.config.widgetMarker(t,n.widget,n),i=r?[r]:null;for(let s of t.state.facet(jgt)){let a=s(t,n.widget,n);a&&(i||(i=[])).push(a)}i&&this.addElement(t,n,i)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let n=t.elements.pop();t.dom.removeChild(n.dom),n.destroy()}}}class hZ{constructor(t,n){this.view=t,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,i=>{let s=i.target,a;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let c=s.getBoundingClientRect();a=(c.top+c.bottom)/2}else a=i.clientY;let l=t.lineBlockAtHeight(a-t.documentTop);n.domEventHandlers[r](t,l,i)&&i.preventDefault()});this.markers=fZ(n.markers(t)),n.initialSpacer&&(this.spacer=new Wye(t,0,0,[n.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let n=this.markers;if(this.markers=fZ(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],t);i!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[i])}let r=t.view.viewport;return!gr.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class Wye{constructor(t,n,r,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,n,r,i)}update(t,n,r,i){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Mgt(this.markers,i)||this.setMarkers(t,i)}setMarkers(t,n){let r="cm-gutterElement",i=this.dom.firstChild;for(let s=0,a=0;;){let l=a,c=ss(l,c,u)||a(l,c,u):a}return r}})}});class XD extends oh{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function GD(e,t){return e.state.facet(Jb).formatNumber(t,e.state)}const Bgt=Wv.compute([Jb],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(Lgt)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new XD(GD(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet($gt)){let s=i(t,n,r);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(Jb)!=t.state.facet(Jb),initialSpacer(t){return new XD(GD(t,pZ(t.state.doc.lines)))},updateSpacer(t,n){let r=GD(n.view,pZ(n.view.state.doc.lines));return r==t.number?t:new XD(r)},domEventHandlers:e.facet(Jb).domEventHandlers,side:"before"}));function Qgt(e={}){return[Jb.of(e),Gye(),Bgt]}function pZ(e){let t=9;for(;t{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(Ugt.range(i)))}return gr.of(t)});function zgt(){return Fgt}let Vgt=0,Xu=class f6{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=Vgt++}toString(){let{name:t}=this;for(let n of this.modified)n.name&&(t=`${n.name}(${t})`);return t}static define(t,n){let r=typeof t=="string"?t:"?";if(t instanceof f6&&(n=t),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new f6(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(t){let n=new SA(t);return r=>r.modified.indexOf(n)>-1?r:SA.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}},Hgt=0;class SA{constructor(t){this.name=t,this.instances=[],this.id=Hgt++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(l=>l.base==t&&qgt(n,l.modified));if(r)return r;let i=[],s=new Xu(t.name,i,t,n);for(let l of n)l.instances.push(s);let a=Xgt(n);for(let l of t.set)if(!l.modified.length)for(let c of a)i.push(SA.get(l,c));return s}}function qgt(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function Xgt(e){let t=[[]];for(let n=0;nr.length-n.length)}function vh(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],a=2,l=i;for(let f=0;;){if(l=="..."&&f>0&&f+3==i.length){a=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!h)throw new RangeError("Invalid path: "+i);if(s.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),f+=h[0].length,f==i.length)break;let m=i[f++];if(f==i.length&&m=="!"){a=0;break}if(m!="/")throw new RangeError("Invalid path: "+i);l=i.slice(f)}let c=s.length-1,u=s[c];if(!u)throw new RangeError("Invalid path: "+i);let d=new cS(r,a,c>0?s.slice(0,c):null);t[u]=d.sort(t[u])}}return Yye.add(t)}const Yye=new Nn({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let s=new cS(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}});let cS=class{constructor(t,n,r,i){this.tags=t,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth{let a=i;for(let l of s)for(let c of l.set){let u=n[c.id];if(u){a=a?a+" "+u:u;break}}return a},scope:r}}function Ggt(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function Wgt(e,t,n,r=0,i=e.length){let s=new Ygt(r,Array.isArray(t)?t:[t],n);s.highlightRange(e.cursor(),r,i,"",s.highlighters),s.flush(i)}class Ygt{constructor(t,n,r){this.at=t,this.highlighters=n,this.span=r,this.class=""}startSpan(t,n){n!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=n)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,n,r,i,s){let{type:a,from:l,to:c}=t;if(l>=r||c<=n)return;a.isTop&&(s=this.highlighters.filter(m=>!m.scope||m.scope(a)));let u=i,d=Zgt(t)||cS.empty,f=Ggt(s,d.tags);if(f&&(u&&(u+=" "),u+=f,d.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(n,l),u),d.opaque)return;let h=t.tree&&t.tree.prop(Nn.mounted);if(h&&h.overlay){let m=t.node.enter(h.overlay[0].from+l,1),g=this.highlighters.filter(y=>!y.scope||y.scope(h.tree.type)),b=t.firstChild();for(let y=0,O=l;;y++){let v=y=x||!t.nextSibling())););if(!v||x>r)break;O=v.to+l,O>n&&(this.highlightRange(m.cursor(),Math.max(n,v.from+l),Math.min(r,O),"",g),this.startSpan(Math.min(r,O),u))}b&&t.parent()}else if(t.firstChild()){h&&(i="");do if(!(t.to<=n)){if(t.from>=r)break;this.highlightRange(t,n,r,i,s),this.startSpan(Math.min(r,t.to),u)}while(t.nextSibling());t.parent()}}}function Zgt(e){let t=e.type.prop(Yye);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const jt=Xu.define,Z2=jt(),Kh=jt(),mZ=jt(Kh),gZ=jt(Kh),Jh=jt(),K2=jt(Jh),WD=jt(Jh),zu=jt(),Nm=jt(zu),Qu=jt(),Uu=jt(),h6=jt(),mx=jt(h6),J2=jt(),Y={comment:Z2,lineComment:jt(Z2),blockComment:jt(Z2),docComment:jt(Z2),name:Kh,variableName:jt(Kh),typeName:mZ,tagName:jt(mZ),propertyName:gZ,attributeName:jt(gZ),className:jt(Kh),labelName:jt(Kh),namespace:jt(Kh),macroName:jt(Kh),literal:Jh,string:K2,docString:jt(K2),character:jt(K2),attributeValue:jt(K2),number:WD,integer:jt(WD),float:jt(WD),bool:jt(Jh),regexp:jt(Jh),escape:jt(Jh),color:jt(Jh),url:jt(Jh),keyword:Qu,self:jt(Qu),null:jt(Qu),atom:jt(Qu),unit:jt(Qu),modifier:jt(Qu),operatorKeyword:jt(Qu),controlKeyword:jt(Qu),definitionKeyword:jt(Qu),moduleKeyword:jt(Qu),operator:Uu,derefOperator:jt(Uu),arithmeticOperator:jt(Uu),logicOperator:jt(Uu),bitwiseOperator:jt(Uu),compareOperator:jt(Uu),updateOperator:jt(Uu),definitionOperator:jt(Uu),typeOperator:jt(Uu),controlOperator:jt(Uu),punctuation:h6,separator:jt(h6),bracket:mx,angleBracket:jt(mx),squareBracket:jt(mx),paren:jt(mx),brace:jt(mx),content:zu,heading:Nm,heading1:jt(Nm),heading2:jt(Nm),heading3:jt(Nm),heading4:jt(Nm),heading5:jt(Nm),heading6:jt(Nm),contentSeparator:jt(zu),list:jt(zu),quote:jt(zu),emphasis:jt(zu),strong:jt(zu),link:jt(zu),monospace:jt(zu),strikethrough:jt(zu),inserted:jt(),deleted:jt(),changed:jt(),invalid:jt(),meta:J2,documentMeta:jt(J2),annotation:jt(J2),processingInstruction:jt(J2),definition:Xu.defineModifier("definition"),constant:Xu.defineModifier("constant"),function:Xu.defineModifier("function"),standard:Xu.defineModifier("standard"),local:Xu.defineModifier("local"),special:Xu.defineModifier("special")};for(let e in Y){let t=Y[e];t instanceof Xu&&(t.name=e)}Zye([{tag:Y.link,class:"tok-link"},{tag:Y.heading,class:"tok-heading"},{tag:Y.emphasis,class:"tok-emphasis"},{tag:Y.strong,class:"tok-strong"},{tag:Y.keyword,class:"tok-keyword"},{tag:Y.atom,class:"tok-atom"},{tag:Y.bool,class:"tok-bool"},{tag:Y.url,class:"tok-url"},{tag:Y.labelName,class:"tok-labelName"},{tag:Y.inserted,class:"tok-inserted"},{tag:Y.deleted,class:"tok-deleted"},{tag:Y.literal,class:"tok-literal"},{tag:Y.string,class:"tok-string"},{tag:Y.number,class:"tok-number"},{tag:[Y.regexp,Y.escape,Y.special(Y.string)],class:"tok-string2"},{tag:Y.variableName,class:"tok-variableName"},{tag:Y.local(Y.variableName),class:"tok-variableName tok-local"},{tag:Y.definition(Y.variableName),class:"tok-variableName tok-definition"},{tag:Y.special(Y.variableName),class:"tok-variableName2"},{tag:Y.definition(Y.propertyName),class:"tok-propertyName tok-definition"},{tag:Y.typeName,class:"tok-typeName"},{tag:Y.namespace,class:"tok-namespace"},{tag:Y.className,class:"tok-className"},{tag:Y.macroName,class:"tok-macroName"},{tag:Y.propertyName,class:"tok-propertyName"},{tag:Y.operator,class:"tok-operator"},{tag:Y.comment,class:"tok-comment"},{tag:Y.meta,class:"tok-meta"},{tag:Y.invalid,class:"tok-invalid"},{tag:Y.punctuation,class:"tok-punctuation"}]);var YD;const bp=new Nn;function iR(e){return Qt.define({combine:e?t=>t.concat(e):void 0})}const _Q=new Nn;class Al{constructor(t,n,r=[],i=""){this.data=t,this.name=i,vr.prototype.hasOwnProperty("tree")||Object.defineProperty(vr.prototype,"tree",{get(){return mi(this)}}),this.parser=n,this.extension=[nm.of(this),vr.languageData.of((s,a,l)=>{let c=bZ(s,a,l),u=c.type.prop(bp);if(!u)return[];let d=s.facet(u),f=c.type.prop(_Q);if(f){let h=c.resolve(a-c.from,l);for(let m of f)if(m.test(h,s)){let g=s.facet(m.facet);return m.type=="replace"?g:g.concat(d)}}return d})].concat(r)}isActiveAt(t,n,r=-1){return bZ(t,n,r).type.prop(bp)==this.data}findRegions(t){let n=t.facet(nm);if((n==null?void 0:n.data)==this.data)return[{from:0,to:t.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(s,a)=>{if(s.prop(bp)==this.data){r.push({from:a,to:a+s.length});return}let l=s.prop(Nn.mounted);if(l){if(l.tree.prop(bp)==this.data){if(l.overlay)for(let c of l.overlay)r.push({from:c.from+a,to:c.to+a});else r.push({from:a,to:a+s.length});return}else if(l.overlay){let c=r.length;if(i(l.tree,l.overlay[0].from+a),r.length>c)return}}for(let c=0;cr.isTop?n:void 0)]}),t.name)}configure(t,n){return new lh(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function mi(e){let t=e.field(Al.state,!1);return t?t.tree:cr.empty}class Kgt{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,n){let r=this.cursorPos-this.string.length;return t=this.cursorPos?this.doc.sliceString(t,n):this.string.slice(t-r,n-r)}}let gx=null;class Zg{constructor(t,n,r=[],i,s,a,l,c){this.parser=t,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=a,this.skipped=l,this.scheduleOn=c,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new Zg(t,n,[],cr.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Kgt(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=cr.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let i=Date.now()+t;t=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=t,this.tree=n,this.fragments=this.withoutTempSkipped(Uf.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=gx;gx=this;try{return t()}finally{gx=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=yZ(t,n.from,n.to);return t}changes(t,n){let{fragments:r,tree:i,treeLen:s,viewport:a,skipped:l}=this;if(this.takeTree(),!t.empty){let c=[];if(t.iterChangedRanges((u,d,f,h)=>c.push({fromA:u,toA:d,fromB:f,toB:h})),r=Uf.applyChanges(r,c),i=cr.empty,s=0,a={from:t.mapPos(a.from,-1),to:t.mapPos(a.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let d=t.mapPos(u.from,1),f=t.mapPos(u.to,-1);dt.from&&(this.fragments=yZ(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,n){this.skipped.push({from:t,to:n})}static getSkippingParser(t){return new class extends Yj{createParse(n,r,i){let s=i[0].from,a=i[i.length-1].to;return{parsedPos:s,advance(){let c=gx;if(c){for(let u of i)c.tempSkipped.push(u);t&&(c.scheduleOn=c.scheduleOn?Promise.all([c.scheduleOn,t]):t)}return this.parsedPos=a,new cr(Hs.none,[],[],a-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let n=this.fragments;return this.treeLen>=t&&n.length&&n[0].from==0&&n[0].to>=t}static get(){return gx}}function yZ(e,t,n){return Uf.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class S1{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new S1(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=Zg.create(t.facet(nm).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new S1(r)}}Al.state=Qa.define({create:S1.init,update(e,t){for(let n of t.effects)if(n.is(Al.setState))return n.value;return t.startState.facet(nm)!=t.state.facet(nm)?S1.init(t.state):e.apply(t)}});let Kye=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Kye=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const ZD=typeof navigator<"u"&&(!((YD=navigator.scheduling)===null||YD===void 0)&&YD.isInputPending)?()=>navigator.scheduling.isInputPending():null,Jgt=ps.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let n=this.view.state.field(Al.state).context;(n.updateViewport(t.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:t}=this.view,n=t.field(Al.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=Kye(this.work))}work(t){this.working=null;let n=Date.now();if(this.chunkEndi+1e3,c=s.context.work(()=>ZD&&ZD()||Date.now()>a,i+(l?0:1e5));this.chunkBudget-=Date.now()-n,(c||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Al.setState.of(new S1(s.context))})),this.chunkBudget>0&&!(c&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Go(this.view.state,n)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),nm=Qt.define({combine(e){return e.length?e[0]:null},enables:e=>[Al.state,Jgt,Ct.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class rm{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class EA{constructor(t,n,r,i,s,a=void 0){this.name=t,this.alias=n,this.extensions=r,this.filename=i,this.loadFunc=s,this.support=a,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");n=()=>Promise.resolve(r)}return new EA(t.name,(t.alias||[]).concat(t.name).map(i=>i.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(t,n){for(let i of t)if(i.filename&&i.filename.test(n))return i;let r=/\.([^.]+)$/.exec(n);if(r){for(let i of t)if(i.extensions.indexOf(r[1])>-1)return i}return null}static matchLanguageName(t,n,r=!0){n=n.toLowerCase();for(let i of t)if(i.alias.some(s=>s==n))return i;if(r)for(let i of t)for(let s of i.alias){let a=n.indexOf(s);if(a>-1&&(s.length>2||!/\w/.test(n[a-1])&&!/\w/.test(n[a+s.length])))return i}return null}}const e0t=Qt.define(),OO=Qt.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(n=>n!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function Kg(e){let t=e.facet(OO);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function uS(e,t){let n="",r=e.tabSize,i=e.facet(OO)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let s=0;s=t?t0t(e,n,t):null}class sR{constructor(t,n={}){this.state=t,this.options=n,this.unit=Kg(t)}lineAt(t,n=1){let r=this.state.doc.lineAt(t),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&i==t?{text:"",from:t}:(n<0?i-1&&(s+=a-this.countColumn(r,r.search(/\S|$/))),s}countColumn(t,n=t.length){return vu(t,this.state.tabSize,n)}lineIndent(t,n=1){let{text:r,from:i}=this.lineAt(t,n),s=this.options.overrideIndentation;if(s){let a=s(i);if(a>-1)return a}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const wh=new Nn;function t0t(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let a=i;a&&!(a.fromr.node.to||a.from==r.node.from&&a.type==r.node.type);a=a.parent)s.push(a);for(let a=s.length-1;a>=0;a--)r={node:s[a],next:r}}return Jye(r,e,n)}function Jye(e,t,n){for(let r=e;r;r=r.next){let i=r0t(r.node);if(i)return i(CQ.create(t,n,r))}return 0}function n0t(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function r0t(e){let t=e.type.prop(wh);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Nn.closedBy))){let i=e.lastChild,s=i&&r.indexOf(i.name)>-1;return a=>e1e(a,!0,1,void 0,s&&!n0t(a)?i.from:void 0)}return e.parent==null?i0t:null}function i0t(){return 0}class CQ extends sR{constructor(t,n,r){super(t.state,t.options),this.base=t,this.pos=n,this.context=r}get node(){return this.context.node}static create(t,n,r){return new CQ(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let n=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(s0t(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Jye(this.context.next,this.base,this.pos)}}function s0t(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function a0t(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,s=e.state.doc.lineAt(n.from),a=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let l=n.to;;){let c=t.childAfter(l);if(!c||c==r)return null;if(!c.type.isSkipped){if(c.from>=a)return null;let u=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+u}}l=c.to}}function Cy({closing:e,align:t=!0,units:n=1}){return r=>e1e(r,t,n,e)}function e1e(e,t,n,r,i){let s=e.textAfter,a=s.match(/^\s*/)[0].length,l=r&&s.slice(a,a+r.length)==r||i==e.pos+a,c=t?a0t(e):null;return c?l?e.column(c.from):e.column(c.to):e.baseIndent+(l?0:e.unit*n)}const o0t=e=>e.baseIndent;function Ay({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const l0t=200;function c0t(){return vr.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+l0t)return e;let s=n.sliceString(i.from,r);if(!t.some(u=>u.test(s)))return e;let{state:a}=e,l=-1,c=[];for(let{head:u}of a.selection.ranges){let d=a.doc.lineAt(u);if(d.from==l)continue;l=d.from;let f=TQ(a,d.from);if(f==null)continue;let h=/^\s*/.exec(d.text)[0],m=uS(a,f);h!=m&&c.push({from:d.from,to:d.from+h.length,insert:m})}return c.length?[e,{changes:c,sequential:!0}]:e})}const t1e=Qt.define(),Sh=new Nn;function BE(e){let t=e.firstChild,n=e.lastChild;return t&&t.ton)continue;if(s&&l.from=t&&u.to>n&&(s=u)}}return s}function d0t(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function kA(e,t,n){for(let r of e.facet(t1e)){let i=r(e,t,n);if(i)return i}return u0t(e,t,n)}function n1e(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const aR=jn.define({map:n1e}),QE=jn.define({map:n1e});function r1e(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(r=>r.from<=n&&r.to>=n)||t.push(e.lineBlockAt(n));return t}const Jg=Qa.define({create(){return dn.none},update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((r,i)=>e=OZ(e,r,i)),e=e.map(t.changes);let n=[];for(let r of t.effects)r.is(aR)&&!f0t(e,r.value.from,r.value.to)?n.push(r.value):r.is(QE)&&(e=e.update({filter:(i,s)=>r.value.from!=i||r.value.to!=s,filterFrom:r.value.from,filterTo:r.value.to}));if(n.length){let{preparePlaceholder:r}=t.state.facet(a1e),i=n.map(s=>(r?dn.replace({widget:new O0t(r(t.state,s))}):xZ).range(s.from,s.to));e=e.update({add:i})}return t.selection&&(e=OZ(e,t.selection.main.head)),e},provide:e=>Ct.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(r,i)=>{n.push(r,i)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n{it&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(i,s)=>i>=n||s<=t}):e}function _A(e,t,n){var r;let i=null;return(r=e.field(Jg,!1))===null||r===void 0||r.between(t,n,(s,a)=>{(!i||i.from>s)&&(i={from:s,to:a})}),i}function f0t(e,t,n){let r=!1;return e.between(t,t,(i,s)=>{i==t&&s==n&&(r=!0)}),r}function i1e(e,t){return e.field(Jg,!1)?t:t.concat(jn.appendConfig.of(o1e()))}const h0t=e=>{for(let t of r1e(e)){let n=kA(e.state,t.from,t.to);if(n)return e.dispatch({effects:i1e(e.state,[aR.of(n),s1e(e,n)])}),!0}return!1},p0t=e=>{if(!e.state.field(Jg,!1))return!1;let t=[];for(let n of r1e(e)){let r=_A(e.state,n.from,n.to);r&&t.push(QE.of(r),s1e(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function s1e(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return Ct.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const m0t=e=>{let{state:t}=e,n=[];for(let r=0;r{let t=e.state.field(Jg,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(QE.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},b0t=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:h0t},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:p0t},{key:"Ctrl-Alt-[",run:m0t},{key:"Ctrl-Alt-]",run:g0t}],y0t={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},a1e=Qt.define({combine(e){return Nd(e,y0t)}});function o1e(e){return[Jg,w0t]}function l1e(e,t){let{state:n}=e,r=n.facet(a1e),i=a=>{let l=e.lineBlockAt(e.posAtDOM(a.target)),c=_A(e.state,l.from,l.to);c&&e.dispatch({effects:QE.of(c)}),a.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let s=document.createElement("span");return s.textContent=r.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}const xZ=dn.replace({widget:new class extends Nu{toDOM(e){return l1e(e,null)}}});class O0t extends Nu{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return l1e(t,this.value)}}const x0t={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class KD extends oh{constructor(t,n){super(),this.config=t,this.open=n}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=t.state.phrase(this.open?"Fold line":"Unfold line"),n}}function v0t(e={}){let t={...x0t,...e},n=new KD(t,!0),r=new KD(t,!1),i=ps.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(nm)!=a.state.facet(nm)||a.startState.field(Jg,!1)!=a.state.field(Jg,!1)||mi(a.startState)!=mi(a.state)||t.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let l=new sh;for(let c of a.viewportLineBlocks){let u=_A(a.state,c.from,c.to)?r:kA(a.state,c.from,c.to)?n:null;u&&l.add(c.from,c.from,u)}return l.finish()}}),{domEventHandlers:s}=t;return[i,Igt({class:"cm-foldGutter",markers(a){var l;return((l=a.plugin(i))===null||l===void 0?void 0:l.markers)||gr.empty},initialSpacer(){return new KD(t,!1)},domEventHandlers:{...s,click:(a,l,c)=>{if(s.click&&s.click(a,l,c))return!0;let u=_A(a.state,l.from,l.to);if(u)return a.dispatch({effects:QE.of(u)}),!0;let d=kA(a.state,l.from,l.to);return d?(a.dispatch({effects:aR.of(d)}),!0):!1}}}),o1e()]}const w0t=Ct.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class UE{constructor(t,n){this.specs=t;let r;function i(l){let c=Jp.newName();return(r||(r=Object.create(null)))["."+c]=l,c}const s=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,a=n.scope;this.scope=a instanceof Al?l=>l.prop(bp)==a.data:a?l=>l==a:void 0,this.style=Zye(t.map(l=>({tag:l.tag,class:l.class||i(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new Jp(r):null,this.themeType=n.themeType}static define(t,n){return new UE(t,n||{})}}const p6=Qt.define(),c1e=Qt.define({combine(e){return e.length?[e[0]]:null}});function xT(e){let t=e.facet(p6);return t.length?t:e.facet(c1e)}function u1e(e,t){let n=[E0t],r;return e instanceof UE&&(e.module&&n.push(Ct.styleModule.of(e.module)),r=e.themeType),t!=null&&t.fallback?n.push(c1e.of(e)):r?n.push(p6.computeN([Ct.darkTheme],i=>i.facet(Ct.darkTheme)==(r=="dark")?[e]:[])):n.push(p6.of(e)),n}function RMt(e,t,n){let r=xT(e),i=null;if(r){for(let s of r)if(!s.scope||n){let a=s.style(t);a&&(i=i?i+" "+a:a)}}return i}class S0t{constructor(t){this.markCache=Object.create(null),this.tree=mi(t.state),this.decorations=this.buildDeco(t,xT(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=mi(t.state),r=xT(t.state),i=r!=xT(t.startState),{viewport:s}=t.view,a=t.changes.mapPos(this.decoratedTo,1);n.length=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=a):(n!=this.tree||t.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=s.to)}buildDeco(t,n){if(!n||!this.tree.length)return dn.none;let r=new sh;for(let{from:i,to:s}of t.visibleRanges)Wgt(this.tree,n,(a,l,c)=>{r.add(a,l,this.markCache[c]||(this.markCache[c]=dn.mark({class:c})))},i,s);return r.finish()}}const E0t=xh.high(ps.fromClass(S0t,{decorations:e=>e.decorations})),k0t=UE.define([{tag:Y.meta,color:"#404740"},{tag:Y.link,textDecoration:"underline"},{tag:Y.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Y.emphasis,fontStyle:"italic"},{tag:Y.strong,fontWeight:"bold"},{tag:Y.strikethrough,textDecoration:"line-through"},{tag:Y.keyword,color:"#708"},{tag:[Y.atom,Y.bool,Y.url,Y.contentSeparator,Y.labelName],color:"#219"},{tag:[Y.literal,Y.inserted],color:"#164"},{tag:[Y.string,Y.deleted],color:"#a11"},{tag:[Y.regexp,Y.escape,Y.special(Y.string)],color:"#e40"},{tag:Y.definition(Y.variableName),color:"#00f"},{tag:Y.local(Y.variableName),color:"#30a"},{tag:[Y.typeName,Y.namespace],color:"#085"},{tag:Y.className,color:"#167"},{tag:[Y.special(Y.variableName),Y.macroName],color:"#256"},{tag:Y.definition(Y.propertyName),color:"#00c"},{tag:Y.comment,color:"#940"},{tag:Y.invalid,color:"#f00"}]),_0t=Ct.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),d1e=1e4,f1e="()[]{}",h1e=Qt.define({combine(e){return Nd(e,{afterCursor:!0,brackets:f1e,maxScanDistance:d1e,renderMatch:A0t})}}),T0t=dn.mark({class:"cm-matchingBracket"}),C0t=dn.mark({class:"cm-nonmatchingBracket"});function A0t(e){let t=[],n=e.matched?T0t:C0t;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function vZ(e){let t=[],n=e.facet(h1e);for(let r of e.selection.ranges){if(!r.empty)continue;let i=sd(e,r.head,-1,n)||r.head>0&&sd(e,r.head-1,1,n)||n.afterCursor&&(sd(e,r.head,1,n)||r.heade.decorations}),j0t=[N0t,_0t];function R0t(e={}){return[h1e.of(e),j0t]}const p1e=new Nn;function m6(e,t,n){let r=e.prop(t<0?Nn.openedBy:Nn.closedBy);if(r)return r;if(e.name.length==1){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function g6(e){let t=e.type.prop(p1e);return t?t(e.node):e}function sd(e,t,n,r={}){let i=r.maxScanDistance||d1e,s=r.brackets||f1e,a=mi(e),l=a.resolveInner(t,n);for(let c=l;c;c=c.parent){let u=m6(c.type,n,s);if(u&&c.from0?t>=d.from&&td.from&&t<=d.to))return I0t(e,t,n,c,d,u,s)}}return D0t(e,t,n,a,l.type,i,s)}function I0t(e,t,n,r,i,s,a){let l=r.parent,c={from:i.from,to:i.to},u=0,d=l==null?void 0:l.cursor();if(d&&(n<0?d.childBefore(r.from):d.childAfter(r.to)))do if(n<0?d.to<=r.from:d.from>=r.to){if(u==0&&s.indexOf(d.type.name)>-1&&d.from0)return null;let u={from:n<0?t-1:t,to:n>0?t+1:t},d=e.doc.iterRange(t,n>0?e.doc.length:0),f=0;for(let h=0;!d.next().done&&h<=s;){let m=d.value;n<0&&(h+=m.length);let g=t+h*n;for(let b=n>0?0:m.length-1,y=n>0?m.length:-1;b!=y;b+=n){let O=a.indexOf(m[b]);if(!(O<0||r.resolveInner(g+b,1).type!=i))if(O%2==0==n>0)f++;else{if(f==1)return{start:u,end:{from:g+b,to:g+b+1},matched:O>>1==c>>1};f--}}n>0&&(h+=m.length)}return d.done?{start:u,matched:!1}:null}function wZ(e,t,n,r=0,i=0){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let s=i;for(let a=r;a=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.posn}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let n=this.string.indexOf(t,this.pos);if(n>-1)return this.pos=n,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPosr?a.toLowerCase():a,s=this.string.substr(this.pos,t.length);return i(s)==i(t)?(n!==!1&&(this.pos+=t.length),!0):null}else{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&n!==!1&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function P0t(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||M0t,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||jQ,mergeTokens:e.mergeTokens!==!1}}function M0t(e){if(typeof e!="object")return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}const SZ=new WeakMap;class AQ extends Al{constructor(t){let n=iR(t.languageData),r=P0t(t),i,s=new class extends Yj{createParse(a,l,c){return new $0t(i,a,l,c)}};super(n,s,[],t.name),this.topNode=U0t(n,this),i=this,this.streamParser=r,this.stateAfter=new Nn({perNode:!0}),this.tokenTable=t.tokenTable?new O1e(r.tokenTable):Q0t}static define(t){return new AQ(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=SZ.get(t.state),n!=null&&n1e4)return null;for(;s=r&&n+t.length<=i&&t.prop(e.stateAfter);if(s)return{state:e.streamParser.copyState(s),pos:n+t.length};for(let a=t.children.length-1;a>=0;a--){let l=t.children[a],c=n+t.positions[a],u=l instanceof cr&&c=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let s=t.children.length-1;s>=0;s--){let a=t.positions[s],l=t.children[s],c;if(an&&NQ(e,s.tree,0-s.offset,n,l),u;if(c&&c.pos<=r&&(u=g1e(e,s.tree,n+s.offset,c.pos+s.offset,!1)))return{state:c.state,tree:u}}return{state:e.streamParser.startState(i?Kg(i):4),tree:cr.empty}}let $0t=class{constructor(t,n,r,i){this.lang=t,this.input=n,this.fragments=r,this.ranges=i,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=i[i.length-1].to;let s=Zg.get(),a=i[0].from,{state:l,tree:c}=L0t(t,r,a,this.to,s==null?void 0:s.state);this.state=l,this.parsedPos=this.chunkStart=a+c.length;for(let u=0;uu.from<=s.viewport.from&&u.to>=s.viewport.from)&&(this.state=this.lang.streamParser.startState(Kg(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let t=Zg.get(),n=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),r=Math.min(n,this.chunkStart+512);for(t&&(r=Math.min(r,t.viewport.to));this.parsedPos=n?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,n),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let n=this.input.chunk(t);if(this.input.lineChunks)n==` `&&(n="");else{let r=n.indexOf(` `);r>-1&&(n=n.slice(0,r))}return t+n.length<=this.to?n:n.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,n=this.lineAfter(t),r=t+n.length;for(let i=this.rangeIndex;;){let s=this.ranges[i].to;if(s>=r||(n=n.slice(0,s-(r-n.length)),i++,i==this.ranges.length))break;let a=this.ranges[i].from,l=this.lineAfter(a);n+=l,r=a+l.length}return{line:n,end:r}}skipGapsTo(t,n,r){for(;;){let i=this.ranges[this.rangeIndex].to,s=t+n;if(r>0?i>s:i>=s)break;let a=this.ranges[++this.rangeIndex].from;n+=a-i}return n}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to1){i=this.skipGapsTo(n,i,1),n+=i;let l=this.chunk.length;i=this.skipGapsTo(r,i,-1),r+=i,s+=this.chunk.length-l}let a=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&s==4&&a>=0&&this.chunk[a]==t&&this.chunk[a+2]==n?this.chunk[a+2]=r:this.chunk.push(t,n,r,s),i}parseLine(t){let{line:n,end:r}=this.nextLine(),i=0,{streamParser:s}=this.lang,a=new m1e(n,t?t.state.tabSize:4,t?Kg(t.state):2);if(a.eol())s.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let l=b1e(s.token,a,this.state);if(l&&(i=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+a.start,this.parsedPos+a.pos,i)),a.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPost.start)return i}throw new Error("Stream parser failed to advance stream.")}const jQ=Object.create(null),dS=[Hs.none],B0t=new bO(dS),EZ=[],kZ=Object.create(null),y1e=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])y1e[e]=x1e(jQ,t);class O1e{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),y1e)}resolve(t){return t?this.table[t]||(this.table[t]=x1e(this.extra,t)):0}}const Q0t=new O1e(jQ);function JD(e,t){EZ.indexOf(e)>-1||(EZ.push(e),console.warn(t))}function x1e(e,t){let n=[];for(let l of t.split(" ")){let c=[];for(let u of l.split(".")){let d=e[u]||Y[u];d?typeof d=="function"?c.length?c=c.map(d):JD(u,`Modifier ${u} used at start of tag`):c.length?JD(u,`Tag ${u} used as modifier`):c=Array.isArray(d)?d:[d]:JD(u,`Unknown highlighting tag ${u}`)}for(let u of c)n.push(u)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(l=>l.id),s=kZ[i];if(s)return s.id;let a=kZ[i]=Hs.define({id:dS.length,name:r,props:[vh({[r]:n})]});return dS.push(a),a.id}function U0t(e,t){let n=Hs.define({id:dS.length,name:"Document",props:[bp.add(()=>e),wh.add(()=>r=>t.getIndent(r))],top:!0});return dS.push(n),n}xi.RTL,xi.LTR;var _Z={};class TA{constructor(t,n,r,i,s,a,l,c,u,d=0,f){this.p=t,this.stack=n,this.state=r,this.reducePos=i,this.pos=s,this.score=a,this.buffer=l,this.bufferBase=c,this.curContext=u,this.lookAhead=d,this.parent=f}toString(){return`[${this.stack.filter((t,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,n,r=0){let i=t.parser.context;return new TA(t,[],n,r,r,0,[],0,i?new TZ(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var n;let r=t>>19,i=t&65535,{parser:s}=this.p,a=this.reducePos=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=d):this.p.lastBigReductionSizec;)this.stack.pop();this.reduceContext(i,u)}storeNode(t,n,r,i=4,s=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[a-4]==0&&this.buffer[a-1]>-1){if(n==r)return;if(this.buffer[a-2]>=n){this.buffer[a-2]=r;return}}}if(!s||this.pos==r)this.buffer.push(t,n,r,i);else{let a=this.buffer.length;if(a>0&&(this.buffer[a-4]!=0||this.buffer[a-1]<0)){let l=!1;for(let c=a;c>0&&this.buffer[c-2]>r;c-=4)if(this.buffer[c-1]>=0){l=!0;break}if(l)for(;a>0&&this.buffer[a-2]>r;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,i>4&&(i-=4)}this.buffer[a]=t,this.buffer[a+1]=n,this.buffer[a+2]=r,this.buffer[a+3]=i}}shift(t,n,r,i){if(t&131072)this.pushState(t&65535,this.pos);else if(t&262144)this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4);else{let s=t,{parser:a}=this.p;this.pos=i;let l=a.stateFlag(s,1);!l&&(i>r||n<=a.maxNode)&&(this.reducePos=i),this.pushState(s,l?r:Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=a.maxNode&&this.buffer.push(n,r,i,4)}}apply(t,n,r,i){t&65536?this.reduce(t):this.shift(t,n,r,i)}useNode(t,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=t)&&(this.p.reused.push(t),r++);let i=this.pos;this.reducePos=this.pos=i+t.length,this.pushState(n,i),this.buffer.push(r,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new TA(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(t,n){let r=t<=this.p.parser.maxNode;r&&this.storeNode(t,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(t){for(let n=new F0t(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,t);if(r==0)return!1;if(!(r&65536))return!0;n.reduce(r)}}recoverByInsert(t){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let s=0,a;sc&1&&l==a)||i.push(n[s],a)}n=i}let r=[];for(let i=0;i>19,i=n&65535,s=this.stack.length-r*3;if(s<0||t.getGoto(this.stack[s],i,!1)<0){let a=this.findForcedReduction();if(a==null)return!1;n=a}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:t}=this.p,n=[],r=(i,s)=>{if(!n.includes(i))return n.push(i),t.allActions(i,a=>{if(!(a&393216))if(a&65536){let l=(a>>19)-s;if(l>1){let c=a&65535,u=this.stack.length-l*3;if(u>=0&&t.getGoto(this.stack[u],c,!1)>=0)return l<<19|65536|c}}else{let l=r(a,s+1);if(l!=null)return l}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let n=0;n0&&this.emitLookAhead()}}class TZ{constructor(t,n){this.tracker=t,this.context=n,this.hash=t.strict?t.hash(n):0}}class F0t{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let n=t&65535,r=t>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=i}}class CA{constructor(t,n,r){this.stack=t,this.pos=n,this.index=r,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new CA(t,n,n-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new CA(this.stack,this.pos,this.index)}}function tv(e,t=Uint16Array){if(typeof e!="string")return e;let n=null;for(let r=0,i=0;r=92&&a--,a>=34&&a--;let c=a-32;if(c>=46&&(c-=46,l=!0),s+=c,l)break;s*=46}n?n[i++]=s:n=new t(s)}return n}class vT{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const CZ=new vT;class z0t{constructor(t,n){this.input=t,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=CZ,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(t,n){let r=this.range,i=this.rangeIndex,s=this.pos+t;for(;sr.to:s>=r.to;){if(i==this.ranges.length-1)return null;let a=this.ranges[++i];s+=a.from-r.to,r=a}return s}clipPos(t){if(t>=this.range.from&&tt)return Math.max(t,n.from);return this.end}peek(t){let n=this.chunkOff+t,r,i;if(n>=0&&n=this.chunk2Pos&&rl.to&&(this.chunk2=this.chunk2.slice(0,l.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(t,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r=this.chunk2Pos&&this.posthis.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,n){if(n?(this.token=n,n.start=t,n.lookAhead=t+1,n.value=n.extended=-1):this.token=CZ,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,n-this.chunkPos);if(t>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,n-this.chunk2Pos);if(t>=this.range.from&&n<=this.range.to)return this.input.read(t,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>t&&(r+=this.input.read(Math.max(i.from,t),Math.min(i.to,n)))}return r}}class Ny{constructor(t,n){this.data=t,this.id=n}token(t,n){let{parser:r}=n.p;v1e(this.data,t,n,this.id,r.data,r.tokenPrecTable)}}Ny.prototype.contextual=Ny.prototype.fallback=Ny.prototype.extend=!1;class AA{constructor(t,n,r){this.precTable=n,this.elseToken=r,this.data=typeof t=="string"?tv(t):t}token(t,n){let r=t.pos,i=0;for(;;){let s=t.next<0,a=t.resolveOffset(1,1);if(v1e(this.data,t,n,0,this.data,this.precTable),t.token.value>-1)break;if(this.elseToken==null)return;if(s||i++,a==null)break;t.reset(a,t.token)}i&&(t.reset(r,t.token),t.acceptToken(this.elseToken,i))}}AA.prototype.contextual=Ny.prototype.fallback=Ny.prototype.extend=!1;class js{constructor(t,n={}){this.token=t,this.contextual=!!n.contextual,this.fallback=!!n.fallback,this.extend=!!n.extend}}function v1e(e,t,n,r,i,s){let a=0,l=1<0){let g=e[m];if(c.allows(g)&&(t.token.value==-1||t.token.value==g||V0t(g,t.token.value,i,s))){t.acceptToken(g);break}}let d=t.next,f=0,h=e[a+2];if(t.next<0&&h>f&&e[u+h*3-3]==65535){a=e[u+h*3-1];continue e}for(;f>1,g=u+m+(m<<1),b=e[g],y=e[g+1]||65536;if(d=y)f=m+1;else{a=e[g+2],t.advance();continue e}}break}}function AZ(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function V0t(e,t,n,r){let i=AZ(n,r,t);return i<0||AZ(n,r,e)t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}let H0t=class{constructor(t,n){this.fragments=t,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?NZ(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?NZ(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(tt)return this.nextStart=a,null;if(s instanceof cr){if(a==t){if(a=Math.max(this.safeFrom,t)&&(this.trees.push(s),this.start.push(a),this.index.push(0))}else this.index[n]++,this.nextStart=a+s.length}}};class q0t{constructor(t,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(r=>new vT)}getActions(t){let n=0,r=null,{parser:i}=t.p,{tokenizers:s}=i,a=i.stateSlot(t.state,3),l=t.curContext?t.curContext.hash:0,c=0;for(let u=0;uf.end+25&&(c=Math.max(f.lookAhead,c)),f.value!=0)){let h=n;if(f.extended>-1&&(n=this.addActions(t,f.extended,f.end,n)),n=this.addActions(t,f.value,f.end,n),!d.extend&&(r=f,n>h))break}}for(;this.actions.length>n;)this.actions.pop();return c&&t.setLookAhead(c),!r&&t.pos==this.stream.end&&(r=new vT,r.value=t.p.parser.eofTerm,r.start=r.end=t.pos,n=this.addActions(t,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let n=new vT,{pos:r,p:i}=t;return n.start=r,n.end=Math.min(r+1,i.stream.end),n.value=r==i.stream.end?i.parser.eofTerm:0,n}updateCachedToken(t,n,r){let i=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(i,t),r),t.value>-1){let{parser:s}=r.p;for(let a=0;a=0&&r.p.parser.dialect.allows(l>>1)){l&1?t.extended=l>>1:t.value=l>>1;break}}}else t.value=0,t.end=this.stream.clipPos(i+1)}putAction(t,n,r,i){for(let s=0;st.bufferLength*4?new H0t(r,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,n=this.minStackPos,r=this.stacks=[],i,s;if(this.bigReductionCount>300&&t.length==1){let[a]=t;for(;a.forceReduce()&&a.stack.length&&a.stack[a.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;an)r.push(l);else{if(this.advanceStack(l,r,t))continue;{i||(i=[],s=[]),i.push(l);let c=this.tokens.getMainToken(l);s.push(c.value,c.end)}}break}}if(!r.length){let a=i&&W0t(i);if(a)return fl&&console.log("Finish with "+this.stackID(a)),this.stackToTree(a);if(this.parser.strict)throw fl&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&i){let a=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,r);if(a)return fl&&console.log("Force-finish "+this.stackID(a)),this.stackToTree(a.forceAll())}if(this.recovering){let a=this.recovering==1?1:this.recovering*3;if(r.length>a)for(r.sort((l,c)=>c.score-l.score);r.length>a;)r.pop();r.some(l=>l.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let a=0;a500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)r.splice(c--,1);else{r.splice(a--,1);continue e}}}r.length>12&&(r.sort((a,l)=>l.score-a.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let a=1;a ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let u=t.curContext&&t.curContext.tracker.strict,d=u?t.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let h=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(t.state,f.type.id):-1;if(h>-1&&f.length&&(!u||(f.prop(Nn.contextHash)||0)==d))return t.useNode(f,h),fl&&console.log(a+this.stackID(t)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof cr)||f.children.length==0||f.positions[0]>0)break;let m=f.children[0];if(m instanceof cr&&f.positions[0]==0)f=m;else break}}let l=s.stateSlot(t.state,4);if(l>0)return t.reduce(l),fl&&console.log(a+this.stackID(t)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let c=this.tokens.getActions(t);for(let u=0;ui?n.push(g):r.push(g)}return!1}advanceFully(t,n){let r=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>r)return jZ(t,n),!0}}runRecovery(t,n,r){let i=null,s=!1;for(let a=0;a ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),fl&&console.log(d+this.stackID(l)+" (restarted)"),this.advanceFully(l,r))))continue;let f=l.split(),h=d;for(let m=0;m<10&&f.forceReduce()&&(fl&&console.log(h+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,r));m++)fl&&(h=this.stackID(f)+" -> ");for(let m of l.recoverByInsert(c))fl&&console.log(d+this.stackID(m)+" (via recover-insert)"),this.advanceFully(m,r);this.stream.end>l.pos?(u==l.pos&&(u++,c=0),l.recoverByDelete(c,u),fl&&console.log(d+this.stackID(l)+` (via recover-delete ${this.parser.getName(c)})`),jZ(l,r)):(!i||i.scoree;class oR{constructor(t){this.start=t.start,this.shift=t.shift||tP,this.reduce=t.reduce||tP,this.reuse=t.reuse||tP,this.hash=t.hash||(()=>0),this.strict=t.strict!==!1}}class ch extends Yj{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let n=t.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let l=0;lt.topRules[l][1]),i=[];for(let l=0;l=0)s(d,c,l[u++]);else{let f=l[u+-d];for(let h=-d;h>0;h--)s(l[u++],c,f);u++}}}this.nodeSet=new bO(n.map((l,c)=>Hs.define({name:c>=this.minRepeatTerm?void 0:l,id:c,props:i[c],top:r.indexOf(c)>-1,error:c==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(c)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=xbe;let a=tv(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new Ny(a,l):l),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,n,r){let i=new X0t(this,t,n,r);for(let s of this.wrappers)i=s(i,t,n,r);return i}getGoto(t,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let s=i[n+1];;){let a=i[s++],l=a&1,c=i[s++];if(l&&r)return c;for(let u=s+(a>>1);s0}validAction(t,n){return!!this.allActions(t,r=>r==n?!0:null)}allActions(t,n){let r=this.stateSlot(t,4),i=r?n(r):void 0;for(let s=this.stateSlot(t,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=pf(this.data,s+2);else break;i=n(pf(this.data,s+1))}return i}nextStates(t){let n=[];for(let r=this.stateSlot(t,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=pf(this.data,r+2);else break;if(!(this.data[r+2]&1)){let i=this.data[r+1];n.some((s,a)=>a&1&&s==i)||n.push(this.data[r],i)}}return n}configure(t){let n=Object.assign(Object.create(ch.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let r=this.topRules[t.top];if(!r)throw new RangeError(`Invalid top rule name ${t.top}`);n.top=r}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=t.tokenizers.find(s=>s.from==r);return i?i.to:r})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=t.specializers.find(l=>l.from==r.external);if(!s)return r;let a=Object.assign(Object.assign({},r),{external:s.to});return n.specializers[i]=RZ(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let n=this.dynamicPrecedences;return n==null?0:n[t]||0}parseDialect(t){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(t)for(let s of t.split(" ")){let a=n.indexOf(s);a>=0&&(r[a]=!0)}let i=null;for(let s=0;sr)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.scoree.external(n,r)<<1|t}return e.get}const Y0t=316,Z0t=317,IZ=1,K0t=2,J0t=3,ebt=4,tbt=318,nbt=320,rbt=321,ibt=5,sbt=6,abt=0,b6=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],w1e=125,obt=59,y6=47,lbt=42,cbt=43,ubt=45,dbt=60,fbt=44,hbt=63,pbt=46,mbt=91,gbt=new oR({start:!1,shift(e,t){return t==ibt||t==sbt||t==nbt?e:t==rbt},strict:!1}),bbt=new js((e,t)=>{let{next:n}=e;(n==w1e||n==-1||t.context)&&e.acceptToken(tbt)},{contextual:!0,fallback:!0}),ybt=new js((e,t)=>{let{next:n}=e,r;b6.indexOf(n)>-1||n==y6&&((r=e.peek(1))==y6||r==lbt)||n!=w1e&&n!=obt&&n!=-1&&!t.context&&e.acceptToken(Y0t)},{contextual:!0}),Obt=new js((e,t)=>{e.next==mbt&&!t.context&&e.acceptToken(Z0t)},{contextual:!0}),xbt=new js((e,t)=>{let{next:n}=e;if(n==cbt||n==ubt){if(e.advance(),n==e.next){e.advance();let r=!t.context&&t.canShift(IZ);e.acceptToken(r?IZ:K0t)}}else n==hbt&&e.peek(1)==pbt&&(e.advance(),e.advance(),(e.next<48||e.next>57)&&e.acceptToken(J0t))},{contextual:!0});function nP(e,t){return e>=65&&e<=90||e>=97&&e<=122||e==95||e>=192||!t&&e>=48&&e<=57}const vbt=new js((e,t)=>{if(e.next!=dbt||!t.dialectEnabled(abt)||(e.advance(),e.next==y6))return;let n=0;for(;b6.indexOf(e.next)>-1;)e.advance(),n++;if(nP(e.next,!0)){for(e.advance(),n++;nP(e.next,!1);)e.advance(),n++;for(;b6.indexOf(e.next)>-1;)e.advance(),n++;if(e.next==fbt)return;for(let r=0;;r++){if(r==7){if(!nP(e.next,!0))return;break}if(e.next!="extends".charCodeAt(r))break;e.advance(),n++}}e.acceptToken(ebt,-n)}),wbt=vh({"get set async static":Y.modifier,"for while do if else switch try catch finally return throw break continue default case defer":Y.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":Y.operatorKeyword,"let var const using function class extends":Y.definitionKeyword,"import export from":Y.moduleKeyword,"with debugger new":Y.keyword,TemplateString:Y.special(Y.string),super:Y.atom,BooleanLiteral:Y.bool,this:Y.self,null:Y.null,Star:Y.modifier,VariableName:Y.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":Y.function(Y.variableName),VariableDefinition:Y.definition(Y.variableName),Label:Y.labelName,PropertyName:Y.propertyName,PrivatePropertyName:Y.special(Y.propertyName),"CallExpression/MemberExpression/PropertyName":Y.function(Y.propertyName),"FunctionDeclaration/VariableDefinition":Y.function(Y.definition(Y.variableName)),"ClassDeclaration/VariableDefinition":Y.definition(Y.className),"NewExpression/VariableName":Y.className,PropertyDefinition:Y.definition(Y.propertyName),PrivatePropertyDefinition:Y.definition(Y.special(Y.propertyName)),UpdateOp:Y.updateOperator,"LineComment Hashbang":Y.lineComment,BlockComment:Y.blockComment,Number:Y.number,String:Y.string,Escape:Y.escape,ArithOp:Y.arithmeticOperator,LogicOp:Y.logicOperator,BitOp:Y.bitwiseOperator,CompareOp:Y.compareOperator,RegExp:Y.regexp,Equals:Y.definitionOperator,Arrow:Y.function(Y.punctuation),": Spread":Y.punctuation,"( )":Y.paren,"[ ]":Y.squareBracket,"{ }":Y.brace,"InterpolationStart InterpolationEnd":Y.special(Y.brace),".":Y.derefOperator,", ;":Y.separator,"@":Y.meta,TypeName:Y.typeName,TypeDefinition:Y.definition(Y.typeName),"type enum interface implements namespace module declare":Y.definitionKeyword,"abstract global Privacy readonly override":Y.modifier,"is keyof unique infer asserts":Y.operatorKeyword,JSXAttributeValue:Y.attributeValue,JSXText:Y.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":Y.angleBracket,"JSXIdentifier JSXNameSpacedName":Y.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":Y.attributeName,"JSXBuiltin/JSXIdentifier":Y.standard(Y.tagName)}),Sbt={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,defer:471,for:476,of:485,while:488,with:492,do:496,if:500,else:502,switch:506,case:512,try:518,catch:522,finally:526,return:530,throw:534,break:538,continue:542,debugger:546},Ebt={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},kbt={__proto__:null,"<":193},_bt=ch.deserialize({version:14,states:"$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQO'#Il'#IlO1XQ`O'#GsO1dQ`O'#EoO1iQ`O'#EoO3hQ!0MxO'#JrO6[Q!0MxO'#JsO6uQ`O'#F]O6zQ,UO'#FtOOQ!0Lf'#Ff'#FfO7VO7dO'#FfO9XQMhO'#F|O9`Q`O'#F{OOQ!0Lf'#Js'#JsOOQ!0Lb'#Jr'#JrO9eQ`O'#GwOOQ['#K_'#K_O9pQ`O'#IYO9uQ!0LrO'#IZOOQ['#J`'#J`OOQ['#I_'#I_Q`QlOOQ`QlOOO9}Q!L^O'#DvO:UQlO'#EOO:]QlO'#EQO9kQ`O'#GsO:dQMhO'#CoO:rQ`O'#EnO:}Q`O'#EyO;hQMhO'#FeO;xQ`O'#GsOOQO'#K`'#K`O;}Q`O'#K`O<]Q`O'#G{O<]Q`O'#G|O<]Q`O'#HOO9kQ`O'#HRO=SQ`O'#HUO>kQ`O'#CeO>{Q`O'#HcO?TQ`O'#HiO?TQ`O'#HkO`QlO'#HmO?TQ`O'#HoO?TQ`O'#HrO?YQ`O'#HxO?_Q!0LsO'#IOO%[QlO'#IQO?jQ!0LsO'#ISO?uQ!0LsO'#IUO9uQ!0LrO'#IWO@QQ!0MxO'#CiOASQpO'#DlQOQ`OOO%[QlO'#EQOAjQ`O'#ETO:dQMhO'#EnOAuQ`O'#EnOBQQ!bO'#FeOOQ['#Cg'#CgOOQ!0Lb'#Dq'#DqOOQ!0Lb'#Jv'#JvO%[QlO'#JvOOQO'#Jy'#JyOOQO'#Ih'#IhOCQQpO'#EgOOQ!0Lb'#Ef'#EfOOQ!0Lb'#J}'#J}OC|Q!0MSO'#EgODWQpO'#EWOOQO'#Jx'#JxODlQpO'#JyOEyQpO'#EWODWQpO'#EgPFWO&2DjO'#CbPOOO)CD})CD}OOOO'#I`'#I`OFcO#tO,59UOOQ!0Lh,59U,59UOOOO'#Ia'#IaOFqO&jO,59UOGPQ!L^O'#DcOOOO'#Ic'#IcOGWO#@ItO,59{OOQ!0Lf,59{,59{OGfQlO'#IdOGyQ`O'#JtOIxQ!fO'#JtO+}QlO'#JtOJPQ`O,5:ROJgQ`O'#EpOJtQ`O'#KTOKPQ`O'#KSOKPQ`O'#KSOKXQ`O,5;^OK^Q`O'#KROOQ!0Ln,5:^,5:^OKeQlO,5:^OMcQ!0MxO,5:fONSQ`O,5:nONmQ!0LrO'#KQONtQ`O'#KPO9eQ`O'#KPO! YQ`O'#KPO! bQ`O,5;]O! gQ`O'#KPO!#lQ!fO'#JsOOQ!0Lh'#Ci'#CiO%[QlO'#ESO!$[Q!fO,5:sOOQS'#Jz'#JzOOQO-EtOOQ['#Jh'#JhOOQ[,5>u,5>uOOQ[-E<]-E<]O!TO`QlO,5>VO!LOQ`O,5>XO`QlO,5>ZO!LTQ`O,5>^O!LYQlO,5>dOOQ[,5>j,5>jO%[QlO,5>jO9uQ!0LrO,5>lOOQ[,5>n,5>nO#!dQ`O,5>nOOQ[,5>p,5>pO#!dQ`O,5>pOOQ[,5>r,5>rO##QQpO'#D_O%[QlO'#JvO##sQpO'#JvO##}QpO'#DmO#$`QpO'#DmO#&qQlO'#DmO#&xQ`O'#JuO#'QQ`O,5:WO#'VQ`O'#EtO#'eQ`O'#KUO#'mQ`O,5;_O#'rQpO'#DmO#(PQpO'#EVOOQ!0Lf,5:o,5:oO%[QlO,5:oO#(WQ`O,5:oO?YQ`O,5;YO!CUQpO,5;YO!C^QMhO,5;YO:dQMhO,5;YO#(`Q`O,5@bO#(eQ07dO,5:sOOQO-EPO$6^Q`O,5>POOQ[1G3i1G3iO`QlO1G3iOOQ[1G3o1G3oOOQ[1G3q1G3qO?TQ`O1G3sO$6cQlO1G3uO$:gQlO'#HtOOQ[1G3x1G3xO$:tQ`O'#HzO?YQ`O'#H|OOQ[1G4O1G4OO$:|QlO1G4OO9uQ!0LrO1G4UOOQ[1G4W1G4WOOQ!0Lb'#G_'#G_O9uQ!0LrO1G4YO9uQ!0LrO1G4[O$?TQ`O,5@bO!)[QlO,5;`O9eQ`O,5;`O?YQ`O,5:XO!)[QlO,5:XO!CUQpO,5:XO$?YQ?MtO,5:XOOQO,5;`,5;`O$?dQpO'#IeO$?zQ`O,5@aOOQ!0Lf1G/r1G/rO$@SQpO'#IkO$@^Q`O,5@pOOQ!0Lb1G0y1G0yO#$`QpO,5:XOOQO'#Ig'#IgO$@fQpO,5:qOOQ!0Ln,5:q,5:qO#(ZQ`O1G0ZOOQ!0Lf1G0Z1G0ZO%[QlO1G0ZOOQ!0Lf1G0t1G0tO?YQ`O1G0tO!CUQpO1G0tO!C^QMhO1G0tOOQ!0Lb1G5|1G5|O!ByQ!0LrO1G0^OOQO1G0m1G0mO%[QlO1G0mO$@mQ!0LrO1G0mO$@xQ!0LrO1G0mO!CUQpO1G0^ODWQpO1G0^O$AWQ!0LrO1G0mOOQO1G0^1G0^O$AlQ!0MxO1G0mPOOO-E<[-E<[POOO1G.h1G.hOOOO1G/i1G/iO$AvQ!bO,5QQpO,5@}OOQ!0Lb1G3c1G3cOOQ[7+$V7+$VO@zQ`O7+$VO9uQ!0LrO7+$VO%>]Q`O7+$VO%[QlO1G6lO%[QlO1G6mO%>bQ!0LrO1G6lO%>lQlO1G3kO%>sQ`O1G3kO%>xQlO1G3kOOQ[7+)T7+)TO9uQ!0LrO7+)_O`QlO7+)aOOQ['#Kh'#KhOOQ['#JS'#JSO%?PQlO,5>`OOQ[,5>`,5>`O%[QlO'#HuO%?^Q`O'#HwOOQ[,5>f,5>fO9eQ`O,5>fOOQ[,5>h,5>hOOQ[7+)j7+)jOOQ[7+)p7+)pOOQ[7+)t7+)tOOQ[7+)v7+)vO%?cQpO1G5|O%?}Q?MtO1G0zO%@XQ`O1G0zOOQO1G/s1G/sO%@dQ?MtO1G/sO?YQ`O1G/sO!)[QlO'#DmOOQO,5?P,5?POOQO-ERQ`O7+,WO&>WQ`O7+,XO%[QlO7+,WO%[QlO7+,XOOQ[7+)V7+)VO&>]Q`O7+)VO&>bQlO7+)VO&>iQ`O7+)VOOQ[<nQ`O,5>aOOQ[,5>c,5>cO&>sQ`O1G4QO9eQ`O7+&fO!)[QlO7+&fOOQO7+%_7+%_O&>xQ?MtO1G6ZO?YQ`O7+%_OOQ!0Lf<yQ?MvO,5?aO'@|Q?MvO,5?cO'CPQ?MvO7+'|O'DuQMjOG27TOOQO<VO!l$xO#jROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]$_Oa$qa'z$qa'w$qa!k$qa!Y$qa!_$qa%i$qa!g$qa~Ol)dO~P!&zOh%VOp%WOr%XOs$tOt$tOz%YO|%ZO!O%]O!S${O!_$|O!i%bO!l$xO#j%cO$W%`O$t%^O$v%_O$y%aO(T(vO(VTO(YUO(a$uO(y$}O(z%PO~Og(pP~P!,TO!Q)iO!g)hO!_$^X$Z$^X$]$^X$_$^X$f$^X~O!g)hO!_({X$Z({X$]({X$_({X$f({X~O!Q)iO~P!.^O!Q)iO!_({X$Z({X$]({X$_({X$f({X~O!_)kO$Z)oO$])jO$_)jO$f)pO~O![)sO~P!)[O$]$hO$_$gO$f)wO~On$zX!Q$zX#S$zX'y$zX(y$zX(z$zX~OgmXg$zXnmX!]mX#`mX~P!0SOx)yO(b)zO(c)|O~On*VO!Q*OO'y*PO(y$}O(z%PO~Og)}O~P!1WOg*WO~Oh%VOr%XOs$tOt$tOz%YO|%ZO!OVO!l$xO#jVO!l$xO#jROe!iOpkOrPO(VTO(YUO(aVO(o[O~O(T=QO~P#$qO!]-]O!^(iX~O!^-_O~O!g-VO#`-UO!]#hX!^#hX~O!]-`O!^(xX~O!^-bO~O!c-cO!d-cO(U!lO~P#$`O!^-fO~P'_On-iO!_'`O~O!Y-nO~Os!{a!b!{a!c!{a!d!{a#T!{a#U!{a#V!{a#W!{a#X!{a#[!{a#]!{a(U!{a(V!{a(Y!{a(e!{a(o!{a~P!#vO!p-sO#`-qO~PChO!c-uO!d-uO(U!lO~PDWOa%nO#`-qO'z%nO~Oa%nO!g#vO#`-qO'z%nO~Oa%nO!g#vO!p-sO#`-qO'z%nO(r'pO~O(P'xO(Q'xO(R-zO~Ov-{O~O!Y'Wa!]'Wa~P!:tO![.PO!Y'WX!]'WX~P%[O!](VO!Y(ha~O!Y(ha~PHRO!](^O!Y(va~O!S%hO![.TO!_%iO(T%gO!Y'^X!]'^X~O#`.VO!](ta!k(taa(ta'z(ta~O!g#vO~P#,wO!](jO!k(sa~O!S%hO!_%iO#j.ZO(T%gO~Op.`O!S%hO![.]O!_%iO!|]O#i._O#j.]O(T%gO!]'aX!k'aX~OR.dO!l#xO~Oh%VOn.gO!_'`O%i.fO~Oa#ci!]#ci'z#ci'w#ci!Y#ci!k#civ#ci!_#ci%i#ci!g#ci~P!:tOn>]O!Q*OO'y*PO(y$}O(z%PO~O#k#_aa#_a#`#_a'z#_a!]#_a!k#_a!_#_a!Y#_a~P#/sO#k(`XP(`XR(`X[(`Xa(`Xj(`Xr(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X'z(`X(a(`X(r(`X!k(`X!Y(`X'w(`Xv(`X!_(`X%i(`X!g(`X~P!6kO!].tO!k(kX~P!:tO!k.wO~O!Y.yO~OP$[OR#zO!Q#yO!S#{O!l#xO!p$[O(aVO[#mia#mij#mir#mi!]#mi#R#mi#o#mi#p#mi#q#mi#r#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#n#mi~P#3cO#n$OO~P#3cOP$[OR#zOr$aO!Q#yO!S#{O!l#xO!p$[O#n$OO#o$PO#p$PO#q$PO(aVO[#mia#mij#mi!]#mi#R#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#r#mi~P#6QO#r$QO~P#6QOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO(aVOa#mi!]#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#v#mi~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO(aVO(z#}Oa#mi!]#mi#z#mi#{#mi'z#mi(r#mi(y#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#x$UO~P#;VO#x#mi~P#;VO#v$SO~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO#x$UO(aVO(y#|O(z#}Oa#mi!]#mi#{#mi'z#mi(r#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#z#mi~P#={O#z$WO~P#={OP]XR]X[]Xj]Xr]X!Q]X!S]X!l]X!p]X#R]X#S]X#`]X#kfX#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#v]X#x]X#z]X#{]X$Q]X(a]X(r]X(y]X(z]X!]]X!^]X~O$O]X~P#@jOP$[OR#zO[]O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P#EyO!]/POg(pX~P!1WOg/RO~Oa$Pi!]$Pi'z$Pi'w$Pi!Y$Pi!k$Piv$Pi!_$Pi%i$Pi!g$Pi~P!:tO$]/SO$_/SO~O$]/TO$_/TO~O!g)hO#`/UO!_$cX$Z$cX$]$cX$_$cX$f$cX~O![/VO~O!_)kO$Z/XO$])jO$_)jO$f/YO~O!]VO!l$xO#j^O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P&,QO#S$dOP(`XR(`X[(`Xj(`Xn(`Xr(`X!Q(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X$O(`X'y(`X(a(`X(r(`X(y(`X(z(`X!](`X!^(`X~O$O$Pi!]$Pi!^$Pi~P#BwO$O!ri!^!ri~P$+oOg']a!]']a~P!1WO!^7nO~O!]'da!^'da~P#BwO!Y7oO~P#/sO!g#vO(r'pO!]'ea!k'ea~O!]/pO!k)Oi~O!]/pO!g#vO!k)Oi~Og$|q!]$|q#`$|q$O$|q~P!1WO!Y'ga!]'ga~P#/sO!g7vO~O!]/yO!Y)Pi~P#/sO!]/yO!Y)Pi~O!Y7yO~Oh%VOr8OO!l%eO(r'pO~Oj8QO!g#vO~Or8TO!g#vO(r'pO~O!Q*OO'y*PO(z%POn'ja(y'ja!]'ja#`'ja~Og'ja$O'ja~P&5RO!Q*OO'y*POn'la(y'la(z'la!]'la#`'la~Og'la$O'la~P&5tOg(_q!](_q~P!1WO#`8VOg(_q!](_q~P!1WO!Y8WO~Og%Oq!]%Oq#`%Oq$O%Oq~P!1WOa$oy!]$oy'z$oy'w$oy!Y$oy!k$oyv$oy!_$oy%i$oy!g$oy~P!:tO!g6rO~O!]5[O!_)Qa~O!_'`OP$TaR$Ta[$Taj$Tar$Ta!Q$Ta!S$Ta!]$Ta!l$Ta!p$Ta#R$Ta#n$Ta#o$Ta#p$Ta#q$Ta#r$Ta#s$Ta#t$Ta#u$Ta#v$Ta#x$Ta#z$Ta#{$Ta(a$Ta(r$Ta(y$Ta(z$Ta~O%i7WO~P&8fO%^8[Oa%[i!_%[i'z%[i!]%[i~Oa#cy!]#cy'z#cy'w#cy!Y#cy!k#cyv#cy!_#cy%i#cy!g#cy~P!:tO[8^O~Ob8`O(T+qO(VTO(YUO~O!]1TO!^)Xi~O`8dO~O(e(|O!]'pX!^'pX~O!]5uO!^)Ua~O!^8nO~P%;eO(o!sO~P$&YO#[8oO~O!_1oO~O!_1oO%i8qO~On8tO!_1oO%i8qO~O[8yO!]'sa!^'sa~O!]1zO!^)Vi~O!k8}O~O!k9OO~O!k9RO~O!k9RO~P%[Oa9TO~O!g9UO~O!k9VO~O!](wi!^(wi~P#BwOa%nO#`9_O'z%nO~O!](ty!k(tya(ty'z(ty~P!:tO!](jO!k(sy~O%i9bO~P&8fO!_'`O%i9bO~O#k$|qP$|qR$|q[$|qa$|qj$|qr$|q!S$|q!]$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q'z$|q(a$|q(r$|q!k$|q!Y$|q'w$|q#`$|qv$|q!_$|q%i$|q!g$|q~P#/sO#k'jaP'jaR'ja['jaa'jaj'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja'z'ja(a'ja(r'ja!k'ja!Y'ja'w'jav'ja!_'ja%i'ja!g'ja~P&5RO#k'laP'laR'la['laa'laj'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la'z'la(a'la(r'la!k'la!Y'la'w'lav'la!_'la%i'la!g'la~P&5tO#k%OqP%OqR%Oq[%Oqa%Oqj%Oqr%Oq!S%Oq!]%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq'z%Oq(a%Oq(r%Oq!k%Oq!Y%Oq'w%Oq#`%Oqv%Oq!_%Oq%i%Oq!g%Oq~P#/sO!]'Yi!k'Yi~P!:tO$O#cq!]#cq!^#cq~P#BwO(y$}OP%aaR%aa[%aaj%aar%aa!S%aa!l%aa!p%aa#R%aa#n%aa#o%aa#p%aa#q%aa#r%aa#s%aa#t%aa#u%aa#v%aa#x%aa#z%aa#{%aa$O%aa(a%aa(r%aa!]%aa!^%aa~On%aa!Q%aa'y%aa(z%aa~P&IyO(z%POP%caR%ca[%caj%car%ca!S%ca!l%ca!p%ca#R%ca#n%ca#o%ca#p%ca#q%ca#r%ca#s%ca#t%ca#u%ca#v%ca#x%ca#z%ca#{%ca$O%ca(a%ca(r%ca!]%ca!^%ca~On%ca!Q%ca'y%ca(y%ca~P&LQOn>^O!Q*OO'y*PO(z%PO~P&IyOn>^O!Q*OO'y*PO(y$}O~P&LQOR0kO!Q0kO!S0lO#S$dOP}a[}aj}an}ar}a!l}a!p}a#R}a#n}a#o}a#p}a#q}a#r}a#s}a#t}a#u}a#v}a#x}a#z}a#{}a$O}a'y}a(a}a(r}a(y}a(z}a!]}a!^}a~O!Q*OO'y*POP$saR$sa[$saj$san$sar$sa!S$sa!l$sa!p$sa#R$sa#n$sa#o$sa#p$sa#q$sa#r$sa#s$sa#t$sa#u$sa#v$sa#x$sa#z$sa#{$sa$O$sa(a$sa(r$sa(y$sa(z$sa!]$sa!^$sa~O!Q*OO'y*POP$uaR$ua[$uaj$uan$uar$ua!S$ua!l$ua!p$ua#R$ua#n$ua#o$ua#p$ua#q$ua#r$ua#s$ua#t$ua#u$ua#v$ua#x$ua#z$ua#{$ua$O$ua(a$ua(r$ua(y$ua(z$ua!]$ua!^$ua~On>^O!Q*OO'y*PO(y$}O(z%PO~OP%TaR%Ta[%Taj%Tar%Ta!S%Ta!l%Ta!p%Ta#R%Ta#n%Ta#o%Ta#p%Ta#q%Ta#r%Ta#s%Ta#t%Ta#u%Ta#v%Ta#x%Ta#z%Ta#{%Ta$O%Ta(a%Ta(r%Ta!]%Ta!^%Ta~P''VO$O$mq!]$mq!^$mq~P#BwO$O$oq!]$oq!^$oq~P#BwO!^9oO~O$O9pO~P!1WO!g#vO!]'ei!k'ei~O!g#vO(r'pO!]'ei!k'ei~O!]/pO!k)Oq~O!Y'gi!]'gi~P#/sO!]/yO!Y)Pq~Or9wO!g#vO(r'pO~O[9yO!Y9xO~P#/sO!Y9xO~Oj:PO!g#vO~Og(_y!](_y~P!1WO!]'na!_'na~P#/sOa%[q!_%[q'z%[q!]%[q~P#/sO[:UO~O!]1TO!^)Xq~O`:YO~O#`:ZO!]'pa!^'pa~O!]5uO!^)Ui~P#BwO!S:]O~O!_1oO%i:`O~O(VTO(YUO(e:eO~O!]1zO!^)Vq~O!k:hO~O!k:iO~O!k:jO~O!k:jO~P%[O#`:mO!]#hy!^#hy~O!]#hy!^#hy~P#BwO%i:rO~P&8fO!_'`O%i:rO~O$O#|y!]#|y!^#|y~P#BwOP$|iR$|i[$|ij$|ir$|i!S$|i!l$|i!p$|i#R$|i#n$|i#o$|i#p$|i#q$|i#r$|i#s$|i#t$|i#u$|i#v$|i#x$|i#z$|i#{$|i$O$|i(a$|i(r$|i!]$|i!^$|i~P''VO!Q*OO'y*PO(z%POP'iaR'ia['iaj'ian'iar'ia!S'ia!l'ia!p'ia#R'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#v'ia#x'ia#z'ia#{'ia$O'ia(a'ia(r'ia(y'ia!]'ia!^'ia~O!Q*OO'y*POP'kaR'ka['kaj'kan'kar'ka!S'ka!l'ka!p'ka#R'ka#n'ka#o'ka#p'ka#q'ka#r'ka#s'ka#t'ka#u'ka#v'ka#x'ka#z'ka#{'ka$O'ka(a'ka(r'ka(y'ka(z'ka!]'ka!^'ka~O(y$}OP%aiR%ai[%aij%ain%air%ai!Q%ai!S%ai!l%ai!p%ai#R%ai#n%ai#o%ai#p%ai#q%ai#r%ai#s%ai#t%ai#u%ai#v%ai#x%ai#z%ai#{%ai$O%ai'y%ai(a%ai(r%ai(z%ai!]%ai!^%ai~O(z%POP%ciR%ci[%cij%cin%cir%ci!Q%ci!S%ci!l%ci!p%ci#R%ci#n%ci#o%ci#p%ci#q%ci#r%ci#s%ci#t%ci#u%ci#v%ci#x%ci#z%ci#{%ci$O%ci'y%ci(a%ci(r%ci(y%ci!]%ci!^%ci~O$O$oy!]$oy!^$oy~P#BwO$O#cy!]#cy!^#cy~P#BwO!g#vO!]'eq!k'eq~O!]/pO!k)Oy~O!Y'gq!]'gq~P#/sOr:|O!g#vO(r'pO~O[;QO!Y;PO~P#/sO!Y;PO~Og(_!R!](_!R~P!1WOa%[y!_%[y'z%[y!]%[y~P#/sO!]1TO!^)Xy~O!]5uO!^)Uq~O(T;XO~O!_1oO%i;[O~O!k;_O~O%i;dO~P&8fOP$|qR$|q[$|qj$|qr$|q!S$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q$O$|q(a$|q(r$|q!]$|q!^$|q~P''VO!Q*OO'y*PO(z%POP'jaR'ja['jaj'jan'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja$O'ja(a'ja(r'ja(y'ja!]'ja!^'ja~O!Q*OO'y*POP'laR'la['laj'lan'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la$O'la(a'la(r'la(y'la(z'la!]'la!^'la~OP%OqR%Oq[%Oqj%Oqr%Oq!S%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq$O%Oq(a%Oq(r%Oq!]%Oq!^%Oq~P''VOg%e!Z!]%e!Z#`%e!Z$O%e!Z~P!1WO!Y;hO~P#/sOr;iO!g#vO(r'pO~O[;kO!Y;hO~P#/sO!]'pq!^'pq~P#BwO!]#h!Z!^#h!Z~P#BwO#k%e!ZP%e!ZR%e!Z[%e!Za%e!Zj%e!Zr%e!Z!S%e!Z!]%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z'z%e!Z(a%e!Z(r%e!Z!k%e!Z!Y%e!Z'w%e!Z#`%e!Zv%e!Z!_%e!Z%i%e!Z!g%e!Z~P#/sOr;tO!g#vO(r'pO~O!Y;uO~P#/sOr;|O!g#vO(r'pO~O!Y;}O~P#/sOP%e!ZR%e!Z[%e!Zj%e!Zr%e!Z!S%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z$O%e!Z(a%e!Z(r%e!Z!]%e!Z!^%e!Z~P''VOrROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]WO!l$xO#jgPPP!>oI[PPPPPPPPP!BOP!C]PPI[!DnPI[PI[I[I[I[I[PI[!FQP!I[P!LbP!Lf!Lp!Lt!LtP!IXP!Lx!LxP#!OP#!SI[PI[#!Y#%_CjA^PA^PA^A^P#&lA^A^#)OA^#+vA^#.SA^A^#.r#1W#1W#1]#1f#1W#1qPP#1WPA^#2ZA^#6YA^A^6mPPP#:_PPP#:x#:xP#:xP#;`#:xPP#;fP#;]P#;]#;y#;]#P#>V#>]#>k#>q#>{#?R#?]#?c#?s#?y#@k#@}#AT#AZ#Ai#BO#Cs#DR#DY#Et#FS#Gt#HS#HY#H`#Hf#Hp#Hv#H|#IW#Ij#IpPPPPPPPPPPP#IvPPPPPPP#Jk#Mx$ b$ i$ qPPP$']P$'f$*_$0x$0{$1O$1}$2Q$2X$2aP$2g$2jP$3W$3[$4S$5b$5g$5}PP$6S$6Y$6^$6a$6e$6i$7e$7|$8e$8i$8l$8o$8y$8|$9Q$9UR!|RoqOXst!Z#d%m&r&t&u&w,s,x2[2_Y!vQ'`-e1o5{Q%tvQ%|yQ&T|Q&j!VS'W!e-]Q'f!iS'l!r!yU*k$|*Z*oQ+o%}S+|&V&WQ,d&dQ-c'_Q-m'gQ-u'mQ0[*qQ1b,OQ1y,eR<{SU+P%]S!S!nQ!r!v!y!z$|'W'_'`'l'm'n*k*o*q*r-]-c-e-u0[0_1o5{5}%[$ti#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^Q&X|Q'U!eS'[%i-`Q+t&PQ,P&WQ,f&gQ0n+SQ1Y+uQ1_+{Q2Q,jQ2R,kQ5f1TQ5o1aQ6[1zQ6_1|Q6`2PQ8`5gQ8c5lQ8|6bQ:X8dQ:f8yQ;V:YR<}*ZrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R,h&k&z^OPXYstuvwz!Z!`!g!j!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'b'r(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mR>S[#]WZ#W#Z'X(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ%wxQ%{yW&Q|&V&W,OQ&_!TQ'c!hQ'e!iQ(q#sS+n%|%}Q+r&PQ,_&bQ,c&dS-l'f'gQ.i(rQ1R+oQ1X+uQ1Z+vQ1^+zQ1t,`S1x,d,eQ2|-mQ5e1TQ5i1WQ5n1`Q6Z1yQ8_5gQ8b5kQ8f5pQ:T8^R;T:U!U$zi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y!^%yy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{Q+h%wQ,T&[Q,W&]Q,b&dQ.h(qQ1s,_U1w,c,d,eQ3e.iQ6U1tS6Y1x1yQ8x6Z#f>T#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o>UPS&[!Q&iQ&]!RQ&^!SU*}%[%d=sR,R&Y%]%Si#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^T)z$u){V+P%]S$i$^c#Y#e%q%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.|.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SQ'Y!eR2q-]!W!nQ!e!r!v!y!z$|'W'_'`'l'm'n*Z*k*o*q*r-]-c-e-u0[0_1o5{5}R1l,ZnqOXst!Z#d%m&r&t&u&w,s,x2[2_Q&y!^Q'v!xS(s#u<^Q+l%zQ,]&_Q,^&aQ-j'dQ-w'oS.r(x=PS0q+X=ZQ1P+mQ1n,[Q2c,zQ2e,{Q2m-WQ2z-kQ2}-oS5Y0r=eQ5a1QS5d1S=fQ6t2oQ6x2{Q6}3SQ8]5bQ9Y6vQ9Z6yQ9^7OR:l9V$d$]c#Y#e%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SS#q]SU$fd)_,mS(p#p'iU*v%R(w4OU0m+O.n7gQ5^0xQ7V3`Q9d7YR:s9em!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}Q't!uS(f#g2US-s'k'wQ/s*]Q0R*jQ3U-vQ4f/tQ4r0TQ4s0UQ4x0^Q7r4`S7}4t4vS8R4y4{Q9r7sQ9v7yQ9{8OQ:Q8TS:{9w9xS;g:|;PS;s;h;iS;{;t;uSSR=o>R%^bOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Q%fj!^%xy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{S&Oz!jQ+k%yQ,a&dW1v,b,c,d,eU6X1w1x1yS8w6Y6ZQ:d8x!r=j$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ=t>QR=u>R%QeOPXYstuvw!Z!`!g!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Y#bWZ#W#Z(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ,n&o!p=k$Z$n)s-U-X/V2p4T5w6s:Z:mSR=n'XU']!e%i*ZR2s-`%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+],p,s,x-i-q.P.V.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3l4z6T6e6f6i6|8t9T9_!r)_$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ,m&oQ0x+gQ3`.gQ7Y3dR9e7[!b$Tc#Y%q(S(Y(t(y)Z)[)`)g+x-x-}.S.U.s.v/b0p3O3V3k3{5X5c6{7Q7a9]:oS)^)q-Z.|2k2n3p4P4X6u7b7k7l8k9X9g9m9n;W;`=vQ>X>ZR>Y>['QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mSS$oh$pR4U/U'XgOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$kf$qQ$ifS)j$l)nR)v$qT$jf$qT)l$l)n'XhOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$oh$pQ$rhR)u$p%^jOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_!s>Q$Z$n'X)s-U-X/V2p4T5w6s:Z:mS#glOPXZst!Z!`!o#S#d#o#{$n%m&k&n&o&r&t&u&w&{'T'b)O)s*i+]+g,p,s,x-i.g/V/n0]0l1r2S2T2V2X2[2_2a3d4T4z6T6e6f6i7[8t9T!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^Q+T%aQ/c*Oo4OP>X>YQ*c$zU*l$|*Z*oQ+U%bQ0W*m#f=q#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^n=rTQ=x>UQ=y>VR=z>W!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o4OP>X>Y>]>^Q,U&]Q1h,WQ5s1gR8h5tV*n$|*Z*oU*n$|*Z*oT5z1o5{S0P*i/nQ4w0]T8S4z:]Q+j%xQ0V*lQ1O+kQ1u,aQ6W1vQ8v6XQ:c8wR;^:d!U%Oi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Yx*R$v)e*S*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>OS0`*t0a#f]>^nZ>[`=T3}7c7f7j9h:t:w;yS=_.l3iT=`7e9k!U%Qi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y|*T$v)e*U*t+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>OS0b*u0c#f]>^nZ>[d=V3}7d7e7j9h9i:t:u:w;yS=a.m3jT=b7f9lrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q&f!UR,p&ornOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R&f!UQ,Y&^R1d,RsnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q1p,_S6R1s1tU8p6P6Q6US:_8r8sS;Y:^:aQ;m;ZR;w;nQ&m!VR,i&iR6_1|R:f8yW&Q|&V&W,OR1Z+vQ&r!WR,s&sR,y&xT2],x2_R,}&yQ,|&yR2f,}Q'y!{R-y'ySsOtQ#dXT%ps#dQ#OTR'{#OQ#RUR'}#RQ){$uR/`){Q#UVR(Q#UQ#XWU(W#X(X.QQ(X#YR.Q(YQ-^'YR2r-^Q.u(yS3m.u3nR3n.vQ-e'`R2v-eY!rQ'`-e1o5{R'j!rQ/Q)eR4S/QU#_W%h*YU(_#_(`.RQ(`#`R.R(ZQ-a']R2t-at`OXst!V!Z#d%m&i&k&r&t&u&w,s,x2[2_S#hZ%eU#r`#h.[R.[(jQ(k#jQ.X(gW.a(k.X3X7RQ3X.YR7R3YQ)n$lR/W)nQ$phR)t$pQ$`cU)a$`-|O>Z>[Q/z*eU4k/z4m7xQ4m/|R7x4lS*o$|*ZR0Y*ox*S$v)e*t*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>O!d.j(u)c*[*e.l.m.q/_/k/|0v1e3h4[4h4l5r7]7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/h*S.j7ca7c3}7e7f7j9h:t:w;yQ0a*tQ3i.lU4}0a3i9kR9k7e|*U$v)e*t*u+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>O!h.k(u)c*[*e.l.m.q/_/k/|0v1e3f3h4[4h4l5r7]7^7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/j*U.k7de7d3}7e7f7j9h9i:t:u:w;yQ0c*uQ3j.mU5P0c3j9lR9l7fQ*z%UR0g*zQ5]0vR8Y5]Q+_%kR0u+_Q5v1jS8j5v:[R:[8kQ,[&_R1m,[Q5{1oR8m5{Q1{,fS6]1{8zR8z6_Q1U+rW5h1U5j8a:VQ5j1XQ8a5iR:V8bQ+w&QR1[+wQ2_,xR6m2_YrOXst#dQ&v!ZQ+a%mQ,r&rQ,t&tQ,u&uQ,w&wQ2Y,sS2],x2_R6l2[Q%opQ&z!_Q&}!aQ'P!bQ'R!cQ'q!uQ+`%lQ+l%zQ,Q&XQ,h&mQ-P&|W-p'k's't'wQ-w'oQ0X*nQ1P+mQ1c,PS2O,i,lQ2g-OQ2h-RQ2i-SQ2}-oW3P-r-s-v-xQ5a1QQ5m1_Q5q1eQ6V1uQ6a2QQ6k2ZU6z3O3R3UQ6}3SQ8]5bQ8e5oQ8g5rQ8l5zQ8u6WQ8{6`S9[6{7PQ9^7OQ:W8cQ:b8vQ:g8|Q:n9]Q;U:XQ;]:cQ;a:oQ;l;VR;o;^Q%zyQ'd!iQ'o!uU+m%{%|%}Q-W'VU-k'e'f'gS-o'k'uQ0Q*jS1Q+n+oQ2o-YS2{-l-mQ3S-tS4p0R0UQ5b1RQ6v2uQ6y2|Q7O3TU7{4r4s4vQ9z7}R;O9{S$wi>PR*{%VU%Ui%V>PR0f*yQ$viS(u#v+iS)c$b$cQ)e$dQ*[$xS*e${*YQ*t%OQ*u%QQ+Q%^Q+R%_Q+V%cQ.lPQ=}>XQ>O>YQ>Z>]R>[>^Q+O%]Q.nSR#[WR'Z!el!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}S'V!e-]U*j$|*Z*oS-Y'W'_S0U*k*qQ0^*rQ2u-cQ4v0[R4{0_R({#xQ!fQT-d'`-e]!qQ!r'`-e1o5{Q#p]R'i < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:380,context:gbt,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,237,243,245,247,249,252,258,264,266,268,270,272,274,275,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[wbt],skippedNodes:[0,5,6,278],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$i&j(WpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(WpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Wp(Z!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$i&j(Wp(Z!b'|0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(X#S$i&j'}0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$i&j(Wp(Z!b'}0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$i&j!p),Q(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(V':f$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$i&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$d`$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$d``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$d`$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(Z!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$d`(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$i&j(Wp(Z!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$i&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(Z!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$i&j(WpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(WpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Wp(Z!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l^!Q^$i&j!X7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!X7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!X7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c^!Ezl$i&j(Z!b!X7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(Z!b!X7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(Z!b!X7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(Z!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$i&j(Z!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!^!LYP;=`<%l!KS>^!L`P;=`<%l!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!g$b$i&j$O)Lv(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#R-v$?V_!^(CdvBr$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$@a_!q7`$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$Aq|$i&j(Wp(Z!b'|0/l$]#t(T,2j(e$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$i&j(Wp(Z!b'}0/l$]#t(T,2j(e$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[ybt,Obt,xbt,vbt,2,3,4,5,6,7,8,9,10,11,12,13,14,bbt,new AA("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOx~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!U~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(c~~",141,340),new AA("j~RQYZXz{^~^O(Q~~aP!P!Qd~iO(R~~",25,323)],topRules:{Script:[0,7],SingleExpression:[1,276],SingleClassItem:[2,277]},dialects:{jsx:0,ts:15175},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:327,get:e=>Sbt[e]||-1},{term:343,get:e=>Ebt[e]||-1},{term:95,get:e=>kbt[e]||-1}],tokenPrec:15201});class RQ{constructor(t,n,r,i){this.state=t,this.pos=n,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let n=mi(this.state).resolveInner(this.pos,-1);for(;n&&t.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(t){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),s=i.search(E1e(t,!1));return s<0?null:{from:r+s,to:this.pos,text:i.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(t,n,r){t=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function DZ(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function Tbt(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let s=1;stypeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:Tbt(t);return i=>{let s=i.matchBefore(r);return s||i.explicit?{from:s?s.from:i.pos,options:t,validFor:n}:null}}function S1e(e,t){return n=>{for(let r=mi(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(e.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return t(n)}}class PZ{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function _g(e){return e.selection.main.from}function E1e(e,t){var n;let{source:r}=e,i=t&&r[0]!="^",s=r[r.length-1]!="$";return!i&&!s?e:new RegExp(`${i?"^":""}(?:${r})${s?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const DQ=Ad.define();function Cbt(e,t,n,r){let{main:i}=e.selection,s=n-i.from,a=r-i.from;return{...e.changeByRange(l=>{if(l!=i&&n!=r&&e.sliceDoc(l.from+s,l.from+a)!=e.sliceDoc(n,r))return{range:l};let c=e.toText(t);return{changes:{from:l.from+s,to:r==i.from?l.to:l.from+a,insert:c},range:Je.cursor(l.from+s+c.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const MZ=new WeakMap;function Abt(e){if(!Array.isArray(e))return e;let t=MZ.get(e);return t||MZ.set(e,t=IQ(e)),t}const NA=jn.define(),fS=jn.define();class Nbt{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n=48&&S<=57||S>=97&&S<=122?2:S>=65&&S<=90?1:0:(E=oQ(S))!=E.toLowerCase()?1:E!=E.toUpperCase()?2:0;(!v||k==1&&y||w==0&&k!=0)&&(n[f]==S||r[f]==S&&(h=!0)?a[f++]=v:a.length&&(O=!1)),w=k,v+=Yu(S)}return f==c&&a[0]==0&&O?this.result(-100+(h?-200:0),a,t):m==c&&g==0?this.ret(-200-t.length+(b==t.length?0:-100),[0,b]):l>-1?this.ret(-700-t.length,[l,l+this.pattern.length]):m==c?this.ret(-900-t.length,[g,b]):f==c?this.result(-100+(h?-200:0)+-700+(O?0:-1100),a,t):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,t)}result(t,n,r){let i=[],s=0;for(let a of n){let l=a+(this.astral?Yu(Uo(r,a)):1);s&&i[s-1]==a?i[s-1]=l:(i[s++]=a,i[s++]=l)}return this.ret(t-r.length,i)}}class jbt{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Rbt,filterStrict:!1,compareCompletions:(t,n)=>(t.sortText||t.label).localeCompare(n.sortText||n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,n)=>t&&n,closeOnBlur:(t,n)=>t&&n,icons:(t,n)=>t&&n,tooltipClass:(t,n)=>r=>LZ(t(r),n(r)),optionClass:(t,n)=>r=>LZ(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function LZ(e,t){return e?t?e+" "+t:e:t}function Rbt(e,t,n,r,i,s){let a=e.textDirection==xi.RTL,l=a,c=!1,u="top",d,f,h=t.left-i.left,m=i.right-t.right,g=r.right-r.left,b=r.bottom-r.top;if(l&&h=b||v>t.top?d=n.bottom-t.top:(u="bottom",d=t.bottom-n.top)}let y=(t.bottom-t.top)/s.offsetHeight,O=(t.right-t.left)/s.offsetWidth;return{style:`${u}: ${d/y}px; max-width: ${f/O}px`,class:"cm-completionInfo-"+(c?a?"left-narrow":"right-narrow":l?"left":"right")}}const PQ=jn.define();function Ibt(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),t.push({render(n,r,i,s){let a=document.createElement("span");a.className="cm-completionLabel";let l=n.displayLabel||n.label,c=0;for(let u=0;uc&&a.appendChild(document.createTextNode(l.slice(c,d)));let h=a.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(l.slice(d,f))),h.className="cm-completionMatchedText",c=f}return cn.position-r.position).map(n=>n.render)}function rP(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let i=Math.floor(t/n);return{from:i*n,to:(i+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}class Dbt{constructor(t,n,r){this.view=t,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:c=>this.placeInfo(c),key:this},this.space=null,this.currentClass="";let i=t.state.field(n),{options:s,selected:a}=i.open,l=t.state.facet(ma);this.optionContent=Ibt(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=rP(s.length,a,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",c=>{let{options:u}=t.state.field(n).open;for(let d=c.target,f;d&&d!=this.dom;d=d.parentNode)if(d.nodeName=="LI"&&(f=/-(\d+)$/.exec(d.id))&&+f[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;d!=null&&(t.dispatch({effects:PQ.of(d)}),c.preventDefault())}}),this.dom.addEventListener("focusout",c=>{let u=t.state.field(this.stateField,!1);u&&u.tooltip&&t.state.facet(ma).closeOnBlur&&c.relatedTarget!=t.contentDOM&&t.dispatch({effects:fS.of(null)})}),this.showOptions(s,i.id)}mount(){this.updateSel()}showOptions(t,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var n;let r=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),r!=i){let{options:s,selected:a,disabled:l}=r.open;(!i.open||i.open.options!=s)&&(this.range=rP(s.length,a,t.state.facet(ma).maxRenderedOptions),this.showOptions(s,r.id)),this.updateSel(),l!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(t){let n=this.tooltipClass(t);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),n=t.open;(n.selected>-1&&n.selected=this.range.to)&&(this.range=rP(n.options.length,n.selected,this.view.state.facet(ma).maxRenderedOptions),this.showOptions(n.options,t.id));let r=this.updateSelectedOption(n.selected);if(r){this.destroyInfo();let{completion:i}=n.options[n.selected],{info:s}=i;if(!s)return;let a=typeof s=="string"?document.createTextNode(s):s(i);if(!a)return;"then"in a?a.then(l=>{l&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(l,i)}).catch(l=>Go(this.view.state,l,"completion info")):(this.addInfoPane(a,i),r.setAttribute("aria-describedby",this.info.id))}}addInfoPane(t,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",r.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),t.nodeType!=null)r.appendChild(t),this.infoDestroy=null;else{let{dom:i,destroy:s}=t;r.appendChild(i),this.infoDestroy=s||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==t?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&(r.removeAttribute("aria-selected"),r.removeAttribute("aria-describedby"));return n&&Mbt(this.list,n),n}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),s=this.space;if(!s){let a=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:a.clientWidth,bottom:a.clientHeight}}return i.top>Math.min(s.bottom,n.bottom)-10||i.bottom{a.target==i&&a.preventDefault()});let s=null;for(let a=r.from;ar.from||r.from==0))if(s=h,typeof u!="string"&&u.header)i.appendChild(u.header(u));else{let m=i.appendChild(document.createElement("completion-section"));m.textContent=h}}const d=i.appendChild(document.createElement("li"));d.id=n+"-"+a,d.setAttribute("role","option");let f=this.optionClass(l);f&&(d.className=f);for(let h of this.optionContent){let m=h(l,this.view.state,this.view,c);m&&d.appendChild(m)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.tonew Dbt(n,e,t)}function Mbt(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.topn.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function $Z(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Lbt(e,t){let n=[],r=null,i=null,s=d=>{n.push(d);let{section:f}=d.completion;if(f){r||(r=[]);let h=typeof f=="string"?f:f.name;r.some(m=>m.name==h)||r.push(typeof f=="string"?{name:h}:f)}},a=t.facet(ma);for(let d of e)if(d.hasResult()){let f=d.result.getMatch;if(d.result.filter===!1)for(let h of d.result.options)s(new PZ(h,d.source,f?f(h):[],1e9-n.length));else{let h=t.sliceDoc(d.from,d.to),m,g=a.filterStrict?new jbt(h):new Nbt(h);for(let b of d.result.options)if(m=g.match(b.label)){let y=b.displayLabel?f?f(b,m.matched):[]:m.matched,O=m.score+(b.boost||0);if(s(new PZ(b,d.source,y,O)),typeof b.section=="object"&&b.section.rank==="dynamic"){let{name:v}=b.section;i||(i=Object.create(null)),i[v]=Math.max(O,i[v]||-1e9)}}}}if(r){let d=Object.create(null),f=0,h=(m,g)=>(m.rank==="dynamic"&&g.rank==="dynamic"?i[g.name]-i[m.name]:0)||(typeof m.rank=="number"?m.rank:1e9)-(typeof g.rank=="number"?g.rank:1e9)||(m.nameh.score-f.score||u(f.completion,h.completion))){let f=d.completion;!c||c.label!=f.label||c.detail!=f.detail||c.type!=null&&f.type!=null&&c.type!=f.type||c.apply!=f.apply||c.boost!=f.boost?l.push(d):$Z(d.completion)>$Z(c)&&(l[l.length-1]=d),c=d.completion}return l}class ey{constructor(t,n,r,i,s,a){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=s,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new ey(this.options,BZ(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,s,a){if(i&&!a&&t.some(u=>u.isPending))return i.setDisabled();let l=Lbt(t,n);if(!l.length)return i&&t.some(u=>u.isPending)?i.setDisabled():null;let c=n.facet(ma).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let u=i.options[i.selected].completion;for(let d=0;dd.hasResult()?Math.min(u,d.from):u,1e8),create:zbt,above:s.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new ey(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new ey(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class jA{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new jA(Ubt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(ma),s=(r.override||n.languageDataAt("autocomplete",_g(n)).map(Abt)).map(c=>(this.active.find(d=>d.source==c)||new Ac(c,this.active.some(d=>d.state!=0)?1:0)).update(t,r));s.length==this.active.length&&s.every((c,u)=>c==this.active[u])&&(s=this.active);let a=this.open,l=t.effects.some(c=>c.is(MQ));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||s.some(c=>c.hasResult()&&t.changes.touchesRange(c.from,c.to))||!$bt(s,this.active)||l?a=ey.build(s,n,this.id,a,r,l):a&&a.disabled&&!s.some(c=>c.isPending)&&(a=null),!a&&s.every(c=>!c.isPending)&&s.some(c=>c.hasResult())&&(s=s.map(c=>c.hasResult()?new Ac(c.source,0):c));for(let c of t.effects)c.is(PQ)&&(a=a&&a.setSelected(c.value,this.id));return s==this.active&&a==this.open?this:new jA(s,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Bbt:Qbt}}function $bt(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Ubt=[];function k1e(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(DQ);if(r&&t.activateOnCompletion(r))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class Ac{constructor(t,n,r=!1){this.source=t,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=k1e(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Ac(i.source,0)),r&4&&i.state==0&&(i=new Ac(this.source,1)),i=i.updateFor(t,r);for(let s of t.effects)if(s.is(NA))i=new Ac(i.source,1,s.value);else if(s.is(fS))i=new Ac(i.source,0);else if(s.is(MQ))for(let a of s.value)a.source==i.source&&(i=a);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(_g(t.state))}}class jy extends Ac{constructor(t,n,r,i,s,a){super(t,3,n),this.limit=r,this.result=i,this.from=s,this.to=a}hasResult(){return!0}updateFor(t,n){var r;if(!(n&3))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let s=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),l=_g(t.state);if(l>a||!i||n&2&&(_g(t.startState)==this.from||ln.map(t))}}),Fo=Qa.define({create(){return jA.start()},update(e,t){return e.update(t)},provide:e=>[EQ.from(e,t=>t.tooltip),Ct.contentAttributes.from(e,t=>t.attrs)]});function LQ(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Fo).active.find(i=>i.source==t.source);return r instanceof jy?(typeof n=="string"?e.dispatch({...Cbt(e.state,n,r.from,r.to),annotations:DQ.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}const zbt=Pbt(Fo,LQ);function e_(e,t="option"){return n=>{let r=n.state.field(Fo,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp-1?r.open.selected+i*(e?1:-1):e?0:a-1;return l<0?l=t=="page"?0:a-1:l>=a&&(l=t=="page"?a-1:0),n.dispatch({effects:PQ.of(l)}),!0}}const Vbt=e=>{let t=e.state.field(Fo,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestampe.state.field(Fo,!1)?(e.dispatch({effects:NA.of(!0)}),!0):!1,Hbt=e=>{let t=e.state.field(Fo,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:fS.of(null)}),!0)};class qbt{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const Xbt=50,Gbt=1e3,Wbt=ps.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(Fo).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Fo),n=e.state.facet(ma);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Fo)==t)return;let r=e.transactions.some(s=>{let a=k1e(s,n);return a&8||(s.selection||s.docChanged)&&!(a&3)});for(let s=0;sXbt&&Date.now()-a.time>Gbt){for(let l of a.context.abortListeners)try{l()}catch(c){Go(this.view.state,c)}a.context.abortListeners=null,this.running.splice(s--,1)}else a.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(s=>s.effects.some(a=>a.is(NA)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(s=>s.isPending&&!this.running.some(a=>a.active.source==s.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let s of e.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Fo);for(let n of t.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ma).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=_g(t),r=new RQ(t,n,e.explicit,this.view),i=new qbt(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(s=>{i.context.aborted||(i.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:fS.of(null)}),Go(this.view.state,s)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ma).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(ma),r=this.view.state.field(Fo);for(let i=0;il.source==s.active.source);if(a&&a.isPending)if(s.done==null){let l=new Ac(s.active.source,0);for(let c of s.updates)l=l.update(c,n);l.isPending||t.push(l)}else this.startQuery(a)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:MQ.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Fo,!1);if(t&&t.tooltip&&this.view.state.facet(ma).closeOnBlur){let n=t.open&&Vye(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:fS.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:NA.of(!1)}),20),this.composing=0}}}),Ybt=typeof navigator=="object"&&/Win/.test(navigator.platform),Zbt=xh.highest(Ct.domEventHandlers({keydown(e,t){let n=t.state.field(Fo,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Ybt&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(a=>a.source==r.source),s=r.completion.commitCharacters||i.result.commitCharacters;return s&&s.indexOf(e.key)>-1&&LQ(t,r),!1}})),_1e=Ct.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Kbt{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class $Q{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Pa.TrackDel),r=t.mapPos(this.to,1,Pa.TrackDel);return n==null||r==null?null:new $Q(this.field,n,r)}}class BQ{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let r=[],i=[n],s=t.doc.lineAt(n),a=/^\s*/.exec(s.text)[0];for(let c of this.lines){if(r.length){let u=a,d=/^\t*/.exec(c)[0].length;for(let f=0;fnew $Q(c.field,i[c.line]+c.from,i[c.line]+c.to));return{text:r,ranges:l}}static parse(t){let n=[],r=[],i=[],s;for(let a of t.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(a);){let l=s[1]?+s[1]:null,c=s[2]||s[3]||"",u=-1;l===0&&(l=1e9);let d=c.replace(/\\[{}]/g,f=>f[1]);for(let f=0;f=u&&h.field++}for(let f of i)if(f.line==r.length&&f.from>s.index){let h=s[2]?3+(s[1]||"").length:2;f.from-=h,f.to-=h}i.push(new Kbt(u,r.length,s.index,s.index+d.length)),a=a.slice(0,s.index)+c+a.slice(s.index+s[0].length)}a=a.replace(/\\([{}])/g,(l,c,u)=>{for(let d of i)d.line==r.length&&d.from>u&&(d.from--,d.to--);return c}),r.push(a)}return new BQ(r,i)}}let Jbt=dn.widget({widget:new class extends Nu{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),eyt=dn.mark({class:"cm-snippetField"});class xO{constructor(t,n){this.ranges=t,this.active=n,this.deco=dn.set(t.map(r=>(r.from==r.to?Jbt:eyt).range(r.from,r.to)),!0)}map(t){let n=[];for(let r of this.ranges){let i=r.map(t);if(!i)return null;n.push(i)}return new xO(n,this.active)}selectionInsideField(t){return t.ranges.every(n=>this.ranges.some(r=>r.field==this.active&&r.from<=n.from&&r.to>=n.to))}}const FE=jn.define({map(e,t){return e&&e.map(t)}}),tyt=jn.define(),hS=Qa.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(FE))return n.value;if(n.is(tyt)&&e)return new xO(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>Ct.decorations.from(e,t=>t?t.deco:dn.none)});function QQ(e,t){return Je.create(e.filter(n=>n.field==t).map(n=>Je.range(n.from,n.to)))}function nyt(e){let t=BQ.parse(e);return(n,r,i,s)=>{let{text:a,ranges:l}=t.instantiate(n.state,i),{main:c}=n.state.selection,u={changes:{from:i,to:s==c.from?c.to:s,insert:Br.of(a)},scrollIntoView:!0,annotations:r?[DQ.of(r),Vs.userEvent.of("input.complete")]:void 0};if(l.length&&(u.selection=QQ(l,0)),l.some(d=>d.field>0)){let d=new xO(l,0),f=u.effects=[FE.of(d)];n.state.field(hS,!1)===void 0&&f.push(jn.appendConfig.of([hS,oyt,lyt,_1e]))}n.dispatch(n.state.update(u))}}function T1e(e){return({state:t,dispatch:n})=>{let r=t.field(hS,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,s=e>0&&!r.ranges.some(a=>a.field==i+e);return n(t.update({selection:QQ(r.ranges,i),effects:FE.of(s?null:new xO(r.ranges,i)),scrollIntoView:!0})),!0}}const ryt=({state:e,dispatch:t})=>e.field(hS,!1)?(t(e.update({effects:FE.of(null)})),!0):!1,iyt=T1e(1),syt=T1e(-1),ayt=[{key:"Tab",run:iyt,shift:syt},{key:"Escape",run:ryt}],QZ=Qt.define({combine(e){return e.length?e[0]:ayt}}),oyt=xh.highest(yO.compute([QZ],e=>e.facet(QZ)));function rs(e,t){return{...t,apply:nyt(e)}}const lyt=Ct.domEventHandlers({mousedown(e,t){let n=t.state.field(hS,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(s=>s.from<=r&&s.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:QQ(n.ranges,i.field),effects:FE.of(n.ranges.some(s=>s.field>i.field)?new xO(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),pS={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},ug=jn.define({map(e,t){let n=t.mapPos(e,-1,Pa.TrackAfter);return n??void 0}}),UQ=new class extends Kp{};UQ.startSide=1;UQ.endSide=-1;const C1e=Qa.define({create(){return gr.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of t.effects)n.is(ug)&&(e=e.update({add:[UQ.range(n.value,n.value+1)]}));return e}});function cyt(){return[dyt,C1e]}const sP="()[]{}<>«»»«[]{}";function A1e(e){for(let t=0;t{if((uyt?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Yu(Uo(r,0))==1||t!=i.from||n!=i.to)return!1;let s=pyt(e.state,r);return s?(e.dispatch(s),!0):!1}),fyt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=N1e(e,e.selection.main.head).brackets||pS.brackets,i=null,s=e.changeByRange(a=>{if(a.empty){let l=myt(e.doc,a.head);for(let c of r)if(c==l&&lR(e.doc,a.head)==A1e(Uo(c,0)))return{changes:{from:a.head-c.length,to:a.head+c.length},range:Je.cursor(a.head-c.length)}}return{range:i=a}});return i||t(e.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},hyt=[{key:"Backspace",run:fyt}];function pyt(e,t){let n=N1e(e,e.selection.main.head),r=n.brackets||pS.brackets;for(let i of r){let s=A1e(Uo(i,0));if(t==i)return s==i?yyt(e,i,r.indexOf(i+i+i)>-1,n):gyt(e,i,s,n.before||pS.before);if(t==s&&j1e(e,e.selection.main.from))return byt(e,i,s)}return null}function j1e(e,t){let n=!1;return e.field(C1e).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function lR(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Yu(Uo(n,0)))}function myt(e,t){let n=e.sliceString(t-2,t);return Yu(Uo(n,0))==n.length?n:n.slice(1)}function gyt(e,t,n,r){let i=null,s=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:ug.of(a.to+t.length),range:Je.range(a.anchor+t.length,a.head+t.length)};let l=lR(e.doc,a.head);return!l||/\s/.test(l)||r.indexOf(l)>-1?{changes:{insert:t+n,from:a.head},effects:ug.of(a.head+t.length),range:Je.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function byt(e,t,n){let r=null,i=e.changeByRange(s=>s.empty&&lR(e.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:Je.cursor(s.head+n.length)}:r={range:s});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function yyt(e,t,n,r){let i=r.stringPrefixes||pS.stringPrefixes,s=null,a=e.changeByRange(l=>{if(!l.empty)return{changes:[{insert:t,from:l.from},{insert:t,from:l.to}],effects:ug.of(l.to+t.length),range:Je.range(l.anchor+t.length,l.head+t.length)};let c=l.head,u=lR(e.doc,c),d;if(u==t){if(UZ(e,c))return{changes:{insert:t+t,from:c},effects:ug.of(c+t.length),range:Je.cursor(c+t.length)};if(j1e(e,c)){let h=n&&e.sliceDoc(c,c+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:c,to:c+h.length,insert:h},range:Je.cursor(c+h.length)}}}else{if(n&&e.sliceDoc(c-2*t.length,c)==t+t&&(d=FZ(e,c-2*t.length,i))>-1&&UZ(e,d))return{changes:{insert:t+t+t+t,from:c},effects:ug.of(c+t.length),range:Je.cursor(c+t.length)};if(e.charCategorizer(c)(u)!=Yi.Word&&FZ(e,c,i)>-1&&!Oyt(e,c,t,i))return{changes:{insert:t+t,from:c},effects:ug.of(c+t.length),range:Je.cursor(c+t.length)}}return{range:s=l}});return s?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function UZ(e,t){let n=mi(e).resolveInner(t+1);return n.parent&&n.from==t}function Oyt(e,t,n,r){let i=mi(e).resolveInner(t,-1),s=r.reduce((a,l)=>Math.max(a,l.length),0);for(let a=0;a<5;a++){let l=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+s)),c=l.indexOf(n);if(!c||c>-1&&r.indexOf(l.slice(0,c))>-1){let d=i.firstChild;for(;d&&d.from==i.from&&d.to-d.from>n.length+c;){if(e.sliceDoc(d.to-n.length,d.to)==n)return!1;d=d.firstChild}return!0}let u=i.to==t&&i.parent;if(!u)break;i=u}return!1}function FZ(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=Yi.Word)return t;for(let i of n){let s=t-i.length;if(e.sliceDoc(s,t)==i&&r(e.sliceDoc(s-1,s))!=Yi.Word)return s}return-1}function xyt(e={}){return[Zbt,Fo,ma.of(e),Wbt,vyt,_1e]}const R1e=[{key:"Ctrl-Space",run:iP},{mac:"Alt-`",run:iP},{mac:"Alt-i",run:iP},{key:"Escape",run:Hbt},{key:"ArrowDown",run:e_(!0)},{key:"ArrowUp",run:e_(!1)},{key:"PageDown",run:e_(!0,"page")},{key:"PageUp",run:e_(!1,"page")},{key:"Enter",run:Vbt}],vyt=xh.highest(yO.computeN([ma],e=>e.facet(ma).defaultKeymap?[R1e]:[])),I1e=[rs("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),rs("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),rs("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),rs("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),rs("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),rs(`try { \${} @@ -1008,7 +1008,8 @@ jobs: if not result.success: raise SystemExit(f"AgentKit publish failed: {result.error}") PY -`,a={__BASE_BRANCH__:JSON.stringify(e.baseBranch),__PROJECT_PATH__:JSON.stringify(e.projectPath),__RUNTIME_NAME__:JSON.stringify(e.runtimeName),__RUNTIME_ID__:JSON.stringify(e.runtimeId),__REGION__:JSON.stringify(e.region),__CLOUD_PROVIDER__:JSON.stringify(t),__ACCESS_KEY_SECRET__:n.accessKey,__SECRET_KEY_SECRET__:n.secretKey,__SESSION_TOKEN_SECRET__:n.sessionToken,__BYTEPLUS_ENV__:r,__BYTEPLUS_RUNTIME_ENV__:i,__CONCURRENCY_GROUP__:JSON.stringify(`agentkit-runtime-${e.runtimeId}`)};return Object.entries(a).reduce((l,[c,u])=>l.split(c).join(u),s)}const ETt={id:"delivery",kind:"github",category:"development",icon:"github",name:"AgentKit Runtime 持续交付",description:"为您的仓库添加持续交付到 AgentKit Runtime 的自动化工作流。",title:"AgentKit Runtime 持续交付",subtitle:"用 Pull Request 把持续发布配置安全地加入代码仓库",panel:"提交后将在目标仓库创建发布分支,并发起包含 GitHub Actions 工作流的 PR。",submitLabel:"确定并提交 PR",fields:[gU,bU,{name:"projectPath",label:"Agent 项目目录",placeholder:".",help:"留空时使用仓库根目录;目录内需包含挂载完整 Studio App Server 的 app.py",required:!1},Hve,qve],initialValues:({cloudProvider:e})=>xU(e),regionHelp:"必须与目标 Runtime 所在地域一致",secrets:({cloudProvider:e})=>yU(e),submit(e,t,n){const r=vU(e),i=pU(e.projectPath,"."),s=OU(t.cloudProvider);return mU({...r,files:[{path:".github/workflows/publish-agentkit.yml",content:Yve({baseBranch:r.baseBranch,projectPath:i,runtimeName:e.runtimeName.trim(),runtimeId:e.runtimeId.trim(),region:r.region,cloudProvider:t.cloudProvider}),commitMessage:"feat: publish Agent to AgentKit Runtime"}],branchPrefix:"feat/agentkit-release",title:"feat: 持续发布到 AgentKit Runtime",description:`新增 GitHub Actions 工作流,在目标分支更新时持续发布到 AgentKit Runtime。合并前请配置工作流所需的 ${s} Secrets。`},n)}};function kTt(e,t){return e==="."?t:`${e}/${t}`}function _Tt(e){return`.github/workflows/publish-agentkit-${e.replace(/[^A-Za-z0-9]+/g,"-").replace(/^-|-$/g,"").toLowerCase()||"root"}.yml`}const TTt={volcengine:"agentkit-prod-public-cn-beijing.cr.volces.com/base/py-simple:python3.12-bookworm-slim-latest",byteplus:"agentkit-prod-public-ap-southeast-1.cr.bytepluses.com/base/py-simple:python3.12-bookworm-slim-latest"};function CTt(e){const t=vR(e);return`# Local ${OU(e)} credentials. Never commit real values. +`,a={__BASE_BRANCH__:JSON.stringify(e.baseBranch),__PROJECT_PATH__:JSON.stringify(e.projectPath),__RUNTIME_NAME__:JSON.stringify(e.runtimeName),__RUNTIME_ID__:JSON.stringify(e.runtimeId),__REGION__:JSON.stringify(e.region),__CLOUD_PROVIDER__:JSON.stringify(t),__ACCESS_KEY_SECRET__:n.accessKey,__SECRET_KEY_SECRET__:n.secretKey,__SESSION_TOKEN_SECRET__:n.sessionToken,__BYTEPLUS_ENV__:r,__BYTEPLUS_RUNTIME_ENV__:i,__CONCURRENCY_GROUP__:JSON.stringify(`agentkit-runtime-${e.runtimeId}`)};return Object.entries(a).reduce((l,[c,u])=>l.split(c).join(u),s)}const ETt={id:"delivery",kind:"github",category:"development",icon:"github",name:"AgentKit Runtime 持续交付",description:"为您的仓库添加持续交付到 AgentKit Runtime 的自动化工作流。",title:"AgentKit Runtime 持续交付",subtitle:"用 Pull Request 把持续发布配置安全地加入代码仓库",panel:"提交后将在目标仓库创建发布分支,并发起包含 GitHub Actions 工作流的 PR。",submitLabel:"确定并提交 PR",fields:[gU,bU,{name:"projectPath",label:"Agent 项目目录",placeholder:".",help:"留空时使用仓库根目录;目录内需包含挂载完整 Studio App Server 的 app.py",required:!1},Hve,qve],initialValues:({cloudProvider:e})=>xU(e),regionHelp:"必须与目标 Runtime 所在地域一致",secrets:({cloudProvider:e})=>yU(e),submit(e,t,n){const r=vU(e),i=pU(e.projectPath,"."),s=OU(t.cloudProvider);return mU({...r,files:[{path:".github/workflows/publish-agentkit.yml",content:Yve({baseBranch:r.baseBranch,projectPath:i,runtimeName:e.runtimeName.trim(),runtimeId:e.runtimeId.trim(),region:r.region,cloudProvider:t.cloudProvider}),commitMessage:"feat: publish Agent to AgentKit Runtime"}],branchPrefix:"feat/agentkit-release",title:"feat: 持续发布到 AgentKit Runtime",description:`新增 GitHub Actions 工作流,在目标分支更新时持续发布到 AgentKit Runtime。合并前请配置工作流所需的 ${s} Secrets。`},n)}};function kTt(e,t){return e==="."?t:`${e}/${t}`}function _Tt(e){return`.github/workflows/publish-agentkit-${e.replace(/[^A-Za-z0-9]+/g,"-").replace(/^-|-$/g,"").toLowerCase()||"root"}.yml`}const TTt={volcengine:"agentkit-prod-public-cn-beijing.cr.volces.com/base/py-simple:python3.12-bookworm-slim-latest",byteplus:"agentkit-prod-public-ap-southeast-1.cr.bytepluses.com/base/py-simple:python3.12-bookworm-slim-latest"},CTt="1.1.9",ATt=["https://repo.huaweicloud.com/repository/pypi/simple","https://mirrors.aliyun.com/pypi/simple/","https://pypi.org/simple"];function NTt(e){return e!=="volcengine"?"RUN uv pip install -r requirements.txt":`RUN ${ATt.map(n=>`uv pip install --index-url ${n} -r requirements.txt`).join(` || \\ + `)}`}function jTt(e){const t=vR(e);return`# Local ${OU(e)} credentials. Never commit real values. ${t.accessKey}= ${t.secretKey}= # ${t.sessionToken}= @@ -1025,7 +1026,7 @@ AGENTKIT_CLOUD_PROVIDER=${e} # Optional Feishu Channel credentials. Studio can create and bind these. FEISHU_APP_ID= FEISHU_APP_SECRET= -`}function ATt(e,t="volcengine"){const n={"app.py":`"""__PROJECT_NAME__ — a VeADK agent with the full Studio App Server.""" +`}function RTt(e,t="volcengine"){const n={"app.py":`"""__PROJECT_NAME__ — a VeADK agent with the full Studio App Server.""" from assistant import root_agent from veadk.integrations.agentkit import create_agentkit_app, run_agentkit_app @@ -1069,7 +1070,7 @@ root_agent = Agent( instruction="You are a helpful assistant. Use your tools when relevant.", tools=[get_city_weather], ) -`,"requirements.txt":`veadk-python==1.1.6 +`,"requirements.txt":`veadk-python==${CTt} agentkit-sdk-python==0.8.4 google-adk==2.1.0 lark-channel-sdk==1.2.0 @@ -1081,7 +1082,7 @@ ENV UV_SYSTEM_PYTHON=1 UV_COMPILE_BYTECODE=1 PYTHONUNBUFFERED=1 WORKDIR /app COPY requirements.txt ./ -RUN uv pip install -r requirements.txt +${NTt(t)} COPY . . @@ -1106,7 +1107,7 @@ and local short-term memory fallback. Pushes to the configured target branch are continuously published by the GitHub Actions workflow added with this project. -`,".env.example":CTt(t),".gitignore":`__pycache__/ +`,".env.example":jTt(t),".gitignore":`__pycache__/ *.pyc .venv/ .env @@ -1120,38 +1121,38 @@ __pycache__/ Dockerfile .dockerignore README.md -`};return Object.fromEntries(Object.entries(n).map(([r,i])=>[r,i.split("__PROJECT_NAME__").join(e)]))}const NTt={id:"template",kind:"github",category:"development",icon:"github",name:"模板项目导入",description:"在您的仓库中创建一个可持续交付到 AgentKit Runtime 的最简智能体",title:"模板项目导入",subtitle:"把可直接启动 Studio 的 basic Agent 和持续交付配置加入仓库",panel:"提交后将创建一个 PR,同时导入 basic 项目和 AgentKit Runtime 发布工作流。",submitLabel:"导入模板并提交 PR",fields:[gU,bU,{name:"projectPath",label:"Agent 项目目录",placeholder:"agentkit-basic-agent",help:"将在此目录新增 basic 项目;app.py 挂载完整 Studio App Server,并作为服务入口启动",required:!0},Hve,qve],initialValues:({cloudProvider:e})=>xU(e,{projectPath:"agentkit-basic-agent"}),regionHelp:"必须与目标 Runtime 所在地域一致",secrets:({cloudProvider:e})=>yU(e),submit(e,t,n){const r=vU(e),i=Vve(r.repository),s=pU(e.projectPath,"agentkit-basic-agent"),a=s==="."?i.split("/").slice(-1)[0]||"agentkit-basic-agent":s.split("/").slice(-1)[0]||"agentkit-basic-agent",l=Object.entries(ATt(a,t.cloudProvider)).map(([c,u])=>({path:kTt(s,c),content:u,commitMessage:"feat: import AgentKit basic template",mustBeNew:!0}));return l.push({path:_Tt(s),content:Yve({baseBranch:r.baseBranch,projectPath:s,runtimeName:e.runtimeName.trim(),runtimeId:e.runtimeId.trim(),region:r.region,cloudProvider:t.cloudProvider}),commitMessage:"feat: add AgentKit Runtime delivery",mustBeNew:!0}),mU({...r,repository:i,files:l,branchPrefix:"feat/agentkit-basic-template",title:"feat: 导入 AgentKit basic 模板",description:`导入带有 AgentKit Studio App Server 的 basic Agent 项目,并添加持续发布到 AgentKit Runtime 的工作流。合并前请配置 ${OU(t.cloudProvider)} Secrets。`},n)}},jTt={id:"website-integration",kind:"website-integration",category:"channels",icon:"website-integration",name:"网站集成",description:"将 AgentKit Runtime 以悬浮聊天窗口嵌入网站。"},zJ=[{id:"development",label:"研发"},{id:"channels",label:"消息渠道"}],Zve=[rTt,NTt,ETt,bTt,iTt,jTt],RTt=new Map(Zve.map(e=>[e.id,e]));function Kve(e){const t=RTt.get(e);if(!t)throw new Error(`Unknown automation: ${e}`);return t}function ITt(e){const t=Kve(e);if(t.kind!=="github")throw new Error(`Automation is not backed by GitHub: ${e}`);return t}function VJ(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"10.8",cy:"10.8",r:"6.2",stroke:"currentColor",strokeWidth:"1.7"}),o.jsx("path",{d:"m15.4 15.4 4 4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function DTt(e){return o.jsxs("svg",{viewBox:"0 0 36 36",fill:"none","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"3.5",y:"5",width:"18",height:"18",rx:"5",fill:"currentColor",opacity:"0.1"}),o.jsx("rect",{x:"3.5",y:"5",width:"18",height:"18",rx:"5",stroke:"currentColor",strokeWidth:"1.6"}),o.jsx("path",{d:"m9.2 11.2-2.8 2.7 2.8 2.7M12.1 17.4h4.3",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("circle",{cx:"26.5",cy:"12",r:"3",fill:"hsl(var(--background))",stroke:"currentColor",strokeWidth:"1.6"}),o.jsx("circle",{cx:"27",cy:"26.5",r:"3",fill:"hsl(var(--background))",stroke:"currentColor",strokeWidth:"1.6"}),o.jsx("path",{d:"M21.5 12h2M19.3 21l5.6 3.8M27 15v8.5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function PTt(e){return o.jsxs("svg",{viewBox:"0 0 36 36",fill:"none","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"3.5",y:"5",width:"22",height:"18",rx:"4",stroke:"currentColor",strokeWidth:"1.6"}),o.jsx("path",{d:"M4.5 10h20M9 7.5h.1M12 7.5h.1",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),o.jsx("path",{d:"M18 18.5c0-3 2.5-5.5 5.5-5.5h3c3 0 5.5 2.5 5.5 5.5v5c0 3-2.5 5.5-5.5 5.5H25l-4 3v-3.6a5.5 5.5 0 0 1-3-4.9v-5Z",fill:"hsl(var(--background))",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),o.jsx("path",{d:"M22 19.5h6M22 23h4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function MTt({onOpen:e}){var u;const[t,n]=p.useState("development"),[r,i]=p.useState(""),s=p.useDeferredValue(r),a=p.useMemo(()=>{const d=s.trim().toLocaleLowerCase();return Zve.filter(f=>f.category===t).filter(f=>!d||`${f.name} ${f.description}`.toLocaleLowerCase().includes(d))},[t,s]),l=(u=zJ.find(d=>d.id===t))==null?void 0:u.label,c=nTt(window.location.hostname);return o.jsxs("div",{className:"applications-page",children:[o.jsxs("header",{className:"applications-header",children:[o.jsxs("div",{children:[o.jsx("h1",{children:"自动化"}),o.jsx("p",{children:"连接研发工具,为智能体扩展自动化工作流"})]}),o.jsxs("label",{className:"applications-search",children:[o.jsx(VJ,{}),o.jsx("input",{type:"search","aria-label":"搜索自动化",value:r,onChange:d=>i(d.target.value),placeholder:"搜索自动化"})]})]}),o.jsx("nav",{className:"applications-categories","aria-label":"自动化分类",children:zJ.map(d=>o.jsx("button",{type:"button",className:t===d.id?"is-active":"","aria-pressed":t===d.id,onClick:()=>n(d.id),children:d.label},d.id))}),o.jsx("section",{className:"applications-results","aria-label":`${l}自动化列表`,children:a.length?o.jsx("div",{className:"applications-grid",children:a.map(d=>{const f=d.id==="coding-agents"&&!c,h=f?"coding-agents-local-only-tooltip":void 0;return o.jsxs("div",{className:`application-card-wrap${f?" is-disabled":""}`,tabIndex:f?0:void 0,"aria-describedby":h,children:[o.jsxs("button",{type:"button",className:"application-card",onClick:()=>e(d.id),"aria-label":`打开${d.name}`,disabled:f,children:[d.icon==="feishu"?o.jsx("img",{className:"application-card-icon application-card-brand-icon",src:xR,alt:"","aria-hidden":"true"}):d.icon==="coding-agents"?o.jsx(DTt,{className:"application-card-icon"}):d.icon==="website-integration"?o.jsx(PTt,{className:"application-card-icon"}):o.jsx(fU,{className:"application-card-icon"}),o.jsxs("div",{className:"application-card-copy",children:[o.jsxs("div",{className:"application-card-title",children:[o.jsx("h2",{children:d.name}),d.badge?o.jsx("span",{className:`application-card-badge is-${d.badgeTone||"default"}`,children:d.badge}):null]}),o.jsx("p",{children:d.description})]})]}),f?o.jsx("span",{id:h,className:"application-card-tooltip",role:"tooltip",children:"仅本地部署可用"}):null]},d.id)})}):o.jsxs("div",{className:"applications-empty",role:"status",children:[o.jsx(VJ,{}),o.jsx("h2",{children:"没有匹配的自动化"}),o.jsx("p",{children:"请尝试搜索其他名称"})]})})]})}const LTt="_Container_1bl61_1",$Tt="_Track_1bl61_16",BTt="_Thumb_1bl61_56",QTt="_Label_1bl61_78",c_={Container:LTt,Track:$Tt,Thumb:BTt,Label:QTt},X6=({className:e,label:t,id:n,disabled:r,labelPosition:i="end",...s})=>{const a=p.useId(),l=n??a;return o.jsxs("div",{className:ur(c_.Container,e),"data-disabled":r?"":void 0,"data-has-label":t?"":void 0,"data-label-position":i,children:[o.jsx($Le,{id:l,className:c_.Track,disabled:r,...s,children:o.jsx(QLe,{className:c_.Thumb})}),t&&o.jsx("label",{htmlFor:l,className:c_.Label,children:t})]})};function t0({message:e,className:t="",onRetry:n,retryLabel:r="重试部署",defaultExpanded:i=!0}){const[s,a]=p.useState(i),[l,c]=p.useState(!1),u=async()=>{if(!(!n||l)){c(!0);try{await n()}finally{c(!1)}}};return o.jsxs("div",{className:`deploy-error-message${s?" is-expanded":""}${t?` ${t}`:""}`,role:"alert",children:[o.jsx("p",{className:"deploy-error-message-text",children:e}),o.jsxs("div",{className:"deploy-error-message-actions",children:[n&&o.jsxs(Nt,{type:"button",className:"deploy-error-retry",color:"danger",variant:"soft",size:"sm",pill:!1,loading:l,onClick:()=>void u(),children:[!l&&o.jsx(iRe,{}),l?"重试中…":r]}),o.jsx(Nt,{type:"button",color:"secondary",variant:"ghost",size:"sm",uniform:!0,pill:!1,title:s?"收起错误信息":"展开完整错误信息","aria-label":s?"收起错误信息":"展开完整错误信息",onClick:()=>a(d=>!d),children:s?o.jsx(cRe,{}):o.jsx(pRe,{})}),o.jsx(q7,{copyValue:e,color:"secondary",variant:"ghost",size:"sm",uniform:!0,pill:!1,title:"复制完整错误信息","aria-label":"复制完整错误信息",children:({copied:d})=>d?o.jsx(Zy,{}):o.jsx(J8,{})})]})]})}const UTt={queued:"已排队",pending:"准备中",running:"执行中",retrying:"自动重试中",success:"成功",failed:"失败",cancelled:"已取消",skipped:"已跳过"},Jve=["周日","周一","周二","周三","周四","周五","周六"];function G6(e){if(!e)return"-";const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(t).replace(/\//g,"-")}function FTt(e){if(!e.startedAt)return"-";const t=Date.parse(e.startedAt),n=e.finishedAt?Date.parse(e.finishedAt):Date.now();if(!Number.isFinite(t)||!Number.isFinite(n)||n{const u=n.current;!u||r.current||l(u.scrollHeight>u.clientHeight+1)},[]);return p.useLayoutEffect(()=>{r.current=i,i||c()},[i,c,e]),p.useEffect(()=>{const u=n.current;if(!u||typeof ResizeObserver>"u")return;const d=new ResizeObserver(c);return d.observe(u),()=>d.disconnect()},[c]),o.jsxs("div",{className:`cronjobs-run-output-body${i?" is-expanded":""}`,children:[o.jsx("p",{id:t,ref:n,children:e}),a?o.jsx(Nt,{type:"button",className:"cronjobs-run-output-toggle",color:"secondary",variant:"ghost",size:"sm",pill:!1,"aria-expanded":i,"aria-controls":t,onClick:()=>s(u=>!u),children:i?"收起":"展开"}):null]})}const Y6="Asia/Shanghai",VTt=3e3,HTt=["Asia/Shanghai","Asia/Singapore","Asia/Tokyo","Europe/London","America/Los_Angeles","America/New_York","UTC"];function qTt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||Y6}catch{return Y6}}function XTt(){const e=qTt(),t=new Date(Date.now()+24*60*60*1e3);return t.setSeconds(0,0),{name:"",runtimeId:"",prompt:"",scheduleType:"daily",onceAt:new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,16),time:"09:00",weekday:1,cron:"0 9 * * *",timezone:e,enabled:!0}}function GTt(e){return{name:e.name,runtimeId:e.runtimeId,prompt:e.prompt,scheduleType:e.schedule.type,onceAt:e.schedule.onceAt??"",time:e.schedule.time??"09:00",weekday:e.schedule.weekday??1,cron:e.schedule.cron??"0 9 * * *",timezone:e.schedule.timezone||Y6,enabled:e.enabled}}function WTt({run:e}){const t=e?e.status==="success"?"success":e.status==="failed"?"danger":["queued","pending","running","retrying"].includes(e.status)?"info":"secondary":"secondary";return o.jsx(ta,{className:"cronjobs-status",color:t,variant:"soft",size:"sm",pill:!0,children:e?UTt[e.status]:"尚未执行"})}function HJ({job:e,runtimes:t,cloudProvider:n,busy:r,onClose:i,onSubmit:s}){const[a,l]=p.useState(()=>e?GTt(e):XTt()),[c,u]=p.useState(""),[d,f]=p.useState(!1),h=p.useRef(null),m=p.useRef(null),g=p.useRef(null),b=r||d,y=p.useRef(b),O=p.useRef(i),v=p.useMemo(()=>Array.from(new Set([a.timezone,...HTt])),[a.timezone]),x=p.useMemo(()=>t.map(k=>({value:k.runtimeId,label:k.name,description:Zf(k.region,n)})),[n,t]),w=p.useMemo(()=>Jve.map((k,_)=>({value:String(_),label:k})),[]),S=p.useMemo(()=>v.map(k=>({value:k,label:k})),[v]);p.useEffect(()=>{y.current=b,O.current=i},[b,i]),p.useEffect(()=>{var T;const k=document.body.style.overflow,_=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",(T=m.current)==null||T.focus();const C=A=>{var N,D;if(A.key==="Escape"&&!y.current){O.current();return}if(A.key!=="Tab")return;const j=Array.from(((N=h.current)==null?void 0:N.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'))??[]).filter(Q=>!Q.hidden&&Q.getClientRects().length>0);if(j.length===0){A.preventDefault();return}const L=j[0],I=j[j.length-1],M=document.activeElement;A.shiftKey&&(M===L||!((D=h.current)!=null&&D.contains(M)))?(A.preventDefault(),I.focus()):!A.shiftKey&&M===I&&(A.preventDefault(),L.focus())};return window.addEventListener("keydown",C),()=>{document.body.style.overflow=k,window.removeEventListener("keydown",C),_!=null&&_.isConnected&&_.focus()}},[]);const E=async k=>{k.preventDefault();const _=a.name.trim(),C=a.prompt.trim(),T=t.find(j=>j.runtimeId===a.runtimeId);if(!_)return u("请输入任务名称。");if(!T)return u("请选择可用的 Runtime Agent。");if(!C)return u("请输入每次执行时发送给 Agent 的文本。");if(a.scheduleType==="once"&&!a.onceAt||(a.scheduleType==="daily"||a.scheduleType==="weekly")&&!a.time)return u("请选择执行时间。");const A=a.cron.trim().split(/\s+/);if(a.scheduleType==="cron"&&A.length!==5)return u("Cron 表达式需要包含 5 个字段,例如 0 9 * * *。");u(""),f(!0);try{let j=(e==null?void 0:e.runtimeId)===T.runtimeId?e.agentName.trim():"";if(!j){const[L]=await XS("","",{runtimeId:T.runtimeId,region:T.region});j=(L==null?void 0:L.trim())??""}if(!j)throw new Error("Runtime Agent 未返回可调用的 appName,请确认 Runtime 已就绪且版本兼容。");await s({name:_,runtimeId:T.runtimeId,runtimeName:T.name,agentName:j,region:T.region,prompt:C,enabled:a.enabled,schedule:{type:a.scheduleType,timezone:a.timezone,...a.scheduleType==="once"?{onceAt:a.onceAt}:{},...a.scheduleType==="daily"?{time:a.time}:{},...a.scheduleType==="weekly"?{time:a.time,weekday:a.weekday}:{},...a.scheduleType==="cron"?{cron:a.cron.trim()}:{}}})}catch(j){u(j instanceof Error?j.message:String(j)),window.requestAnimationFrame(()=>{var L;return(L=g.current)==null?void 0:L.focus()})}finally{f(!1)}};return o.jsx("div",{className:"cronjobs-drawer-backdrop",onMouseDown:k=>{k.target===k.currentTarget&&!b&&i()},children:o.jsxs("aside",{ref:h,className:"cronjobs-drawer",role:"dialog","aria-modal":"true","aria-labelledby":"cronjobs-drawer-title",children:[o.jsxs("header",{className:"cronjobs-drawer-head",children:[o.jsxs("div",{children:[o.jsx("h2",{id:"cronjobs-drawer-title",children:e?"编辑定时任务":"创建定时任务"}),o.jsx("p",{children:"每次触发都会为 Runtime Agent 创建独立 Session。"})]}),o.jsx(Nt,{type:"button",color:"secondary",variant:"ghost",size:"lg",uniform:!0,pill:!1,onClick:i,disabled:b,"aria-label":"关闭抽屉",children:o.jsx(e9,{})})]}),o.jsxs("form",{className:"cronjobs-form",onSubmit:k=>void E(k),children:[o.jsxs("div",{className:"cronjobs-form-scroll",children:[o.jsxs("label",{className:"cronjobs-field",children:[o.jsx("span",{children:"任务名称"}),o.jsx(Li,{ref:m,size:"lg",value:a.name,maxLength:80,invalid:!!c&&!a.name.trim(),onChange:k=>l({...a,name:k.target.value}),placeholder:"例如:每日生成运营摘要"})]}),o.jsxs("label",{className:"cronjobs-field",children:[o.jsx("span",{children:"Runtime Agent"}),o.jsx(Xo,{value:a.runtimeId,options:x,size:"lg",disabled:t.length===0,placeholder:t.length?"选择 Runtime Agent":"暂无可用 Runtime",onChange:k=>l({...a,runtimeId:k.value})}),o.jsx("small",{children:"任务始终跟随该 Runtime 当前生效版本。"})]}),o.jsxs("label",{className:"cronjobs-field",children:[o.jsx("span",{children:"执行文本"}),o.jsx(pd,{value:a.prompt,rows:5,maxRows:10,autoResize:!0,maxLength:2e4,invalid:!!c&&!a.prompt.trim(),onChange:k=>l({...a,prompt:k.target.value}),placeholder:"输入每次执行时发送给 Agent 的固定文本"}),o.jsxs("small",{className:"cronjobs-character-count",children:[a.prompt.length.toLocaleString()," / 20,000"]})]}),o.jsxs("fieldset",{className:"cronjobs-fieldset",children:[o.jsx("legend",{children:"执行计划"}),o.jsxs(Fs,{className:"cronjobs-schedule-types",value:a.scheduleType,size:"lg",block:!0,"aria-label":"执行计划类型",onChange:k=>l({...a,scheduleType:k}),children:[o.jsx(Fs.Option,{value:"once",children:"一次性"}),o.jsx(Fs.Option,{value:"daily",children:"每天"}),o.jsx(Fs.Option,{value:"weekly",children:"每周"}),o.jsx(Fs.Option,{value:"cron",children:"Cron"})]}),a.scheduleType==="once"?o.jsxs("label",{className:"cronjobs-field",children:[o.jsx("span",{children:"执行时间"}),o.jsx(Li,{size:"lg",type:"datetime-local",value:a.onceAt,onChange:k=>l({...a,onceAt:k.target.value})})]}):null,a.scheduleType==="daily"?o.jsxs("label",{className:"cronjobs-field",children:[o.jsx("span",{children:"每天执行时间"}),o.jsx(Li,{size:"lg",type:"time",value:a.time,onChange:k=>l({...a,time:k.target.value})})]}):null,a.scheduleType==="weekly"?o.jsxs("div",{className:"cronjobs-inline-fields",children:[o.jsxs("label",{className:"cronjobs-field",children:[o.jsx("span",{children:"星期"}),o.jsx(Xo,{value:String(a.weekday),options:w,size:"lg",onChange:k=>l({...a,weekday:Number(k.value)})})]}),o.jsxs("label",{className:"cronjobs-field",children:[o.jsx("span",{children:"执行时间"}),o.jsx(Li,{size:"lg",type:"time",value:a.time,onChange:k=>l({...a,time:k.target.value})})]})]}):null,a.scheduleType==="cron"?o.jsxs("label",{className:"cronjobs-field",children:[o.jsx("span",{children:"Cron 表达式"}),o.jsx(Li,{size:"lg",value:a.cron,onChange:k=>l({...a,cron:k.target.value}),placeholder:"0 9 * * *"}),o.jsx("small",{children:"依次填写分钟、小时、日期、月份、星期。"})]}):null,o.jsxs("label",{className:"cronjobs-field",children:[o.jsx("span",{children:"时区"}),o.jsx(Xo,{value:a.timezone,options:S,size:"lg",onChange:k=>l({...a,timezone:k.value})})]})]}),o.jsxs("div",{className:"cronjobs-switch-row",children:[o.jsxs("span",{children:[o.jsx("strong",{children:"创建后启用"}),o.jsx("small",{children:"启用后会从下一个计划时间开始执行。"})]}),o.jsx(X6,{checked:a.enabled,onCheckedChange:k=>l({...a,enabled:k}),"aria-label":"创建后启用"})]}),c?o.jsx("div",{ref:g,className:"cronjobs-inline-error",tabIndex:-1,children:o.jsx(zg,{color:"danger",variant:"soft",description:c})}):null]}),o.jsxs("footer",{className:"cronjobs-drawer-actions",children:[o.jsx(Nt,{type:"button",color:"secondary",variant:"ghost",size:"lg",pill:!1,onClick:i,disabled:b,children:"取消"}),o.jsx(Nt,{type:"submit",color:"primary",size:"lg",pill:!1,loading:b,disabled:t.length===0,"aria-busy":b||void 0,children:d?"正在连接 Runtime…":r?"保存中…":e?"保存更改":"创建任务"})]})]})]})})}function YTt({jobs:e,canCreate:t,onCreate:n,onSelect:r}){return o.jsxs(aO,{children:[o.jsx(Vg,{icon:o.jsx(Tae,{}),onClick:n,disabled:!t,title:t?"创建定时任务":"暂无可用的 Runtime Agent",children:"创建定时任务"}),e.map(i=>{const s=ewe(i.schedule);return o.jsx(bE,{className:"cronjobs-card",title:i.name,status:o.jsx(ta,{color:i.enabled?"success":"secondary",variant:"soft",size:"sm",pill:!0,children:i.enabled?"已启用":"已暂停"}),description:i.prompt,metadata:[{label:"执行计划",value:s,title:s}],detailAction:{label:"查看详情",onClick:()=>r(i)}},i.jobId)})]})}function ZTt({job:e,runs:t,runsLoading:n,runsError:r,busyAction:i,onBack:s,onEdit:a,onToggle:l,onRun:c,onDelete:u,onCancel:d,onRetryRun:f,onRetryRuns:h}){const m=t.find(b=>b.status==="queued"||b.status==="running"||b.status==="retrying"||b.status==="pending")??(W6(e)?e.latestRun:void 0),g=i.includes(e.jobId);return o.jsxs("div",{className:"cronjobs-detail",children:[o.jsxs("header",{className:"cronjobs-detail-head",children:[o.jsxs("div",{className:"cronjobs-detail-title",children:[o.jsx(Nt,{type:"button",color:"secondary",variant:"ghost",size:"lg",uniform:!0,pill:!1,onClick:s,"aria-label":"返回定时任务列表",children:o.jsx(nRe,{})}),o.jsxs("div",{children:[o.jsx("h1",{children:e.name}),o.jsxs("p",{children:[e.runtimeName||e.agentName," · ",ewe(e.schedule)]})]})]}),o.jsxs("div",{className:"cronjobs-detail-actions",children:[o.jsxs(Nt,{type:"button",color:"secondary",variant:"outline",size:"lg",pill:!1,onClick:a,disabled:g,children:[o.jsx(hRe,{}),"编辑"]}),o.jsxs(Nt,{type:"button",color:"secondary",variant:"outline",size:"lg",pill:!1,onClick:l,disabled:g,children:[e.enabled?o.jsx(ORe,{}):o.jsx(bH,{}),e.enabled?"暂停":"启用"]}),m?o.jsxs(Nt,{type:"button",color:"danger",variant:"soft",size:"lg",pill:!1,onClick:()=>d(m),disabled:g||!!m.cancellationRequestedAt,children:[o.jsx(ERe,{}),m.cancellationRequestedAt?m.status==="queued"?"取消中…":"终止中…":m.status==="queued"?"取消排队":"终止本次执行"]}):o.jsxs(Nt,{type:"button",color:"primary",size:"lg",pill:!1,onClick:c,disabled:g||!e.enabled,children:[o.jsx(bH,{}),"立即执行"]}),o.jsx(vo,{compact:!0,content:m?m.status==="queued"?"请先取消排队":"请先终止当前执行":"删除任务",children:o.jsxs(Nt,{type:"button",color:"danger",variant:"ghost",size:"lg",pill:!1,onClick:u,disabled:g||!!m,"aria-label":"删除任务",children:[o.jsx(uRe,{}),"删除"]})})]})]}),o.jsxs("div",{className:"cronjobs-detail-scroll",children:[o.jsxs("section",{className:"cronjobs-summary-grid","aria-label":"任务配置",children:[o.jsxs("dl",{children:[o.jsxs("div",{children:[o.jsx("dt",{children:"任务状态"}),o.jsx("dd",{children:e.enabled?"已启用":"已暂停"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"下次执行"}),o.jsx("dd",{children:e.enabled?G6(e.nextRunAt):"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"Runtime"}),o.jsx("dd",{title:e.runtimeName,children:e.runtimeName})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"地域"}),o.jsx("dd",{children:e.region})]})]}),o.jsxs("div",{className:"cronjobs-prompt",children:[o.jsx("span",{children:"执行文本"}),o.jsx("p",{children:e.prompt})]})]}),o.jsxs("section",{className:"cronjobs-history",children:[o.jsxs("header",{children:[o.jsxs("div",{children:[o.jsx("h2",{children:"执行历史"}),o.jsx("p",{children:"每次运行均使用独立 Session,结果与错误会永久保留。"})]}),o.jsx(vo,{compact:!0,content:"刷新",children:o.jsx(Nt,{type:"button",color:"secondary",variant:"ghost",size:"lg",uniform:!0,pill:!1,onClick:h,disabled:n,"aria-label":"刷新执行历史",children:o.jsx(CN,{})})})]}),n&&t.length===0?o.jsx(bd,{}):r?o.jsx(zg,{className:"cronjobs-history-alert",color:"danger",variant:"soft",title:"无法加载执行历史",description:r,actions:o.jsx(Nt,{type:"button",color:"danger",variant:"soft",size:"sm",pill:!1,onClick:h,children:"重试"})}):t.length===0?o.jsxs(xn,{className:"cronjobs-history-state",fill:"none",children:[o.jsx(xn.Icon,{children:o.jsx(K8,{})}),o.jsx(xn.Title,{children:"暂无执行记录"}),o.jsx(xn.Description,{children:"任务触发或立即执行后,记录会显示在这里。"})]}):o.jsx("div",{className:"cronjobs-runs",children:t.map(b=>o.jsxs("article",{className:"cronjobs-run",children:[o.jsxs("div",{className:"cronjobs-run-main",children:[o.jsx(WTt,{run:b}),o.jsxs("div",{children:[o.jsx("strong",{children:G6(b.startedAt||b.scheduledAt)}),o.jsxs("span",{children:["耗时 ",FTt(b),b.runtimeVersion?` · Runtime v${b.runtimeVersion}`:""]})]})]}),b.sessionId?o.jsxs("div",{className:"cronjobs-run-meta",children:[o.jsx("span",{children:"Session"}),o.jsx("strong",{title:b.sessionId,children:b.sessionId})]}):null,b.output?o.jsxs("div",{className:"cronjobs-run-output",children:[o.jsx("span",{children:"最终回答"}),o.jsx(zTt,{output:b.output})]}):null,b.error?o.jsxs("div",{className:"cronjobs-run-output is-error",children:[o.jsx("span",{children:"错误详情"}),o.jsx(t0,{message:b.error,className:"cronjobs-run-error-detail",defaultExpanded:!1,onRetry:b.status==="failed"?f:void 0,retryLabel:"重新执行"})]}):null,b.status==="queued"||b.status==="running"||b.status==="retrying"||b.status==="pending"?o.jsx(Nt,{type:"button",className:"cronjobs-run-cancel",color:"danger",variant:"soft",size:"sm",pill:!1,onClick:()=>d(b),disabled:g||!!b.cancellationRequestedAt,loading:!!b.cancellationRequestedAt,children:b.cancellationRequestedAt?"终止中…":b.status==="queued"?"取消排队":"终止执行"}):null]},b.runId))})]})]})]})}function KTt({cloudProvider:e}){const[t,n]=p.useState([]),[r,i]=p.useState([]),[s,a]=p.useState(!0),[l,c]=p.useState(""),[u,d]=p.useState(""),[f,h]=p.useState(void 0),[m,g]=p.useState([]),[b,y]=p.useState(!1),[O,v]=p.useState(""),[x,w]=p.useState(""),[S,E]=p.useState("all"),[k,_]=p.useState(""),[C,T]=p.useState(null),[A,j]=p.useState(""),L=t.find(Z=>Z.jobId===u),I=S==="all"?t:t.filter(Z=>S==="enabled"?Z.enabled:!Z.enabled),M=p.useCallback(async Z=>{a(!0),c("");try{const[ce,be]=await Promise.all([GM(Z),H1({scope:"all",region:"all",pageSize:100})]);if(Z!=null&&Z.aborted)return;n(ce),i(be.runtimes.filter(ie=>ie.status.toLowerCase()==="ready"))}catch(ce){if(Z!=null&&Z.aborted)return;c(ce instanceof Error?ce.message:String(ce))}finally{Z!=null&&Z.aborted||a(!1)}},[]);p.useEffect(()=>{const Z=new AbortController;return M(Z.signal),()=>Z.abort()},[M]);const N=p.useCallback(async(Z,ce)=>{y(!0),v("");try{const be=await WM(Z,ce);ce!=null&&ce.aborted||g(be)}catch(be){ce!=null&&ce.aborted||v(be instanceof Error?be.message:String(be))}finally{ce!=null&&ce.aborted||y(!1)}},[]);p.useEffect(()=>{if(!u){g([]),v("");return}const Z=new AbortController;return N(u,Z.signal),()=>Z.abort()},[N,u]);const D=t.some(W6);p.useEffect(()=>{!D&&k.includes("已排队")&&_("")},[D,k]),p.useEffect(()=>{if(!D)return;const Z=new AbortController,ce=async()=>{try{const[ie,q]=await Promise.all([GM(Z.signal),u?WM(u,Z.signal):Promise.resolve(null)]);if(Z.signal.aborted)return;n(ie),q&&g(q),ie.some(W6)||_("")}catch(ie){Z.signal.aborted||_(ie instanceof Error?ie.message:String(ie))}},be=window.setInterval(()=>void ce(),VTt);return()=>{window.clearInterval(be),Z.abort()}},[D,u]);const Q=Z=>n(ce=>ce.some(be=>be.jobId===Z.jobId)?ce.map(be=>be.jobId===Z.jobId?Z:be):[Z,...ce]),F=async(Z,ce,be,ie=!1)=>{w(Z),_("");try{await ce(),_(be)}catch(q){const X=q instanceof Error?q.message:String(q);if(ie)throw new Error(X);_(X)}finally{w("")}},$=async Z=>{const ce=f??null;await F(`${(ce==null?void 0:ce.jobId)??"new"}:save`,async()=>{const be=ce?await nle(ce.jobId,Z):await tle(Z);Q(be),h(void 0),ce&&d(be.jobId)},ce?"任务已更新。":"任务已创建。",!0)},H=Z=>void F(`${Z.jobId}:toggle`,async()=>Q(await rle(Z.jobId,!Z.enabled)),Z.enabled?"任务已暂停。":"任务已启用。"),z=(Z,ce)=>F(`${Z.jobId}:run`,async()=>{const be=await ile(Z.jobId);Q({...Z,latestRun:be}),u===Z.jobId&&g(ie=>[be,...ie.filter(q=>q.runId!==be.runId)])},ce),B=Z=>void z(Z,"任务已排队,将在一分钟内开始执行。"),V=()=>{if(!C)return;j("");const Z=C;Z.kind==="delete"?F(`${Z.job.jobId}:delete`,async()=>{await ale(Z.job.jobId),n(ce=>ce.filter(be=>be.jobId!==Z.job.jobId)),d(""),T(null)},"任务及其执行历史已删除。",!0).catch(ce=>{j(ce instanceof Error?ce.message:String(ce))}):F(`${Z.job.jobId}:cancel`,async()=>{var be;const ce=await sle(Z.job.jobId,Z.run.runId);g(ie=>ie.map(q=>q.runId===ce.runId?ce:q)),Q({...Z.job,latestRun:((be=Z.job.latestRun)==null?void 0:be.runId)===ce.runId?ce:Z.job.latestRun}),T(null)},"已提交终止请求。",!0).catch(ce=>{j(ce instanceof Error?ce.message:String(ce))})};return L?o.jsxs(ih,{className:"cronjobs-page","aria-label":"定时任务详情",children:[o.jsx(ZTt,{job:L,runs:m,runsLoading:b,runsError:O,busyAction:x,onBack:()=>d(""),onEdit:()=>h(L),onToggle:()=>H(L),onRun:()=>B(L),onDelete:()=>{j(""),T({kind:"delete",job:L})},onCancel:Z=>{j(""),T({kind:"cancel",job:L,run:Z})},onRetryRun:()=>z(L,"任务已重新排队,将在一分钟内开始执行。"),onRetryRuns:()=>void N(L.jobId)}),k?o.jsx("div",{className:"cronjobs-notice",role:"status",children:o.jsx(zg,{color:"info",variant:"soft",description:k})}):null,f!==void 0?o.jsx(HJ,{job:f,runtimes:r,cloudProvider:e,busy:x.endsWith(":save"),onClose:()=>h(void 0),onSubmit:$}):null,C?o.jsx(zl,{title:C.kind==="delete"?"删除定时任务?":"终止本次执行?",description:C.kind==="delete"?`“${C.job.name}”及其全部执行历史将被永久删除。`:"本次 Session 将被取消,后续计划不会暂停。",error:A,confirmLabel:C.kind==="delete"?"删除任务":"终止执行",variant:"danger",busy:x.endsWith(C.kind),onCancel:()=>{j(""),T(null)},onConfirm:V}):null]}):o.jsxs(ih,{className:"cronjobs-page","aria-label":"定时任务",children:[o.jsx(sO,{className:"cronjobs-page-head",title:"定时任务"}),o.jsx(g0,{children:o.jsx(pE,{idPrefix:"cronjobs-filter",ariaLabel:"定时任务状态筛选",value:S,items:[{id:"all",label:"全部"},{id:"enabled",label:"已启用"},{id:"paused",label:"已暂停"}],onChange:E})}),k?o.jsx("div",{className:"cronjobs-banner",role:"status",children:o.jsx(zg,{color:"info",variant:"soft",description:k})}):null,o.jsx(b0,{"aria-label":"定时任务列表",children:s&&t.length===0?o.jsx(bd,{}):l?o.jsxs(xn,{className:"cronjobs-state",fill:"none",children:[o.jsx(xn.Icon,{color:"danger",children:o.jsx(K8,{})}),o.jsx(xn.Title,{color:"danger",children:"无法加载定时任务"}),o.jsx(xn.Description,{children:l}),o.jsx(xn.ActionRow,{children:o.jsxs(Nt,{type:"button",color:"secondary",variant:"outline",size:"lg",pill:!1,onClick:()=>void M(),children:[o.jsx(CN,{}),"重试"]})})]}):o.jsx(YTt,{jobs:I,canCreate:!s&&r.length>0,onCreate:()=>h(null),onSelect:Z=>d(Z.jobId)})}),f!==void 0?o.jsx(HJ,{job:f,runtimes:r,cloudProvider:e,busy:x.endsWith(":save"),onClose:()=>h(void 0),onSubmit:$}):null]})}function twe({label:e,onClick:t}){return o.jsx("button",{type:"button",className:"page-back-button","aria-label":e,title:e,onClick:t,children:o.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:o.jsx("path",{d:"m14.5 6-6 6 6 6"})})})}const JTt={volcengine:"https://console.volcengine.com",byteplus:"https://console.byteplus.com"};function _S(e){return e.trim()}function wU(e){return JTt[e]}function eCt(e){const t=_S(e);if(!t)return null;let n=t;try{n=new URL(t.includes("://")?t:`https://${t}`).hostname}catch{return null}const r=n.match(/^(.+)\.tos-([a-z0-9-]+)\.(?:volces|bytepluses)\.com$/i);return r?{bucket:r[1],region:r[2]}:null}function tCt(e,t){const n=eCt(t);if(!n)return null;const r=new URLSearchParams({id:n.bucket,region:n.region,type:"objects"});return`${wU(e)}/tos/bucket/setting?${r.toString()}`}function nCt(e,t,n){const r=_S(t),i=_S(n);return!r||!i?null:`${wU(e)}/agentkit/region:agentkit+${encodeURIComponent(r)}/builtintools/${encodeURIComponent(i)}/detail`}function rCt(e,t,n){const r=_S(t),i=_S(n);return!r||!i?null:`${wU(e)}/identity/region:identity+${encodeURIComponent(r)}/user-pools/${encodeURIComponent(i)}/info`}function Ex({href:e,label:t,children:n}){return e?o.jsxs("a",{className:"system-info-resource-link",href:e,target:"_blank",rel:"noreferrer","aria-label":t,title:t,children:[o.jsx("span",{children:n}),o.jsxs("svg",{viewBox:"0 0 20 20","aria-hidden":"true",children:[o.jsx("path",{d:"M7.75 5.25h-2.5a1.5 1.5 0 0 0-1.5 1.5v8a1.5 1.5 0 0 0 1.5 1.5h8a1.5 1.5 0 0 0 1.5-1.5v-2.5"}),o.jsx("path",{d:"M10.25 3.75h6v6M16 4 9 11"})]})]}):o.jsx("span",{children:n})}function iCt(e){return e instanceof Error&&e.message.includes("Volcengine credentials not found")}function qJ(e){return e==="codex"||e==="codex_snapshot"}function XJ(){return{busy:!1,error:"",message:""}}function sCt({version:e,localMode:t,role:n,provider:r,region:i,onBack:s}){const a=n==="admin",[l,c]=p.useState(""),[u,d]=p.useState([]),[f,h]=p.useState([]),[m,g]=p.useState(null),[b,y]=p.useState(!0),[O,v]=p.useState(""),[x,w]=p.useState(!0),[S,E]=p.useState(""),[k,_]=p.useState(!0),[C,T]=p.useState(""),[A,j]=p.useState(0),[L,I]=p.useState(0),[M,N]=p.useState(0),D=p.useRef(!1),[Q,F]=p.useState({});p.useEffect(()=>(D.current=!0,()=>{D.current=!1}),[]);function $(z,B){F(V=>({...V,[z]:{...XJ(),...V[z],...B}}))}async function H(z){if(!(!qJ(z.kind)||!z.toolId||(Q[z.kind]??XJ()).busy)){$(z.kind,{busy:!0,error:"",message:""});try{const V=await Qoe(z.kind);if(!D.current)return;d(Z=>Z.map(ce=>ce.kind===z.kind?{...ce,needsModelEnvUpdate:!1,canUpdateModelEnv:!1,modelEnvError:"",modelEnvErrorCode:""}:ce)),$(z.kind,{busy:!1,error:"",message:V.updated?"已更新":"无需更新"})}catch(V){if(!D.current)return;$(z.kind,{busy:!1,error:V instanceof Error?V.message:String(V),message:""})}}}return p.useEffect(()=>{if(!a){c(""),d([]),y(!1),v("");return}const z=new AbortController;return y(!0),v(""),voe(z.signal).then(B=>{c(B.storage.tosAddress),d(B.sandboxTools)}).catch(B=>{(B==null?void 0:B.name)!=="AbortError"&&v(B instanceof Error?B.message:String(B))}).finally(()=>{z.signal.aborted||y(!1)}),()=>z.abort()},[a,A]),p.useEffect(()=>{if(!a){h([]),w(!1),E("");return}const z=new AbortController;return w(!0),E(""),$N(z.signal).then(B=>{h(B.filter(V=>V.isCurrent))}).catch(B=>{if((B==null?void 0:B.name)!=="AbortError"){if(t&&iCt(B)){h([]);return}E(B instanceof Error?B.message:String(B))}}).finally(()=>{z.signal.aborted||w(!1)}),()=>z.abort()},[a,t,L]),p.useEffect(()=>{if(!a){g(null),_(!1),T("");return}const z=new AbortController;return _(!0),T(""),Boe(z.signal).then(g).catch(B=>{(B==null?void 0:B.name)!=="AbortError"&&T(B instanceof Error?B.message:String(B))}).finally(()=>{z.signal.aborted||_(!1)}),()=>z.abort()},[a,M]),o.jsxs("div",{className:"system-info-page",children:[o.jsxs("header",{className:"system-info-page-header",children:[o.jsx(twe,{label:"返回上一页",onClick:s}),o.jsxs("div",{children:[o.jsx("h1",{children:"系统信息"}),o.jsx("p",{children:"查看当前 Studio 版本及关联的基础资源"})]})]}),o.jsxs("div",{className:"system-info-scroll",children:[o.jsxs("section",{className:"system-info-section","aria-labelledby":"studio-info-title",children:[o.jsx("h2",{id:"studio-info-title",children:"通用"}),o.jsx("dl",{className:"system-info-summary",children:o.jsxs("div",{children:[o.jsx("dt",{children:"当前版本"}),o.jsx("dd",{children:e||"—"})]})})]}),a?o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:"system-info-section","aria-labelledby":"storage-info-title",children:[o.jsx("h2",{id:"storage-info-title",children:"存储"}),b?o.jsx("div",{className:"system-info-loading",role:"status","aria-live":"polite",children:o.jsx(En,{as:"span",children:"正在加载存储信息"})}):O?o.jsxs("div",{className:"system-info-error",role:"alert",children:[o.jsx("p",{children:O}),o.jsx("button",{type:"button",onClick:()=>j(z=>z+1),children:"重新加载"})]}):o.jsx("dl",{className:"system-info-summary",children:o.jsxs("div",{className:"system-info-resource-row",children:[o.jsx("dt",{children:"TOS 地址"}),o.jsx("dd",{className:`system-info-resource-value${l?"":" is-empty"}`,children:o.jsx(Ex,{href:tCt(r,l),label:"在云控制台中打开 TOS 存储桶",children:l||"未配置"})})]})})]}),o.jsxs("section",{className:"system-info-section","aria-labelledby":"environment-build-info-title",children:[o.jsx("h2",{id:"environment-build-info-title",children:"环境构建"}),k?o.jsx("div",{className:"system-info-loading",role:"status","aria-live":"polite",children:o.jsx(En,{as:"span",children:"正在加载环境构建资源"})}):C?o.jsxs("div",{className:"system-info-error",role:"alert",children:[o.jsx("p",{children:C}),o.jsx("button",{type:"button",onClick:()=>N(z=>z+1),children:"重新加载"})]}):m?o.jsxs("dl",{className:"system-info-summary",children:[o.jsxs("div",{className:"system-info-resource-row",children:[o.jsx("dt",{children:"CodePipeline Workspace"}),o.jsx("dd",{className:"system-info-resource-value",children:o.jsx(Ex,{href:m.codePipeline.consoleUrl||null,label:"在云控制台中打开 CodePipeline Workspace",children:m.codePipeline.workspaceName||m.codePipeline.workspaceId||"首次构建时自动创建"})})]}),o.jsxs("div",{className:"system-info-resource-row",children:[o.jsx("dt",{children:"CodePipeline Pipeline"}),o.jsx("dd",{className:"system-info-resource-value",children:m.codePipeline.pipelineName||m.codePipeline.pipelineId||"首次构建时自动创建"})]}),o.jsxs("div",{className:"system-info-resource-row",children:[o.jsx("dt",{children:"Container Registry 仓库"}),o.jsx("dd",{className:"system-info-resource-value",children:o.jsx(Ex,{href:m.containerRegistry.consoleUrl||null,label:"在云控制台中打开 Container Registry 仓库",children:m.containerRegistry.imageRepository||[m.containerRegistry.registry,m.containerRegistry.namespace,m.containerRegistry.repository].filter(Boolean).join("/")||"首次构建时自动创建"})})]})]}):null]}),o.jsxs("section",{className:"system-info-section","aria-labelledby":"sandbox-tool-title",children:[o.jsx("h2",{id:"sandbox-tool-title",children:"沙箱信息"}),b?o.jsx("div",{className:"system-info-loading",role:"status","aria-live":"polite",children:o.jsx(En,{as:"span",children:"正在加载沙箱信息"})}):O?o.jsxs("div",{className:"system-info-error",role:"alert",children:[o.jsx("p",{children:O}),o.jsx("button",{type:"button",onClick:()=>j(z=>z+1),children:"重新加载"})]}):o.jsx("div",{className:"system-info-tool-list",children:u.map(z=>{const B=qJ(z.kind)?z.kind:null,V=B?Q[B]:void 0,Z=B!==null&&!!z.toolId&&z.needsModelEnvUpdate&&z.canUpdateModelEnv,ce=B?(V==null?void 0:V.error)||z.modelEnvError:"";return o.jsx("dl",{className:"system-info-tool",children:o.jsxs("div",{className:"system-info-resource-row",children:[o.jsxs("dt",{className:"system-info-tool-label",children:[o.jsx("span",{children:z.label}),z.snapshot?o.jsx("span",{className:"system-info-tool-badge",children:"快照版"}):null]}),o.jsxs("dd",{className:`system-info-resource-value${z.toolId?"":" is-empty"}`,children:[o.jsx(Ex,{href:nCt(r,i,z.toolId),label:`在云控制台中打开${z.label}`,children:z.toolId||"未配置"}),Z?o.jsx("button",{type:"button",className:"system-info-resource-update",disabled:V==null?void 0:V.busy,"aria-busy":(V==null?void 0:V.busy)||void 0,"aria-label":`更新${z.snapshot?"快照版 ":""}${z.label}模型环境变量`,title:`更新${z.snapshot?"快照版 ":""}${z.label}模型环境变量`,onClick:()=>void H(z),children:o.jsx($ae,{"aria-hidden":"true",className:V!=null&&V.busy?"is-spinning":""})}):null,B&&(V!=null&&V.message)?o.jsx("span",{className:"system-info-inline-status",role:"status",children:V.message}):null,ce?o.jsx("span",{className:"system-info-inline-error",role:"alert",children:ce}):null]})]})},z.kind)})})]}),o.jsxs("section",{className:"system-info-section","aria-labelledby":"user-pool-title",children:[o.jsx("h2",{id:"user-pool-title",children:"用户池"}),x?o.jsx("div",{className:"system-info-loading",role:"status","aria-live":"polite",children:o.jsx(En,{as:"span",children:"正在加载用户池"})}):S?o.jsxs("div",{className:"system-info-error",role:"alert",children:[o.jsx("p",{children:S}),o.jsx("button",{type:"button",onClick:()=>I(z=>z+1),children:"重新加载"})]}):f.length>0?o.jsx("div",{className:"system-info-pool-list",children:f.map(z=>o.jsxs("dl",{className:"system-info-pool",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"名称"}),o.jsx("dd",{className:"system-info-resource-value",children:o.jsx(Ex,{href:rCt(r,z.region||i,z.uid),label:`在云控制台中打开用户池${z.name?`“${z.name}”`:""}`,children:z.name||"未命名用户池"})})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"ID"}),o.jsx("dd",{children:z.uid||"—"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"域名"}),o.jsx("dd",{children:z.domain||"—"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"区域"}),o.jsx("dd",{children:z.region||"—"})]})]},z.uid))}):o.jsx("p",{className:"system-info-empty",children:t?"本地模式未配置用户池":"当前 Studio 未配置用户池"})]})]}):null]})]})}const aCt="_TextLink_16uec_1",oCt={TextLink:aCt},u_=e=>{const{children:t,primary:n=!1,underline:r=!n,className:i,target:s,forceExternal:a,as:l,href:c,to:u,...d}=e,f=a??/^https?:\/\//.test(c??u??""),h=khe(),m=l||(f?"a":h),g={...d,className:ur(oCt.TextLink,i),"data-primary":n?"":void 0,"data-underline":r?"":void 0};if(!c&&!u)return o.jsx("span",{...g,role:"button",children:t});const b={...f?{target:"_blank",rel:"noopener noreferrer",href:c??u}:{href:c,to:u},...g};return o.jsx(m,{...b,children:t})},lCt="/assets/media/article-agent-workflow-GXPkXUjV.webp",cCt="/assets/media/article-tool-debugging-BxiMDz_8.webp",uCt="/assets/media/showcase-a2ui-BgBnE9RT.webp",dCt="/assets/media/showcase-customer-service-DNw0mUH1.webp",fCt="/assets/media/showcase-multimodal-BRTl8NLI.webp",hCt="/assets/media/showcase-research-assistant-CbfMFfhS.webp",pCt="/assets/media/showcase-web-search-D2kl1imN.webp",mCt={volcengine:{console:"https://console.volcengine.com/agentkit",docs:"https://www.volcengine.com/docs/86681/1844823"},byteplus:{console:"https://console.byteplus.com/agentkit",docs:"https://docs.byteplus.com/en/docs/AgentKit"}};function gCt(e){return mCt[e]}const bCt=[{id:"documentation",title:"相关链接",description:"查看开发文档与 AgentKit 常用入口"},{id:"best-practices",title:"最佳实践",description:"参考开发、调试与部署经验"},{id:"showcases",title:"Showcases",description:"探索 AgentKit 应用案例"}],yCt="https://volcengine.github.io/veadk-python/",OCt="https://volcengine.github.io/agentkit-sdk-python/content/2.agentkit-cli/1.overview.html",xCt=[{id:"veadk-development",title:"使用 VeADK 开发并部署智能体",description:"使用 VeADK 构建 Agent,并部署至 AgentKit 智能体运行时。",meta:"AgentKit · VeADK",image:lCt,href:"https://docs.volcengine.com/docs/86681/2155817?lang=zh"},{id:"agentkit-cli-development",title:"使用 AgentKit CLI 开发并部署智能体",description:"通过 AgentKit CLI 创建项目、调试 Agent,并完成部署。",meta:"AgentKit · CLI",image:cCt,href:"https://docs.volcengine.com/docs/86681/1844871?lang=zh"}],vCt=[{id:"research-assistant",title:"多智能体研究助手",description:"由多个专业 Agent 协同完成资料检索、分析和结论整理。",image:hCt,href:"https://github.com/volcengine/veadk-python/tree/main/examples/06_multi_agent"},{id:"multimodal-analysis",title:"多模态内容分析",description:"在统一会话中理解图片、文档和视频内容。",image:fCt,href:"https://github.com/volcengine/veadk-python/tree/main/examples/multimodal_agent"},{id:"customer-service",title:"智能客服工作台",description:"结合知识检索与工具调用处理复杂的客户服务任务。",image:dCt,href:"https://github.com/volcengine/veadk-python/tree/main/examples/basic-app"},{id:"web-search",title:"联网搜索 Agent",description:"检索实时网页内容,并将信息整理为可追溯的回答。",image:pCt,href:"https://github.com/volcengine/veadk-python/tree/main/examples/04_web_search"},{id:"a2ui-app",title:"A2UI 交互应用",description:"让 Agent 根据任务过程生成可交互的前端界面。",image:uCt,href:"https://github.com/volcengine/veadk-python/tree/main/examples/a2ui_agent"}];function wCt({cloudProvider:e}){const t=gCt(e);return o.jsxs(ih,{className:"developer-resources","aria-label":"开发者资源",children:[o.jsx(sO,{title:"开发者资源"}),o.jsx("div",{className:"developer-resources__content",children:bCt.map(n=>o.jsxs("section",{className:"developer-resources__section","aria-labelledby":`developer-resources-${n.id}`,children:[o.jsxs("header",{className:"developer-resources__section-header",children:[o.jsx("h2",{id:`developer-resources-${n.id}`,children:n.title}),o.jsx("p",{children:n.description})]}),n.id==="documentation"?o.jsxs("ul",{className:"developer-resources__links",children:[o.jsx("li",{children:o.jsxs(u_,{className:"developer-resources__link",primary:!0,underline:!0,href:yCt,target:"_blank",rel:"noreferrer",children:["VeADK 文档",o.jsx(Fk,{"aria-hidden":"true"})]})}),o.jsx("li",{children:o.jsxs(u_,{className:"developer-resources__link",primary:!0,underline:!0,href:OCt,target:"_blank",rel:"noreferrer",children:["AgentKit CLI 文档",o.jsx(Fk,{"aria-hidden":"true"})]})}),o.jsx("li",{children:o.jsxs(u_,{className:"developer-resources__link",primary:!0,underline:!0,href:t.docs,target:"_blank",rel:"noreferrer",children:["AgentKit 平台文档",o.jsx(Fk,{"aria-hidden":"true"})]})}),o.jsx("li",{children:o.jsxs(u_,{className:"developer-resources__link",primary:!0,underline:!0,href:t.console,target:"_blank",rel:"noreferrer",children:["AgentKit 控制台",o.jsx(Fk,{"aria-hidden":"true"})]})})]}):n.id==="best-practices"?o.jsx("div",{className:"developer-resources__articles",children:xCt.map(r=>o.jsxs("a",{className:"developer-resources__article",href:r.href,target:"_blank",rel:"noreferrer",children:[o.jsx("img",{src:r.image,alt:`${r.title}文章封面`,loading:"lazy"}),o.jsxs("span",{className:"developer-resources__article-copy",children:[o.jsx("strong",{children:r.title}),o.jsx("span",{children:r.description}),o.jsx("small",{children:r.meta})]})]},r.id))}):n.id==="showcases"?o.jsx("div",{className:"developer-resources__showcases",children:vCt.map(r=>o.jsxs("a",{className:"developer-resources__showcase",href:r.href,target:"_blank",rel:"noreferrer",children:[o.jsx("span",{className:"developer-resources__showcase-media",children:o.jsx("img",{src:r.image,alt:`${r.title}界面预览`,loading:"lazy"})}),o.jsx("strong",{children:r.title}),o.jsx("span",{children:r.description})]},r.id))}):null]},n.id))})]})}function SCt(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"m9.8 3.5-4.5 4.5 4.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function ECt({hidden:e,...t}){return o.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[o.jsx("path",{d:"M2.5 10s2.6-4 7.5-4 7.5 4 7.5 4-2.6 4-7.5 4-7.5-4-7.5-4Z"}),o.jsx("circle",{cx:"10",cy:"10",r:"1.8"}),e?o.jsx("path",{d:"m4 4 12 12"}):null]})}function GJ(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"M6.5 4H4.8A1.8 1.8 0 0 0 3 5.8v5.4A1.8 1.8 0 0 0 4.8 13h5.4a1.8 1.8 0 0 0 1.8-1.8V9.5M9 3h4v4M12.5 3.5 7.2 8.8",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function kCt(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"m4 6 4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function _Ct(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"m3.5 8.2 2.8 2.8 6.2-6.2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function zP(e,t,n){const r=t.trim();if(!r)return n?"此项不能为空":"";if(e==="repository"&&!/^(?:https:\/\/github\.com\/)?[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?:\.git)?$/.test(r))return"请输入 owner/repository 或完整 GitHub Repo URL";if(e==="baseBranch"&&(!/^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(r)||r.includes("..")))return"目标分支格式不正确";if(e==="projectPath"&&(r.startsWith("/")||r.split("/").includes("..")))return"请输入仓库内的相对目录";if(e==="runtimeName")return qE(r)??"";if(e==="runtimeId"&&!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(r))return"Runtime ID 格式不正确";if(e==="sandboxToolId"&&!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(r))return"Sandbox Tool ID 格式不正确";if(e==="modelName"&&!/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/.test(r))return"模型名称格式不正确";if(e==="modelBaseUrl")try{const i=new URL(r);if(i.protocol!=="https:"||i.username||i.password||i.search||i.hash)return"请输入不含凭据、查询参数或锚点的 HTTPS 地址"}catch{return"请输入有效的 HTTPS 地址"}return""}function TCt({automation:e,cloudProvider:t,onBack:n}){const r=ITt(e),i=Sd(t),s=r.secrets({cloudProvider:t}),[a,l]=p.useState(()=>({...r.initialValues({cloudProvider:t})})),c=i.find(A=>A.value===a.region),[u,d]=p.useState({}),[f,h]=p.useState(""),[m,g]=p.useState(!1),[b,y]=p.useState(!1),[O,v]=p.useState(!1),[x,w]=p.useState(null),S=p.useRef(null);p.useEffect(()=>()=>{var A;return(A=S.current)==null?void 0:A.abort()},[]),p.useEffect(()=>{var A;l({...r.initialValues({cloudProvider:t})}),d({}),h(""),w(null),v(!1),(A=S.current)==null||A.abort()},[e,t,r]);const E=(A,j)=>{l(L=>({...L,[A]:j})),u[A]&&d(L=>({...L,[A]:""}))},k=A=>{var I;const j=A==="token"||((I=r.fields.find(M=>M.name===A))==null?void 0:I.required)===!0,L=zP(A,a[A],j);d(M=>({...M,[A]:L}))},_=async A=>{var M;A.preventDefault();const j={};for(const N of r.fields){const D=zP(N.name,a[N.name],N.required);D&&(j[N.name]=D)}const L=zP("token",a.token,!0);if(L&&(j.token=L),d(j),Object.keys(j).length)return;(M=S.current)==null||M.abort();const I=new AbortController;S.current=I,g(!0),h(""),w(null);try{const N=await r.submit(a,{cloudProvider:t},I.signal);if(S.current!==I)return;w(N),l(D=>({...D,token:""}))}catch(N){if(I.signal.aborted||S.current!==I)return;h(N instanceof Error?N.message:String(N))}finally{S.current===I&&(S.current=null,g(!1))}},C=A=>{A.key==="Enter"&&(A.nativeEvent.isComposing||A.nativeEvent.keyCode===229)&&A.preventDefault()},T=A=>{const{name:j,label:L,placeholder:I,help:M,required:N}=A;return o.jsxs("div",{className:"github-field",children:[o.jsxs("label",{htmlFor:`github-${j}`,children:[o.jsx("span",{children:L}),o.jsx("span",{className:`github-field-requirement${N?" is-required":""}`,children:N?"必填":"可选"})]}),o.jsx("input",{id:`github-${j}`,value:a[j],onChange:D=>E(j,D.target.value),onBlur:()=>k(j),placeholder:I,required:N,"aria-invalid":!!u[j],"aria-describedby":`github-${j}-help${u[j]?` github-${j}-error`:""}`}),o.jsx("span",{id:`github-${j}-help`,className:"github-field-help",children:M}),u[j]?o.jsx("span",{id:`github-${j}-error`,className:"github-field-error",role:"alert",children:u[j]}):null]},j)};return o.jsxs("div",{className:"github-integration-page",children:[o.jsxs("header",{className:"github-integration-header",children:[o.jsx("button",{type:"button",className:"github-back",onClick:n,"aria-label":"返回自动化列表",children:o.jsx(SCt,{})}),o.jsx(fU,{className:"github-integration-logo"}),o.jsxs("div",{children:[o.jsx("h1",{children:r.title}),o.jsx("p",{children:r.subtitle})]})]}),o.jsx("div",{className:"github-integration-layout",children:o.jsxs("section",{id:`github-panel-${e}`,className:"github-section-panel",children:[o.jsx("div",{className:"github-panel-heading",children:o.jsx("p",{children:r.panel})}),o.jsxs("form",{className:"github-release-form",onSubmit:_,onKeyDown:C,noValidate:!0,children:[o.jsxs("div",{className:"github-field-grid",children:[r.fields.map(T),o.jsxs("div",{className:"github-field",children:[o.jsxs("label",{id:"github-region-label",children:[o.jsx("span",{children:"地域"}),o.jsx("span",{className:"github-field-requirement is-required",children:"必填"})]}),o.jsxs("div",{className:"pp-network-region github-region-picker",onKeyDown:A=>{A.key==="Escape"&&v(!1)},children:[o.jsxs("button",{type:"button",className:"pp-region-trigger","aria-labelledby":"github-region-label","aria-haspopup":"listbox","aria-expanded":O,onClick:()=>v(A=>!A),children:[o.jsx("span",{children:(c==null?void 0:c.label)??a.region}),o.jsx(kCt,{className:`pp-region-chevron${O?" is-open":""}`})]}),O?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-scrim",onClick:()=>v(!1)}),o.jsx("div",{className:"pp-region-menu",role:"listbox","aria-label":"地域",children:i.map(A=>{const j=A.value===a.region;return o.jsxs("button",{type:"button",role:"option","aria-selected":j,className:`pp-region-option${j?" is-selected":""}`,onClick:()=>{E("region",A.value),v(!1)},children:[o.jsx("span",{children:A.label}),j?o.jsx(_Ct,{}):null]},A.value)})})]}):null]}),o.jsx("span",{className:"github-field-help",children:r.regionHelp})]})]}),o.jsxs("div",{className:"github-field github-token-field",children:[o.jsxs("div",{className:"github-token-label-row",children:[o.jsxs("label",{htmlFor:"github-token",children:[o.jsx("span",{children:"GitHub Token"}),o.jsx("span",{className:"github-field-requirement is-required",children:"必填"})]}),o.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new?name=VeADK%20Studio&description=Create%20a%20GitHub%20automation%20pull%20request&contents=write&pull_requests=write",target:"_blank",rel:"noreferrer",children:["获取 Token",o.jsx(GJ,{})]})]}),o.jsxs("div",{className:"github-token-input",children:[o.jsx("input",{id:"github-token",type:b?"text":"password",value:a.token,onChange:A=>E("token",A.target.value),onBlur:()=>k("token"),autoComplete:"off",required:!0,placeholder:"需要仓库 Contents 与 Pull requests 写权限","aria-invalid":!!u.token,"aria-describedby":`github-token-help${u.token?" github-token-error":""}`}),o.jsx("button",{type:"button",onClick:()=>y(A=>!A),"aria-label":b?"隐藏 Token":"显示 Token",title:b?"隐藏 Token":"显示 Token",children:o.jsx(ECt,{hidden:b})})]}),o.jsx("span",{id:"github-token-help",className:"github-field-help",children:"Token 仅用于本次提交,不会保存在浏览器或写入 PR"}),u.token?o.jsx("span",{id:"github-token-error",className:"github-field-error",role:"alert",children:u.token}):null]}),f?o.jsx("div",{className:"github-submit-message is-error",role:"alert",children:f}):null,x?o.jsxs("div",{className:"github-submit-message is-success",role:"status",children:[o.jsxs("span",{children:["PR #",x.number," 已创建"]}),o.jsxs("a",{href:x.url,target:"_blank",rel:"noreferrer",children:["在 GitHub 查看",o.jsx(GJ,{})]})]}):null,o.jsxs("div",{className:"github-form-actions",children:[o.jsxs("div",{className:"github-secrets-note",children:[o.jsx("strong",{children:"合并 PR 前,请在仓库的 GitHub Actions Secrets 中配置:"}),s.map(A=>o.jsx("span",{children:A},A))]}),o.jsx("button",{type:"submit",disabled:m,children:m?"提交 PR 中…":r.submitLabel})]})]})]})})]})}const CCt=1050062,WJ="1.0",ACt="https://lf-static.applogcdn.com/obj/applog-sdk-static/log-sdk/collect/5/collect.js";class NCt{constructor(){kr(this,"enabled",!1);kr(this,"initialized",!1);kr(this,"pending",[]);kr(this,"userUniqueId","");kr(this,"initPromise")}init(t){return this.enabled=t.enabled,this.enabled?this.initPromise?this.initPromise:(this.initPromise=Promise.resolve().then(()=>{const n=this.bootstrapCollector();n("init",{app_id:CCt,channel:"cn",disable_auto_pv:1}),this.userUniqueId&&n("config",{user_unique_id:this.userUniqueId}),n("config",{_staging_flag:t.environment==="prod"?0:1}),n("start"),this.initialized=!0;const r=this.pending;this.pending=[];for(const[i,s]of r)this.collect(i,s)}),this.initPromise):(this.pending=[],Promise.resolve())}identify(t){this.userUniqueId=t,this.initialized&&this.collect("config",{user_unique_id:t})}emit(t,n){if(this.enabled){if(this.initialized){this.collect(t,n);return}this.pending=[...this.pending.slice(-49),[t,n]]}}bootstrapCollector(){if(window.collectEvent)return window.collectEvent;window.LogAnalyticsObject="collectEvent";const t=function(){var i;(i=t.q)==null||i.push(arguments)};t.q=[],t.l=Date.now(),window.collectEvent=t;const n=document.createElement("script");return n.async=!0,n.src=ACt,n.onerror=()=>{this.enabled=!1,t.q=[],console.warn("[telemetry] TEA SDK script failed to load")},document.head.appendChild(n),t}collect(t,n){var r;(r=window.collectEvent)==null||r.call(window,t,n)}}const jCt=256,nwe=1024,VP="[REDACTED]";function RCt(e){if(typeof e!="string"&&typeof e!="number")return;const t=String(e).trim();return/^[A-Za-z0-9_.:-]{1,64}$/.test(t)?t:void 0}function Zd(e,t){return t===void 0?{errorKind:e}:{errorKind:e,errorCode:t}}function rwe(e,t,n={}){if(e.length<=t)return e;if(n.preserveEnd){const i="[truncated] ...";return`${i}${e.slice(-Math.max(0,t-i.length))}`}const r="... [truncated]";return`${e.slice(0,Math.max(0,t-r.length))}${r}`}function ICt(e){return e.replace(/\b(Authorization\s*[:=]\s*)(Bearer\s+)?[^\s"',;&]+/gi,(t,n,r)=>`${n}${r??""}${VP}`).replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi,`Bearer ${VP}`).replace(/\b([\w.-]*(?:token|password|passwd|secret|api[_-]?key|access[_-]?key|secret[_-]?key|cookie)[\w.-]*\s*[:=]\s*)(["']?)[^\s"',;&]+/gi,(t,n,r)=>`${n}${r}${VP}`)}function Dy(e,t={}){const n=e!==null&&typeof e=="object"?e:{},i=(typeof n.message=="string"?n.message:typeof e=="string"||typeof e=="number"||typeof e=="boolean"?String(e):"").replace(/\s+/g," ").trim();if(i)return rwe(ICt(i),nwe,t)}function fo(e,t={}){const n=e!==null&&typeof e=="object"?e:{},r=RCt(n.code),i=typeof n.name=="string"?n.name:"";if(i==="RuntimeProbeError")return Zd("runtime_probe_error",r);if(i==="AbortError")return Zd("abort",r);if(i==="RuntimeAccessDeniedError"||i==="AuthError")return Zd("auth",r);if(t.phase==="build")return Zd("build_failed",r);if(i==="TimeoutError")return Zd("timeout",r);if(i==="NetworkError"||i==="TypeError")return Zd("network",r);if(i==="ValidationError")return Zd("validation",r);if(i==="ServerError")return Zd("server",r);const s=typeof n.status=="number"&&Number.isInteger(n.status)?n.status:void 0;if(s===void 0||s<400||s>599)return Zd("unknown",r);const a=String(s);return s===401||s===403?{errorKind:"auth",errorCode:a}:s===400||s===409||s===422?{errorKind:"validation",errorCode:a}:s>=500?{errorKind:"server",errorCode:a}:{errorKind:"unknown",errorCode:a}}const DCt=["schema_version","event_id","operation_id","user_pool_id","studio_deploy_id","vefaas_application_id","vefaas_function_id","studio_region","studio_project","studio_version","environment","cloud_provider","account_id","account_id_resolution_error","user_role","user_source","page_instance_id"],PCt={studio_entry_viewed:["auth_state"],studio_session_started:["agents_source"],studio_agent_deploy:["status","agent_id","deploy_action","deploy_source","create_mode","ai_assisted","deploy_region","runtime_network_type","feishu_enabled","runtime_id","duration_ms","failed_phase","error_kind","error_code","error_message"],studio_sandbox_create:["status","sandbox_kind","sandbox_source","sandbox_id","duration_ms","error_kind","error_code"],studio_agent_debug:["status","agent_id","variant_type","debug_run_id","duration_ms","failed_phase","error_kind","error_code"],studio_agent_connect:["status","target_id","agent_kind","connect_source","runtime_region","runtime_is_mine","sandbox_status","duration_ms","error_kind","error_code"],studio_agent_message:["status","agent_id","agent_kind","message_source","session_state","session_id","duration_ms","failed_phase","error_kind","error_code"],studio_agent_source_download:["status","agent_id","deploy_action","deploy_source","create_mode","ai_assisted","duration_ms","file_count","zip_size_bytes","error_kind","error_code"]};function MCt(e){return typeof e=="string"||typeof e=="number"&&Number.isFinite(e)}function YJ(e,t){const n=new Set([...DCt,...PCt[e]]),r={};for(const[i,s]of Object.entries(t))!n.has(i)||!MCt(s)||(typeof s=="string"?r[i]=rwe(s,i==="error_message"?nwe:jCt):r[i]=s);return r}function LCt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}function $Ct(){return typeof performance<"u"?performance.now():Date.now()}function ib(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}class BCt{constructor(t){kr(this,"sink");kr(this,"createId");kr(this,"now");kr(this,"pageInstanceId");kr(this,"context");kr(this,"identity");kr(this,"entryViewed",!1);kr(this,"sessionStarted",!1);this.sink=t.sink,this.createId=t.createId??LCt,this.now=t.now??$Ct,this.pageInstanceId=this.createId()}setContext(t){var n,r;this.context={...t,accountId:((n=t.accountId)==null?void 0:n.trim())??"",accountIdResolutionError:((r=t.accountIdResolutionError)==null?void 0:r.trim())??""}}identify(t){var r,i,s;const n=t.userUniqueId.trim();n&&(this.identity&&this.identity.userUniqueId!==n&&(this.pageInstanceId=this.createId(),this.sessionStarted=!1),this.identity={...t,userUniqueId:n,accountId:((r=t.accountId)==null?void 0:r.trim())??""},(s=(i=this.sink).identify)==null||s.call(i,n))}trackStudioSessionStarted(t){this.sessionStarted||!this.context||!this.identity||(this.sessionStarted=!0,this.emit("studio_session_started",{agents_source:t.agentsSource}))}trackStudioEntryViewed(t){if(this.entryViewed||!this.context)return;this.entryViewed=!0;const n=YJ("studio_entry_viewed",ib({schema_version:WJ,event_id:this.createId(),user_pool_id:this.context.userPoolId,studio_deploy_id:this.context.studioDeployId,vefaas_application_id:this.context.applicationId,vefaas_function_id:this.context.functionId,studio_region:this.context.studioRegion,studio_project:this.context.studioProject,studio_version:this.context.studioVersion,environment:this.context.environment,cloud_provider:this.context.cloudProvider,account_id:this.context.accountId,account_id_resolution_error:this.context.accountIdResolutionError||void 0,page_instance_id:this.pageInstanceId,auth_state:t.authState}));this.sink.emit("studio_entry_viewed",n)}beginAgentDeploy(t){return this.beginOperation("studio_agent_deploy",{agent_id:t.agentId,deploy_action:t.deployAction,deploy_source:t.deploySource,create_mode:t.createMode,ai_assisted:t.aiAssisted,deploy_region:t.deployRegion,runtime_network_type:t.runtimeNetworkType,feishu_enabled:t.feishuEnabled},n=>({runtime_id:n.runtimeId}),n=>({failed_phase:n.failedPhase,error_kind:n.errorKind,error_code:n.errorCode,error_message:n.errorMessage}))}beginSandboxCreate(t){return this.beginOperation("studio_sandbox_create",{sandbox_kind:t.sandboxKind,sandbox_source:t.sandboxSource},n=>({sandbox_id:n.sandboxId}),n=>({error_kind:n.errorKind,error_code:n.errorCode}))}beginAgentDebug(t){return this.beginOperation("studio_agent_debug",{agent_id:t.agentId,variant_type:t.variantType},n=>({debug_run_id:n.debugRunId}),n=>({failed_phase:n.failedPhase,error_kind:n.errorKind,error_code:n.errorCode}))}beginAgentConnect(t){return this.beginOperation("studio_agent_connect",{target_id:t.targetId,agent_kind:t.agentKind,connect_source:t.connectSource},n=>ib({runtime_region:n.runtimeRegion,runtime_is_mine:n.runtimeIsMine,sandbox_status:n.sandboxStatus}),n=>ib({error_kind:n.errorKind,error_code:n.errorCode}))}beginAgentMessage(t){return this.beginOperation("studio_agent_message",ib({agent_id:t.agentId,agent_kind:t.agentKind,message_source:t.messageSource,session_state:t.sessionState,session_id:t.sessionId}),n=>({session_id:n.sessionId}),n=>ib({session_id:n.sessionId,failed_phase:n.failedPhase,error_kind:n.errorKind,error_code:n.errorCode}))}beginAgentSourceDownload(t){return this.beginOperation("studio_agent_source_download",{agent_id:t.agentId,deploy_action:t.deployAction,deploy_source:t.deploySource,create_mode:t.createMode,ai_assisted:t.aiAssisted},n=>({file_count:n.fileCount,zip_size_bytes:n.zipSizeBytes}),n=>({file_count:n.fileCount,error_kind:n.errorKind,error_code:n.errorCode}))}beginOperation(t,n,r,i){const s=this.createId(),a=this.now(),l=!!(this.context&&this.identity);let c=!1;l&&this.emit(t,{...n,status:"started"},s);const u=(d,f)=>{c||(c=!0,l&&this.emit(t,{...n,...f,status:d,duration_ms:Math.max(0,this.now()-a)},s))};return{operationId:s,succeed:d=>u("succeeded",r(d)),fail:d=>u("failed",i(d))}}emit(t,n,r){if(!this.context||!this.identity)return;const i=YJ(t,ib({schema_version:WJ,event_id:this.createId(),operation_id:r,user_pool_id:this.context.userPoolId,studio_deploy_id:this.context.studioDeployId,vefaas_application_id:this.context.applicationId,vefaas_function_id:this.context.functionId,studio_region:this.context.studioRegion,studio_project:this.context.studioProject,studio_version:this.context.studioVersion,environment:this.context.environment,cloud_provider:this.context.cloudProvider,account_id:this.identity.accountId,account_id_resolution_error:this.context.accountIdResolutionError||void 0,user_role:this.identity.userRole,user_source:this.identity.userSource,page_instance_id:this.pageInstanceId,...n}));this.sink.emit(t,i)}}const iwe=new NCt,jd=new BCt({sink:iwe});function QCt(e){return iwe.init(e)}function UCt(e){jd.setContext(e)}function FCt(e){jd.identify(e)}function zCt(e){jd.trackStudioEntryViewed(e)}function VCt(e){jd.trackStudioSessionStarted(e)}function swe(e){return jd.beginAgentDeploy(e)}function HCt(e){return jd.beginSandboxCreate(e)}function qCt(e){return jd.beginAgentDebug(e)}function HP(e){return jd.beginAgentConnect(e)}function ZJ(e){return jd.beginAgentMessage(e)}function awe(e){return jd.beginAgentSourceDownload(e)}const XCt=/^[A-Za-z_][A-Za-z0-9_]*$/;function A1(e){return e.trim().length===0?"名称为必填项":e==="user"?"user 是 Google ADK 保留名称,请使用其他名称":XCt.test(e)?null:"名称须以英文字母或下划线开头,且只能包含英文字母、数字和下划线"}function GCt(e){const t=new Set,n=new Set,r=i=>{A1(i.name)===null&&(t.has(i.name)?n.add(i.name):t.add(i.name)),i.subAgents.forEach(r)};return r(e),n}function WCt(e){return{...Ml(),name:e,description:"一个通过飞书接收消息并提供帮助的智能助手。",instruction:"你是一个通过飞书为用户提供帮助的智能助手。准确理解用户问题,给出简洁、可靠的回答;信息不足时先提问澄清,不要臆造事实。",deployment:{feishuEnabled:!0}}}async function YCt(e){const t=WCt(e.agentName),n=await xC(t);return V1(n.name,n.files,{region:e.region,projectName:"default"},{taskId:e.taskId,sessionStorage:"in-memory",minInstance:1,maxInstance:1,description:t.description,im:{feishu:{enabled:!0}},envs:[{key:"FEISHU_APP_ID",value:e.appId},{key:"FEISHU_APP_SECRET",value:e.appSecret}],onStage:e.onStage})}const Kc=[{value:"cn-beijing",label:"北京"},{value:"cn-shanghai",label:"上海"}],owe=[{phase:"prepare",label:"生成智能体"},{phase:"build",label:"构建镜像"},{phase:"deploy",label:"创建 Runtime"},{phase:"publish",label:"发布服务"}];function ZCt(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"m9.8 3.5-4.5 4.5 4.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function KCt(e){return o.jsx("svg",{viewBox:"0 0 18 18",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"m5 7 4 4 4-4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function KJ(e){return o.jsx("svg",{viewBox:"0 0 18 18",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"m4 9.2 3.1 3.1L14 5.8",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function JCt(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"M6.5 4H4.8A1.8 1.8 0 0 0 3 5.8v5.4A1.8 1.8 0 0 0 4.8 13h5.4a1.8 1.8 0 0 0 1.8-1.8V9.5M9 3h4v4M12.5 3.5 7.2 8.8",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function eAt(e){if(!e||e==="upload")return 0;const t=owe.findIndex(n=>n.phase===e);return t<0?0:t}function qP(e){switch(e){case"prepare":case"upload":case"build":case"deploy":case"publish":case"update":case"evaluation":return e;default:return"unknown"}}function tAt({onBack:e}){var ie;const[t,n]=p.useState("feishu_assistant"),[r,i]=p.useState(""),[s,a]=p.useState(""),[l,c]=p.useState(!1),[u,d]=p.useState("cn-beijing"),[f,h]=p.useState(!1),[m,g]=p.useState(""),[b,y]=p.useState(""),[O,v]=p.useState(""),[x,w]=p.useState("idle"),[S,E]=p.useState(null),[k,_]=p.useState(""),[C,T]=p.useState(null),A=p.useRef(null),j=p.useRef(null),L=p.useRef([]),I=p.useRef(0),M=p.useRef(null),N=p.useRef(null),D=p.useRef("prepare"),Q=p.useRef(!1),F=p.useRef(!0),$=["preparing","running","cancelling"].includes(x);p.useEffect(()=>(F.current=!0,()=>{F.current=!1}),[]),p.useEffect(()=>{var K;if(!f)return;(K=L.current[I.current])==null||K.focus();const q=de=>{de.target instanceof Node&&A.current&&!A.current.contains(de.target)&&h(!1)},X=de=>{var xe;de.key==="Escape"&&(h(!1),(xe=j.current)==null||xe.focus())};return window.addEventListener("pointerdown",q),window.addEventListener("keydown",X),()=>{window.removeEventListener("pointerdown",q),window.removeEventListener("keydown",X)}},[f]);const H=q=>{q.key==="Enter"&&(q.nativeEvent.isComposing||q.nativeEvent.keyCode===229)&&q.preventDefault()},z=()=>{const q=A1(t.trim())??"",X=r.trim()?"":"请输入飞书 App ID",K=s.trim()?"":"请输入飞书 App Secret";return g(q),y(X),v(K),!q&&!X&&!K},B=async q=>{if(q.preventDefault(),!z()||$)return;const X=crypto.randomUUID();M.current=X,D.current="prepare",Q.current=!1,w("preparing"),E(null),_(""),T(null);const K=swe({agentId:String(t.trim()),deployAction:"create",deploySource:"feishu_automation",createMode:"feishu_template",aiAssisted:0,deployRegion:String(u),runtimeNetworkType:"public",feishuEnabled:1});N.current=K;try{const de=await YCt({agentName:t.trim(),appId:r.trim(),appSecret:s.trim(),region:u,taskId:X,onStage:xe=>{D.current=xe.phase||"deploy",!(!F.current||Q.current)&&(w("running"),E(xe))}});if(Q.current){K.fail({failedPhase:qP(D.current),errorKind:"abort",errorMessage:Dy("用户取消部署")});return}if(K.succeed({runtimeId:String(de.runtimeId||"")}),!F.current)return;T(de),a(""),c(!1),w("succeeded")}catch(de){if(K.fail({failedPhase:qP(D.current),...Q.current?{errorKind:"abort"}:fo(de,{phase:D.current}),errorMessage:Dy(de)}),!F.current||Q.current)return;w("failed"),_(de instanceof Error?de.message:String(de))}finally{M.current===X&&(M.current=null),N.current===K&&(N.current=null)}},V=async()=>{var X;const q=M.current;if(!(!q||x!=="running")&&window.confirm("取消部署将停止任务并清理已创建的 Runtime,确定继续吗?")){Q.current=!0,w("cancelling"),_("");try{await Xoe(q),(X=N.current)==null||X.fail({failedPhase:qP(D.current),errorKind:"abort",errorMessage:Dy("用户取消部署")}),F.current&&w("cancelled")}catch(K){if(Q.current=!1,!F.current)return;w("failed"),_(K instanceof Error?K.message:String(K))}}},Z=eAt((S==null?void 0:S.phase)??null),ce=!!(t.trim()&&r.trim()&&s.trim()&&!$),be=Kc.find(q=>q.value===u);return o.jsxs("div",{className:"feishu-integration-page",children:[o.jsxs("header",{className:"feishu-integration-header",children:[o.jsx("button",{type:"button",className:"feishu-back",onClick:e,"aria-label":"返回自动化列表",disabled:$,children:o.jsx(ZCt,{})}),o.jsx("img",{className:"feishu-integration-logo",src:xR,alt:"","aria-hidden":"true"}),o.jsxs("div",{children:[o.jsx("h1",{children:"飞书机器人"}),o.jsx("p",{children:"创建一个由 AgentKit Runtime 驱动的飞书智能体"})]})]}),o.jsx("div",{className:"feishu-integration-layout",children:o.jsxs("section",{className:"feishu-section-panel",children:[o.jsx("p",{className:"feishu-panel-description",children:"填写已发布飞书应用的凭据,Studio 将生成 basic 智能体、创建独立 Runtime,并启用飞书消息长连接。"}),o.jsxs("form",{className:"feishu-form",onSubmit:B,onKeyDown:H,noValidate:!0,children:[o.jsxs("div",{className:"feishu-field-grid",children:[o.jsxs("div",{className:"feishu-field",children:[o.jsx("label",{htmlFor:"feishu-agent-name",children:"智能体名称"}),o.jsx("input",{id:"feishu-agent-name",value:t,maxLength:64,disabled:$,onChange:q=>{n(q.target.value),m&&g("")},onBlur:()=>g(A1(t.trim())??""),"aria-invalid":!!m,"aria-describedby":`feishu-agent-name-help${m?" feishu-agent-name-error":""}`}),o.jsx("span",{id:"feishu-agent-name-help",className:"feishu-field-help",children:"将作为新 Runtime 中的根智能体名称"}),m?o.jsx("span",{id:"feishu-agent-name-error",className:"feishu-field-error",role:"alert",children:m}):null]}),o.jsxs("div",{className:"feishu-field",children:[o.jsx("label",{id:"feishu-region-label",children:"部署地域"}),o.jsxs("div",{className:"feishu-region-picker",ref:A,children:[o.jsxs("button",{ref:j,type:"button",className:"feishu-region-trigger",disabled:$,"aria-haspopup":"listbox","aria-expanded":f,"aria-labelledby":"feishu-region-label feishu-region-value",onClick:()=>{I.current=Kc.findIndex(q=>q.value===u),h(q=>!q)},onKeyDown:q=>{q.key!=="ArrowDown"&&q.key!=="ArrowUp"||(q.preventDefault(),I.current=q.key==="ArrowUp"?Kc.length-1:Kc.findIndex(X=>X.value===u),h(!0))},children:[o.jsx("span",{id:"feishu-region-value",children:be.label}),o.jsx(KCt,{})]}),f?o.jsx("div",{className:"feishu-region-menu",role:"listbox","aria-label":"部署地域",onKeyDown:q=>{var de;const X=L.current.findIndex(xe=>xe===document.activeElement);let K=null;q.key==="ArrowDown"?K=(X+1)%Kc.length:q.key==="ArrowUp"?K=(X-1+Kc.length)%Kc.length:q.key==="Home"?K=0:q.key==="End"?K=Kc.length-1:q.key==="Tab"&&h(!1),K!==null&&(q.preventDefault(),(de=L.current[K])==null||de.focus())},children:Kc.map(q=>o.jsx("button",{ref:X=>{const K=Kc.findIndex(de=>de.value===q.value);L.current[K]=X},type:"button",role:"option","aria-selected":u===q.value,className:`feishu-region-option${u===q.value?" is-selected":""}`,onClick:()=>{var X;d(q.value),h(!1),(X=j.current)==null||X.focus()},children:q.label},q.value))}):null]}),o.jsx("span",{className:"feishu-field-help",children:"Runtime 与构建产物将创建在该地域"})]}),o.jsxs("div",{className:"feishu-field",children:[o.jsx("label",{htmlFor:"feishu-app-id",children:"飞书 App ID"}),o.jsx("input",{id:"feishu-app-id",value:r,maxLength:128,autoComplete:"off",disabled:$,placeholder:"cli_xxxxxxxxxxxxxxxx",onChange:q=>{i(q.target.value),b&&y("")},onBlur:()=>y(r.trim()?"":"请输入飞书 App ID"),"aria-invalid":!!b,"aria-describedby":`feishu-app-id-help${b?" feishu-app-id-error":""}`}),o.jsx("span",{id:"feishu-app-id-help",className:"feishu-field-help",children:"来自飞书开放平台的应用凭证"}),b?o.jsx("span",{id:"feishu-app-id-error",className:"feishu-field-error",role:"alert",children:b}):null]}),o.jsxs("div",{className:"feishu-field",children:[o.jsx("label",{htmlFor:"feishu-app-secret",children:"飞书 App Secret"}),o.jsxs("div",{className:"feishu-secret-input",children:[o.jsx("input",{id:"feishu-app-secret",type:l?"text":"password",value:s,maxLength:256,autoComplete:"off",disabled:$,placeholder:"请输入 App Secret",onChange:q=>{a(q.target.value),O&&v("")},onBlur:()=>v(s.trim()?"":"请输入飞书 App Secret"),"aria-invalid":!!O,"aria-describedby":`feishu-app-secret-help${O?" feishu-app-secret-error":""}`}),o.jsx("button",{type:"button",disabled:$,onClick:()=>c(q=>!q),"aria-label":l?"隐藏 App Secret":"显示 App Secret",children:l?"隐藏":"显示"})]}),o.jsx("span",{id:"feishu-app-secret-help",className:"feishu-field-help",children:"仅写入新 Runtime 的环境变量"}),O?o.jsx("span",{id:"feishu-app-secret-error",className:"feishu-field-error",role:"alert",children:O}):null]})]}),x!=="idle"?o.jsxs("div",{className:`feishu-deployment-status is-${x}`,role:x==="failed"?"alert":"status",children:[o.jsxs("div",{className:"feishu-deployment-heading",children:[x==="preparing"?o.jsx(En,{as:"strong",children:"正在生成 basic 智能体"}):null,x==="running"?o.jsx(En,{as:"strong",children:(S==null?void 0:S.message)||"正在创建 Runtime"}):null,x==="cancelling"?o.jsx(En,{as:"strong",children:"正在取消部署"}):null,x==="succeeded"?o.jsxs("strong",{children:[o.jsx(KJ,{}),"飞书机器人 Runtime 已创建"]}):null,x==="cancelled"?o.jsx("strong",{children:"部署已取消"}):null,x==="failed"?o.jsx("strong",{children:"创建失败"}):null]}),x==="preparing"||x==="running"||x==="cancelling"?o.jsx("ol",{className:"feishu-deployment-steps",children:owe.map((q,X)=>{const K=x==="running"&&Xq.value===(C.region||u)))==null?void 0:ie.label)||C.region}),C.consoleUrl?o.jsxs("a",{href:C.consoleUrl,target:"_blank",rel:"noreferrer",children:["打开 Runtime 控制台",o.jsx(JCt,{})]}):null]}):null]}):null,o.jsxs("div",{className:"feishu-form-actions",children:[o.jsxs("div",{className:"feishu-secrets-note",children:[o.jsx("strong",{children:"凭据处理"}),o.jsx("span",{children:"App Secret 仅用于本次部署,不会写入生成源码或浏览器存储。"})]}),o.jsxs("div",{className:"feishu-action-buttons",children:[x==="running"?o.jsx("button",{type:"button",className:"feishu-cancel",onClick:()=>void V(),children:"取消部署"}):null,o.jsx("button",{type:"submit",className:"feishu-submit",disabled:!ce,children:$?"正在创建…":"创建飞书机器人 Runtime"})]})]})]})]})})]})}async function SU(e,t,n,r=_o){var s;const i=await In(e,{...t,headers:{accept:"application/json",...t.headers},signal:n},r);if(!i.ok){let a="";try{a=((s=(await i.json()).detail)==null?void 0:s.trim())||""}catch{}throw new Error(a||`请求失败 (${i.status})`)}return i.json()}function nAt(e){return SU("/web/coding-agents/capabilities",{method:"GET"},e,i9)}function rAt(e,t){return SU(`/web/coding-agents/skills/${encodeURIComponent(e)}/preview`,{method:"GET"},t)}function iAt(e,t){return SU("/web/coding-agents/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},t)}const sAt="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='16'%20height='16'%20rx='3.692'%20fill='%231A1B1D'/%3e%3cpath%20d='M13.235%205.829V4.332H2.758v5.987h1.496v1.496h8.981V5.828Zm-1.497%204.49H4.254V5.83h7.484v4.49Z'%20fill='%2332F08C'/%3e%3cpath%20d='M6.937%206.993%205.88%208.051%206.937%209.11%207.995%208.05%206.937%206.993ZM9.931%206.992%208.873%208.05%209.931%209.11%2010.99%208.05%209.93%206.992Z'%20fill='%2332F08C'/%3e%3c/svg%3e";function aAt(){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:o.jsx("path",{d:"m4 4 8 8m0-8-8 8",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function JJ(){return o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[o.jsx("path",{d:"M4 1.8h5l3 3V14H4z",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),o.jsx("path",{d:"M9 1.8V5h3M6 8h4M6 10.5h4",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]})}function eee(){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:o.jsx("path",{d:"M1.8 4.5h4l1.2-1.3h2.2l1.2 1.3h3.8v8H1.8z",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function oAt(e){return e instanceof DOMException&&e.name==="AbortError"}function lAt(e){return e instanceof Error&&e.message?e.message:"读取 Skill 文件失败"}function cAt(e){return e<1024?`${e} B`:`${(e/1024).toFixed(e<10*1024?1:0)} KB`}function uAt(e){const t=e.split("/");return t[t.length-1]??e}function dAt(e){const t=new Map;for(const n of e){const r=n.path.split("/"),i=r.length>1?r.slice(0,-1).join("/"):"";t.set(i,[...t.get(i)??[],n])}return Array.from(t,([n,r])=>({directory:n,files:r})).sort((n,r)=>n.directory?r.directory?n.directory.localeCompare(r.directory):1:-1)}function fAt({skill:e,onClose:t}){const n=p.useRef(null),r=p.useRef(null),i=p.useId(),s=p.useId(),[a,l]=p.useState(null),[c,u]=p.useState(""),[d,f]=p.useState(!0),[h,m]=p.useState(""),[g,b]=p.useState(0);p.useEffect(()=>{r.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const v=n.current;return v&&!v.open&&v.showModal(),()=>{var x;v!=null&&v.open&&v.close(),(x=r.current)==null||x.focus()}},[]),p.useEffect(()=>{const v=new AbortController;return f(!0),m(""),l(null),u(""),rAt(e.id,v.signal).then(x=>{if(v.signal.aborted)return;l(x);const w=x.files.find(S=>S.path==="SKILL.md")??x.files[0];u((w==null?void 0:w.path)??"")}).catch(x=>{!v.signal.aborted&&!oAt(x)&&m(lAt(x))}).finally(()=>{v.signal.aborted||f(!1)}),()=>v.abort()},[g,e.id]);const y=p.useMemo(()=>dAt((a==null?void 0:a.files)??[]),[a]),O=(a==null?void 0:a.files.find(v=>v.path===c))??null;return o.jsxs("dialog",{ref:n,className:"coding-agents-preview-dialog","aria-labelledby":i,"aria-describedby":s,onCancel:v=>{v.preventDefault(),t()},onMouseDown:v=>{const x=v.currentTarget.getBoundingClientRect();(v.clientXx.right||v.clientYx.bottom)&&t()},children:[o.jsxs("header",{className:"coding-agents-preview-header",children:[o.jsx("span",{className:"coding-agents-preview-mark",children:o.jsx(eee,{})}),o.jsxs("div",{children:[o.jsx("h2",{id:i,children:e.name}),o.jsx("p",{id:s,children:"只读浏览随 Studio 提供的 Skill 文件"})]}),o.jsx("button",{type:"button",autoFocus:!0,"aria-label":"关闭文件预览",onClick:t,children:o.jsx(aAt,{})})]}),d?o.jsxs("div",{className:"coding-agents-preview-state",children:[o.jsx("i",{}),"正在读取文件…"]}):h?o.jsxs("div",{className:"coding-agents-preview-state is-error",role:"alert",children:[o.jsx("span",{children:h}),o.jsx("button",{type:"button",onClick:()=>b(v=>v+1),children:"重试"})]}):o.jsxs("div",{className:"coding-agents-preview-layout",children:[o.jsxs("nav",{className:"coding-agents-preview-tree","aria-label":`${e.name} 文件`,children:[o.jsxs("div",{className:"coding-agents-preview-tree-title",children:[o.jsx("span",{children:"文件"}),o.jsx("small",{children:(a==null?void 0:a.files.length)??0})]}),o.jsx("div",{className:"coding-agents-preview-tree-scroll",children:y.map(v=>v.directory?o.jsxs("details",{open:!0,children:[o.jsxs("summary",{children:[o.jsx(eee,{}),o.jsx("span",{children:v.directory})]}),o.jsx("div",{children:v.files.map(x=>o.jsxs("button",{type:"button",className:c===x.path?"is-selected":"","aria-current":c===x.path?"true":void 0,onClick:()=>u(x.path),children:[o.jsx(JJ,{}),o.jsx("span",{children:uAt(x.path)})]},x.path))})]},v.directory):v.files.map(x=>o.jsxs("button",{type:"button",className:c===x.path?"is-selected":"","aria-current":c===x.path?"true":void 0,onClick:()=>u(x.path),children:[o.jsx(JJ,{}),o.jsx("span",{children:x.path})]},x.path)))})]}),o.jsx("section",{className:"coding-agents-preview-file","aria-label":"文件内容",children:O?o.jsxs(o.Fragment,{children:[o.jsxs("header",{children:[o.jsx("strong",{children:O.path}),o.jsx("span",{children:cAt(O.size)})]}),O.previewable&&O.content!==null?o.jsx("pre",{tabIndex:0,children:o.jsx("code",{children:O.content})}):o.jsx("div",{className:"coding-agents-preview-unavailable",children:"此文件不是可预览的 UTF-8 文本。"})]}):o.jsx("div",{className:"coding-agents-preview-unavailable",children:"没有可预览的文件。"})})]})]})}function hAt(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"m9.8 3.5-4.5 4.5 4.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function pAt(e){return o.jsxs("svg",{viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"3.5",y:"5",width:"16",height:"16",rx:"4.5",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("path",{d:"m8.5 11-2.4 2.4 2.4 2.4M11 16.5h3.8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("circle",{cx:"24.5",cy:"10.5",r:"2.5",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("circle",{cx:"24.5",cy:"24.5",r:"2.5",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("path",{d:"M19.5 10.5H22M18.2 19l4.3 3.7M24.5 13v9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function mAt(e){return o.jsx("svg",{viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",...e,children:o.jsxs("g",{stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",children:[o.jsx("path",{d:"M16 4.5v7M16 20.5v7"}),o.jsx("path",{d:"m9.3 6.3 3.5 6.1M19.2 19.6l3.5 6.1"}),o.jsx("path",{d:"m5.9 11.1 6.2 3.5M19.9 17.4l6.2 3.5"}),o.jsx("path",{d:"M4.7 16h7M20.3 16h7"}),o.jsx("path",{d:"m5.9 20.9 6.2-3.5M19.9 14.6l6.2-3.5"}),o.jsx("path",{d:"m9.3 25.7 3.5-6.1M19.2 12.4l3.5-6.1"})]})})}function gAt(e){return o.jsxs("svg",{viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M15.8 4.2c2.4 0 4.5 1.2 5.7 3.1 2.2-.3 4.5.8 5.6 2.9 1.1 2 .8 4.4-.5 6.1 1.2 1.8 1.3 4.3.1 6.2-1.2 2-3.4 3-5.6 2.6-1.3 1.8-3.5 2.9-5.8 2.7-2.2-.2-4.1-1.5-5.1-3.4-2.2.1-4.4-1-5.4-3.1-1-2-.6-4.4.8-6.1-1.1-1.9-1.1-4.3.2-6.1 1.3-1.9 3.6-2.7 5.7-2.2 1.1-1.7 2.6-2.7 4.3-2.7Z",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"}),o.jsx("path",{d:"m10.7 12.2 3.1 3.8-3.1 3.8M17.1 20h4.3",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}function tee(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"m3.4 8.2 3 3L12.8 5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function bAt(e){return o.jsxs("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M2.8 6.3h14.4v8.3a1.6 1.6 0 0 1-1.6 1.6H4.4a1.6 1.6 0 0 1-1.6-1.6V6.3Z",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"}),o.jsx("path",{d:"M2.8 6.3V5.1a1.4 1.4 0 0 1 1.4-1.4h3.4l1.5 1.6h6.5a1.6 1.6 0 0 1 1.6 1.6",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"})]})}function yAt({agentId:e}){return e==="trae"?o.jsx("img",{src:sAt,alt:"","aria-hidden":"true"}):e==="claude-code"?o.jsx(mAt,{}):o.jsx(gAt,{})}function nee(e){return e instanceof DOMException&&e.name==="AbortError"}function ree(e,t){return e instanceof Error&&e.message?e.message:t}function OAt({onBack:e}){var T;const[t,n]=p.useState(null),[r,i]=p.useState(!0),[s,a]=p.useState(""),[l,c]=p.useState(0),[u,d]=p.useState(new Set),[f,h]=p.useState(new Set),[m,g]=p.useState(null),[b,y]=p.useState(!1),[O,v]=p.useState(null),x=p.useRef(null);p.useEffect(()=>{const A=new AbortController;return i(!0),a(""),nAt(A.signal).then(j=>{if(A.signal.aborted)return;n(j);const L=j.agents.filter(I=>I.available);d(I=>{const M=L.filter(N=>I.has(N.id));return new Set((M.length?M:L.slice(0,1)).map(N=>N.id))}),h(I=>{const M=j.skills.filter(N=>I.has(N.id));return new Set((M.length?M:j.skills).map(N=>N.id))})}).catch(j=>{!nee(j)&&!A.signal.aborted&&(n(null),a(ree(j,"检测本机客户端失败")))}).finally(()=>{A.signal.aborted||i(!1)}),()=>A.abort()},[l]),p.useEffect(()=>()=>{var A;return(A=x.current)==null?void 0:A.abort()},[]);const w=p.useMemo(()=>(t==null?void 0:t.agents.filter(A=>A.available&&u.has(A.id)))||[],[t,u]),S=p.useMemo(()=>(t==null?void 0:t.skills.filter(A=>f.has(A.id)))||[],[t,f]),E=!!(!b&&w.length&&S.length),k=(A,j)=>{!j||b||(v(null),d(L=>{const I=new Set(L);return I.has(A)?I.delete(A):I.add(A),I}))},_=A=>{b||(v(null),h(j=>{const L=new Set(j);return L.has(A)?L.delete(A):L.add(A),L}))},C=async()=>{var j;if(!E)return;(j=x.current)==null||j.abort();const A=new AbortController;x.current=A,y(!0),v(null);try{const L=await iAt({agents:w.map(M=>M.id),skills:S.map(M=>M.id)},A.signal);if(A.signal.aborted)return;const I=L.installations;v({tone:"success",message:`已为 ${w.length} 个客户端配置 ${S.length} 个 Skill`,details:I.map(M=>`${M.agentName} · ${M.skill} → ${M.displayPath}`)})}catch(L){!nee(L)&&!A.signal.aborted&&v({tone:"error",message:ree(L,"配置失败,请检查用户目录权限后重试")})}finally{x.current===A&&(x.current=null),A.signal.aborted||y(!1)}};return o.jsxs("section",{className:"coding-agents-page",children:[o.jsxs("header",{className:"coding-agents-header",children:[o.jsx("button",{type:"button",className:"coding-agents-back",onClick:e,disabled:b,"aria-label":"返回自动化列表",children:o.jsx(hAt,{})}),o.jsx(pAt,{className:"coding-agents-logo"}),o.jsxs("div",{children:[o.jsx("h1",{children:"配置 Coding Agents"}),o.jsx("p",{children:"把随 Studio 提供的 AgentKit Skills 全局安装到本地编码客户端。"})]})]}),o.jsx("div",{className:"coding-agents-scroll",children:o.jsxs("div",{className:"coding-agents-content",children:[o.jsxs("section",{className:"coding-agents-section","aria-label":"选择 Coding Agent",children:[o.jsxs("div",{className:"coding-agents-section-heading",children:[o.jsxs("div",{children:[o.jsx("span",{children:"1"}),o.jsx("h2",{children:"本机客户端"})]}),o.jsx("button",{type:"button",onClick:()=>c(A=>A+1),disabled:r||b,children:"重新检测"})]}),r?o.jsxs("div",{className:"coding-agents-inline-state",children:[o.jsx("i",{}),"正在检测本机客户端…"]}):s?o.jsxs("div",{className:"coding-agents-error-row",role:"alert",children:[o.jsx("span",{children:s}),o.jsx("button",{type:"button",onClick:()=>c(A=>A+1),children:"重试"})]}):o.jsx("div",{className:"coding-agents-agent-grid",children:t==null?void 0:t.agents.map(A=>o.jsxs("button",{type:"button",className:`coding-agents-agent ${u.has(A.id)?"is-selected":""}`,"aria-pressed":u.has(A.id),disabled:!A.available||b,onClick:()=>k(A.id,A.available),title:A.available?A.name:A.reason,children:[o.jsx("span",{className:`coding-agents-agent-mark is-${A.id}`,children:o.jsx(yAt,{agentId:A.id})}),o.jsxs("span",{className:"coding-agents-agent-copy",children:[o.jsx("strong",{children:A.name}),o.jsx("small",{children:A.available?A.version||"已检测到客户端":A.reason})]}),o.jsx("span",{className:`coding-agents-status ${A.available?"is-ready":""}`,children:A.available?"可用":"未检测到"}),o.jsx("span",{className:"coding-agents-check",children:o.jsx(tee,{})})]},A.id))})]}),o.jsxs("section",{className:"coding-agents-section","aria-label":"选择内置 Skill",children:[o.jsx("div",{className:"coding-agents-section-heading",children:o.jsxs("div",{children:[o.jsx("span",{children:"2"}),o.jsx("h2",{children:"内置 Skills"})]})}),o.jsx("div",{className:"coding-agents-skill-list",children:t==null?void 0:t.skills.map(A=>o.jsxs("div",{className:`coding-agents-skill ${f.has(A.id)?"is-selected":""}`,children:[o.jsxs("label",{children:[o.jsx("input",{type:"checkbox",checked:f.has(A.id),onChange:()=>_(A.id),disabled:b}),o.jsx("span",{className:"coding-agents-skill-check","aria-hidden":"true",children:o.jsx(tee,{})}),o.jsxs("span",{children:[o.jsx("strong",{children:A.name}),o.jsx("small",{children:A.description})]})]}),o.jsx("button",{type:"button",onClick:()=>g(A),children:"查看文件"})]},A.id))}),o.jsxs("div",{className:"coding-agents-global","aria-label":"全局安装目录",children:[o.jsxs("div",{className:"coding-agents-global-heading",children:[o.jsx(bAt,{}),o.jsxs("div",{children:[o.jsx("strong",{children:"全局安装"}),o.jsx("span",{children:"配置后可在本机其他项目中使用"})]})]}),w.length?o.jsx("dl",{children:w.map(A=>o.jsxs("div",{children:[o.jsx("dt",{children:A.name}),o.jsx("dd",{children:A.globalSkillsPath})]},A.id))}):o.jsx("p",{children:"选择客户端后显示对应安装目录。"})]})]}),O?o.jsxs("div",{className:`coding-agents-result is-${O.tone}`,role:O.tone==="error"?"alert":"status",children:[o.jsx("strong",{children:O.message}),(T=O.details)!=null&&T.length?o.jsx("ul",{children:O.details.map(A=>o.jsx("li",{children:A},A))}):null]}):null,o.jsxs("div",{className:"coding-agents-actions",children:[o.jsx("span",{children:w.length?`已选择 ${w.length} 个客户端、${S.length} 个 Skill`:"请先选择客户端"}),o.jsx("button",{type:"button",onClick:()=>void C(),disabled:!E,children:b?"正在配置…":"配置"})]})]})}),m?o.jsx(fAt,{skill:m,onClose:()=>g(null)}):null]})}async function EU(e,t){const n=await e.json().catch(()=>null),r=typeof(n==null?void 0:n.detail)=="string"?n.detail:"";return new Error(r||`${t}(HTTP ${e.status})`)}async function xAt(e){const t=await In("/web/website-integrations",{cache:"no-store",signal:e});if(!t.ok)throw await EU(t,"加载网站集成失败");return(await t.json()).integrations??[]}async function vAt(e){const t=await In("/web/website-integrations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw await EU(t,"创建网站集成失败");return t.json()}async function wAt(e){const t=await In(`/web/website-integrations/${encodeURIComponent(e)}`,{method:"DELETE"});if(!t.ok)throw await EU(t,"删除网站集成失败")}function SAt(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"m9.8 3.5-4.5 4.5 4.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function iee(e){return o.jsxs("svg",{viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"3.5",y:"5",width:"20",height:"17",rx:"3.5",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("path",{d:"M4.5 10h18M8.5 7.5h.1M11.5 7.5h.1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),o.jsx("path",{d:"M17 18.5a5 5 0 0 1 5-5h1.5a5 5 0 0 1 5 5V23a5 5 0 0 1-5 5H22l-3.5 2.5v-3.3A5 5 0 0 1 17 23v-4.5Z",fill:"hsl(var(--background))",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),o.jsx("path",{d:"M21 19h4M21 22.5h3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function EAt(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}async function kAt(e){const t=[];let n="";for(let r=0;r<10;r+=1){const i=await H1({nextToken:n||void 0,pageSize:100,region:"all",scope:"all"});if(e.aborted)return[];if(t.push(...i.runtimes),n=i.nextToken,!n)break}return t}function _At({onBack:e}){const[t,n]=p.useState([]),[r,i]=p.useState([]),[s,a]=p.useState(""),[l,c]=p.useState(""),[u,d]=p.useState(""),[f,h]=p.useState(!0),[m,g]=p.useState(!1),[b,y]=p.useState(""),[O,v]=p.useState("");p.useEffect(()=>{const C=new AbortController;return h(!0),v(""),Promise.all([xAt(C.signal),kAt(C.signal)]).then(([T,A])=>{var L;if(C.signal.aborted)return;n(T),i(A),c(((L=T[0])==null?void 0:L.id)??"");const j=A[0];j&&a(`${j.region}::${j.runtimeId}`)}).catch(T=>{C.signal.aborted||v(T instanceof Error?T.message:"加载网站集成失败")}).finally(()=>{C.signal.aborted||h(!1)}),()=>C.abort()},[]);const x=p.useMemo(()=>r.map(C=>({value:`${C.region}::${C.runtimeId}`,label:C.name||C.runtimeId,description:`${C.region} · ${C.status}`,runtime:C})),[r]),w=p.useMemo(()=>new Map(x.map(C=>[C.value,C.runtime])),[x]),S=t.find(C=>C.id===l)??t[0],E=S?` +