agentengine-sdk-python 0.8.1__py3-none-any.whl → 0.8.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {agentengine_sdk_python-0.8.1.dist-info → agentengine_sdk_python-0.8.2.dist-info}/METADATA +22 -2
- {agentengine_sdk_python-0.8.1.dist-info → agentengine_sdk_python-0.8.2.dist-info}/RECORD +356 -222
- ksadk/a2a/_space_client_events.py +381 -0
- ksadk/a2a/event_adapter.py +156 -64
- ksadk/a2a/executor.py +179 -63
- ksadk/a2a/space_client.py +6 -333
- ksadk/a2ui/core.py +222 -53
- ksadk/agui/_agent_helpers.py +243 -0
- ksadk/agui/a2ui_projection.py +12 -5
- ksadk/agui/agent.py +443 -259
- ksadk/api/client.py +525 -27
- ksadk/builders/code_builder.py +284 -8
- ksadk/builders/container_builder.py +8 -1
- ksadk/builders/managed_runtime_builder.py +39 -35
- ksadk/cli/__init__.py +17 -0
- ksadk/cli/cmd_dashboard.py +15 -1
- ksadk/cli/cmd_deploy.py +10 -2
- ksadk/cli/cmd_eval.py +66 -9
- ksadk/cli/cmd_evalset.py +284 -0
- ksadk/cli/cmd_files.py +5 -1
- ksadk/cli/cmd_hermes.py +1 -126
- ksadk/cli/cmd_invoke.py +28 -38
- ksadk/cli/cmd_managed_runtime.py +95 -0
- ksadk/cli/cmd_observe.py +85 -0
- ksadk/cli/cmd_openclaw.py +1 -435
- ksadk/cli/cmd_replay.py +28 -4
- ksadk/cli/cmd_studio.py +99 -8
- ksadk/cli/cmd_web.py +10 -2
- ksadk/cli/hermes_env.py +151 -0
- ksadk/cli/invoke_payload.py +49 -0
- ksadk/cli/openclaw_env.py +458 -0
- ksadk/codex/client.py +180 -30
- ksadk/codex/runtime.py +428 -326
- ksadk/configs/env_registry.py +66 -12
- ksadk/configs/env_registry_pcm.py +181 -0
- ksadk/configs/env_var_spec.py +18 -0
- ksadk/configs/global_config.py +5 -0
- ksadk/context_engine/__init__.py +98 -0
- ksadk/context_engine/assembler.py +176 -0
- ksadk/context_engine/baseline.py +419 -0
- ksadk/context_engine/cache_observability.py +228 -0
- ksadk/context_engine/capabilities.py +443 -0
- ksadk/context_engine/contributors.py +344 -0
- ksadk/context_engine/hosted_pipeline.py +417 -0
- ksadk/context_engine/models.py +117 -0
- ksadk/context_engine/planner.py +698 -0
- ksadk/context_engine/policies.py +319 -0
- ksadk/context_engine/projection.py +31 -0
- ksadk/context_engine/shadow_plan.py +266 -0
- ksadk/context_engine/tokenizer.py +164 -0
- ksadk/conversations/context.py +126 -6
- ksadk/conversations/message_projection.py +292 -28
- ksadk/conversations/model_context.py +49 -3
- ksadk/conversations/runtime_compaction.py +207 -5
- ksadk/conversations/runtime_input.py +184 -2
- ksadk/conversations/runtime_invocation.py +81 -3
- ksadk/conversations/runtime_observability.py +141 -0
- ksadk/conversations/runtime_payloads.py +42 -0
- ksadk/conversations/runtime_preparation.py +272 -2
- ksadk/conversations/runtime_resume.py +20 -1
- ksadk/conversations/runtime_stream_events.py +94 -9
- ksadk/conversations/semantic_summary.py +311 -1
- ksadk/conversations/session_lock.py +51 -0
- ksadk/deployment/env_forward.py +72 -0
- ksadk/deployment/managed_runtime.py +5 -0
- ksadk/deployment/providers/serverless.py +143 -69
- ksadk/evaluation/__init__.py +32 -0
- ksadk/evaluation/a2a_adapter.py +9 -1
- ksadk/evaluation/adapters.py +18 -5
- ksadk/evaluation/agent_eval_client.py +395 -0
- ksadk/evaluation/cloud_binding.py +80 -0
- ksadk/evaluation/cloud_converter.py +194 -0
- ksadk/evaluation/cloud_service.py +199 -0
- ksadk/evaluation/contracts.py +73 -4
- ksadk/evaluation/evaluators.py +183 -17
- ksadk/evaluation/evidence.py +258 -0
- ksadk/evaluation/executor.py +31 -6
- ksadk/evaluation/local_adapter.py +550 -0
- ksadk/evaluation/service_env.py +27 -0
- ksadk/evaluation/studio_build_adapter.py +253 -0
- ksadk/evaluation/target.py +15 -6
- ksadk/events/__init__.py +13 -13
- ksadk/events/_v1_compat/__init__.py +1 -0
- ksadk/events/_v1_compat/models.py +299 -0
- ksadk/events/_v1_compat/parser.py +247 -0
- ksadk/events/_v1_compat/projection.py +753 -0
- ksadk/events/adapters/__init__.py +34 -0
- ksadk/events/adapters/_a2a_snapshot.py +622 -0
- ksadk/events/adapters/_a2a_support.py +275 -0
- ksadk/events/adapters/_codex_interactions.py +375 -0
- ksadk/events/adapters/_codex_items.py +801 -0
- ksadk/events/adapters/_codex_validators.py +311 -0
- ksadk/events/adapters/_langgraph_support.py +785 -0
- ksadk/events/adapters/a2a.py +841 -0
- ksadk/events/adapters/adk.py +503 -0
- ksadk/events/adapters/codex.py +717 -0
- ksadk/events/adapters/langgraph.py +745 -0
- ksadk/events/canonical.py +440 -0
- ksadk/events/canonical_replay.py +497 -0
- ksadk/events/canonical_store.py +468 -0
- ksadk/events/cold_recovery.py +257 -0
- ksadk/events/content.py +89 -0
- ksadk/events/identity.py +86 -0
- ksadk/events/pipeline.py +455 -0
- ksadk/events/projections.py +66 -0
- ksadk/events/reducer.py +661 -0
- ksadk/events/replay.py +3 -36
- ksadk/events/runtime_event.py +20 -265
- ksadk/events/session_event.py +324 -0
- ksadk/events/store.py +3 -316
- ksadk/events/v1_compat.py +41 -0
- ksadk/harness/runtime.py +160 -57
- ksadk/identity/resolver.py +4 -3
- ksadk/interaction/__init__.py +28 -0
- ksadk/interaction/contracts.py +136 -0
- ksadk/interaction/ledger.py +189 -0
- ksadk/interaction/provider.py +122 -0
- ksadk/interaction/providers/__init__.py +52 -0
- ksadk/interaction/providers/adk.py +40 -0
- ksadk/interaction/providers/codex.py +94 -0
- ksadk/interaction/providers/langgraph.py +58 -0
- ksadk/kernel/__init__.py +117 -0
- ksadk/kernel/authorization.py +258 -0
- ksadk/kernel/bootstrap.py +1074 -0
- ksadk/kernel/contract_fingerprints.py +61 -0
- ksadk/kernel/contracts.py +362 -0
- ksadk/kernel/control.py +219 -0
- ksadk/kernel/errors.py +79 -0
- ksadk/kernel/ingress.py +1102 -0
- ksadk/kernel/mapping.py +111 -0
- ksadk/kernel/memory_store.py +1133 -0
- ksadk/kernel/postgres_store.py +1756 -0
- ksadk/kernel/recovery.py +452 -0
- ksadk/kernel/runtime_identity.py +103 -0
- ksadk/kernel/sql/001_agent_kernel.sql +120 -0
- ksadk/kernel/sqlite_store.py +1410 -0
- ksadk/kernel/state.py +145 -0
- ksadk/kernel/store.py +232 -0
- ksadk/kernel/worker.py +953 -0
- ksadk/knowledge_base/client.py +7 -0
- ksadk/knowledge_base/service.py +32 -5
- ksadk/memory/__init__.py +61 -0
- ksadk/memory/adk/backends/base_ltm_backend.py +96 -1
- ksadk/memory/adk/backends/http_ltm_backend.py +14 -5
- ksadk/memory/adk/backends/inmemory_ltm_backend.py +136 -3
- ksadk/memory/adk/backends/sdk_ltm_backend.py +384 -2
- ksadk/memory/adk/backends/sqlite_ltm_backend.py +95 -0
- ksadk/memory/coordinator.py +461 -0
- ksadk/memory/events.py +202 -0
- ksadk/memory/extraction.py +228 -0
- ksadk/memory/ltm_backend_factory.py +16 -3
- ksadk/memory/models.py +316 -0
- ksadk/memory/policy.py +215 -0
- ksadk/memory/provider.py +47 -0
- ksadk/memory/provider_adapter.py +159 -0
- ksadk/memory/provider_resolver.py +71 -0
- ksadk/memory/providers/__init__.py +5 -0
- ksadk/memory/providers/local_sqlite.py +490 -0
- ksadk/memory/resolved_policy.py +145 -0
- ksadk/memory/service.py +188 -6
- ksadk/model_proxy/bootstrap.py +16 -9
- ksadk/model_proxy/detect.py +202 -9
- ksadk/model_proxy/namespace.py +39 -15
- ksadk/model_proxy/server.py +24 -5
- ksadk/model_proxy/transform.py +60 -2
- ksadk/observability/__init__.py +25 -0
- ksadk/observability/session_log.py +420 -0
- ksadk/observability/trajectory.py +105 -0
- ksadk/prompts/__init__.py +71 -0
- ksadk/prompts/compiler.py +215 -0
- ksadk/prompts/models.py +82 -0
- ksadk/prompts/projection.py +89 -0
- ksadk/prompts/resolved.py +137 -0
- ksadk/prompts/sources.py +233 -0
- ksadk/runners/_langgraph_runner_streams.py +822 -0
- ksadk/runners/adk_runner.py +5 -5
- ksadk/runners/base_runner.py +16 -0
- ksadk/runners/factory.py +1 -2
- ksadk/runners/langgraph_runner.py +198 -437
- ksadk/runtime/_runner_adapter/__init__.py +1 -0
- ksadk/runtime/_runner_adapter/stream_mapping.py +788 -0
- ksadk/runtime/adapter.py +118 -2
- ksadk/runtime/conversation_execution.py +316 -182
- ksadk/runtime/executor.py +144 -3
- ksadk/runtime/factory.py +193 -7
- ksadk/runtime/hosted_finalizer.py +268 -0
- ksadk/runtime/launch.py +14 -1
- ksadk/runtime/preprocessing.py +25 -3
- ksadk/runtime/runner_adapter.py +288 -508
- ksadk/runtime/usage.py +33 -0
- ksadk/sandbox/backends/e2b.py +35 -2
- ksadk/server/composition.py +8 -0
- ksadk/server/factory.py +69 -6
- ksadk/server/routes/kernel_ingress.py +258 -0
- ksadk/server/routes/openai_compat.py +88 -8
- ksadk/server/routes/projection.py +35 -20
- ksadk/server/routes/run.py +94 -0
- ksadk/server/routes/sessions.py +2 -0
- ksadk/server/routes/streaming.py +5 -2
- ksadk/server/static/assets/{ArtifactsPanel-CakCqxEN.js → ArtifactsPanel-DSU1sWD_.js} +1 -1
- ksadk/server/static/assets/{CodeBlock-CynLknyO.js → CodeBlock-DOH6MVcn.js} +4 -4
- ksadk/server/static/assets/{MathMessageMarkdown-3sQdOysS.js → MathMessageMarkdown-BL8my1R2.js} +4 -4
- ksadk/server/static/assets/MathMessageMarkdown-BorAY7qD.css +1 -0
- ksadk/server/static/assets/MermaidBlock-Dz4IP-Tx.js +312 -0
- ksadk/server/static/assets/NativeTerminalPanel-DUrK0JpZ.js +1 -0
- ksadk/server/static/assets/abnfDiagram-VCTEODGH-g20pFzNV.js +1 -0
- ksadk/server/static/assets/arc-C4FzinUA.js +1 -0
- ksadk/server/static/assets/architecture-7GRP2DOG-DjKratdf.js +1 -0
- ksadk/server/static/assets/architectureDiagram-5GKGNRK7-DpIqL5h4.js +36 -0
- ksadk/server/static/assets/blockDiagram-NRAW4CY4-BjkljTNz.js +129 -0
- ksadk/server/static/assets/c4Diagram-UCG6FXSJ-Dk_ieq2X.js +38 -0
- ksadk/server/static/assets/channel-4cQHKtx1.js +1 -0
- ksadk/server/static/assets/chunk-2Q5K7J3B-DmgWkESh.js +1 -0
- ksadk/server/static/assets/{chunk-FMBD7UC4-B_fH2YuH.js → chunk-5VM5RSS4-BVHAchFb.js} +1 -1
- ksadk/server/static/assets/{chunk-ND2GUHAM-D6rFLaVV.js → chunk-F27PBJKO-C-ipQzuS.js} +1 -1
- ksadk/server/static/assets/chunk-G27WJ6UU-C2EyJbIK.js +231 -0
- ksadk/server/static/assets/{chunk-4BX2VUAB-B9drTgOW.js → chunk-JWPE2WC7-vYvVJb_M.js} +1 -1
- ksadk/server/static/assets/chunk-LCL6LL3I-BcI6ysPT.js +206 -0
- ksadk/server/static/assets/chunk-POPQ4Y6H-C030x_Z1.js +1 -0
- ksadk/server/static/assets/chunk-RHFEMEQ7-yyGpsz4n.js +168 -0
- ksadk/server/static/assets/chunk-SVP7TREG-BLTlmMU7.js +88 -0
- ksadk/server/static/assets/chunk-XXDRQBXY-C_32ArgP.js +1 -0
- ksadk/server/static/assets/classDiagram-DTDB5LWJ-DLFd9Xi0.js +1 -0
- ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-DLFd9Xi0.js +1 -0
- ksadk/server/static/assets/{cose-bilkent-S5V4N54A-ChNs_Mdk.js → cose-bilkent-JH36ORCC-9YQYwdl0.js} +1 -1
- ksadk/server/static/assets/cynefin-OW5HDTMX-DjEM48Qp.js +1 -0
- ksadk/server/static/assets/cynefinDiagram-5FMLGOSQ-ErLF5N13.js +62 -0
- ksadk/server/static/assets/cytoscape.esm-CyCl8rPi.js +321 -0
- ksadk/server/static/assets/dagre-3AP2YEHR-DFiQF-6f.js +4 -0
- ksadk/server/static/assets/dagre-BuhGnRI1.js +1 -0
- ksadk/server/static/assets/diagram-S7CK7UJ4-Bt1v8-GC.js +30 -0
- ksadk/server/static/assets/diagram-UQ7AKVKN-DSCxJdBK.js +41 -0
- ksadk/server/static/assets/diagram-VSXAHHWV-DHfYwp_9.js +3 -0
- ksadk/server/static/assets/diagram-VX7I27RA-DdzD-4Le.js +24 -0
- ksadk/server/static/assets/diagram-Z3DM3KII-Du-nAJ9F.js +24 -0
- ksadk/server/static/assets/{dist-Dli7qW-B.js → dist-8hqcx0sU.js} +1 -1
- ksadk/server/static/assets/dist-B7seoj3d.js +1 -0
- ksadk/server/static/assets/{dist-C1sz5Eo3.js → dist-BE7bu-DL.js} +1 -1
- ksadk/server/static/assets/{dist-fhOuWds5.js → dist-BVDffZ0U.js} +1 -1
- ksadk/server/static/assets/{dist-BjOdlDjj.js → dist-BX8z72IC.js} +1 -1
- ksadk/server/static/assets/{dist-DsHPdk3W.js → dist-Bf2M8m3N.js} +1 -1
- ksadk/server/static/assets/{dist-o2OVmKvt.js → dist-BjU6y-A2.js} +1 -1
- ksadk/server/static/assets/{dist-DWKByxWV.js → dist-BytlxIDT.js} +1 -1
- ksadk/server/static/assets/{dist-DJN_6Y39.js → dist-CSh_DE14.js} +1 -1
- ksadk/server/static/assets/{dist-DQU9EWw-.js → dist-CXYYBw3_.js} +1 -1
- ksadk/server/static/assets/{dist-4N2NMVYg.js → dist-C_wsv-Qd.js} +1 -1
- ksadk/server/static/assets/{dist-gLnrGsoU.js → dist-ClxGviKw.js} +1 -1
- ksadk/server/static/assets/{dist-j6Dxmf_j.js → dist-CttYUqzS.js} +1 -1
- ksadk/server/static/assets/{dist-D6MpCZtz.js → dist-DNp6rLRA.js} +1 -1
- ksadk/server/static/assets/{dist-BB3-OwTQ.js → dist-DUX-id_F.js} +1 -1
- ksadk/server/static/assets/{dist-_pHPTyZ-.js → dist-DmldrHd_.js} +1 -1
- ksadk/server/static/assets/{dist-CWV4lDr1.js → dist-DnfXs8Vn.js} +2 -2
- ksadk/server/static/assets/{dist-B5oS1zcj.js → dist-Dq9gLD7L.js} +1 -1
- ksadk/server/static/assets/{dist-B-jNR6Vn.js → dist-W-TIVntx.js} +1 -1
- ksadk/server/static/assets/{dist-BIlKoW0k.js → dist-dDdADKFA.js} +1 -1
- ksadk/server/static/assets/{dist-X4TnqwOK.js → dist-dydu68Fl.js} +1 -1
- ksadk/server/static/assets/{dist-CmZHzlwZ.js → dist-ngtN0DJB.js} +1 -1
- ksadk/server/static/assets/ebnfDiagram-PWID7BFC-Da9C9NO1.js +1 -0
- ksadk/server/static/assets/erDiagram-SSCWMZ5O-EAGqqR79.js +99 -0
- ksadk/server/static/assets/eventmodeling-NTZA5JFV-CMgMaJrC.js +1 -0
- ksadk/server/static/assets/flowDiagram-A5DVABFB-BBKL0x3P.js +1 -0
- ksadk/server/static/assets/ganttDiagram-EL5Y4UJY-DqJsKb59.js +292 -0
- ksadk/server/static/assets/gitGraph-4MIJSDKK-Dw63mrhw.js +1 -0
- ksadk/server/static/assets/gitGraphDiagram-WWUBYQGX-B6g4dtDi.js +106 -0
- ksadk/server/static/assets/index-8ipRcQ-M.js +240 -0
- ksadk/server/static/assets/index-ByFCqjlh.css +2 -0
- ksadk/server/static/assets/info-A6RAGUB7-B6iAblII.js +1 -0
- ksadk/server/static/assets/infoDiagram-RXCK75RN-Djm_nbd5.js +2 -0
- ksadk/server/static/assets/{ishikawaDiagram-YF4QCWOH-K0OOfVna.js → ishikawaDiagram-5VMMS53U-DWya9SG2.js} +6 -6
- ksadk/server/static/assets/{journeyDiagram-JHISSGLW-8LeOJaZp.js → journeyDiagram-EYS64GPL-DutxhSNI.js} +6 -6
- ksadk/server/static/assets/{kanban-definition-UN3LZRKU-C6uCgZrW.js → kanban-definition-3QL26DDD-DJdOF8Fm.js} +10 -10
- ksadk/server/static/assets/katex-vFWytM5c.js +257 -0
- ksadk/server/static/assets/{linear-hdBcYzM8.js → linear-BHjG8b-J.js} +1 -1
- ksadk/server/static/assets/mermaid-parser.core-KGSy4jWT.js +166 -0
- ksadk/server/static/assets/{mindmap-definition-RKZ34NQL-Bjy_2v4_.js → mindmap-definition-FBJOCRG2-9-HC88D4.js} +29 -29
- ksadk/server/static/assets/packet-AYTQ26CC-BOYAipuq.js +1 -0
- ksadk/server/static/assets/pegDiagram-XKGWAZYB-DrEZd4fD.js +1 -0
- ksadk/server/static/assets/pie-WAS4IAKB-Ctq0Kbku.js +1 -0
- ksadk/server/static/assets/pieDiagram-E7YTZNPT-DpjqOFFp.js +39 -0
- ksadk/server/static/assets/{quadrantDiagram-W4KKPZXB-BmkRbwCg.js → quadrantDiagram-AXDQQJYC-BiNhgOXX.js} +6 -6
- ksadk/server/static/assets/radar-RG4KPBEZ-DN0-ul_0.js +1 -0
- ksadk/server/static/assets/railroad-74A4TZTK-C6cC_to0.js +1 -0
- ksadk/server/static/assets/railroad-abnf-HS5TGJTU-BimjIuRc.js +1 -0
- ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-CvY65ABq.js +1 -0
- ksadk/server/static/assets/railroad-peg-WCYAUIDC-D72Iq_Tv.js +1 -0
- ksadk/server/static/assets/railroadDiagram-O6MQD6OU-_Y3Ojg6G.js +1 -0
- ksadk/server/static/assets/requirementDiagram-EFPCY7ZU-DeCFdg9K.js +84 -0
- ksadk/server/static/assets/{sankeyDiagram-5OEKKPKP-l6iXmU65.js → sankeyDiagram-P5KCCOFB-CPH75rhw.js} +7 -7
- ksadk/server/static/assets/{sequenceDiagram-3UESZ5HK-Cq6UBeQB.js → sequenceDiagram-WJ2MYXX4-OEpQQdr4.js} +10 -10
- ksadk/server/static/assets/sizeCapture-X5ZJPWSS-heUErzhI.js +1 -0
- ksadk/server/static/assets/stateDiagram-HBIQ2CUA-DvA3jSMB.js +1 -0
- ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-BgQY03nz.js +1 -0
- ksadk/server/static/assets/swimlanes-XN3QIQJK-CR-dfN_t.js +1 -0
- ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-DLVw3q5Q.js +8 -0
- ksadk/server/static/assets/{timeline-definition-PNZ67QCA-DEz24vV0.js → timeline-definition-24CTP7MA-DAVJf1TX.js} +7 -7
- ksadk/server/static/assets/treeView-Q6P3EWNA-BMpO0wsB.js +1 -0
- ksadk/server/static/assets/treemap-WGGIJYW6-Et0aqzU3.js +1 -0
- ksadk/server/static/assets/vennDiagram-4TSXK5OY-DwM8eDkh.js +34 -0
- ksadk/server/static/assets/wardley-WFR3VGLG-CbY0mhpl.js +1 -0
- ksadk/server/static/assets/wardleyDiagram-VM6X3IG4-DZL-Zz2t.js +78 -0
- ksadk/server/static/assets/xychartDiagram-S5SC5T6Z-Dy6Yh_hu.js +7 -0
- ksadk/server/static/index.html +2 -2
- ksadk/sessions/__init__.py +26 -9
- ksadk/sessions/_local_service_sync.py +688 -0
- ksadk/sessions/_local_tables.py +21 -0
- ksadk/sessions/_postgres_schema.py +305 -0
- ksadk/sessions/_postgres_tables.py +15 -0
- ksadk/sessions/base.py +80 -1
- ksadk/sessions/in_memory.py +53 -2
- ksadk/sessions/local_service.py +63 -604
- ksadk/sessions/postgres_service.py +58 -148
- ksadk/sessions/resilient.py +35 -1
- ksadk/studio/api.py +577 -25
- ksadk/studio/api_contracts.py +114 -5
- ksadk/studio/api_memory_routes.py +82 -0
- ksadk/studio/authoring.py +252 -27
- ksadk/studio/authoring_coordinator.py +799 -67
- ksadk/studio/builder.py +88 -11
- ksadk/studio/capabilities.py +17 -0
- ksadk/studio/cloud.py +1916 -95
- ksadk/studio/codex_agent_service.py +125 -14
- ksadk/studio/codex_authoring.py +469 -0
- ksadk/studio/codex_builder.py +138 -25
- ksadk/studio/codex_manifest.py +51 -22
- ksadk/studio/codex_run.py +46 -3
- ksadk/studio/compiler.py +1 -0
- ksadk/studio/contracts.py +114 -3
- ksadk/studio/event_store.py +25 -95
- ksadk/studio/framework_run.py +231 -3
- ksadk/studio/hosted_kernel.py +317 -0
- ksadk/studio/manifest_resolver.py +131 -0
- ksadk/studio/model_client.py +95 -9
- ksadk/studio/model_profile_service.py +1 -1
- ksadk/studio/operations.py +37 -5
- ksadk/studio/otel_trace.py +348 -42
- ksadk/studio/pcm_memory.py +85 -0
- ksadk/studio/repository.py +23 -2
- ksadk/studio/resource_catalog.py +43 -0
- ksadk/studio/run_service.py +563 -137
- ksadk/studio/runtime_source.py +42 -16
- ksadk/studio/service.py +1180 -72
- ksadk/studio/shared_web.py +32 -22
- ksadk/studio/static/assets/index-BLpcdrgW.css +1 -0
- ksadk/studio/static/assets/index-CYekR2Xv.js +260 -0
- ksadk/studio/static/index.html +2 -2
- ksadk/studio/templates.py +100 -8
- ksadk/studio/validator.py +19 -0
- ksadk/studio/workspace.py +30 -32
- ksadk/tracing/setup.py +304 -3
- ksadk/version.py +1 -1
- ksadk_runtime_common/schemas/runtime_event_v1.json +37 -0
- ksadk_runtime_common/schemas/runtime_event_v2.json +271 -0
- ksadk/events/parser.py +0 -191
- ksadk/server/static/assets/MathMessageMarkdown-DeYh8QPr.css +0 -1
- ksadk/server/static/assets/MermaidBlock-NERD_ef7.js +0 -303
- ksadk/server/static/assets/NativeTerminalPanel-CiHWf82q.js +0 -1
- ksadk/server/static/assets/arc-DrgjcKhl.js +0 -1
- ksadk/server/static/assets/architecture-7EHR7CIX-CpZLRCcY.js +0 -1
- ksadk/server/static/assets/architectureDiagram-3BPJPVTR-BXoVRbQ6.js +0 -36
- ksadk/server/static/assets/blockDiagram-GPEHLZMM-BnaB3Ywv.js +0 -132
- ksadk/server/static/assets/c4Diagram-AAUBKEIU-Dw4weZcp.js +0 -10
- ksadk/server/static/assets/channel-Dt3rQTFI.js +0 -1
- ksadk/server/static/assets/chunk-2J33WTMH-ChjpLK7j.js +0 -1
- ksadk/server/static/assets/chunk-55IACEB6-CK4ROATy.js +0 -1
- ksadk/server/static/assets/chunk-727SXJPM-B9KtTTgw.js +0 -206
- ksadk/server/static/assets/chunk-AQP2D5EJ-1O1mki3m.js +0 -231
- ksadk/server/static/assets/chunk-QZHKN3VN-iXEZtKQc.js +0 -1
- ksadk/server/static/assets/classDiagram-4FO5ZUOK-DIveV17Q.js +0 -1
- ksadk/server/static/assets/classDiagram-v2-Q7XG4LA2-DIveV17Q.js +0 -1
- ksadk/server/static/assets/cytoscape.esm-DelgaX4f.js +0 -321
- ksadk/server/static/assets/dagre-BM42HDAG-D0QXg_MQ.js +0 -4
- ksadk/server/static/assets/dagre-Bx709z4p.js +0 -1
- ksadk/server/static/assets/diagram-2AECGRRQ-DBDDKwBQ.js +0 -43
- ksadk/server/static/assets/diagram-5GNKFQAL-BkwDOxmO.js +0 -10
- ksadk/server/static/assets/diagram-KO2AKTUF-Bv8waYvY.js +0 -3
- ksadk/server/static/assets/diagram-LMA3HP47-e1VECDdu.js +0 -24
- ksadk/server/static/assets/diagram-OG6HWLK6-Ds9adfRl.js +0 -24
- ksadk/server/static/assets/dist-B5J2uhNk.js +0 -1
- ksadk/server/static/assets/erDiagram-TEJ5UH35-BPItFKH6.js +0 -85
- ksadk/server/static/assets/eventmodeling-FCH6USID-DYFSxbqr.js +0 -1
- ksadk/server/static/assets/flowDiagram-I6XJVG4X-BbYB9w5Y.js +0 -162
- ksadk/server/static/assets/ganttDiagram-6RSMTGT7-TQXa0KXv.js +0 -292
- ksadk/server/static/assets/gitGraph-WXDBUCRP-DyNYp6BN.js +0 -1
- ksadk/server/static/assets/gitGraphDiagram-PVQCEYII-bKblCnpa.js +0 -106
- ksadk/server/static/assets/graphlib-B8gBHxth.js +0 -1
- ksadk/server/static/assets/index-R52pJJvg.js +0 -177
- ksadk/server/static/assets/index-jJr3_955.css +0 -2
- ksadk/server/static/assets/info-J43DQDTF-WUx7qTde.js +0 -1
- ksadk/server/static/assets/infoDiagram-5YYISTIA-BGVT7J_i.js +0 -2
- ksadk/server/static/assets/katex-CYWseY5E.js +0 -265
- ksadk/server/static/assets/mermaid-parser.core-BWrDjSZM.js +0 -161
- ksadk/server/static/assets/packet-YPE3B663-BN13y_xl.js +0 -1
- ksadk/server/static/assets/pie-LRSECV5Y-ftSLXhhc.js +0 -1
- ksadk/server/static/assets/pieDiagram-4H26LBE5-GmmqNiVH.js +0 -30
- ksadk/server/static/assets/radar-GUYGQ44K-jaICkIeO.js +0 -1
- ksadk/server/static/assets/requirementDiagram-4Y6WPE33-DSWFqL7c.js +0 -84
- ksadk/server/static/assets/stateDiagram-AJRCARHV-qzTQpg3Y.js +0 -1
- ksadk/server/static/assets/stateDiagram-v2-BHNVJYJU-BYCoYGAN.js +0 -1
- ksadk/server/static/assets/treeView-BLDUP644-Cpib_vlz.js +0 -1
- ksadk/server/static/assets/treemap-LRROVOQU-DQxfmVHK.js +0 -1
- ksadk/server/static/assets/vennDiagram-CIIHVFJN-CMCixki2.js +0 -34
- ksadk/server/static/assets/wardley-L42UT6IY-BQYHnnkU.js +0 -1
- ksadk/server/static/assets/wardleyDiagram-YWT4CUSO-CVzB8F9K.js +0 -78
- ksadk/server/static/assets/xychartDiagram-2RQKCTM6-BFBqBLc1.js +0 -7
- ksadk/studio/evaluation.py +0 -192
- ksadk/studio/static/assets/index-CaEN0eTR.css +0 -1
- ksadk/studio/static/assets/index-DI2eY_NH.js +0 -252
- {agentengine_sdk_python-0.8.1.dist-info → agentengine_sdk_python-0.8.2.dist-info}/WHEEL +0 -0
- {agentengine_sdk_python-0.8.1.dist-info → agentengine_sdk_python-0.8.2.dist-info}/entry_points.txt +0 -0
- {agentengine_sdk_python-0.8.1.dist-info → agentengine_sdk_python-0.8.2.dist-info}/licenses/LICENSE +0 -0
- {agentengine_sdk_python-0.8.1.dist-info → agentengine_sdk_python-0.8.2.dist-info}/top_level.txt +0 -0
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PrismRenderer-IYN-ffww.js","assets/rolldown-runtime-hePW80VL.js","assets/react-vendor-BNmTiJ-I.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{i as r,n as i,r as a,t as o}from"./react-vendor-BNmTiJ-I.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var s=t(r(),1),c=i(),l=``,u=window.fetch.bind(window);function d(e){return e.startsWith(`/api/v1/`)||e===`/v1/responses`||e.startsWith(`/v1/responses/`)}async function f(e,t={}){let n=String(t.method||(e instanceof Request?e.method:`GET`)).toUpperCase(),r=new URL(e instanceof Request?e.url:String(e),window.location.href),i=new Headers(t.headers||(e instanceof Request?e.headers:void 0));l&&r.origin===window.location.origin&&d(r.pathname)&&![`GET`,`HEAD`,`OPTIONS`].includes(n)&&i.set(`X-CSRF-Token`,l);let a=e instanceof Request?e.clone():e,o={...t,headers:i,credentials:t.credentials||`same-origin`},s=await u(e,o);if(s.status!==403||[`GET`,`HEAD`,`OPTIONS`].includes(n)||r.origin!==window.location.origin||!d(r.pathname))return s;let c=``;try{c=(await s.clone().json())?.error?.code||``}catch{return s}if(c!==`CSRF_TOKEN_INVALID`)return s;let f=await u(`/api/v1/system/bootstrap`,{credentials:`same-origin`});return!f.ok||(l=(await f.json()).csrfToken||``,!l)?s:(i.set(`X-CSRF-Token`,l),u(a,{...o,headers:i}))}async function p(){let e=window.location.hash.match(/(?:^#|&)session=([^&]+)/);if(e){let t=await u(`/api/v1/system/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:decodeURIComponent(e[1])}),credentials:`same-origin`});if(!t.ok)throw Error(`本地 Studio 会话已失效,请重新启动服务。`);l=(await t.json()).csrfToken||``,window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}`);return}let t=await u(`/api/v1/system/bootstrap`,{credentials:`same-origin`});t.ok&&(l=(await t.json()).csrfToken||``)}var m=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),h=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),g=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),_=e=>{let t=g(e);return t.charAt(0).toUpperCase()+t.slice(1)},v={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},y=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},b=(0,s.createContext)({}),x=()=>(0,s.useContext)(b),S=(0,s.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...c},l)=>{let{size:u=24,strokeWidth:d=2,absoluteStrokeWidth:f=!1,color:p=`currentColor`,className:h=``}=x()??{},g=r??f?Number(n??d)*24/Number(t??u):n??d;return(0,s.createElement)(`svg`,{ref:l,...v,width:t??u??v.width,height:t??u??v.height,stroke:e??p,strokeWidth:g,className:m(`lucide`,h,i),...!a&&!y(c)&&{"aria-hidden":`true`},...c},[...o.map(([e,t])=>(0,s.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),C=(e,t)=>{let n=(0,s.forwardRef)(({className:n,...r},i)=>(0,s.createElement)(S,{ref:i,iconNode:t,className:m(`lucide-${h(_(e))}`,`lucide-${e}`,n),...r}));return n.displayName=_(e),n},w=C(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),T=C(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),E=C(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),D=C(`book-open`,[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]),O=C(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),k=C(`brain-circuit`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]),A=C(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),j=C(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),M=C(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),N=C(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),P=C(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),F=C(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),I=C(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),L=C(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),R=C(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),z=C(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),B=C(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),V=C(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),H=C(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),U=C(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),ee=C(`coins`,[[`path`,{d:`M13.744 17.736a6 6 0 1 1-7.48-7.48`,key:`bq4yh3`}],[`path`,{d:`M15 6h1v4`,key:`11y1tn`}],[`path`,{d:`m6.134 14.768.866-.5 2 3.464`,key:`17snzx`}],[`circle`,{cx:`16`,cy:`8`,r:`6`,key:`14bfc9`}]]),te=C(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),ne=C(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),re=C(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),ie=C(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),ae=C(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),oe=C(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),se=C(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),ce=C(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),le=C(`folder-closed`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M2 10h20`,key:`1ir3d8`}]]),ue=C(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),de=C(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),fe=C(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),pe=C(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),me=C(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),he=C(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),ge=C(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),_e=C(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),ve=C(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),ye=C(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),be=C(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),xe=C(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),Se=C(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),Ce=C(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),we=C(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),Te=C(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),Ee=C(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),De=C(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),Oe=C(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),ke=C(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Ae=C(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),je=C(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Me=C(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Ne=C(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),Pe=C(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Fe=C(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Ie=C(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Le=C(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Re=C(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ze=C(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Be=C(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Ve=C(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),He=C(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),Ue=C(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),We=C(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Ge=C(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Ke=C(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),qe=C(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Je=C(`text-wrap`,[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]]),Ye=C(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Xe=C(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),Ze=C(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),Qe=C(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),$e=C(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),et=C(`zap`,[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]),W=o(),tt={bot:O,sparkles:He,search:Ie,code:H,workflow:Te};function nt({name:e,appearance:t,template:n,size:r=`md`,className:i=``}){let a=tt[t?.icon||(n===`research`?`search`:`bot`)],o={"--agent-avatar-color":t?.color||(n===`research`?`#2d7c68`:`#426ea8`)};return(0,W.jsx)(`span`,{className:`agent-avatar agent-avatar-${r}${i?` ${i}`:``}`,style:o,role:`img`,"aria-label":`${e}头像`,children:t?.imageUrl?(0,W.jsx)(`img`,{src:t.imageUrl,alt:``,draggable:!1}):(0,W.jsx)(a,{"aria-hidden":!0,size:r===`lg`?22:r===`xs`?12:16})})}var rt=Object.defineProperty,it=(e,t)=>rt(e,`name`,{value:t,configurable:!0}),at=!!(typeof window<`u`&&window.document&&window.document.createElement);function G(e,t,{checkForDefaultPrevented:n=!0}={}){return it(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}it(G,`composeEventHandlers`);function ot(e){if(!at)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}it(ot,`getOwnerWindow`);function st(e){if(!at)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}it(st,`getOwnerDocument`);function ct(e,t=!1){let{activeElement:n}=st(e);if(!n?.nodeName)return null;if(lt(n)&&n.contentDocument)return ct(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=st(n).getElementById(e);if(t)return t}}return n}it(ct,`getActiveElement`);function lt(e){return e.tagName===`IFRAME`}it(lt,`isFrame`);var ut=Object.defineProperty,dt=(e,t)=>ut(e,`name`,{value:t,configurable:!0});function ft(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}dt(ft,`setRef`);function pt(...e){return t=>{let n=!1,r=e.map(e=>{let r=ft(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():ft(e[t],null)}}}}dt(pt,`composeRefs`);function mt(...e){return s.useCallback(pt(...e),e)}dt(mt,`useComposedRefs`);var ht=Object.defineProperty,gt=(e,t)=>ht(e,`name`,{value:t,configurable:!0});function _t(e,t){let n=s.createContext(t);n.displayName=e+`Context`;let r=gt(e=>{let{children:t,...r}=e,i=s.useMemo(()=>r,Object.values(r));return(0,W.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=s.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return gt(i,`useContext`),[r,i]}gt(_t,`createContext`);function vt(e,t=[]){let n=[];function r(t,r){let i=s.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=gt(t=>{let{scope:n,children:r,...o}=t,c=n?.[e]?.[a]||i,l=s.useMemo(()=>o,Object.values(o));return(0,W.jsx)(c.Provider,{value:l,children:r})},`Provider`);o.displayName=t+`Provider`;function c(n,o,c={}){let{optional:l=!1}=c,u=o?.[e]?.[a]||i,d=s.useContext(u);if(d)return d;if(r!==void 0)return r;if(!l)throw Error(`\`${n}\` must be used within \`${t}\``)}return gt(c,`useContext`),[o,c]}gt(r,`createContext`);let i=gt(()=>{let t=n.map(e=>s.createContext(e));return gt(function(n){let r=n?.[e]||t;return s.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,yt(i,...t)]}gt(vt,`createContextScope`);function yt(...e){let t=e[0];if(e.length===1)return t;let n=gt(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return gt(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return s.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}gt(yt,`composeContextScopes`);var bt=globalThis?.document?s.useLayoutEffect:()=>{},xt=Object.defineProperty,St=(e,t)=>xt(e,`name`,{value:t,configurable:!0}),Ct=s.useId||(()=>void 0),wt=0;function Tt(e){let[t,n]=s.useState(Ct());return bt(()=>{e||n(e=>e??String(wt++))},[e]),e||(t?`radix-${t}`:``)}St(Tt,`useId`);var Et=Object.defineProperty,Dt=(e,t)=>Et(e,`name`,{value:t,configurable:!0}),Ot=s.useEffectEvent,kt=s.useInsertionEffect;function At(e){if(typeof Ot==`function`)return Ot(e);let t=s.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof kt==`function`?kt(()=>{t.current=e}):bt(()=>{t.current=e}),s.useMemo(()=>((...e)=>t.current?.(...e)),[])}Dt(At,`useEffectEvent`);var jt=Object.defineProperty,Mt=(e,t)=>jt(e,`name`,{value:t,configurable:!0}),Nt=s.useInsertionEffect||bt;function Pt({prop:e,defaultProp:t,onChange:n=Mt(()=>{},`onChange`),caller:r}){let[i,a,o]=Ft({defaultProp:t,onChange:n}),c=e!==void 0;return[c?e:i,s.useCallback(t=>{if(c){let n=It(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[c,e,a,o])]}Mt(Pt,`useControllableState`);function Ft({defaultProp:e,onChange:t}){let[n,r]=s.useState(e),i=s.useRef(n),a=s.useRef(t);return Nt(()=>{a.current=t},[t]),s.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}Mt(Ft,`useUncontrolledState`);function It(e){return typeof e==`function`}Mt(It,`isFunction`);var Lt=Symbol(`RADIX:SYNC_STATE`);function Rt(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:c}=t,l=i!==void 0,u=At(o),d=[{...n,state:a}];r&&d.push(r);let[f,p]=s.useReducer((t,n)=>{if(n.type===Lt)return{...t,state:n.state};let r=e(t,n);return l&&!Object.is(r.state,t.state)&&u(r.state),r},...d),m=f.state,h=s.useRef(m);s.useEffect(()=>{h.current!==m&&(h.current=m,l||u(m))},[m,h,l]);let g=s.useMemo(()=>i===void 0?f:{...f,state:i},[f,i]);return s.useEffect(()=>{l&&!Object.is(i,f.state)&&p({type:Lt,state:i})},[i,f.state,l]),[g,p]}Mt(Rt,`useControllableStateReducer`);var zt=t(a(),1),Bt=Object.defineProperty,Vt=(e,t)=>Bt(e,`name`,{value:t,configurable:!0});function Ht(e){let t=s.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,c=[];Xt(r)&&typeof en==`function`&&(r=en(r._payload)),s.Children.forEach(r,e=>{if(Jt(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;Xt(n)&&typeof en==`function`&&(n=en(n._payload)),a=Gt(t,n),c.push(a?.props?.children)}else c.push(e)}),a?a=s.cloneElement(a,void 0,c):!o&&s.Children.count(r)===1&&s.isValidElement(r)&&(a=r);let l=a?qt(a):void 0,u=mt(n,l);if(!a){if(r||r===0)throw Error(o?$t(e):Qt(e));return r}let d=Kt(i,a.props??{});return a.type!==s.Fragment&&(d.ref=n?u:l),s.cloneElement(a,d)});return t.displayName=`${e}.Slot`,t}Vt(Ht,`createSlot`);var Ut=Symbol.for(`radix.slottable`);function Wt(e){let t=Vt(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=Ut,t}Vt(Wt,`createSlottable`);var Gt=Vt((e,t)=>{if(`child`in e.props){let t=e.props.child;return s.isValidElement(t)?s.cloneElement(t,void 0,e.props.children(t.props.children)):null}return s.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function Kt(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}Vt(Kt,`mergeProps`);function qt(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Vt(qt,`getElementRef`);function Jt(e){return s.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Ut}Vt(Jt,`isSlottable`);var Yt=Symbol.for(`react.lazy`);function Xt(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Yt&&`_payload`in e&&Zt(e._payload)}Vt(Xt,`isLazyComponent`);function Zt(e){return typeof e==`object`&&!!e&&`then`in e}Vt(Zt,`isPromiseLike`);var Qt=Vt(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),$t=Vt(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),en=s.use,tn=Object.defineProperty,nn=(e,t)=>tn(e,`name`,{value:t,configurable:!0}),rn=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Ht(`Primitive.${t}`),r=s.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,W.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function an(e,t){e&&zt.flushSync(()=>e.dispatchEvent(t))}nn(an,`dispatchDiscreteCustomEvent`);var on=Object.defineProperty,sn=(e,t)=>on(e,`name`,{value:t,configurable:!0});function cn(e){let t=s.useRef(e);return s.useEffect(()=>{t.current=e}),s.useMemo(()=>((...e)=>t.current?.(...e)),[])}sn(cn,`useCallbackRef`);var ln=Object.defineProperty,un=(e,t)=>ln(e,`name`,{value:t,configurable:!0}),dn=`dismissableLayer.update`,fn=`dismissableLayer.pointerDownOutside`,pn=`dismissableLayer.focusOutside`,mn,hn=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),gn=s.forwardRef(un(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:c,onDismiss:l,...u}=e,d=s.useContext(hn),[f,p]=s.useState(null),m=f?.ownerDocument??globalThis?.document,[,h]=s.useState({}),g=mt(t,p),_=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=v?_.indexOf(v):-1,b=f?_.indexOf(f):-1,x=d.layersWithOutsidePointerEventsDisabled.size>0,S=b>=y,C=s.useRef(!1),w=yn(e=>{a?.(e),c?.(e),e.defaultPrevented||l?.()},{ownerDocument:m,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:C,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:s.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...d.branches].some(t=>t.contains(e));return S&&!t},[d.branches,S])}),T=bn(e=>{if(r&&C.current)return;let t=e.target;[...d.branches].some(e=>e.contains(t))||(o?.(e),c?.(e),e.defaultPrevented||l?.())},m),E=f?b===_.length-1:!1,D=cn(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))});return s.useEffect(()=>{if(E)return m.addEventListener(`keydown`,D,{capture:!0}),()=>m.removeEventListener(`keydown`,D,{capture:!0})},[m,E,D]),s.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(mn=m.body.style.pointerEvents,m.body.style.pointerEvents=`none`),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),xn(),()=>{n&&(d.layersWithOutsidePointerEventsDisabled.delete(f),d.layersWithOutsidePointerEventsDisabled.size===0&&(m.body.style.pointerEvents=mn))}},[f,m,n,d]),s.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),xn())},[f,d]),s.useEffect(()=>{let e=un(()=>h({}),`handleUpdate`);return document.addEventListener(dn,e),()=>document.removeEventListener(dn,e)},[]),(0,W.jsx)(rn.div,{...u,ref:g,style:{pointerEvents:x?S?`auto`:`none`:void 0,...e.style},onFocusCapture:G(e.onFocusCapture,T.onFocusCapture),onBlurCapture:G(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:G(e.onPointerDownCapture,w.onPointerDownCapture)})},`DismissableLayer`));function _n(){let e=s.useContext(hn),[t,n]=s.useState(null);return s.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}un(_n,`useDismissableLayerSurface`);var vn=un(()=>!0,`IS_TRUE`);function yn(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=vn}=t,c=cn(e),l=s.useRef(!1),u=s.useRef(!1),d=s.useRef(new Map),f=s.useRef(()=>{});return s.useEffect(()=>{function e(){u.current=!1,i.current=!1,d.current.clear()}un(e,`resetOutsideInteraction`);function t(){return Array.from(d.current.values()).some(Boolean)}un(t,`isOutsideInteractionIntercepted`);function s(e){if(!u.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||d.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{u.current&&f.current()},0)}un(s,`handleInteractionCapture`);function p(e){u.current&&d.current.set(e.type,!1)}un(p,`handleInteractionBubble`);let m=un(a=>{if(a.target&&!l.current){let s=function(){n.removeEventListener(`click`,f.current);let r=t();e(),r||Sn(fn,c,p,{discrete:!0})};if(un(s,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,f.current),e(),l.current=!1;return}let p={originalEvent:a};u.current=!0,i.current=r&&a.button===0,d.current.clear(),!r||a.button!==0?s():(n.removeEventListener(`click`,f.current),f.current=s,n.addEventListener(`click`,f.current,{once:!0}))}else n.removeEventListener(`click`,f.current),e();l.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,s,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,f.current);for(let e of h)n.removeEventListener(e,s,!0),n.removeEventListener(e,p)}},[n,c,r,i,a,o]),{onPointerDownCapture:un(()=>l.current=!0,`onPointerDownCapture`)}}un(yn,`usePointerDownOutside`);function bn(e,t=globalThis?.document){let n=cn(e),r=s.useRef(!1);return s.useEffect(()=>{let e=un(e=>{e.target&&!r.current&&Sn(pn,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:un(()=>r.current=!0,`onFocusCapture`),onBlurCapture:un(()=>r.current=!1,`onBlurCapture`)}}un(bn,`useFocusOutside`);function xn(){let e=new CustomEvent(dn);document.dispatchEvent(e)}un(xn,`dispatchUpdate`);function Sn(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?an(i,a):i.dispatchEvent(a)}un(Sn,`handleAndDispatchCustomEvent`);var Cn=Object.defineProperty,wn=(e,t)=>Cn(e,`name`,{value:t,configurable:!0}),Tn=`focusScope.autoFocusOnMount`,En=`focusScope.autoFocusOnUnmount`,Dn={bubbles:!1,cancelable:!0},On=s.forwardRef(wn(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[c,l]=s.useState(null),u=cn(i),d=cn(a),f=s.useRef(null),p=mt(t,l),m=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(r){let e=function(e){if(m.paused||!c)return;let t=e.target;c.contains(t)?f.current=t:Fn(f.current,{select:!0})},t=function(e){if(m.paused||!c)return;let t=e.relatedTarget;t!==null&&(c.contains(t)||Fn(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Fn(c)};wn(e,`handleFocusIn`),wn(t,`handleFocusOut`),wn(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,c,m.paused]),s.useEffect(()=>{if(c){In.add(m);let e=document.activeElement;if(!c.contains(e)){let t=new CustomEvent(Tn,Dn);c.addEventListener(Tn,u),c.dispatchEvent(t),t.defaultPrevented||(kn(zn(jn(c)),{select:!0}),document.activeElement===e&&Fn(c))}return()=>{c.removeEventListener(Tn,u),setTimeout(()=>{let t=new CustomEvent(En,Dn);c.addEventListener(En,d),c.dispatchEvent(t),t.defaultPrevented||Fn(e??document.body,{select:!0}),c.removeEventListener(En,d),In.remove(m)},0)}}},[c,u,d,m]);let h=s.useCallback(e=>{if(!n&&!r||m.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=An(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Fn(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Fn(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,m.paused]);return(0,W.jsx)(rn.div,{tabIndex:-1,...o,ref:p,onKeyDown:h})},`FocusScope`));function kn(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Fn(r,{select:t}),document.activeElement!==n)return}wn(kn,`focusFirst`);function An(e){let t=jn(e);return[Mn(t,e),Mn(t.reverse(),e)]}wn(An,`getTabbableEdges`);function jn(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:wn(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}wn(jn,`getTabbableCandidates`);function Mn(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Nn(r,{upTo:t})))return r}wn(Mn,`findVisible`);function Nn(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}wn(Nn,`isHidden`);function Pn(e){return e instanceof HTMLInputElement&&`select`in e}wn(Pn,`isSelectableInput`);function Fn(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Pn(e)&&t&&e.select()}}wn(Fn,`focus`);var In=Ln();function Ln(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Rn(e,t),e.unshift(t)},remove(t){e=Rn(e,t),e[0]?.resume()}}}wn(Ln,`createFocusScopesStack`);function Rn(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}wn(Rn,`arrayRemove`);function zn(e){return e.filter(e=>e.tagName!==`A`)}wn(zn,`removeLinks`);var Bn=Object.defineProperty,Vn=s.forwardRef(((e,t)=>Bn(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=s.useState(!1);bt(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?zt.createPortal((0,W.jsx)(rn.div,{...r,ref:t}),o):null},`Portal`)),Hn=Object.defineProperty,Un=(e,t)=>Hn(e,`name`,{value:t,configurable:!0});function Wn(e,t){return s.useReducer((e,n)=>t[e][n]??e,e)}Un(Wn,`useStateMachine`);var Gn=Un(e=>{let{present:t,children:n}=e,r=Kn(t),i=typeof n==`function`?n({present:r.isPresent}):s.Children.only(n),a=Jn(r.ref,Xn(i));return typeof n==`function`||r.isPresent?s.cloneElement(i,{ref:a}):null},`Presence`);function Kn(e){let[t,n]=s.useState(),r=s.useRef(null),i=s.useRef(e),a=s.useRef(`none`),o=s.useRef(void 0),[c,l]=Wn(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return s.useEffect(()=>{c===`mounted`?(a.current=o.current??Yn(r.current),o.current=void 0):a.current=`none`},[c]),bt(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=Yn(t);e?(o.current=s,l(`MOUNT`)):s===`none`||t?.display===`none`?l(`UNMOUNT`):l(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,l]),bt(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=Un(a=>{let o=Yn(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(l(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=Un(e=>{e.target===t&&(a.current=Yn(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}l(`ANIMATION_END`)},[t,l]),{isPresent:[`mounted`,`unmountSuspended`].includes(c),ref:s.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=Yn(t)}else r.current=null;n(e)},[])}}Un(Kn,`usePresence`);function qn(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}Un(qn,`setRef`);function Jn(...e){let t=s.useRef(e);return t.current=e,s.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=qn(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():qn(n[e],null)}}},[])}Un(Jn,`useStableComposedRefs`);function Yn(e){return e?.animationName||`none`}Un(Yn,`getAnimationName`);function Xn(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Un(Xn,`getElementRef`);var Zn=Object.defineProperty,Qn=(e,t)=>Zn(e,`name`,{value:t,configurable:!0}),$n=0,er=null;function tr(e){return nr(),e.children}Qn(tr,`FocusGuards`);function nr(){s.useEffect(()=>{er||={start:rr(),end:rr()};let{start:e,end:t}=er;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),$n++,()=>{$n===1&&(er?.start.remove(),er?.end.remove(),er=null),$n=Math.max(0,$n-1)}},[])}Qn(nr,`useFocusGuards`);function rr(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}Qn(rr,`createFocusGuard`);var ir=function(e,t){return ir=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},ir(e,t)};function ar(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);ir(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var or=function(){return or=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},or.apply(this,arguments)};function sr(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function cr(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var lr=`right-scroll-bar-position`,ur=`width-before-scroll-bar`,dr=`with-scroll-bars-hidden`,fr=`--removed-body-scroll-bar-size`;function pr(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function mr(e,t){var n=(0,s.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var hr=typeof window<`u`?s.useLayoutEffect:s.useEffect,gr=new WeakMap;function _r(e,t){var n=mr(t||null,function(t){return e.forEach(function(e){return pr(e,t)})});return hr(function(){var t=gr.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||pr(e,null)}),i.forEach(function(e){r.has(e)||pr(e,a)})}gr.set(n,e)},[e]),n}function vr(e){return e}function yr(e,t){t===void 0&&(t=vr);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function br(e){e===void 0&&(e={});var t=yr(null);return t.options=or({async:!0,ssr:!1},e),t}var xr=function(e){var t=e.sideCar,n=sr(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return s.createElement(r,or({},n))};xr.isSideCarExport=!0;function Sr(e,t){return e.useMedium(t),xr}var Cr=br(),wr=function(){},Tr=s.forwardRef(function(e,t){var n=s.useRef(null),r=s.useState({onScrollCapture:wr,onWheelCapture:wr,onTouchMoveCapture:wr}),i=r[0],a=r[1],o=e.forwardProps,c=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=sr(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=p,C=_r([n,t]),w=or(or({},x),i);return s.createElement(s.Fragment,null,d&&s.createElement(S,{sideCar:Cr,removeScrollBar:u,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?s.cloneElement(s.Children.only(c),or(or({},w),{ref:C})):s.createElement(y,or({},w,{className:l,ref:C}),c))});Tr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Tr.classNames={fullWidth:ur,zeroRight:lr};var Er,Dr=function(){if(Er)return Er;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function Or(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Dr();return t&&e.setAttribute(`nonce`,t),e}function kr(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ar(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var jr=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Or())&&(kr(t,n),Ar(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Mr=function(){var e=jr();return function(t,n){s.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Nr=function(){var e=Mr();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Pr={left:0,top:0,right:0,gap:0},Fr=function(e){return parseInt(e||``,10)||0},Ir=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[Fr(n),Fr(r),Fr(i)]},Lr=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Pr;var t=Ir(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Rr=Nr(),zr=`data-scroll-locked`,Br=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
3
|
-
.${dr} {
|
|
4
|
-
overflow: hidden ${r};
|
|
5
|
-
padding-right: ${s}px ${r};
|
|
6
|
-
}
|
|
7
|
-
body[${zr}] {
|
|
8
|
-
overflow: hidden ${r};
|
|
9
|
-
overscroll-behavior: contain;
|
|
10
|
-
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
11
|
-
padding-left: ${i}px;
|
|
12
|
-
padding-top: ${a}px;
|
|
13
|
-
padding-right: ${o}px;
|
|
14
|
-
margin-left:0;
|
|
15
|
-
margin-top:0;
|
|
16
|
-
margin-right: ${s}px ${r};
|
|
17
|
-
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.${lr} {
|
|
21
|
-
right: ${s}px ${r};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.${ur} {
|
|
25
|
-
margin-right: ${s}px ${r};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.${lr} .${lr} {
|
|
29
|
-
right: 0 ${r};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.${ur} .${ur} {
|
|
33
|
-
margin-right: 0 ${r};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
body[${zr}] {
|
|
37
|
-
${fr}: ${s}px;
|
|
38
|
-
}
|
|
39
|
-
`},Vr=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Hr=function(){s.useEffect(function(){return document.body.setAttribute(zr,(Vr()+1).toString()),function(){var e=Vr()-1;e<=0?document.body.removeAttribute(zr):document.body.setAttribute(zr,e.toString())}},[])},Ur=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Hr();var a=s.useMemo(function(){return Lr(i)},[i]);return s.createElement(Rr,{styles:Br(a,!t,i,n?``:`!important`)})},Wr=!1;if(typeof window<`u`)try{var Gr=Object.defineProperty({},"passive",{get:function(){return Wr=!0,!0}});window.addEventListener(`test`,Gr,Gr),window.removeEventListener(`test`,Gr,Gr)}catch{Wr=!1}var Kr=Wr?{passive:!1}:!1,qr=function(e){return e.tagName===`TEXTAREA`},Jr=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!qr(e)&&n[t]===`visible`)},Yr=function(e){return Jr(e,`overflowY`)},Xr=function(e){return Jr(e,`overflowX`)},Zr=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),ei(e,r)){var i=ti(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Qr=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},$r=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},ei=function(e,t){return e===`v`?Yr(t):Xr(t)},ti=function(e,t){return e===`v`?Qr(t):$r(t)},ni=function(e,t){return e===`h`&&t===`rtl`?-1:1},ri=function(e,t,n,r,i){var a=ni(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=ti(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&ei(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},ii=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},ai=function(e){return[e.deltaX,e.deltaY]},oi=function(e){return e&&`current`in e?e.current:e},si=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ci=function(e){return`
|
|
40
|
-
.block-interactivity-${e} {pointer-events: none;}
|
|
41
|
-
.allow-interactivity-${e} {pointer-events: all;}
|
|
42
|
-
`},li=0,ui=[];function di(e){var t=s.useRef([]),n=s.useRef([0,0]),r=s.useRef(),i=s.useState(li++)[0],a=s.useState(Nr)[0],o=s.useRef(e);s.useEffect(function(){o.current=e},[e]),s.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=cr([e.lockRef.current],(e.shards||[]).map(oi),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var c=s.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=ii(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Zr(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Zr(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return ri(h,t,e,h===`h`?s:c,!0)},[]),l=s.useCallback(function(e){var n=e;if(!(!ui.length||ui[ui.length-1]!==a)){var r=`deltaY`in n?ai(n):ii(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&si(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var s=(o.current.shards||[]).map(oi).filter(Boolean).filter(function(e){return e.contains(n.target)});(s.length>0?c(n,s[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),u=s.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:fi(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),d=s.useCallback(function(e){n.current=ii(e),r.current=void 0},[]),f=s.useCallback(function(t){u(t.type,ai(t),t.target,c(t,e.lockRef.current))},[]),p=s.useCallback(function(t){u(t.type,ii(t),t.target,c(t,e.lockRef.current))},[]);s.useEffect(function(){return ui.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener(`wheel`,l,Kr),document.addEventListener(`touchmove`,l,Kr),document.addEventListener(`touchstart`,d,Kr),function(){ui=ui.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,l,Kr),document.removeEventListener(`touchmove`,l,Kr),document.removeEventListener(`touchstart`,d,Kr)}},[]);var m=e.removeScrollBar,h=e.inert;return s.createElement(s.Fragment,null,h?s.createElement(a,{styles:ci(i)}):null,m?s.createElement(Ur,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function fi(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var pi=Sr(Cr,di),mi=s.forwardRef(function(e,t){return s.createElement(Tr,or({},e,{ref:t,sideCar:pi}))});mi.classNames=Tr.classNames;var hi=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},gi=new WeakMap,_i=new WeakMap,vi={},yi=0,bi=function(e){return e&&(e.host||bi(e.parentNode))},xi=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=bi(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Si=function(e,t,n,r){var i=xi(t,Array.isArray(e)?e:[e]);vi[n]||(vi[n]=new WeakMap);var a=vi[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(gi.get(e)||0)+1,l=(a.get(e)||0)+1;gi.set(e,c),a.set(e,l),o.push(e),c===1&&i&&_i.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),yi++,function(){o.forEach(function(e){var t=gi.get(e)-1,i=a.get(e)-1;gi.set(e,t),a.set(e,i),t||(_i.has(e)||e.removeAttribute(r),_i.delete(e)),i||e.removeAttribute(n)}),yi--,yi||(gi=new WeakMap,gi=new WeakMap,_i=new WeakMap,vi={})}},Ci=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||hi(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Si(r,i,n,`aria-hidden`)):function(){return null}},wi=Object.defineProperty,Ti=(e,t)=>wi(e,`name`,{value:t,configurable:!0}),Ei=`Dialog`,[Di,Oi]=vt(Ei),[ki,Ai]=Di(Ei),ji=Ti(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,c=s.useRef(null),l=s.useRef(null),[u,d]=Pt({prop:r,defaultProp:i??!1,onChange:a,caller:Ei}),[f,p]=s.useState(0),[m,h]=s.useState(0);return(0,W.jsx)(ki,{scope:t,triggerRef:c,contentRef:l,contentId:Tt(),titleId:Tt(),descriptionId:Tt(),titlePresent:f>0,descriptionPresent:m>0,setTitleCount:p,setDescriptionCount:h,open:u,onOpenChange:d,onOpenToggle:s.useCallback(()=>d(e=>!e),[d]),modal:o,children:n})},`Dialog`),Mi=`DialogPortal`,[Ni,Pi]=Di(Mi,{forceMount:void 0}),Fi=Ti(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Ai(Mi,t);return(0,W.jsx)(Ni,{scope:t,forceMount:n,children:s.Children.map(r,e=>(0,W.jsx)(Gn,{present:n||a.open,children:(0,W.jsx)(Vn,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Ii=`DialogOverlay`,Li=s.forwardRef(Ti(function(e,t){let n=Pi(Ii,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Ai(Ii,e.__scopeDialog);return a.modal?(0,W.jsx)(Gn,{present:r||a.open,children:(0,W.jsx)(zi,{...i,ref:t})}):null},`DialogOverlay`)),Ri=Ht(`DialogOverlay.RemoveScroll`),zi=s.forwardRef(Ti(function(e,t){let{__scopeDialog:n,...r}=e,i=Ai(Ii,n),a=mt(t,_n());return(0,W.jsx)(mi,{as:Ri,allowPinchZoom:!0,shards:[i.contentRef],children:(0,W.jsx)(rn.div,{"data-state":Zi(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Bi=`DialogContent`,Vi=s.forwardRef(Ti(function(e,t){let n=Pi(Bi,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Ai(Bi,e.__scopeDialog);return(0,W.jsx)(Gn,{present:r||a.open,children:a.modal?(0,W.jsx)(Hi,{...i,ref:t}):(0,W.jsx)(Ui,{...i,ref:t})})},`DialogContent`)),Hi=s.forwardRef(Ti(function(e,t){let n=Ai(Bi,e.__scopeDialog),r=s.useRef(null),i=mt(t,n.contentRef,r);return s.useEffect(()=>{let e=r.current;if(e)return Ci(e)},[]),(0,W.jsx)(Wi,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:G(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:G(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:G(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Ui=s.forwardRef(Ti(function(e,t){let n=Ai(Bi,e.__scopeDialog),r=s.useRef(!1),i=s.useRef(!1);return(0,W.jsx)(Wi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Wi=s.forwardRef(Ti(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=Ai(Bi,n);return nr(),(0,W.jsx)(W.Fragment,{children:(0,W.jsx)(On,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,W.jsx)(gn,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Zi(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),Gi=`DialogTitle`,Ki=s.forwardRef(Ti(function(e,t){let{__scopeDialog:n,...r}=e,i=Ai(Gi,n),{setTitleCount:a}=i;return bt(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,W.jsx)(rn.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),qi=`DialogDescription`,Ji=s.forwardRef(Ti(function(e,t){let{__scopeDialog:n,...r}=e,i=Ai(qi,n),{setDescriptionCount:a}=i;return bt(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,W.jsx)(rn.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),Yi=`DialogClose`,Xi=s.forwardRef(Ti(function(e,t){let{__scopeDialog:n,...r}=e,i=Ai(Yi,n);return(0,W.jsx)(rn.button,{type:`button`,...r,ref:t,onClick:G(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Zi(e){return e?`open`:`closed`}Ti(Zi,`getState`);var Qi=[],$i=new Map,ea=[`.skip-link`,`.sidebar`,`.global-header`,`#mainContent`,`.page-header`];function ta(e){if(e){for(let e of document.querySelectorAll(ea.join(`,`)))$i.has(e)||$i.set(e,e.hasAttribute(`inert`)),e.setAttribute(`inert`,``);return}for(let[e,t]of $i)e.isConnected&&!t&&e.removeAttribute(`inert`);$i.clear()}function na(e){if(e.key!==`Escape`||!Qi.length)return;let t=Qi[Qi.length-1];e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),t.disabled||t.close()}function ra(e){return Qi.length||(document.addEventListener(`keydown`,na,!0),ta(!0)),Qi.push(e),()=>{let t=Qi.lastIndexOf(e);t>=0&&Qi.splice(t,1),Qi.length||(document.removeEventListener(`keydown`,na,!0),ta(!1))}}function ia({open:e,onOpenChange:t,closeDisabled:n=!1,children:r}){return(0,W.jsx)(ji,{open:e,onOpenChange:e=>{!e&&n||t(e)},children:r})}function aa({open:e,className:t,closeDisabled:n=!1,role:r=`dialog`,onRequestClose:i,children:a}){let o=(0,s.useRef)(null),c=(0,s.useRef)({close:i,disabled:n});return c.current.close=i,c.current.disabled=n,(0,s.useEffect)(()=>{if(e)return o.current=document.activeElement instanceof HTMLElement?document.activeElement:null,ra(c.current)},[e]),(0,W.jsx)(Fi,{children:(0,W.jsxs)(`div`,{className:`overlay`,children:[(0,W.jsx)(Li,{className:`overlay-backdrop`}),(0,W.jsx)(Vi,{className:t,role:r,"aria-busy":n||void 0,onEscapeKeyDown:e=>{e.preventDefault(),e.stopPropagation()},onPointerDownOutside:e=>{n&&e.preventDefault()},onCloseAutoFocus:e=>{let t=o.current;t?.isConnected&&(e.preventDefault(),t.focus())},children:a})]})})}function oa({open:e,onOpenChange:t,title:n,description:r,icon:i,footer:a,children:o,closeDisabled:s=!1,showClose:c=!0,className:l,role:u=`dialog`}){return(0,W.jsx)(ia,{open:e,onOpenChange:t,closeDisabled:s,children:(0,W.jsxs)(aa,{open:e,className:`studio-dialog${l?` ${l}`:``}`,closeDisabled:s,role:u,onRequestClose:()=>t(!1),children:[i?(0,W.jsx)(`div`,{className:`studio-dialog-icon`,children:i}):null,(0,W.jsxs)(`header`,{className:`studio-dialog-header`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Ki,{children:n}),r?(0,W.jsx)(Ji,{children:r}):null]}),c?(0,W.jsx)(Xi,{asChild:!0,children:(0,W.jsx)(`button`,{className:`icon-button tertiary`,type:`button`,"aria-label":`关闭`,disabled:s,children:(0,W.jsx)($e,{size:16})})}):null]}),o?(0,W.jsx)(`div`,{className:`studio-dialog-body`,children:o}):null,a?(0,W.jsx)(`footer`,{className:`studio-dialog-footer`,children:a}):null]})})}function sa({open:e,onOpenChange:t,title:n,subtitle:r,wide:i=!1,compact:a=!1,closeDisabled:o=!1,footer:s,children:c}){return(0,W.jsx)(ia,{open:e,onOpenChange:t,closeDisabled:o,children:(0,W.jsxs)(aa,{open:e,className:`drawer${i?` wide`:``}${a?` compact`:``}`,closeDisabled:o,onRequestClose:()=>t(!1),children:[(0,W.jsxs)(`header`,{className:`drawer-header`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Ki,{children:n}),r?(0,W.jsx)(Ji,{children:r}):null]}),(0,W.jsx)(Xi,{asChild:!0,children:(0,W.jsx)(`button`,{className:`icon-button tertiary`,type:`button`,"aria-label":`关闭`,disabled:o,children:(0,W.jsx)($e,{size:16})})})]}),(0,W.jsx)(`div`,{className:`drawer-body`,children:c}),s?(0,W.jsx)(`footer`,{className:`drawer-footer`,children:s}):null]})})}function ca({title:e,description:t,confirmText:n=`确认`,danger:r=!0,busy:i=!1,onConfirm:a,onCancel:o}){return(0,W.jsx)(oa,{open:!0,onOpenChange:e=>{!e&&!i&&o()},title:e,description:t,closeDisabled:i,showClose:!1,role:`alertdialog`,className:`confirm-dialog`,icon:(0,W.jsx)(`span`,{className:`confirm-icon${r?` danger`:``}`,style:r?void 0:{background:`var(--accent-soft)`,color:`var(--accent-strong)`},children:r?(0,W.jsx)(I,{size:18}):(0,W.jsx)(he,{size:18})}),footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Xi,{asChild:!0,children:(0,W.jsx)(`button`,{className:`button secondary`,type:`button`,disabled:i,children:`取消`})}),(0,W.jsx)(`button`,{className:`button ${r?`danger`:`accent`}`,type:`button`,onClick:a,disabled:i,children:i?`处理中…`:n})]})})}function la(e){return ua(e)||typeof e==`function`||da(e)}function ua(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function da(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function fa(e,t){return e==null?null:la(e)?s.createElement(e,t):e}function pa(e){if(`cell`in e&&e.cell){let t=e.cell,n=t.column.columnDef,r=t,i=n;return r.getIsAggregated?.()?fa(i.aggregatedCell??n.cell,t.getContext()):r.getIsPlaceholder?.()?null:fa(n.cell,t.getContext())}return`header`in e&&e.header?fa(e.header.column.columnDef.header,e.header.getContext()):`footer`in e&&e.footer?fa(e.footer.column.columnDef.footer,e.footer.getContext()):null}function ma({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function ha(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var ga=[],_a=0,{link:va,unlink:ya,propagate:ba,checkDirty:xa,shallowPropagate:Sa}=ma({update(e){return e._update()},notify(e){ga[wa++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,Oa(e))}}),Ca=0,wa=0,Ta,Ea=0;function Da(e){try{++Ea,e()}finally{--Ea||ka()}}function Oa(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=ya(n,e)}function ka(){if(!(Ea>0)){for(;Ca<wa;){let e=ga[Ca];ga[Ca++]=void 0,e.notify()}Ca=0,wa=0}}function Aa(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:+!n,get(){return Ta!==void 0&&va(i,Ta,_a),i._snapshot},subscribe(e){let t=ha(e),n={current:!1},r=ja(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=Ta,o=t?.compare??Object.is;if(n)Ta=i,++_a,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=5);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{Ta=a,n&&(i.flags&=-5),Oa(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&xa(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&Sa(e)}}else e&32&&(i.flags=e&-33);return Ta!==void 0&&va(i,Ta,_a),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(ba(e),Sa(e),ka())}},i}function ja(e){let t=()=>{let t=Ta;Ta=n,++_a,n.depsTail=void 0,n.flags=6;try{return e()}finally{Ta=t,n.flags&=-5,Oa(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let e=this.flags;e&16||e&32&&xa(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,Oa(this)}};return t(),n}function Ma(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=Na(e);if(n.length!==Na(t).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!Object.is(e[n[r]],t[n[r]]))return!1;return!0}function Na(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}var Pa=n((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Fa=n(((e,t)=>{t.exports=Pa()})),Ia=n((e=>{var t=r(),n=Fa();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),La=t(n(((e,t)=>{t.exports=Ia()}))(),1);function Ra(e,t){return e===t}function za(e,t=e=>e,n){let r=n?.compare??Ra,i=(0,s.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,s.useCallback)(()=>e.get(),[e]);return(0,La.useSyncExternalStoreWithSelector)(i,a,a,t,r)}function Ba(e){let t=za(e.source,e.selector,{compare:Ma});return typeof e.children==`function`?e.children(t):e.children}function Va(e){let t=e;return Object.defineProperty(e,"state",{get(){return e.get()}}),`set`in e&&(t.setState=e.set.bind(e)),t}function Ha(e){let{createAtom:t,batch:n}=e,r=t(0);return{createOptionsStore:!1,wrapExternalAtoms:!1,addSubscription:()=>{throw Error(`Feature not supported in current reactivity implementation`)},unmount:()=>{throw Error(`Feature not supported in current reactivity implementation`)},schedule:e.schedule??(e=>queueMicrotask(e)),batch:n,untrack:e=>e(),createReadonlyAtom:(e,n)=>{let i=n?.compare??Object.is,a=!1,o,s=()=>{let t=e();return(!a||!i(o,t))&&(o=t,a=!0),o},c=t(()=>(r.get(),s()),{compare:i});return{get:s,subscribe:c.subscribe.bind(c)}},createWritableAtom:(e,n)=>t(e,{compare:n?.compare}),commit:()=>{r.set(e=>e+1)}}}function Ua(e,t=Object.is){let n=!1,r;return{get:e.get,markCommitted:e=>{r=e,n=!0},subscribe:i=>e.subscribe(e=>{(!n||!t(r,e))&&i(e)})}}function Wa(){return Ha({createAtom:Aa,batch:Da})}function Ga(e,t){return typeof e==`function`?e(t):e}function Ka(e){if(Array.isArray(e))return e.map(Ka);if(e&&typeof e==`object`){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;let n=t===null?qa():{},r=Object.keys(e);for(let t=0;t<r.length;t++){let i=r[t];Object.defineProperty(n,i,{configurable:!0,enumerable:!0,value:Ka(e[i]),writable:!0})}return n}return e}function qa(){return Object.create(null)}function Ja(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ya(e){if(typeof e!=`object`||!e)return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Xa(e){return Reflect.ownKeys(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}var Za=3;function Qa(e,t){return $a(e,t,Za)}function $a(e,t,n){if(Object.is(e,t))return!0;if(n<=0||!Ya(e)||!Ya(t)||(Array.isArray(e)||Array.isArray(t))&&(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length))return!1;let r=Xa(e),i=Xa(t);if(r.length!==i.length)return!1;let a=e,o=t;for(let e=0;e<r.length;e++){let i=r[e];if(!Object.prototype.propertyIsEnumerable.call(t,i)||!$a(a[i],o[i],n-1))return!1}return!0}function eo(e,t,n,r=Qa){let i=`on${t.charAt(0).toUpperCase()}${t.slice(1)}Change`,a=e.options[i];a&&a(e=>{let t=Ga(n,e);return r(e,t)?e:t})}function to(e,t){let n=[],r=e=>{e.forEach(e=>{n.push(e);let i=t(e);i.length&&r(i)})};return r(e),n}var no=({fn:e,memoDeps:t,onAfterCompare:n,onAfterUpdate:r,onBeforeCompare:i,onBeforeUpdate:a})=>{let o=[],s;return c=>{i?.();let l=t?.(c),u=!l||l.length!==o?.length;if(!u&&l){for(let e=0;e<l.length;e++)if(l[e]!==o[e]){u=!0;break}}return n?.(u),u?(o=l,a?.(),s=e(...l??[]),r?.(s),s):s}};function ro(e){let t=!1;return()=>{if(!t){t=!0;return}e()}}function io({feature:e,fnName:t,objectId:n,onAfterUpdate:r,table:i,...a}){let o=()=>{if(!r)return;let{schedule:e,untrack:t}=i._reactivity;e(()=>t(()=>r()))},s={onAfterUpdate:()=>{o()}};return no({...a,...s})}function ao(e,t=`_`){let[n,r]=e.split(t);return{fnKey:r,fnName:`${n}.${r}`,parentName:n}}function oo(e,t,n){for(let[r,{fn:i,memoDeps:a}]of Object.entries(n)){let{fnKey:n,fnName:o}=ao(r);t[n]=a?io({memoDeps:a,fn:i,fnName:o,table:t,feature:e}):i}}function so(e,t,n,r){for(let[i,{fn:a,memoDeps:o}]of Object.entries(r)){let{fnKey:r,fnName:s}=ao(i);if(o){let i=`_memo_${r}`;t[r]=function(...t){if(!this[i]){let t=this;this[i]=io({memoDeps:e=>o(t,e),fn:(...e)=>a(t,...e),fnName:s,objectId:t.id,table:n,feature:e})}return this[i](...t)}}else t[r]=function(...e){return a(this,...e)}}}function co(e,t,n,...r){return e[t]?.(...r)??n(e,...r)}function lo(e){return e.row.getValue(e.column.id)}function uo(e){return e.getValue()??e.table.options.renderFallbackValue}function fo(e){return{table:e.table,column:e.column,row:e.row,cell:e,getValue:()=>e.getValue(),renderValue:()=>e.renderValue()}}var po={assignCellPrototype:(e,t)=>{so(`coreCellsFeature`,e,t,{cell_getValue:{fn:e=>lo(e)},cell_renderValue:{fn:e=>uo(e)},cell_getContext:{fn:e=>fo(e),memoDeps:e=>[e]}})}};function mo(e){if(!e._headerPrototype){e._headerPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignHeaderPrototype?.(e._headerPrototype,e)}return e._headerPrototype}function ho(e,t,n){let r=mo(e),i=Object.create(r);i.colSpan=0,i.column=t,i.depth=n.depth,i.headerGroup=null,i.id=n.id??t.id,i.index=n.index,i.isPlaceholder=!!n.isPlaceholder,i.placeholderId=n.placeholderId,i.rowSpan=0,i.subHeaders=[];let a=e._headerInstanceInitFns;for(let e=0;e<a.length;e++)a[e](i);return i}function go(){return{start:[],end:[]}}function _o(e){let t=e.table.atoms.columnVisibility?.get();if(!t)return!0;let n=e.columns;return n.length?n.some(e=>co(e,`getIsVisible`,_o)):(Ja(t,e.id)?t[e.id]:void 0)??!0}function vo(e){return e.getAllLeafColumns().filter(e=>co(e,`getIsVisible`,_o))}function yo(e,t=1){let n=t;for(let r=0;r<e.length;r++){let i=e[r];co(i,`getIsVisible`,_o)&&i.columns.length&&(n=Math.max(n,yo(i.columns,t+1)))}return n}function bo(e,t){return e?`${e}_${t}`:String(t)}function xo(e,t,n,r){let i=e??``;return t&&(i=i?`${i}_${t}`:String(t)),n&&(i=i?`${i}_${n}`:n),r&&(i=i?`${i}_${r}`:r),i}function So(e,t){let n=0;for(let r=0;r<e.length;r++)e[r].column===t&&n++;return n}function Co(e,t,n,r,i,a){let o={depth:t,id:bo(r,t),headers:[]},s=[];for(let i=0;i<e.length;i++){if(!(i in e))continue;let a=e[i],c=s[s.length-1],l=a.column.depth===o.depth,u,d=!1;if(l&&a.column.parent?u=a.column.parent:(u=a.column,d=!0),c&&c.column===u)c.subHeaders.push(a);else{let e=ho(n,u,{id:xo(r,t,u.id,a.id),isPlaceholder:d,placeholderId:d?String(So(s,u)):void 0,depth:t,index:s.length});e.subHeaders.push(a),s.push(e)}o.headers.push(a),a.headerGroup=o}for(let e=0;e<a.length;e++)a[e](o);i.push(o),t>0&&Co(s,t-1,n,r,i,a)}function wo(e){for(let t=0;t<e.length;t++){let n=e[t];if(!co(n.column,`getIsVisible`,_o))continue;let r=0;if(n.subHeaders.length){wo(n.subHeaders);for(let e=0;e<n.subHeaders.length;e++){let t=n.subHeaders[e];co(t.column,`getIsVisible`,_o)&&(r+=t.colSpan)}}else r=1;if(n.colSpan=r,n.isPlaceholder&&n.subHeaders.length===1&&n.subHeaders[0].column===n.column){let e=1,t=n.subHeaders[0];for(;t;)t.rowSpan=0,e++,t=t.subHeaders.length===1&&t.subHeaders[0].column===n.column?t.subHeaders[0]:void 0;n.rowSpan=e}else n.rowSpan=1}}function To(e,t,n,r){let i=yo(e),a=[],o=n._headerGroupInstanceInitFns,s=Array(t.length);for(let e=0;e<t.length;e++)e in t&&(s[e]=ho(n,t[e],{depth:i,index:e}));return Co(s,i-1,n,r,a,o),a.reverse(),wo(a[0]?.headers??[]),a}function Eo(e){if(!e._columnPrototype){e._columnPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignColumnPrototype?.(e._columnPrototype,e)}return e._columnPrototype}function Do(e,t,n,r){let i={...e.getDefaultColumnDef(),...t},a=i.accessorKey,o=a===void 0?void 0:String(a),s=i.id??o?.replaceAll(`.`,`_`)??(typeof i.header==`string`?i.header:void 0),c;if(i.accessorFn)c=i.accessorFn;else if(a!==void 0){if(typeof a==`string`&&a.includes(`.`)){let e=a.split(`.`);c=t=>{let n=t;for(let t=0;t<e.length;t++){let r=e[t];n=n?.[r]}return n}}else c=e=>e[i.accessorKey]}if(!s)throw Error();let l=Eo(e),u=Object.create(l);u.accessorFn=c,u.columnDef=i,u.columns=[],u.depth=n,u.id=`${String(s)}`,u.parent=r;let d=e._columnInstanceInitFns;for(let e=0;e<d.length;e++)d[e](u);return u}function Oo(e){let t=e.atoms.columnOrder?.get();return n=>{let r=[];if(!t?.length)r=n;else{let e=new Map;for(let t=0;t<n.length;t++){let r=n[t];e.set(r.id,r)}for(let n=0;n<t.length;n++){let i=t[n],a=e.get(i);a&&(r.push(a),e.delete(i))}for(let t=0;t<n.length;t++){let i=n[t];e.has(i.id)&&r.push(i)}}return ko(e,r)}}function ko(e,t){let n=e.atoms.grouping?.get()??[],{groupedColumnMode:r}=e.options;if(!n.length||!r)return t;let i=t.filter(e=>!n.includes(e.id));if(r===`remove`)return i;let a=new Map;for(let e=0;e<t.length;e++){let n=t[e];a.set(n.id,n)}let o=[];for(let e=0;e<n.length;e++){let t=a.get(n[e]);t&&o.push(t)}return[...o,...i]}function Ao(e){return[e,...e.columns.flatMap(e=>e.getFlatColumns())]}function jo(e){if(e.columns.length){let t=e.columns.flatMap(e=>e.getLeafColumns());return co(e.table,`getOrderColumns`,Oo)(t)}return[e]}function Mo(e){return{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>e.renderValue()?.toString?.()??null,...Object.values(e._features).reduce((e,t)=>Object.assign(e,t.getDefaultColumnDef?.()),{}),...e.options.defaultColumn}}function No(e,t,n,r=0){let i=Array(t.length);for(let a=0;a<t.length;a++){if(!(a in t))continue;let o=t[a],s=Do(e,o,r,n),c=o;s.columns=c.columns?No(e,c.columns,s,r+1):[],i[a]=s}return i}function Po(e){return No(e,e.options.columns)}function Fo(e){return e.getAllColumns().flatMap(e=>e.getFlatColumns())}function Io(e){let t=qa(),n=e.getAllFlatColumns();for(let e=0;e<n.length;e++){let r=n[e];t[r.id]=r}return t}function Lo(e){let t=e.getAllColumns().flatMap(e=>e.getLeafColumns());return co(e,`getOrderColumns`,Oo)(t)}function Ro(e){let t=qa(),n=e.getAllLeafColumns();for(let e=0;e<n.length;e++){let r=n[e];t[r.id]=r}return t}function zo(e,t){return e.getAllFlatColumnsById()[t]}var Bo={assignColumnPrototype:(e,t)=>{so(`coreColumnsFeature`,e,t,{column_getFlatColumns:{fn:e=>Ao(e),memoDeps:e=>[e.table.options.columns]},column_getLeafColumns:{fn:e=>jo(e),memoDeps:e=>[e.table.atoms.columnOrder?.get(),e.table.atoms.grouping?.get(),e.table.options.columns,e.table.options.groupedColumnMode]}})},constructTableAPIs:e=>{oo(`coreColumnsFeature`,e,{table_getDefaultColumnDef:{fn:()=>Mo(e),memoDeps:()=>[e.options.defaultColumn]},table_getAllColumns:{fn:()=>Po(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumns:{fn:()=>Fo(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumnsById:{fn:()=>Io(e),memoDeps:()=>[e.options.columns]},table_getAllLeafColumns:{fn:()=>Lo(e),memoDeps:()=>[e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.columns,e.options.groupedColumnMode]},table_getAllLeafColumnsById:{fn:()=>Ro(e),memoDeps:()=>[e.getAllLeafColumns()]},table_getColumn:{fn:t=>zo(e,t)}})}};function Vo(e,t){for(let n=0;n<e.subHeaders.length;n++)Vo(e.subHeaders[n],t);t.push(e)}function Ho(e){let t=[];return Vo(e,t),t}function Uo(e){return{column:e.column,header:e,table:e.column.table}}function Wo(e){let{start:t,end:n}=e.atoms.columnPinning?.get()??go(),r=e.getAllColumns(),i=co(e,`getVisibleLeafColumns`,vo);if(!t.length&&!n.length)return To(r,i,e);let a=e.getAllLeafColumnsById(),o=[];for(let e=0;e<t.length;e++){let n=a[t[e]];n&&co(n,`getIsVisible`,_o)&&o.push(n)}let s=[];for(let e=0;e<n.length;e++){let t=a[n[e]];t&&co(t,`getIsVisible`,_o)&&s.push(t)}let c=i.filter(e=>!t.includes(e.id)&&!n.includes(e.id));return To(r,[...o,...c,...s],e)}function Go(e){return[...e.getHeaderGroups()].reverse()}function Ko(e){let t=e.getHeaderGroups(),n=[];for(let e=0;e<t.length;e++){let r=t[e].headers;for(let e=0;e<r.length;e++)n.push(r[e])}return n}function qo(e){let t=e.getHeaderGroups()[0]?.headers??[],n=[];for(let e=0;e<t.length;e++){let r=t[e].getLeafHeaders();for(let e=0;e<r.length;e++)n.push(r[e])}return n}var Jo={assignHeaderPrototype:(e,t)=>{so(`coreHeadersFeature`,e,t,{header_getLeafHeaders:{fn:e=>Ho(e),memoDeps:e=>[e.column.table.options.columns]},header_getContext:{fn:e=>Uo(e),memoDeps:e=>[e.column.table.options.columns]}})},constructTableAPIs:e=>{oo(`coreHeadersFeature`,e,{table_getHeaderGroups:{fn:()=>Wo(e),memoDeps:()=>[e.options.columns,e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.atoms.columnPinning?.get(),e.atoms.columnVisibility?.get(),e.options.groupedColumnMode]},table_getFooterGroups:{fn:()=>Go(e),memoDeps:()=>[e.getHeaderGroups()]},table_getFlatHeaders:{fn:()=>Ko(e),memoDeps:()=>[e.getHeaderGroups()]},table_getLeafHeaders:{fn:()=>qo(e),memoDeps:()=>[e.getHeaderGroups()]}})}};function Yo(e){if(!e._rowPrototype){e._rowPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignRowPrototype?.(e._rowPrototype,e)}return e._rowPrototype}var Xo=(e,t,n,r,i,a,o)=>{let s=Yo(e),c=Object.create(s);c._displayIndexCache=-1,c._uniqueValuesCache=qa(),c._valuesCache=qa(),c.depth=i,c.id=t,c.index=r,c.original=n,c.parentId=o,c.subRows=a??[];let l=e._rowInstanceInitFns;for(let e=0;e<l.length;e++)l[e](c);return c};function Zo(){return[]}function Qo(e,t){eo(e,`cellSelection`,t?Zo():Ka(e.initialState.cellSelection)??Zo())}function $o(e){e.atoms.cellSelection&&(e.options.autoResetAll??e.options.autoResetCellSelection??!0)&&e._reactivity.schedule(()=>Qo(e))}function es(e){e.atoms.expanded&&(e.options.autoResetAll??e.options.autoResetExpanded??!e.options.manualExpanding)&&e._reactivity.schedule(()=>ts(e))}function ts(e,t){let n=e.initialState.expanded;eo(e,`expanded`,t?qa():n===!0||Object.assign(qa(),Ka(n??{})))}var ns=0;function rs(e){if(e.options.autoResetAll??e.options.autoResetPageIndex??!e.options.manualPagination){if((e.atoms.pagination?.get()?.pageIndex??ns)===ns)return;os(e,!0)}}function is(e,t){eo(e,`pagination`,t)}function as(e,t){is(e,n=>{let r=Ga(t,n.pageIndex),i=e.options.pageCount===void 0||e.options.pageCount===-1?2**53-1:e.options.pageCount-1;return r=Math.max(0,Math.min(r,i)),{...n,pageIndex:r}})}function os(e,t){as(e,t?ns:e.initialState.pagination?.pageIndex??ns)}function ss(e,t){eo(e,`sorting`,t)}function cs(e,t){ss(e,t?[]:Ka(e.initialState.sorting??[]))}function ls(e){e.atoms.sorting&&(e.options.autoResetAll??e.options.autoResetSorting??!1)&&cs(e)}function us(){return e=>io({feature:`coreRowModelsFeature`,table:e,fnName:`table.getCoreRowModel`,memoDeps:()=>[e.options.data],fn:()=>fs(e,e.options.data),onAfterUpdate:ro(()=>{es(e),rs(e),ls(e),$o(e)})})}function ds(e,t,n,r=0,i){let a=[];for(let o=0;o<n.length;o++){let s=n[o],c=Xo(e,e.getRowId(s,o,i),s,o,r,void 0,i?.id);t.flatRows.push(c),t.rowsById[c.id]=c,a.push(c),e.options.getSubRows&&(c.originalSubRows=e.options.getSubRows(s,o),c.originalSubRows?.length&&(c.subRows=ds(e,t,c.originalSubRows,r+1,c)))}return a}function fs(e,t){let n={rows:[],flatRows:[],rowsById:qa()};return n.rows=ds(e,n,t),n}function ps(e){return e._rowModels.coreRowModel||(e._rowModels.coreRowModel=e.options.features.coreRowModel?.(e)??us()(e)),e._rowModels.coreRowModel()}function ms(e){return e.getCoreRowModel()}function hs(e){return e._rowModels.filteredRowModel||(e._rowModels.filteredRowModel=e.options.features.filteredRowModel?.(e)),e.options.manualFiltering||!e._rowModels.filteredRowModel?e.getPreFilteredRowModel():e._rowModels.filteredRowModel()}function gs(e){return e.getFilteredRowModel()}function _s(e){return e._rowModels.groupedRowModel||(e._rowModels.groupedRowModel=e.options.features.groupedRowModel?.(e)),e.options.manualGrouping||!e._rowModels.groupedRowModel?e.getPreGroupedRowModel():e._rowModels.groupedRowModel()}function vs(e){return e.getGroupedRowModel()}function ys(e){return e._rowModels.sortedRowModel||(e._rowModels.sortedRowModel=e.options.features.sortedRowModel?.(e)),e.options.manualSorting||!e._rowModels.sortedRowModel?e.getPreSortedRowModel():e._rowModels.sortedRowModel()}function bs(e){return e.getSortedRowModel()}function xs(e){return e._rowModels.expandedRowModel||(e._rowModels.expandedRowModel=e.options.features.expandedRowModel?.(e)),e.options.manualExpanding||!e._rowModels.expandedRowModel?e.getPreExpandedRowModel():e._rowModels.expandedRowModel()}function Ss(e){return e.getExpandedRowModel()}function Cs(e){return e._rowModels.paginatedRowModel||(e._rowModels.paginatedRowModel=e.options.features.paginatedRowModel?.(e)),e.options.manualPagination||!e._rowModels.paginatedRowModel?e.getPrePaginatedRowModel():e._rowModels.paginatedRowModel()}function ws(e){return e.getPaginatedRowModel()}var Ts={constructTableAPIs:e=>{oo(`coreRowModelsFeature`,e,{table_getCoreRowModel:{fn:()=>ps(e)},table_getPreFilteredRowModel:{fn:()=>ms(e)},table_getFilteredRowModel:{fn:()=>hs(e)},table_getPreGroupedRowModel:{fn:()=>gs(e)},table_getGroupedRowModel:{fn:()=>_s(e)},table_getPreSortedRowModel:{fn:()=>vs(e)},table_getSortedRowModel:{fn:()=>ys(e)},table_getPreExpandedRowModel:{fn:()=>bs(e)},table_getExpandedRowModel:{fn:()=>xs(e)},table_getPrePaginatedRowModel:{fn:()=>Ss(e)},table_getPaginatedRowModel:{fn:()=>Cs(e)},table_getRowModel:{fn:()=>ws(e)}})}};function Es(e){if(!e._cellPrototype){e._cellPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignCellPrototype?.(e._cellPrototype,e)}return e._cellPrototype}function Ds(e,t,n){let r=Es(n),i=Object.create(r);i.column=e,i.id=`${t.id}_${e.id}`,i.row=t;let a=n._cellInstanceInitFns;for(let e=0;e<a.length;e++)a[e](i);return i}function Os(e){let t=e.table.getRowsInDisplayOrder(),n=e._displayIndexCache;return t[n]===e?n:-1}function ks(e){let t=e.getPrePaginatedRowModel().rows;if(e.options.paginateExpandedRows===!1){let e=[],n=t=>{t._displayIndexCache=e.length,e.push(t),t.subRows.length&&t.getIsExpanded?.()&&t.subRows.forEach(n)};return t.forEach(n),e}for(let e=0;e<t.length;e++)t[e]._displayIndexCache=e;return t}function As(e,t){if(Ja(e._valuesCache,t))return e._valuesCache[t];let n=e.table.getColumn(t);if(n?.accessorFn)return e._valuesCache[t]=n.accessorFn(e.original,e.index),e._valuesCache[t]}function js(e,t){if(Ja(e._uniqueValuesCache,t))return e._uniqueValuesCache[t];let n=e.table.getColumn(t);if(n?.accessorFn)return n.columnDef.getUniqueValues?(e._uniqueValuesCache[t]=n.columnDef.getUniqueValues(e.original,e.index),e._uniqueValuesCache[t]):(e._uniqueValuesCache[t]=[e.getValue(t)],e._uniqueValuesCache[t])}function Ms(e,t){return e.getValue(t)??e.table.options.renderFallbackValue}function Ns(e){return to(e.subRows,e=>e.subRows)}function Ps(e){let t=e.getCoreRowModel().flatRows,n=0;for(let e=0;e<t.length;e++)n=Math.max(n,t[e].depth);return n}function Fs(e){if(e.parentId)return e.table.getCoreRowModel().rowsById[e.parentId]??e.table.getRow(e.parentId,!0)}function Is(e){let t=[],n=e;for(;;){let e=n.getParentRow();if(!e)break;t.push(e),n=e}return t.reverse()}function Ls(e){let t=e.table.getAllLeafColumns(),n=e._cellsCache;n||=e._cellsCache=new WeakMap;let r=Array(t.length);for(let i=0;i<t.length;i++){let a=t[i],o=n.get(a);o||(o=Ds(a,e,e.table),n.set(a,o)),r[i]=o}return r}function Rs(e){let t=qa(),n=e.getAllCells();for(let e=0;e<n.length;e++){let r=n[e];t[r.column.id]=r}return t}function zs(e,t,n,r){return t.options.getRowId?.(e,n,r)??(r?`${r.id}.${n}`:String(n))}function Bs(e,t,n){let r=(n?e.getPrePaginatedRowModel():e.getRowModel()).rowsById[t];if(!r&&(r=e.getCoreRowModel().rowsById[t],!r))throw Error();return r}var Vs={assignRowPrototype:(e,t)=>{so(`coreRowsFeature`,e,t,{row_getDisplayIndex:{fn:e=>Os(e)},row_getAllCellsByColumnId:{fn:e=>Rs(e),memoDeps:e=>[e.getAllCells()]},row_getAllCells:{fn:e=>Ls(e),memoDeps:e=>[e.table.getAllLeafColumns()]},row_getLeafRows:{fn:e=>Ns(e),memoDeps:e=>[e.subRows]},row_getParentRow:{fn:e=>Fs(e)},row_getParentRows:{fn:e=>Is(e)},row_getUniqueValues:{fn:(e,t)=>js(e,t)},row_getValue:{fn:(e,t)=>As(e,t)},row_renderValue:{fn:(e,t)=>Ms(e,t)}})},constructTableAPIs:e=>{oo(`coreRowsFeature`,e,{table_getRowsInDisplayOrder:{fn:()=>ks(e),memoDeps:()=>[e.getPrePaginatedRowModel().rows,e.options.paginateExpandedRows,e.options.paginateExpandedRows===!1?e.atoms.expanded?.get():void 0]},table_getRowId:{fn:(t,n,r)=>zs(t,e,n,r)},table_getRow:{fn:(t,n)=>Bs(e,t,n)},table_getMaxSubRowDepth:{fn:()=>Ps(e),memoDeps:()=>[e.getCoreRowModel()]}})}};function Hs(e,t,n=(e,t)=>e===t){let r=t===void 0?e.options.state:t;e._reactivity.batch(()=>{if(r)for(let t in r){let i=e.baseAtoms[t];if(!i)continue;let a=r[t],o=a===void 0?e.initialState[t]:a;n(e._reactivity.untrack(()=>i.get()),o)||i.set(()=>o)}})}function Us(e,t,n=(e,t)=>e===t){e._reactivity.batch(()=>{Hs(e,t,n),e._reactivity.commit?.()})}function Ws(e){let t=Ka(e.initialState);e._reactivity.batch(()=>{let n=Object.keys(t);for(let r=0;r<n.length;r++){let i=n[r];e.baseAtoms[i].set(t[i])}});let n=Object.values(e._features);for(let t=0;t<n.length;t++)n[t].resetTableInstanceData?.(e)}function Gs(e,t){let{features:n,atoms:r,initialState:i}=e.options;if(!e.options.mergeOptions)return{...e.options,...t,features:n,atoms:r,initialState:i};let a=e.options.mergeOptions(e.options,t),o={...Object.getOwnPropertyDescriptors(a)};return Object.defineProperties(Object.create(Object.getPrototypeOf(a)),{...o,features:{value:n,enumerable:!0,configurable:!0,writable:!0},atoms:{value:r,enumerable:!0,configurable:!0,writable:!0},initialState:{value:i,enumerable:!0,configurable:!0,writable:!0}})}function Ks(e,t,n){let r=Gs(e,Ga(t,e.options));e.optionsStore?e.optionsStore.set(()=>r):e.options=r,n?.syncExternalState!==!1&&Us(e,r.state??null)}var qs={coreCellsFeature:po,coreColumnsFeature:Bo,coreHeadersFeature:Jo,coreRowModelsFeature:Ts,coreRowsFeature:Vs,coreTablesFeature:{constructTableAPIs:e=>{oo(`coreTablesFeature`,e,{table_reset:{fn:()=>Ws(e)},table_setOptions:{fn:t=>Ks(e,t)}})}}};function Js(){return{accessor:(e,t)=>typeof e==`function`?{...t,accessorFn:e}:{...t,accessorKey:e},columns:e=>e,display:e=>e,group:e=>e}}function Ys(e){return e}function Xs(e,t={}){return Object.values(e).forEach(e=>{t=e.getInitialState?.(t)??t}),Ka(t)}function Zs(e){let t=e.features.coreReactivityFeature,{aggregationFns:n,columnMeta:r,coreRowModel:i,expandedRowModel:a,facetedMinMaxValues:o,facetedRowModel:s,facetedUniqueValues:c,filterFns:l,filterMeta:u,filteredRowModel:d,groupedRowModel:f,paginatedRowModel:p,sortFns:m,sortedRowModel:h,tableMeta:g,..._}=e.features,v={_cellInstanceInitFns:[],_columnInstanceInitFns:[],_features:{...qs,..._},_headerGroupInstanceInitFns:[],_headerInstanceInitFns:[],_reactivity:t,_rowInstanceInitFns:[],_rowModelFns:{aggregationFns:n,filterFns:l,sortFns:m},_rowModels:{},atoms:{},baseAtoms:{}},y=Object.values(v._features),b={...y.reduce((e,t)=>Object.assign(e,t.getDefaultTableOptions?.(v)),{}),...e};if(t.wrapExternalAtoms&&b.atoms)for(let[e,n]of Object.entries(b.atoms)){let r=n,i=t.createWritableAtom(r.get(),{debugName:`externalAtom/${e}`});b.atoms[e]=i;let a=!1,o=r.subscribe(e=>{a||i.set(e)}),s=i.subscribe(e=>{a=!0,r.set(e),a=!1});t.addSubscription(o),t.addSubscription(s)}t.createOptionsStore?(v.optionsStore=t.createWritableAtom(b,{debugName:`table/optionsStore`}),Object.defineProperty(v,"options",{configurable:!0,enumerable:!0,get(){return v.optionsStore.get()},set(e){v.optionsStore.set(()=>e)}})):v.options=b,v.initialState=Xs(v._features,v.options.initialState);let x=Object.keys(v.initialState);for(let e=0;e<x.length;e++){let n=x[e];v.baseAtoms[n]=t.createWritableAtom(v.initialState[n],{debugName:`table/baseAtoms/${n}`}),v.atoms[n]=t.createReadonlyAtom(()=>{let e=v.options,t=e.atoms?.[n],r=t?t.get():v.baseAtoms[n].get();if(t)return r;let i=e.state;if(i&&Ja(i,n)){let e=i[n];return e===void 0?v.initialState[n]:e}return r},{debugName:`table/atoms/${n}`})}Hs(v),v.store=Va(t.createReadonlyAtom(()=>{let e={};for(let t=0;t<x.length;t++){let n=x[t];e[n]=v.atoms[n].get()}return e},{compare:Ma,debugName:`table/store`}));for(let e=0;e<y.length;e++){let t=y[e];t.initTableInstanceData?.(v),t.initCellInstanceData&&v._cellInstanceInitFns.push(t.initCellInstanceData.bind(t)),t.initColumnInstanceData&&v._columnInstanceInitFns.push(t.initColumnInstanceData.bind(t)),t.initHeaderGroupInstanceData&&v._headerGroupInstanceInitFns.push(t.initHeaderGroupInstanceData.bind(t)),t.initHeaderInstanceData&&v._headerInstanceInitFns.push(t.initHeaderInstanceData.bind(t)),t.initRowInstanceData&&v._rowInstanceInitFns.push(t.initRowInstanceData.bind(t)),t.constructTableAPIs?.(v)}return v}var Qs=typeof window>`u`?s.useEffect:s.useLayoutEffect;function $s(e,t){let[{table:n,rootSource:r}]=(0,s.useState)(()=>{let t=Zs({...e,features:{coreReactivityFeature:Wa(),...e.features}});return t.Subscribe=(e=>Ba({...e,source:e.source??t.store})),t.FlexRender=pa,{table:t,rootSource:Ua(t.store,Ma)}}),i=n;Ks(i,t=>({...t,...e}),{syncExternalState:!1});let a=i.options.state,o=r.get(),c=za(r,t,{compare:Ma});return Qs(()=>{r.markCommitted(o),Us(i,a??null,Ma)}),(0,s.useMemo)(()=>({...n,options:e,state:c}),[n,e,c])}var ec=Ys({});function tc(e){return typeof e==`number`?`${e}px`:e}function nc(e){return e instanceof Element&&!!e.closest(`button, a, input, select, textarea, [role='button']`)}function rc({columns:e,data:t,getRowId:n,caption:r,minWidth:i=880,loading:a=!1,error:o=``,onRetry:c,empty:l={title:`没有数据`},pagination:u,onRowActivate:d,rowAriaLabel:f}){let p=(0,s.useMemo)(()=>Js(),[]),m=$s({features:ec,columns:(0,s.useMemo)(()=>p.columns(e.map(e=>p.display({id:e.id,header:()=>e.header,cell:t=>e.cell(t.row.original)}))),[e,p]),data:t,getRowId:n}),h=(e,t)=>{!d||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),d(t))},g=u&&t.length?u.pageIndex*u.pageSize+1:0,_=u?Math.min(u.pageIndex*u.pageSize+t.length,u.total):0;return(0,W.jsxs)(`div`,{className:`studio-data-table`,"aria-busy":a||void 0,children:[(0,W.jsxs)(`div`,{className:`studio-data-table-scroll data-scroll-region`,children:[!a&&!o&&(0,W.jsxs)(`table`,{style:{minWidth:tc(i)},children:[r&&(0,W.jsx)(`caption`,{className:`sr-only`,children:r}),(0,W.jsx)(`thead`,{children:m.getHeaderGroups().map(t=>(0,W.jsx)(`tr`,{children:t.headers.map((t,n)=>{let r=e[n],i={width:tc(r?.width),minWidth:tc(r?.minWidth)};return(0,W.jsx)(`th`,{className:r?.headerClassName,style:i,children:t.isPlaceholder?null:(0,W.jsx)(m.FlexRender,{header:t})},t.id)})},t.id))}),(0,W.jsx)(`tbody`,{children:m.getRowModel().rows.map(t=>(0,W.jsx)(`tr`,{className:d?`is-interactive`:void 0,tabIndex:d?0:void 0,"aria-label":f?.(t.original),onKeyDown:e=>h(e,t.original),onClick:e=>{d&&!nc(e.target)&&d(t.original)},children:t.getAllCells().map((t,n)=>(0,W.jsx)(`td`,{className:e[n]?.className,children:(0,W.jsx)(m.FlexRender,{cell:t})},t.id))},t.id))})]}),a&&(0,W.jsxs)(`div`,{className:`studio-data-table-state`,role:`status`,children:[(0,W.jsx)(_e,{className:`animate-spin`,size:20}),(0,W.jsx)(`strong`,{children:`正在加载`}),(0,W.jsx)(`span`,{children:`正在同步最新数据…`})]}),!a&&o&&(0,W.jsxs)(`div`,{className:`studio-data-table-state is-error`,role:`alert`,children:[(0,W.jsx)(I,{size:20}),(0,W.jsx)(`strong`,{children:`加载失败`}),(0,W.jsx)(`span`,{children:o}),c&&(0,W.jsx)(`button`,{className:`button secondary small`,type:`button`,onClick:c,children:`重新加载`})]}),!a&&!o&&t.length===0&&(0,W.jsxs)(`div`,{className:`studio-data-table-state is-empty`,children:[l.icon&&(0,W.jsx)(`span`,{className:`empty-icon`,children:l.icon}),(0,W.jsx)(`strong`,{children:l.title}),l.description&&(0,W.jsx)(`span`,{children:l.description}),l.action]})]}),u&&!a&&!o&&(0,W.jsxs)(`footer`,{className:`studio-data-table-pagination`,children:[(0,W.jsxs)(`span`,{children:[`第 `,u.pageIndex+1,` 页 · `,g,`–`,_,` / `,u.total,` 条`]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`button`,{className:`button tertiary small`,type:`button`,disabled:u.pageIndex<=0,onClick:u.onPreviousPage,children:[(0,W.jsx)(N,{size:14}),`上一页`]}),(0,W.jsxs)(`button`,{className:`button tertiary small`,type:`button`,disabled:!u.hasNextPage,onClick:u.onNextPage,children:[`下一页`,(0,W.jsx)(P,{size:14})]})]})]})]})}var ic=Object.defineProperty,ac=(e,t)=>ic(e,`name`,{value:t,configurable:!0});function oc(e,[t,n]){return Math.min(n,Math.max(t,e))}ac(oc,`clamp`);var sc=Object.defineProperty,cc=(e,t)=>sc(e,`name`,{value:t,configurable:!0});function lc(e){let t=e+`CollectionProvider`,[n,r]=vt(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=cc(e=>{let{scope:t,children:n}=e,r=s.useRef(null),a=s.useRef(new Map).current;return(0,W.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let c=e+`CollectionSlot`,l=Ht(c),u=s.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=mt(t,a(c,n).collectionRef);return(0,W.jsx)(l,{ref:i,children:r})});u.displayName=c;let d=e+`CollectionItemSlot`,f=`data-radix-collection-item`,p=Ht(d),m=s.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=s.useRef(null),c=mt(t,o),l=a(d,n);return s.useEffect(()=>(l.itemMap.set(o,{ref:o,...i}),()=>void l.itemMap.delete(o))),(0,W.jsx)(p,{[f]:``,ref:c,children:r})});m.displayName=d;function h(t){let n=a(e+`CollectionConsumer`,t);return s.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return cc(h,`useCollection`),[{Provider:o,Slot:u,ItemSlot:m},h,r]}cc(lc,`createCollection`);var uc=new WeakMap,dc=class e extends Map{static{cc(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],uc.set(this,!0)}set(e,t){return uc.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=mc(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=fc(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=fc(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return fc(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function fc(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=pc(e,t);return n===-1?void 0:e[n]}cc(fc,`at`);function pc(e,t){let n=e.length,r=mc(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}cc(pc,`toSafeIndex`);function mc(e){return e!==e||e===0?0:Math.trunc(e)}cc(mc,`toSafeInteger`);function hc(e){let t=e+`CollectionProvider`,[n,r]=vt(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new dc,setItemMap:cc(()=>void 0,`setItemMap`)}),o=cc(({state:e,...t})=>e?(0,W.jsx)(l,{...t,state:e}):(0,W.jsx)(c,{...t}),`CollectionProvider`);o.displayName=t;let c=cc(e=>{let t=g();return(0,W.jsx)(l,{...e,state:t})},`CollectionInit`);c.displayName=t+`Init`;let l=cc(e=>{let{scope:t,children:n,state:r}=e,a=s.useRef(null),[o,c]=s.useState(null),l=mt(a,c),[u,d]=r;return s.useEffect(()=>{if(!o)return;let e=yc(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,W.jsx)(i,{scope:t,itemMap:u,setItemMap:d,collectionRef:l,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);l.displayName=t+`Impl`;let u=e+`CollectionSlot`,d=Ht(u),f=s.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=mt(t,a(u,n).collectionRef);return(0,W.jsx)(d,{ref:i,children:r})});f.displayName=u;let p=e+`CollectionItemSlot`,m=Ht(p),h=s.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=s.useRef(null),[c,l]=s.useState(null),u=mt(t,o,l),{setItemMap:d}=a(p,n),f=s.useRef(i);gc(f.current,i)||(f.current=i);let h=f.current;return s.useEffect(()=>{let e=h;return d(t=>c?t.has(c)?t.set(c,{...e,element:c}).toSorted(vc):(t.set(c,{...e,element:c}),t.toSorted(vc)):t),()=>{d(e=>!c||!e.has(c)?e:(e.delete(c),new dc(e)))}},[c,h,d]),(0,W.jsx)(m,{"data-radix-collection-item":``,ref:u,children:r})});h.displayName=p;function g(){return s.useState(new dc)}cc(g,`useInitCollection`);function _(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return cc(_,`useCollection`),[{Provider:o,Slot:f,ItemSlot:h},{createCollectionScope:r,useCollection:_,useInitCollection:g}]}cc(hc,`createCollection`);function gc(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}cc(gc,`shallowEqual`);function _c(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}cc(_c,`isElementPreceding`);function vc(e,t){return!e[1].element||!t[1].element?0:_c(e[1].element,t[1].element)?-1:1}cc(vc,`sortByDocumentPosition`);function yc(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}cc(yc,`getChildListObserver`);var bc=Object.defineProperty,xc=(e,t)=>bc(e,`name`,{value:t,configurable:!0}),Sc=s.createContext(void 0);function Cc(e){let t=s.useContext(Sc);return e||t||`ltr`}xc(Cc,`useDirection`);var wc=[`top`,`right`,`bottom`,`left`],Tc=Math.min,Ec=Math.max,Dc=Math.round,Oc=Math.floor,kc=e=>({x:e,y:e}),Ac={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function jc(e,t,n){return Ec(e,Tc(t,n))}function Mc(e,t){return typeof e==`function`?e(t):e}function Nc(e){return e.split(`-`)[0]}function Pc(e){return e.split(`-`)[1]}function Fc(e){return e===`x`?`y`:`x`}function Ic(e){return e===`y`?`height`:`width`}function Lc(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Rc(e){return Fc(Lc(e))}function zc(e,t,n){n===void 0&&(n=!1);let r=Pc(e),i=Rc(e),a=Ic(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Jc(o)),[o,Jc(o)]}function Bc(e){let t=Jc(e);return[Vc(e),t,Vc(t)]}function Vc(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Hc=[`left`,`right`],Uc=[`right`,`left`],Wc=[`top`,`bottom`],Gc=[`bottom`,`top`];function Kc(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Uc:Hc:t?Hc:Uc;case`left`:case`right`:return t?Wc:Gc;default:return[]}}function qc(e,t,n,r){let i=Pc(e),a=Kc(Nc(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Vc)))),a}function Jc(e){let t=Nc(e);return Ac[t]+e.slice(t.length)}function Yc(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Xc(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Yc(e)}function Zc(e){let{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 Qc(e,t,n){let{reference:r,floating:i}=e,a=Lc(t),o=Rc(t),s=Ic(o),c=Nc(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Pc(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function $c(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Mc(t,e),p=Xc(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Zc(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Zc(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var el=50,tl=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:$c},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Qc(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<el&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Qc(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},nl=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Mc(e,t)||{};if(l==null)return{};let d=Xc(u),f={x:n,y:r},p=Rc(i),m=Ic(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Tc(d[_],T),D=Tc(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=jc(E,k,O),j=!c.arrow&&Pc(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),rl=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Mc(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Nc(r),_=Lc(o),v=Nc(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Jc(o)]:Bc(o)),x=p!==`none`;!d&&x&&b.push(...qc(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=zc(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Lc(t)||T.every(e=>Lc(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Lc(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function il(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function al(e){return wc.some(t=>e[t]>=0)}var ol=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Mc(e,t);switch(i){case`referenceHidden`:{let e=il(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:al(e)}}}case`escaped`:{let e=il(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:al(e)}}}default:return{}}}}},sl=new Set([`left`,`top`]);async function cl(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Nc(n),s=Pc(n),c=Lc(n)===`y`,l=sl.has(o)?-1:1,u=a&&c?-1:1,d=Mc(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var ll=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await cl(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},ul=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Mc(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Lc(i),p=Fc(f),m=u[p],h=u[f],g=(e,t)=>jc(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},dl=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Mc(e,t),u={x:n,y:r},d=Lc(i),f=Fc(d),p=u[f],m=u[d],h=Mc(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=sl.has(Nc(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},fl=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=Mc(e,t),c=await i.detectOverflow(t,s),l=Nc(n),u=Pc(n),d=Lc(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Tc(p-c[m],g),y=Tc(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Ec(c.left,c.right):S=p-2*Ec(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function pl(){return typeof window<`u`}function ml(e){return _l(e)?(e.nodeName||``).toLowerCase():`#document`}function hl(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function gl(e){return((_l(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function _l(e){return pl()?e instanceof Node||e instanceof hl(e).Node:!1}function vl(e){return pl()?e instanceof Element||e instanceof hl(e).Element:!1}function yl(e){return pl()?e instanceof HTMLElement||e instanceof hl(e).HTMLElement:!1}function bl(e){return!pl()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof hl(e).ShadowRoot}function xl(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Ml(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Sl(e){return/^(table|td|th)$/.test(ml(e))}function Cl(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var wl=/transform|translate|scale|rotate|perspective|filter/,Tl=/paint|layout|strict|content/,El=e=>!!e&&e!==`none`,Dl;function Ol(e){let t=vl(e)?Ml(e):e;return El(t.transform)||El(t.translate)||El(t.scale)||El(t.rotate)||El(t.perspective)||!Al()&&(El(t.backdropFilter)||El(t.filter))||wl.test(t.willChange||``)||Tl.test(t.contain||``)}function kl(e){let t=Pl(e);for(;yl(t)&&!jl(t);){if(Ol(t))return t;if(Cl(t))return null;t=Pl(t)}return null}function Al(){return Dl??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Dl}function jl(e){return/^(html|body|#document)$/.test(ml(e))}function Ml(e){return hl(e).getComputedStyle(e)}function Nl(e){return vl(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Pl(e){if(ml(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||bl(e)&&e.host||gl(e);return bl(t)?t.host:t}function Fl(e){let t=Pl(e);return jl(t)?(e.ownerDocument||e).body:yl(t)&&xl(t)?t:Fl(t)}function Il(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Fl(e),i=r===e.ownerDocument?.body,a=hl(r);if(i){let e=Ll(a);return t.concat(a,a.visualViewport||[],xl(r)?r:[],e&&n?Il(e):[])}return t.concat(r,Il(r,[],n))}function Ll(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Rl(e){let t=Ml(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=yl(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Dc(n)!==a||Dc(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function zl(e){return vl(e)?e:e.contextElement}function Bl(e){let t=zl(e);if(!yl(t))return kc(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Rl(t),o=(a?Dc(n.width):n.width)/r,s=(a?Dc(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Vl=kc(0);function Hl(e){let t=hl(e);return!Al()||!t.visualViewport?Vl:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ul(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===hl(e)}function Wl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=zl(e),o=kc(1);t&&(r?vl(r)&&(o=Bl(r)):o=Bl(e));let s=Ul(a,n,r)?Hl(a):kc(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=hl(a),t=vl(r)?hl(r):r,n=e,i=Ll(n);for(;i&&t!==n;){let e=Bl(i),t=i.getBoundingClientRect(),r=Ml(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=hl(i),i=Ll(n)}}return Zc({width:u,height:d,x:c,y:l})}function Gl(e,t){let n=Nl(e).scrollLeft;return t?t.left+n:Wl(gl(e)).left+n}function Kl(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Gl(e,n),y:n.top+t.scrollTop}}function ql(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=gl(r),s=t?Cl(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=kc(1),u=kc(0),d=yl(r);if((d||!a)&&((ml(r)!==`body`||xl(o))&&(c=Nl(r)),d)){let e=Wl(r);l=Bl(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Kl(o,c):kc(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Jl(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Yl(e){let t=Nl(e),n=e.ownerDocument.body,r=Ec(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Ec(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Gl(e),o=-t.scrollTop;return Ml(n).direction===`rtl`&&(a+=Ec(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var Xl=25;function Zl(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=hl(e),a=gl(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Al()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Gl(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=Xl&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Ql(e,t){let n=Wl(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Bl(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function $l(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Zl(e,n,t);else if(t===`document`)r=Yl(gl(e));else if(vl(t))r=Ql(t,n);else{let n=Hl(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Zc(r)}function eu(e,t){let n=t.get(e);if(n)return n;let r=Il(e,[],!1).filter(e=>vl(e)&&ml(e)!==`body`),i=null,a=Ml(e).position===`fixed`,o=a?Pl(e):e;for(;vl(o)&&!jl(o);){let e=Ml(o),t=Ol(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Pl(o)}return t.set(e,r),r}function tu(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Cl(t)?[]:eu(t,this._c):[].concat(n),r],o=$l(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=$l(t,a[e],i);s=Ec(n.top,s),c=Tc(n.right,c),l=Tc(n.bottom,l),u=Ec(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function nu(e){let{width:t,height:n}=Rl(e);return{width:t,height:n}}function ru(e,t,n){let r=yl(t),i=gl(t),a=n===`fixed`,o=Wl(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=kc(0);if((r||!a)&&((ml(t)!==`body`||xl(i))&&(s=Nl(t)),r)){let e=Wl(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Gl(i));let l=i&&!r&&!a?Kl(i,s):kc(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function iu(e){return Ml(e).position===`static`}function au(e,t){if(!yl(e)||Ml(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return gl(e)===n&&(n=n.ownerDocument.body),n}function ou(e,t){let n=hl(e);if(Cl(e))return n;if(!yl(e)){let t=Pl(e);for(;t&&!jl(t);){if(vl(t)&&!iu(t))return t;t=Pl(t)}return n}let r=au(e,t);for(;r&&Sl(r)&&iu(r);)r=au(r,t);return r&&jl(r)&&iu(r)&&!Ol(r)?n:r||kl(e)||n}var su=async function(e){let t=this.getOffsetParent||ou,n=this.getDimensions,r=await n(e.floating);return{reference:ru(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function cu(e){return Ml(e).direction===`rtl`}var lu={convertOffsetParentRelativeRectToViewportRelativeRect:ql,getDocumentElement:gl,getClippingRect:tu,getOffsetParent:ou,getElementRects:su,getClientRects:Jl,getDimensions:nu,getScale:Bl,isElement:vl,isRTL:cu};function uu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function du(e,t,n){let r=null,i,a=gl(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Oc(d),h=Oc(a.clientWidth-(u+f)),g=Oc(a.clientHeight-(d+p)),_=Oc(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Ec(0,Tc(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!uu(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=hl(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function fu(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=zl(e),u=i||a?[...l?Il(l):[],...t?Il(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?du(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Wl(e):null;c&&g();function g(){let t=Wl(e);h&&!uu(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var pu=ll,mu=ul,hu=rl,gu=fl,_u=ol,vu=nl,yu=dl,bu=(e,t,n)=>{let r=new Map,i=n??{},a={...lu,...i.platform,_c:r};return tl(e,t,{...i,platform:a})},xu=typeof document<`u`?s.useLayoutEffect:function(){};function Su(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(!Su(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;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Su(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Cu(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function wu(e,t){let n=Cu(e);return Math.round(t*n)/n}function Tu(e){let t=s.useRef(e);return xu(()=>{t.current=e}),t}function Eu(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:c=!0,whileElementsMounted:l,open:u}=e,[d,f]=s.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=s.useState(r);Su(p,r)||m(r);let[h,g]=s.useState(null),[_,v]=s.useState(null),y=s.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=s.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=s.useRef(null),w=s.useRef(null),T=s.useRef(d),E=l!=null,D=Tu(l),O=Tu(i),k=Tu(u),A=s.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};O.current&&(e.platform=O.current),bu(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!Su(T.current,t)&&(T.current=t,zt.flushSync(()=>{f(t)}))})},[p,t,n,O,k]);xu(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[u]);let j=s.useRef(!1);xu(()=>(j.current=!0,()=>{j.current=!1}),[]),xu(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=s.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=s.useMemo(()=>({reference:x,floating:S}),[x,S]),P=s.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=wu(N.floating,d.x),r=wu(N.floating,d.y);return c?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Cu(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,c,N.floating,d.x,d.y]);return s.useMemo(()=>({...d,update:A,refs:M,elements:N,floatingStyles:P}),[d,A,M,N,P])}var Du=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:vu({element:r.current,padding:i}).fn(n):r?vu({element:r,padding:i}).fn(n):{}}}},Ou=(e,t)=>{let n=pu(e);return{name:n.name,fn:n.fn,options:[e,t]}},ku=(e,t)=>{let n=mu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Au=(e,t)=>({fn:yu(e).fn,options:[e,t]}),ju=(e,t)=>{let n=hu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Mu=(e,t)=>{let n=gu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Nu=(e,t)=>{let n=_u(e);return{name:n.name,fn:n.fn,options:[e,t]}},Pu=(e,t)=>{let n=Du(e);return{name:n.name,fn:n.fn,options:[e,t]}},Fu=Object.defineProperty,Iu=s.forwardRef(((e,t)=>Fu(e,`name`,{value:t,configurable:!0}))(function(e,t){let{children:n,width:r=10,height:i=5,...a}=e;return(0,W.jsx)(rn.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,W.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})},`Arrow`)),Lu=Object.defineProperty,Ru=(e,t)=>Lu(e,`name`,{value:t,configurable:!0});function zu(e){let[t,n]=s.useState(void 0);return bt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}Ru(zu,`useSize`);var Bu=Object.defineProperty,Vu=(e,t)=>Bu(e,`name`,{value:t,configurable:!0}),Hu=`Popper`,[Uu,Wu]=vt(Hu),[Gu,Ku]=Uu(Hu),qu=Vu(e=>{let{__scopePopper:t,children:n}=e,[r,i]=s.useState(null),[a,o]=s.useState(void 0);return(0,W.jsx)(Gu,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),Ju=`PopperAnchor`,Yu=s.forwardRef(Vu(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=Ku(Ju,n),o=s.useRef(null),c=a.onAnchorChange,l=mt(t,s.useCallback(e=>{o.current=e,e&&c(e)},[c])),u=s.useRef(null);s.useEffect(()=>{if(!r)return;let e=u.current;u.current=r.current,e!==u.current&&c(u.current)});let d=a.placementState&&ad(a.placementState),f=d?.[0],p=d?.[1];return r?null:(0,W.jsx)(rn.div,{"data-radix-popper-side":f,"data-radix-popper-align":p,...i,ref:l})},`PopperAnchor`)),Xu=`PopperContent`,[Zu,Qu]=Uu(Xu),$u=s.forwardRef(Vu(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f=`partial`,hideWhenDetached:p=!1,updatePositionStrategy:m=`optimized`,onPlaced:h,...g}=e,_=Ku(Xu,n),[v,y]=s.useState(null),b=mt(t,y),[x,S]=s.useState(null),C=zu(x),w=C?.width??0,T=C?.height??0,E=r+(a===`center`?``:`-`+a),D=typeof d==`number`?d:{top:0,right:0,bottom:0,left:0,...d},O=Array.isArray(u)?u:[u],k=O.length>0,A={padding:D,boundary:O.filter(rd),altBoundary:k},{refs:j,floatingStyles:M,placement:N,isPositioned:P,middlewareData:F}=Eu({strategy:`fixed`,placement:E,whileElementsMounted:Vu((...e)=>fu(...e,{animationFrame:m===`always`}),`whileElementsMounted`),elements:{reference:_.anchor},middleware:[Ou({mainAxis:i+T,alignmentAxis:o}),l&&ku({mainAxis:!0,crossAxis:!1,limiter:f===`partial`?Au():void 0,...A}),l&&ju({...A}),Mu({...A,apply:Vu(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),x&&Pu({element:x,padding:c}),id({arrowWidth:w,arrowHeight:T}),p&&Nu({strategy:`referenceHidden`,...A,boundary:k?A.boundary:void 0})]}),I=_.setPlacementState;bt(()=>(I(N),()=>{I(void 0)}),[N,I]);let[L,R]=ad(N),z=cn(h);bt(()=>{P&&z?.()},[P,z]);let B=F.arrow?.x,V=F.arrow?.y,H=F.arrow?.centerOffset!==0,[U,ee]=s.useState();return bt(()=>{v&&ee(window.getComputedStyle(v).zIndex)},[v]),(0,W.jsx)(`div`,{ref:j.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:P?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:U,"--radix-popper-transform-origin":[F.transformOrigin?.x,F.transformOrigin?.y].join(` `),...F.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,W.jsx)(Zu,{scope:n,placedSide:L,placedAlign:R,onArrowChange:S,arrowX:B,arrowY:V,shouldHideArrow:H,children:(0,W.jsx)(rn.div,{"data-side":L,"data-align":R,...g,ref:b,style:{...g.style,animation:P?g.style?.animation:`none`}})})})},`PopperContent`)),ed=`PopperArrow`,td={top:`bottom`,right:`left`,bottom:`top`,left:`right`},nd=s.forwardRef(Vu(function(e,t){let{__scopePopper:n,...r}=e,i=Qu(ed,n),a=td[i.placedSide];return(0,W.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,W.jsx)(Iu,{...r,ref:t,style:{...r.style,display:`block`}})})},`PopperArrow`));function rd(e){return e!==null}Vu(rd,`isNotNull`);var id=Vu(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=ad(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function ad(e){let[t,n=`center`]=e.split(`-`);return[t,n]}Vu(ad,`getSideAndAlignFromPlacement`);var od=qu,sd=Yu,cd=$u,ld=nd,ud=Object.defineProperty,dd=(e,t)=>ud(e,`name`,{value:t,configurable:!0});function fd(e){let t=s.useRef({value:e,previous:e});return s.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}dd(fd,`usePrevious`);var pd=Object.defineProperty,md=(e,t)=>pd(e,`name`,{value:t,configurable:!0}),hd=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),gd=s.forwardRef(md(function(e,t){return(0,W.jsx)(rn.span,{...e,ref:t,style:{...hd,...e.style}})},`VisuallyHidden`)),_d=Object.defineProperty,vd=(e,t)=>_d(e,`name`,{value:t,configurable:!0}),yd=[` `,`Enter`,`ArrowUp`,`ArrowDown`],bd=[` `,`Enter`],xd=`Select`,[Sd,Cd,wd]=lc(xd),[Td,Ed]=vt(xd,[wd,Wu]),Dd=Wu(),[Od,kd]=Td(xd),[Ad,jd]=Td(xd);function Md(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:c,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:p,required:m,form:h,internal_do_not_use_render:g}=e,_=Dd(t),[v,y]=s.useState(null),[b,x]=s.useState(null),[S,C]=s.useState(!1),w=Cc(u),[T,E]=Pt({prop:r,defaultProp:i??!1,onChange:a,caller:xd}),[D,O]=Pt({prop:o,defaultProp:c,onChange:l,caller:xd}),k=s.useRef(null),A=s.useRef(D);s.useEffect(()=>{let e=h?v?.ownerDocument.getElementById(h):v?.form;if(e instanceof HTMLFormElement){let t=vd(()=>O(A.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[h,v,O]);let j=!v||!!h||!!v.closest(`form`),[M,N]=s.useState(new Set),P=Tt(),F=Array.from(M).map(e=>e.props.value).join(`;`),I=s.useCallback(e=>{N(t=>new Set(t).add(e))},[]),L=s.useCallback(e=>{N(t=>{let n=new Set(t);return n.delete(e),n})},[]),R={required:m,trigger:v,onTriggerChange:y,valueNode:b,onValueNodeChange:x,valueNodeHasChildren:S,onValueNodeHasChildrenChange:C,contentId:P,value:D,onValueChange:O,open:T,onOpenChange:E,dir:w,triggerPointerDownPosRef:k,disabled:p,name:d,autoComplete:f,form:h,nativeOptions:M,nativeSelectKey:F,isFormControl:j};return(0,W.jsx)(od,{..._,children:(0,W.jsx)(Od,{scope:t,...R,children:(0,W.jsx)(Sd.Provider,{scope:t,children:(0,W.jsx)(Ad,{scope:t,onNativeOptionAdd:I,onNativeOptionRemove:L,children:bf(g)?g(R):n})})})})}vd(Md,`SelectProvider`);var Nd=vd(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,W.jsx)(Md,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,W.jsxs)(W.Fragment,{children:[n,e?(0,W.jsx)(yf,{__scopeSelect:t}):null]})})},`Select`),Pd=`SelectTrigger`,Fd=s.forwardRef(vd(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Dd(n),o=kd(Pd,n),c=o.disabled||r,l=mt(t,o.onTriggerChange),u=Cd(n),d=s.useRef(`touch`),[f,p,m]=Sf(e=>{let t=u().filter(e=>!e.disabled),n=Cf(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),h=vd(e=>{c||(o.onOpenChange(!0),m()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,W.jsx)(sd,{asChild:!0,...a,children:(0,W.jsx)(rn.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:c,"data-disabled":c?``:void 0,"data-placeholder":xf(o.value)?``:void 0,...i,ref:l,onClick:G(i.onClick,e=>{e.currentTarget.focus(),d.current!==`mouse`&&h(e)}),onPointerDown:G(i.onPointerDown,e=>{d.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(h(e),e.preventDefault())}),onKeyDown:G(i.onKeyDown,e=>{let t=f.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&p(e.key),!(t&&e.key===` `)&&yd.includes(e.key)&&(h(),e.preventDefault())})})})},`SelectTrigger`)),Id=`SelectValue`,Ld=s.forwardRef(vd(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...c}=e,l=kd(Id,n),{onValueNodeHasChildrenChange:u}=l,d=a!==void 0,f=mt(t,l.onValueNodeChange);bt(()=>{u(d)},[u,d]);let p=xf(l.value);return(0,W.jsx)(rn.span,{...c,asChild:!p&&c.asChild,ref:f,style:{pointerEvents:`none`},children:(0,W.jsx)(s.Fragment,{children:p?o:a},p?`placeholder`:`value`)})},`SelectValue`)),Rd=s.forwardRef(vd(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,W.jsx)(rn.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[zd,Bd]=Td(`SelectPortal`,{forceMount:void 0}),Vd=vd(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,W.jsx)(zd,{scope:e.__scopeSelect,forceMount:n,children:(0,W.jsx)(Vn,{asChild:!0,...r})})},`SelectPortal`),Hd=`SelectContent`,Ud=s.forwardRef(vd(function(e,t){let n=Bd(Hd,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=kd(Hd,e.__scopeSelect),[o,c]=s.useState();return bt(()=>{c(new DocumentFragment)},[]),(0,W.jsx)(Gn,{present:r||a.open,children:({present:e})=>e?(0,W.jsx)(Yd,{...i,ref:t}):(0,W.jsx)(Wd,{...i,fragment:o})})},`SelectContent`)),Wd=s.forwardRef(vd(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?zt.createPortal((0,W.jsx)(Kd,{scope:n,children:(0,W.jsx)(Sd.Slot,{scope:n,children:(0,W.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Gd=10,[Kd,qd]=Td(Hd),Jd=Ht(`SelectContent.RemoveScroll`),Yd=s.forwardRef(vd(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_,...v}=e,y=kd(Hd,n),[b,x]=s.useState(null),[S,C]=s.useState(null),w=mt(t,x),[T,E]=s.useState(null),[D,O]=s.useState(null),k=Cd(n),[A,j]=s.useState(!1),M=s.useRef(!1);s.useEffect(()=>{if(b)return Ci(b)},[b]),nr();let N=s.useCallback(e=>{let[t,...n]=k().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i))return},[k,S]),P=s.useCallback(()=>N([T,b]),[N,T,b]);s.useEffect(()=>{A&&P()},[A,P]);let{onOpenChange:F,triggerPointerDownPosRef:I}=y;s.useEffect(()=>{if(b){let e={x:0,y:0},t=vd(t=>{e={x:Math.abs(Math.round(t.pageX)-(I.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(I.current?.y??0))}},`handlePointerMove`),n=vd(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(b)||F(!1),document.removeEventListener(`pointermove`,t),I.current=null},`handlePointerUp`);return I.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[b,F,I]),s.useEffect(()=>{let e=vd(()=>F(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[F]);let[L,R]=Sf(e=>{let t=k().filter(e=>!e.disabled),n=Cf(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),z=s.useCallback((e,t,n)=>{let r=!M.current&&!n;(y.value!==void 0&&y.value===t||r)&&(E(e),r&&(M.current=!0))},[y.value]),B=s.useCallback(()=>b?.focus(),[b]),V=s.useCallback((e,t,n)=>{let r=!M.current&&!n;(y.value!==void 0&&y.value===t||r)&&O(e)},[y.value]),H=r===`popper`?Zd:Xd,U=H===Zd?{side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_}:{};return(0,W.jsx)(Kd,{scope:n,content:b,viewport:S,onViewportChange:C,itemRefCallback:z,selectedItem:T,onItemLeave:B,itemTextRefCallback:V,focusSelectedItem:P,selectedItemText:D,position:r,isPositioned:A,searchRef:L,children:(0,W.jsx)(mi,{as:Jd,allowPinchZoom:!0,children:(0,W.jsx)(On,{asChild:!0,trapped:y.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:G(i,e=>{y.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,W.jsx)(gn,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:(0,W.jsx)(H,{role:`listbox`,id:y.contentId,"data-state":y.open?`open`:`closed`,dir:y.dir,onContextMenu:e=>e.preventDefault(),...v,...U,onPlaced:()=>j(!0),ref:w,style:{display:`flex`,flexDirection:`column`,outline:`none`,...v.style},onKeyDown:G(v.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&R(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=k().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>N(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),Xd=s.forwardRef(vd(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=kd(Hd,n),o=qd(Hd,n),[c,l]=s.useState(null),[u,d]=s.useState(null),f=mt(t,d),p=Cd(n),m=s.useRef(!1),h=s.useRef(!0),{viewport:g,selectedItem:_,selectedItemText:v,focusSelectedItem:y}=o,b=s.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&u&&g&&_&&v){let e=a.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=v.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-Gd,d=oc(a,[Gd,Math.max(Gd,u-l)]);c.style.minWidth=s+`px`,c.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-Gd,d=oc(a,[Gd,Math.max(Gd,u-l)]);c.style.minWidth=s+`px`,c.style.right=d+`px`}let o=p(),s=window.innerHeight-Gd*2,l=g.scrollHeight,d=window.getComputedStyle(u),f=parseInt(d.borderTopWidth,10),h=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=f+h+l+b+y,S=Math.min(_.offsetHeight*5,x),C=window.getComputedStyle(g),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Gd,D=s-E,O=_.offsetHeight/2,k=_.offsetTop+O,A=f+h+k,j=x-A;if(A<=E){let e=o.length>0&&_===o[o.length-1].ref.current;c.style.bottom=`0px`;let t=u.clientHeight-g.offsetTop-g.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);c.style.height=n+`px`}else{let e=o.length>0&&_===o[0].ref.current;c.style.top=`0px`;let t=Math.max(E,f+g.offsetTop+(e?w:0)+O)+j;c.style.height=t+`px`,g.scrollTop=A-E+g.offsetTop}c.style.margin=`${Gd}px 0`,c.style.minHeight=S+`px`,c.style.maxHeight=s+`px`,r?.(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,c,u,g,_,v,a.dir,r]);bt(()=>b(),[b]);let[x,S]=s.useState();bt(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);let C=s.useCallback(e=>{e&&h.current===!0&&(b(),y?.(),h.current=!1)},[b,y]);return(0,W.jsx)(Qd,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:m,onScrollButtonChange:C,children:(0,W.jsx)(`div`,{ref:l,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,W.jsx)(rn.div,{...i,ref:f,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),Zd=s.forwardRef(vd(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Gd,...a}=e,o=Dd(n);return(0,W.jsx)(cd,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[Qd,$d]=Td(Hd,{}),ef=`SelectViewport`,tf=s.forwardRef(vd(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=qd(ef,n),o=$d(ef,n),c=mt(t,a.onViewportChange),l=s.useRef(0);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,W.jsx)(Sd.Slot,{scope:n,children:(0,W.jsx)(rn.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:c,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:G(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(l.current-t.scrollTop);if(e>0){let r=window.innerHeight-Gd*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}l.current=t.scrollTop})})})]})},`SelectViewport`)),[nf,rf]=Td(`SelectGroup`),af=`SelectItem`,[of,sf]=Td(af),cf=s.forwardRef(vd(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,c=kd(af,n),l=qd(af,n),u=c.value===r,[d,f]=s.useState(a??``),[p,m]=s.useState(!1),h=mt(t,cn(e=>l.itemRefCallback?.(e,r,i))),g=Tt(),_=s.useRef(`touch`),v=vd(()=>{i||(c.onValueChange(r),c.onOpenChange(!1))},`handleSelect`);return(0,W.jsx)(of,{scope:n,value:r,disabled:i,textId:g,isSelected:u,onItemTextChange:s.useCallback(e=>{f(t=>t||(e?.textContent??``).trim())},[]),children:(0,W.jsx)(Sd.ItemSlot,{scope:n,value:r,disabled:i,textValue:d,children:(0,W.jsx)(rn.div,{role:`option`,"aria-labelledby":g,"data-highlighted":p?``:void 0,"aria-selected":u&&p,"data-state":u?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:h,onFocus:G(o.onFocus,()=>m(!0)),onBlur:G(o.onBlur,()=>m(!1)),onClick:G(o.onClick,()=>{_.current!==`mouse`&&v()}),onPointerUp:G(o.onPointerUp,()=>{_.current===`mouse`&&v()}),onPointerDown:G(o.onPointerDown,e=>{_.current=e.pointerType}),onPointerMove:G(o.onPointerMove,e=>{_.current=e.pointerType,i?l.onItemLeave?.():_.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:G(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:G(o.onKeyDown,e=>{i||e.target!==e.currentTarget||(l.searchRef?.current===``||e.key!==` `)&&(bd.includes(e.key)&&v(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),lf=`SelectItemText`,uf=s.forwardRef(vd(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=kd(lf,n),c=qd(lf,n),l=sf(lf,n),u=jd(lf,n),[d,f]=s.useState(null),p=cn(e=>c.itemTextRefCallback?.(e,l.value,l.disabled)),m=mt(t,f,l.onItemTextChange,p),h=d?.textContent,g=s.useMemo(()=>(0,W.jsx)(`option`,{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:_,onNativeOptionRemove:v}=u;return bt(()=>(_(g),()=>v(g)),[_,v,g]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(rn.span,{id:l.textId,...a,ref:m}),l.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!xf(o.value)?zt.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),df=`SelectItemIndicator`,ff=s.forwardRef(vd(function(e,t){let{__scopeSelect:n,...r}=e;return sf(df,n).isSelected?(0,W.jsx)(rn.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),pf=`SelectScrollUpButton`,mf=s.forwardRef(vd(function(e,t){let n=qd(pf,e.__scopeSelect),r=$d(pf,e.__scopeSelect),[i,a]=s.useState(!1),o=mt(t,r.onScrollButtonChange);return bt(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};vd(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,W.jsx)(_f,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),hf=`SelectScrollDownButton`,gf=s.forwardRef(vd(function(e,t){let n=qd(hf,e.__scopeSelect),r=$d(hf,e.__scopeSelect),[i,a]=s.useState(!1),o=mt(t,r.onScrollButtonChange);return bt(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};vd(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,W.jsx)(_f,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),_f=s.forwardRef(vd(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=qd(`SelectScrollButton`,n),o=s.useRef(null),c=Cd(n),l=s.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return s.useEffect(()=>()=>l(),[l]),bt(()=>{c().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[c]),(0,W.jsx)(rn.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:G(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:G(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:G(i.onPointerLeave,()=>{l()})})},`SelectScrollButtonImpl`)),vf=`SelectBubbleInput`,yf=s.forwardRef(vd(function({__scopeSelect:e,...t},n){let r=kd(vf,e),{value:i,onValueChange:a,required:o,disabled:c,name:l,autoComplete:u,form:d}=r,{nativeOptions:f,nativeSelectKey:p}=r,m=s.useRef(null),h=mt(n,m),g=i??``,_=fd(g),v=Array.from(f).some(e=>(e.props.value??``)===``);return s.useEffect(()=>{let e=m.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(_!==g&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,g),e.dispatchEvent(t)}},[_,g]),(0,W.jsxs)(rn.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:l,autoComplete:u,disabled:c,form:d,onChange:e=>a(e.target.value),...t,style:{...hd,...t.style},ref:h,defaultValue:g,children:[xf(i)&&!v?(0,W.jsx)(`option`,{value:``}):null,Array.from(f)]},p)},`SelectBubbleInput`));function bf(e){return typeof e==`function`}vd(bf,`isFunction`);function xf(e){return e===``||e===void 0}vd(xf,`shouldShowPlaceholder`);function Sf(e){let t=cn(e),n=s.useRef(``),r=s.useRef(0),i=s.useCallback(e=>{let i=n.current+e;t(i),vd((function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(i)},[t]),a=s.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return s.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}vd(Sf,`useTypeaheadSearch`);function Cf(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=wf(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}vd(Cf,`findNextItem`);function wf(e,t){return e.map((n,r)=>e[(t+r)%e.length])}vd(wf,`wrapArray`);function Tf({id:e,ariaLabel:t,value:n,placeholder:r=`请选择`,options:i,disabled:a=!1,className:o=``,onValueChange:s}){let c=i.find(e=>e.value===n);return(0,W.jsxs)(Nd,{value:n||void 0,disabled:a,onValueChange:s,children:[(0,W.jsxs)(Fd,{id:e,className:`studio-select-trigger${o?` ${o}`:``}`,"aria-label":t,children:[(0,W.jsx)(Ld,{placeholder:r,children:c?.label}),(0,W.jsx)(Rd,{className:`studio-select-chevron`,children:(0,W.jsx)(M,{size:15})})]}),(0,W.jsx)(Vd,{children:(0,W.jsxs)(Ud,{className:`studio-select-content`,position:`popper`,sideOffset:5,collisionPadding:10,children:[(0,W.jsx)(mf,{className:`studio-select-scroll`,children:(0,W.jsx)(F,{size:14})}),(0,W.jsx)(tf,{className:`studio-select-viewport`,children:i.map(e=>(0,W.jsxs)(cf,{value:e.value,disabled:e.disabled,className:`studio-select-item`,children:[(0,W.jsx)(uf,{children:(0,W.jsxs)(`span`,{className:`studio-select-item-copy`,children:[(0,W.jsx)(`span`,{children:e.label}),e.description&&(0,W.jsx)(`small`,{children:e.description})]})}),(0,W.jsx)(ff,{className:`studio-select-check`,children:(0,W.jsx)(j,{size:14})})]},e.value))}),(0,W.jsx)(gf,{className:`studio-select-scroll`,children:(0,W.jsx)(M,{size:14})})]})})]})}function Ef({agents:e,runtimeReady:t,workspaceName:n,onCreate:r,onDetail:i,onChat:a,onBuild:o,onChanged:c}){let[l,u]=(0,s.useState)(``),[d,p]=(0,s.useState)(``),[m,h]=(0,s.useState)(0),[g,_]=(0,s.useState)(0),[v,y]=(0,s.useState)(null),[b,x]=(0,s.useState)(!1),[S,C]=(0,s.useState)(``);(0,s.useEffect)(()=>{Promise.all([f(`/api/v1/catalog/resources?limit=200`).then(e=>e.json()),f(`/api/v1/catalog/models`).then(e=>e.json()).catch(()=>null)]).then(([e,t])=>{let n=e.items||[],r=n.filter(e=>e.kind===`model`);t?.items?.length&&(r=[...r.filter(e=>e.source===`local`||e.source===`market`),...t.items]),h(r.filter(e=>e.status===`ready`).length),_(n.filter(e=>[`tool`,`mcp`,`skill`].includes(e.kind)&&e.status===`ready`).length)}).catch(()=>{})},[]);let w=(0,s.useMemo)(()=>e.filter(e=>{let t=!!e.builds?.some(e=>e.status===`SUCCEEDED`),n=l.trim().toLowerCase();return(!n||e.metadata.name.toLowerCase().includes(n)||e.metadata.id.toLowerCase().includes(n))&&(!d||d===`built`&&t||d===`draft`&&!t)}),[e,l,d]),T=(0,s.useMemo)(()=>[{id:`agent`,header:`Agent`,minWidth:260,cell:e=>{let t=e.metadata.labels?.[`agentkit.ksyun.com/template`]||`blank`;return(0,W.jsxs)(`div`,{className:`agent-cell`,children:[(0,W.jsx)(nt,{name:e.metadata.name,appearance:e.metadata.appearance,template:t}),(0,W.jsxs)(`div`,{className:`agent-cell-copy`,children:[(0,W.jsx)(`strong`,{children:e.metadata.name}),(0,W.jsx)(`span`,{children:e.metadata.id})]})]})}},{id:`template`,header:`模板`,minWidth:150,cell:e=>{let t=e.metadata.labels?.[`agentkit.ksyun.com/template`]||`blank`,n=e.spec?.runtime?.type||e.metadata.labels?.[`agentkit.ksyun.com/framework`]||`adk`;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`status-badge neutral`,children:n}),` `,(0,W.jsx)(`span`,{className:`meta-inline`,children:t===`research`?`Research`:`Blank`})]})}},{id:`capabilities`,header:`能力`,minWidth:210,cell:e=>{let t=e.spec?.bindings||{};return(0,W.jsxs)(`div`,{className:`resource-counts`,children:[(0,W.jsxs)(`span`,{children:[t.tools?.length||0,` Tool`]}),(0,W.jsxs)(`span`,{children:[t.mcpServers?.length||0,` MCP`]}),(0,W.jsxs)(`span`,{children:[t.skills?.length||0,` Skill`]})]})}},{id:`revision`,header:`Revision`,width:100,cell:e=>(0,W.jsxs)(`span`,{className:`mono`,children:[`r`,e.metadata.revision]})},{id:`build`,header:`最近构建`,width:120,cell:e=>e.builds?.some(e=>e.status===`SUCCEEDED`)?(0,W.jsx)(`span`,{className:`status-badge success`,children:`已构建`}):(0,W.jsx)(`span`,{className:`status-badge neutral`,children:`草稿`})},{id:`actions`,header:`操作`,minWidth:300,className:`actions-column`,headerClassName:`actions-column`,cell:e=>(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:`button tertiary small`,type:`button`,onClick:()=>i(e.metadata.id),children:`配置`}),(0,W.jsx)(`button`,{className:`button tertiary small`,type:`button`,onClick:()=>i(e.metadata.id),children:`编辑`}),(0,W.jsx)(`button`,{className:`button secondary small`,type:`button`,onClick:()=>a(e.metadata.id),children:`会话`}),(0,W.jsx)(`button`,{className:`button danger small`,type:`button`,onClick:()=>y(e),children:`删除`})]})}],[a,i]);async function E(){if(v){x(!0),C(``);try{let e=await f(`/api/v1/agents/${encodeURIComponent(v.metadata.id)}`,{method:`DELETE`});if(!e.ok){let t=await e.text().catch(()=>``),n=`删除失败(${e.status})`;try{n=JSON.parse(t)?.error?.message||n}catch{}throw Error(n)}}catch(e){C(e.message||`删除失败`)}x(!1),y(null),c()}}return(0,W.jsxs)(`div`,{className:`page-container`,"data-layout":`data`,"data-scroll-mode":`data`,children:[(0,W.jsxs)(`header`,{className:`page-header`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{children:`Agent`}),(0,W.jsx)(`p`,{children:`创建、配置和运行本地 Agent,同一 Bundle 可直接部署至云端。`})]}),(0,W.jsxs)(`button`,{className:`button accent`,type:`button`,disabled:!t,onClick:r,children:[(0,W.jsx)(Pe,{size:16}),(0,W.jsx)(`span`,{children:`创建 Agent`})]})]}),(0,W.jsxs)(`div`,{className:`data-page-body table-data-body`,children:[S&&(0,W.jsx)(`div`,{className:`form-error`,style:{marginBottom:16},children:S}),(0,W.jsxs)(`div`,{className:`overview-strip`,children:[(0,W.jsxs)(`div`,{className:`overview-item`,children:[(0,W.jsx)(`span`,{children:`Agent`}),(0,W.jsx)(`strong`,{children:e.length}),(0,W.jsx)(`small`,{children:`当前工作区`})]}),(0,W.jsxs)(`div`,{className:`overview-item`,children:[(0,W.jsx)(`span`,{children:`可用模型`}),(0,W.jsx)(`strong`,{children:m}),(0,W.jsx)(`small`,{children:`Model Profile`})]}),(0,W.jsxs)(`div`,{className:`overview-item`,children:[(0,W.jsx)(`span`,{children:`能力资源`}),(0,W.jsx)(`strong`,{children:g}),(0,W.jsx)(`small`,{children:`Tool · MCP · Skill`})]}),(0,W.jsxs)(`div`,{className:`overview-item environment-overview`,children:[(0,W.jsx)(`span`,{children:`运行环境`}),(0,W.jsxs)(`strong`,{children:[(0,W.jsx)(`span`,{className:`status-dot ${t?`success`:`warning`}`}),(0,W.jsx)(`span`,{children:t?`运行正常`:`正在连接`})]}),(0,W.jsx)(`small`,{children:t?n||`本地构建与运行`:`正在连接本地工作区`})]})]}),(0,W.jsxs)(`section`,{className:`content-section`,children:[(0,W.jsxs)(`div`,{className:`section-toolbar`,children:[(0,W.jsxs)(`div`,{className:`search-field`,children:[(0,W.jsx)(Ie,{size:15}),(0,W.jsx)(`input`,{type:`search`,placeholder:`搜索 Agent 名称或 ID`,"aria-label":`搜索 Agent`,value:l,onChange:e=>u(e.target.value)})]}),(0,W.jsx)(Tf,{className:`compact-select`,ariaLabel:`筛选 Agent 状态`,value:d||`__all__`,options:[{value:`__all__`,label:`全部状态`},{value:`built`,label:`已构建`},{value:`draft`,label:`草稿`}],onValueChange:e=>p(e===`__all__`?``:e)}),(0,W.jsx)(`div`,{className:`toolbar-spacer`}),(0,W.jsx)(`span`,{className:`sync-state`,children:`已同步`})]}),(0,W.jsx)(rc,{columns:T,data:w,getRowId:e=>e.metadata.id,caption:`Agent 列表`,minWidth:1120,onRowActivate:e=>i(e.metadata.id),rowAriaLabel:e=>`${e.metadata.name} ${e.metadata.id}`,empty:{icon:(0,W.jsx)(O,{size:24}),title:l||d?`没有匹配的 Agent`:`还没有 Agent`,description:l||d?`调整搜索词或状态筛选后重试。`:`输入系统提示词并选择所需能力,创建第一个可在本地运行和构建的 Agent。`,action:!l&&!d?(0,W.jsxs)(`button`,{className:`button accent`,type:`button`,onClick:r,children:[(0,W.jsx)(Pe,{size:16}),(0,W.jsx)(`span`,{children:`创建 Agent`})]}):void 0}})]})]}),v&&(0,W.jsx)(ca,{title:`确认删除 Agent「${v.metadata.name}」?`,description:`Agent ID:${v.metadata.id}。删除后其配置与 Revision 将移除,此操作不可撤销。`,confirmText:`确认删除`,busy:b,onConfirm:E,onCancel:()=>y(null)})]})}var Df=e=>e.type===`checkbox`,Of=e=>e.type===`file`,kf=e=>e instanceof Date,Af=e=>e==null,jf=e=>typeof e==`object`,Mf=e=>!Af(e)&&!Array.isArray(e)&&jf(e)&&!kf(e),Nf=e=>Mf(e)&&e.target?Df(e.target)?e.target.checked:Of(e.target)?e.target.files:e.target.value:e,Pf=(e,t)=>t.split(`.`).some((t,n,r)=>!isNaN(Number(t))&&e.has(r.slice(0,n).join(`.`))),Ff=e=>{let t=e.constructor&&e.constructor.prototype;return Mf(t)&&t.hasOwnProperty(`isPrototypeOf`)},If=typeof window<`u`&&window.HTMLElement!==void 0&&typeof document<`u`;function Lf(e){if(e instanceof Date)return new Date(e);let t=typeof FileList<`u`&&e instanceof FileList;if(If&&(e instanceof Blob||t))return e;let n=Array.isArray(e);if(!n&&!(Mf(e)&&Ff(e)))return e;let r=n?[]:Object.create(Object.getPrototypeOf(e));for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=Lf(e[t]));return r}var Rf={BLUR:`blur`,FOCUS_OUT:`focusout`,CHANGE:`change`,SUBMIT:`submit`,TRIGGER:`trigger`,VALID:`valid`},zf={onBlur:`onBlur`,onChange:`onChange`,onSubmit:`onSubmit`,onTouched:`onTouched`,all:`all`},Bf={max:`max`,min:`min`,maxLength:`maxLength`,minLength:`minLength`,pattern:`pattern`,required:`required`,validate:`validate`},Vf=`root`,Hf=[`__proto__`,`constructor`,`prototype`],Uf=/^\w*$/,Wf=e=>Uf.test(e),Gf=e=>e===void 0,Kf=/[.[\]'"]/,qf=e=>e.split(Kf).filter(Boolean),K=(e,t,n)=>{if(!t||!Mf(e))return n;let r=Wf(t)?[t]:qf(t);if(r.some(e=>Hf.includes(e)))return n;let i=r.reduce((e,t)=>Af(e)?void 0:e[t],e);return Gf(i)||i===e?Gf(e[t])?n:e[t]:i},Jf=e=>typeof e==`boolean`,Yf=e=>typeof e==`function`,Xf=(e,t,n)=>{let r=-1,i=Wf(t)?[t]:qf(t),a=i.length,o=a-1;for(;++r<a;){let t=i[r],a=n;if(r!==o){let n=e[t];a=Mf(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if(Hf.includes(t))return;e[t]=a,e=e[t]}},Zf=s.createContext(null);Zf.displayName=`HookFormControlContext`;var Qf=(e,t,n,r=!0)=>{let i={};for(let a in e)Object.defineProperty(i,a,{get:()=>{let i=a;return t._proxyFormState[i]!==zf.all&&(t._proxyFormState[i]=!r||zf.all),n&&(n[i]=!0),e[i]}});return i},$f=If?s.useLayoutEffect:s.useEffect,ep=e=>Af(e)||!jf(e),tp=(e,t)=>t.length===0&&!Array.isArray(e)&&!Ff(e);function np(e,t,n=new WeakMap){if(e===t)return!0;if(ep(e)||ep(t))return Object.is(e,t);if(kf(e)&&kf(t))return Object.is(e.getTime(),t.getTime());let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;if(tp(e,r)||tp(t,i))return Object.is(e,t);if(!r.length&&Array.isArray(e)!==Array.isArray(t))return!1;let a=n.get(e);if(a&&a.has(t))return!0;if(a)a.add(t);else{let r=new WeakSet;r.add(t),n.set(e,r)}for(let i of r){let r=e[i];if(!(i in t))return!1;if(i!==`ref`){let e=t[i];if(kf(r)&&kf(e)||(Mf(r)||Array.isArray(r))&&(Mf(e)||Array.isArray(e))?!np(r,e,n):!Object.is(r,e))return!1}}return!0}function rp(){let e=s.useRef(!1),t=s.useRef(void 0);return{resyncIfNeeded:s.useCallback((n,r,i)=>{if(n&&e.current){let e=r();np(t.current,e)||i(e)}e.current=!0},[]),snapshot:s.useCallback((e,n)=>{e&&(t.current=Lf(n()))},[])}}var ip=e=>typeof e==`string`,ap=(e,t,n,r,i)=>ip(e)?(r&&t.watch.add(e),K(n,e,i)):Array.isArray(e)?e.map(e=>(r&&t.watch.add(e),K(n,e))):(r&&(t.watchAll=!0),n),op=e=>({isOnSubmit:!e||e===zf.onSubmit,isOnBlur:e===zf.onBlur,isOnChange:e===zf.onChange,isOnAll:e===zf.all,isOnTouch:e===zf.onTouched}),sp=(e,t,n)=>{if(n)return!1;if(t.watchAll||t.watch.has(e))return!0;for(let n of t.watch)if(e.startsWith(n)&&e.charAt(n.length)===`.`)return!0;return!1},cp=(e,t,n,r)=>{for(let i of n||Object.keys(e)){if(i===`_f`)continue;let a=n?K(e,i):e[i];if(a){let{_f:e}=a;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r||e.ref&&t(e.ref,e.name)&&!r)return!0;if(cp(a,t))break}else if((Mf(a)||Array.isArray(a))&&cp(a,t))break}}},lp=(e,t,n)=>{let r=K(e,n),i=Array.isArray(r)?r:[];return Xf(i,Vf,t[n]),Xf(e,n,i),e},up=e=>Mf(e)&&!Object.keys(e).length,dp=e=>{if(!If)return!1;let t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},fp=e=>e.type===`radio`,pp=e=>e instanceof RegExp,mp=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},hp={value:!1,isValid:!1},gp={value:!0,isValid:!0},_p=e=>{if(Array.isArray(e)){if(e.length>1){let t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Gf(e[0].attributes.value)?Gf(e[0].value)||e[0].value===``?gp:{value:e[0].value,isValid:!0}:gp:hp}return hp},vp={isValid:!1,value:null},yp=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,vp):vp;function bp(e,t,n=`validate`){if(ip(e)||Array.isArray(e)&&e.every(ip)||Jf(e)&&!e)return{type:n,message:ip(e)?e:``,ref:t}}var xp=e=>Mf(e)&&!pp(e)?e:{value:e,message:``},Sp=async(e,t,n,r,i,a)=>{let{ref:o,refs:s,required:c,maxLength:l,minLength:u,min:d,max:f,pattern:p,validate:m,name:h,valueAsNumber:g,mount:_}=e._f,v=K(n,h);if(!_||t.has(h))return{};let y=s?s[0]:o,b=e=>{if(i&&y.reportValidity){let t=Jf(e)?``:e||``;s?s.forEach(e=>e.setCustomValidity(t)):y.setCustomValidity(t),y.reportValidity()}},x={},S=fp(o),C=Df(o),w=S||C,T=(g||Of(o))&&Gf(o.value)&&Gf(v)||dp(o)&&o.value===``||v===``||Array.isArray(v)&&!v.length,E=mp.bind(null,h,r,x),D=(e,t,n,r=Bf.maxLength,i=Bf.minLength)=>{let a=e?t:n;x[h]={type:e?r:i,message:a,ref:o,...E(e?r:i,a)}};if(a?!Array.isArray(v)||!v.length:c&&(!w&&(T||Af(v))||Jf(v)&&!v||C&&!_p(s).isValid||S&&!yp(s).isValid)){let{value:e,message:t}=ip(c)?{value:!!c,message:c}:xp(c);if(e&&(x[h]={type:Bf.required,message:t,ref:y,...E(Bf.required,t)},!r))return b(t),x}if(!T&&(!Af(d)||!Af(f))){let e,t,n=xp(f),i=xp(d);if(!Af(v)&&!kf(v)&&!isNaN(v)){let r=o.valueAsNumber||v&&+v;Af(n.value)||(e=r>n.value),Af(i.value)||(t=r<i.value)}else{let r=o.valueAsDate||new Date(v),a=e=>new Date(new Date().toDateString()+` `+e),s=o.type==`time`,c=o.type==`week`;ip(n.value)&&v&&(e=s?a(v)>a(n.value):c?v>n.value:r>new Date(n.value)),ip(i.value)&&v&&(t=s?a(v)<a(i.value):c?v<i.value:r<new Date(i.value))}if((e||t)&&(D(!!e,n.message,i.message,Bf.max,Bf.min),!r))return b(x[h].message),x}if((l||u)&&!T&&(ip(v)||a&&Array.isArray(v))){let e=xp(l),t=xp(u),n=!Af(e.value)&&v.length>+e.value,i=!Af(t.value)&&v.length<+t.value;if((n||i)&&(D(n,e.message,t.message),!r))return b(x[h].message),x}if(p&&!T&&ip(v)){let{value:e,message:t}=xp(p);if(pp(e)&&!v.match(e)&&(x[h]={type:Bf.pattern,message:t,ref:o,...E(Bf.pattern,t)},!r))return b(t),x}if(m){if(Yf(m)){let e=bp(await m(v,n),y);if(e&&(x[h]={...e,...E(Bf.validate,e.message)},!r))return b(e.message),x}else if(Mf(m)){let e={};for(let t in m){if(!up(e)&&!r)break;let i=bp(await m[t](v,n),y,t);i&&(e={...i,...E(t,i.message)},b(i.message),r&&(x[h]=e))}if(!up(e)&&(x[h]={ref:y,...e},!r))return x}}return b(!0),x},Cp=e=>Array.isArray(e)?e:[e],wp=e=>Array.isArray(e)?e.filter(Boolean):[];function Tp(e,t){let n=t.length-1,r=0;for(;r<n;){if(Af(e)){e=void 0;break}e=e[t[r]],r++}return e}function Ep(e){for(let t in e)if(e.hasOwnProperty(t)&&!Gf(e[t]))return!1;return!0}function Dp(e,t){if(ip(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;let n=Array.isArray(t)?t:Wf(t)?[t]:qf(t);if(n.some(e=>Hf.includes(String(e))))return e;let r=n.length===1?e:Tp(e,n),i=n.length-1,a=n[i];return r&&delete r[a],i!==0&&(Mf(r)&&up(r)||Array.isArray(r)&&Ep(r))&&Dp(e,n.slice(0,-1)),e}var Op=e=>{let t={};for(let n of Object.keys(e))if(jf(e[n])&&e[n]!==null&&!kf(e[n])){let r=Op(e[n]);for(let e of Object.keys(r))t[`${n}.${e}`]=r[e]}else t[n]=e[n];return t},kp=s.createContext(null);kp.displayName=`HookFormContext`;var Ap=({children:e,watch:t,getValues:n,getFieldState:r,setError:i,clearErrors:a,setValue:o,setValues:c,trigger:l,formState:u,resetField:d,reset:f,resetDefaultValues:p,handleSubmit:m,unregister:h,control:g,register:_,setFocus:v,subscribe:y})=>{let b=s.useMemo(()=>({watch:t,getValues:n,getFieldState:r,setError:i,clearErrors:a,setValue:o,setValues:c,trigger:l,formState:u,resetField:d,reset:f,resetDefaultValues:p,handleSubmit:m,unregister:h,control:g,register:_,setFocus:v,subscribe:y}),[a,g,u,r,n,m,_,f,p,d,i,v,o,c,y,l,h,t]);return s.createElement(kp.Provider,{value:b},s.createElement(Zf.Provider,{value:b.control},e))},jp=()=>{let e=[];return{get observers(){return e},next:t=>{for(let n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}};function Mp(e,t){let n={};for(let r in e)if(e.hasOwnProperty(r)){let i=e[r],a=t[r];if(i&&Mf(i)&&a){let e=Mp(i,a);Mf(e)&&(n[r]=e)}else e[r]&&(n[r]=a)}return n}var Np=e=>e.type===`select-multiple`,Pp=e=>fp(e)||Df(e),Fp=e=>dp(e)&&e.isConnected;function Ip(e){return Array.isArray(e)||Mf(e)}function Lp(e,t,n=``,r=[]){for(let i in e){let a=n?`${n}.${i}`:i,o=e[i];Ip(o)&&Ip(K(t,a))?Lp(o,t,a,r):r.push(a)}return r}var Rp=e=>{for(let t in e)if(Yf(e[t]))return!0;return!1};function zp(e){return Array.isArray(e)||Mf(e)&&!Rp(e)}function Bp(e){return!!(e&&`_f`in e)}function Vp(e){return Array.isArray(e)?!e.some(e=>!Gf(e)):!Object.keys(e).length}function Hp(e,t){Array.isArray(e)?e[t]=void 0:delete e[t]}function Up(e,t={},n){for(let r in e){let i=e[r],a=n&&n[r];zp(i)&&(!Array.isArray(i)||!Bp(a))?(t[r]=Array.isArray(i)?[]:{},Up(i,t[r],a),Vp(t[r])&&Hp(t,r)):Gf(i)||(t[r]=!0)}return t}function Wp(e,t,n,r){n||=Up(t,{},r);for(let i in e){let a=e[i],o=r&&r[i];zp(a)&&(!Array.isArray(a)||!Bp(o))?(Gf(t)||ep(n[i])?n[i]=Up(a,Array.isArray(a)?[]:{},o):Wp(a,Af(t)?{}:t[i],n[i],o),Vp(n[i])&&Hp(n,i)):np(a,t[i])?Hp(n,i):n[i]=!0}return n}var Gp=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Gf(e)?e:t?e===``?NaN:e&&+e:n&&ip(e)?new Date(e):r?r(e):e;function Kp(e){let t=e.ref;return Of(t)?t.files:fp(t)?yp(e.refs).value:Np(t)?[...t.selectedOptions].map(({value:e})=>e):Df(t)?_p(e.refs).value:Gp(t.value,e)}var qp=(e,t,n,r)=>{let i={};for(let n of e){let e=K(t,n);e&&Xf(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},Jp=e=>Gf(e)?e:pp(e)?e.source:Mf(e)?pp(e.value)?e.value.source:e.value:e,Yp=`AsyncFunction`,Xp=e=>{if(!e||!e.validate)return!1;if(Yf(e.validate))return e.validate.constructor.name===Yp;if(Mf(e.validate)){for(let t in e.validate)if(e.validate[t].constructor.name===Yp)return!0}return!1},Zp=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Qp(e,t,n){let r=K(e,n);if(r||Wf(n))return{error:r,name:n};let i=n.split(`.`);for(;i.length;){let r=i.join(`.`),a=K(t,r),o=K(e,r);if(a&&!Array.isArray(a)&&n!==r)return{name:n};if(o&&o.type)return{name:r,error:o};if(o&&o.root&&o.root.type)return{name:`${r}.root`,error:o.root};i.pop()}return{name:n}}var $p=(e,t,n,r)=>{n(e);let i=Object.keys(e).filter(e=>e!==`name`);return!i.length||r&&i.length>=Object.keys(t).length||i.find(e=>t[e]===(!r||zf.all))},em=(e,t,n)=>!e||!t||e===t||Cp(e).some(e=>e&&(n?e===t||e.startsWith(t+`.`):e.startsWith(t)||t.startsWith(e))),tm=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:!(n?r.isOnChange:i.isOnChange)||e,nm=(e,t)=>{let n=K(e,t);!wp(n).length&&!n?.root&&Dp(e,t)},rm={mode:zf.onSubmit,reValidateMode:zf.onChange,shouldFocusError:!0},im=`form`,am=(e,t)=>{for(let n in e)n in t||delete e[n];Object.assign(e,t)},om={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function sm(e={}){let t={...rm,...e},n={...Lf(om),isLoading:Yf(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},r={},i=(Mf(t.defaultValues)||Mf(t.values))&&Lf(t.defaultValues||t.values)||{},a=t.shouldUnregister?{}:Lf(i),o={action:!1,actionArrayLengths:new Map,mount:!1,watch:!1,keepIsValid:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},c={},l={},u=0,d=op(t.mode),f=op(t.reValidateMode),p={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},m={...p},h={...m},g={array:jp(),state:jp()},_=0,v=t.criteriaMode===zf.all,y=(e,t)=>n=>{clearTimeout(l[e]),l[e]=setTimeout(t,n)},b=async e=>{if(!o.keepIsValid&&!t.disabled&&(m.isValid||h.isValid||e)){let e=++_,i;t.resolver?(i=up((await j()).errors),e===_&&x()):i=await P({fields:r,onlyCheckValid:!0,eventType:Rf.VALID}),e===_&&i!==n.isValid&&g.state.next({isValid:i})}},x=(e,r)=>{!t.disabled&&(m.isValidating||m.validatingFields||h.isValidating||h.validatingFields)&&((e||Array.from(s.mount)).forEach(e=>{e&&(r?Xf(n.validatingFields,e,r):Dp(n.validatingFields,e))}),g.state.next({validatingFields:n.validatingFields,isValidating:!up(n.validatingFields)}))},S=()=>{n.dirtyFields=Wp(i,a,void 0,r)},C=(e,i=[],s,c,l=!0,u=!0)=>{if(c&&s&&!t.disabled){if(o.action=!0,!o.actionArrayLengths.has(e)){let t=K(r,e);o.actionArrayLengths.set(e,Array.isArray(t)?t.length:0)}if(u&&Array.isArray(K(r,e))){let t=s(K(r,e),c.argA,c.argB);l&&Xf(r,e,t)}if(u&&Array.isArray(K(n.errors,e))){let t=K(n.errors,e),r=t.root,i=s(t,c.argA,c.argB)||t;r&&(i.root=r),l&&Xf(n.errors,e,i),nm(n.errors,e)}if((m.touchedFields||h.touchedFields)&&u&&Array.isArray(K(n.touchedFields,e))){let t=s(K(n.touchedFields,e),c.argA,c.argB);l&&Xf(n.touchedFields,e,t)}(m.dirtyFields||h.dirtyFields)&&S(),g.state.next({name:e,isDirty:I(e,i),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Xf(a,e,i)},w=(e,t)=>{Xf(n.errors,e,t),n.errors={...n.errors},g.state.next({errors:n.errors})},T=e=>{n.errors=e,g.state.next({errors:n.errors,isValid:!1})},E=e=>{let t=Wf(e)?[e]:qf(e),n=a,r=i;for(let e=0;e<t.length-1;e++){let i=t[e];if(n=Af(n)?n:n[i],r=Af(r)?r:r[i],n===null&&r!==null)return!0}return!1},D=e=>{if(!o.actionArrayLengths.size)return!1;let t=Wf(e)?[e]:qf(e),n=a,r=``,i=-1,s=0;for(let e=0;e<t.length;e++){if(Af(n))return!1;let a=t[e];if(r=r?`${r}.${a}`:a,Array.isArray(n)&&+a>=n.length)return i===-1?!1:e!==i||+a<s;o.actionArrayLengths.has(r)&&(i=e+1,s=o.actionArrayLengths.get(r)),n=n[a]}return!1},O=(t,c,l,u)=>{let d=K(r,t);if(d){if(E(t)||D(t))return;let r=Gf(K(a,t)),f=K(a,t,Gf(l)?K(i,t):l);Gf(f)||u&&u.defaultChecked||c?Xf(a,t,c?f:Kp(d._f)):z(t,f),o.mount&&!o.action&&(b(),r&&n.isDirty&&(m.isDirty||h.isDirty)&&(I()||(n.isDirty=!1,g.state.next({...n}))),e.shouldUnregister&&r&&!Gf(K(a,t))&&sp(t,s)&&(o.watch=!0))}},k=(e,o,s,c,l)=>{let u=!1,d=!1,f={name:e};if(!t.disabled||c===!0){if(!s||c){let t=np(K(i,e),o);(m.isDirty||h.isDirty)&&(d=n.isDirty,n.isDirty=f.isDirty=!t||I(),u=d!==f.isDirty),d=!!K(n.dirtyFields,e),t===n.isDirty?t?Dp(n.dirtyFields,e):Xf(n.dirtyFields,e,!0):am(n.dirtyFields,Wp(i,a,void 0,r)),f.dirtyFields=n.dirtyFields,u||=(m.dirtyFields||h.dirtyFields)&&d!==!t}if(s){let t=K(n.touchedFields,e);t||(Xf(n.touchedFields,e,s),f.touchedFields=n.touchedFields,u||=(m.touchedFields||h.touchedFields)&&t!==s)}u&&l&&g.state.next(f)}return u?f:{}},A=(e,r,i,a)=>{let o=K(n.errors,e),s=(m.isValid||h.isValid)&&Jf(r)&&n.isValid!==r;if(t.delayError&&i?(c[e]=y(e,()=>w(e,i)),c[e](t.delayError)):(clearTimeout(l[e]),delete c[e],i?Xf(n.errors,e,i):Dp(n.errors,e),n.errors={...n.errors}),(i?!np(o,i):o)||!up(a)||s){let t={...a,...s&&Jf(r)?{isValid:r}:{},errors:n.errors,name:e};n={...n,...t},g.state.next(t)}},j=async e=>(x(e,!0),await t.resolver(a,t.context,qp(e||s.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),M=async e=>{let{errors:t}=await j(e);if(x(e),e){for(let r of e){let e=K(t,r);e?s.array.has(r)&&Mf(e)&&!Object.keys(e).some(e=>!Number.isNaN(Number(e)))?lp(n.errors,{[r]:e},r):Xf(n.errors,r,e):Dp(n.errors,r)}n.errors={...n.errors}}else n.errors=t;return t},N=async({name:t,eventType:r})=>{if(e.validate){let i=await e.validate({formValues:a,formState:n,name:t,eventType:r});if(Mf(i))for(let e in i){let t=i[e];t&&oe(`${im}.${e}`,{message:ip(t.message)?t.message:``,type:t.type||Bf.validate})}else ip(i)||!i?oe(im,{message:i||``,type:Bf.validate}):ae(im);return i}return!0},P=async({fields:r,onlyCheckValid:i,name:o,eventType:c,context:l={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(l.runRootValidation=!0,!await N({name:o,eventType:c})&&(l.valid=!1,i)))return l.valid;for(let o in r){let u=r[o];if(u){let{_f:r,...d}=u;if(r){let o=s.array.has(r.name),c=u._f&&Xp(u._f),d=m.validatingFields||m.isValidating||h.validatingFields||h.isValidating;c&&d&&x([r.name],!0);let f=await Sp(u,s.disabled,a,v,t.shouldUseNativeValidation&&!i,o);if(c&&d&&x([r.name]),f[r.name]&&(l.valid=!1,i)||(!i&&(K(f,r.name)?o?lp(n.errors,f,r.name):Xf(n.errors,r.name,f[r.name]):Dp(n.errors,r.name)),e.shouldUseNativeValidation&&f[r.name]))break}!up(d)&&await P({context:l,onlyCheckValid:i,fields:d,name:o,eventType:c})}}return l.valid},F=()=>{for(let e of s.unMount){let t=K(r,e);t&&(t._f.refs?t._f.refs.every(e=>!Fp(e)):!Fp(t._f.ref))&&ue(e)}s.unMount=new Set},I=(e,t)=>(e&&t&&Xf(a,e,t),!np(o.mount?a:i,i)),L=(e,t,n)=>ap(e,s,{...o.mount?a:Gf(t)||ip(e)?i:t},n,t),R=e=>wp(K(o.mount?a:i,e,t.shouldUnregister?K(i,e,[]):[])),z=(e,t,n={},i=!1,o=!1,s=!1)=>{let c=K(r,e),l=t;if(c){let n=c._f;n&&(!n.disabled&&Xf(a,e,Gp(t,n)),l=dp(n.ref)&&Af(t)?``:t,Np(n.ref)?[...n.ref.options].forEach(e=>e.selected=l.includes(e.value)):n.refs?Df(n.ref)?n.refs.forEach(e=>{(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(l)?!!l.find(t=>t===e.value):l===e.value||!!l)}):n.refs.forEach(e=>e.checked=e.value===l):Of(n.ref)?n.ref.value=``:(n.ref.value=l,!n.ref.type&&!o&&!s&&g.state.next({name:e,values:i?a:Lf(a)})))}(n.shouldDirty||n.shouldTouch)&&k(e,l,n.shouldTouch,n.shouldDirty,!o),n.shouldValidate&&ne(e,{delayError:n.delayError})},B=(e,t,n,i=!1,o=!1,c=!1)=>{s.array.has(e)&&g.array.next({name:e,values:i?a:Lf(a)});for(let a in t){if(!t.hasOwnProperty(a))return;let l=t[a],u=e+`.`+a,d=K(r,u);(s.array.has(e)||Mf(l)||d&&!d._f)&&!kf(l)?B(u,l,n,i,o,c):z(u,l,n,i,o,c)}},V=(e,t,i,c,l=!1)=>{let u=K(r,e),d=s.array.has(e),f=c?t:Lf(t),p=np(K(a,e),f);if(p||Xf(a,e,f),d)g.array.next({name:e,values:c?a:Lf(a)}),(m.isDirty||m.dirtyFields||h.isDirty||h.dirtyFields)&&i.shouldDirty&&(S(),l||g.state.next({name:e,dirtyFields:n.dirtyFields,isDirty:I(e,f)}));else{let t=Array.isArray(f)&&!f.length||up(f),n=!p&&!l;!u||u._f||Af(f)||t?z(e,f,i,c,l,n):B(e,f,i,c,l,n)}if(!p&&!l){let t=sp(e,s),r=c?a:Lf(a);g.state.next({...t&&n,name:o.mount||t?e:void 0,values:r})}},H=(e,t,n={})=>V(e,t,n,!1),U=(e,t={})=>{let r=Yf(e)?e(a):e;if(!np(a,r)){a={...a,...r};let e=Op(r);for(let n of s.mount)n in e&&V(n,e[n],t,!0,!0);g.state.next({...n,name:void 0,type:void 0,...u?{values:a}:{}}),t.shouldValidate&&b()}},ee=async i=>{o.mount=!0;let l=i.target,p=l.name,_=!0,y=K(r,p),S=e=>{_=Number.isNaN(e)||kf(e)&&isNaN(e.getTime())||np(e,K(a,p,e))};if(y){let o,C,w=l.type?Kp(y._f):Nf(i),T=i.type===Rf.BLUR||i.type===Rf.FOCUS_OUT,E=!Zp(y._f)&&!e.validate&&!t.resolver&&!K(n.errors,p)&&!y._f.deps,D=E||tm(T,K(n.touchedFields,p),n.isSubmitted,f,d),O=sp(p,s,T);if(Xf(a,p,w),T){if(!l||!l.readOnly){y._f.onBlur&&y._f.onBlur(i);let e=c[p];e&&e(0)}}else y._f.onChange&&y._f.onChange(i);let M=k(p,w,T),F=!up(M)||O;if(!T&&g.state.next({name:p,type:i.type,...u?{values:Lf(a)}:{}}),D)return(!E||!n.isValid)&&(m.isValid||h.isValid)&&(t.mode===`onBlur`?T&&b():T||b()),F&&g.state.next({name:p,...O?{}:M});if(!t.resolver&&e.validate&&await N({name:p,eventType:i.type}),!T&&O&&g.state.next({...n}),t.resolver){let{errors:e}=await j([p]);if(x([p]),S(w),!_){!up(M)&&g.state.next(M);return}let t=Qp(n.errors,r,p),i=Qp(e,r,t.name||p);o=i.error,p=i.name,C=up(e)}else x([p],!0),o=(await Sp(y,s.disabled,a,v,t.shouldUseNativeValidation))[p],x([p]),S(w),_&&(o?C=!1:(m.isValid||h.isValid)&&(C=await P({fields:r,onlyCheckValid:!0,name:p,eventType:i.type})));_&&(y._f.deps&&(!Array.isArray(y._f.deps)||y._f.deps.length>0)&&ne(y._f.deps),A(p,C,o,M))}},te=(e,t)=>{if(K(n.errors,t)&&e.focus)return e.focus(),1},ne=async(e,i={})=>{let a,o,u=Cp(e);if(t.resolver){let t=await M(Gf(e)?e:u);a=up(t),o=e?!u.some(e=>K(t,e)):a}else e?(o=(await Promise.all(u.map(async e=>{let t=K(r,e);return await P({fields:t&&t._f?{[e]:t}:t,eventType:Rf.TRIGGER})}))).every(Boolean),!(!o&&!n.isValid)&&b()):o=a=await P({fields:r,name:e,eventType:Rf.TRIGGER});if(i.delayError&&t.delayError&&ip(e)){let r=K(n.errors,e);r?(Dp(n.errors,e),c[e]=y(e,()=>w(e,r)),c[e](t.delayError)):(clearTimeout(l[e]),delete c[e])}return g.state.next({...!ip(e)||(m.isValid||h.isValid)&&a!==n.isValid?{}:{name:e},...t.resolver||!e?{isValid:a}:{},errors:n.errors}),i.shouldFocus&&!o&&cp(r,te,e?u:s.mount),o},re=(e,t)=>{let r={...o.mount?a:i};return t&&(r=Mp(t.dirtyFields?n.dirtyFields:n.touchedFields,r)),Gf(e)?r:ip(e)?K(r,e):e.map(e=>K(r,e))},ie=(e,t)=>({invalid:!!K((t||n).errors,e),isDirty:!!K((t||n).dirtyFields,e),error:K((t||n).errors,e),isValidating:!!K(n.validatingFields,e),isTouched:!!K((t||n).touchedFields,e)}),ae=e=>{let t=e?Cp(e):void 0;t?.forEach(e=>Dp(n.errors,e)),t?t.forEach(e=>{g.state.next({name:e,errors:n.errors})}):(n.errors={},g.state.next({errors:n.errors}))},oe=(e,t,i)=>{let a=(K(r,e,{_f:{}})._f||{}).ref,{ref:o,message:s,type:c,...l}=K(n.errors,e)||{};Xf(n.errors,e,{...l,...t,ref:a}),g.state.next({name:e,errors:n.errors,isValid:!1}),i&&i.shouldFocus&&a&&a.focus&&a.focus()},se=(e,t)=>{if(Yf(e)){u++;let{unsubscribe:n}=g.state.subscribe({next:n=>`values`in n&&e(n.values||L(void 0,t),n)}),r=!1;return{unsubscribe:()=>{r||(r=!0,u--,n())}}}return L(e,t,!0)},ce=e=>{let t=!!e.formState?.values;t&&u++;let{unsubscribe:r}=g.state.subscribe({next:t=>{if(em(e.name,t.name,e.exact)&&$p(t,e.formState||m,be,e.reRenderRoot)){let r={...a};e.callback({values:r,...n,...t,defaultValues:i})}}});if(!t)return r;let o=!1;return()=>{o||(o=!0,u--,r())}},le=e=>(o.mount=!0,h={...h,...e.formState},ce({...e,formState:{...p,...e.formState}})),ue=(e,o={})=>{for(let c of e?Cp(e):s.mount)s.mount.delete(c),s.array.delete(c),o.keepValue||(Dp(r,c),Dp(a,c)),!o.keepError&&Dp(n.errors,c),!o.keepDirty&&Dp(n.dirtyFields,c),!o.keepTouched&&Dp(n.touchedFields,c),!o.keepIsValidating&&Dp(n.validatingFields,c),!t.shouldUnregister&&!o.keepDefaultValue&&Dp(i,c);g.state.next({values:Lf(a)}),g.state.next({...n,...o.keepDirty?{isDirty:I()}:{}}),!o.keepIsValid&&b()},de=({disabled:e,name:t})=>{if(Jf(e)&&o.mount||e||s.disabled.has(t)){let n=s.disabled.has(t)!==!!e;e?s.disabled.add(t):s.disabled.delete(t),n&&o.mount&&!o.action&&b()}},fe=(e,n={})=>{let a=K(r,e),c=Jf(n.disabled)||Jf(t.disabled),l=!s.registerName.has(e)&&a&&a._f&&!a._f.mount;return Xf(r,e,{...a||{},_f:{...a&&a._f?a._f:{ref:{name:e}},name:e,mount:!0,...n}}),s.mount.add(e),a&&!l?de({disabled:Jf(n.disabled)?n.disabled:t.disabled,name:e}):O(e,!0,n.value),{...c?{disabled:n.disabled||t.disabled}:{},...t.progressive?{required:!!n.required,min:Jp(n.min),max:Jp(n.max),minLength:Jp(n.minLength),maxLength:Jp(n.maxLength),pattern:Jp(n.pattern)}:{},name:e,onChange:ee,onBlur:ee,ref:c=>{if(c){s.registerName.add(e),fe(e,n),s.registerName.delete(e),a=K(r,e);let t=Gf(c.value)&&c.querySelectorAll&&c.querySelectorAll(`input,select,textarea`)[0]||c,o=Pp(t),l=a._f.refs||[];if(o?l.find(e=>e===t):t===a._f.ref)return;let u={...a._f};o?(u.refs=[...l.filter(Fp),t,...Array.isArray(K(i,e))?[{}]:[]],u.ref={type:t.type,name:e}):(u.ref=t,delete u.refs),Xf(r,e,{_f:u}),O(e,!1,void 0,t)}else a=K(r,e,{}),a._f&&(a._f.mount=!1),(t.shouldUnregister||n.shouldUnregister)&&!(Pf(s.array,e)&&o.action)&&s.unMount.add(e)}}},pe=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&cp(r,te,s.mount),me=e=>{Jf(e)&&(g.state.next({disabled:e}),cp(r,(t,n)=>{let i=K(r,n);i&&(t.disabled=i._f.disabled||e,Array.isArray(i._f.refs)&&i._f.refs.forEach(t=>{t.disabled=i._f.disabled||e}))},0,!1))},he=(e,i)=>async o=>{let c,l;o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let u=Lf(a);if(g.state.next({isSubmitting:!0}),t.resolver){let{errors:e,values:t}=await j();x(),n.errors=e,u=Lf(t)}else await P({fields:r,eventType:Rf.SUBMIT});if(s.disabled.size)for(let e of s.disabled)Dp(u,e);if(Dp(n.errors,Vf),up(n.errors)){g.state.next({errors:{}});try{c=await e(u,o)}catch(e){l=e}}else i&&await i({...n.errors},o),pe(),setTimeout(pe);if(g.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:up(n.errors)&&!l,submitCount:n.submitCount+1,errors:n.errors}),l)throw l;return c},ge=(e,t={})=>{K(r,e)&&(Gf(t.defaultValue)?H(e,Lf(K(i,e))):(H(e,t.defaultValue),Xf(i,e,Lf(t.defaultValue))),t.keepTouched||Dp(n.touchedFields,e),t.keepDirty||(Dp(n.dirtyFields,e),n.isDirty=t.defaultValue?I(e,Lf(K(i,e))):I()),t.keepError||(Dp(n.errors,e),m.isValid&&b()),g.state.next({...n}))},_e=(e,c={})=>{let l=e?Lf(e):i,u=Lf(l),d=up(e),f=u,p=r;if(c.keepDefaultValues||(i=l),!c.keepValues){if(c.keepDirtyValues){let e=new Set([...s.mount,...Lp(Wp(i,a,void 0,p),n.dirtyFields)]);for(let t of Array.from(e)){let e=K(n.dirtyFields,t),r=K(a,t),i=K(f,t);e&&!Gf(r)?Xf(f,t,r):!e&&!Gf(i)&&H(t,i)}}else{if(If&&Gf(e))for(let e of s.mount){let t=K(r,e);if(t&&t._f){let e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(dp(e)){let t=e.closest(`form`);if(t){t.reset();break}}}}if(c.keepFieldsRef)for(let e of s.mount)H(e,K(f,e));else r={}}if(t.shouldUnregister){if(a=c.keepDefaultValues?Lf(i):{},c.keepFieldsRef)for(let e of s.mount)Xf(a,e,K(f,e))}else a=Lf(f);g.array.next({values:{...f}}),g.state.next({name:void 0,type:void 0,values:{...f}})}s={mount:c.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:``},o.mount=!m.isValid||!!c.keepIsValid||!!c.keepDirtyValues||!t.shouldUnregister&&!up(f),o.watch=!!t.shouldUnregister,o.keepIsValid=!!c.keepIsValid,o.action=!1,o.actionArrayLengths.clear(),c.keepErrors||(n.errors={}),g.state.next({submitCount:c.keepSubmitCount?n.submitCount:0,isDirty:d?!1:c.keepDirty?n.isDirty:c.keepValues?I():!!(c.keepDefaultValues&&!np(e,i)),isSubmitted:c.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:d?{}:c.keepDirtyValues?c.keepDefaultValues&&a?Wp(i,a,void 0,p):n.dirtyFields:c.keepDefaultValues&&e?Wp(i,e,void 0,p):c.keepDirty?n.dirtyFields:{},touchedFields:c.keepTouched?n.touchedFields:{},errors:c.keepErrors?n.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:i})},ve=(e,n)=>_e(Yf(e)?e(a):e,{...t.resetOptions,...n}),ye=(e,t={})=>{let n=K(r,e),i=n&&n._f;if(i){let e=i.refs?i.refs[0]:i.ref;e.focus&&setTimeout(()=>{e.focus(),t.shouldSelect&&Yf(e.select)&&e.select()})}},be=e=>{let{name:t,type:r,values:i,...a}=e;n={...n,...a}};g.state.subscribe({next:be});let xe={control:{register:fe,unregister:ue,getFieldState:ie,handleSubmit:he,setError:oe,_subscribe:ce,_runSchema:j,_updateIsValidating:x,_focusError:pe,_getWatch:L,_getDirty:I,_setValid:b,_setFieldArray:C,_setDisabledField:de,_setErrors:T,_getFieldArray:R,_reset:_e,_resetDefaultValues:()=>Yf(t.defaultValues)&&t.defaultValues().then(e=>{ve(e,t.resetOptions),g.state.next({isLoading:!1})}),_removeUnmounted:F,_disableForm:me,_subjects:g,_proxyFormState:m,get _fields(){return r},get _formValues(){return a},get _state(){return o},set _state(e){o=e},get _defaultValues(){return i},get _names(){return s},set _names(e){s=e},get _formState(){return n},get _options(){return t},set _options(e){t={...t,...e},d=op(t.mode),f=op(t.reValidateMode)}},subscribe:le,trigger:ne,register:fe,handleSubmit:he,watch:se,setValue:H,setValues:U,getValues:re,reset:ve,resetField:ge,resetDefaultValues:(e,t={})=>{if(i=Lf(e),!t.keepDirty){let e=Wp(i,a,void 0,r);n.dirtyFields=e,n.isDirty=!up(e)}t.keepIsValid||b(),g.state.next({...n,defaultValues:i})},clearErrors:ae,unregister:ue,setError:oe,setFocus:ye,getFieldState:ie};return{...xe,formControl:xe}}function cm(e={}){let t=s.useRef(void 0),n=s.useRef(void 0),r=s.useRef(e.formControl),[i,a]=s.useState(()=>({...Lf(om),isLoading:Yf(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Yf(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&r.current!==e.formControl){if(r.current=e.formControl,e.formControl)t.current={...e.formControl,formState:i},e.defaultValues&&!Yf(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{let{formControl:n,...r}=sm(e);t.current={...r,formState:i}}}let o=t.current.control;o._options=e;let{resyncIfNeeded:c,snapshot:l}=rp();return $f(()=>{let e=()=>({...o._formState,defaultValues:o._defaultValues});c(!0,e,a);let t=o._subscribe({formState:o._proxyFormState,callback:()=>a({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return a(e=>({...e,isReady:!0})),o._formState.isReady=!0,()=>{t(),l(!0,e)}},[o,c,l]),s.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),s.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),s.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),s.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),s.useEffect(()=>{if(o._proxyFormState.isDirty){let e=o._getDirty();e!==i.isDirty&&o._subjects.state.next({isDirty:e})}},[o,i.isDirty]),s.useEffect(()=>{e.values&&!np(e.values,n.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),o._options.resetOptions?.keepIsValid||o._setValid(),n.current=e.values,a(e=>({...e}))):o._resetDefaultValues()},[o,e.values]),s.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=s.useMemo(()=>Qf(i,o),[o,i]),t.current}var lm=(e,t,n)=>{if(e&&`reportValidity`in e){let r=K(n,t);e.setCustomValidity(r&&r.message||``),e.reportValidity()}},um=(e,t)=>{for(let n in t.fields){let r=t.fields[n];r&&r.ref&&`reportValidity`in r.ref?lm(r.ref,n,e):r&&r.refs&&r.refs.forEach(t=>lm(t,n,e))}},dm=(e,t)=>{t.shouldUseNativeValidation&&um(e,t);let n={};for(let r in e){let i=K(t.fields,r),a=Object.assign(e[r]||{},{ref:i&&i.refs?i.refs[0]:i&&i.ref});if(fm(t.names||Object.keys(e),r)){let e=Object.assign({},K(n,r));Xf(e,`root`,a),Xf(n,r,e)}else Xf(n,r,a)}return n},fm=(e,t)=>{let n=pm(t).replace(/[.*+?^${}()|\\]/g,`\\$&`);return e.some(e=>pm(e).match(`^${n}\\.\\d+`))};function pm(e){return e.replace(/[\[\]]/g,``)}function mm(){return mm=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},mm.apply(null,arguments)}function hm(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}function gm(e,t){for(var n=Object.create(null);e.length;){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o]){if(`unionErrors`in r){var s=r.unionErrors.reduce(function(e,t){return t.errors.length<e.errors.length?t:e}).errors[0];n[o]={message:s?.message??a,type:s?.code??i}}else n[o]={message:a,type:i}}if(`unionErrors`in r&&r.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=mp(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()}return n}function _m(e,t){for(var n=Object.create(null),r=function(){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o]){if(r.code===`invalid_union`&&r.errors.length>0){var s=r.errors.reduce(function(e,t){return t.length<e.length?t:e})[0];n[o]={message:s?.message??a,type:s?.code??i}}else n[o]={message:a,type:i}}if(r.code===`invalid_union`&&r.errors.forEach(function(t){return t.forEach(function(t){return e.push(mm({},t,{path:[].concat(r.path,t.path)}))})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=mp(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()};e.length;)r();return n}function vm(e,t,n){if(n===void 0&&(n={}),function(e){return`_zod`in e&&typeof e._zod==`object`}(e))return function(r,i,a){try{return Promise.resolve(hm(function(){function i(e){return a.shouldUseNativeValidation&&um({},a),{errors:{},values:n.raw?Object.assign({},r):e}}var o=e;return n.mode===`sync`?i(o.parse(r,t)):Promise.resolve(o.parseAsync(r,t)).then(i)},function(e){if(function(e){var t;return!(e==null||(t=e._zod)==null||(t=t.traits)==null||!t.has(`$ZodError`))}(e))return{values:{},errors:dm(_m(e.issues,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}};if(function(e){return`_def`in e&&typeof e._def==`object`}(e))return function(r,i,a){try{return Promise.resolve(hm(function(){return Promise.resolve(e[n.mode===`sync`?`parse`:`parseAsync`](r,t)).then(function(e){return a.shouldUseNativeValidation&&um({},a),{errors:{},values:n.raw?Object.assign({},r):e}})},function(e){if(function(e){return Array.isArray(e?.issues)}(e))return{values:{},errors:dm(gm(e.errors,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}};throw Error(`Invalid input: not a Zod schema`)}var ym=[],bm=0,xm=new Set;function Sm(){xm.forEach(e=>e([...ym]))}function Cm(e,t=``,n=`success`){let r=`${n}:${e}:${t}`;if(ym.some(e=>e.toastKey===r))return;let i={key:++bm,toastKey:r,title:e,message:t,type:n};ym=[...ym,i],Sm(),window.setTimeout(()=>{ym=ym.filter(e=>e.key!==i.key),Sm()},n===`error`?7e3:3600)}function wm(){let[e,t]=(0,s.useState)(ym);return(0,s.useEffect)(()=>{let e=e=>t(e);return xm.add(e),()=>{xm.delete(e)}},[]),(0,W.jsx)(`div`,{className:`toast-region`,"aria-live":`polite`,"aria-atomic":`true`,children:e.map(e=>(0,W.jsxs)(`div`,{className:`toast ${e.type}`,children:[e.type===`error`?(0,W.jsx)(I,{size:15}):(0,W.jsx)(j,{size:15}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.title}),e.message?(0,W.jsx)(`p`,{children:e.message}):null]})]},e.key))})}var Tm=n(((e,t)=>{var n=!1,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_;function v(){if(!n){n=!0;var e=navigator.userAgent,t=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(e),v=/(Mac OS X)|(Windows)|(Linux)/.exec(e);if(m=/\b(iPhone|iP[ao]d)/.exec(e),h=/\b(iP[ao]d)/.exec(e),f=/Android/i.exec(e),g=/FBAN\/\w+;/i.exec(e),_=/Mobile/i.exec(e),p=!!/Win64/.exec(e),t){r=t[1]?parseFloat(t[1]):t[5]?parseFloat(t[5]):NaN,r&&document&&document.documentMode&&(r=document.documentMode);var y=/(?:Trident\/(\d+.\d+))/.exec(e);c=y?parseFloat(y[1])+4:r,i=t[2]?parseFloat(t[2]):NaN,a=t[3]?parseFloat(t[3]):NaN,o=t[4]?parseFloat(t[4]):NaN,o?(t=/(?:Chrome\/(\d+\.\d+))/.exec(e),s=t&&t[1]?parseFloat(t[1]):NaN):s=NaN}else r=i=a=s=o=NaN;if(v){if(v[1]){var b=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(e);l=!b||parseFloat(b[1].replace(`_`,`.`))}else l=!1;u=!!v[2],d=!!v[3]}else l=u=d=!1}}var y={ie:function(){return v()||r},ieCompatibilityMode:function(){return v()||c>r},ie64:function(){return y.ie()&&p},firefox:function(){return v()||i},opera:function(){return v()||a},webkit:function(){return v()||o},safari:function(){return y.webkit()},chrome:function(){return v()||s},windows:function(){return v()||u},osx:function(){return v()||l},linux:function(){return v()||d},iphone:function(){return v()||m},mobile:function(){return v()||m||h||f||_},nativeApp:function(){return v()||g},android:function(){return v()||f},ipad:function(){return v()||h}};t.exports=y})),Em=n(((e,t)=>{var n=!!(typeof window<`u`&&window.document&&window.document.createElement);t.exports={canUseDOM:n,canUseWorkers:typeof Worker<`u`,canUseEventListeners:n&&!!(window.addEventListener||window.attachEvent),canUseViewport:n&&!!window.screen,isInWorker:!n}})),Dm=n(((e,t)=>{var n=Em(),r;n.canUseDOM&&(r=document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature(``,``)!==!0);function i(e,t){if(!n.canUseDOM||t&&!(`addEventListener`in document))return!1;var i=`on`+e,a=i in document;if(!a){var o=document.createElement(`div`);o.setAttribute(i,`return;`),a=typeof o[i]==`function`}return!a&&r&&e===`wheel`&&(a=document.implementation.hasFeature(`Events.wheel`,`3.0`)),a}t.exports=i})),Om=n(((e,t)=>{var n=Tm(),r=Dm(),i=10,a=40,o=800;function s(e){var t=0,n=0,r=0,s=0;return`detail`in e&&(n=e.detail),`wheelDelta`in e&&(n=-e.wheelDelta/120),`wheelDeltaY`in e&&(n=-e.wheelDeltaY/120),`wheelDeltaX`in e&&(t=-e.wheelDeltaX/120),`axis`in e&&e.axis===e.HORIZONTAL_AXIS&&(t=n,n=0),r=t*i,s=n*i,`deltaY`in e&&(s=e.deltaY),`deltaX`in e&&(r=e.deltaX),(r||s)&&e.deltaMode&&(e.deltaMode==1?(r*=a,s*=a):(r*=o,s*=o)),r&&!t&&(t=r<1?-1:1),s&&!n&&(n=s<1?-1:1),{spinX:t,spinY:n,pixelX:r,pixelY:s}}s.getEventType=function(){return n.firefox()?`DOMMouseScroll`:r(`wheel`)?`wheel`:`mousewheel`},t.exports=s})),km=t(n(((e,t)=>{t.exports=Om()}))(),1);function Am(e,t,n,r,i,a){a===void 0&&(a=0);var o=Wm(e,t,a),s=o.width,c=o.height,l=Math.min(s,n),u=Math.min(c,r);return l>u*i?{width:u*i,height:u}:{width:l,height:l/i}}function jm(e){return e.width>e.height?e.width/e.naturalWidth:e.height/e.naturalHeight}function Mm(e,t,n,r,i){i===void 0&&(i=0);var a=Wm(t.width,t.height,i),o=a.width,s=a.height;return{x:Nm(e.x,o,n.width,r),y:Nm(e.y,s,n.height,r)}}function Nm(e,t,n,r){var i=Math.abs(t*r/2-n/2);return Gm(e,-i,i)}function Pm(e,t){return Math.sqrt((e.y-t.y)**2+(e.x-t.x)**2)}function Fm(e,t){return Math.atan2(t.y-e.y,t.x-e.x)*180/Math.PI}function Im(e,t,n,r,i,a,o){a===void 0&&(a=0),o===void 0&&(o=!0);var s=o?Lm:Rm,c=Wm(t.width,t.height,a),l=Wm(t.naturalWidth,t.naturalHeight,a),u={x:s(100,((c.width-n.width/i)/2-e.x/i)/c.width*100),y:s(100,((c.height-n.height/i)/2-e.y/i)/c.height*100),width:s(100,n.width/c.width*100/i),height:s(100,n.height/c.height*100/i)},d=Math.round(s(l.width,u.width*l.width/100)),f=Math.round(s(l.height,u.height*l.height/100)),p=l.width>=l.height*r?{width:Math.round(f*r),height:f}:{width:d,height:Math.round(d/r)};return{croppedAreaPercentages:u,croppedAreaPixels:or(or({},p),{x:Math.round(s(l.width-p.width,u.x*l.width/100)),y:Math.round(s(l.height-p.height,u.y*l.height/100))})}}function Lm(e,t){return Math.min(e,Math.max(0,t))}function Rm(e,t){return t}function zm(e,t,n,r,i,a){var o=Wm(t.width,t.height,n),s=Gm(r.width/o.width*(100/e.width),i,a);return{crop:{x:s*o.width/2-r.width/2-o.width*s*(e.x/100),y:s*o.height/2-r.height/2-o.height*s*(e.y/100)},zoom:s}}function Bm(e,t,n){var r=jm(t);return n.height>n.width?n.height/(e.height*r):n.width/(e.width*r)}function Vm(e,t,n,r,i,a){n===void 0&&(n=0);var o=Wm(t.naturalWidth,t.naturalHeight,n),s=Gm(Bm(e,t,r),i,a),c=r.height>r.width?r.height/e.height:r.width/e.width;return{crop:{x:((o.width-e.width)/2-e.x)*c,y:((o.height-e.height)/2-e.y)*c},zoom:s}}function Hm(e,t){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}function Um(e){return e*Math.PI/180}function Wm(e,t,n){var r=Um(n);return{width:Math.abs(Math.cos(r)*e)+Math.abs(Math.sin(r)*t),height:Math.abs(Math.sin(r)*e)+Math.abs(Math.cos(r)*t)}}function Gm(e,t,n){return Math.min(Math.max(e,t),n)}function Km(){return[...arguments].filter(function(e){return typeof e==`string`&&e.length>0}).join(` `).trim()}var qm=`.reactEasyCrop_Container {
|
|
43
|
-
position: absolute;
|
|
44
|
-
top: 0;
|
|
45
|
-
left: 0;
|
|
46
|
-
right: 0;
|
|
47
|
-
bottom: 0;
|
|
48
|
-
overflow: hidden;
|
|
49
|
-
user-select: none;
|
|
50
|
-
touch-action: none;
|
|
51
|
-
cursor: move;
|
|
52
|
-
display: flex;
|
|
53
|
-
justify-content: center;
|
|
54
|
-
align-items: center;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.reactEasyCrop_Image,
|
|
58
|
-
.reactEasyCrop_Video {
|
|
59
|
-
will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.reactEasyCrop_Contain {
|
|
63
|
-
max-width: 100%;
|
|
64
|
-
max-height: 100%;
|
|
65
|
-
margin: auto;
|
|
66
|
-
position: absolute;
|
|
67
|
-
top: 0;
|
|
68
|
-
bottom: 0;
|
|
69
|
-
left: 0;
|
|
70
|
-
right: 0;
|
|
71
|
-
}
|
|
72
|
-
.reactEasyCrop_Cover_Horizontal {
|
|
73
|
-
width: 100%;
|
|
74
|
-
height: auto;
|
|
75
|
-
}
|
|
76
|
-
.reactEasyCrop_Cover_Vertical {
|
|
77
|
-
width: auto;
|
|
78
|
-
height: 100%;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.reactEasyCrop_CropArea {
|
|
82
|
-
position: absolute;
|
|
83
|
-
left: 50%;
|
|
84
|
-
top: 50%;
|
|
85
|
-
transform: translate(-50%, -50%);
|
|
86
|
-
border: 1px solid rgba(255, 255, 255, 0.5);
|
|
87
|
-
box-sizing: border-box;
|
|
88
|
-
box-shadow: 0 0 0 9999em;
|
|
89
|
-
color: rgba(0, 0, 0, 0.5);
|
|
90
|
-
overflow: hidden;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.reactEasyCrop_CropAreaRound {
|
|
94
|
-
border-radius: 50%;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.reactEasyCrop_CropAreaGrid::before {
|
|
98
|
-
content: ' ';
|
|
99
|
-
box-sizing: border-box;
|
|
100
|
-
position: absolute;
|
|
101
|
-
border: 1px solid rgba(255, 255, 255, 0.5);
|
|
102
|
-
top: 0;
|
|
103
|
-
bottom: 0;
|
|
104
|
-
left: 33.33%;
|
|
105
|
-
right: 33.33%;
|
|
106
|
-
border-top: 0;
|
|
107
|
-
border-bottom: 0;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.reactEasyCrop_CropAreaGrid::after {
|
|
111
|
-
content: ' ';
|
|
112
|
-
box-sizing: border-box;
|
|
113
|
-
position: absolute;
|
|
114
|
-
border: 1px solid rgba(255, 255, 255, 0.5);
|
|
115
|
-
top: 33.33%;
|
|
116
|
-
bottom: 33.33%;
|
|
117
|
-
left: 0;
|
|
118
|
-
right: 0;
|
|
119
|
-
border-left: 0;
|
|
120
|
-
border-right: 0;
|
|
121
|
-
}
|
|
122
|
-
`,Jm=1,Ym=3,Xm=1,Zm=function(e){ar(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.cropperRef=s.createRef(),n.imageRef=s.createRef(),n.videoRef=s.createRef(),n.containerPosition={x:0,y:0},n.containerRef=null,n.styleRef=null,n.containerRect=null,n.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},n.dragStartPosition={x:0,y:0},n.dragStartCrop={x:0,y:0},n.gestureZoomStart=0,n.gestureRotationStart=0,n.isTouching=!1,n.lastPinchDistance=0,n.lastPinchRotation=0,n.rafDragTimeout=null,n.rafPinchTimeout=null,n.wheelTimer=null,n.currentDoc=typeof document<`u`?document:null,n.currentWindow=typeof window<`u`?window:null,n.resizeObserver=null,n.previousCropSize=null,n.isInitialized=!1,n.state={cropSize:null,hasWheelJustStarted:!1,mediaObjectFit:void 0},n.initResizeObserver=function(){if(!(window.ResizeObserver===void 0||!n.containerRef)){var e=!0;n.resizeObserver=new window.ResizeObserver(function(t){if(e){e=!1;return}n.computeSizes()}),n.resizeObserver.observe(n.containerRef)}},n.preventZoomSafari=function(e){return e.preventDefault()},n.cleanEvents=function(){n.currentDoc&&(n.currentDoc.removeEventListener(`mousemove`,n.onMouseMove),n.currentDoc.removeEventListener(`mouseup`,n.onDragStopped),n.currentDoc.removeEventListener(`touchmove`,n.onTouchMove),n.currentDoc.removeEventListener(`touchend`,n.onDragStopped),n.currentDoc.removeEventListener(`gesturechange`,n.onGestureChange),n.currentDoc.removeEventListener(`gestureend`,n.onGestureEnd),n.currentDoc.removeEventListener(`scroll`,n.onScroll))},n.clearScrollEvent=function(){n.containerRef&&n.containerRef.removeEventListener(`wheel`,n.onWheel),n.wheelTimer&&clearTimeout(n.wheelTimer)},n.onMediaLoad=function(){var e=n.computeSizes();e&&(n.previousCropSize=e,n.emitCropData(),n.setInitialCrop(e),n.isInitialized=!0),n.props.onMediaLoaded&&n.props.onMediaLoaded(n.mediaSize)},n.setInitialCrop=function(e){if(n.props.initialCroppedAreaPercentages){var t=zm(n.props.initialCroppedAreaPercentages,n.mediaSize,n.props.rotation,e,n.props.minZoom,n.props.maxZoom),r=t.crop,i=t.zoom;n.props.onCropChange(r),n.props.onZoomChange&&n.props.onZoomChange(i)}else if(n.props.initialCroppedAreaPixels){var a=Vm(n.props.initialCroppedAreaPixels,n.mediaSize,n.props.rotation,e,n.props.minZoom,n.props.maxZoom),r=a.crop,i=a.zoom;n.props.onCropChange(r),n.props.onZoomChange&&n.props.onZoomChange(i)}},n.computeSizes=function(){var e=n.imageRef.current||n.videoRef.current;if(e&&n.containerRef){n.containerRect=n.containerRef.getBoundingClientRect(),n.saveContainerPosition();var t=n.containerRect.width/n.containerRect.height,r=n.imageRef.current?.naturalWidth||n.videoRef.current?.videoWidth||0,i=n.imageRef.current?.naturalHeight||n.videoRef.current?.videoHeight||0,a=e.offsetWidth<r||e.offsetHeight<i,o=r/i,s=void 0;if(a)switch(n.state.mediaObjectFit){default:case`contain`:s=t>o?{width:n.containerRect.height*o,height:n.containerRect.height}:{width:n.containerRect.width,height:n.containerRect.width/o};break;case`horizontal-cover`:s={width:n.containerRect.width,height:n.containerRect.width/o};break;case`vertical-cover`:s={width:n.containerRect.height*o,height:n.containerRect.height}}else s={width:e.offsetWidth,height:e.offsetHeight};n.mediaSize=or(or({},s),{naturalWidth:r,naturalHeight:i}),n.props.setMediaSize&&n.props.setMediaSize(n.mediaSize);var c=n.props.cropSize?n.props.cropSize:Am(n.mediaSize.width,n.mediaSize.height,n.containerRect.width,n.containerRect.height,n.props.aspect,n.props.rotation);return(n.state.cropSize?.height!==c.height||n.state.cropSize?.width!==c.width)&&n.props.onCropSizeChange&&n.props.onCropSizeChange(c),n.setState({cropSize:c},n.recomputeCropPosition),n.props.setCropSize&&n.props.setCropSize(c),c}},n.saveContainerPosition=function(){if(n.containerRef){var e=n.containerRef.getBoundingClientRect();n.containerPosition={x:e.left,y:e.top}}},n.onMouseDown=function(e){n.currentDoc&&(e.preventDefault(),n.currentDoc.addEventListener(`mousemove`,n.onMouseMove),n.currentDoc.addEventListener(`mouseup`,n.onDragStopped),n.saveContainerPosition(),n.onDragStart(t.getMousePoint(e)))},n.onMouseMove=function(e){return n.onDrag(t.getMousePoint(e))},n.onScroll=function(e){n.currentDoc&&(e.preventDefault(),n.saveContainerPosition())},n.onTouchStart=function(e){n.currentDoc&&(n.isTouching=!0,!(n.props.onTouchRequest&&!n.props.onTouchRequest(e))&&(n.currentDoc.addEventListener(`touchmove`,n.onTouchMove,{passive:!1}),n.currentDoc.addEventListener(`touchend`,n.onDragStopped),n.saveContainerPosition(),e.touches.length===2?n.onPinchStart(e):e.touches.length===1&&n.onDragStart(t.getTouchPoint(e.touches[0]))))},n.onTouchMove=function(e){e.preventDefault(),e.touches.length===2?n.onPinchMove(e):e.touches.length===1&&n.onDrag(t.getTouchPoint(e.touches[0]))},n.onGestureStart=function(e){n.currentDoc&&(e.preventDefault(),n.currentDoc.addEventListener(`gesturechange`,n.onGestureChange),n.currentDoc.addEventListener(`gestureend`,n.onGestureEnd),n.gestureZoomStart=n.props.zoom,n.gestureRotationStart=n.props.rotation)},n.onGestureChange=function(e){if(e.preventDefault(),!n.isTouching){var r=t.getMousePoint(e),i=n.gestureZoomStart-1+e.scale;if(n.setNewZoom(i,r,{shouldUpdatePosition:!0}),n.props.onRotationChange){var a=n.gestureRotationStart+e.rotation;n.props.onRotationChange(a)}}},n.onGestureEnd=function(e){n.cleanEvents()},n.onDragStart=function(e){var t,r;n.dragStartPosition={x:e.x,y:e.y},n.dragStartCrop=or({},n.props.crop),(r=(t=n.props).onInteractionStart)==null||r.call(t)},n.onDrag=function(e){var t=e.x,r=e.y;n.currentWindow&&(n.rafDragTimeout&&n.currentWindow.cancelAnimationFrame(n.rafDragTimeout),n.rafDragTimeout=n.currentWindow.requestAnimationFrame(function(){if(n.state.cropSize&&t!==void 0&&r!==void 0){var e=t-n.dragStartPosition.x,i=r-n.dragStartPosition.y,a={x:n.dragStartCrop.x+e,y:n.dragStartCrop.y+i},o=n.props.restrictPosition?Mm(a,n.mediaSize,n.state.cropSize,n.props.zoom,n.props.rotation):a;n.props.onCropChange(o)}}))},n.onDragStopped=function(){var e,t;n.isTouching=!1,n.cleanEvents(),n.emitCropData(),(t=(e=n.props).onInteractionEnd)==null||t.call(e)},n.onWheel=function(e){if(n.currentWindow&&!(n.props.onWheelRequest&&!n.props.onWheelRequest(e))){e.preventDefault();var r=t.getMousePoint(e),i=(0,km.default)(e).pixelY,a=n.props.zoom-i*n.props.zoomSpeed/200;n.setNewZoom(a,r,{shouldUpdatePosition:!0}),n.state.hasWheelJustStarted||n.setState({hasWheelJustStarted:!0},function(){var e;return(e=n.props).onInteractionStart?.call(e)}),n.wheelTimer&&clearTimeout(n.wheelTimer),n.wheelTimer=n.currentWindow.setTimeout(function(){return n.setState({hasWheelJustStarted:!1},function(){var e;return(e=n.props).onInteractionEnd?.call(e)})},250)}},n.getPointOnContainer=function(e,t){var r=e.x,i=e.y;if(!n.containerRect)throw Error(`The Cropper is not mounted`);return{x:n.containerRect.width/2-(r-t.x),y:n.containerRect.height/2-(i-t.y)}},n.getPointOnMedia=function(e){var t=e.x,r=e.y,i=n.props,a=i.crop,o=i.zoom;return{x:(t+a.x)/o,y:(r+a.y)/o}},n.setNewZoom=function(e,t,r){var i=(r===void 0?{}:r).shouldUpdatePosition,a=i===void 0||i;if(!(!n.state.cropSize||!n.props.onZoomChange)){var o=Gm(e,n.props.minZoom,n.props.maxZoom);if(a){var s=n.getPointOnContainer(t,n.containerPosition),c=n.getPointOnMedia(s),l={x:c.x*o-s.x,y:c.y*o-s.y},u=n.props.restrictPosition?Mm(l,n.mediaSize,n.state.cropSize,o,n.props.rotation):l;n.props.onCropChange(u)}n.props.onZoomChange(o)}},n.getCropData=function(){return n.state.cropSize?Im(n.props.restrictPosition?Mm(n.props.crop,n.mediaSize,n.state.cropSize,n.props.zoom,n.props.rotation):n.props.crop,n.mediaSize,n.state.cropSize,n.getAspect(),n.props.zoom,n.props.rotation,n.props.restrictPosition):null},n.emitCropData=function(){var e=n.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;n.props.onCropComplete&&n.props.onCropComplete(t,r),n.props.onCropAreaChange&&n.props.onCropAreaChange(t,r)}},n.emitCropAreaChange=function(){var e=n.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;n.props.onCropAreaChange&&n.props.onCropAreaChange(t,r)}},n.recomputeCropPosition=function(){if(n.state.cropSize){var e=n.props.crop;if(n.isInitialized&&n.previousCropSize?.width&&n.previousCropSize?.height&&(Math.abs(n.previousCropSize.width-n.state.cropSize.width)>1e-6||Math.abs(n.previousCropSize.height-n.state.cropSize.height)>1e-6)){var t=n.state.cropSize.width/n.previousCropSize.width,r=n.state.cropSize.height/n.previousCropSize.height;e={x:n.props.crop.x*t,y:n.props.crop.y*r}}var i=n.props.restrictPosition?Mm(e,n.mediaSize,n.state.cropSize,n.props.zoom,n.props.rotation):e;n.previousCropSize=n.state.cropSize,n.props.onCropChange(i),n.emitCropData()}},n.onKeyDown=function(e){var t,r,i=n.props,a=i.crop,o=i.onCropChange,s=i.keyboardStep,c=i.zoom,l=i.rotation,u=s;if(n.state.cropSize){e.shiftKey&&(u*=.2);var d=or({},a);switch(e.key){case`ArrowUp`:d.y-=u,e.preventDefault();break;case`ArrowDown`:d.y+=u,e.preventDefault();break;case`ArrowLeft`:d.x-=u,e.preventDefault();break;case`ArrowRight`:d.x+=u,e.preventDefault();break;default:return}n.props.restrictPosition&&(d=Mm(d,n.mediaSize,n.state.cropSize,c,l)),e.repeat||(r=(t=n.props).onInteractionStart)==null||r.call(t),o(d)}},n.onKeyUp=function(e){var t,r;switch(e.key){case`ArrowUp`:case`ArrowDown`:case`ArrowLeft`:case`ArrowRight`:e.preventDefault();break;default:return}n.emitCropData(),(r=(t=n.props).onInteractionEnd)==null||r.call(t)},n}return t.prototype.componentDidMount=function(){!this.currentDoc||!this.currentWindow||(this.containerRef&&(this.containerRef.ownerDocument&&(this.currentDoc=this.containerRef.ownerDocument),this.currentDoc.defaultView&&(this.currentWindow=this.currentDoc.defaultView),this.initResizeObserver(),window.ResizeObserver===void 0&&this.currentWindow.addEventListener(`resize`,this.computeSizes),this.props.zoomWithScroll&&this.containerRef.addEventListener(`wheel`,this.onWheel,{passive:!1}),this.containerRef.addEventListener(`gesturestart`,this.onGestureStart)),this.currentDoc.addEventListener(`scroll`,this.onScroll),this.props.disableAutomaticStylesInjection||(this.styleRef=this.currentDoc.createElement(`style`),this.styleRef.setAttribute(`type`,`text/css`),this.props.nonce&&this.styleRef.setAttribute(`nonce`,this.props.nonce),this.styleRef.innerHTML=qm,this.currentDoc.head.appendChild(this.styleRef)),this.imageRef.current&&this.imageRef.current.complete&&this.onMediaLoad(),this.props.setImageRef&&this.props.setImageRef(this.imageRef),this.props.setVideoRef&&this.props.setVideoRef(this.videoRef),this.props.setCropperRef&&this.props.setCropperRef(this.cropperRef))},t.prototype.componentWillUnmount=function(){var e,t;!this.currentDoc||!this.currentWindow||(window.ResizeObserver===void 0&&this.currentWindow.removeEventListener(`resize`,this.computeSizes),(e=this.resizeObserver)==null||e.disconnect(),this.containerRef&&this.containerRef.removeEventListener(`gesturestart`,this.preventZoomSafari),this.styleRef&&((t=this.styleRef.parentNode)==null||t.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent())},t.prototype.componentDidUpdate=function(e){var t;e.rotation===this.props.rotation?e.aspect===this.props.aspect&&e.objectFit===this.props.objectFit?e.zoom===this.props.zoom?e.cropSize?.height!==this.props.cropSize?.height||e.cropSize?.width!==this.props.cropSize?.width?this.computeSizes():(e.crop?.x!==this.props.crop?.x||e.crop?.y!==this.props.crop?.y)&&this.emitCropAreaChange():this.recomputeCropPosition():this.computeSizes():(this.computeSizes(),this.recomputeCropPosition()),e.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener(`wheel`,this.onWheel,{passive:!1}):this.clearScrollEvent()),e.video!==this.props.video&&((t=this.videoRef.current)==null||t.load());var n=this.getObjectFit();n!==this.state.mediaObjectFit&&this.setState({mediaObjectFit:n},this.computeSizes)},t.prototype.getAspect=function(){var e=this.props,t=e.cropSize,n=e.aspect;return t?t.width/t.height:n},t.prototype.getObjectFit=function(){if(this.props.objectFit===`cover`){if((this.imageRef.current||this.videoRef.current)&&this.containerRef){this.containerRect=this.containerRef.getBoundingClientRect();var e=this.containerRect.width/this.containerRect.height;return(this.imageRef.current?.naturalWidth||this.videoRef.current?.videoWidth||0)/(this.imageRef.current?.naturalHeight||this.videoRef.current?.videoHeight||0)<e?`horizontal-cover`:`vertical-cover`}return`horizontal-cover`}return this.props.objectFit},t.prototype.onPinchStart=function(e){var n=t.getTouchPoint(e.touches[0]),r=t.getTouchPoint(e.touches[1]);this.lastPinchDistance=Pm(n,r),this.lastPinchRotation=Fm(n,r),this.onDragStart(Hm(n,r))},t.prototype.onPinchMove=function(e){var n=this;if(!(!this.currentDoc||!this.currentWindow)){var r=t.getTouchPoint(e.touches[0]),i=t.getTouchPoint(e.touches[1]),a=Hm(r,i);this.onDrag(a),this.rafPinchTimeout&&this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout),this.rafPinchTimeout=this.currentWindow.requestAnimationFrame(function(){var e=Pm(r,i),t=n.props.zoom*(e/n.lastPinchDistance);n.setNewZoom(t,a,{shouldUpdatePosition:!1}),n.lastPinchDistance=e;var o=Fm(r,i),s=n.props.rotation+(o-n.lastPinchRotation);n.props.onRotationChange&&n.props.onRotationChange(s),n.lastPinchRotation=o})}},t.prototype.render=function(){var e=this,t=this.props,n=t.image,r=t.video,i=t.mediaProps,a=t.cropperProps,o=t.transform,c=t.crop,l=c.x,u=c.y,d=t.rotation,f=t.zoom,p=t.cropShape,m=t.showGrid,h=t.roundCropAreaPixels,g=t.style,_=g.containerStyle,v=g.cropAreaStyle,y=g.mediaStyle,b=t.classes,x=b.containerClassName,S=b.cropAreaClassName,C=b.mediaClassName,w=this.state.mediaObjectFit??this.getObjectFit();return s.createElement(`div`,{onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,ref:function(t){return e.containerRef=t},"data-testid":`container`,style:_,className:Km(`reactEasyCrop_Container`,x)},n?s.createElement(`img`,or({alt:``,className:Km(`reactEasyCrop_Image`,w===`contain`&&`reactEasyCrop_Contain`,w===`horizontal-cover`&&`reactEasyCrop_Cover_Horizontal`,w===`vertical-cover`&&`reactEasyCrop_Cover_Vertical`,C)},i,{src:n,ref:this.imageRef,style:or(or({},y),{transform:o||`translate(${l}px, ${u}px) rotate(${d}deg) scale(${f})`}),onLoad:this.onMediaLoad})):r&&s.createElement(`video`,or({autoPlay:!0,playsInline:!0,loop:!0,muted:!0,className:Km(`reactEasyCrop_Video`,w===`contain`&&`reactEasyCrop_Contain`,w===`horizontal-cover`&&`reactEasyCrop_Cover_Horizontal`,w===`vertical-cover`&&`reactEasyCrop_Cover_Vertical`,C)},i,{ref:this.videoRef,onLoadedMetadata:this.onMediaLoad,style:or(or({},y),{transform:o||`translate(${l}px, ${u}px) rotate(${d}deg) scale(${f})`}),controls:!1}),(Array.isArray(r)?r:[{src:r}]).map(function(e){return s.createElement(`source`,or({key:e.src},e))})),this.state.cropSize&&s.createElement(`div`,or({ref:this.cropperRef,style:or(or({},v),{width:h?Math.round(this.state.cropSize.width):this.state.cropSize.width,height:h?Math.round(this.state.cropSize.height):this.state.cropSize.height}),tabIndex:0,onKeyDown:this.onKeyDown,onKeyUp:this.onKeyUp,"data-testid":`cropper`,className:Km(`reactEasyCrop_CropArea`,p===`round`&&`reactEasyCrop_CropAreaRound`,m&&`reactEasyCrop_CropAreaGrid`,S)},a)))},t.defaultProps={zoom:1,rotation:0,aspect:4/3,maxZoom:Ym,minZoom:Jm,cropShape:`rect`,objectFit:`contain`,showGrid:!0,style:{},classes:{},mediaProps:{},cropperProps:{},zoomSpeed:1,restrictPosition:!0,zoomWithScroll:!0,keyboardStep:Xm},t.getMousePoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},t.getTouchPoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},t}(s.Component),Qm=[{id:`bot`,label:`Bot`,icon:O},{id:`sparkles`,label:`Sparkles`,icon:He},{id:`search`,label:`Search`,icon:Ie},{id:`code`,label:`Code`,icon:H},{id:`workflow`,label:`Workflow`,icon:Te}],$m=[{value:`#426ea8`,label:`云蓝`},{value:`#7c5cc4`,label:`紫罗兰`},{value:`#2d7c68`,label:`松石绿`},{value:`#a86d32`,label:`琥珀`},{value:`#a55267`,label:`玫瑰`},{value:`#526173`,label:`石墨`}];function eh(e){return{icon:e?.icon||`bot`,color:e?.color||`#426ea8`,imageUrl:e?.imageUrl||null}}async function th(e){let t=new Image;return t.decoding=`async`,t.src=e,await t.decode(),t}async function nh(e,t){let n=await th(e),r=document.createElement(`canvas`);r.width=512,r.height=512;let i=r.getContext(`2d`);if(!i)throw Error(`当前浏览器无法创建头像画布`);i.imageSmoothingEnabled=!0,i.imageSmoothingQuality=`high`,i.drawImage(n,t.x,t.y,t.width,t.height,0,0,r.width,r.height);let a=await new Promise(e=>r.toBlob(e,`image/webp`,.9));if(!a)throw Error(`头像裁剪失败,请更换图片后重试`);return a}function rh({name:e,appearance:t,disabled:n=!1,onSave:r}){let[i,a]=(0,s.useState)(()=>eh(t)),[o,c]=(0,s.useState)(null),[l,u]=(0,s.useState)({x:0,y:0}),[d,p]=(0,s.useState)(1),[m,h]=(0,s.useState)(null),[g,_]=(0,s.useState)(!1),[v,y]=(0,s.useState)(!1),[b,x]=(0,s.useState)(``),S=(0,s.useRef)(null);(0,s.useEffect)(()=>a(eh(t)),[t]),(0,s.useEffect)(()=>()=>{o&&URL.revokeObjectURL(o)},[o]);let C=eh(t),w=i.icon!==C.icon||i.color!==C.color||i.imageUrl!==C.imageUrl;function T(e){if(x(``),e){if(![`image/png`,`image/webp`].includes(e.type)){x(`仅支持 PNG 或 WebP 图片`);return}if(e.size>2097152){x(`头像文件不能超过 2 MiB`);return}u({x:0,y:0}),p(1),h(null),c(URL.createObjectURL(e))}}async function E(){if(!(!o||!m||g)){_(!0),x(``);try{let e=await nh(o,m),t=await f(`/api/v1/assets/agent-avatars`,{method:`POST`,headers:{"Content-Type":e.type},body:e}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error?.message||`头像上传失败(${t.status})`);a(e=>({...e,imageUrl:n.url})),c(null)}catch(e){x(e instanceof Error?e.message:`头像上传失败`)}finally{_(!1)}}}async function D(){if(!(!w||v||n)){y(!0),x(``);try{await r(i)}catch(e){x(e instanceof Error?e.message:`外观保存失败`)}finally{y(!1)}}}return(0,W.jsxs)(`section`,{className:`agent-appearance-editor`,"aria-label":`Agent 外观`,children:[(0,W.jsxs)(`div`,{className:`agent-appearance-preview`,children:[(0,W.jsx)(nt,{name:e,appearance:i,size:`lg`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`Agent 外观`}),(0,W.jsx)(`span`,{children:`用于列表、会话和 Trace;不会写入模型提示词。`})]})]}),(0,W.jsxs)(`div`,{className:`agent-appearance-controls`,children:[(0,W.jsxs)(`div`,{className:`appearance-choice-group`,role:`group`,"aria-label":`头像图标`,children:[(0,W.jsx)(`span`,{children:`图标`}),(0,W.jsx)(`div`,{children:Qm.map(e=>(0,W.jsx)(`button`,{className:i.icon===e.id&&!i.imageUrl?`active`:``,type:`button`,"aria-label":`使用 ${e.label} 图标`,"aria-pressed":i.icon===e.id&&!i.imageUrl,disabled:n,onClick:()=>a(t=>({...t,icon:e.id,imageUrl:null})),children:(0,W.jsx)(e.icon,{size:16})},e.id))})]}),(0,W.jsxs)(`div`,{className:`appearance-choice-group color`,role:`group`,"aria-label":`头像配色`,children:[(0,W.jsx)(`span`,{children:`配色`}),(0,W.jsx)(`div`,{children:$m.map(e=>(0,W.jsx)(`button`,{className:i.color===e.value?`active`:``,type:`button`,"aria-label":`使用${e.label}配色`,"aria-pressed":i.color===e.value,disabled:n,style:{"--appearance-swatch":e.value},onClick:()=>a(t=>({...t,color:e.value}))},e.value))})]})]}),(0,W.jsxs)(`div`,{className:`agent-appearance-actions`,children:[(0,W.jsx)(`input`,{ref:S,className:`sr-only`,type:`file`,accept:`image/png,image/webp`,"aria-label":`选择 Agent 头像图片`,disabled:n,onChange:e=>{T(e.target.files?.[0]),e.target.value=``}}),(0,W.jsxs)(`button`,{className:`button tertiary small`,type:`button`,disabled:n,onClick:()=>S.current?.click(),children:[(0,W.jsx)(me,{size:14}),(0,W.jsx)(`span`,{children:`上传图片`})]}),i.imageUrl?(0,W.jsxs)(`button`,{className:`button tertiary small`,type:`button`,disabled:n,onClick:()=>a(e=>({...e,imageUrl:null})),children:[(0,W.jsx)(Ye,{size:14}),(0,W.jsx)(`span`,{children:`移除图片`})]}):null,(0,W.jsx)(`button`,{className:`button secondary small`,type:`button`,disabled:n||v||!w,onClick:D,children:v?`正在保存`:`保存外观`})]}),b?(0,W.jsx)(`p`,{className:`studio-field-error`,role:`alert`,children:b}):null,(0,W.jsx)(oa,{open:!!o,onOpenChange:e=>{!e&&!g&&c(null)},title:`调整 Agent 头像`,description:`拖动画面并缩放,保存后会生成 512 × 512 WebP。`,closeDisabled:g,className:`avatar-crop-dialog`,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:`button tertiary`,type:`button`,disabled:g,onClick:()=>c(null),children:`取消`}),(0,W.jsx)(`button`,{className:`button accent`,type:`button`,disabled:g||!m,onClick:E,children:g?`正在上传`:`使用裁剪`})]}),children:o?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`avatar-crop-stage`,children:(0,W.jsx)(Zm,{image:o,crop:l,zoom:d,aspect:1,showGrid:!1,onCropChange:u,onZoomChange:p,onCropComplete:(e,t)=>h(t)})}),(0,W.jsxs)(`label`,{className:`avatar-zoom-control`,children:[(0,W.jsx)(`span`,{children:`缩放`}),(0,W.jsx)(`input`,{type:`range`,min:1,max:3,step:.05,value:d,onChange:e=>p(Number(e.target.value))})]})]}):null})]})}var ih=Object.defineProperty,ah=s.forwardRef(((e,t)=>ih(e,`name`,{value:t,configurable:!0}))(function(e,t){return(0,W.jsx)(rn.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}})},`Label`)),oh={required:`必填`,optional:`选填`,generated:`自动生成`};function sh({children:e,htmlFor:t,requirement:n}){return(0,W.jsxs)(ah,{className:`studio-field-label`,htmlFor:t,children:[(0,W.jsx)(`span`,{children:e}),n?(0,W.jsx)(`span`,{className:`studio-field-requirement ${n}`,children:oh[n]}):null]})}function ch({id:e,children:t}){return(0,W.jsx)(`p`,{className:`studio-field-hint`,id:e,children:t})}function lh({id:e,children:t}){return(0,W.jsx)(`p`,{className:`studio-field-error`,id:e,role:`alert`,children:t})}function q({label:e,requirement:t,hint:n,error:r,htmlFor:i,children:a,className:o}){let c=(0,s.useId)(),l=n?`${c}-hint`:void 0,u=r?`${c}-error`:void 0,d=[l,u].filter(Boolean).join(` `)||void 0,f=a;if((0,s.isValidElement)(a)){let e=a,t=typeof e.props[`aria-describedby`]==`string`?e.props[`aria-describedby`]:void 0;f=(0,s.cloneElement)(e,{"aria-describedby":[t,d].filter(Boolean).join(` `)||void 0,"aria-invalid":r?!0:e.props[`aria-invalid`]})}return(0,W.jsxs)(`div`,{className:`studio-form-field${r?` has-error`:``}${o?` ${o}`:``}`,children:[(0,W.jsx)(sh,{htmlFor:i,requirement:t,children:e}),(0,W.jsx)(`div`,{className:`studio-field-control`,children:f}),n?(0,W.jsx)(ch,{id:l,children:n}):null,r?(0,W.jsx)(lh,{id:u,children:r}):null]})}var uh=Object.defineProperty,dh=(e,t)=>uh(e,`name`,{value:t,configurable:!0}),fh=`Popover`,[ph,mh]=vt(fh,[Wu]),hh=Wu(),[gh,_h]=ph(fh),vh=dh(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,c=hh(t),l=s.useRef(null),[u,d]=s.useState(!1),[f,p]=Pt({prop:r,defaultProp:i??!1,onChange:a,caller:fh});return(0,W.jsx)(od,{...c,children:(0,W.jsx)(gh,{scope:t,contentId:Tt(),triggerRef:l,open:f,onOpenChange:p,onOpenToggle:s.useCallback(()=>p(e=>!e),[p]),hasCustomAnchor:u,onCustomAnchorAdd:s.useCallback(()=>d(!0),[]),onCustomAnchorRemove:s.useCallback(()=>d(!1),[]),modal:o,children:n})})},`Popover`),yh=`PopoverTrigger`,bh=s.forwardRef(dh(function(e,t){let{__scopePopover:n,...r}=e,i=_h(yh,n),a=hh(n),o=mt(t,i.triggerRef),s=(0,W.jsx)(rn.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":jh(i.open),...r,ref:o,onClick:G(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,W.jsx)(sd,{asChild:!0,...a,children:s})},`PopoverTrigger`)),xh=`PopoverPortal`,[Sh,Ch]=ph(xh,{forceMount:void 0}),wh=dh(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=_h(xh,t);return(0,W.jsx)(Sh,{scope:t,forceMount:n,children:(0,W.jsx)(Gn,{present:n||a.open,children:(0,W.jsx)(Vn,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),Th=`PopoverContent`,Eh=s.forwardRef(dh(function(e,t){let n=Ch(Th,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=_h(Th,e.__scopePopover);return(0,W.jsx)(Gn,{present:r||a.open,children:a.modal?(0,W.jsx)(Oh,{...i,ref:t}):(0,W.jsx)(kh,{...i,ref:t})})},`PopoverContent`)),Dh=Ht(`PopoverContent.RemoveScroll`),Oh=s.forwardRef(dh(function(e,t){let n=_h(Th,e.__scopePopover),r=s.useRef(null),i=mt(t,r),a=s.useRef(!1);return s.useEffect(()=>{let e=r.current;if(e)return Ci(e)},[]),(0,W.jsx)(mi,{as:Dh,allowPinchZoom:!0,children:(0,W.jsx)(Ah,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:G(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:G(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:G(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),kh=s.forwardRef(dh(function(e,t){let n=_h(Th,e.__scopePopover),r=s.useRef(!1),i=s.useRef(!1);return(0,W.jsx)(Ah,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),Ah=s.forwardRef(dh(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=_h(Th,n),p=hh(n);return nr(),(0,W.jsx)(On,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,W.jsx)(gn,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,W.jsx)(cd,{"data-state":jh(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.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 jh(e){return e?`open`:`closed`}dh(jh,`getState`);var Mh=vh,Nh=bh,Ph=wh,Fh=Eh,Ih=1,Lh=.9,Rh=.8,zh=.17,Bh=.1,Vh=.999,Hh=.9999,Uh=.99,Wh=/[\\\/_+.#"@\[\(\{&]/,Gh=/[\\\/_+.#"@\[\(\{&]/g,Kh=/[\s-]/,qh=/[\s-]/g;function Jh(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Ih:Uh;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=Jh(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Ih:Wh.test(e.charAt(l-1))?(d*=Rh,p=e.slice(i,l-1).match(Gh),p&&i>0&&(d*=Vh**+p.length)):Kh.test(e.charAt(l-1))?(d*=Lh,m=e.slice(i,l-1).match(qh),m&&i>0&&(d*=Vh**+m.length)):(d*=zh,i>0&&(d*=Vh**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=Hh)),(d<Bh&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=Jh(e,t,n,r,l+1,a+2,o),f*Bh>d&&(d=f*Bh)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Yh(e){return e.toLowerCase().replace(qh,` `)}function Xh(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,Jh(e,t,Yh(e),Yh(t),0,0,{})}var Zh=`[cmdk-group=""]`,Qh=`[cmdk-group-items=""]`,$h=`[cmdk-group-heading=""]`,eg=`[cmdk-item=""]`,tg=`${eg}:not([aria-disabled="true"])`,ng=`cmdk-item-select`,rg=`data-value`,ig=(e,t,n)=>Xh(e,t,n),ag=s.createContext(void 0),og=()=>s.useContext(ag),sg=s.createContext(void 0),cg=()=>s.useContext(sg),lg=s.createContext(void 0),ug=s.forwardRef((e,t)=>{let n=wg(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=wg(()=>new Set),i=wg(()=>new Map),a=wg(()=>new Map),o=wg(()=>new Set),c=Sg(e),{label:l,children:u,value:d,onValueChange:f,filter:p,shouldFilter:m,loop:h,disablePointerSelection:g=!1,vimBindings:_=!0,...v}=e,y=Tt(),b=Tt(),x=Tt(),S=s.useRef(null),C=Dg();Cg(()=>{if(d!==void 0){let e=d.trim();n.current.value=e,w.emit()}},[d]),Cg(()=>{C(6,A)},[]);let w=s.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),C(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(x);e?e.focus():(i=document.getElementById(y))==null||i.focus()}if(C(7,()=>{n.current.selectedItemId=j()?.id,w.emit()}),r||C(5,A),c.current?.value!==void 0){let e=t??``;(o=(a=c.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=s.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),C(2,()=>{D(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),C(3,()=>{k(),D(),n.current.value||O(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=j();C(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>c.current.shouldFilter,label:l||e[`aria-label`],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:y,inputId:x,labelId:b,listInnerRef:S}),[]);function E(e,t){let r=c.current?.filter??ig;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||c.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=S.current;M().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(Qh);t?t.appendChild(e.parentElement===t?e:e.closest(`${Qh} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${Qh} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=S.current?.querySelector(`${Zh}[${rg}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=M().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(rg);w.setState(`value`,e||void 0)}function k(){if(!n.current.search||c.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=E(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function A(){var e;let t=j();t&&(t.parentElement?.firstChild===t&&((e=t.closest(Zh)?.querySelector($h))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function j(){return S.current?.querySelector(`${eg}[aria-selected="true"]`)}function M(){return Array.from(S.current?.querySelectorAll(tg)||[])}function N(e){let t=M()[e];t&&w.setState(`value`,t.getAttribute(rg))}function P(e){var t;let n=j(),r=M(),i=r.findIndex(e=>e===n),a=r[i+e];(t=c.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(rg))}function F(e){let t=j()?.closest(Zh),n;for(;t&&!n;)t=e>0?bg(t,Zh):xg(t,Zh),n=t?.querySelector(tg);n?w.setState(`value`,n.getAttribute(rg)):P(e)}let I=()=>N(M().length-1),L=e=>{e.preventDefault(),e.metaKey?I():e.altKey?F(1):P(1)},R=e=>{e.preventDefault(),e.metaKey?N(0):e.altKey?F(-1):P(-1)};return s.createElement(rn.div,{ref:t,tabIndex:-1,...v,"cmdk-root":``,onKeyDown:e=>{var t;(t=v.onKeyDown)==null||t.call(v,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:_&&e.ctrlKey&&L(e);break;case`ArrowDown`:L(e);break;case`p`:case`k`:_&&e.ctrlKey&&R(e);break;case`ArrowUp`:R(e);break;case`Home`:e.preventDefault(),N(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=j();if(t){let e=new Event(ng);t.dispatchEvent(e)}}}}},s.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:Ag},l),kg(e,e=>s.createElement(sg.Provider,{value:w},s.createElement(ag.Provider,{value:T},e))))}),dg=s.forwardRef((e,t)=>{let n=Tt(),r=s.useRef(null),i=s.useContext(lg),a=og(),o=Sg(e),c=o.current?.forceMount??i?.forceMount;Cg(()=>{if(!c)return a.item(n,i?.id)},[c]);let l=Eg(n,r,[e.value,e.children,r],e.keywords),u=cg(),d=Tg(e=>e.value&&e.value===l.current),f=Tg(e=>c||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);s.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(ng,p),()=>t.removeEventListener(ng,p)},[f,e.onSelect,e.disabled]);function p(){var e,t;m(),(t=(e=o.current).onSelect)==null||t.call(e,l.current)}function m(){u.setState(`value`,l.current,!0)}if(!f)return null;let{disabled:h,value:g,onSelect:_,forceMount:v,keywords:y,...b}=e;return s.createElement(rn.div,{ref:pt(r,t),...b,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!h,"aria-selected":!!d,"data-disabled":!!h,"data-selected":!!d,onPointerMove:h||a.getDisablePointerSelection()?void 0:m,onClick:h?void 0:p},e.children)}),fg=s.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Tt(),c=s.useRef(null),l=s.useRef(null),u=Tt(),d=og(),f=Tg(e=>i||d.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Cg(()=>d.group(o),[]),Eg(o,c,[e.value,e.heading,l]);let p=s.useMemo(()=>({id:o,forceMount:i}),[i]);return s.createElement(rn.div,{ref:pt(c,t),...a,"cmdk-group":``,role:`presentation`,hidden:!f||void 0},n&&s.createElement(`div`,{ref:l,"cmdk-group-heading":``,"aria-hidden":!0,id:u},n),kg(e,e=>s.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?u:void 0},s.createElement(lg.Provider,{value:p},e))))}),pg=s.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=s.useRef(null),a=Tg(e=>!e.search);return!n&&!a?null:s.createElement(rn.div,{ref:pt(i,t),...r,"cmdk-separator":``,role:`separator`})}),mg=s.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=cg(),o=Tg(e=>e.search),c=Tg(e=>e.selectedItemId),l=og();return s.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),s.createElement(rn.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":c,id:l.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),hg=s.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=s.useRef(null),o=s.useRef(null),c=Tg(e=>e.selectedItemId),l=og();return s.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),s.createElement(rn.div,{ref:pt(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":c,"aria-label":r,id:l.listId},kg(e,e=>s.createElement(`div`,{ref:pt(o,l.listInnerRef),"cmdk-list-sizer":``},e)))}),gg=s.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...c}=e;return s.createElement(ji,{open:n,onOpenChange:r},s.createElement(Fi,{container:o},s.createElement(Li,{"cmdk-overlay":``,className:i}),s.createElement(Vi,{"aria-label":e.label,"cmdk-dialog":``,className:a},s.createElement(ug,{ref:t,...c}))))}),_g=s.forwardRef((e,t)=>Tg(e=>e.filtered.count===0)?s.createElement(rn.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),vg=s.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return s.createElement(rn.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},kg(e,e=>s.createElement(`div`,{"aria-hidden":!0},e)))}),yg=Object.assign(ug,{List:hg,Item:dg,Input:mg,Group:fg,Separator:pg,Dialog:gg,Empty:_g,Loading:vg});function bg(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function xg(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Sg(e){let t=s.useRef(e);return Cg(()=>{t.current=e}),t}var Cg=typeof window>`u`?s.useEffect:s.useLayoutEffect;function wg(e){let t=s.useRef();return t.current===void 0&&(t.current=e()),t}function Tg(e){let t=cg(),n=()=>e(t.snapshot());return s.useSyncExternalStore(t.subscribe,n,n)}function Eg(e,t,n,r=[]){let i=s.useRef(),a=og();return Cg(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(rg,s),i.current=s}),i}var Dg=()=>{let[e,t]=s.useState(),n=wg(()=>new Map);return Cg(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Og(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function kg({asChild:e,children:t},n){return e&&s.isValidElement(t)?s.cloneElement(Og(t),{ref:t.ref},n(t.props.children)):n(t)}var Ag={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function jg({ariaLabel:e,items:t,selectedIds:n,getId:r,getLabel:i,getDescription:a=()=>``,onChange:o,searchPlaceholder:c=`搜索`,emptyMessage:l=`没有匹配项`,disabledIds:u=[]}){let[d,f]=(0,s.useState)(!1),[p,m]=(0,s.useState)(!1),h=(0,s.useMemo)(()=>new Set(u),[u]),g=(0,s.useMemo)(()=>new Set(n),[n]),_=t.filter(e=>g.has(r(e))),v=p?_:t;function y(e){h.has(e)||o(g.has(e)?n.filter(t=>t!==e):[...n,e])}return(0,W.jsxs)(`div`,{className:`studio-multi-select`,children:[(0,W.jsxs)(`div`,{className:`studio-multi-select-summary`,children:[(0,W.jsx)(`span`,{children:n.length?`已选 ${n.length} 个`:`尚未选择`}),n.length?(0,W.jsx)(`button`,{className:`text-button`,type:`button`,onClick:()=>o([]),children:`清空`}):null]}),(0,W.jsx)(`div`,{className:`studio-multi-select-selection`,"data-testid":`studio-multi-select-selection`,children:_.map(e=>{let t=r(e),n=i(e);return(0,W.jsxs)(`span`,{className:`studio-selection-chip`,children:[(0,W.jsx)(`span`,{title:n,children:n}),h.has(t)?null:(0,W.jsx)(`button`,{type:`button`,"aria-label":`移除 ${n}`,onClick:()=>y(t),children:(0,W.jsx)($e,{size:12})})]},t)})}),(0,W.jsxs)(Mh,{open:d,onOpenChange:f,children:[(0,W.jsx)(Nh,{asChild:!0,children:(0,W.jsxs)(`button`,{className:`studio-multi-select-trigger`,type:`button`,"aria-label":e,"aria-expanded":d,children:[(0,W.jsx)(`span`,{children:n.length?`继续选择`:e}),(0,W.jsx)(M,{size:15})]})}),(0,W.jsx)(Ph,{children:(0,W.jsx)(Fh,{className:`studio-multi-select-popover`,align:`start`,sideOffset:6,collisionPadding:12,children:(0,W.jsxs)(yg,{loop:!0,label:c,children:[(0,W.jsxs)(`div`,{className:`studio-command-search`,children:[(0,W.jsx)(Ie,{size:14,"aria-hidden":`true`}),(0,W.jsx)(yg.Input,{"aria-label":c,placeholder:c,autoFocus:!0})]}),(0,W.jsxs)(`div`,{className:`studio-multi-select-tools`,children:[(0,W.jsx)(`button`,{className:p?`selected`:``,type:`button`,"aria-pressed":p,onClick:()=>m(e=>!e),children:`仅看已选`}),(0,W.jsxs)(`span`,{children:[v.length,` 项`]})]}),(0,W.jsxs)(yg.List,{className:`studio-command-list`,children:[(0,W.jsx)(yg.Empty,{children:l}),v.map(e=>{let t=r(e),n=i(e),o=a(e),s=g.has(t),c=h.has(t);return(0,W.jsxs)(yg.Item,{value:`${n} ${o} ${t}`,disabled:c,onSelect:()=>y(t),children:[(0,W.jsx)(`span`,{className:`studio-option-check`,role:`checkbox`,"aria-checked":s,children:s?(0,W.jsx)(j,{size:13}):null}),(0,W.jsxs)(`span`,{className:`studio-option-copy`,children:[(0,W.jsx)(`strong`,{children:n}),o?(0,W.jsx)(`small`,{children:o}):null]})]},t)})]})]})})})]})]})}var Mg=`modulepreload`,Ng=function(e){return`/static/`+e},Pg={},Fg=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Ng(t,n),t=s(t),t in Pg)return;Pg[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Mg,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ig=(0,s.lazy)(()=>Fg(()=>import(`./PrismRenderer-IYN-ffww.js`),__vite__mapDeps([0,1,2])));function Lg({code:e,language:t=`text`,filename:n,wrap:r=!1,showLineNumbers:i=!0}){let[a,o]=(0,s.useState)(r),[c,l]=(0,s.useState)(!1);(0,s.useEffect)(()=>o(r),[r]);async function u(){navigator.clipboard?.writeText&&(await navigator.clipboard.writeText(e),l(!0),window.setTimeout(()=>l(!1),1600))}let d=n?`${n} 源码`:`${t||`text`} 代码`;return(0,W.jsxs)(`section`,{className:`code-viewer`,role:`region`,"aria-label":d,"data-code-theme":`studio`,"data-wrap":String(a),children:[(0,W.jsxs)(`header`,{className:`code-viewer-toolbar`,children:[(0,W.jsxs)(`div`,{children:[n&&(0,W.jsx)(`strong`,{title:n,children:n}),(0,W.jsx)(`span`,{children:t||`text`})]}),(0,W.jsxs)(`div`,{className:`code-viewer-actions`,children:[(0,W.jsx)(`button`,{className:`icon-button tertiary`,type:`button`,"aria-label":a?`取消自动换行`:`自动换行`,title:a?`取消自动换行`:`自动换行`,"aria-pressed":a,onClick:()=>o(e=>!e),children:(0,W.jsx)(Je,{size:15})}),(0,W.jsx)(`button`,{className:`icon-button tertiary`,type:`button`,"aria-label":c?`已复制`:`复制代码`,title:c?`已复制`:`复制代码`,onClick:()=>void u(),children:c?(0,W.jsx)(j,{size:15}):(0,W.jsx)(te,{size:15})})]})]}),(0,W.jsx)(`div`,{className:`code-viewer-scroll`,children:(0,W.jsx)(s.Suspense,{fallback:(0,W.jsx)(`pre`,{className:`code-viewer-fallback`,children:(0,W.jsx)(`code`,{children:e})}),children:(0,W.jsx)(Ig,{code:e,language:t||`text`,showLineNumbers:i})})})]})}function Rg(e){if(!e||e.length===0)return null;let t=e[e.length-1];return typeof t==`string`?t:null}function zg(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.errors;if(n&&typeof n==`object`&&!Array.isArray(n)){let e={},t=!1;for(let[r,i]of Object.entries(n))typeof i==`string`?(e[r]=i,t=!0):Array.isArray(i)&&i.length&&typeof i[0]==`string`&&(e[r]=String(i[0]),t=!0);return t?e:null}let r=t.error;if(r&&typeof r==`object`){let e=r,t=e.fields;if(t&&typeof t==`object`&&!Array.isArray(t)){let e={},n=!1;for(let[r,i]of Object.entries(t))typeof i==`string`&&(e[r]=i,n=!0);if(n)return e}let n=e.details;if(Array.isArray(n)){let e={},t=!1;for(let r of n){let n=r.field||Rg(r.loc);n&&r.message&&(e[n]=r.message,t=!0)}return t?e:null}}return null}function Bg(e,t){let n=zg(e);if(!n)return!1;for(let[e,r]of Object.entries(n))t(e,{type:`server`,message:r});return!0}var Vg;function J(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Hg=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Ug=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Vg=globalThis).__zod_globalConfig??(Vg.__zod_globalConfig={});var Wg=globalThis.__zod_globalConfig;function Gg(e){return e&&Object.assign(Wg,e),Wg}function Kg(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function qg(e,t){return typeof t==`bigint`?t.toString():t}function Jg(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Yg(e){return e==null}function Xg(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Zg(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Qg=Symbol(`evaluating`);function $g(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Qg)return r===void 0&&(r=Qg,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function e_(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function t_(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function n_(e){return JSON.stringify(e)}function r_(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var i_=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function a_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var o_=Jg(()=>{if(Wg.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function s_(e){if(a_(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return a_(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function c_(e){return s_(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var l_=new Set([`string`,`number`,`symbol`]);function u_(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function d_(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Y(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function f_(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var p_={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function m_(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return d_(e,t_(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return e_(this,`shape`,e),e},checks:[]}))}function h_(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return d_(e,t_(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return e_(this,`shape`,r),r},checks:[]}))}function g_(e,t){if(!s_(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return d_(e,t_(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return e_(this,`shape`,n),n}}))}function __(e,t){if(!s_(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return d_(e,t_(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return e_(this,`shape`,n),n}}))}function v_(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return d_(e,t_(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return e_(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function y_(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return d_(t,t_(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return e_(this,`shape`,i),i},checks:[]}))}function b_(e,t,n){return d_(t,t_(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return e_(this,`shape`,i),i}}))}function x_(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function S_(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function C_(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function w_(e){return typeof e==`string`?e:e?.message}function T_(e,t,n){let r=e.message?e.message:w_(e.inst?._zod.def?.error?.(e))??w_(t?.error?.(e))??w_(n.customError?.(e))??w_(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function E_(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function D_(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var O_=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,qg,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},k_=J(`$ZodError`,O_),A_=J(`$ZodError`,O_,{Parent:Error});function j_(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function M_(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var N_=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Hg;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>T_(e,a,Gg())));throw i_(t,i?.callee),t}return o.value},P_=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>T_(e,a,Gg())));throw i_(t,i?.callee),t}return o.value},F_=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Hg;return a.issues.length?{success:!1,error:new(e??k_)(a.issues.map(e=>T_(e,i,Gg())))}:{success:!0,data:a.value}},I_=F_(A_),L_=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>T_(e,i,Gg())))}:{success:!0,data:a.value}},R_=L_(A_),z_=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return N_(e)(t,n,i)},B_=e=>(t,n,r)=>N_(e)(t,n,r),V_=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return P_(e)(t,n,i)},H_=e=>async(t,n,r)=>P_(e)(t,n,r),U_=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return F_(e)(t,n,i)},W_=e=>(t,n,r)=>F_(e)(t,n,r),G_=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return L_(e)(t,n,i)},K_=e=>async(t,n,r)=>L_(e)(t,n,r),q_=/^[cC][0-9a-z]{6,}$/,J_=/^[0-9a-z]+$/,Y_=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,X_=/^[0-9a-vA-V]{20}$/,Z_=/^[A-Za-z0-9]{27}$/,Q_=/^[a-zA-Z0-9_-]{21}$/,$_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ev=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,tv=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,nv=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,rv=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function iv(){return new RegExp(rv,`u`)}var av=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ov=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,sv=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,cv=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,lv=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,uv=/^[A-Za-z0-9_-]*$/,dv=/^https?$/,fv=/^\+[1-9]\d{6,14}$/,pv=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,mv=RegExp(`^${pv}$`);function hv(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function gv(e){return RegExp(`^${hv(e)}$`)}function _v(e){let t=hv({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${pv}T(?:${r})$`)}var vv=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},yv=/^-?\d+$/,bv=/^-?\d+(?:\.\d+)?$/,xv=/^(?:true|false)$/i,Sv=/^[^A-Z]*$/,Cv=/^[^a-z]*$/,wv=J(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Tv={number:`number`,bigint:`bigint`,object:`date`},Ev=J(`$ZodCheckLessThan`,(e,t)=>{wv.init(e,t);let n=Tv[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Dv=J(`$ZodCheckGreaterThan`,(e,t)=>{wv.init(e,t);let n=Tv[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ov=J(`$ZodCheckMultipleOf`,(e,t)=>{wv.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Zg(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),kv=J(`$ZodCheckNumberFormat`,(e,t)=>{wv.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=p_[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=yv)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Av=J(`$ZodCheckMaxLength`,(e,t)=>{var n;wv.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Yg(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=E_(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),jv=J(`$ZodCheckMinLength`,(e,t)=>{var n;wv.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Yg(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=E_(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Mv=J(`$ZodCheckLengthEquals`,(e,t)=>{var n;wv.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Yg(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=E_(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Nv=J(`$ZodCheckStringFormat`,(e,t)=>{var n,r;wv.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Pv=J(`$ZodCheckRegex`,(e,t)=>{Nv.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Fv=J(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Sv,Nv.init(e,t)}),Iv=J(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Cv,Nv.init(e,t)}),Lv=J(`$ZodCheckIncludes`,(e,t)=>{wv.init(e,t);let n=u_(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Rv=J(`$ZodCheckStartsWith`,(e,t)=>{wv.init(e,t);let n=RegExp(`^${u_(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),zv=J(`$ZodCheckEndsWith`,(e,t)=>{wv.init(e,t);let n=RegExp(`.*${u_(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Bv=J(`$ZodCheckOverwrite`,(e,t)=>{wv.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Vv=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
123
|
-
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
124
|
-
`))}},Hv={major:4,minor:4,patch:3},Uv=J(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Hv;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=x_(e),i;for(let a of t){if(a._zod.def.when){if(S_(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Hg;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=x_(e,t))});else{if(e.issues.length===t)continue;r||=x_(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(x_(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Hg;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Hg;return o.then(e=>t(e,r,a))}return t(o,r,a)}}$g(e,`~standard`,()=>({validate:t=>{try{let n=I_(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return R_(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Wv=J(`$ZodString`,(e,t)=>{Uv.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??vv(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Gv=J(`$ZodStringFormat`,(e,t)=>{Nv.init(e,t),Wv.init(e,t)}),Kv=J(`$ZodGUID`,(e,t)=>{t.pattern??=ev,Gv.init(e,t)}),qv=J(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=tv(e)}else t.pattern??=tv();Gv.init(e,t)}),Jv=J(`$ZodEmail`,(e,t)=>{t.pattern??=nv,Gv.init(e,t)}),Yv=J(`$ZodURL`,(e,t)=>{Gv.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===dv.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Xv=J(`$ZodEmoji`,(e,t)=>{t.pattern??=iv(),Gv.init(e,t)}),Zv=J(`$ZodNanoID`,(e,t)=>{t.pattern??=Q_,Gv.init(e,t)}),Qv=J(`$ZodCUID`,(e,t)=>{t.pattern??=q_,Gv.init(e,t)}),$v=J(`$ZodCUID2`,(e,t)=>{t.pattern??=J_,Gv.init(e,t)}),ey=J(`$ZodULID`,(e,t)=>{t.pattern??=Y_,Gv.init(e,t)}),ty=J(`$ZodXID`,(e,t)=>{t.pattern??=X_,Gv.init(e,t)}),ny=J(`$ZodKSUID`,(e,t)=>{t.pattern??=Z_,Gv.init(e,t)}),ry=J(`$ZodISODateTime`,(e,t)=>{t.pattern??=_v(t),Gv.init(e,t)}),iy=J(`$ZodISODate`,(e,t)=>{t.pattern??=mv,Gv.init(e,t)}),ay=J(`$ZodISOTime`,(e,t)=>{t.pattern??=gv(t),Gv.init(e,t)}),oy=J(`$ZodISODuration`,(e,t)=>{t.pattern??=$_,Gv.init(e,t)}),sy=J(`$ZodIPv4`,(e,t)=>{t.pattern??=av,Gv.init(e,t),e._zod.bag.format=`ipv4`}),cy=J(`$ZodIPv6`,(e,t)=>{t.pattern??=ov,Gv.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),ly=J(`$ZodCIDRv4`,(e,t)=>{t.pattern??=sv,Gv.init(e,t)}),uy=J(`$ZodCIDRv6`,(e,t)=>{t.pattern??=cv,Gv.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function dy(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var fy=J(`$ZodBase64`,(e,t)=>{t.pattern??=lv,Gv.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{dy(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function py(e){if(!uv.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return dy(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var my=J(`$ZodBase64URL`,(e,t)=>{t.pattern??=uv,Gv.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{py(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),hy=J(`$ZodE164`,(e,t)=>{t.pattern??=fv,Gv.init(e,t)});function gy(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var _y=J(`$ZodJWT`,(e,t)=>{Gv.init(e,t),e._zod.check=n=>{gy(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),vy=J(`$ZodNumber`,(e,t)=>{Uv.init(e,t),e._zod.pattern=e._zod.bag.pattern??bv,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),yy=J(`$ZodNumberFormat`,(e,t)=>{kv.init(e,t),vy.init(e,t)}),by=J(`$ZodBoolean`,(e,t)=>{Uv.init(e,t),e._zod.pattern=xv,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),xy=J(`$ZodUnknown`,(e,t)=>{Uv.init(e,t),e._zod.parse=e=>e}),Sy=J(`$ZodNever`,(e,t)=>{Uv.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Cy(e,t,n){e.issues.length&&t.issues.push(...C_(n,e.issues)),t.value[n]=e.value}var wy=J(`$ZodArray`,(e,t)=>{Uv.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Cy(t,n,e))):Cy(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Ty(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...C_(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Ey(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=f_(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Dy(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Ty(e,n,i,t,u,d))):Ty(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Oy=J(`$ZodObject`,(e,t)=>{if(Uv.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=Jg(()=>Ey(t));$g(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=a_,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>Ty(n,t,e,s,r,i))):Ty(a,t,e,s,r,i)}return i?Dy(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),ky=J(`$ZodObjectJIT`,(e,t)=>{Oy.init(e,t);let n=e._zod.parse,r=Jg(()=>Ey(t)),i=e=>{let t=new Vv([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=n_(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=n_(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
125
|
-
if (${n}.issues.length) {
|
|
126
|
-
if (${o} in input) {
|
|
127
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
128
|
-
...iss,
|
|
129
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
130
|
-
})));
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (${n}.value === undefined) {
|
|
135
|
-
if (${o} in input) {
|
|
136
|
-
newResult[${o}] = undefined;
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
newResult[${o}] = ${n}.value;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
`):c?t.write(`
|
|
143
|
-
if (${n}.issues.length) {
|
|
144
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
145
|
-
...iss,
|
|
146
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
147
|
-
})));
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (${n}.value === undefined) {
|
|
151
|
-
if (${o} in input) {
|
|
152
|
-
newResult[${o}] = undefined;
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
newResult[${o}] = ${n}.value;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
`):t.write(`
|
|
159
|
-
const ${n}_present = ${o} in input;
|
|
160
|
-
if (${n}.issues.length) {
|
|
161
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
162
|
-
...iss,
|
|
163
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
164
|
-
})));
|
|
165
|
-
}
|
|
166
|
-
if (!${n}_present && !${n}.issues.length) {
|
|
167
|
-
payload.issues.push({
|
|
168
|
-
code: "invalid_type",
|
|
169
|
-
expected: "nonoptional",
|
|
170
|
-
input: undefined,
|
|
171
|
-
path: [${o}]
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (${n}_present) {
|
|
176
|
-
if (${n}.value === undefined) {
|
|
177
|
-
newResult[${o}] = undefined;
|
|
178
|
-
} else {
|
|
179
|
-
newResult[${o}] = ${n}.value;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=a_,s=!Wg.jitless,c=s&&o_.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Dy([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Ay(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!x_(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>T_(e,r,Gg())))}),t)}var jy=J(`$ZodUnion`,(e,t)=>{Uv.init(e,t),$g(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),$g(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),$g(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),$g(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Xg(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Ay(t,r,e,i)):Ay(o,r,e,i)}}),My=J(`$ZodIntersection`,(e,t)=>{Uv.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Py(e,t,n)):Py(e,i,a)}});function Ny(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(s_(e)&&s_(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Ny(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Ny(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Py(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),x_(e))return e;let o=Ny(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Fy=J(`$ZodEnum`,(e,t)=>{Uv.init(e,t);let n=Kg(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>l_.has(typeof e)).map(e=>typeof e==`string`?u_(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Iy=J(`$ZodLiteral`,(e,t)=>{if(Uv.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?u_(e):e?u_(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Ly=J(`$ZodTransform`,(e,t)=>{Uv.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ug(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Hg;return n.value=i,n.fallback=!0,n}});function Ry(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var zy=J(`$ZodOptional`,(e,t)=>{Uv.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,$g(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),$g(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Xg(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Ry(e,r)):Ry(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),By=J(`$ZodExactOptional`,(e,t)=>{zy.init(e,t),$g(e._zod,`values`,()=>t.innerType._zod.values),$g(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Vy=J(`$ZodNullable`,(e,t)=>{Uv.init(e,t),$g(e._zod,`optin`,()=>t.innerType._zod.optin),$g(e._zod,`optout`,()=>t.innerType._zod.optout),$g(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Xg(e.source)}|null)$`):void 0}),$g(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Hy=J(`$ZodDefault`,(e,t)=>{Uv.init(e,t),e._zod.optin=`optional`,$g(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Uy(e,t)):Uy(r,t)}});function Uy(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Wy=J(`$ZodPrefault`,(e,t)=>{Uv.init(e,t),e._zod.optin=`optional`,$g(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Gy=J(`$ZodNonOptional`,(e,t)=>{Uv.init(e,t),$g(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ky(t,e)):Ky(i,e)}});function Ky(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var qy=J(`$ZodCatch`,(e,t)=>{Uv.init(e,t),e._zod.optin=`optional`,$g(e._zod,`optout`,()=>t.innerType._zod.optout),$g(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>T_(e,n,Gg()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>T_(e,n,Gg()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Jy=J(`$ZodPipe`,(e,t)=>{Uv.init(e,t),$g(e._zod,`values`,()=>t.in._zod.values),$g(e._zod,`optin`,()=>t.in._zod.optin),$g(e._zod,`optout`,()=>t.out._zod.optout),$g(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Yy(e,t.in,n)):Yy(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Yy(e,t.out,n)):Yy(r,t.out,n)}});function Yy(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Xy=J(`$ZodReadonly`,(e,t)=>{Uv.init(e,t),$g(e._zod,`propValues`,()=>t.innerType._zod.propValues),$g(e._zod,`values`,()=>t.innerType._zod.values),$g(e._zod,`optin`,()=>t.innerType?._zod?.optin),$g(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Zy):Zy(r)}});function Zy(e){return e.value=Object.freeze(e.value),e}var Qy=J(`$ZodCustom`,(e,t)=>{wv.init(e,t),Uv.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>$y(t,n,r,e));$y(i,n,r,e)}});function $y(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(D_(e))}}var eb,tb=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function nb(){return new tb}(eb=globalThis).__zod_globalRegistry??(eb.__zod_globalRegistry=nb());var rb=globalThis.__zod_globalRegistry;function ib(e,t){return new e({type:`string`,...Y(t)})}function ab(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Y(t)})}function ob(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Y(t)})}function sb(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Y(t)})}function cb(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Y(t)})}function lb(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Y(t)})}function ub(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Y(t)})}function db(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Y(t)})}function fb(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Y(t)})}function pb(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Y(t)})}function mb(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Y(t)})}function hb(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Y(t)})}function gb(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Y(t)})}function _b(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Y(t)})}function vb(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Y(t)})}function yb(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Y(t)})}function bb(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Y(t)})}function xb(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Y(t)})}function Sb(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Y(t)})}function Cb(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Y(t)})}function wb(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Y(t)})}function Tb(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Y(t)})}function Eb(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Y(t)})}function Db(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Y(t)})}function Ob(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Y(t)})}function kb(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Y(t)})}function Ab(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Y(t)})}function jb(e,t){return new e({type:`number`,coerce:!0,checks:[],...Y(t)})}function Mb(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...Y(t)})}function Nb(e,t){return new e({type:`boolean`,...Y(t)})}function Pb(e){return new e({type:`unknown`})}function Fb(e,t){return new e({type:`never`,...Y(t)})}function Ib(e,t){return new Ev({check:`less_than`,...Y(t),value:e,inclusive:!1})}function Lb(e,t){return new Ev({check:`less_than`,...Y(t),value:e,inclusive:!0})}function Rb(e,t){return new Dv({check:`greater_than`,...Y(t),value:e,inclusive:!1})}function zb(e,t){return new Dv({check:`greater_than`,...Y(t),value:e,inclusive:!0})}function Bb(e,t){return new Ov({check:`multiple_of`,...Y(t),value:e})}function Vb(e,t){return new Av({check:`max_length`,...Y(t),maximum:e})}function Hb(e,t){return new jv({check:`min_length`,...Y(t),minimum:e})}function Ub(e,t){return new Mv({check:`length_equals`,...Y(t),length:e})}function Wb(e,t){return new Pv({check:`string_format`,format:`regex`,...Y(t),pattern:e})}function Gb(e){return new Fv({check:`string_format`,format:`lowercase`,...Y(e)})}function Kb(e){return new Iv({check:`string_format`,format:`uppercase`,...Y(e)})}function qb(e,t){return new Lv({check:`string_format`,format:`includes`,...Y(t),includes:e})}function Jb(e,t){return new Rv({check:`string_format`,format:`starts_with`,...Y(t),prefix:e})}function Yb(e,t){return new zv({check:`string_format`,format:`ends_with`,...Y(t),suffix:e})}function Xb(e){return new Bv({check:`overwrite`,tx:e})}function Zb(e){return Xb(t=>t.normalize(e))}function Qb(){return Xb(e=>e.trim())}function $b(){return Xb(e=>e.toLowerCase())}function ex(){return Xb(e=>e.toUpperCase())}function tx(){return Xb(e=>r_(e))}function nx(e,t,n){return new e({type:`array`,element:t,...Y(n)})}function rx(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Y(n)})}function ix(e,t){let n=ax(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(D_(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(D_(r))}},e(t.value,t)),t);return n}function ax(e,t){let n=new wv({check:`custom`,...Y(t)});return n._zod.check=e,n}function ox(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??rb,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function sx(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,sx(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&ux(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function cx(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
184
|
-
|
|
185
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function lx(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:fx(t,`input`,e.processors),output:fx(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function ux(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return ux(r.element,n);if(r.type===`set`)return ux(r.valueType,n);if(r.type===`lazy`)return ux(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return ux(r.innerType,n);if(r.type===`intersection`)return ux(r.left,n)||ux(r.right,n);if(r.type===`record`||r.type===`map`)return ux(r.keyType,n)||ux(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:ux(r.in,n)||ux(r.out,n);if(r.type===`object`){for(let e in r.shape)if(ux(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(ux(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(ux(e,n))return!0;return!!(r.rest&&ux(r.rest,n))}return!1}var dx=(e,t={})=>n=>{let r=ox({...n,processors:t});return sx(e,r),cx(r,e),lx(r,e)},fx=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ox({...i??{},target:a,io:t,processors:n});return sx(e,o),cx(o,e),lx(o,e)},px={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},mx=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=px[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},hx=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},gx=(e,t,n,r)=>{n.type=`boolean`},_x=(e,t,n,r)=>{n.not={}},vx=(e,t,n,r)=>{let i=e._zod.def,a=Kg(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},yx=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},bx=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},xx=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Sx=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=sx(a.element,t,{...r,path:[...r.path,`items`]})},Cx=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=sx(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=sx(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},wx=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>sx(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Tx=(e,t,n,r)=>{let i=e._zod.def,a=sx(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=sx(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Ex=(e,t,n,r)=>{let i=e._zod.def,a=sx(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Dx=(e,t,n,r)=>{let i=e._zod.def;sx(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ox=(e,t,n,r)=>{let i=e._zod.def;sx(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},kx=(e,t,n,r)=>{let i=e._zod.def;sx(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Ax=(e,t,n,r)=>{let i=e._zod.def;sx(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},jx=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;sx(o,t,r);let s=t.seen.get(e);s.ref=o},Mx=(e,t,n,r)=>{let i=e._zod.def;sx(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Nx=(e,t,n,r)=>{let i=e._zod.def;sx(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Px=J(`ZodISODateTime`,(e,t)=>{ry.init(e,t),sS.init(e,t)});function Fx(e){return Db(Px,e)}var Ix=J(`ZodISODate`,(e,t)=>{iy.init(e,t),sS.init(e,t)});function Lx(e){return Ob(Ix,e)}var Rx=J(`ZodISOTime`,(e,t)=>{ay.init(e,t),sS.init(e,t)});function zx(e){return kb(Rx,e)}var Bx=J(`ZodISODuration`,(e,t)=>{oy.init(e,t),sS.init(e,t)});function Vx(e){return Ab(Bx,e)}var Hx=J(`ZodError`,(e,t)=>{k_.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>M_(e,t)},flatten:{value:t=>j_(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,qg,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,qg,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ux=N_(Hx),Wx=P_(Hx),Gx=F_(Hx),Kx=L_(Hx),qx=z_(Hx),Jx=B_(Hx),Yx=V_(Hx),Xx=H_(Hx),Zx=U_(Hx),Qx=W_(Hx),$x=G_(Hx),eS=K_(Hx),tS=new WeakMap;function nS(e,t,n){let r=Object.getPrototypeOf(e),i=tS.get(r);if(i||(i=new Set,tS.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var rS=J(`ZodType`,(e,t)=>(Uv.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:fx(e,`input`),output:fx(e,`output`)}}),e.toJSONSchema=dx(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Ux(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Gx(e,t,n),e.parseAsync=async(t,n)=>Wx(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Kx(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>qx(e,t,n),e.decode=(t,n)=>Jx(e,t,n),e.encodeAsync=async(t,n)=>Yx(e,t,n),e.decodeAsync=async(t,n)=>Xx(e,t,n),e.safeEncode=(t,n)=>Zx(e,t,n),e.safeDecode=(t,n)=>Qx(e,t,n),e.safeEncodeAsync=async(t,n)=>$x(e,t,n),e.safeDecodeAsync=async(t,n)=>eS(e,t,n),nS(e,`ZodType`,{check(...e){let t=this.def;return this.clone(t_(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return d_(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(gC(e,t))},superRefine(e,t){return this.check(_C(e,t))},overwrite(e){return this.check(Xb(e))},optional(){return QS(this)},exactOptional(){return eC(this)},nullable(){return nC(this)},nullish(){return QS(nC(this))},nonoptional(e){return cC(this,e)},array(){return RS(this)},or(e){return HS([this,e])},and(e){return WS(this,e)},transform(e){return fC(this,XS(e))},default(e){return iC(this,e)},prefault(e){return oC(this,e)},catch(e){return uC(this,e)},pipe(e){return fC(this,e)},readonly(){return mC(this)},describe(e){let t=this.clone();return rb.add(t,{description:e}),t},meta(...e){if(e.length===0)return rb.get(this);let t=this.clone();return rb.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return rb.get(e)?.description},configurable:!0}),e)),iS=J(`_ZodString`,(e,t)=>{Wv.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mx(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,nS(e,`_ZodString`,{regex(...e){return this.check(Wb(...e))},includes(...e){return this.check(qb(...e))},startsWith(...e){return this.check(Jb(...e))},endsWith(...e){return this.check(Yb(...e))},min(...e){return this.check(Hb(...e))},max(...e){return this.check(Vb(...e))},length(...e){return this.check(Ub(...e))},nonempty(...e){return this.check(Hb(1,...e))},lowercase(e){return this.check(Gb(e))},uppercase(e){return this.check(Kb(e))},trim(){return this.check(Qb())},normalize(...e){return this.check(Zb(...e))},toLowerCase(){return this.check($b())},toUpperCase(){return this.check(ex())},slugify(){return this.check(tx())}})}),aS=J(`ZodString`,(e,t)=>{Wv.init(e,t),iS.init(e,t),e.email=t=>e.check(ab(cS,t)),e.url=t=>e.check(db(dS,t)),e.jwt=t=>e.check(Eb(DS,t)),e.emoji=t=>e.check(fb(pS,t)),e.guid=t=>e.check(ob(lS,t)),e.uuid=t=>e.check(sb(uS,t)),e.uuidv4=t=>e.check(cb(uS,t)),e.uuidv6=t=>e.check(lb(uS,t)),e.uuidv7=t=>e.check(ub(uS,t)),e.nanoid=t=>e.check(pb(mS,t)),e.guid=t=>e.check(ob(lS,t)),e.cuid=t=>e.check(mb(hS,t)),e.cuid2=t=>e.check(hb(gS,t)),e.ulid=t=>e.check(gb(_S,t)),e.base64=t=>e.check(Cb(wS,t)),e.base64url=t=>e.check(wb(TS,t)),e.xid=t=>e.check(_b(vS,t)),e.ksuid=t=>e.check(vb(yS,t)),e.ipv4=t=>e.check(yb(bS,t)),e.ipv6=t=>e.check(bb(xS,t)),e.cidrv4=t=>e.check(xb(SS,t)),e.cidrv6=t=>e.check(Sb(CS,t)),e.e164=t=>e.check(Tb(ES,t)),e.datetime=t=>e.check(Fx(t)),e.date=t=>e.check(Lx(t)),e.time=t=>e.check(zx(t)),e.duration=t=>e.check(Vx(t))});function oS(e){return ib(aS,e)}var sS=J(`ZodStringFormat`,(e,t)=>{Gv.init(e,t),iS.init(e,t)}),cS=J(`ZodEmail`,(e,t)=>{Jv.init(e,t),sS.init(e,t)}),lS=J(`ZodGUID`,(e,t)=>{Kv.init(e,t),sS.init(e,t)}),uS=J(`ZodUUID`,(e,t)=>{qv.init(e,t),sS.init(e,t)}),dS=J(`ZodURL`,(e,t)=>{Yv.init(e,t),sS.init(e,t)});function fS(e){return db(dS,e)}var pS=J(`ZodEmoji`,(e,t)=>{Xv.init(e,t),sS.init(e,t)}),mS=J(`ZodNanoID`,(e,t)=>{Zv.init(e,t),sS.init(e,t)}),hS=J(`ZodCUID`,(e,t)=>{Qv.init(e,t),sS.init(e,t)}),gS=J(`ZodCUID2`,(e,t)=>{$v.init(e,t),sS.init(e,t)}),_S=J(`ZodULID`,(e,t)=>{ey.init(e,t),sS.init(e,t)}),vS=J(`ZodXID`,(e,t)=>{ty.init(e,t),sS.init(e,t)}),yS=J(`ZodKSUID`,(e,t)=>{ny.init(e,t),sS.init(e,t)}),bS=J(`ZodIPv4`,(e,t)=>{sy.init(e,t),sS.init(e,t)}),xS=J(`ZodIPv6`,(e,t)=>{cy.init(e,t),sS.init(e,t)}),SS=J(`ZodCIDRv4`,(e,t)=>{ly.init(e,t),sS.init(e,t)}),CS=J(`ZodCIDRv6`,(e,t)=>{uy.init(e,t),sS.init(e,t)}),wS=J(`ZodBase64`,(e,t)=>{fy.init(e,t),sS.init(e,t)}),TS=J(`ZodBase64URL`,(e,t)=>{my.init(e,t),sS.init(e,t)}),ES=J(`ZodE164`,(e,t)=>{hy.init(e,t),sS.init(e,t)}),DS=J(`ZodJWT`,(e,t)=>{_y.init(e,t),sS.init(e,t)}),OS=J(`ZodNumber`,(e,t)=>{vy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hx(e,t,n,r),nS(e,`ZodNumber`,{gt(e,t){return this.check(Rb(e,t))},gte(e,t){return this.check(zb(e,t))},min(e,t){return this.check(zb(e,t))},lt(e,t){return this.check(Ib(e,t))},lte(e,t){return this.check(Lb(e,t))},max(e,t){return this.check(Lb(e,t))},int(e){return this.check(AS(e))},safe(e){return this.check(AS(e))},positive(e){return this.check(Rb(0,e))},nonnegative(e){return this.check(zb(0,e))},negative(e){return this.check(Ib(0,e))},nonpositive(e){return this.check(Lb(0,e))},multipleOf(e,t){return this.check(Bb(e,t))},step(e,t){return this.check(Bb(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}),kS=J(`ZodNumberFormat`,(e,t)=>{yy.init(e,t),OS.init(e,t)});function AS(e){return Mb(kS,e)}var jS=J(`ZodBoolean`,(e,t)=>{by.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gx(e,t,n,r)});function MS(e){return Nb(jS,e)}var NS=J(`ZodUnknown`,(e,t)=>{xy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function PS(){return Pb(NS)}var FS=J(`ZodNever`,(e,t)=>{Sy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_x(e,t,n,r)});function IS(e){return Fb(FS,e)}var LS=J(`ZodArray`,(e,t)=>{wy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sx(e,t,n,r),e.element=t.element,nS(e,`ZodArray`,{min(e,t){return this.check(Hb(e,t))},nonempty(e){return this.check(Hb(1,e))},max(e,t){return this.check(Vb(e,t))},length(e,t){return this.check(Ub(e,t))},unwrap(){return this.element}})});function RS(e,t){return nx(LS,e,t)}var zS=J(`ZodObject`,(e,t)=>{ky.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cx(e,t,n,r),$g(e,`shape`,()=>t.shape),nS(e,`ZodObject`,{keyof(){return KS(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:PS()})},loose(){return this.clone({...this._zod.def,catchall:PS()})},strict(){return this.clone({...this._zod.def,catchall:IS()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return g_(this,e)},safeExtend(e){return __(this,e)},merge(e){return v_(this,e)},pick(e){return m_(this,e)},omit(e){return h_(this,e)},partial(...e){return y_(ZS,this,e[0])},required(...e){return b_(sC,this,e[0])}})});function BS(e,t){return new zS({type:`object`,shape:e??{},...Y(t)})}var VS=J(`ZodUnion`,(e,t)=>{jy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wx(e,t,n,r),e.options=t.options});function HS(e,t){return new VS({type:`union`,options:e,...Y(t)})}var US=J(`ZodIntersection`,(e,t)=>{My.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tx(e,t,n,r)});function WS(e,t){return new US({type:`intersection`,left:e,right:t})}var GS=J(`ZodEnum`,(e,t)=>{Fy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vx(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new GS({...t,checks:[],...Y(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new GS({...t,checks:[],...Y(r),entries:i})}});function KS(e,t){return new GS({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Y(t)})}var qS=J(`ZodLiteral`,(e,t)=>{Iy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yx(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function JS(e,t){return new qS({type:`literal`,values:Array.isArray(e)?e:[e],...Y(t)})}var YS=J(`ZodTransform`,(e,t)=>{Ly.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xx(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ug(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(D_(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(D_(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function XS(e){return new YS({type:`transform`,transform:e})}var ZS=J(`ZodOptional`,(e,t)=>{zy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function QS(e){return new ZS({type:`optional`,innerType:e})}var $S=J(`ZodExactOptional`,(e,t)=>{By.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function eC(e){return new $S({type:`optional`,innerType:e})}var tC=J(`ZodNullable`,(e,t)=>{Vy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ex(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nC(e){return new tC({type:`nullable`,innerType:e})}var rC=J(`ZodDefault`,(e,t)=>{Hy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ox(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function iC(e,t){return new rC({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():c_(t)}})}var aC=J(`ZodPrefault`,(e,t)=>{Wy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function oC(e,t){return new aC({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():c_(t)}})}var sC=J(`ZodNonOptional`,(e,t)=>{Gy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function cC(e,t){return new sC({type:`nonoptional`,innerType:e,...Y(t)})}var lC=J(`ZodCatch`,(e,t)=>{qy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ax(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function uC(e,t){return new lC({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var dC=J(`ZodPipe`,(e,t)=>{Jy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jx(e,t,n,r),e.in=t.in,e.out=t.out});function fC(e,t){return new dC({type:`pipe`,in:e,out:t})}var pC=J(`ZodReadonly`,(e,t)=>{Xy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function mC(e){return new pC({type:`readonly`,innerType:e})}var hC=J(`ZodCustom`,(e,t)=>{Qy.init(e,t),rS.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bx(e,t,n,r)});function gC(e,t={}){return rx(hC,e,t)}function _C(e,t){return ix(e,t)}function vC(e){return jb(OS,e)}var yC=oS().trim().min(1,`请填写 Agent 名称`).max(128,`Agent 名称不能超过 128 个字符`),bC=oS().trim().min(3,`本地标识至少填写 3 个字符`).max(63,`本地标识不能超过 63 个字符`).regex(/^[a-z][a-z0-9-]*$/,`本地标识只能包含小写字母、数字和连字符`),xC=HS([JS(``),bC]),SC=KS([`codex`,`adk`,`langgraph`]),CC=oS().trim().min(4,`系统提示词至少填写 4 个字符`).max(32768,`系统提示词不能超过 32768 个字符`),wC=oS().trim().max(1024,`描述不能超过 1024 个字符`).default(``),TC=BS({name:yC,slug:bC,runtimeType:SC,template:KS([`blank`,`research`]).default(`blank`),prompt:CC,description:wC,audience:oS().trim().max(256,`目标读者不能超过 256 个字符`).default(``),language:KS([`zh-CN`,`en-US`]).default(`zh-CN`),depth:KS([`focused`,`standard`,`deep`]).default(`deep`),format:KS([`report`,`brief`,`evidence-table`]).default(`report`),systemPrompt:oS().max(32768,`系统提示词不能超过 32768 个字符`).default(``),taskPrompt:oS().max(32768,`任务契约不能超过 32768 个字符`).default(``),buildAfterCreate:MS().default(!0)}).superRefine((e,t)=>{e.template===`research`&&!e.audience&&t.addIssue({code:`custom`,path:[`audience`],message:`请填写目标读者`})}),EC=BS({name:yC,slug:bC,runtimeType:SC,prompt:CC,description:wC.optional(),modelProfileId:oS().trim().min(3,`请选择用于构建的模型`).max(256).optional()}),DC=BS({name:yC,slug:xC.default(``)}),OC=BS({name:yC,slug:xC.default(``),path:oS().trim().min(1,`请选择项目目录`).max(4096,`项目路径不能超过 4096 个字符`)}),kC=new Set([`SUCCEEDED`,`FAILED`,`CANCELLED`,`TIMED_OUT`]);function AC(e){return e?.contract?.model||e?.name||``}function jC(e){return e===`adk`?`ADKRuntimeAdapter`:e===`langgraph`?`LangGraphRuntimeAdapter`:`CodexRuntimeAdapter`}function MC(e,t){return t===`codex`?{type:`codex`}:{type:t,projectPath:`.`,entryPoint:t===`adk`?`agent.py`:`graph.py`,agentVariable:t===`adk`?`root_agent`:`app`,agentId:e}}async function NC(e){for(let t=0;t<1200;t+=1){let t=await f(`/api/v1/operations/${encodeURIComponent(e)}`),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error?.message||`构建状态获取失败(${t.status})`);if(kC.has(n.status)){if(n.status!==`SUCCEEDED`)throw Error(n.error?.message||`构建未完成`);return n}await new Promise(e=>window.setTimeout(e,200))}throw Error(`构建等待超时`)}function PC({agentId:e,catalog:t,onSaved:n,onAppearanceSaved:r}){let[i,a]=(0,s.useState)(null),[o,c]=(0,s.useState)(``),l=cm({resolver:vm(TC),defaultValues:{name:``,slug:e,runtimeType:`codex`,prompt:``,description:``}}),{name:u,slug:d,runtimeType:p,prompt:m}=l.watch(),[h,g]=(0,s.useState)(``),[_,v]=(0,s.useState)([]),[y,b]=(0,s.useState)([]),[x,S]=(0,s.useState)([]),[C,w]=(0,s.useState)(!0),[T,E]=(0,s.useState)(!1),[D,O]=(0,s.useState)(``),k=(0,s.useMemo)(()=>t.filter(e=>e.kind===`model`&&[`ready`,`missing-secret`].includes(e.status)),[t]),A=(0,s.useMemo)(()=>t.filter(e=>e.kind===`skill`&&e.status===`ready`),[t]),M=(0,s.useMemo)(()=>t.filter(e=>e.kind===`mcp`),[t]),N=_.map(e=>k.find(t=>t.resourceId===e)).filter(Boolean);(0,s.useEffect)(()=>{let t=!0;return a(null),c(``),f(`/api/v1/agents/${encodeURIComponent(e)}`).then(async n=>{let r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error?.message||`Agent 加载失败(${n.status})`);if(!t)return;let i=r.draft,o=i.spec?.bindings||{},s=o.modelProfileIds?.length?o.modelProfileIds:o.modelProfileId?[o.modelProfileId]:[];a(r),l.reset({name:i.metadata.name||``,slug:i.metadata.id||e,runtimeType:i.spec?.runtime?.type||i.metadata.labels?.[`agentkit.ksyun.com/framework`]||`codex`,prompt:i.spec?.instructions?.system||``,description:i.spec?.description||``}),v(s),g(o.modelProfileId||s[0]||``),b((o.skills||[]).map(e=>e.resourceId)),S((o.mcpServers||[]).map(e=>e.resourceId))}).catch(e=>{t&&c(e.message||`Agent 加载失败`)}),()=>{t=!1}},[e,l]),(0,s.useEffect)(()=>{if(!i||_.length||!k.length)return;let e=i.draft.metadata.labels?.[`agentkit.ksyun.com/model`],t=k.find(t=>AC(t)===e)?.resourceId;t&&(v([t]),g(t))},[i,k,_.length]);function P(e){v(e),e.includes(h)||g(e[0]||``)}let F=k.find(e=>e.resourceId===h)||N[0],L=i?.draft.metadata.labels?.[`agentkit.ksyun.com/model`]||`glm-5.1`,R=N.map(AC).filter(Boolean),z=p===`codex`?[`name: ${d}`,`version: 1.0.0`,`framework: codex`,`artifact_type: ManagedRuntime`,`runtime:`,` name: codex`,` version: 0.144.4`,`model: ${AC(F)||L}`,...R.length>1?[`models:`,...R.map(e=>` - ${e}`)]:[],`prompt: |-`,...m.split(`
|
|
186
|
-
`).map(e=>` ${e}`)].join(`
|
|
187
|
-
`):[`apiVersion: agentkit.ksyun.com/v1alpha1`,`kind: Agent`,`metadata:`,` id: ${d}`,`spec:`,` runtime:`,` type: ${p}`,` projectPath: .`,` entryPoint: ${p===`adk`?`agent.py`:`graph.py`}`,` agentVariable: ${p===`adk`?`root_agent`:`app`}`,` instructions:`,` system: |-`,...m.split(`
|
|
188
|
-
`).map(e=>` ${e}`)].join(`
|
|
189
|
-
`);async function B(t){if(!(!i||T)){E(!0),O(``);try{let r=i.draft.spec,a=JSON.parse(JSON.stringify(r));a.runtime=r.runtime||MC(t.slug,t.runtimeType),a.instructions={system:t.prompt.trim(),task:r.instructions?.task||``},a.execution={...r.execution||{},strategy:r.execution?.strategy||`direct`,maxSteps:r.execution?.maxSteps||12,timeoutSeconds:r.execution?.timeoutSeconds||120},a.bindings={...r.bindings||{},modelProfileId:h||null,modelProfileIds:_,skills:y.map(e=>({resourceId:e,enabled:!0})),mcpServers:x.map(e=>({resourceId:e,enabled:!0}))};let o=await f(`/api/v1/agents/${encodeURIComponent(e)}`,{method:`PUT`,headers:{"Content-Type":`application/json`,"If-Match":String(i.draft.metadata.revision)},body:JSON.stringify(a)}),s=await o.json().catch(()=>null);if(!o.ok){if(Bg(s,l.setError))return;throw Error(s?.error?.message||`保存失败(${o.status})`)}let c=s?.metadata?.id||e;if(Cm(`Agent 已更新`,`agentengine.yaml 已回写,旧构建不会继续用于新会话。`),C){let e=s?.metadata?.revision||i.draft.metadata.revision+1,n=await f(`/api/v1/agents/${encodeURIComponent(c)}/builds`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":`build-${c}-r${e}-${Date.now()}`},body:JSON.stringify({revision:e,runEvaluation:!1})}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error?.message||`构建提交失败(${n.status})`);await NC(r.id),Cm(`${t.runtimeType} Bundle 构建完成`,c)}n(c,C)}catch(e){O(e.message||`保存失败`),Cm(`保存失败`,e.message||`保存失败`,`error`)}finally{E(!1)}}}async function V(t){if(!i)return;let n=await f(`/api/v1/agents/${encodeURIComponent(e)}/appearance`,{method:`PUT`,headers:{"Content-Type":`application/json`,"If-Match":String(i.draft.metadata.revision)},body:JSON.stringify(t)}),o=await n.json().catch(()=>null);if(!n.ok)throw Error(o?.error?.message||`外观保存失败(${n.status})`);a(e=>e&&{...e,draft:{...e.draft,metadata:o.metadata}}),r?.(),Cm(`Agent 外观已更新`,`列表、会话和 Trace 将使用新的头像。`)}return o?(0,W.jsxs)(`div`,{className:`inline-alert error`,children:[(0,W.jsx)(I,{size:16}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`Agent 加载失败`}),(0,W.jsx)(`p`,{children:o})]})]}):i?(0,W.jsxs)(`div`,{className:`quick-create`,children:[(0,W.jsx)(Ap,{...l,children:(0,W.jsxs)(`form`,{className:`quick-create-form`,onSubmit:l.handleSubmit(B),noValidate:!0,children:[(0,W.jsxs)(`div`,{className:`quick-runtime-strip`,children:[(0,W.jsx)(`span`,{className:`runtime-logo`,children:(0,W.jsx)(U,{size:17})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:jC(p)}),(0,W.jsx)(`span`,{children:`一 Agent 一 YAML · 不可变 Bundle`})]}),(0,W.jsx)(`span`,{className:`status-badge success`,children:`本地可运行`})]}),(0,W.jsxs)(`div`,{className:`quick-create-heading`,children:[(0,W.jsx)(`span`,{className:`eyebrow`,children:`YAML-first`}),(0,W.jsxs)(`h2`,{children:[`编辑 `,d]}),(0,W.jsx)(`p`,{children:`保存会直接回写该 Agent 的 agentengine.yaml;旧构建会标记为过期。`})]}),(0,W.jsx)(rh,{name:u||i.draft.metadata.name,appearance:i.draft.metadata.appearance,disabled:T,onSave:V}),(0,W.jsxs)(`div`,{className:`form-grid two-columns`,children:[(0,W.jsx)(q,{label:`显示名称`,requirement:`required`,htmlFor:`editAgentName`,error:l.formState.errors.name?.message,children:(0,W.jsx)(`input`,{id:`editAgentName`,readOnly:!0,...l.register(`name`)})}),(0,W.jsx)(q,{label:`本地标识(Slug)`,requirement:`generated`,htmlFor:`editAgentSlug`,hint:`本地唯一标识由创建流程生成;云端 AgentId 由部署服务另行映射。`,error:l.formState.errors.slug?.message,children:(0,W.jsx)(`input`,{id:`editAgentSlug`,className:`mono generated-value`,readOnly:!0,...l.register(`slug`)})})]}),(0,W.jsx)(q,{label:`Runtime`,requirement:`required`,htmlFor:`editAgentRuntime`,hint:`已有 Build 后不能直接切换 Runtime;需创建迁移 Revision。`,error:l.formState.errors.runtimeType?.message,children:(0,W.jsx)(Tf,{id:`editAgentRuntime`,ariaLabel:`Runtime`,disabled:!0,value:p,options:[{value:`codex`,label:`CodexRuntimeAdapter`},{value:`adk`,label:`ADKRuntimeAdapter`},{value:`langgraph`,label:`LangGraphRuntimeAdapter`}],onValueChange:()=>void 0})}),(0,W.jsx)(q,{label:`系统提示词`,requirement:`required`,htmlFor:`editAgentPrompt`,hint:`首个 Agent 写入根目录 agentengine.yaml;后续 Agent 写入 agents/<id>/agentengine.yaml。`,error:l.formState.errors.prompt?.message,children:(0,W.jsx)(`textarea`,{id:`editAgentPrompt`,maxLength:32768,rows:10,...l.register(`prompt`)})}),(0,W.jsx)(`div`,{className:`form-grid two-columns`,children:(0,W.jsx)(q,{label:`默认模型`,requirement:`required`,htmlFor:`editDefaultModel`,hint:`每轮未指定模型时使用`,children:(0,W.jsx)(Tf,{id:`editDefaultModel`,ariaLabel:`默认模型`,value:h,placeholder:L||`请先绑定模型`,disabled:!N.length,options:N.map(e=>({value:e.resourceId,label:e.displayName,description:AC(e)})),onValueChange:g})})}),(0,W.jsxs)(`div`,{className:`field quick-model-binding-field`,children:[(0,W.jsxs)(`div`,{className:`field-heading`,children:[(0,W.jsx)(`label`,{children:`绑定模型`}),(0,W.jsx)(`span`,{className:`helper`,children:`会话中只能动态切换到这里选中的模型`})]}),(0,W.jsx)(jg,{ariaLabel:`选择绑定模型`,items:k,selectedIds:_,getId:e=>e.resourceId,getLabel:e=>e.displayName,getDescription:e=>`${AC(e)} · ${e.status}`,onChange:P,searchPlaceholder:`搜索绑定模型`,emptyMessage:`当前模型服务没有返回可绑定模型`})]}),(0,W.jsxs)(`div`,{className:`field quick-model-binding-field`,children:[(0,W.jsxs)(`div`,{className:`field-heading`,children:[(0,W.jsx)(`label`,{children:`绑定 Skill / MCP`}),(0,W.jsx)(`span`,{className:`helper`,children:`Skill 以原生 SkillInput 注入;MCP 经 codex config_overrides 注入`})]}),(0,W.jsxs)(`div`,{className:`quick-capability-bindings`,children:[(0,W.jsx)(jg,{ariaLabel:`选择绑定 Skill`,items:A,selectedIds:y,getId:e=>e.resourceId,getLabel:e=>e.displayName,getDescription:e=>e.version,onChange:b,searchPlaceholder:`搜索 Skill`,emptyMessage:`没有已安装的 Skill`}),(0,W.jsx)(jg,{ariaLabel:`选择绑定 MCP`,items:M,selectedIds:x,getId:e=>e.resourceId,getLabel:e=>e.displayName,getDescription:e=>`${e.version} · ${e.health?.toolCount||0} Tool`,onChange:S,searchPlaceholder:`搜索 MCP`,emptyMessage:`没有已连接的 MCP`})]})]}),(0,W.jsxs)(`div`,{className:`quick-create-actions`,children:[(0,W.jsxs)(`label`,{className:`checkbox-row`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>w(e.target.checked)}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:`保存后立即重新构建`}),(0,W.jsx)(`small`,{children:`新构建完成后直接进入会话工作台`})]})]}),(0,W.jsxs)(`button`,{className:`button accent`,type:`submit`,disabled:T,children:[(0,W.jsx)(Ee,{size:15}),(0,W.jsx)(`span`,{children:T?`正在保存`:`保存修改`})]})]}),D&&(0,W.jsxs)(`div`,{className:`inline-alert error`,children:[(0,W.jsx)(I,{size:16}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`保存失败`}),(0,W.jsx)(`p`,{children:D})]})]})]})}),(0,W.jsxs)(`aside`,{className:`manifest-preview`,children:[(0,W.jsx)(Lg,{code:z,language:`yaml`,filename:`agentkit.yaml`,wrap:!0}),(0,W.jsxs)(`div`,{className:`manifest-contract`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(j,{size:13}),`唯一配置源`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(j,{size:13}),`SHA-256 可追溯`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(j,{size:13}),`RuntimeAdapter 执行`]})]})]})]}):(0,W.jsx)(`div`,{className:`quick-create`,children:(0,W.jsx)(`p`,{children:`正在加载 Agent 配置…`})})}function FC({title:e,subtitle:t,wide:n=!1,closeDisabled:r=!1,onClose:i,footer:a,children:o}){return(0,W.jsx)(sa,{open:!0,onOpenChange:e=>{e||i()},title:e,subtitle:t,wide:n,closeDisabled:r,footer:a,children:o})}function IC({kind:e,title:t,message:n}){return(0,W.jsxs)(`div`,{className:`inline-alert ${e}`,children:[e===`success`?(0,W.jsx)(R,{size:15}):(0,W.jsx)(I,{size:15}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:t}),n?(0,W.jsx)(`p`,{children:n}):null]})]})}function LC(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var RC=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,zC=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,BC={};function VC(e,t){return((t||BC).jsx?zC:RC).test(e)}var HC=/[ \t\n\f\r]/g;function UC(e){return typeof e==`object`?e.type===`text`&&WC(e.value):WC(e)}function WC(e){return e.replace(HC,``)===``}var GC=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};GC.prototype.normal={},GC.prototype.property={},GC.prototype.space=void 0;function KC(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new GC(n,r,t)}function qC(e){return e.toLowerCase()}var JC=class{constructor(e,t){this.attribute=t,this.property=e}};JC.prototype.attribute=``,JC.prototype.booleanish=!1,JC.prototype.boolean=!1,JC.prototype.commaOrSpaceSeparated=!1,JC.prototype.commaSeparated=!1,JC.prototype.defined=!1,JC.prototype.mustUseProperty=!1,JC.prototype.number=!1,JC.prototype.overloadedBoolean=!1,JC.prototype.property=``,JC.prototype.spaceSeparated=!1,JC.prototype.space=void 0;var YC=e({boolean:()=>X,booleanish:()=>ZC,commaOrSpaceSeparated:()=>tw,commaSeparated:()=>ew,number:()=>Z,overloadedBoolean:()=>QC,spaceSeparated:()=>$C}),XC=0,X=nw(),ZC=nw(),QC=nw(),Z=nw(),$C=nw(),ew=nw(),tw=nw();function nw(){return 2**++XC}var rw=Object.keys(YC),iw=class extends JC{constructor(e,t,n,r){let i=-1;if(super(e,t),aw(this,`space`,r),typeof n==`number`)for(;++i<rw.length;){let e=rw[i];aw(this,rw[i],(n&YC[e])===YC[e])}}};iw.prototype.defined=!0;function aw(e,t,n){n&&(e[t]=n)}function ow(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new iw(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[qC(r)]=r,n[qC(a.attribute)]=r}return new GC(t,n,e.space)}var sw=ow({properties:{ariaActiveDescendant:null,ariaAtomic:ZC,ariaAutoComplete:null,ariaBusy:ZC,ariaChecked:ZC,ariaColCount:Z,ariaColIndex:Z,ariaColSpan:Z,ariaControls:$C,ariaCurrent:null,ariaDescribedBy:$C,ariaDetails:null,ariaDisabled:ZC,ariaDropEffect:$C,ariaErrorMessage:null,ariaExpanded:ZC,ariaFlowTo:$C,ariaGrabbed:ZC,ariaHasPopup:null,ariaHidden:ZC,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:$C,ariaLevel:Z,ariaLive:null,ariaModal:ZC,ariaMultiLine:ZC,ariaMultiSelectable:ZC,ariaOrientation:null,ariaOwns:$C,ariaPlaceholder:null,ariaPosInSet:Z,ariaPressed:ZC,ariaReadOnly:ZC,ariaRelevant:null,ariaRequired:ZC,ariaRoleDescription:$C,ariaRowCount:Z,ariaRowIndex:Z,ariaRowSpan:Z,ariaSelected:ZC,ariaSetSize:Z,ariaSort:null,ariaValueMax:Z,ariaValueMin:Z,ariaValueNow:Z,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function cw(e,t){return t in e?e[t]:t}function lw(e,t){return cw(e,t.toLowerCase())}var uw=ow({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:ew,acceptCharset:$C,accessKey:$C,action:null,allow:null,allowFullScreen:X,allowPaymentRequest:X,allowUserMedia:X,alpha:X,alt:null,as:null,async:X,autoCapitalize:null,autoComplete:$C,autoFocus:X,autoPlay:X,blocking:$C,capture:null,charSet:null,checked:X,cite:null,className:$C,closedBy:null,colorSpace:null,cols:Z,colSpan:Z,command:null,commandFor:null,content:null,contentEditable:ZC,controls:X,controlsList:$C,coords:Z|ew,crossOrigin:null,data:null,dateTime:null,decoding:null,default:X,defer:X,dir:null,dirName:null,disabled:X,download:QC,draggable:ZC,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:X,formTarget:null,headers:$C,height:Z,hidden:QC,high:Z,href:null,hrefLang:null,htmlFor:$C,httpEquiv:$C,id:null,imageSizes:null,imageSrcSet:null,inert:X,inputMode:null,integrity:null,is:null,isMap:X,itemId:null,itemProp:$C,itemRef:$C,itemScope:X,itemType:$C,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:X,low:Z,manifest:null,max:null,maxLength:Z,media:null,method:null,min:null,minLength:Z,multiple:X,muted:X,name:null,nonce:null,noModule:X,noValidate:X,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:X,optimum:Z,pattern:null,ping:$C,placeholder:null,playsInline:X,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:X,referrerPolicy:null,rel:$C,required:X,reversed:X,rows:Z,rowSpan:Z,sandbox:$C,scope:null,scoped:X,seamless:X,selected:X,shadowRootClonable:X,shadowRootCustomElementRegistry:X,shadowRootDelegatesFocus:X,shadowRootMode:null,shadowRootSerializable:X,shape:null,size:Z,sizes:null,slot:null,span:Z,spellCheck:ZC,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Z,step:null,style:null,tabIndex:Z,target:null,title:null,translate:null,type:null,typeMustMatch:X,useMap:null,value:ZC,width:Z,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:$C,axis:null,background:null,bgColor:null,border:Z,borderColor:null,bottomMargin:Z,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:X,declare:X,event:null,face:null,frame:null,frameBorder:null,hSpace:Z,leftMargin:Z,link:null,longDesc:null,lowSrc:null,marginHeight:Z,marginWidth:Z,noResize:X,noHref:X,noShade:X,noWrap:X,object:null,profile:null,prompt:null,rev:null,rightMargin:Z,rules:null,scheme:null,scrolling:ZC,standby:null,summary:null,text:null,topMargin:Z,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Z,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:X,disablePictureInPicture:X,disableRemotePlayback:X,exportParts:ew,part:$C,prefix:null,property:null,results:Z,security:null,unselectable:null},space:`html`,transform:lw}),dw=ow({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:tw,accentHeight:Z,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Z,amplitude:Z,arabicForm:null,ascent:Z,attributeName:null,attributeType:null,azimuth:Z,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Z,by:null,calcMode:null,capHeight:Z,className:$C,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Z,diffuseConstant:Z,direction:null,display:null,dur:null,divisor:Z,dominantBaseline:null,download:X,dx:null,dy:null,edgeMode:null,editable:null,elevation:Z,enableBackground:null,end:null,event:null,exponent:Z,externalResourcesRequired:null,fill:null,fillOpacity:Z,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:ew,g2:ew,glyphName:ew,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Z,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Z,horizOriginX:Z,horizOriginY:Z,id:null,ideographic:Z,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Z,k:Z,k1:Z,k2:Z,k3:Z,k4:Z,kernelMatrix:tw,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Z,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Z,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Z,overlineThickness:Z,paintOrder:null,panose1:null,path:null,pathLength:Z,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:$C,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Z,pointsAtY:Z,pointsAtZ:Z,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:tw,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:tw,rev:tw,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:tw,requiredFeatures:tw,requiredFonts:tw,requiredFormats:tw,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Z,specularExponent:Z,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Z,strikethroughThickness:Z,string:null,stroke:null,strokeDashArray:tw,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Z,strokeOpacity:Z,strokeWidth:null,style:null,surfaceScale:Z,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:tw,tabIndex:Z,tableValues:null,target:null,targetX:Z,targetY:Z,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:tw,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Z,underlineThickness:Z,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Z,values:null,vAlphabetic:Z,vMathematical:Z,vectorEffect:null,vHanging:Z,vIdeographic:Z,version:null,vertAdvY:Z,vertOriginX:Z,vertOriginY:Z,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Z,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:cw}),fw=ow({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),pw=ow({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:lw}),mw=ow({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),hw={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},gw=/[A-Z]/g,_w=/-[a-z]/g,vw=/^data[-\w.:]+$/i;function yw(e,t){let n=qC(t),r=t,i=JC;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&vw.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(_w,xw);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!_w.test(e)){let n=e.replace(gw,bw);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=iw}return new i(r,t)}function bw(e){return`-`+e.toLowerCase()}function xw(e){return e.charAt(1).toUpperCase()}var Sw=KC([sw,uw,fw,pw,mw],`html`),Cw=KC([sw,dw,fw,pw,mw],`svg`);function ww(e){return e.join(` `).trim()}var Tw=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
190
|
-
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),Ew=n((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(Tw());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),Dw=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),Ow=n(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Ew()),r=Dw();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),kw=jw(`end`),Aw=jw(`start`);function jw(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function Mw(e){let t=Aw(e),n=kw(e);if(t&&n)return{start:t,end:n}}function Nw(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Fw(e.position):`start`in e||`end`in e?Fw(e):`line`in e||`column`in e?Pw(e):``}function Pw(e){return Iw(e&&e.line)+`:`+Iw(e&&e.column)}function Fw(e){return Pw(e&&e.start)+`-`+Pw(e&&e.end)}function Iw(e){return e&&typeof e==`number`?e:1}var Lw=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=Nw(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Lw.prototype.file=``,Lw.prototype.name=``,Lw.prototype.reason=``,Lw.prototype.message=``,Lw.prototype.stack=``,Lw.prototype.column=void 0,Lw.prototype.line=void 0,Lw.prototype.ancestors=void 0,Lw.prototype.cause=void 0,Lw.prototype.fatal=void 0,Lw.prototype.place=void 0,Lw.prototype.ruleId=void 0,Lw.prototype.source=void 0;var Rw=t(Ow(),1),zw={}.hasOwnProperty,Bw=new Map,Vw=/[A-Z]/g,Hw=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Uw=new Set([`td`,`th`]);function Ww(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=tT(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=eT(n,t.jsx,t.jsxs)}let 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`?Cw:Sw,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Gw(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Gw(e,t,n){if(t.type===`element`)return Kw(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return qw(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Yw(e,t,n);if(t.type===`mdxjsEsm`)return Jw(e,t);if(t.type===`root`)return Xw(e,t,n);if(t.type===`text`)return Zw(e,t)}function Kw(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Cw,e.schema=i),e.ancestors.push(t);let a=sT(e,t.tagName,!1),o=nT(e,t),s=iT(e,t);return Hw.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!UC(e)})),Qw(e,o,a,t),$w(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function qw(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}cT(e,t.position)}function Jw(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);cT(e,t.position)}function Yw(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Cw,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:sT(e,t.name,!0),o=rT(e,t),s=iT(e,t);return Qw(e,o,a,t),$w(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Xw(e,t,n){let r={};return $w(r,iT(e,t)),e.create(t,e.Fragment,r,n)}function Zw(e,t){return t.value}function Qw(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function $w(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function eT(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function tT(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=Aw(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function nT(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&zw.call(t.properties,i)){let a=aT(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Uw.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function rT(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else cT(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else cT(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function iT(e,t){let n=[],r=-1,i=e.passKeys?new Map:Bw;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=Gw(e,a,o);s!==void 0&&n.push(s)}return n}function aT(e,t,n){let r=yw(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?LC(n):ww(n)),r.property===`style`){let t=typeof n==`object`?n:oT(e,String(n));return e.stylePropertyNameCase===`css`&&(t=lT(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?hw[r.property]||r.property:r.attribute,n]}}function oT(e,t){try{return(0,Rw.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new Lw("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute`,r}}function sT(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=VC(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=VC(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return zw.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);cT(e)}function cT(e,t){let n=new Lw("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-handle-mdx-estrees-without-createevaluater`,n}function lT(e){let t={},n;for(n in e)zw.call(e,n)&&(t[uT(n)]=e[n]);return t}function uT(e){let t=e.replace(Vw,dT);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function dT(e){return`-`+e.toLowerCase()}var fT={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},pT={};function mT(e,t){let n=t||pT;return hT(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function hT(e,t,n){if(_T(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return gT(e.children,t,n)}return Array.isArray(e)?gT(e,t,n):``}function gT(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=hT(e[i],t,n);return r.join(``)}function _T(e){return!!(e&&typeof e==`object`)}var vT=document.createElement(`i`);function yT(e){let t=`&`+e+`;`;vT.innerHTML=t;let n=vT.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function bT(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function xT(e,t){return e.length>0?(bT(e,e.length,0,t),e):t}var ST={}.hasOwnProperty;function CT(e){let t={},n=-1;for(;++n<e.length;)wT(t,e[n]);return t}function wT(e,t){let n;for(n in t){let r=(ST.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){ST.call(r,a)||(r[a]=[]);let e=i[a];TT(r[a],Array.isArray(e)?e:e?[e]:[])}}}function TT(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);bT(e,0,0,r)}function ET(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&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 DT(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var OT=zT(/[A-Za-z]/),kT=zT(/[\dA-Za-z]/),AT=zT(/[#-'*+\--9=?A-Z^-~]/);function jT(e){return e!==null&&(e<32||e===127)}var MT=zT(/\d/),NT=zT(/[\dA-Fa-f]/),PT=zT(/[!-/:-@[-`{-~]/);function Q(e){return e!==null&&e<-2}function FT(e){return e!==null&&(e<0||e===32)}function IT(e){return e===-2||e===-1||e===32}var LT=zT(/\p{P}|\p{S}/u),RT=zT(/\s/);function zT(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function BT(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&kT(e.charCodeAt(n+1))&&kT(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function VT(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return IT(r)?(e.enter(n),s(r)):t(r)}function s(r){return IT(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var HT={tokenize:UT};function UT(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),VT(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return Q(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var WT={tokenize:KT},GT={tokenize:qT};function KT(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return bT(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(GT,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(GT,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return Q(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;bT(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function qT(e,t,n){return VT(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function JT(e){if(e===null||FT(e)||RT(e))return 1;if(LT(e))return 2}function YT(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var XT={name:`attention`,resolveAll:ZT,tokenize:QT};function ZT(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};$T(d,-c),$T(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=xT(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=xT(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=xT(l,YT(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=xT(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=xT(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,bT(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function QT(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=JT(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=JT(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function $T(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var eE={name:`autolink`,tokenize:tE};function tE(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return OT(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||kT(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||kT(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||jT(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):AT(t)?(e.consume(t),l):n(t)}function u(e){return kT(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||kT(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var nE={partial:!0,tokenize:rE};function rE(e,t,n){return r;function r(t){return IT(t)?VT(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||Q(e)?t(e):n(e)}}var iE={continuation:{tokenize:oE},exit:sE,name:`blockQuote`,tokenize:aE};function aE(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return IT(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function oE(e,t,n){let r=this;return i;function i(t){return IT(t)?VT(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(iE,t,n)(r)}}function sE(e){e.exit(`blockQuote`)}var cE={name:`characterEscape`,tokenize:lE};function lE(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return PT(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var uE={name:`characterReference`,tokenize:dE};function dE(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=kT,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=NT,u):(e.enter(`characterReferenceValue`),a=7,o=MT,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===kT&&!yT(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var fE={partial:!0,tokenize:hE},pE={concrete:!0,name:`codeFenced`,tokenize:mE};function mE(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),IT(t)?VT(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||Q(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(fE,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||Q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):IT(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),VT(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||Q(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||Q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&IT(t)?VT(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||Q(t)?e.check(fE,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||Q(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),IT(t)?VT(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),IT(t)?VT(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||Q(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function hE(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var gE={name:`codeIndented`,tokenize:vE},_E={partial:!0,tokenize:yE};function vE(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),VT(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):Q(t)?e.attempt(_E,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||Q(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function yE(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):Q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):VT(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):Q(e)?i(e):n(e)}}var bE={name:`codeText`,previous:SE,resolve:xE,tokenize:CE};function xE(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<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function SE(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function CE(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):Q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||Q(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var wE=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&TE(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),TE(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),TE(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);TE(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);TE(this.left,t.reverse())}}}};function TE(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function EE(e){let t={},n=-1,r,i,a,o,s,c,l,u=new wE(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,DE(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return bT(e,0,1/0,u.slice(0)),!l}function DE(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var OE={resolve:AE,tokenize:jE},kE={partial:!0,tokenize:ME};function AE(e){return EE(e),e}function jE(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):Q(t)?e.check(kE,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function ME(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),VT(e,a,`linePrefix`)}function a(i){if(i===null||Q(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function NE(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||jT(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||Q(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||FT(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||jT(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function PE(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):Q(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||Q(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!IT(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function FE(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):Q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),VT(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||Q(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function IE(e,t){let n;return r;function r(i){return Q(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):IT(i)?VT(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var LE={name:`definition`,tokenize:zE},RE={partial:!0,tokenize:BE};function zE(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return PE.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=DT(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return FT(t)?IE(e,l)(t):l(t)}function l(t){return NE(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(RE,d,d)(t)}function d(t){return IT(t)?VT(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||Q(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function BE(e,t,n){return r;function r(t){return FT(t)?IE(e,i)(t):n(t)}function i(t){return FE(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return IT(t)?VT(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||Q(e)?t(e):n(e)}}var VE={name:`hardBreakEscape`,tokenize:HE};function HE(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return Q(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var UE={name:`headingAtx`,resolve:WE,tokenize:GE};function WE(e,t){let n=e.length-2,r=3,i,a;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},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},bT(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function GE(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||FT(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||Q(n)?(e.exit(`atxHeading`),t(n)):IT(n)?VT(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||FT(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var KE=`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`.split(`.`),qE=[`pre`,`script`,`style`,`textarea`],JE={concrete:!0,name:`htmlFlow`,resolveTo:ZE,tokenize:QE},YE={partial:!0,tokenize:eD},XE={partial:!0,tokenize:$E};function ZE(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 QE(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):OT(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):OT(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return OT(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||FT(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&qE.includes(l)?(i=1,r.interrupt?t(s):O(s)):KE.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||kT(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return IT(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||OT(t)?(e.consume(t),b):IT(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||kT(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):IT(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):IT(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||Q(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||FT(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||IT(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||Q(t)?O(t):IT(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):Q(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(YE,R,k)(t)):t===null||Q(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(XE,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||Q(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return qE.includes(n)?(e.consume(t),L):O(t)}return OT(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||Q(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function $E(e,t,n){let r=this;return i;function i(t){return Q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function eD(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(nE,t,n)}}var tD={name:`htmlText`,tokenize:nD};function nD(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):OT(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):OT(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):Q(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):Q(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):Q(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):Q(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return OT(t)?(e.consume(t),S):n(t)}function S(t){return t===45||kT(t)?(e.consume(t),S):C(t)}function C(t){return Q(t)?(o=C,N(t)):IT(t)?(e.consume(t),C):M(t)}function w(t){return t===45||kT(t)?(e.consume(t),w):t===47||t===62||FT(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||OT(t)?(e.consume(t),E):Q(t)?(o=T,N(t)):IT(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||kT(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):Q(t)?(o=D,N(t)):IT(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):Q(t)?(o=O,N(t)):IT(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):Q(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||FT(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||FT(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return IT(t)?VT(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var rD={name:`labelEnd`,resolveAll:sD,resolveTo:cD,tokenize:lD},iD={tokenize:uD},aD={tokenize:dD},oD={tokenize:fD};function sD(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&bT(e,0,e.length,n),e}function cD(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=xT(s,e.slice(a+1,a+r+3)),s=xT(s,[[`enter`,u,t]]),s=xT(s,YT(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=xT(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=xT(s,e.slice(o+1)),s=xT(s,[[`exit`,c,t]]),bT(e,a,e.length,s),e}function lD(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(DT(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(iD,u,o?u:d)(t):t===91?e.attempt(aD,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(oD,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function uD(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return FT(t)?IE(e,a)(t):a(t)}function a(t){return t===41?u(t):NE(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return FT(t)?IE(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?FE(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return FT(t)?IE(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function dD(e,t,n){let r=this;return i;function i(t){return PE.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(DT(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function fD(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var pD={name:`labelStartImage`,resolveAll:rD.resolveAll,tokenize:mD};function mD(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var hD={name:`labelStartLink`,resolveAll:rD.resolveAll,tokenize:gD};function gD(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var _D={name:`lineEnding`,tokenize:vD};function vD(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),VT(e,t,`linePrefix`)}}var yD={name:`thematicBreak`,tokenize:bD};function bD(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||Q(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),IT(t)?VT(e,s,`whitespace`)(t):s(t))}}var xD={continuation:{tokenize:TD},exit:DD,name:`list`,tokenize:wD},SD={partial:!0,tokenize:OD},CD={partial:!0,tokenize:ED};function wD(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:MT(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(yD,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return MT(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(nE,r.interrupt?n:u,e.attempt(SD,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return IT(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function TD(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(nE,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,VT(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!IT(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(CD,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,VT(e,e.attempt(xD,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function ED(e,t,n){let r=this;return VT(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function DD(e){e.exit(this.containerState.type)}function OD(e,t,n){let r=this;return VT(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!IT(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var kD={name:`setextUnderline`,resolveTo:AD,tokenize:jD};function AD(e,t){let n=e.length,r,i,a;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),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function jD(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),IT(t)?VT(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||Q(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var MD={tokenize:ND};function ND(e){let t=this,n=e.attempt(nE,r,e.attempt(this.parser.constructs.flowInitial,i,VT(e,e.attempt(this.parser.constructs.flow,i,e.attempt(OE,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var PD={resolveAll:RD()},FD=LD(`string`),ID=LD(`text`);function LD(e){return{resolveAll:RD(e===`text`?zD:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function RD(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function zD(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var BD=e({attentionMarkers:()=>JD,contentInitial:()=>HD,disable:()=>YD,document:()=>VD,flow:()=>WD,flowInitial:()=>UD,insideSpan:()=>qD,string:()=>GD,text:()=>KD}),VD={42:xD,43:xD,45:xD,48:xD,49:xD,50:xD,51:xD,52:xD,53:xD,54:xD,55:xD,56:xD,57:xD,62:iE},HD={91:LE},UD={[-2]:gE,[-1]:gE,32:gE},WD={35:UE,42:yD,45:[kD,yD],60:JE,61:kD,95:yD,96:pE,126:pE},GD={38:uE,92:cE},KD={[-5]:_D,[-4]:_D,[-3]:_D,33:pD,38:uE,42:XT,60:[eE,tD],91:hD,92:[VE,cE],93:rD,95:XT,96:bE},qD={null:[XT,PD]},JD={null:[42,95]},YD={null:[]};function XD(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=xT(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=YT(a,l.events,l),l.events):[]}function f(e,t){return QD(p(e),t)}function p(e){return ZD(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){Q(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&bT(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function ZD(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function QD(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
191
|
-
`;break;case-3:o=`\r
|
|
192
|
-
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function $D(e){let t={constructs:CT([BD,...(e||{}).extensions||[]]),content:n(HT),defined:[],document:n(WT),flow:n(MD),lazy:{},string:n(FD),text:n(ID)};return t;function n(e){return n;function n(n){return XD(t,e,n)}}}function eO(e){for(;!EE(e););return e}var tO=/[\0\t\n\r]/g;function nO(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(tO.lastIndex=u,c=tO.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var rO=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function iO(e){return e.replace(rO,aO)}function aO(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return ET(n.slice(t?2:1),t?16:10)}return yT(n)||e}var oO={}.hasOwnProperty;function sO(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),cO(n)(eO($D(n).document().write(nO()(e,t,!0))))}function cO(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(de),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(se),blockQuote:a(ne),characterEscape:T,characterReference:T,codeFenced:a(re),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(re,o),codeText:a(ie,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ae),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(oe),hardBreakEscape:a(ce),hardBreakTrailing:a(ce),htmlFlow:a(le,o),htmlFlowData:T,htmlText:a(le,o),htmlTextData:T,image:a(ue),label:o,link:a(de),listItem:a(pe),listItemValue:f,listOrdered:a(fe,d),listUnordered:a(fe),paragraph:a(me),reference:z,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(se),strong:a(he),thematicBreak:a(_e)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:te,autolinkProtocol:ee,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:V,characterReferenceMarkerNumeric:V,characterReferenceValue:H,characterReference:U,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:B,resourceDestinationString:I,resourceTitleString:L,resource:R,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};uO(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];oO.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||fO).call(a,void 0,e[0])}for(r.position={start:lO(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:lO(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:lO(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||fO).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+Nw({start:e.start,end:e.end})+`): it’s not open`);n.position.end=lO(e.end)}function u(){return mT(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=DT(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=ge(),n.position={start:lO(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=lO(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=lO(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=iO(t),n.identifier=DT(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function R(){this.data.inReference=void 0}function z(){this.data.referenceType=`collapsed`}function B(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=DT(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function V(e){this.data.characterReferenceType=e.type}function H(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=ET(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=yT(t);let i=this.stack[this.stack.length-1];i.value+=r}function U(e){let t=this.stack.pop();t.position.end=lO(e.end)}function ee(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function te(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ne(){return{type:`blockquote`,children:[]}}function re(){return{type:`code`,lang:null,meta:null,value:``}}function ie(){return{type:`inlineCode`,value:``}}function ae(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function oe(){return{type:`emphasis`,children:[]}}function se(){return{type:`heading`,depth:0,children:[]}}function ce(){return{type:`break`}}function le(){return{type:`html`,value:``}}function ue(){return{type:`image`,title:null,url:``,alt:null}}function de(){return{type:`link`,title:null,url:``,children:[]}}function fe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function pe(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function me(){return{type:`paragraph`,children:[]}}function he(){return{type:`strong`,children:[]}}function ge(){return{type:`text`,value:``}}function _e(){return{type:`thematicBreak`}}}function lO(e){return{line:e.line,column:e.column,offset:e.offset}}function uO(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?uO(e,r):dO(e,r)}}function dO(e,t){let n;for(n in t)if(oO.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function fO(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+Nw({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Nw({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+Nw({start:t.start,end:t.end})+`) is still open`)}function pO(e){let t=this;t.parser=n;function n(n){return sO(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function mO(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function hO(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
193
|
-
`}]}function gO(e,t){let n=t.value?t.value+`
|
|
194
|
-
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function _O(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function vO(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function yO(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=BT(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function bO(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function xO(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function SO(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function CO(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return SO(e,t);let i={src:BT(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function wO(e,t){let n={src:BT(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function TO(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function EO(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return SO(e,t);let i={href:BT(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function DO(e,t){let n={href:BT(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function OO(e,t,n){let r=e.all(t),i=n?kO(n):AO(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
195
|
-
`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
196
|
-
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function kO(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=AO(n[r])}return t}function AO(e){return e.spread??e.children.length>1}function jO(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function MO(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function NO(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function PO(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function FO(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=Aw(t.children[1]),o=kw(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function IO(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function LO(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var RO=9,zO=32;function BO(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(VO(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(VO(t.slice(i),i>0,!1)),a.join(``)}function VO(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===RO||t===zO;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===RO||t===zO;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function HO(e,t){let n={type:`text`,value:BO(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function UO(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var WO={blockquote:mO,break:hO,code:gO,delete:_O,emphasis:vO,footnoteReference:yO,heading:bO,html:xO,imageReference:CO,image:wO,inlineCode:TO,linkReference:EO,link:DO,listItem:OO,list:jO,paragraph:MO,root:NO,strong:PO,table:FO,tableCell:LO,tableRow:IO,text:HO,thematicBreak:UO,toml:GO,yaml:GO,definition:GO,footnoteDefinition:GO};function GO(){}var KO=typeof self==`object`?self:globalThis,qO=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new KO[e](t)},JO=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof KO[e]==`function`?qO(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(qO(a,o),i)};return r},YO=e=>JO(new Map,e)(0),XO=``,{toString:ZO}={},{keys:QO}=Object,$O=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=ZO.call(e).slice(8,-1);switch(n){case`Array`:return[1,XO];case`Object`:return[2,XO];case`Date`:return[3,XO];case`RegExp`:return[4,XO];case`Map`:return[5,XO];case`Set`:return[6,XO];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},ek=([e,t])=>e===0&&(t===`function`||t===`symbol`),tk=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=$O(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of QO(r))(e||!ek($O(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,isNaN(r.getTime())?XO:r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(ek($O(n))||ek($O(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!ek($O(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},nk=(e,{json:t,lossy:n}={})=>{let r=[];return tk(!(t||n),!!t,new Map,r)(e),r},rk=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?YO(nk(e,t)):structuredClone(e):(e,t)=>YO(nk(e,t));function ik(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function ak(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function ok(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||ik,r=e.options.footnoteBackLabel||ak,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=BT(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...rk(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
197
|
-
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
198
|
-
`}]}}var sk=(function(e){if(e==null)return fk;if(typeof e==`function`)return dk(e);if(typeof e==`object`)return Array.isArray(e)?ck(e):lk(e);if(typeof e==`string`)return uk(e);throw Error(`Expected function, string, or object as test`)});function ck(e){let t=[],n=-1;for(;++n<e.length;)t[n]=sk(e[n]);return dk(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function lk(e){let t=e;return dk(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function uk(e){return dk(t);function t(t){return t&&t.type===e}}function dk(e){return t;function t(t,n,r){return!!(pk(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function fk(){return!0}function pk(e){return typeof e==`object`&&!!e&&`type`in e}function mk(e){return e}var hk=[];function gk(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=sk(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+mk(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=hk,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=_k(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function _k(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?hk:[e]}function vk(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),gk(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var yk={}.hasOwnProperty,bk={};function xk(e,t){let n=t||bk,r=new Map,i=new Map,a={all:s,applyData:Ck,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...WO,...n.handlers},one:o,options:n,patch:Sk,wrap:Tk};return vk(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(yk.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=rk(n);return r.children=a.all(e),r}return rk(e)}return(a.options.unknownHandler||wk)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=Ek(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=Ek(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function Sk(e,t){e.position&&(t.position=Mw(e))}function Ck(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,rk(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function wk(e,t){let n=t.data||{},r=`value`in t&&!(yk.call(n,`hProperties`)||yk.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Tk(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
199
|
-
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
200
|
-
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
201
|
-
`}),n}function Ek(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Dk(e,t){let n=xk(e,t),r=n.one(e,void 0),i=ok(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
202
|
-
`},i)),a}function Ok(e,t){return e&&`run`in e?async function(n,r){let i=Dk(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Dk(n,{file:r,...e||t})}}function kk(e){if(e)throw e}var Ak=n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function jk(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Mk(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?Nk(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function Nk(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var Pk={basename:Fk,dirname:Ik,extname:Lk,join:Rk,sep:`/`};function Fk(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);Vk(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function Ik(e){if(Vk(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function Lk(e){Vk(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function Rk(...e){let t=-1,n;for(;++t<e.length;)Vk(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:zk(n)}function zk(e){Vk(e);let t=e.codePointAt(0)===47,n=Bk(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function Bk(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function Vk(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var Hk={cwd:Uk};function Uk(){return`/`}function Wk(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function Gk(e){if(typeof e==`string`)e=new URL(e);else if(!Wk(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return Kk(e)}function Kk(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var qk=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],Jk=class{constructor(e){let t;t=e?Wk(e)?{path:e}:typeof e==`string`||Qk(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Hk.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<qk.length;){let e=qk[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)qk.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?Pk.basename(this.path):void 0}set basename(e){Xk(e,`basename`),Yk(e,`basename`),this.path=Pk.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?Pk.dirname(this.path):void 0}set dirname(e){Zk(this.basename,`dirname`),this.path=Pk.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?Pk.extname(this.path):void 0}set extname(e){if(Yk(e,`extname`),Zk(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=Pk.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){Wk(e)&&(e=Gk(e)),Xk(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?Pk.basename(this.path,this.extname):void 0}set stem(e){Xk(e,`stem`),Yk(e,`stem`),this.path=Pk.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new Lw(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function Yk(e,t){if(e&&e.includes(Pk.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Pk.sep+"`")}function Xk(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function Zk(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function Qk(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var $k=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),eA=t(Ak(),1),tA={}.hasOwnProperty,nA=new class e extends $k{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Mk()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,eA.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(aA(`data`,this.frozen),this.namespace[e]=t,this):tA.call(this.namespace,e)&&this.namespace[e]||void 0:e?(aA(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=cA(e),n=this.parser||this.Parser;return rA(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),rA(`process`,this.parser||this.Parser),iA(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=cA(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);uA(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),rA(`processSync`,this.parser||this.Parser),iA(`processSync`,this.compiler||this.Compiler),this.process(e,r),sA(`processSync`,`process`,t),n;function r(e,r){t=!0,kk(e),n=r}}run(e,t,n){oA(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=cA(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),sA(`runSync`,`run`,n),r;function i(e,t){kk(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=cA(t),r=this.compiler||this.Compiler;return iA(`stringify`,r),oA(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(aA(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,eA.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];jk(o)&&jk(r)&&(r=(0,eA.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function rA(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function iA(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function aA(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function oA(e){if(!jk(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function sA(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function cA(e){return lA(e)?e:new Jk(e)}function lA(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function uA(e){return typeof e==`string`||dA(e)}function dA(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var fA=[],pA={allowDangerousHtml:!0},mA=/^(https?|ircs?|mailto|xmpp)$/i,hA=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function gA(e){let t=_A(e),n=vA(e);return yA(t.runSync(t.parse(n),n),e)}function _A(e){let t=e.rehypePlugins||fA,n=e.remarkPlugins||fA,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...pA}:pA;return nA().use(pO).use(n).use(Ok,r).use(t)}function vA(e){let t=e.children||``,n=new Jk;return typeof t==`string`?n.value=t:``+t,n}function yA(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||bA;for(let e of hA)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return vk(e,l),Ww(e,{Fragment:W.Fragment,components:i,ignoreInvalidStyle:!0,jsx:W.jsx,jsxs:W.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in fT)if(Object.hasOwn(fT,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=fT[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function bA(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||mA.test(e.slice(0,t))?e:``}function xA(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function SA(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function CA(e,t,n){let r=sk((n||{}).ignore||[]),i=wA(t),a=-1;for(;++a<i.length;)gk(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function wA(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([TA(e[0]),EA(e[1])])}return t}function TA(e){return typeof e==`string`?new RegExp(SA(e),`g`):e}function EA(e){return typeof e==`function`?e:function(){return e}}var DA=`phrasing`,OA=[`autolink`,`link`,`image`,`label`];function kA(){return{transforms:[LA],enter:{literalAutolink:jA,literalAutolinkEmail:MA,literalAutolinkHttp:MA,literalAutolinkWww:MA},exit:{literalAutolink:IA,literalAutolinkEmail:FA,literalAutolinkHttp:NA,literalAutolinkWww:PA}}}function AA(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:DA,notInConstruct:OA},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:DA,notInConstruct:OA},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:DA,notInConstruct:OA}]}}function jA(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function MA(e){this.config.enter.autolinkProtocol.call(this,e)}function NA(e){this.config.exit.autolinkProtocol.call(this,e)}function PA(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function FA(e){this.config.exit.autolinkEmail.call(this,e)}function IA(e){this.exit(e)}function LA(e){CA(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,RA],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,zA]],{ignore:[`link`,`linkReference`]})}function RA(e,t,n,r,i){let a=``;if(!HA(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!BA(n)))return!1;let o=VA(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function zA(e,t,n,r){return!HA(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function BA(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function VA(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=xA(e,`(`),a=xA(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function HA(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||RT(n)||LT(n))&&(!t||n!==47)}QA.peek=ZA;function UA(){this.buffer()}function WA(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function GA(){this.buffer()}function KA(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function qA(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=DT(this.sliceSerialize(e)).toLowerCase(),n.label=t}function JA(e){this.exit(e)}function YA(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=DT(this.sliceSerialize(e)).toLowerCase(),n.label=t}function XA(e){this.exit(e)}function ZA(){return`[`}function QA(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function $A(){return{enter:{gfmFootnoteCallString:UA,gfmFootnoteCall:WA,gfmFootnoteDefinitionLabelString:GA,gfmFootnoteDefinition:KA},exit:{gfmFootnoteCallString:qA,gfmFootnoteCall:JA,gfmFootnoteDefinitionLabelString:YA,gfmFootnoteDefinition:XA}}}function ej(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:QA},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
203
|
-
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?nj:tj))),s(),o}}function tj(e,t,n){return t===0?e:nj(e,t,n)}function nj(e,t,n){return(n?``:` `)+e}var rj=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];cj.peek=lj;function ij(){return{canContainEols:[`delete`],enter:{strikethrough:oj},exit:{strikethrough:sj}}}function aj(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:rj}],handlers:{delete:cj}}}function oj(e){this.enter({type:`delete`,children:[]},e)}function sj(e){this.exit(e)}function cj(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function lj(){return`~`}function uj(e){return e.length}function dj(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||uj,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=fj(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=pj(r[d]);else{let e=pj(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
204
|
-
`)}function fj(e){return e==null?``:String(e)}function pj(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function mj(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),hj);return i(),o}function hj(e,t,n){return`>`+(n?``:` `)+e}function gj(e,t){return _j(e,t.inConstruct,!0)&&!_j(e,t.notInConstruct,!1)}function _j(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function vj(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
205
|
-
`&&gj(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
|
|
206
|
-
`}function yj(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function bj(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function xj(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function Sj(e,t,n,r){let i=xj(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(bj(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,Cj);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(yj(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
|
|
207
|
-
`,encode:["`"],...s.current()})),t()}return u+=s.move(`
|
|
208
|
-
`),a&&(u+=s.move(a+`
|
|
209
|
-
`)),u+=s.move(c),l(),u}function Cj(e,t,n){return(n?``:` `)+e}function wj(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Tj(e,t,n,r){let i=wj(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
|
|
210
|
-
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function Ej(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Dj(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function Oj(e,t,n){let r=JT(e),i=JT(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}kj.peek=Aj;function kj(e,t,n,r){let i=Ej(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=Oj(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Dj(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Oj(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Dj(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Aj(e,t,n){return n.options.emphasis||`*`}function jj(e,t){let n=!1;return vk(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&mT(e)&&(t.options.setext||n))}function Mj(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(jj(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
211
|
-
`,after:`
|
|
212
|
-
`});return r(),t(),o+`
|
|
213
|
-
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
214
|
-
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
215
|
-
`,...a.current()});return/^[\t ]/.test(l)&&(l=Dj(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Nj.peek=Pj;function Nj(e){return e.value||``}function Pj(){return`<`}Fj.peek=Ij;function Fj(e,t,n,r){let i=wj(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function Ij(){return`!`}Lj.peek=Rj;function Lj(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Rj(){return`!`}zj.peek=Bj;function zj(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Bj(){return"`"}function Vj(e,t){let n=mT(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Hj.peek=Uj;function Hj(e,t,n,r){let i=wj(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(Vj(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Uj(e,t,n){return Vj(e,n)?`<`:`[`}Wj.peek=Gj;function Wj(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Gj(){return`[`}function Kj(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function qj(e){let t=Kj(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Jj(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Yj(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Xj(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Jj(n):Kj(n),s=e.ordered?o===`.`?`)`:`.`:qj(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Yj(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function Zj(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Qj(e,t,n,r){let i=Zj(n),a=n.bulletCurrent||Kj(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function $j(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var eM=sk([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function tM(e,t,n,r){return(e.children.some(function(e){return eM(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function nM(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}rM.peek=iM;function rM(e,t,n,r){let i=nM(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=Oj(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Dj(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Oj(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Dj(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function iM(e,t,n){return n.options.strong||`*`}function aM(e,t,n,r){return n.safe(e.value,r)}function oM(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function sM(e,t,n){let r=(Yj(n)+(n.options.ruleSpaces?` `:``)).repeat(oM(n));return n.options.ruleSpaces?r.slice(0,-1):r}var cM={blockquote:mj,break:vj,code:Sj,definition:Tj,emphasis:kj,hardBreak:vj,heading:Mj,html:Nj,image:Fj,imageReference:Lj,inlineCode:zj,link:Hj,linkReference:Wj,list:Xj,listItem:Qj,paragraph:$j,root:tM,strong:rM,text:aM,thematicBreak:sM};function lM(){return{enter:{table:uM,tableData:mM,tableHeader:mM,tableRow:fM},exit:{codeText:hM,table:dM,tableData:pM,tableHeader:pM,tableRow:pM}}}function uM(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function dM(e){this.exit(e),this.data.inTable=void 0}function fM(e){this.enter({type:`tableRow`,children:[]},e)}function pM(e){this.exit(e)}function mM(e){this.enter({type:`tableCell`,children:[]},e)}function hM(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,gM));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function gM(e,t){return t===`|`?t:e}function _M(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
216
|
-
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
217
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return dj(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=cM.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function vM(){return{exit:{taskListCheckValueChecked:bM,taskListCheckValueUnchecked:bM,paragraph:xM}}}function yM(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:SM}}}function bM(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function xM(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function SM(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=cM.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function CM(){return[kA(),$A(),ij(),lM(),vM()]}function wM(e){return{extensions:[AA(),ej(e),aj(),_M(e),yM()]}}var TM={tokenize:zM,partial:!0},EM={tokenize:BM,partial:!0},DM={tokenize:VM,partial:!0},OM={tokenize:HM,partial:!0},kM={tokenize:UM,partial:!0},AM={name:`wwwAutolink`,tokenize:LM,previous:WM},jM={name:`protocolAutolink`,tokenize:RM,previous:GM},MM={name:`emailAutolink`,tokenize:IM,previous:KM},NM={};function PM(){return{text:NM}}for(var FM=48;FM<123;)NM[FM]=MM,FM++,FM===58?FM=65:FM===91&&(FM=97);NM[43]=MM,NM[45]=MM,NM[46]=MM,NM[95]=MM,NM[72]=[MM,jM],NM[104]=[MM,jM],NM[87]=[MM,AM],NM[119]=[MM,AM];function IM(e,t,n){let r=this,i,a;return o;function o(t){return!qM(t)||!KM.call(r,r.previous)||JM(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return qM(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(kM,u,l)(t):t===45||t===95||kT(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&OT(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function LM(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!WM.call(r,r.previous)||JM(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(TM,e.attempt(EM,e.attempt(DM,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function RM(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&GM.call(r,r.previous)&&!JM(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(OT(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||jT(t)||FT(t)||RT(t)||LT(t)?n(t):e.attempt(EM,e.attempt(DM,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function zM(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function BM(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(OM,c,s)(t):t===null||FT(t)||RT(t)||t!==45&<(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function VM(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(OM,t,a)(o):o===null||FT(o)||RT(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function HM(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||FT(o)||RT(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||FT(e)||RT(e)?t(e):r(e)}function a(e){return OT(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):OT(t)?(e.consume(t),o):n(t)}}function UM(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return kT(e)?n(e):t(e)}}function WM(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||FT(e)}function GM(e){return!OT(e)}function KM(e){return!(e===47||qM(e))}function qM(e){return e===43||e===45||e===46||e===95||kT(e)}function JM(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var YM={tokenize:rN,partial:!0};function XM(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:eN,continuation:{tokenize:tN},exit:nN}},text:{91:{name:`gfmFootnoteCall`,tokenize:$M},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:ZM,resolveTo:QM}}}}function ZM(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=DT(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function QM(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function $M(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||FT(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(DT(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return FT(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function eN(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||FT(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=DT(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return FT(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),VT(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function tN(e,t,n){return e.check(nE,t,e.attempt(YM,t,n))}function nN(e){e.exit(`gfmFootnoteDefinition`)}function rN(e,t,n){let r=this;return VT(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function iN(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&bT(o,o.length,0,YT(s,e.slice(r+1,n),t)),bT(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),bT(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=JT(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=JT(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var aN=class{constructor(){this.map=[]}add(e,t,n){oN(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function oN(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function sN(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function cN(){return{flow:{null:{name:`table`,tokenize:lN,resolveAll:uN}}}}function lN(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):Q(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):IT(t)?VT(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||FT(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,IT(t)?VT(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return IT(t)?VT(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Q(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return IT(t)?VT(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Q(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Q(n)?(e.exit(`tableRow`),t(n)):IT(n)?VT(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||FT(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function uN(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new aN;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(fN(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=dN(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=dN(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=dN(f,t,o,i,n,d)):(o[0]=o[1],d=dN(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&fN(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=sN(t.events,n))}return e}function dN(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},pN(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=pN(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=pN(t.events,n[2]),a=pN(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},pN(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function fN(e,t,n,r,i){let a=[],o=pN(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function pN(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var mN={name:`tasklistCheck`,tokenize:gN};function hN(){return{text:{91:mN}}}function gN(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return FT(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Q(r)?t(r):IT(r)?e.check({tokenize:_N},t,n)(r):n(r)}}function _N(e,t,n){return VT(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function vN(e){return CT([PM(),XM(),iN(e),cN(),hN()])}var yN={};function bN(e){let t=this,n=e||yN,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(vN(n)),a.push(CM()),o.push(wM(n))}function xN(e){let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);return t?{frontmatter:t[1].trim(),markdown:e.slice(t[0].length)}:{frontmatter:``,markdown:e}}function SN({content:e}){let{frontmatter:t,markdown:n}=xN(e);return(0,W.jsxs)(`div`,{className:`markdown-preview-shell`,children:[t&&(0,W.jsxs)(`details`,{className:`markdown-frontmatter`,children:[(0,W.jsx)(`summary`,{children:`文档元数据`}),(0,W.jsx)(Lg,{code:t,language:`yaml`,filename:`frontmatter.yaml`,showLineNumbers:!1,wrap:!0})]}),(0,W.jsx)(`article`,{className:`markdown-preview`,children:(0,W.jsx)(gA,{remarkPlugins:[bN],components:{pre:({children:e})=>(0,W.jsx)(W.Fragment,{children:e}),code:({className:e,children:t,...n})=>{let r=/language-([\w-]+)/.exec(e||``)?.[1];return r?(0,W.jsx)(Lg,{code:String(t).replace(/\n$/,``),language:r,showLineNumbers:!1}):(0,W.jsx)(`code`,{className:e,...n,children:t})},table:({children:e,...t})=>(0,W.jsx)(`div`,{className:`markdown-table-scroll`,children:(0,W.jsx)(`table`,{...t,children:e})}),a:({children:e,...t})=>(0,W.jsx)(`a`,{...t,target:`_blank`,rel:`noreferrer noopener`,children:e})},children:n})})]})}function CN(e){let t=Number(e||0);return t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(1)} KiB`:`${(t/1024/1024).toFixed(1)} MiB`}async function wN(e,t){let n=await e.text().catch(()=>``);try{return JSON.parse(n)?.error?.message||`${t}(${e.status})`}catch{return`${t}(${e.status})`}}function TN(e){return{bash:`bash`,c:`c`,cpp:`cpp`,css:`css`,go:`go`,h:`c`,html:`markup`,java:`java`,js:`javascript`,json:`json`,jsx:`jsx`,md:`markdown`,mjs:`javascript`,py:`python`,rs:`rust`,sh:`bash`,toml:`toml`,ts:`typescript`,tsx:`tsx`,xml:`markup`,yaml:`yaml`,yml:`yaml`}[e.split(`.`).pop()?.toLowerCase()||``]||`text`}function EN(e){let t={name:``,path:``,directory:!0,children:[]};for(let n of e){let e=n.path.split(`/`).filter(Boolean),r=t;e.forEach((t,i)=>{let a=e.slice(0,i+1).join(`/`),o=i<e.length-1,s=r.children.find(e=>e.name===t&&e.directory===o);s||(s={name:t,path:a,directory:o,file:o?void 0:n,children:[]},r.children.push(s)),r=s})}let n=e=>{e.sort((e,t)=>Number(t.directory)-Number(e.directory)||e.name.localeCompare(t.name)),e.forEach(e=>n(e.children))};return n(t.children),t.children}function DN({files:e,selected:t,onSelect:n}){let r=(0,s.useMemo)(()=>EN(e),[e]),[i,a]=(0,s.useState)(new Set),o=(e,r=0)=>e.map(e=>{let s={"--skill-depth":r};if(e.directory){let t=i.has(e.path);return(0,W.jsxs)(`div`,{role:`none`,children:[(0,W.jsxs)(`button`,{className:`skill-tree-row directory`,type:`button`,role:`treeitem`,style:s,"aria-expanded":!t,onClick:()=>a(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),children:[t?(0,W.jsx)(P,{size:13}):(0,W.jsx)(M,{size:13}),(0,W.jsx)(le,{size:14}),(0,W.jsx)(`span`,{title:e.name,children:e.name})]}),!t&&(0,W.jsx)(`div`,{role:`group`,children:o(e.children,r+1)})]},`dir:${e.path}`)}let c=e.file?.kind===`script`?oe:se;return(0,W.jsxs)(`button`,{className:`skill-tree-row file${t===e.path?` active`:``}`,type:`button`,role:`treeitem`,"aria-selected":t===e.path,style:s,onClick:()=>n(e.path),children:[(0,W.jsx)(`span`,{className:`skill-tree-spacer`}),(0,W.jsx)(c,{size:14}),(0,W.jsx)(`span`,{title:e.path,children:e.name})]},`file:${e.path}`)});return(0,W.jsx)(`div`,{className:`skill-file-tree`,role:`tree`,"aria-label":`Skill 文件树`,children:o(r)})}function ON({title:e,endpoint:t,onClose:n}){let[r,i]=(0,s.useState)([]),[a,o]=(0,s.useState)(``),[c,l]=(0,s.useState)(null),[u,d]=(0,s.useState)(!0),[p,m]=(0,s.useState)(!1),[h,g]=(0,s.useState)(``),[_,v]=(0,s.useState)(``),y=(0,s.useRef)(0);return(0,s.useEffect)(()=>{let e=new AbortController;return d(!0),g(``),i([]),o(``),l(null),f(t,{signal:e.signal}).then(async e=>{if(!e.ok)throw Error(await wN(e,`Skill 文件读取失败`));return e.json()}).then(e=>{let t=e.files||[];i(t),o(t.find(e=>e.path===`SKILL.md`)?.path||t[0]?.path||``)}).catch(e=>{e?.name!==`AbortError`&&g(e.message||`Skill 文件读取失败`)}).finally(()=>{e.signal.aborted||d(!1)}),()=>e.abort()},[t]),(0,s.useEffect)(()=>{if(!a){l(null),m(!1);return}let e=new AbortController,n=++y.current;return l(null),m(!0),v(``),f(`${t}?${new URLSearchParams({path:a})}`,{signal:e.signal}).then(async e=>{if(!e.ok)throw Error(await wN(e,`Skill 文件读取失败`));return e.json()}).then(e=>{y.current===n&&l(e)}).catch(e=>{e?.name!==`AbortError`&&y.current===n&&v(e.message||`Skill 文件读取失败`)}).finally(()=>{!e.signal.aborted&&y.current===n&&m(!1)}),()=>e.abort()},[t,a]),(0,W.jsx)(FC,{title:`${e} · 文件`,subtitle:`${r.length} 个文件;只读预览,不会执行脚本。`,wide:!0,onClose:n,children:(0,W.jsxs)(`div`,{className:`skill-preview-layout`,children:[(0,W.jsxs)(`aside`,{className:`skill-preview-sidebar`,children:[u&&(0,W.jsx)(`div`,{className:`skill-file-state`,children:`正在读取目录…`}),!u&&h&&(0,W.jsx)(IC,{kind:`error`,title:`无法读取 Skill 文件`,message:h}),!u&&!h&&r.length===0&&(0,W.jsx)(`div`,{className:`skill-file-state`,children:`Skill 中没有可预览的文件。`}),!u&&!h&&r.length>0&&(0,W.jsx)(DN,{files:r,selected:a,onSelect:o})]}),(0,W.jsxs)(`section`,{className:`skill-preview-pane`,"aria-live":`polite`,children:[(c||a)&&(0,W.jsxs)(`header`,{className:`skill-preview-header`,children:[(0,W.jsx)(`strong`,{title:c?.path||a,children:c?.path||a}),c&&(0,W.jsxs)(`span`,{children:[c.kind,` · `,CN(c.size||0)]})]}),(0,W.jsxs)(`div`,{className:`skill-preview-content`,children:[p&&(0,W.jsx)(`div`,{className:`skill-file-state`,children:`正在读取文件…`}),!p&&_&&(0,W.jsx)(IC,{kind:`error`,title:`无法预览文件`,message:_}),!p&&!_&&c?.kind===`markdown`&&(0,W.jsx)(SN,{content:c.content||``}),!p&&!_&&[`script`,`text`].includes(c?.kind||``)&&(0,W.jsx)(Lg,{code:c?.content||``,language:TN(c?.path||a),filename:c?.path||a,showLineNumbers:!0}),!p&&!_&&c?.kind===`binary`&&(0,W.jsx)(`div`,{className:`skill-file-state`,children:`二进制文件不提供内容预览。`}),!p&&!_&&!c&&!a&&(0,W.jsx)(`div`,{className:`skill-file-state`,children:`选择一个文件查看内容。`})]}),c?.truncated&&(0,W.jsx)(`div`,{className:`skill-preview-truncated`,children:`文件较大,仅显示前 512 KiB。`})]})]})})}var kN=new Map([[`avif`,`image/avif`],[`bmp`,`image/bmp`],[`css`,`text/css`],[`csv`,`text/csv`],[`doc`,`application/msword`],[`docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`gif`,`image/gif`],[`gz`,`application/gzip`],[`htm`,`text/html`],[`html`,`text/html`],[`ico`,`image/x-icon`],[`jpeg`,`image/jpeg`],[`jpg`,`image/jpeg`],[`js`,`application/javascript`],[`json`,`application/json`],[`md`,`text/markdown`],[`mjs`,`application/javascript`],[`mp3`,`audio/mpeg`],[`mp4`,`video/mp4`],[`ogg`,`audio/ogg`],[`pdf`,`application/pdf`],[`png`,`image/png`],[`ppt`,`application/powerpoint`],[`pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`svg`,`image/svg+xml`],[`tif`,`image/tiff`],[`tiff`,`image/tiff`],[`txt`,`text/plain`],[`wasm`,`application/wasm`],[`wav`,`audio/x-wav`],[`weba`,`audio/webm`],[`webm`,`video/webm`],[`webp`,`image/webp`],[`xls`,`application/vnd.ms-excel`],[`xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`xml`,`application/xml`],[`zip`,`application/zip`]]),AN=class extends Error{constructor(e){super(`DataTransferItem is not a file`),this.item=e,this.name=`UnexpectedObjectError`}};function jN(e,t,n){let r=e,{webkitRelativePath:i}=e,a=typeof t==`string`?t:typeof i==`string`&&i.length>0?i:`./${e.name}`;return typeof r.path!=`string`&&NN(r,`path`,a),n!==void 0&&Object.defineProperty(r,"handle",{value:n,writable:!1,configurable:!1,enumerable:!0}),NN(r,`relativePath`,a),r}function MN(e,t=kN){let{name:n}=e;if(n&&n.lastIndexOf(`.`)!==-1&&!e.type){let r=n.split(`.`).pop().toLowerCase(),i=t.get(r);i&&Object.defineProperty(e,"type",{value:i,writable:!1,configurable:!1,enumerable:!0})}return e}function NN(e,t,n){Object.defineProperty(e,t,{value:n,writable:!1,configurable:!1,enumerable:!0})}var PN=[`.DS_Store`,`Thumbs.db`];async function FN(e,{mimeTypes:t=kN}={}){return(await IN(e)).map(e=>e instanceof File?MN(e,t):e)}async function IN(e){return BN(e)&&LN(e.dataTransfer)?UN(e.dataTransfer,e.type):RN(e)?WN(e.clipboardData):zN(e)?VN(e):Array.isArray(e)&&e.every(e=>`getFile`in e&&typeof e.getFile==`function`)?HN(e):[]}function LN(e){return BN(e)}function RN(e){return BN(e)&&LN(e.clipboardData)}function zN(e){return BN(e)&&BN(e.target)}function BN(e){return typeof e==`object`&&!!e}function VN(e){return KN(e.target.files).map(e=>jN(e))}async function HN(e){return(await Promise.all(e.map(e=>e.getFile()))).map(e=>jN(e))}async function UN(e,t){let n=KN(e.items).filter(e=>e.kind===`file`);return t===`drop`?GN(JN(await Promise.all(n.map(qN)))):n}function WN(e){let t=KN(e.items).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null);return GN((t.length>0?t:KN(e.files)).map(e=>jN(e)))}function GN(e){return e.filter(e=>PN.indexOf(e.name)===-1)}function KN(e){return e===null?[]:Array.from(e)}async function qN(e){if(typeof e.webkitGetAsEntry!=`function`)return YN(e);let t=e.webkitGetAsEntry();if(t?.isDirectory){let n=await XN(e);return n?.kind===`directory`?ZN(n,`/${n.name}`):$N(t)}return YN(e,t)}function JN(e){let t=[];for(let n of e)Array.isArray(n)?t.push(...JN(n)):t.push(n);return t}async function YN(e,t){let n=e.getAsFile(),r=await XN(e);if(r!=null){let e=n??await r.getFile();return e.handle=r,jN(e)}if(!n)throw new AN(e);return jN(n,t?.fullPath??void 0)}async function XN(e){if(globalThis.isSecureContext&&typeof e.getAsFileSystemHandle==`function`)return e.getAsFileSystemHandle()}async function ZN(e,t){let n=[];for await(let r of e.values()){let e=`${t}/${r.name}`;if(r.kind===`directory`)n.push(...await ZN(r,e));else{let t=await r.getFile();n.push(jN(t,e,r))}}return n}async function QN(e){return e.isDirectory?$N(e):eP(e)}function $N(e){let t=e.createReader();return new Promise((e,n)=>{let r=[];function i(){t.readEntries(async t=>{if(t.length){let e=Promise.all(t.map(QN));r.push(e),i()}else try{e(await Promise.all(r))}catch(e){n(e)}},e=>{n(e)})}i()})}async function eP(e){return new Promise((t,n)=>{e.file(n=>{t(jN(n,e.fullPath))},e=>{n(e)})})}var tP=t(n((e=>{e.__esModule=!0,e.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(`,`);if(n.length===0)return!0;var r=e.name||``,i=(e.type||``).toLowerCase(),a=i.replace(/\/.*$/,``);return n.some(function(e){var t=e.trim().toLowerCase();return t.charAt(0)===`.`?r.toLowerCase().endsWith(t):t.endsWith(`/*`)?a===t.replace(/\/.*$/,``):i===t})}return!0}}))(),1),nP=typeof tP.default==`function`?tP.default:tP.default.default,rP=`file-invalid-type`,iP=`file-too-large`,aP=`file-too-small`,oP=`too-many-files`;function sP(e=``){let t=e.split(`,`);return{code:rP,message:`File type must be ${t.length>1?`one of ${t.join(`, `)}`:t[0]}`}}var cP=[`KB`,`MB`,`GB`,`TB`,`PB`];function lP(e){if(e<1024)return`${e} ${e===1?`byte`:`bytes`}`;let t=e/1024,n=0;for(;t>=1024&&n<cP.length-1;)t/=1024,n++;return`${Number(t.toFixed(2))} ${cP[n]}`}function uP(e){return{code:iP,message:`File is larger than ${lP(e)}`}}function dP(e){return{code:aP,message:`File is smaller than ${lP(e)}`}}var fP={code:oP,message:`Too many files`};function pP(e){return e.type===``&&typeof e.getAsFile==`function`}function mP(e,t){let n=e.type===`application/x-moz-file`||nP(e,t??``)||pP(e);return[n,n?null:sP(t)]}function hP(e,t,n){if(gP(e.size)){if(gP(t)&&gP(n)){if(e.size>n)return[!1,uP(n)];if(e.size<t)return[!1,dP(t)]}else if(gP(t)&&e.size<t)return[!1,dP(t)];else if(gP(n)&&e.size>n)return[!1,uP(n)]}return[!0,null]}function gP(e){return e!=null}function _P(e){return e!=null&&typeof e.then==`function`}function vP({files:e,accept:t,minSize:n,maxSize:r,multiple:i,maxFiles:a=0,validator:o,getErrorMessage:s}){let c=[],l=[],u=(e,t)=>s&&typeof File<`u`&&t instanceof File?{...e,message:s(e,t)}:e;e.forEach(e=>{let[i,a]=mP(e,t),[o,s]=hP(e,n,r);i&&o?c.push(e):l.push({file:e,errors:[a,s].filter(e=>e!=null).map(t=>u(t,e))})});let d=i?a>=1?a:1/0:1;return c.length>d&&c.slice(d).forEach(e=>{l.push({file:e,errors:[u(fP,e)]})}),l.length>0?{verdict:`reject`,rejections:l}:{verdict:o?`unknown`:`accept`,rejections:l}}function yP(e){return typeof e.isPropagationStopped==`function`?e.isPropagationStopped():e.cancelBubble!==void 0&&e.cancelBubble}function bP(e){let t=e.dataTransfer??e.clipboardData;return t?Array.prototype.some.call(t.types,e=>e===`Files`||e===`application/x-moz-file`)||Array.prototype.some.call(t.items??[],xP):!!e.target&&!!e.target.files}function xP(e){return typeof e==`object`&&!!e&&e.kind===`file`}function SP(e){e.preventDefault()}function CP(e){return e.indexOf(`MSIE`)!==-1||e.indexOf(`Trident/`)!==-1}function wP(e){return e.indexOf(`Edge/`)!==-1}function TP(e=window.navigator.userAgent){return CP(e)||wP(e)}function EP(...e){return(t,...n)=>e.some(e=>(!yP(t)&&e&&e(t,...n),yP(t)))}function DP(){return`showOpenFilePicker`in window}function OP(e){return Array.isArray(e)?e:typeof e==`string`?[e]:[]}function kP(e){if(gP(e))return Array.isArray(e)?e.filter(e=>gP(e)&&gP(e.accept)):[{accept:e}]}function AP(e){let t=[],n=Object.keys(e);for(let n of Object.values(e))for(let e of OP(n))t.includes(e)||t.push(e);return t.length>0?t.join(`, `):n.length>0?n.join(`, `):`Files`}function jP(e){let t=kP(e);if(!gP(t))return;let n={};for(let e of t)for(let[t,r]of Object.entries(e.accept)){let e=n[t]??(n[t]=[]);for(let t of OP(r))e.includes(t)||e.push(t)}return n}function MP(e){let t=kP(e);if(!gP(t))return;let n=t.map(e=>{let t=Object.entries(e.accept).filter(([e,t])=>{let n=!0;return LP(e)||(console.warn(`Skipped "${e}" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.`),n=!1),(!(Array.isArray(t)||typeof t==`string`)||!OP(t).every(zP))&&(console.warn(`Skipped "${e}" because an invalid file extension was provided.`),n=!1),n}).reduce((e,[t,n])=>(e[t]=OP(n),e),{});return{description:gP(e.description)&&e.description!==``?e.description:AP(t),accept:t}}).filter(e=>Object.keys(e.accept).length>0);return n.length>0?n:void 0}function NP(e,{omitWildcardMimeTypesWithExtensions:t=!1}={}){if(gP(e))return Object.entries(e).reduce((e,[n,r])=>{let i=OP(r);return t&&RP(n)&&i.some(zP)?e.push(...i):e.push(n,...i),e},[]).filter(e=>LP(e)||zP(e)).join(`,`)}function PP(e){return e instanceof DOMException&&(e.name===`AbortError`||e.code===e.ABORT_ERR)}function FP(e){return e instanceof DOMException&&(e.name===`SecurityError`||e.code===e.SECURITY_ERR)}function IP(e){return e instanceof DOMException&&e.name===`NotAllowedError`}function LP(e){return e===`audio/*`||e===`video/*`||e===`image/*`||e===`text/*`||e===`application/*`||/\w+\/[-+.\w]+/g.test(e)}function RP(e){return e.endsWith(`/*`)}function zP(e){return/^.*\.[\w]+$/.test(e)}var BP=(0,s.forwardRef)(({children:e,...t},n)=>{let{open:r,...i}=HP(t);return(0,s.useImperativeHandle)(n,()=>({open:r}),[r]),(0,W.jsx)(W.Fragment,{children:e?.({...i,open:r})})});BP.displayName=`Dropzone`;var VP={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragUnknown:!1,isDragGlobal:!1,isProcessing:!1,acceptedFiles:[],fileRejections:[],dragFileRejections:[]};function HP(e={}){let{accept:t,disabled:n=!1,getFilesFromEvent:r=FN,maxSize:i=1/0,minSize:a=0,multiple:o=!0,maxFiles:c=0,onDragEnter:l,onDragLeave:u,onDragOver:d,onDrop:f,onDropAccepted:p,onDropRejected:m,onFileDialogCancel:h,onFileDialogOpen:g,useFsAccessApi:_=!1,autoFocus:v=!1,preventDropOnDocument:y=!0,noClick:b=!1,noKeyboard:x=!1,noDrag:S=!1,noDragEventsBubbling:C=!1,noPaste:w=!1,onError:T,validator:E,getErrorMessage:D}=e,O=(0,s.useMemo)(()=>jP(t),[t]),k=(0,s.useMemo)(()=>NP(O),[O]),A=(0,s.useMemo)(()=>NP(O,{omitWildcardMimeTypesWithExtensions:!0}),[O]),j=(0,s.useMemo)(()=>MP(t),[t]),M=(0,s.useMemo)(()=>typeof g==`function`?g:WP,[g]),N=(0,s.useMemo)(()=>typeof h==`function`?h:WP,[h]),P=(0,s.useRef)(null),F=(0,s.useRef)(null),[I,L]=(0,s.useReducer)(UP,VP),{isFocused:R,isFileDialogActive:z}=I,B=(0,s.useRef)(z);B.current=z;let V=(0,s.useRef)(null),H=(0,s.useCallback)(()=>{V.current?.abort();let e=new AbortController;return V.current=e,L({type:`setProcessing`,isProcessing:!0}),e.signal},[]),U=(0,s.useCallback)(e=>{e.aborted||L({type:`setProcessing`,isProcessing:!1})},[]),ee=(0,s.useRef)(typeof window<`u`&&window.isSecureContext&&_&&DP()),te=()=>{!ee.current&&z&&setTimeout(()=>{if(F.current){let{files:e}=F.current;e?.length||(L({type:`closeDialog`}),N())}},300)};(0,s.useEffect)(()=>(window.addEventListener(`focus`,te,!1),()=>{window.removeEventListener(`focus`,te,!1)}),[F,z,N,ee]);let ne=(0,s.useRef)([]),re=(0,s.useRef)([]),ie=e=>{P.current&&e.target&&P.current.contains(e.target)&&e.defaultPrevented||(e.preventDefault(),ne.current=[])};(0,s.useEffect)(()=>(y&&(document.addEventListener(`dragover`,SP,!1),document.addEventListener(`drop`,ie,!1)),()=>{y&&(document.removeEventListener(`dragover`,SP),document.removeEventListener(`drop`,ie))}),[P,y]),(0,s.useEffect)(()=>{let e=e=>{e.target&&(re.current=[...re.current,e.target]),bP(e)&&L({isDragGlobal:!0,type:`setDragGlobal`})},t=e=>{re.current=re.current.filter(t=>t!==e.target&&t!==null),!(re.current.length>0)&&L({isDragGlobal:!1,type:`setDragGlobal`})},n=()=>{re.current=[],L({isDragGlobal:!1,type:`setDragGlobal`})},r=()=>{re.current=[],L({isDragGlobal:!1,type:`setDragGlobal`})};return document.addEventListener(`dragenter`,e,!1),document.addEventListener(`dragleave`,t,!1),document.addEventListener(`dragend`,n,!1),document.addEventListener(`drop`,r,!1),()=>{document.removeEventListener(`dragenter`,e),document.removeEventListener(`dragleave`,t),document.removeEventListener(`dragend`,n),document.removeEventListener(`drop`,r)}},[P]),(0,s.useEffect)(()=>(!n&&v&&P.current&&P.current.focus(),()=>{}),[P,v,n]);let ae=(0,s.useCallback)(e=>{T?T(e):console.error(e)},[T]),oe=(0,s.useCallback)(e=>{e.preventDefault(),e.persist?.(),xe(e),!B.current&&(ne.current=[...ne.current,e.target],bP(e)&&Promise.resolve(r(e)).then(t=>{if(yP(e)&&!C)return;let n=t.length>0?vP({files:t,accept:k,minSize:a,maxSize:i,multiple:o,maxFiles:c,validator:E,getErrorMessage:D}):null;L({isDragAccept:n?.verdict===`accept`,isDragReject:n?.verdict===`reject`,isDragUnknown:n?.verdict===`unknown`,isDragActive:!0,dragFileRejections:n?.rejections??[],type:`setDraggedFiles`}),l&&l(e)}).catch(e=>ae(e)))},[r,l,ae,C,k,a,i,o,c,E,D]),se=(0,s.useCallback)(e=>{if(e.preventDefault(),e.persist?.(),xe(e),B.current)return!1;let t=bP(e);if(t&&e.dataTransfer)try{e.dataTransfer.dropEffect=`copy`}catch{}return t&&d&&d(e),!1},[d,C]),ce=(0,s.useCallback)(e=>{e.preventDefault(),e.persist?.(),xe(e);let t=ne.current.filter(e=>P.current?.contains(e)),n=t.indexOf(e.target);n!==-1&&t.splice(n,1),ne.current=t,!(t.length>0)&&(L({type:`setDraggedFiles`,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragUnknown:!1,dragFileRejections:[]}),bP(e)&&u&&u(e))},[P,u,C]),le=(0,s.useCallback)(async(e,t,n)=>{let r=(e,t)=>D?{...e,message:D(e,t)}:e,s=e=>{let n=[],i=[];e.forEach(({file:e,accepted:t,acceptError:a,sizeMatch:o,sizeError:s,customErrors:c})=>{if(t&&o&&!c)n.push(e);else{let t=[a,s];c&&(t=t.concat(c)),i.push({file:e,errors:t.filter(e=>e!=null).map(t=>r(t,e))})}});let a=o?c>=1?c:1/0:1;n.length>a&&n.splice(a).forEach(e=>{i.push({file:e,errors:[r(fP,e)]})}),L({acceptedFiles:n,fileRejections:i,type:`setFiles`}),f&&f(n,i,t),i.length>0&&m&&m(i,t),n.length>0&&p&&p(n,t)},l=e.map(e=>{let[t,n]=mP(e,A),[r,o]=hP(e,a,i);return{file:e,accepted:t,acceptError:n,sizeMatch:r,sizeError:o,customErrors:E?E(e):null}});if(!l.some(({customErrors:e})=>_P(e))){s(l);return}let u;try{u=await Promise.all(l.map(async({customErrors:e,...t})=>({...t,customErrors:await e})))}catch(e){n.aborted||(U(n),ae(e));return}n.aborted||s(u)},[L,o,A,a,i,c,f,p,m,E,D,ae,U]),ue=(0,s.useCallback)(e=>{if(e.preventDefault(),e.persist?.(),xe(e),ne.current=[],!(B.current&&e.dataTransfer)&&(L({type:`reset`}),bP(e))){let t=H();Promise.resolve(r(e)).then(n=>{if(!t.aborted){if(yP(e)&&!C){U(t);return}return le(n,e,t)}}).catch(e=>{t.aborted||(U(t),ae(e))})}},[r,le,ae,C,H,U]),de=(0,s.useCallback)(e=>{if(!bP(e))return;e.preventDefault(),e.persist?.(),xe(e);let t=H();Promise.resolve(r(e)).then(n=>{if(!t.aborted){if(yP(e)&&!C){U(t);return}return le(n,e,t)}}).catch(e=>{t.aborted||(U(t),ae(e))})},[r,le,ae,C,H,U]),fe=(0,s.useCallback)(()=>{if(ee.current){L({type:`openDialog`}),M();let e={multiple:o,types:j},t;window.showOpenFilePicker(e).then(e=>(t=H(),r(e))).then(e=>{if(L({type:`closeDialog`}),!t.aborted)return le(e,null,t)}).catch(e=>{t&&U(t),PP(e)?(N(e),L({type:`closeDialog`})):FP(e)||IP(e)?(ee.current=!1,F.current?(F.current.value=``,F.current.click()):ae(Error(`Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided.`))):ae(e)});return}F.current&&(L({type:`openDialog`}),M(),F.current.value=``,F.current.click())},[L,M,N,_,le,ae,j,o,H,U]),pe=(0,s.useCallback)(e=>{P.current?.isEqualNode(e.target)&&(e.key===` `||e.key===`Enter`||e.keyCode===32||e.keyCode===13)&&(e.preventDefault(),fe())},[P,fe]),me=(0,s.useCallback)(()=>{L({type:`focus`})},[]),he=(0,s.useCallback)(()=>{L({type:`blur`})},[]),ge=(0,s.useCallback)(()=>{b||(TP()?setTimeout(fe,0):fe())},[b,fe]),_e=e=>n?null:e,ve=e=>x?null:_e(e),ye=e=>S?null:_e(e),be=e=>w?null:_e(e),xe=e=>{C&&e.stopPropagation()},Se=(0,s.useMemo)(()=>({refKey:e=`ref`,role:t,onKeyDown:r,onFocus:i,onBlur:a,onClick:o,onDragEnter:s,onDragOver:c,onDragLeave:l,onDrop:u,onPaste:d,...f}={})=>({onKeyDown:ve(EP(r,pe)),onFocus:ve(EP(i,me)),onBlur:ve(EP(a,he)),onClick:_e(EP(o,ge)),onDragEnter:ye(EP(s,oe)),onDragOver:ye(EP(c,se)),onDragLeave:ye(EP(l,ce)),onDrop:ye(EP(u,ue)),onPaste:be(EP(d,de)),role:typeof t==`string`&&t!==``?t:`presentation`,[e]:P,...!n&&!x?{tabIndex:0}:{},...n?{"aria-disabled":!0}:{},...f}),[P,pe,me,he,ge,oe,se,ce,ue,de,x,S,w,n]),Ce=(0,s.useCallback)(e=>{e.stopPropagation()},[]),we=(0,s.useMemo)(()=>({refKey:e=`ref`,onChange:t,onClick:n,...r}={})=>({accept:A,multiple:o,type:`file`,"aria-label":`file upload`,style:{border:0,display:`block`,height:0,margin:0,opacity:0,overflow:`hidden`,padding:0,width:0},onChange:_e(EP(t,ue)),onClick:_e(EP(n,Ce)),tabIndex:-1,[e]:F,...r}),[F,t,o,ue,n]);return{...I,isFocused:R&&!n,getRootProps:Se,getInputProps:we,rootRef:P,inputRef:F,open:_e(fe)}}function UP(e,t){switch(t.type){case`focus`:return{...e,isFocused:!0};case`blur`:return{...e,isFocused:!1};case`openDialog`:return{...VP,isFileDialogActive:!0};case`closeDialog`:return{...e,isFileDialogActive:!1};case`setDraggedFiles`:return{...e,isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject,isDragUnknown:t.isDragUnknown,dragFileRejections:t.dragFileRejections};case`setProcessing`:return{...e,isProcessing:t.isProcessing};case`setFiles`:return{...e,acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,dragFileRejections:[],isProcessing:!1,isDragReject:!1,isDragUnknown:!1};case`setDragGlobal`:return{...e,isDragGlobal:t.isDragGlobal};case`reset`:return{...VP};default:return e}}function WP(){}function GP(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(+(e<10240))} KiB`:`${(e/1048576).toFixed(1)} MiB`}function KP(e){let t=e.errors[0]?.code;return t===`file-invalid-type`?`文件类型不受支持,请重新选择。`:t===`file-too-large`?`文件超过允许大小,请重新选择。`:t===`too-many-files`?`一次只能选择一个文件。`:e.errors[0]?.message||`文件无法读取,请重新选择。`}function qP({accept:e,maxSize:t,file:n,onFile:r,onError:i,ariaLabel:a=`选择文件`,hint:o=`拖放文件到这里,或点击选择`}){let{getRootProps:s,getInputProps:c,isDragActive:l,isDragReject:u,open:d}=HP({accept:e,maxSize:t,multiple:!1,noClick:!!n,onDropAccepted:e=>{i(``),r(e[0]||null)},onDropRejected:e=>{r(null),i(KP(e[0]))}});return(0,W.jsxs)(`div`,{...s({className:`studio-file-dropzone${l?` dragging`:``}${u?` rejected`:``}${n?` has-file`:``}`}),children:[(0,W.jsx)(`input`,{...c({"aria-label":a})}),n?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`studio-file-icon`,children:(0,W.jsx)(oe,{size:20})}),(0,W.jsxs)(`span`,{className:`studio-file-copy`,children:[(0,W.jsx)(`strong`,{title:n.name,children:n.name}),(0,W.jsxs)(`small`,{children:[GP(n.size),` · 已准备检查`]})]}),(0,W.jsxs)(`span`,{className:`studio-file-actions`,children:[(0,W.jsx)(`button`,{className:`icon-button tertiary`,type:`button`,"aria-label":`替换 ${n.name}`,title:`替换文件`,onClick:e=>{e.stopPropagation(),d()},children:(0,W.jsx)(Fe,{size:14})}),(0,W.jsx)(`button`,{className:`icon-button tertiary`,type:`button`,"aria-label":`移除 ${n.name}`,title:`移除文件`,onClick:e=>{e.stopPropagation(),r(null)},children:(0,W.jsx)($e,{size:15})})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`studio-file-icon`,children:(0,W.jsx)(ce,{size:20})}),(0,W.jsxs)(`span`,{className:`studio-file-copy`,children:[(0,W.jsx)(`strong`,{children:l?`松开即可选择`:o}),(0,W.jsx)(`small`,{children:`文件只会先做只读检查,确认后才写入 Catalog。`})]})]})]})}var JP=`def query_order(
|
|
218
|
-
order_id: str,
|
|
219
|
-
include_history: bool = False,
|
|
220
|
-
) -> dict[str, object]:
|
|
221
|
-
"""查询订单状态,并按需返回流转记录。"""
|
|
222
|
-
result: dict[str, object] = {
|
|
223
|
-
"order_id": order_id,
|
|
224
|
-
"status": "processing",
|
|
225
|
-
}
|
|
226
|
-
if include_history:
|
|
227
|
-
result["history"] = ["created", "paid"]
|
|
228
|
-
return result
|
|
229
|
-
`;function YP(){let[e,t]=(0,s.useState)(!1),n=(0,s.useId)();return(0,W.jsxs)(`section`,{className:`python-tool-example`,"aria-label":`Python Tool 编写帮助`,children:[(0,W.jsxs)(`button`,{className:`python-tool-example-trigger`,type:`button`,"aria-label":e?`收起编写示例`:`查看编写示例`,"aria-expanded":e,"aria-controls":n,onClick:()=>t(e=>!e),children:[(0,W.jsx)(D,{size:17,"aria-hidden":`true`}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:`Python Tool 怎么写?`}),(0,W.jsx)(`small`,{children:`查看可复制的函数样例与约定`})]}),(0,W.jsx)(M,{className:`python-tool-example-chevron`,size:17,"aria-hidden":`true`})]}),e&&(0,W.jsxs)(`div`,{id:n,className:`python-tool-example-panel`,role:`region`,"aria-label":`Python Tool 编写示例`,children:[(0,W.jsx)(Lg,{code:JP,language:`python`,filename:`tool_example.py`,wrap:!0,showLineNumbers:!0}),(0,W.jsxs)(`ul`,{className:`python-tool-example-rules`,children:[(0,W.jsx)(`li`,{children:`公开函数需定义在模块顶层,同步与异步函数均可。`}),(0,W.jsx)(`li`,{children:`建议提供类型注解和 docstring,方便生成清晰的 Tool Contract。`}),(0,W.jsx)(`li`,{children:`返回值应可 JSON 序列化;模块导入阶段不要执行有副作用的逻辑。`})]})]})]})}var XP=oS().trim().min(1,`请填写显示名称`).max(128,`显示名称不能超过 128 个字符`),ZP=oS().trim().min(2,`资源标识至少填写 2 个字符`).max(128,`资源标识不能超过 128 个字符`).regex(/^[a-z][a-z0-9._-]*$/,`资源标识只能包含小写字母、数字、点、下划线和连字符`),QP=oS().trim().min(1,`请填写 Python 标识`).max(128,`Python 标识不能超过 128 个字符`).regex(/^[A-Za-z_][A-Za-z0-9_]*$/,`请输入有效的 Python 标识`),$P=oS().trim().url(`请输入有效的接口地址`).max(1024,`接口地址不能超过 1024 个字符`),eF=oS().trim().max(512,`凭证引用不能超过 512 个字符`).regex(/^env:\/\/[A-Za-z_][A-Za-z0-9_]*$/,`凭证引用需使用 env://环境变量名`),tF=oS().trim().max(4096,`描述不能超过 4096 个字符`).default(``),nF=BS({name:ZP,displayName:XP,model:oS().trim().min(1,`请填写模型 ID`).max(256,`模型 ID 不能超过 256 个字符`),endpointUrl:$P,credentialRef:eF,description:tF.optional(),apiKey:oS().max(16384,`API Key 不能超过 16384 个字符`).default(``),temperature:vC().min(0,`temperature 需在 0-2 之间`).max(2,`temperature 需在 0-2 之间`).default(.2),maxTokens:vC().int(`max_tokens 需为 1-131072 的整数`).min(1,`max_tokens 需为 1-131072 的整数`).max(131072,`max_tokens 需为 1-131072 的整数`).default(2048),addressMode:KS([`endpoint`,`base`]).default(`endpoint`),wireApi:KS([``,`chat`,`responses`]).default(``)}),rF=BS({displayName:XP,name:ZP,transport:KS([`stdio`,`sse`,`http`,`streamable-http`]),endpointUrl:oS().trim().max(1024,`Server URL 不能超过 1024 个字符`).default(``),command:oS().trim().max(4096,`Command 不能超过 4096 个字符`).default(``),args:oS().trim().max(8192,`Arguments 不能超过 8192 个字符`).default(``),apiKeyName:HS([JS(``),oS().trim().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,`环境变量名需为合法标识符`)]).default(``),apiKeyValue:oS().max(16384,`API Key 不能超过 16384 个字符`).default(``),description:tF}).superRefine((e,t)=>{if(e.transport===`stdio`){e.command||t.addIssue({code:`custom`,path:[`command`],message:`请填写 Command`});return}if(!e.endpointUrl){t.addIssue({code:`custom`,path:[`endpointUrl`],message:`请填写 Server URL`});return}fS().safeParse(e.endpointUrl).success||t.addIssue({code:`custom`,path:[`endpointUrl`],message:`请输入有效的 Server URL`})}),iF=BS({displayName:XP,name:QP,callableName:QP,description:oS().trim().max(1024,`描述不能超过 1024 个字符`).default(``),sourceMode:KS([`upload`,`workspace`]).default(`upload`),sourcePath:oS().trim().max(4096,`工作区路径不能超过 4096 个字符`).default(``)}).superRefine((e,t)=>{e.sourceMode===`workspace`&&!e.sourcePath&&t.addIssue({code:`custom`,path:[`sourcePath`],message:`请填写工作区 Python 文件`})}),aF=BS({value:oS().max(16384,`API Key 不能超过 16384 个字符`)}),oF=BS({sandbox:KS([`read-only`,`read_only`,`workspace-write`,`workspace-write-auto`,`full-access`]),buildAfterCreate:MS(),codexProxy:KS([`auto`,`forced`,`direct`]),cloudAccessKey:oS().max(1024,`Access Key 不能超过 1024 个字符`).default(``),cloudSecretKey:oS().max(4096,`Secret Key 不能超过 4096 个字符`).default(``),cloudRegion:oS().trim().max(128,`Region 不能超过 128 个字符`).default(``)});function sF(e){return e.status===`ready`||e.status===`conflict`}function cF(e){return new Set(e.filter(sF).map(e=>e.candidateId))}async function lF({candidates:e,selectedIds:t,overwriteIds:n,commit:r,onResult:i}){let a=e.filter(e=>t.has(e.candidateId)&&sF(e)),o=[];for(let e of a){let t;try{let i=await r(e,n.has(e.candidateId));t={candidateId:e.candidateId,status:`succeeded`,value:i}}catch(n){t={candidateId:e.candidateId,status:`failed`,error:n instanceof Error?n.message:String(n)}}o.push(t),i?.(t,o.length,a.length)}return{results:o,succeededIds:o.filter(e=>e.status===`succeeded`).map(e=>e.candidateId),failedIds:o.filter(e=>e.status===`failed`).map(e=>e.candidateId)}}var uF={model:{title:`模型`,description:`管理 Model Profile、Endpoint 和凭据引用。`,addLabel:`配置模型`,headings:[`发现来源`,`上下文窗口`,`输入模态`],icon:re},tool:{title:`Tool`,description:`管理结构化 Tool Contract、权限和审批策略。`,addLabel:`添加 Python Tool`,headings:[`来源`,`Tool 分组`,`权限 / 边界`],icon:Qe},mcp:{title:`MCP`,description:`连接、探测并复用 MCP Server。`,addLabel:`添加资源`,headings:[`来源`,`版本`,`说明`],icon:Te},skill:{title:`Skill`,description:`安装版本化 Skill,并在构建时锁定内容摘要。`,addLabel:`发现 Skill`,headings:[`来源`,`版本`,`说明`],icon:He}},dF={provider:`模型服务 /v1/models`,builtin:`ksadk 内置`,local:`工作区自定义`,market:`市场`},fF=40;async function pF(e,t){let n=await e.text().catch(()=>``);try{return JSON.parse(n)?.error?.message||`${t}(${e.status})`}catch{return`${t}(${e.status})`}}function mF(e){return e.requiredSecretRefs?.[0]||e.contract?.credentialRef||``}function hF(e){return e.replace(/^env:\/\//,``)}function gF(e){let t=Number(e||0);return t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(1)} KiB`:`${(t/1024/1024).toFixed(1)} MiB`}function _F({kind:e,onKindChange:t,refreshTick:n}){let[r,i]=(0,s.useState)([]),[a,o]=(0,s.useState)(``),[c,l]=(0,s.useState)(``),[u,d]=(0,s.useState)(0),[p,m]=(0,s.useState)([null]),[h,g]=(0,s.useState)(null),[_,v]=(0,s.useState)(0),[y,b]=(0,s.useState)(!0),[x,S]=(0,s.useState)(``),[C,w]=(0,s.useState)(null),[T,E]=(0,s.useState)(!1),[D,O]=(0,s.useState)(!1),[k,A]=(0,s.useState)(null),[j,M]=(0,s.useState)(null),[N,P]=(0,s.useState)(!1),[F,I]=(0,s.useState)(!1),[L,R]=(0,s.useState)(null),[z,B]=(0,s.useState)(!1),V=(0,s.useRef)(0),H=(0,s.useCallback)(async t=>{let n=++V.current,r=new URLSearchParams({kind:e,limit:String(fF),sort:`default`});a.trim()&&r.set(`query`,a.trim()),c&&r.set(`status`,c),t&&r.set(`cursor`,t),b(!0),S(``);try{let e=await f(`/api/v1/catalog/resources?${r}`);if(!e.ok)throw Error(await pF(e,`资源加载失败`));let t=await e.json();if(V.current!==n)return;i(t.items||[]),g(t.nextCursor||null),v(Number(t.total)||0)}catch(e){if(V.current!==n)return;i([]),g(null),v(0),S(e instanceof Error?e.message:`资源加载失败`)}finally{V.current===n&&b(!1)}},[e,a,c]),U=(0,s.useCallback)(()=>{m([null]),d(0),H(null)},[H]),ee=(0,s.useCallback)(()=>{H(p[u]||null)},[p,H,u]);(0,s.useEffect)(()=>{U()},[n,U]);let te=(0,s.useCallback)(async e=>{try{let t=await f(`/api/v1/catalog/mcp-servers/${encodeURIComponent(e.resourceId)}:probe?timeoutSeconds=15`,{method:`POST`});if(!t.ok)throw Error(await pF(t,`MCP 探测失败`));let n=await t.json();ee(),Cm(`MCP 探测完成`,`已发现 ${n.health?.toolCount||0} 个 Tool。`)}catch(e){ee(),Cm(`MCP 探测失败`,e.message,`error`)}},[ee]);async function ne(){if(L){B(!0);try{let e=await f(`/api/v1/catalog/resources/${encodeURIComponent(L.resourceId)}`,{method:`DELETE`});if(!e.ok)throw Error(await pF(e,`删除失败`));if(R(null),r.length===1&&u>0){let e=u-1;d(e),await H(p[e]||null)}else await H(p[u]||null);Cm(`资源已删除`,`${L.displayName||L.name} 已从工作区移除。`)}catch(e){Cm(`删除失败`,e.message,`error`)}B(!1)}}function re(){if(e===`model`){E(!0);return}if(e===`mcp`){O(!0);return}if(e===`skill`){P(!0);return}I(!0)}let ae=uF[e],oe=(0,s.useMemo)(()=>[{id:`name`,header:`名称`,minWidth:250,cell:e=>(0,W.jsx)(vF,{item:e})},{id:`source`,header:ae.headings[0],minWidth:170,cell:e=>dF[e.source]||e.source},{id:`detail`,header:ae.headings[1],minWidth:150,cell:e=>(0,W.jsx)(yF,{item:e})},{id:`capability`,header:ae.headings[2],minWidth:240,className:`capability-cell`,cell:e=>(0,W.jsx)(bF,{item:e})},{id:`status`,header:`状态`,minWidth:135,cell:e=>(0,W.jsx)(xF,{item:e})},{id:`actions`,header:`操作`,minWidth:290,className:`actions-column`,headerClassName:`actions-column`,cell:e=>(0,W.jsx)(SF,{item:e,onConfigure:()=>w(e),onView:()=>e.kind===`mcp`?A(e):M(e),onProbe:()=>te(e),onDelete:()=>R(e)})}],[ae.headings,te]),se=(0,s.useCallback)(()=>{if(u<=0)return;let e=u-1;d(e),H(p[e]||null)},[p,H,u]),ce=(0,s.useCallback)(()=>{if(!h)return;let e=u+1;m(t=>{let n=t.slice(0,e);return n[e]=h,n}),d(e),H(h)},[H,h,u]);return(0,W.jsxs)(`div`,{className:`page-container`,"data-layout":`data`,"data-scroll-mode":`data`,children:[(0,W.jsxs)(`header`,{className:`page-header`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{children:ae.title}),(0,W.jsx)(`p`,{children:ae.description})]}),(0,W.jsxs)(`button`,{className:`button accent`,type:`button`,onClick:re,children:[(0,W.jsx)(Pe,{size:15}),(0,W.jsx)(`span`,{children:ae.addLabel})]})]}),(0,W.jsxs)(`div`,{className:`data-page-body table-data-body`,children:[(0,W.jsxs)(`div`,{className:`section-toolbar`,children:[(0,W.jsxs)(`div`,{className:`search-field`,children:[(0,W.jsx)(Ie,{size:14}),(0,W.jsx)(`input`,{type:`search`,placeholder:`搜索资源`,value:a,onChange:e=>o(e.target.value)})]}),(0,W.jsx)(Tf,{className:`compact-select`,ariaLabel:`筛选资源状态`,value:c||`__all__`,options:[{value:`__all__`,label:`全部状态`},{value:`ready`,label:`可用`},{value:`missing-secret`,label:`缺少凭证`},{value:`unhealthy`,label:`异常`},{value:`unresolved`,label:`未解析`}],onValueChange:e=>l(e===`__all__`?``:e)})]}),(0,W.jsx)(rc,{columns:oe,data:r,getRowId:e=>e.resourceId,caption:`${ae.title}资源列表`,minWidth:1180,loading:y,error:x,onRetry:ee,empty:{icon:(0,W.jsx)(ie,{size:20}),title:`没有匹配的资源`,description:`调整筛选条件,或添加一个新的工程资源。`},pagination:{pageIndex:u,pageSize:fF,total:_,hasNextPage:!!h,onPreviousPage:se,onNextPage:ce}})]}),C&&(0,W.jsx)(CF,{model:C,onClose:()=>w(null),onChanged:U}),T&&(0,W.jsx)(wF,{onClose:()=>E(!1),onAdded:()=>{E(!1),U()}}),D&&(0,W.jsx)(TF,{onClose:()=>O(!1),onConnected:()=>{O(!1),U()}}),k&&(0,W.jsx)(EF,{item:k,onClose:()=>A(null)}),j&&(0,W.jsx)(DF,{item:j,onClose:()=>M(null)}),N&&(0,W.jsx)(OF,{onClose:()=>P(!1),onCatalogChanged:U}),F&&(0,W.jsx)(kF,{onClose:()=>I(!1),onAdded:()=>{I(!1),U()}}),L&&(0,W.jsx)(ca,{title:`确认删除资源「${L.displayName||L.name}」?`,description:`删除后已绑定该资源的 Agent 不会自动更新,需手动重新编辑。`,confirmText:`确认删除`,busy:z,onConfirm:ne,onCancel:()=>R(null)})]})}function vF({item:e}){let t=uF[e.kind]?.icon||ie;return(0,W.jsxs)(`div`,{className:`agent-cell`,children:[(0,W.jsx)(`span`,{className:`capability-icon`,children:(0,W.jsx)(t,{size:15})}),(0,W.jsxs)(`div`,{className:`agent-cell-copy`,children:[(0,W.jsx)(`strong`,{children:e.displayName}),(0,W.jsx)(`span`,{children:e.name})]})]})}function yF({item:e}){if(e.kind===`model`){let t=e.contract?.metadata||{},n=Number(t.context_window_tokens||0),r=e.contract?.discovery?.contextWindow===`provider`?`服务返回`:`ksadk 默认`,i=n>=1e6?`${(n/1e6).toFixed(n%1e6?1:0)}M`:n>=1e3?`${Math.round(n/1e3)}K`:`${n||`-`}`;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`strong`,{children:i}),(0,W.jsx)(`span`,{className:`resource-origin`,children:r})]})}return e.kind===`tool`?(0,W.jsx)(`span`,{className:`status-badge neutral`,children:e.contract?.group||e.category||`general`}):(0,W.jsx)(`span`,{className:`mono`,children:e.version})}function bF({item:e}){if(e.kind===`model`){let t=e.contract?.metadata?.capabilities||{},n=[`文字`];t.multimodal_input_image&&n.push(`图片`),t.multimodal_input_video&&n.push(`视频`),t.multimodal_input_file&&n.push(`文件`);let r=e.contract?.discovery?.inputModalities===`provider`?`服务返回`:`ksadk 默认`;return(0,W.jsxs)(W.Fragment,{children:[n.join(` + `),(0,W.jsx)(`span`,{className:`resource-origin`,children:r})]})}if(e.kind===`tool`){let t=e.contract?.approval===`always`?`需审批`:`无需审批`,n=e.contract?.boundary||`ksadk-runtime`;return(0,W.jsxs)(W.Fragment,{children:[t,(0,W.jsx)(`span`,{className:`resource-origin`,children:n})]})}let t=e.description||`未提供说明`;return(0,W.jsx)(`span`,{className:`cell-clamp`,title:t,children:t})}function xF({item:e}){if(e.kind===`model`){let t=e.status===`ready`;return(0,W.jsx)(`span`,{className:`status-badge ${t?`success`:`warning`}`,children:t?`凭证已配置`:`凭证未配置`})}return(0,W.jsx)(`span`,{className:`status-badge ${e.status===`ready`?`success`:`warning`}`,children:e.status})}function SF({item:e,onConfigure:t,onView:n,onProbe:r,onDelete:i}){return(0,W.jsxs)(W.Fragment,{children:[e.kind===`model`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:`button secondary small`,type:`button`,onClick:t,children:`配置凭证`}),e.source===`local`&&(0,W.jsx)(`button`,{className:`button tertiary small`,type:`button`,onClick:i,children:`删除`})]}),e.kind===`mcp`&&e.source===`local`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:`button tertiary small`,type:`button`,onClick:n,children:`查看`}),(0,W.jsx)(`button`,{className:`button secondary small`,type:`button`,onClick:r,children:`重新探测`}),(0,W.jsx)(`button`,{className:`button tertiary small`,type:`button`,onClick:i,children:`删除`})]}),e.kind===`mcp`&&e.source!==`local`&&(0,W.jsx)(`button`,{className:`button tertiary small`,type:`button`,onClick:n,children:`查看`}),(e.kind===`tool`||e.kind===`skill`)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:`button tertiary small`,type:`button`,onClick:n,children:`查看`}),e.source===`local`&&(0,W.jsx)(`button`,{className:`button tertiary small`,type:`button`,onClick:i,children:`删除`})]})]})}function CF({model:e,onClose:t,onChanged:n}){let r=mF(e),i=hF(r),[a,o]=(0,s.useState)(null),c=cm({resolver:vm(aF),defaultValues:{value:``}}),[l,u]=(0,s.useState)(null),[d,p]=(0,s.useState)(``);(0,s.useEffect)(()=>{f(`/api/v1/credentials/${encodeURIComponent(i)}`).then(e=>e.json()).then(o).catch(()=>o({configured:!1,source:`missing`}))},[i]);let m=!!a?.configured,h=a?.source||`missing`,g=a==null?`正在检查凭证`:m?`模型凭证已配置`:`模型凭证未配置`,_=a==null?`检查当前 Runtime 是否已经获得模型凭证。`:h===`session`?`凭证已持久保存到工作区,重启后仍生效,所有 Agent 可复用。`:h===`environment`?`凭证由 Studio 启动环境变量提供,可以用新的会话凭证临时覆盖。`:`输入 API Key 后即可在本地运行当前模型。`;async function v(r,a){if(u(null),!a.value&&!m){c.setError(`value`,{type:`manual`,message:`当前模型还没有可用凭证,请输入 API Key。`});return}p(r?`test`:`save`);let o=!1;try{if(a.value){let e=await f(`/api/v1/credentials/${encodeURIComponent(i)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({value:a.value,persistence:`session`})});if(!e.ok)throw Error(await pF(e,`凭证保存失败`));o=!0}let s=null;if(r){let t=await f(`/api/v1/model-profiles/${encodeURIComponent(e.resourceId)}:test`,{method:`POST`}),n=await t.text().catch(()=>``),r={};try{r=JSON.parse(n)}catch{}if(!t.ok||r.ok===!1)throw Error(r?.error?.message||`HTTP ${t.status}`);s=r.latencyMs??0}n?.(),t(),Cm(r?`模型连接测试通过`:`模型凭证已保存`,r?`${e.displayName} · ${s} ms`:`凭证已持久保存到工作区,所有 Agent 可复用。`)}catch(e){u({title:o?`凭证已保存,但连接测试失败`:`模型凭证配置失败`,message:e.message}),o&&n?.()}p(``)}async function y(){u(null),p(`remove`);try{let r=await f(`/api/v1/credentials/${encodeURIComponent(i)}`,{method:`DELETE`});if(!r.ok)throw Error(await pF(r,`凭证清除失败`));n?.(),Cm(`会话凭证已清除`,e.displayName),t()}catch(e){u({title:`凭证清除失败`,message:e.message})}p(``)}return(0,W.jsx)(Ap,{...c,children:(0,W.jsxs)(FC,{title:`配置模型凭证`,subtitle:`凭证只保存在当前 Studio 会话,不写入 Agent 或 Bundle。`,onClose:t,footer:(0,W.jsxs)(W.Fragment,{children:[h===`session`&&(0,W.jsx)(`button`,{className:`button secondary`,type:`button`,onClick:y,disabled:d!==``,children:d===`remove`?`正在清除`:`清除会话凭证`}),(0,W.jsx)(`span`,{className:`drawer-footer-spacer`}),(0,W.jsx)(`button`,{className:`button secondary`,type:`button`,onClick:t,children:`取消`}),(0,W.jsx)(`button`,{className:`button secondary`,type:`button`,onClick:c.handleSubmit(e=>v(!1,e)),disabled:d!==``,children:d===`save`?`正在保存`:`仅保存`}),(0,W.jsxs)(`button`,{className:`button accent`,type:`button`,onClick:c.handleSubmit(e=>v(!0,e)),disabled:d!==``,children:[(0,W.jsx)(j,{size:15}),(0,W.jsx)(`span`,{children:d===`test`?`正在测试`:`保存并测试`})]})]}),children:[(0,W.jsxs)(`div`,{className:`credential-profile`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`模型`}),(0,W.jsx)(`strong`,{children:e.displayName})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`Provider`}),(0,W.jsx)(`strong`,{children:e.contract?.provider||`openai-compatible`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`Endpoint`}),(0,W.jsx)(`code`,{children:e.contract?.endpointUrl||e.contract?.baseUrl||`-`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`凭证引用`}),(0,W.jsx)(`code`,{children:r||`-`})]})]}),(0,W.jsxs)(`div`,{className:`credential-status ${m?`configured`:`missing`}`,children:[(0,W.jsx)(`span`,{className:`status-dot ${a==null?`warning`:m?`success`:`warning`}`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:g}),(0,W.jsx)(`p`,{children:_})]})]}),(0,W.jsx)(q,{label:`API Key`,requirement:m?`optional`:`required`,htmlFor:`modelCredValue`,hint:`保存后立即生效;关闭 Studio 后自动清除,需要持久化时可通过启动环境变量注入。`,error:c.formState.errors.value?.message,children:(0,W.jsx)(`input`,{id:`modelCredValue`,type:`password`,autoComplete:`new-password`,maxLength:16384,placeholder:m?`输入新的 API Key 以覆盖当前凭证`:`输入新的 API Key`,...c.register(`value`)})}),l&&(0,W.jsx)(IC,{kind:`error`,title:l.title,message:l.message})]})})}function wF({onClose:e,onAdded:t}){let n=cm({resolver:vm(nF),defaultValues:{name:``,displayName:``,model:``,endpointUrl:``,credentialRef:`env://MODEL_API_KEY`,description:``,apiKey:``,temperature:.2,maxTokens:2048,addressMode:`endpoint`,wireApi:``}}),{name:r,displayName:i,model:a,endpointUrl:o,credentialRef:c,apiKey:l,temperature:u,maxTokens:d,addressMode:p,wireApi:m}=n.watch(),h=c.replace(/^env:\/\//,``),[g,_]=(0,s.useState)(!1),[v,y]=(0,s.useState)(``),[b,x]=(0,s.useState)(!1),[S,C]=(0,s.useState)([]),[w,T]=(0,s.useState)([]),[E,D]=(0,s.useState)([]);(0,s.useEffect)(()=>{f(`/api/v1/catalog/models`).then(e=>e.json()).then(e=>{D((e.items||[]).map(e=>e.name).filter(Boolean))}).catch(()=>{})},[]);async function O(){if(!o.trim()){y(`请先填写接口地址再探测`);return}x(!0),y(``),C([]),T([]);try{let e={url:o.trim()};h.trim()&&(e.credentialRef=`env://${h.trim()}`),l.trim()&&(e.apiKey=l.trim());let t=await f(`/api/v1/model-endpoints:probe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await pF(t,`探测失败`));let r=await t.json();C(r.attempts||[]),T(r.models||[]),r.recommended?(n.setValue(`wireApi`,r.recommended.wireApi||`chat`),n.setValue(`addressMode`,`endpoint`),n.setValue(`endpointUrl`,r.recommended.endpointUrl,{shouldValidate:!0}),r.recommended.status===`auth_required`&&y(`端点可达,但需要有效凭证(401/403);配置 API Key 后可正常使用`)):y(`未能识别可用协议,请检查地址或网络`)}catch(e){y(e.message)}x(!1)}let k=[...new Set([...w,...E])];async function A(e){_(!0),y(``);try{let r=e.credentialRef.replace(/^env:\/\//,``);if(e.apiKey.trim()){let t=await f(`/api/v1/credentials/${encodeURIComponent(r)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({value:e.apiKey.trim(),persistence:`session`})});if(!t.ok)throw Error(await pF(t,`凭证保存失败`))}let i={provider:`openai-compatible`,model:e.model.trim(),credentialRef:e.credentialRef,parameters:{temperature:e.temperature,max_tokens:e.maxTokens}};e.wireApi&&(i.wireApi=e.wireApi),e.addressMode===`endpoint`?i.endpointUrl=e.endpointUrl.trim():i.baseUrl=e.endpointUrl.trim();let a=await f(`/api/v1/catalog/model-profiles`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e.name.trim(),displayName:e.displayName.trim(),version:`1.0.0`,description:e.description||``,spec:i})});if(!a.ok){let e=await a.json().catch(()=>null);if(Bg(e,n.setError)){_(!1);return}throw Error(e?.error?.message||`创建失败(${a.status})`)}Cm(`模型已创建`,`${e.displayName.trim()} · ${e.model.trim()}`),t()}catch(e){y(e.message)}_(!1)}let M=e=>`${e.protocol===`chat`?`Chat`:`Responses`} · ${e.status===`ok`?`可用 ${e.latencyMs}ms`:e.status===`auth_required`?`需凭证`:e.status===`recognized`?`可识别`:e.status===`unavailable`?`不存在`:e.status===`unreachable`?`不可达`:`错误`}`,N=e=>e.status===`ok`?`success`:e.status===`unavailable`||e.status===`unreachable`?`neutral`:`warning`;return(0,W.jsx)(Ap,{...n,children:(0,W.jsxs)(FC,{title:`添加模型`,subtitle:`接入 OpenAI 兼容端点的自定义 Model Profile。`,wide:!0,onClose:e,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:`button secondary`,type:`button`,onClick:e,children:`取消`}),(0,W.jsxs)(`button`,{className:`button accent`,type:`button`,onClick:n.handleSubmit(A),disabled:g,children:[(0,W.jsx)(j,{size:15}),(0,W.jsx)(`span`,{children:g?`创建中…`:`创建模型`})]})]}),children:[(0,W.jsxs)(`div`,{className:`form-grid two-columns`,children:[(0,W.jsx)(q,{label:`名称(Slug)`,requirement:`required`,htmlFor:`amName`,error:n.formState.errors.name?.message,children:(0,W.jsx)(`input`,{id:`amName`,className:`mono`,placeholder:`my-model`,...n.register(`name`)})}),(0,W.jsx)(q,{label:`显示名称`,requirement:`required`,htmlFor:`amDisplayName`,error:n.formState.errors.displayName?.message,children:(0,W.jsx)(`input`,{id:`amDisplayName`,placeholder:`我的模型`,...n.register(`displayName`)})})]}),(0,W.jsx)(q,{label:`模型 ID`,requirement:`required`,htmlFor:`amModelId`,error:n.formState.errors.model?.message,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`input`,{id:`amModelId`,className:`mono`,placeholder:`glm-5.1 / gpt-4o-mini / …`,list:`am-model-suggestions`,...n.register(`model`)}),(0,W.jsx)(`datalist`,{id:`am-model-suggestions`,children:k.map(e=>(0,W.jsx)(`option`,{value:e},e))}),k.length>0&&(0,W.jsxs)(`span`,{className:`helper`,children:[`可输入或从 `,k.length,` 个可用模型中选择(自动补全)。`]})]})}),(0,W.jsx)(q,{label:`接口地址`,requirement:`required`,htmlFor:`amEndpoint`,hint:`支持主机、/v1、Chat Completions 或 Responses 地址;智能探测会自动归一化。`,error:n.formState.errors.endpointUrl?.message,children:(0,W.jsxs)(`div`,{children:[m&&(0,W.jsx)(`span`,{className:`status-badge info`,children:m===`responses`?`Responses 协议`:`Chat 协议`}),(0,W.jsxs)(`div`,{style:{display:`flex`,gap:8,marginBottom:10,alignItems:`center`},children:[(0,W.jsxs)(`div`,{className:`segmented-control`,children:[(0,W.jsx)(`button`,{type:`button`,className:p===`endpoint`?`selected`:``,onClick:()=>n.setValue(`addressMode`,`endpoint`),children:`完整 endpointUrl`}),(0,W.jsx)(`button`,{type:`button`,className:p===`base`?`selected`:``,onClick:()=>n.setValue(`addressMode`,`base`),children:`baseUrl`})]}),(0,W.jsxs)(`button`,{className:`button secondary small`,type:`button`,onClick:O,disabled:b||!o.trim(),children:[(0,W.jsx)(et,{size:14}),(0,W.jsx)(`span`,{children:b?`探测中…`:`智能探测`})]})]}),(0,W.jsx)(`input`,{id:`amEndpoint`,className:`mono`,placeholder:p===`endpoint`?`https://host/v1/chat/completions`:`https://host/v1`,...n.register(`endpointUrl`)}),S.length>0&&(0,W.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6,marginTop:10},children:S.map((e,t)=>(0,W.jsx)(`span`,{className:`status-badge ${N(e)}`,title:e.endpointUrl,children:M(e)},t))})]})}),(0,W.jsxs)(`div`,{className:`form-grid two-columns`,children:[(0,W.jsx)(q,{label:`凭证环境变量名`,requirement:`required`,htmlFor:`amEnvName`,error:n.formState.errors.credentialRef?.message,children:(0,W.jsx)(`input`,{id:`amEnvName`,className:`mono`,value:h,onChange:e=>n.setValue(`credentialRef`,`env://${e.target.value}`,{shouldDirty:!0,shouldValidate:!0}),placeholder:`MY_MODEL_API_KEY`})}),(0,W.jsx)(q,{label:`API Key 值`,requirement:`optional`,htmlFor:`amApiKey`,hint:`仅保存到当前 Studio 会话;留空则从启动环境读取。`,error:n.formState.errors.apiKey?.message,children:(0,W.jsx)(`input`,{id:`amApiKey`,type:`password`,autoComplete:`new-password`,placeholder:`留空则从环境读取`,...n.register(`apiKey`)})})]}),(0,W.jsxs)(`div`,{className:`form-grid two-columns`,children:[(0,W.jsx)(q,{label:`temperature`,requirement:`optional`,htmlFor:`amTemp`,error:n.formState.errors.temperature?.message,children:(0,W.jsx)(`input`,{id:`amTemp`,type:`number`,step:`0.1`,min:0,max:2,...n.register(`temperature`,{valueAsNumber:!0})})}),(0,W.jsx)(q,{label:`max_tokens`,requirement:`optional`,htmlFor:`amMaxTokens`,error:n.formState.errors.maxTokens?.message,children:(0,W.jsx)(`input`,{id:`amMaxTokens`,type:`number`,min:1,max:131072,...n.register(`maxTokens`,{valueAsNumber:!0})})})]}),v&&(0,W.jsx)(IC,{kind:`error`,title:`添加模型`,message:v})]})})}function TF({onClose:e,onConnected:t}){let n=(0,s.useRef)(null),r=cm({resolver:vm(rF),defaultValues:{displayName:``,name:``,transport:`http`,command:``,args:``,endpointUrl:``,apiKeyName:``,apiKeyValue:``,description:``}}),{transport:i}=r.watch(),[a,o]=(0,s.useState)(``),[c,l]=(0,s.useState)(!1);function u(){let e=n.current?.value.trim();if(!e)return;let t;try{t=JSON.parse(e)}catch{Cm(`配置解析失败`,`请粘贴有效的 JSON`,`error`);return}let i=t.mcpServers||t.mcp_servers||t,a=Object.keys(i)[0],o=i[a];if(!o||typeof o!=`object`){Cm(`配置解析失败`,`未找到 MCP server 定义`,`error`);return}r.setValue(`name`,a,{shouldValidate:!0}),r.setValue(`displayName`,o.name||a,{shouldValidate:!0}),o.description&&r.setValue(`description`,o.description);let s=String(o.type||o.transport||``).toLowerCase();s.includes(`http`)||o.url?(r.setValue(`transport`,s===`sse`?`sse`:`http`),o.url&&r.setValue(`endpointUrl`,o.url,{shouldValidate:!0})):(r.setValue(`transport`,`stdio`),o.command&&r.setValue(`command`,o.command,{shouldValidate:!0}),Array.isArray(o.args)&&r.setValue(`args`,o.args.join(` `)));let c=o.headers||{},l=c.Authorization||c.authorization;if(l){let e=String(l).match(/\$\{?([A-Za-z0-9_]+)\}?/);e&&r.setValue(`apiKeyName`,e[1],{shouldValidate:!0})}else o.env_key&&r.setValue(`apiKeyName`,o.env_key,{shouldValidate:!0})}async function d(e){o(``),l(!0);try{if(e.apiKeyName.trim()&&e.apiKeyValue.trim()){let t=await f(`/api/v1/credentials/${encodeURIComponent(e.apiKeyName.trim())}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({value:e.apiKeyValue.trim(),persistence:`session`})});if(!t.ok)throw Error(await pF(t,`凭证保存失败`))}let n=e.transport===`streamable-http`?`http`:e.transport,i=n===`stdio`?e.apiKeyName.trim():`Authorization`,a={name:e.name.trim(),version:`1.0.0`,transport:n,args:n===`stdio`?e.args.trim().split(/\s+/).filter(Boolean):[],envRefs:e.apiKeyName.trim()?{[i]:`env://${e.apiKeyName.trim()}`}:{}};n===`stdio`?a.command=e.command.trim():a.endpointUrl=e.endpointUrl.trim();let o=await f(`/api/v1/catalog/mcp-servers`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({displayName:e.displayName.trim(),description:e.description.trim(),server:a})}),s=await o.json().catch(()=>null);if(!o.ok){if(Bg(s,r.setError)){l(!1);return}throw Error(s?.error?.message||`保存失败(${o.status})`)}let c=await f(`/api/v1/catalog/mcp-servers/${encodeURIComponent(s.resourceId)}:probe?timeoutSeconds=15`,{method:`POST`});if(!c.ok)throw Error(await pF(c,`探测失败`));Cm(`MCP 已连接`,`已发现 ${(await c.json()).health?.toolCount||0} 个 Tool。`),t()}catch(e){o(e.message)}l(!1)}return(0,W.jsx)(Ap,{...r,children:(0,W.jsxs)(FC,{title:`连接 MCP Server`,subtitle:`保存后执行探测,再回到 Agent 能力选择。`,onClose:e,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:`button secondary`,type:`button`,onClick:e,children:`取消`}),(0,W.jsxs)(`button`,{className:`button accent`,type:`button`,onClick:r.handleSubmit(d),disabled:c,children:[(0,W.jsx)(Te,{size:15}),(0,W.jsx)(`span`,{children:c?`正在探测`:`保存并探测`})]})]}),children:[(0,W.jsx)(q,{label:`粘贴 MCP 配置`,requirement:`optional`,htmlFor:`mcpPaste`,hint:`粘贴 JSON 后会自动填充下方字段。`,children:(0,W.jsx)(`textarea`,{id:`mcpPaste`,ref:n,rows:5,placeholder:'{"mcpServers":{"metaso":{"type":"streamable-http","url":"https://...","headers":{"Authorization":"Bearer ${KSC_AIPRO_API_KEY}"}}}}',onPaste:()=>window.setTimeout(u,0)})}),(0,W.jsxs)(`div`,{className:`form-grid two-columns`,children:[(0,W.jsx)(q,{label:`显示名称`,requirement:`required`,htmlFor:`mcpDisplayName`,error:r.formState.errors.displayName?.message,children:(0,W.jsx)(`input`,{id:`mcpDisplayName`,placeholder:`Web Research MCP`,...r.register(`displayName`)})}),(0,W.jsx)(q,{label:`Server 名称`,requirement:`required`,htmlFor:`mcpName`,error:r.formState.errors.name?.message,children:(0,W.jsx)(`input`,{id:`mcpName`,className:`mono`,placeholder:`web-research`,...r.register(`name`)})})]}),(0,W.jsx)(q,{label:`Transport`,requirement:`required`,htmlFor:`mcpTransport`,error:r.formState.errors.transport?.message,children:(0,W.jsx)(Tf,{id:`mcpTransport`,ariaLabel:`Transport`,value:i,options:[{value:`http`,label:`Streamable HTTP`},{value:`stdio`,label:`STDIO(本地命令)`},{value:`sse`,label:`SSE`}],onValueChange:e=>r.setValue(`transport`,e,{shouldDirty:!0,shouldValidate:!0})})}),i===`stdio`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:`Command`,requirement:`required`,htmlFor:`mcpCommand`,error:r.formState.errors.command?.message,children:(0,W.jsx)(`input`,{id:`mcpCommand`,className:`mono`,placeholder:`npx`,...r.register(`command`)})}),(0,W.jsx)(q,{label:`Arguments`,requirement:`optional`,htmlFor:`mcpArgs`,error:r.formState.errors.args?.message,children:(0,W.jsx)(`input`,{id:`mcpArgs`,className:`mono`,placeholder:`-y @your-org/web-research-mcp`,...r.register(`args`)})})]}),i!==`stdio`&&(0,W.jsx)(q,{label:`Server URL`,requirement:`required`,htmlFor:`mcpEndpoint`,error:r.formState.errors.endpointUrl?.message,children:(0,W.jsx)(`input`,{id:`mcpEndpoint`,className:`mono`,placeholder:`https://mcp.example.com/mcp`,...r.register(`endpointUrl`)})}),(0,W.jsx)(q,{label:`API Key 环境变量名`,requirement:`optional`,htmlFor:`mcpApiKey`,error:r.formState.errors.apiKeyName?.message,children:(0,W.jsx)(`input`,{id:`mcpApiKey`,className:`mono`,placeholder:`KSC_AIPRO_API_KEY`,...r.register(`apiKeyName`)})}),(0,W.jsx)(q,{label:`API Key 值`,requirement:`optional`,htmlFor:`mcpApiKeyValue`,hint:`仅保存到当前 Studio 会话;留空则从环境变量读取。`,error:r.formState.errors.apiKeyValue?.message,children:(0,W.jsx)(`input`,{id:`mcpApiKeyValue`,type:`password`,autoComplete:`new-password`,placeholder:`留空则从环境变量读取`,...r.register(`apiKeyValue`)})}),(0,W.jsx)(q,{label:`说明`,requirement:`optional`,htmlFor:`mcpDescription`,error:r.formState.errors.description?.message,children:(0,W.jsx)(`textarea`,{id:`mcpDescription`,rows:2,placeholder:`提供 Web 搜索和页面抓取能力`,...r.register(`description`)})}),a&&(0,W.jsx)(IC,{kind:`error`,title:`连接失败`,message:a})]})})}function EF({item:e,onClose:t}){let n=e.contract||{},r=e.health||{},i=n.discoveredTools||r.discoveredTools||[],a=[[`Resource ID`,e.resourceId],[`Transport`,n.transport||`-`],[`Endpoint`,n.endpointUrl||n.command||`-`],[`状态`,r.status||e.status],[`工具数`,r.toolCount??i.length],[`凭证`,(e.requiredSecretRefs||[]).join(`、`)||`无`]];return(0,W.jsxs)(FC,{title:e.displayName||e.name,subtitle:`${e.name} · ${e.version} · ${n.transport||``}`,onClose:t,children:[(0,W.jsx)(`dl`,{className:`trace-detail-grid`,children:a.map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e}),(0,W.jsx)(`dd`,{children:String(t)})]},e))}),(0,W.jsx)(`div`,{className:`inspector-title inspector-title-spaced`,children:`已发现工具`}),(0,W.jsx)(`div`,{className:`resource-detail-list`,children:i.length===0?(0,W.jsx)(`div`,{className:`resource-detail-item`,children:(0,W.jsxs)(`span`,{className:`resource-detail-item-copy`,children:[(0,W.jsx)(`strong`,{children:`未发现工具`}),(0,W.jsx)(`span`,{children:`点击“重新探测”以加载工具列表`})]})}):i.map(e=>(0,W.jsxs)(`div`,{className:`resource-detail-item`,children:[(0,W.jsx)(`span`,{className:`capability-icon`,children:(0,W.jsx)(Qe,{size:15})}),(0,W.jsxs)(`span`,{className:`resource-detail-item-copy`,children:[(0,W.jsx)(`strong`,{children:e.name}),(0,W.jsx)(`span`,{children:e.description||``})]})]},e.name))})]})}function DF({item:e,onClose:t}){let[n,r]=(0,s.useState)(!1),i=e.contract||{},a=[[`Resource ID`,e.resourceId],[`来源`,dF[e.source]||e.source],[`版本`,e.version||`-`],[`状态`,e.kind===`model`?e.status===`ready`?`凭证已配置`:`凭证未配置`:e.status]];return e.kind===`tool`&&(a.push([`Tool 分组`,i.group||e.category||`general`]),a.push([`审批`,i.approval===`always`?`需审批`:`无需审批`]),a.push([`边界`,i.boundary||`ksadk-runtime`]),i.sourcePath&&a.push([`源码`,`${i.sourcePath} · ${i.callableName||`-`}()`])),e.kind===`skill`&&i?.contentSha256&&a.push([`内容摘要`,i.contentSha256]),(0,W.jsxs)(FC,{title:e.displayName||e.name,subtitle:`${e.name} · ${e.version}`,onClose:t,children:[(0,W.jsx)(`dl`,{className:`trace-detail-grid`,children:a.map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e}),(0,W.jsx)(`dd`,{children:String(t)})]},e))}),(0,W.jsx)(`div`,{className:`inspector-title inspector-title-spaced`,children:`说明`}),(0,W.jsx)(`p`,{style:{margin:0,color:`var(--text-secondary)`,fontSize:`var(--font-size-meta)`,lineHeight:`var(--line-height-body)`},children:e.description||i.description||`未提供说明`}),e.kind===`skill`&&e.source===`local`&&(0,W.jsxs)(`button`,{className:`button secondary skill-files-open`,type:`button`,onClick:()=>r(!0),children:[(0,W.jsx)(ae,{size:15}),(0,W.jsx)(`span`,{children:`查看 Skill 文件`})]}),n&&(0,W.jsx)(ON,{title:e.displayName||e.name,endpoint:`/api/v1/catalog/skills/${encodeURIComponent(e.resourceId)}/files`,onClose:()=>r(!1)})]})}function OF({onClose:e,onCatalogChanged:t}){let[n,r]=(0,s.useState)(``),[i,a]=(0,s.useState)(null),[o,c]=(0,s.useState)(new Set),[l,u]=(0,s.useState)({}),[d,p]=(0,s.useState)(null),[m,h]=(0,s.useState)({completed:0,total:0}),[g,_]=(0,s.useState)(``),[v,y]=(0,s.useState)(``),[b,x]=(0,s.useState)(!1),[S,C]=(0,s.useState)(!1),[w,T]=(0,s.useState)(null),[E,D]=(0,s.useState)(null),O=i?.candidates||[];function k(){c(new Set),u({}),p(null),h({completed:0,total:0}),_(``),T(null)}async function A(){y(``),x(!0);try{let e=n.split(`,`).map(e=>e.trim()).filter(Boolean),t=await f(`/api/v1/catalog/skills:discover`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({scanPaths:e})});if(!t.ok)throw Error(await pF(t,`Skill 发现失败`));let r=await t.json();a(r),k()}catch(e){y(e.message)}x(!1)}function M(e){S||l[e]?.status===`succeeded`||c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function N(){let e=cF(O);for(let[t,n]of Object.entries(l))n.status===`succeeded`&&e.delete(t);c(e)}async function P(e){let n=i?.inspectionToken;if(!o.size||!n||S)return;let r=new Set(o),a=O.filter(e=>r.has(e.candidateId)&&(e.status===`ready`||e.status===`conflict`)).length;y(``),p(null),u({}),h({completed:0,total:a}),C(!0);try{let i=await lF({candidates:O,selectedIds:r,overwriteIds:e,commit:async(e,t)=>{_(e.candidateId);let r=await f(`/api/v1/catalog/skills/discoveries/${encodeURIComponent(n)}:commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({candidateId:e.candidateId,overwrite:t})});if(!r.ok)throw Error(await pF(r,`Skill 导入失败`));return r.json()},onResult:(e,t,n)=>{u(t=>({...t,[e.candidateId]:e})),h({completed:t,total:n})}});p(i),c(new Set(i.failedIds)),i.succeededIds.length&&await t(),i.failedIds.length?Cm(`Skill 批量导入完成`,`已导入 ${i.succeededIds.length} 个,${i.failedIds.length} 个失败。`,`error`):Cm(`Skill 批量导入完成`,`已导入 ${i.succeededIds.length} 个 Skill。`)}catch(e){y(e.message)}_(``),C(!1)}function F(){let e=O.filter(e=>o.has(e.candidateId)&&e.status===`conflict`);if(e.length){T(e);return}P(new Set)}let I=o.size;return(0,W.jsxs)(FC,{title:`发现本地 Skill`,subtitle:`默认扫描工作区及允许的 Claude、Codex、Agent 用户目录;扫描只产生候选,确认后才导入。`,wide:!0,closeDisabled:S,onClose:e,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:`button secondary`,type:`button`,onClick:e,disabled:S,children:`取消`}),(0,W.jsxs)(`button`,{className:`button accent`,type:`button`,onClick:F,disabled:!I||S,children:[(0,W.jsx)(j,{size:15}),(0,W.jsx)(`span`,{children:S?`正在导入 ${m.completed}/${m.total}`:`导入所选 ${I} 个`})]})]}),children:[(0,W.jsxs)(`div`,{className:`field`,children:[(0,W.jsx)(`label`,{htmlFor:`skillScanPaths`,children:`扫描目录(逗号分隔;留空扫描安全默认目录)`}),(0,W.jsx)(`input`,{id:`skillScanPaths`,value:n,onChange:e=>r(e.target.value),placeholder:`skills, .claude/skills, user:codex`}),(0,W.jsx)(`span`,{className:`helper`,children:`用户目录仅支持 user:agents、user:codex、user:claude;不支持任意本机路径扫描。`})]}),(0,W.jsxs)(`button`,{className:`button secondary`,type:`button`,onClick:A,disabled:b||S,children:[(0,W.jsx)(Ie,{size:15}),(0,W.jsx)(`span`,{children:b?`正在扫描`:`扫描候选`})]}),O.length>0&&(0,W.jsxs)(`div`,{className:`skill-selection-toolbar`,children:[(0,W.jsxs)(`span`,{children:[`已选择 `,I,` / `,cF(O).size]}),(0,W.jsxs)(`span`,{className:`skill-selection-actions`,children:[(0,W.jsx)(`button`,{className:`button tertiary small`,type:`button`,onClick:N,disabled:S,children:`全选可导入`}),(0,W.jsx)(`button`,{className:`button tertiary small`,type:`button`,onClick:()=>c(new Set),disabled:!I||S,children:`清空选择`})]})]}),(0,W.jsx)(`div`,{className:`skill-discovery-list`,style:{marginTop:16},children:O.length===0?(0,W.jsx)(`div`,{className:`trace-stage-empty compact`,children:(0,W.jsx)(`p`,{children:i?`安全默认目录中没有发现 Skill。`:`点击扫描候选。`})}):O.map(e=>{let t=e.risk||{},n=[`ready`,`conflict`].includes(e.status),r=l[e.candidateId],i=r?.status===`succeeded`,a=e.status===`ready`?`可导入`:e.status===`conflict`?`已安装`:`无效`,s=e.diagnostics?.map(e=>e.message).join(`;`)||`${e.fileCount||0} 个文件 · ${gF(e.totalBytes||0)}`,c=r?.status===`succeeded`?`已导入`:r?.status===`failed`?`导入失败:${r.error||`未知错误`}`:g===e.candidateId?`正在导入`:S&&o.has(e.candidateId)?`等待导入`:``;return(0,W.jsxs)(`div`,{className:`skill-candidate${n?``:` invalid`}`,children:[(0,W.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.displayName||e.name}`,disabled:!n||S||i,checked:o.has(e.candidateId),onChange:()=>M(e.candidateId)}),(0,W.jsx)(`span`,{className:`capability-icon`,children:(0,W.jsx)(He,{size:15})}),(0,W.jsxs)(`span`,{className:`skill-candidate-copy`,children:[(0,W.jsx)(`strong`,{children:e.displayName||e.name}),(0,W.jsxs)(`span`,{children:[e.path,` · `,e.version||`版本无效`]}),(0,W.jsx)(`small`,{children:s}),c&&(0,W.jsx)(`small`,{className:`skill-import-state ${r?.status||`pending`}`,children:c})]}),(0,W.jsxs)(`span`,{className:`status-badge ${e.status===`ready`?`success`:`warning`}`,children:[a,t.requiresReview?` · 需复核`:``]}),n&&(0,W.jsxs)(`button`,{className:`button tertiary small skill-preview-button`,type:`button`,onClick:()=>D(e),children:[(0,W.jsx)(ae,{size:14}),(0,W.jsx)(`span`,{children:`查看详情`})]})]},e.candidateId)})}),d&&(0,W.jsx)(IC,{kind:d.failedIds.length?`warning`:`success`,title:d.failedIds.length?`已导入 ${d.succeededIds.length} 个,${d.failedIds.length} 个失败`:`已导入 ${d.succeededIds.length} 个 Skill`,message:d.failedIds.length?`失败项已保留选择,可修复后再次导入。`:`资源目录已刷新。`}),v&&(0,W.jsx)(IC,{kind:`error`,title:`Skill 发现或导入失败`,message:v}),w&&(0,W.jsx)(ca,{title:`所选 Skill 中有 ${w.length} 个已安装`,description:`${w.map(e=>e.displayName||e.name).join(`、`)} 将被覆盖;旧版本会移入回收位置,可手工恢复。`,confirmText:`覆盖并继续`,danger:!1,onCancel:()=>T(null),onConfirm:()=>{let e=new Set(w.map(e=>e.candidateId));T(null),P(e)}}),E&&i?.inspectionToken&&(0,W.jsx)(ON,{title:E.displayName||E.name||`Skill`,endpoint:`/api/v1/catalog/skills/discoveries/${encodeURIComponent(i.inspectionToken)}/candidates/${encodeURIComponent(E.candidateId)}/files`,onClose:()=>D(null)})]})}function kF({onClose:e,onAdded:t}){let n=cm({resolver:vm(iF),defaultValues:{displayName:``,name:``,callableName:``,description:``,sourceMode:`upload`,sourcePath:``}}),{sourceMode:r,name:i,callableName:a}=n.watch(),[o,c]=(0,s.useState)(null),[l,u]=(0,s.useState)(null),[d,p]=(0,s.useState)(``),[m,h]=(0,s.useState)(!1);async function g(){if(!o){p(`请先选择 Python 文件`);return}h(!0),p(``);try{let e=new FormData;e.append(`file`,o);let t=await f(`/api/v1/catalog/python-tools:inspect`,{method:`POST`,body:e});if(!t.ok)throw Error(await pF(t,`Python Tool 检查失败`));let r=await t.json(),i=r.callables?.[0];u(r);let a=o.name.replace(/\.py$/i,``).replace(/[^A-Za-z0-9_]+/g,`_`).replace(/^[^A-Za-z_]+/,`tool_`)||`python_tool`;n.setValue(`callableName`,i?.name||``,{shouldValidate:!0}),n.getValues(`name`)||n.setValue(`name`,a,{shouldValidate:!0}),n.getValues(`displayName`)||n.setValue(`displayName`,a,{shouldValidate:!0}),n.getValues(`description`)||n.setValue(`description`,i?.description||``)}catch(e){u(null),p(e.message||`Python Tool 检查失败`)}finally{h(!1)}}async function _(e){if(e.sourceMode===`upload`&&!l){n.setError(`callableName`,{type:`manual`,message:`请先完成 Python 文件检查`});return}h(!0),p(``);try{let r=e.sourceMode===`upload`?await f(`/api/v1/catalog/python-tools/${encodeURIComponent(l.inspectionToken)}:commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({displayName:e.displayName.trim(),name:e.name.trim(),callableName:e.callableName.trim(),description:e.description.trim()})}):await f(`/api/v1/catalog/tools`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({displayName:e.displayName.trim(),category:`custom`,contract:{name:e.name.trim(),version:`1.0.0`,description:e.description.trim(),inputSchema:{type:`object`,properties:{}},outputSchema:{},approval:`policy`,sideEffect:`none`,executor:`python`,sourcePath:e.sourcePath.trim(),callableName:e.callableName.trim()}})}),i=await r.json().catch(()=>null);if(!r.ok){if(Bg(i,n.setError)){h(!1);return}throw Error(i?.error?.message||`Tool 添加失败(${r.status})`)}Cm(`Python Tool 已保存`,`${i.displayName||e.displayName.trim()} · SHA-256 已锁定`),t()}catch(e){p(e.message)}h(!1)}return(0,W.jsx)(Ap,{...n,children:(0,W.jsxs)(FC,{title:`添加 Python Tool`,subtitle:`源码先复制进 Catalog 并锁定 SHA-256,构建时进入不可变 Runtime 快照。`,onClose:e,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:`button secondary`,type:`button`,onClick:e,children:`取消`}),(0,W.jsxs)(`button`,{className:`button accent`,type:`button`,onClick:n.handleSubmit(_),disabled:m,children:[(0,W.jsx)(j,{size:15}),(0,W.jsx)(`span`,{children:m?`正在保存`:`保存 Tool`})]})]}),children:[(0,W.jsxs)(`div`,{className:`segmented-control python-tool-source-mode`,"aria-label":`Python Tool 源码方式`,children:[(0,W.jsx)(`button`,{className:r===`upload`?`selected`:``,type:`button`,onClick:()=>{n.setValue(`sourceMode`,`upload`,{shouldValidate:!0}),p(``)},children:`上传文件`}),(0,W.jsx)(`button`,{className:r===`workspace`?`selected`:``,type:`button`,onClick:()=>{n.setValue(`sourceMode`,`workspace`,{shouldValidate:!0}),p(``)},children:`工作区路径`})]}),(0,W.jsx)(YP,{}),r===`upload`?(0,W.jsx)(q,{label:`Python 文件`,requirement:`required`,hint:`拖放 .py 文件,或点击选择;检查只解析 AST,不会执行脚本。`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(qP,{ariaLabel:`选择 Python Tool 文件`,accept:{"text/x-python":[`.py`],"text/plain":[`.py`]},maxSize:1048576,file:o,onFile:e=>{c(e),u(null),n.setValue(`callableName`,``)},onError:p}),(0,W.jsxs)(`button`,{className:`button secondary`,type:`button`,onClick:g,disabled:!o||m,children:[(0,W.jsx)(Ie,{size:15}),(0,W.jsx)(`span`,{children:m?`检查中`:`只读检查 Callable`})]}),l&&(0,W.jsxs)(`div`,{className:`python-tool-inspection-summary`,children:[(0,W.jsx)(j,{size:15}),(0,W.jsxs)(`span`,{children:[`SHA-256 `,l.sha256.slice(0,12),`… · 发现 `,l.callables.length,` 个公开函数`]})]})]})}):(0,W.jsx)(q,{label:`工作区 Python 文件`,requirement:`required`,htmlFor:`ptSource`,hint:`仅允许当前工作区内的普通 .py 文件;符号链接会被拒绝。`,error:n.formState.errors.sourcePath?.message,children:(0,W.jsx)(`input`,{id:`ptSource`,placeholder:`tools/my_tool.py`,...n.register(`sourcePath`)})}),(0,W.jsxs)(`div`,{className:`form-grid two-columns`,children:[(0,W.jsx)(q,{label:`显示名称`,requirement:`required`,htmlFor:`ptDisplayName`,error:n.formState.errors.displayName?.message,children:(0,W.jsx)(`input`,{id:`ptDisplayName`,placeholder:`例如:订单查询`,...n.register(`displayName`)})}),(0,W.jsx)(q,{label:`Tool 标识`,requirement:`required`,htmlFor:`ptName`,error:n.formState.errors.name?.message,children:(0,W.jsx)(`input`,{id:`ptName`,className:`mono`,...n.register(`name`)})}),(0,W.jsx)(q,{label:`Callable`,requirement:`required`,htmlFor:`ptCallable`,error:n.formState.errors.callableName?.message,children:r===`upload`?(0,W.jsx)(Tf,{id:`ptCallable`,ariaLabel:`Callable`,value:a,placeholder:l?`选择公开函数`:`请先检查文件`,disabled:!l,options:(l?.callables||[]).map(e=>({value:e.name,label:`${e.async?`async `:``}${e.name}(${e.parameters.join(`, `)})`,description:e.description||void 0})),onValueChange:e=>{n.setValue(`callableName`,e,{shouldDirty:!0,shouldValidate:!0});let t=l?.callables?.find(t=>t.name===e);t?.description&&n.setValue(`description`,t.description)}}):(0,W.jsx)(`input`,{id:`ptCallable`,className:`mono`,...n.register(`callableName`)})})]}),(0,W.jsx)(q,{label:`说明`,requirement:`optional`,htmlFor:`ptDesc`,error:n.formState.errors.description?.message,children:(0,W.jsx)(`textarea`,{id:`ptDesc`,rows:3,...n.register(`description`)})}),d&&(0,W.jsx)(IC,{kind:`error`,title:`Tool 添加失败`,message:d})]})})}function AF(){return`agent-${Date.now().toString(36).slice(-6)}${Math.random().toString(36).slice(2,6)}`}function jF({value:e,onChange:t,error:n,generate:r=AF,id:i=`agent-slug`,label:a=`本地标识`}){return(0,W.jsx)(q,{htmlFor:i,label:a,requirement:`generated`,hint:`默认生成唯一的本地 ID;可手动修改,云端 AgentId 由部署服务另行映射。`,error:n,children:(0,W.jsxs)(`div`,{className:`generated-id-control`,children:[(0,W.jsx)(`input`,{id:i,value:e,onChange:e=>t(e.target.value),pattern:`[a-z][a-z0-9-]{2,62}`,maxLength:63,spellCheck:!1,autoComplete:`off`}),(0,W.jsx)(`button`,{className:`icon-button tertiary`,type:`button`,"aria-label":`重新生成本地标识`,title:`重新生成`,onClick:()=>t(r()),children:(0,W.jsx)(Fe,{size:15})})]})})}var MF=`agentkit.studio.agentDraft.v1`;function NF(e){return e?.requiredSecretRefs?.[0]||e?.contract?.credentialRef||e?.contract?.credential_ref||e?.contract?.requiredSecretRefs?.[0]||e?.contract?.required_secret_refs?.[0]||``}var PF={loose:{title:`宽松权限策略`,description:`本地 Tool 全部自动允许,外部操作仍需审批。`},strict:{title:`严格权限策略`,description:`只读 Tool 自动允许,外部或写入操作需要审批。`},custom:{title:`自定义权限策略`,description:`沿用每个 Tool Contract 中配置的审批策略。`}},FF=[{value:`codex`,label:`Codex · ManagedRuntime`},{value:`adk`,label:`Google ADK · Python source`},{value:`langgraph`,label:`LangGraph · Python graph`}],IF=[[`定义 Agent`,`模板与系统提示词`],[`绑定能力`,`Model · Tool · MCP · Skill`],[`Prompt 与策略`,`检查并调整`],[`检查并创建`,`构建与打开会话`]],LF=new Set([`SUCCEEDED`,`FAILED`,`CANCELLED`,`TIMED_OUT`]);async function RF(e){for(let t=0;t<1200;t+=1){let t=await f(`/api/v1/operations/${encodeURIComponent(e)}`),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error?.message||`构建状态获取失败(${t.status})`);if(LF.has(n?.status)){if(n.status!==`SUCCEEDED`)throw Error(n.error?.message||`构建未完成`);return n}await new Promise(e=>window.setTimeout(e,200))}throw Error(`构建等待超时`)}function zF({editingAgentId:e,viewportMode:t,onBack:n,onCreated:r,onAgentsChanged:i}){let[a,o]=(0,s.useState)(`quick`),[c,l]=(0,s.useState)(!1),[u,d]=(0,s.useState)(`尚未保存`),[p,m]=(0,s.useState)([]),[h,g]=(0,s.useState)({}),[_,v]=(0,s.useState)(1),[y,b]=(0,s.useState)(1),x=cm({resolver:vm(TC),defaultValues:{name:`New Agent`,slug:AF(),runtimeType:`codex`,template:`blank`,prompt:``,description:``,audience:`产品与技术负责人`,language:`zh-CN`,depth:`deep`,format:`report`,systemPrompt:``,taskPrompt:``,buildAfterCreate:!0}}),{name:S,slug:C,runtimeType:w,template:D,description:k,prompt:A,audience:M,language:N,depth:P,format:F,systemPrompt:L,taskPrompt:R,buildAfterCreate:z}=x.watch(),[B,V]=(0,s.useState)([]),[H,U]=(0,s.useState)([]),[ee,ne]=(0,s.useState)([]),[ie,ae]=(0,s.useState)([]),[oe,se]=(0,s.useState)(`strict`),[ce,le]=(0,s.useState)(`idle`),[de,fe]=(0,s.useState)(``),[pe,me]=(0,s.useState)(!1),[he,ge]=(0,s.useState)(!1),[_e,ve]=(0,s.useState)(null),[ye,be]=(0,s.useState)(!1),Se=(0,s.useRef)(null),Ce=(0,s.useRef)(null),we=(0,s.useRef)(0),De=(0,s.useRef)(!1),[Oe,Ae]=(0,s.useState)([]),[je,Me]=(0,s.useState)(``),[Ne,Re]=(0,s.useState)([]),[ze,Ve]=(0,s.useState)(null),Ue=cm({resolver:vm(EC),defaultValues:{name:``,slug:AF(),runtimeType:`codex`,prompt:``,description:``,modelProfileId:void 0}}),[We,Ge]=(0,s.useState)(!1),[Ke,qe]=(0,s.useState)(``),[Je,Ye]=(0,s.useState)(null),[Xe,$e]=(0,s.useState)(null),tt=cm({resolver:vm(DC),defaultValues:{name:``,slug:AF()}}),[nt,rt]=(0,s.useState)(null),it=cm({resolver:vm(OC),defaultValues:{name:``,slug:AF(),path:`.`}}),at=it.watch(`path`),[G,ot]=(0,s.useState)(!1),[st,ct]=(0,s.useState)(``),lt=(0,s.useCallback)(async()=>{try{let[e,t]=await Promise.all([f(`/api/v1/catalog/resources?limit=200`).then(e=>e.json()),f(`/api/v1/catalog/models`).then(e=>e.json()).catch(()=>null)]),n=e.items||[],r=n.filter(e=>e.kind===`model`&&(e.source===`local`||e.source===`market`)),i=t?.items?.length?[...r,...t.items]:n.filter(e=>e.kind===`model`);m([...i,...n.filter(e=>e.kind!==`model`)]);let a=[...new Set(i.map(NF).filter(e=>e.startsWith(`env://`)))],o=await Promise.all(a.map(async e=>{let t=e.slice(6);try{let n=await f(`/api/v1/credentials/${encodeURIComponent(t)}`);return[e,n.ok?await n.json():{configured:!1}]}catch{return[e,{configured:!1}]}}));g(Object.fromEntries(o))}catch{}},[]);(0,s.useEffect)(()=>{lt()},[lt]);let ut=(0,s.useMemo)(()=>p.filter(e=>e.kind===`model`&&[`ready`,`missing-secret`].includes(e.status)),[p]),dt=(0,s.useMemo)(()=>p.filter(e=>e.kind===`tool`&&e.status===`ready`),[p]),ft=(0,s.useMemo)(()=>p.filter(e=>e.kind===`mcp`),[p]),pt=(0,s.useMemo)(()=>p.filter(e=>e.kind===`skill`&&e.status===`ready`),[p]),mt=(0,s.useCallback)(e=>p.find(t=>t.resourceId===e),[p]),ht=(0,s.useCallback)(e=>{let t=NF(e);return t?h[t]:void 0},[h]);(0,s.useEffect)(()=>{if(a!==`conversation`){De.current=!1;return}De.current||!ut.length||(De.current=!0,Ne.length||Re([ut[0].resourceId]))},[a,ut,Ne.length]);function gt(){return`${MF}:local-workspace`}function _t(){try{window.localStorage.setItem(gt(),JSON.stringify({version:1,savedAt:new Date().toISOString(),mode:a,wizard:{step:_,maxStep:y,template:D,runtime:w,depth:P,selectedTools:H,selectedSkills:ie,selectedMcp:ee,selectedModels:B,policy:oe},fields:{name:S,slug:C,description:k,prompt:A,audience:M,language:N,format:F,systemPrompt:L,taskPrompt:R,buildAfterCreate:z}})),d(`已保存 ${new Intl.DateTimeFormat(`zh-CN`,{hour:`2-digit`,minute:`2-digit`}).format(new Date)}`)}catch{}}function vt(){d(`有未保存更改`)}let yt=(0,s.useCallback)(()=>({prompt:A,goal:A,description:k,taskPrompt:R,audience:M,language:N,depth:P,outputFormat:F,modelProfileId:B[0]||null,modelProfileIds:B,toolResourceIds:H,skillResourceIds:ie,mcpResourceIds:ee,policyTemplate:oe,executionStrategy:D===`research`?`plan-act-observe`:`direct`,maxSteps:D===`research`?28:12,timeoutSeconds:D===`research`?900:120}),[A,k,R,D,M,N,P,F,B,H,ie,ee,oe]),bt=(0,s.useCallback)(async({preservePrompt:e=!0}={})=>{let t=++we.current;le(`composing`);try{let n=await f(`/api/v1/agent-templates/${D}:compose`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(yt())}),r=await n.json();if(!n.ok)throw Error(r?.error?.message||`生成 Agent 配置失败(${n.status})`);if(t!==we.current)return;Se.current=r;let i=r.spec?.bindings||{};U(w===`codex`?[]:(i.tools||[]).map(e=>e.resourceId)),ae((i.skills||[]).map(e=>e.resourceId)),ne((i.mcpServers||[]).map(e=>e.resourceId));let a=i.modelProfileIds?.length?i.modelProfileIds:i.modelProfileId?[i.modelProfileId]:[];a.length&&V(a),(!e||!L.trim())&&x.setValue(`systemPrompt`,r.spec?.instructions?.system||``,{shouldDirty:!0}),(!e||!R.trim())&&x.setValue(`taskPrompt`,r.spec?.instructions?.task||``,{shouldDirty:!0}),le(`done`)}catch(e){t===we.current&&(le(`idle`),fe(e.message||`生成 Agent 配置失败`))}},[D,yt,w,L,R,x]);async function xt(e){if(!(e<1||e>4)){if(e>_){if(_===1&&!await x.trigger([`name`,`slug`,`runtimeType`,`prompt`,`audience`])){fe(`请修正标记字段后继续。`);return}if(_===2&&!B.length){fe(`请至少选择一个模型后继续。`);return}}fe(``),e===3&&ce===`idle`&&bt({preservePrompt:!0}),v(e),b(t=>Math.max(t,e)),vt()}}async function St(e){fe(``),me(!0);try{if(Se.current||await bt({preservePrompt:!1}),!Se.current)throw Error(`未能生成 Agent 配置,请检查模板和能力绑定后重试。`);let t=JSON.parse(JSON.stringify(Se.current?.spec||{}));t.instructions={system:e.systemPrompt.trim(),task:e.taskPrompt.trim()},t.description=e.description.trim()||t.description;let n=await f(`/api/v1/authoring/quick`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e.name.trim(),slug:e.slug.trim(),runtimeType:e.runtimeType,description:t.description,template:e.template,spec:t})}),i=await n.json().catch(()=>null);if(!n.ok){if(Bg(i,x.setError)){v(1);return}throw Error(i?.error?.message||`创建失败(${n.status})`)}let a=String(i?.metadata?.id||``);if(!a)throw Error(`创建响应未返回 Agent 标识`);if(e.buildAfterCreate){let e=Number(i?.metadata?.revision||1),t=await f(`/api/v1/agents/${encodeURIComponent(a)}/builds`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":`build-${a}-r${e}-${Date.now()}`},body:JSON.stringify({revision:e,runEvaluation:!1})}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error?.message||`构建提交失败(${t.status})`);let r=String(n?.id||``);if(!r)throw Error(`构建响应未返回操作标识`);await RF(r)}try{window.localStorage.removeItem(gt())}catch{}r(a,e.buildAfterCreate)}catch(e){fe(e.message||`创建失败`)}finally{me(!1)}}async function Ct(){let e=je.trim();if(!e||!Ne.length){qe(`请输入需求并选择用于构建的模型。`);return}qe(``);let t=[...Oe,{role:`user`,content:e}];Ae(t),Me(``),Ge(!0);try{let e=await f(`/api/v1/authoring/conversations:compose`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({messages:t,modelProfileId:Ne[0]})}),n=await e.json();if(!e.ok)throw Error(n?.error?.message||`生成失败(${e.status})`);Ve(n.proposal),Ue.reset({name:n.proposal.name||``,slug:AF(),runtimeType:n.proposal.runtimeType||`codex`,prompt:n.proposal.instructions?.system||``,description:n.proposal.description||``,modelProfileId:Ne[0]}),Ae([...t,{role:`assistant`,content:JSON.stringify(n.proposal)}])}catch(e){qe(e.message||`对话构建失败`)}finally{Ge(!1)}}async function wt(e){if(ze){Ge(!0),qe(``);try{let t=await f(`/api/v1/authoring/quick`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e.name.trim(),slug:e.slug.trim(),runtimeType:e.runtimeType,description:e.description?.trim()||ze.description||``,spec:{instructions:{system:e.prompt.trim(),task:ze.instructions?.task||``},bindings:{modelProfileId:Ne[0]||null,modelProfileIds:Ne.slice()}}})}),n=await t.json().catch(()=>null);if(!t.ok){if(Bg(n,Ue.setError))return;throw Error(n?.error?.message||`创建失败(${t.status})`)}r(n?.metadata?.id)}catch(e){qe(e.message||`创建失败`)}finally{Ge(!1)}}}async function Tt(){if(Je){ot(!0),ct(``);try{let e=new FormData;e.append(`file`,Je);let t=await f(`/api/v1/authoring/imports:inspect`,{method:`POST`,body:e}),n=await t.json();if(!t.ok)throw Error(n?.error?.message||`检查失败(${t.status})`);$e(n),tt.reset({name:n.displayName||``,slug:AF()})}catch(e){ct(e.message)}finally{ot(!1)}}}async function Et(e){if(Xe){ot(!0),ct(``);try{let t=await f(`/api/v1/authoring/imports/${encodeURIComponent(Xe.inspectionToken)}:commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e.name.trim(),slug:e.slug.trim()||void 0})}),n=await t.json();if(!t.ok){if(Bg(n,tt.setError))return;throw Error(n?.error?.message||`导入失败(${t.status})`)}r(n?.metadata?.id)}catch(e){ct(e.message)}finally{ot(!1)}}}async function Dt(){if(await it.trigger(`path`)){ot(!0),ct(``);try{let e=await f(`/api/v1/authoring/projects:inspect`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:at.trim()})}),t=await e.json();if(!e.ok)throw Error(t?.error?.message||`检测失败(${e.status})`);rt(t),it.reset({name:t.name||`Detected Agent`,slug:AF(),path:at})}catch(e){ct(e.message)}finally{ot(!1)}}}async function Ot(e){if(nt){ot(!0),ct(``);try{let t=await f(`/api/v1/authoring/projects/${encodeURIComponent(nt.inspectionToken)}:commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e.name.trim(),slug:e.slug.trim()||void 0,modelProfileId:ut[0]?.resourceId||null})}),n=await t.json();if(!t.ok){if(Bg(n,it.setError))return;throw Error(n?.error?.message||`创建失败(${t.status})`)}r(n?.metadata?.id)}catch(e){ct(e.message)}finally{ot(!1)}}}let kt=D===`research`?`深度调研`:`空白 Agent`,At={codex:`Codex`,adk:`ADK`,langgraph:`LangGraph`}[w]||w,jt=PF[oe],Mt=B.map(e=>mt(e)?.displayName||e).join(`、`)||`待选择`,Nt=H.length+ee.length+ie.length,Pt=B.map(mt).filter(e=>!!e),Ft=Pt.length===0?`未选择模型;Agent 可以先构建,但运行前需要配置。`:Pt.every(e=>ht(e)?.configured)?`已选 ${Pt.length} 个模型 · 凭证已配置`:`部分模型凭证未配置;Agent 可以先构建,但运行前需要配置 API Key。`,It=(0,s.useCallback)((e=!1)=>{l(!1),e&&requestAnimationFrame(()=>Ce.current?.focus())},[]);(0,s.useEffect)(()=>{t!==`compact`&&It()},[It,t]);function Lt(e){o(e),t===`compact`&&It(!0)}let Rt=[{id:`quick`,icon:et,label:`快速创建`,sub:`配置 YAML Revision`},{id:`conversation`,icon:xe,label:`对话构建`,sub:`多轮生成 Draft Patch`},{id:`import`,icon:Ze,label:`导入`,sub:`YAML / Agent ZIP`},{id:`project`,icon:ue,label:`项目识别`,sub:`检测 ADK / LangGraph`}],zt=!e&&a===`conversation`?`workbench`:`document`,Bt=t=>(0,W.jsxs)(`div`,{className:`create-rail-panel`,children:[t&&(0,W.jsx)(`div`,{className:`create-rail-label`,children:`创建方式`}),!e&&(0,W.jsx)(`nav`,{className:`authoring-mode-tabs`,"aria-label":`创建方式`,children:Rt.map(e=>{let t=e.icon;return(0,W.jsxs)(`button`,{className:a===e.id?`active`:``,type:`button`,onClick:()=>Lt(e.id),children:[(0,W.jsx)(t,{size:16}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:e.label}),(0,W.jsx)(`small`,{children:e.sub})]})]},e.id)})}),(e||a===`quick`)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`create-rail-divider`}),(0,W.jsx)(`div`,{className:`create-rail-label wizard-step-label`,children:`配置步骤`}),(0,W.jsx)(`nav`,{className:`wizard-steps`,"aria-label":`创建步骤`,children:IF.map((t,n)=>{let r=n+1;return(0,W.jsxs)(`button`,{className:`wizard-step${(e?r===1:_===r)?` active`:``}${!e&&r<y&&r!==_?` completed`:``}`,type:`button`,disabled:!!e||r>y,onClick:()=>xt(r),children:[(0,W.jsx)(`span`,{className:`step-number`,children:r}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:t[0]}),(0,W.jsx)(`small`,{children:t[1]})]})]},r)})})]})]});return(0,W.jsxs)(`div`,{className:`create-shell`,"data-scroll-mode":zt,children:[(0,W.jsxs)(`header`,{className:`create-header`,children:[(0,W.jsxs)(`button`,{className:`button tertiary`,type:`button`,onClick:n,children:[(0,W.jsx)(T,{size:16}),(0,W.jsx)(`span`,{children:`返回 Agent`})]}),(0,W.jsxs)(`div`,{className:`create-heading`,children:[(0,W.jsx)(`span`,{className:`eyebrow`,children:`Agent Builder`}),(0,W.jsx)(`h1`,{children:e?`编辑 Agent`:`创建 Agent`}),(0,W.jsx)(`p`,{children:e?`修改系统提示词与模型绑定;本地标识保持不变,避免破坏已有引用。`:`从系统提示词开始,按需组合模型、Tool、MCP 与 Skill。`})]}),(0,W.jsx)(`button`,{ref:Ce,className:`button secondary compact-create-rail-trigger`,type:`button`,"aria-expanded":c,"aria-controls":`createRail`,onClick:()=>l(e=>!e),children:`创建方式`}),(0,W.jsxs)(`div`,{className:`draft-state`,children:[(0,W.jsx)(`span`,{className:`status-dot neutral`}),(0,W.jsx)(`span`,{children:u})]})]}),(0,W.jsxs)(`div`,{className:`create-workbench`,children:[t!==`compact`&&(0,W.jsx)(`aside`,{id:`createRail`,className:`create-rail`,"aria-label":`创建方式与步骤`,children:Bt(!0)}),t===`compact`&&c&&(0,W.jsx)(sa,{open:!0,compact:!0,title:`创建方式`,subtitle:`切换创建入口,或查看当前配置步骤。`,onOpenChange:e=>{e||It(!0)},children:(0,W.jsx)(`div`,{id:`createRail`,children:Bt(!1)})}),(0,W.jsxs)(`div`,{className:`create-stage`,children:[e&&(0,W.jsx)(PC,{agentId:e,catalog:p,onSaved:(e,t)=>r(e,t),onAppearanceSaved:i}),!e&&a===`conversation`&&(0,W.jsxs)(`section`,{className:`authoring-mode-panel`,children:[(0,W.jsxs)(`div`,{className:`authoring-panel-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`eyebrow`,children:`Conversation authoring`}),(0,W.jsx)(`h2`,{children:`通过多轮对话设计 Agent`}),(0,W.jsx)(`p`,{children:`模型只返回结构化 Draft Patch;确认前不会写入工作区。`})]}),(0,W.jsx)(`span`,{className:`status-badge neutral`,children:`Inspect → Confirm`})]}),(0,W.jsxs)(`div`,{className:`conversation-authoring-layout`,children:[(0,W.jsxs)(`div`,{className:`authoring-chat-column`,children:[(0,W.jsxs)(`div`,{className:`authoring-transcript`,children:[Oe.length===0&&(0,W.jsx)(`div`,{className:`trace-stage-empty compact`,children:(0,W.jsx)(`p`,{children:`说明 Agent 的职责、边界、Runtime 和期望能力。`})}),Oe.map((e,t)=>(0,W.jsxs)(`div`,{className:`authoring-message ${e.role}`,children:[(0,W.jsx)(`strong`,{children:e.role===`user`?`你`:`构建助手`}),(0,W.jsx)(`p`,{children:e.role===`user`?e.content:`已生成结构化方案,见右侧 Draft Patch。`})]},t))]}),(0,W.jsx)(`div`,{className:`authoring-composer`,children:(0,W.jsx)(`textarea`,{rows:3,placeholder:`例如:做一个 ADK 发布评审 Agent,只输出阻断项和证据`,value:je,onChange:e=>Me(e.target.value)})}),(0,W.jsx)(`div`,{className:`authoring-composer-actions`,children:(0,W.jsxs)(`button`,{className:`button accent`,type:`button`,disabled:We,onClick:Ct,children:[(0,W.jsx)(Le,{size:16}),(0,W.jsx)(`span`,{children:We?`正在生成`:`生成方案`})]})}),Ke&&(0,W.jsxs)(`div`,{className:`inline-alert error`,children:[(0,W.jsx)(I,{size:16}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`对话构建失败`}),(0,W.jsx)(`p`,{children:Ke})]})]}),(0,W.jsxs)(`div`,{className:`field authoring-model-field`,children:[(0,W.jsx)(`label`,{children:`用于构建的模型(可多选)`}),(0,W.jsx)(jg,{ariaLabel:`选择用于构建的模型`,items:ut,selectedIds:Ne,getId:e=>e.resourceId,getLabel:e=>e.displayName,getDescription:e=>`${e.contract?.model||e.name} · ${ht(e)?.configured?`凭证已配置`:`需配置凭证`}`,onChange:Re,searchPlaceholder:`搜索构建模型`,emptyMessage:`没有可用模型`})]})]}),(0,W.jsx)(Ap,{...Ue,children:(0,W.jsxs)(`form`,{className:`authoring-inspection-card`,onSubmit:Ue.handleSubmit(wt),noValidate:!0,children:[(0,W.jsxs)(`div`,{className:`authoring-preview-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`Draft Patch`}),(0,W.jsx)(`span`,{children:`必须确认后才创建`})]}),(0,W.jsx)(`span`,{className:`status-dot ${ze?`success`:`neutral`}`})]}),(0,W.jsxs)(`div`,{className:`form-grid two-columns`,children:[(0,W.jsx)(q,{label:`显示名称`,requirement:`required`,htmlFor:`conversationName`,error:Ue.formState.errors.name?.message,children:(0,W.jsx)(`input`,{id:`conversationName`,...Ue.register(`name`)})}),(0,W.jsx)(jF,{id:`conversationSlug`,value:Ue.watch(`slug`),onChange:e=>Ue.setValue(`slug`,e,{shouldDirty:!0,shouldValidate:!0}),error:Ue.formState.errors.slug?.message})]}),(0,W.jsx)(q,{label:`Runtime`,requirement:`required`,htmlFor:`conversationRuntime`,error:Ue.formState.errors.runtimeType?.message,children:(0,W.jsx)(Tf,{id:`conversationRuntime`,ariaLabel:`Runtime`,value:Ue.watch(`runtimeType`),options:FF,onValueChange:e=>Ue.setValue(`runtimeType`,e,{shouldDirty:!0,shouldValidate:!0})})}),(0,W.jsx)(q,{label:`系统提示词`,requirement:`required`,htmlFor:`conversationPrompt`,error:Ue.formState.errors.prompt?.message,children:(0,W.jsx)(`textarea`,{id:`conversationPrompt`,rows:8,...Ue.register(`prompt`)})}),(0,W.jsx)(Lg,{code:ze?JSON.stringify(ze,null,2):`完成一轮或多轮对话后,这里会出现可编辑的 Draft Patch。`,language:ze?`json`:`text`,filename:`draft-patch.json`,showLineNumbers:!!ze,wrap:!ze}),(0,W.jsxs)(`button`,{className:`button accent`,type:`submit`,disabled:!ze||We,children:[(0,W.jsx)(j,{size:16}),(0,W.jsx)(`span`,{children:`确认并创建 Revision`})]})]})})]})]}),!e&&a===`import`&&(0,W.jsxs)(`section`,{className:`authoring-mode-panel`,children:[(0,W.jsxs)(`div`,{className:`authoring-panel-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`eyebrow`,children:`Agent import`}),(0,W.jsx)(`h2`,{children:`检查并导入 Agent`}),(0,W.jsx)(`p`,{children:`先解析格式、Runtime、文件清单和 SHA-256,确认后再写入。`})]}),(0,W.jsx)(`span`,{className:`status-badge neutral`,children:`YAML / ZIP`})]}),(0,W.jsxs)(`div`,{className:`authoring-inspect-grid`,children:[(0,W.jsxs)(`form`,{className:`authoring-input-card`,onSubmit:e=>{e.preventDefault(),Tt()},children:[(0,W.jsx)(q,{label:`Agent 文件`,requirement:`required`,hint:`拖放 Agent YAML / ZIP,或点击选择`,children:(0,W.jsx)(`div`,{children:(0,W.jsx)(qP,{ariaLabel:`选择 Agent YAML 或 ZIP`,accept:{"application/zip":[`.zip`],"application/yaml":[`.yaml`,`.yml`],"text/yaml":[`.yaml`,`.yml`]},maxSize:104857600,file:Je,onFile:e=>{Ye(e),$e(null)},onError:ct})})}),(0,W.jsxs)(`button`,{className:`button accent`,type:`submit`,disabled:G,children:[(0,W.jsx)(Ie,{size:16}),(0,W.jsx)(`span`,{children:G?`检查中`:`只读检查`})]})]}),(0,W.jsx)(Ap,{...tt,children:(0,W.jsxs)(`form`,{className:`authoring-inspection-card`,onSubmit:tt.handleSubmit(Et),noValidate:!0,children:[(0,W.jsxs)(`div`,{className:`form-grid two-columns`,children:[(0,W.jsx)(q,{label:`显示名称`,requirement:`required`,htmlFor:`importName`,error:tt.formState.errors.name?.message,children:(0,W.jsx)(`input`,{id:`importName`,...tt.register(`name`)})}),(0,W.jsx)(jF,{id:`importSlug`,value:tt.watch(`slug`),onChange:e=>tt.setValue(`slug`,e,{shouldDirty:!0,shouldValidate:!0}),error:tt.formState.errors.slug?.message})]}),(0,W.jsx)(Lg,{code:Xe?JSON.stringify(Xe,null,2):`选择文件并检查后显示解析结果、警告和 RuntimeRef。`,language:Xe?`json`:`text`,filename:`agent-import-inspection.json`,showLineNumbers:!!Xe,wrap:!Xe}),(0,W.jsxs)(`button`,{className:`button accent`,type:`submit`,disabled:!Xe||G,children:[(0,W.jsx)(j,{size:16}),(0,W.jsx)(`span`,{children:`确认导入`})]})]})})]}),st&&(0,W.jsxs)(`div`,{className:`inline-alert error`,children:[(0,W.jsx)(I,{size:16}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`操作失败`}),(0,W.jsx)(`p`,{children:st})]})]})]}),!e&&a===`project`&&(0,W.jsxs)(`section`,{className:`authoring-mode-panel`,children:[(0,W.jsxs)(`div`,{className:`authoring-panel-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`eyebrow`,children:`Project detection`}),(0,W.jsx)(`h2`,{children:`识别现有项目`}),(0,W.jsx)(`p`,{children:`复用 FrameworkDetector 展示证据和置信度;确认前不修改源码。`})]}),(0,W.jsx)(`span`,{className:`status-badge neutral`,children:`Workspace only`})]}),(0,W.jsx)(Ap,{...it,children:(0,W.jsxs)(`div`,{className:`authoring-inspect-grid`,children:[(0,W.jsxs)(`form`,{className:`authoring-input-card`,onSubmit:e=>{e.preventDefault(),Dt()},children:[(0,W.jsx)(q,{label:`工作区相对路径`,requirement:`required`,htmlFor:`projectPath`,hint:`仅检查当前工作区内的目录,不会修改项目源码。`,error:it.formState.errors.path?.message,children:(0,W.jsx)(`input`,{id:`projectPath`,...it.register(`path`)})}),(0,W.jsxs)(`button`,{className:`button accent`,type:`submit`,disabled:G,children:[(0,W.jsx)(Ie,{size:16}),(0,W.jsx)(`span`,{children:G?`检测中`:`检测项目`})]})]}),(0,W.jsxs)(`form`,{className:`authoring-inspection-card`,onSubmit:it.handleSubmit(Ot),noValidate:!0,children:[(0,W.jsxs)(`div`,{className:`form-grid two-columns`,children:[(0,W.jsx)(q,{label:`显示名称`,requirement:`required`,htmlFor:`projectName`,error:it.formState.errors.name?.message,children:(0,W.jsx)(`input`,{id:`projectName`,...it.register(`name`)})}),(0,W.jsx)(jF,{id:`projectSlug`,value:it.watch(`slug`),onChange:e=>it.setValue(`slug`,e,{shouldDirty:!0,shouldValidate:!0}),error:it.formState.errors.slug?.message})]}),(0,W.jsx)(Lg,{code:nt?JSON.stringify(nt,null,2):`输入本地项目路径后显示 FrameworkDetector 证据。`,language:nt?`json`:`text`,filename:`project-inspection.json`,showLineNumbers:!!nt,wrap:!nt}),(0,W.jsxs)(`button`,{className:`button accent`,type:`submit`,disabled:!nt||G,children:[(0,W.jsx)(j,{size:16}),(0,W.jsx)(`span`,{children:`确认创建 Revision`})]})]})]})}),st&&(0,W.jsxs)(`div`,{className:`inline-alert error`,children:[(0,W.jsx)(I,{size:16}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`操作失败`}),(0,W.jsx)(`p`,{children:st})]})]})]}),!e&&a===`quick`&&(0,W.jsxs)(`div`,{className:`wizard-layout`,children:[(0,W.jsx)(Ap,{...x,children:(0,W.jsxs)(`form`,{className:`wizard-content`,onSubmit:x.handleSubmit(St),noValidate:!0,children:[(0,W.jsxs)(`section`,{className:`wizard-panel${_===1?` active`:``}`,hidden:_!==1,children:[(0,W.jsxs)(`div`,{className:`panel-heading`,children:[(0,W.jsx)(`span`,{className:`panel-index`,children:`01`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{children:`定义 Agent 的角色`}),(0,W.jsx)(`p`,{children:`选择起点,并说明 Agent 的职责、边界和期望行为。`})]})]}),(0,W.jsxs)(`div`,{className:`field`,children:[(0,W.jsx)(`label`,{children:`创建方式`}),(0,W.jsxs)(`div`,{className:`template-grid`,children:[(0,W.jsxs)(`button`,{className:`template-card${D===`blank`?` selected`:``}`,type:`button`,onClick:()=>{x.setValue(`template`,`blank`,{shouldDirty:!0}),vt()},children:[(0,W.jsx)(`span`,{className:`template-icon`,children:(0,W.jsx)(O,{size:18})}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:`空白 Agent`}),(0,W.jsx)(`small`,{children:`输入系统提示词,自主选择能力和执行策略`})]}),(0,W.jsx)(`span`,{className:`choice-check`,children:(0,W.jsx)(j,{size:14})})]}),(0,W.jsxs)(`button`,{className:`template-card${D===`research`?` selected`:``}`,type:`button`,onClick:()=>{x.setValue(`template`,`research`,{shouldDirty:!0}),vt()},children:[(0,W.jsx)(`span`,{className:`template-icon`,children:(0,W.jsx)(Ie,{size:18})}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:`深度调研`}),(0,W.jsx)(`small`,{children:`预置问题拆解、来源验证和引用报告方法`})]}),(0,W.jsx)(`span`,{className:`choice-check`,children:(0,W.jsx)(j,{size:14})})]})]})]}),(0,W.jsxs)(`div`,{className:`form-grid two-columns`,children:[(0,W.jsx)(q,{label:`Agent 名称`,requirement:`required`,htmlFor:`quickAgentName`,error:x.formState.errors.name?.message,children:(0,W.jsx)(`input`,{id:`quickAgentName`,maxLength:128,placeholder:`例如:技术支持助手`,...x.register(`name`,{onChange:vt})})}),(0,W.jsx)(jF,{value:C,onChange:e=>{x.setValue(`slug`,e,{shouldDirty:!0,shouldValidate:!0}),vt()},error:x.formState.errors.slug?.message})]}),(0,W.jsx)(q,{label:`Runtime`,requirement:`required`,htmlFor:`quickRuntime`,hint:`由所选 RuntimeAdapter 运行;Codex 支持 OpenAI Responses 与兼容代理。`,error:x.formState.errors.runtimeType?.message,children:(0,W.jsx)(Tf,{id:`quickRuntime`,ariaLabel:`Runtime`,value:w,options:FF,onValueChange:e=>{x.setValue(`runtimeType`,e,{shouldDirty:!0,shouldValidate:!0}),vt()}})}),(0,W.jsx)(q,{label:`描述`,requirement:`optional`,htmlFor:`quickDescription`,error:x.formState.errors.description?.message,children:(0,W.jsx)(`input`,{id:`quickDescription`,maxLength:1024,placeholder:`简要说明这个 Agent 解决什么问题`,...x.register(`description`,{onChange:vt})})}),(0,W.jsx)(q,{label:`系统提示词`,requirement:`required`,htmlFor:`quickPrompt`,error:x.formState.errors.prompt?.message,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`textarea`,{id:`quickPrompt`,rows:7,maxLength:32768,placeholder:`例如:你是一名企业技术支持助手。先识别问题类型,再结合知识库给出准确、可执行的处理步骤;信息不足时先提问,不要编造事实。`,...x.register(`prompt`,{onChange:vt})}),(0,W.jsxs)(`div`,{className:`field-footer`,children:[(0,W.jsx)(`span`,{children:`写清角色、目标、工作边界和回答方式`}),(0,W.jsxs)(`span`,{children:[A.length,` / 32768`]})]})]})}),D===`research`&&(0,W.jsxs)(`div`,{className:`template-specific`,children:[(0,W.jsxs)(`div`,{className:`form-grid two-columns`,children:[(0,W.jsx)(q,{label:`目标读者`,requirement:`required`,htmlFor:`researchAudience`,error:x.formState.errors.audience?.message,children:(0,W.jsx)(`input`,{id:`researchAudience`,maxLength:256,...x.register(`audience`)})}),(0,W.jsx)(q,{label:`输出语言`,requirement:`required`,htmlFor:`researchLanguage`,children:(0,W.jsx)(Tf,{id:`researchLanguage`,ariaLabel:`输出语言`,value:N,options:[{value:`zh-CN`,label:`简体中文`},{value:`en-US`,label:`English`}],onValueChange:e=>x.setValue(`language`,e,{shouldDirty:!0,shouldValidate:!0})})})]}),(0,W.jsxs)(`div`,{className:`field`,children:[(0,W.jsx)(`label`,{children:`调研深度`}),(0,W.jsx)(`div`,{className:`choice-grid`,children:[{value:`focused`,label:`聚焦`,desc:`8 个步骤,适合快速事实核验`,time:`约 3 分钟`},{value:`standard`,label:`标准`,desc:`16 个步骤,兼顾范围和深度`,time:`约 8 分钟`},{value:`deep`,label:`深度`,desc:`28 个步骤,多来源交叉验证`,time:`约 15 分钟`}].map(e=>(0,W.jsxs)(`button`,{className:`choice-card${P===e.value?` selected`:``}`,type:`button`,onClick:()=>x.setValue(`depth`,e.value,{shouldDirty:!0}),children:[(0,W.jsx)(`span`,{className:`choice-check`,children:(0,W.jsx)(j,{size:14})}),(0,W.jsx)(`strong`,{children:e.label}),(0,W.jsx)(`span`,{children:e.desc}),(0,W.jsx)(`small`,{children:e.time})]},e.value))})]}),(0,W.jsx)(q,{label:`默认输出`,requirement:`required`,htmlFor:`researchFormat`,children:(0,W.jsx)(Tf,{id:`researchFormat`,ariaLabel:`默认输出`,value:F,options:[{value:`report`,label:`结构化研究报告`},{value:`brief`,label:`决策简报`},{value:`evidence-table`,label:`证据矩阵与结论`}],onValueChange:e=>x.setValue(`format`,e,{shouldDirty:!0,shouldValidate:!0})})})]})]}),(0,W.jsxs)(`section`,{className:`wizard-panel${_===2?` active`:``}`,hidden:_!==2,children:[(0,W.jsxs)(`div`,{className:`panel-heading`,children:[(0,W.jsx)(`span`,{className:`panel-index`,children:`02`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{children:`选择 Agent 可以使用的能力`}),(0,W.jsx)(`p`,{children:`所有依赖都会在构建时锁定版本和摘要,并由权限策略控制调用。`})]})]}),w===`codex`&&(0,W.jsxs)(`div`,{className:`inline-alert warning codex-capability-notice`,children:[(0,W.jsx)(I,{size:16}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`ManagedRuntime 不绑定 ksadk Tool`}),(0,W.jsx)(`p`,{children:`codex CLI 自身提供工具能力,ksadk Tool 不会绑定到 codex Agent。MCP(streamable-http)与 Skill 可绑定:MCP 经 codex config_overrides 注入,Skill 以原生 SkillInput 注入。模型仍需选择并配置凭证。`})]})]}),(0,W.jsxs)(`div`,{className:`capability-section`,children:[(0,W.jsxs)(`div`,{className:`capability-heading`,children:[(0,W.jsx)(`span`,{className:`capability-icon`,children:(0,W.jsx)(re,{size:15})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{children:`Model Profile`}),(0,W.jsx)(`p`,{children:`负责理解请求、规划执行和生成回答;可多选`})]}),(0,W.jsx)(`span`,{className:`required-badge`,children:`必需`})]}),(0,W.jsx)(`div`,{className:`model-profile-control`,children:(0,W.jsx)(`button`,{className:`button secondary`,type:`button`,onClick:()=>ve(Pt[0]||null),children:`配置凭证`})}),(0,W.jsx)(jg,{ariaLabel:`选择模型`,items:ut,selectedIds:B,getId:e=>e.resourceId,getLabel:e=>e.displayName,getDescription:e=>`${e.contract?.model||e.name} · ${ht(e)?.configured?`凭证已配置`:`需配置凭证`}`,onChange:e=>{V(e),vt()},searchPlaceholder:`搜索模型`,emptyMessage:`没有可用模型`}),(0,W.jsx)(`span`,{className:`helper`,children:Ft})]}),w!==`codex`&&(0,W.jsxs)(`div`,{className:`capability-section`,children:[(0,W.jsxs)(`div`,{className:`capability-heading`,children:[(0,W.jsx)(`span`,{className:`capability-icon`,children:(0,W.jsx)(Qe,{size:15})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{children:`Tool 与权限`}),(0,W.jsx)(`p`,{children:`选择本地 Tool,并设置默认审批级别`})]})]}),(0,W.jsx)(`div`,{className:`segmented-control`,"aria-label":`Tool 权限模板`,children:[`loose`,`strict`,`custom`].map(e=>(0,W.jsx)(`button`,{className:oe===e?`selected`:``,type:`button`,onClick:()=>{se(e),vt()},children:{loose:`宽松`,strict:`严格`,custom:`自定义`}[e]},e))}),(0,W.jsx)(`p`,{className:`policy-description`,children:jt.description}),(0,W.jsx)(jg,{ariaLabel:`选择 Tool`,items:dt,selectedIds:H,getId:e=>e.resourceId,getLabel:e=>e.displayName,getDescription:e=>`${e.version} · ${e.description||`本地 Tool`}`,onChange:e=>{U(e),vt()},searchPlaceholder:`搜索 Tool`,emptyMessage:`没有可用 Tool`})]}),(0,W.jsxs)(`div`,{className:`capability-section`,children:[(0,W.jsxs)(`div`,{className:`capability-heading`,children:[(0,W.jsx)(`span`,{className:`capability-icon`,children:(0,W.jsx)(Te,{size:15})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{children:`MCP Server`}),(0,W.jsx)(`p`,{children:`连接外部服务并提供可发现的 Tool;codex 经 config_overrides 注入 streamable-http MCP`})]}),(0,W.jsxs)(`button`,{className:`button secondary small`,type:`button`,onClick:()=>be(!0),children:[(0,W.jsx)(Pe,{size:14}),(0,W.jsx)(`span`,{children:`连接 MCP`})]})]}),(0,W.jsx)(jg,{ariaLabel:`选择 MCP Server`,items:ft,selectedIds:ee,getId:e=>e.resourceId,getLabel:e=>e.displayName,getDescription:e=>`${e.description||`MCP Server`} · ${e.health?.toolCount||0} Tool · ${e.status===`ready`?`Ready`:e.status}`,onChange:e=>{ne(e),vt()},searchPlaceholder:`搜索 MCP Server`,emptyMessage:`没有已连接的 MCP Server`})]}),(0,W.jsxs)(`div`,{className:`capability-section`,children:[(0,W.jsxs)(`div`,{className:`capability-heading`,children:[(0,W.jsx)(`span`,{className:`capability-icon`,children:(0,W.jsx)(He,{size:15})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{children:`Skill`}),(0,W.jsx)(`p`,{children:`按需注入可复用的方法、知识和任务约束`})]})]}),(0,W.jsx)(jg,{ariaLabel:`选择 Skill`,items:pt,selectedIds:ie,getId:e=>e.resourceId,getLabel:e=>e.displayName,getDescription:e=>`${e.version} · ${e.description||`版本化 Skill`}`,onChange:e=>{ae(e),vt()},searchPlaceholder:`搜索 Skill`,emptyMessage:`没有已安装的 Skill`})]})]}),(0,W.jsxs)(`section`,{className:`wizard-panel${_===3?` active`:``}`,hidden:_!==3,children:[(0,W.jsxs)(`div`,{className:`panel-heading`,children:[(0,W.jsx)(`span`,{className:`panel-index`,children:`03`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{children:`检查系统提示词与任务契约`}),(0,W.jsx)(`p`,{children:`保存前可以继续编辑,创建时会完整写入 Agent Draft。`})]}),(0,W.jsxs)(`button`,{className:`button secondary small`,type:`button`,onClick:()=>bt({preservePrompt:!1}),children:[(0,W.jsx)(Fe,{size:14}),(0,W.jsx)(`span`,{children:`重新生成`})]})]}),(0,W.jsxs)(`div`,{className:`prompt-status`,children:[(0,W.jsx)(`span`,{className:`status-dot ${ce===`done`?`success`:`info`}`}),(0,W.jsx)(`span`,{children:ce===`composing`?`正在根据模板与能力生成 Agent 配置`:ce===`done`?`Agent 配置已根据当前选择生成`:`进入此步骤后生成 Prompt`})]}),(0,W.jsx)(q,{label:`角色与系统提示词`,requirement:`required`,htmlFor:`composedSystemPrompt`,hint:`定义角色、目标、工作边界和回答原则`,error:x.formState.errors.systemPrompt?.message,children:(0,W.jsx)(`textarea`,{id:`composedSystemPrompt`,className:`prompt-editor`,rows:16,...x.register(`systemPrompt`,{onChange:vt})})}),(0,W.jsx)(q,{label:`任务契约`,requirement:`optional`,htmlFor:`composedTaskPrompt`,hint:`约束每次请求的执行步骤、工具使用和交付结构`,error:x.formState.errors.taskPrompt?.message,children:(0,W.jsx)(`textarea`,{id:`composedTaskPrompt`,className:`prompt-editor`,rows:10,...x.register(`taskPrompt`,{onChange:vt})})})]}),(0,W.jsxs)(`section`,{className:`wizard-panel${_===4?` active`:``}`,hidden:_!==4,children:[(0,W.jsxs)(`div`,{className:`panel-heading`,children:[(0,W.jsx)(`span`,{className:`panel-index`,children:`04`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{children:`检查配置并创建`}),(0,W.jsx)(`p`,{children:`确认 Agent 身份、能力依赖和创建后的动作。`})]})]}),(0,W.jsxs)(`div`,{className:`review-block`,children:[(0,W.jsxs)(`div`,{className:`review-title`,children:[(0,W.jsx)(`span`,{children:`Agent`}),(0,W.jsx)(`button`,{className:`text-button`,type:`button`,onClick:()=>xt(1),children:`编辑`})]}),(0,W.jsxs)(`div`,{className:`review-agent`,children:[(0,W.jsx)(`span`,{className:`agent-avatar`,children:D===`research`?(0,W.jsx)(Ie,{size:16}):(0,W.jsx)(O,{size:16})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:S}),(0,W.jsxs)(`span`,{children:[C,` · `,w,` · `,kt]}),(0,W.jsx)(`p`,{children:A||`等待填写系统提示词`})]})]})]}),(0,W.jsxs)(`div`,{className:`review-block`,children:[(0,W.jsxs)(`div`,{className:`review-title`,children:[(0,W.jsx)(`span`,{children:`能力绑定`}),(0,W.jsx)(`button`,{className:`text-button`,type:`button`,onClick:()=>xt(2),children:`编辑`})]}),(0,W.jsxs)(`div`,{className:`review-capabilities`,children:[(0,W.jsxs)(`div`,{className:`review-capability`,children:[(0,W.jsx)(re,{size:16}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:Pt[0]?.displayName||`Model`}),(0,W.jsx)(`span`,{children:`Model Profile`})]})]}),(0,W.jsxs)(`div`,{className:`review-capability`,children:[(0,W.jsx)(Qe,{size:16}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`strong`,{children:[H.length,` 个 Tool`]}),(0,W.jsx)(`span`,{children:jt.title})]})]}),(0,W.jsxs)(`div`,{className:`review-capability`,children:[(0,W.jsx)(Te,{size:16}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`strong`,{children:[ee.length,` 个 MCP`]}),(0,W.jsx)(`span`,{children:ee.length?`已连接外部服务`:`未绑定`})]})]}),(0,W.jsxs)(`div`,{className:`review-capability`,children:[(0,W.jsx)(He,{size:16}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`strong`,{children:[ie.length,` 个 Skill`]}),(0,W.jsx)(`span`,{children:ie.length?`已注入版本化能力`:`未绑定`})]})]})]})]}),(0,W.jsxs)(`div`,{className:`review-block`,children:[(0,W.jsxs)(`div`,{className:`review-title`,children:[(0,W.jsx)(`span`,{children:`Prompt`}),(0,W.jsx)(`button`,{className:`text-button`,type:`button`,onClick:()=>xt(3),children:`编辑`})]}),(0,W.jsx)(`div`,{className:`prompt-preview`,children:L||A||`等待生成`})]}),(0,W.jsxs)(`label`,{className:`post-create-option`,children:[(0,W.jsx)(`input`,{type:`checkbox`,...x.register(`buildAfterCreate`)}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:`创建后立即构建并打开会话`}),(0,W.jsx)(`small`,{children:`生成不可变 AgentBundle,完成后进入 Chat 工作台`})]})]})]}),de&&(0,W.jsxs)(`div`,{className:`inline-alert error wizard-error-summary`,role:`alert`,children:[(0,W.jsx)(I,{size:16}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`需要处理一项配置`}),(0,W.jsx)(`p`,{children:de})]})]}),(0,W.jsxs)(`footer`,{className:`wizard-actions`,children:[(0,W.jsxs)(`button`,{className:`button secondary`,type:`button`,disabled:_===1,onClick:()=>xt(_-1),children:[(0,W.jsx)(T,{size:16}),(0,W.jsx)(`span`,{children:`上一步`})]}),(0,W.jsxs)(`button`,{className:`button tertiary`,type:`button`,onClick:_t,children:[(0,W.jsx)(te,{size:16}),(0,W.jsx)(`span`,{children:`保存草稿`})]}),(0,W.jsxs)(`span`,{className:`wizard-progress`,children:[`第 `,_,` 步,共 4 步`]}),(0,W.jsxs)(`button`,{className:`button tertiary`,type:`button`,"aria-expanded":he,onClick:()=>ge(e=>!e),children:[(0,W.jsx)(ke,{size:16}),(0,W.jsx)(`span`,{children:`配置摘要`}),(0,W.jsx)(`span`,{className:`summary-count`,children:Nt})]}),_<4&&(0,W.jsxs)(`button`,{className:`button accent`,type:`button`,onClick:()=>xt(_+1),children:[(0,W.jsx)(`span`,{children:`继续`}),(0,W.jsx)(E,{size:16})]}),_===4&&(0,W.jsxs)(`button`,{className:`button accent`,type:`submit`,disabled:pe,children:[(0,W.jsx)(Pe,{size:16}),(0,W.jsx)(`span`,{children:pe?`正在创建`:`创建 Agent`})]})]})]})}),(0,W.jsx)(sa,{open:he,compact:!0,title:`配置摘要`,subtitle:`检查本轮创建使用的 Runtime、模型、能力与权限策略。`,onOpenChange:ge,children:(0,W.jsxs)(`div`,{className:`wizard-summary-content`,children:[(0,W.jsxs)(`dl`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`模板`}),(0,W.jsx)(`dd`,{children:kt})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Runtime`}),(0,W.jsx)(`dd`,{children:At})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`模型`}),(0,W.jsx)(`dd`,{children:Mt})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Skill`}),(0,W.jsx)(`dd`,{children:ie.length})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`MCP`}),(0,W.jsx)(`dd`,{children:ee.length})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Tool`}),(0,W.jsx)(`dd`,{children:H.length})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`策略`}),(0,W.jsx)(`dd`,{children:D===`research`?`Plan-Act-Observe`:`Direct`})]})]}),(0,W.jsx)(`div`,{className:`summary-divider`}),(0,W.jsxs)(`div`,{className:`summary-note`,children:[(0,W.jsx)(Be,{size:16}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:jt.title}),(0,W.jsx)(`p`,{children:jt.description})]})]}),(0,W.jsxs)(`div`,{className:`summary-note`,children:[(0,W.jsx)(Ee,{size:16}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`不可变构建`}),(0,W.jsx)(`p`,{children:`Skill、MCP 和 Tool 将锁定版本与摘要。`})]})]})]})})]})]})]}),_e&&(0,W.jsx)(CF,{model:_e,onClose:()=>ve(null),onChanged:lt}),ye&&(0,W.jsx)(TF,{onClose:()=>be(!1),onConnected:()=>{be(!1),lt()}})]})}function BF(e,t=28){return e.length>t?`${e.slice(0,t)}…`:e}function VF({detail:e,catalog:t,buildId:n,onClose:r}){let[i,a]=(0,s.useState)(`curl`),o=e.draft,c=o.metadata.labels||{},l=o.spec.bindings?.modelProfileId||o.spec.bindings?.modelProfileIds?.[0]||``,u=t.find(e=>e.resourceId===l),d=c[`agentkit.ksyun.com/template`]||`blank`,f={model:u?.contract?.model||u?.name||c[`agentkit.ksyun.com/model`]||`glm-5.1`,input:[{role:`user`,content:[{type:`input_text`,text:d===`research`?`调研 Agent 工程平台的核心能力`:`请根据你的职责处理这个请求`}]}],metadata:{agent_id:o.metadata.id},stream:!0},p=i===`curl`?[`curl -X POST "${window.location.origin}/v1/responses" \\`,` -H "Content-Type: application/json" \\`,` -H "Authorization: Bearer <RUNTIME_API_KEY>" \\`,` -d '${JSON.stringify(f,null,2)}'`].join(`
|
|
230
|
-
`):[`const response = await fetch("${window.location.origin}/v1/responses", {`,` method: "POST",`,` headers: {`,` "Content-Type": "application/json",`,' "Authorization": `Bearer ${runtimeApiKey}`',` },`,` body: JSON.stringify(${JSON.stringify(f,null,2)})`,`});`].join(`
|
|
231
|
-
`);return(0,W.jsxs)(FC,{title:`调用 Agent`,subtitle:`使用统一 Runtime 的 OpenAI Responses API;本地与云端请求体一致。`,onClose:r,children:[(0,W.jsxs)(`div`,{className:`callout`,children:[(0,W.jsx)(Be,{size:16}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`标准接入协议`}),(0,W.jsx)(`p`,{children:`本地 Studio 仅监听 loopback;部署后由云端网关校验 Runtime API Key,不暴露 Studio Session 或 CSRF Token。`})]})]}),(0,W.jsxs)(`div`,{className:`code-tabs`,children:[(0,W.jsx)(`button`,{className:i===`curl`?`active`:``,type:`button`,onClick:()=>a(`curl`),children:`cURL`}),(0,W.jsx)(`button`,{className:i===`javascript`?`active`:``,type:`button`,onClick:()=>a(`javascript`),children:`JavaScript`})]}),(0,W.jsx)(Lg,{code:p,language:i===`curl`?`bash`:`javascript`,filename:i===`curl`?`invoke-agent.sh`:`invoke-agent.js`,wrap:!0}),(0,W.jsxs)(`div`,{className:`api-contract`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`Endpoint`}),(0,W.jsx)(`code`,{children:`POST /v1/responses`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`本地 Build`}),(0,W.jsx)(`code`,{children:n||`尚未构建`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`Conversation`}),(0,W.jsx)(`code`,{children:`首次调用可省略`})]})]})]})}function HF({agentId:e,onBack:t,onChat:n,onBuild:r,onEdit:i,onChanged:a}){let[o,c]=(0,s.useState)(null),[l,u]=(0,s.useState)([]),[d,p]=(0,s.useState)(!1),[m,h]=(0,s.useState)(!1),[g,_]=(0,s.useState)(!1),[v,y]=(0,s.useState)(``);(0,s.useEffect)(()=>{f(`/api/v1/agents/${encodeURIComponent(e)}`).then(e=>e.json()).then(c).catch(()=>c(null)),f(`/api/v1/catalog/resources?limit=200`).then(e=>e.json()).then(e=>u(e.items||[])).catch(()=>{})},[e]);async function b(){_(!0),y(``);try{let n=await f(`/api/v1/agents/${encodeURIComponent(e)}`,{method:`DELETE`});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error?.message||`删除失败(${n.status})`)}p(!1),a(),t()}catch(e){y(e.message)}finally{_(!1)}}if(!o)return(0,W.jsx)(`div`,{className:`page-container`,"data-layout":`document`,children:(0,W.jsx)(`p`,{style:{color:`var(--text-tertiary)`},children:`正在加载 Agent 配置…`})});let x=o.draft,S=x.spec.bindings||{},C=x.metadata.labels||{},w=String(C[`agentkit.ksyun.com/models`]||``).split(`,`).map(e=>e.trim()).filter(Boolean),E=S.modelProfileIds?.length?S.modelProfileIds:S.modelProfileId?[S.modelProfileId]:w.length?w:C[`agentkit.ksyun.com/model`]?[C[`agentkit.ksyun.com/model`]]:[],D=(o.builds||[]).find(e=>e.status===`SUCCEEDED`),O=C[`agentkit.ksyun.com/template`]||`blank`,k=e=>l.find(t=>t.resourceId===e)?.displayName||BF(e),A=(S.tools||[]).map(e=>typeof e==`string`?e:e.resourceId),M=[[`Model`,E],[`Skill`,(S.skills||[]).map(e=>e.resourceId)],[`MCP`,(S.mcpServers||[]).map(e=>e.resourceId)],[`Tool`,A]];return(0,W.jsxs)(`div`,{className:`page-container`,"data-layout":`document`,children:[(0,W.jsxs)(`header`,{className:`page-header detail-header`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`button`,{className:`button tertiary compact`,type:`button`,onClick:t,children:[(0,W.jsx)(T,{size:15}),(0,W.jsx)(`span`,{children:`Agent`})]}),(0,W.jsxs)(`div`,{className:`detail-title-row`,children:[(0,W.jsx)(nt,{name:x.metadata.name,appearance:x.metadata.appearance,template:O,size:`lg`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{children:x.metadata.name}),(0,W.jsxs)(`p`,{children:[x.metadata.id,` · revision `,x.metadata.revision]})]})]})]}),(0,W.jsxs)(`div`,{className:`header-actions`,children:[(0,W.jsxs)(`button`,{className:`button secondary`,type:`button`,onClick:()=>i(e),children:[(0,W.jsx)(Ue,{size:15}),(0,W.jsx)(`span`,{children:`编辑`})]}),(0,W.jsxs)(`button`,{className:`button secondary`,type:`button`,onClick:()=>h(!0),children:[(0,W.jsx)(U,{size:15}),(0,W.jsx)(`span`,{children:`调用方式`})]}),(0,W.jsxs)(`button`,{className:`button secondary`,type:`button`,onClick:r,children:[(0,W.jsx)(Ee,{size:15}),(0,W.jsx)(`span`,{children:`构建`})]}),(0,W.jsxs)(`button`,{className:`button accent`,type:`button`,onClick:()=>n(e),children:[(0,W.jsx)(xe,{size:15}),(0,W.jsx)(`span`,{children:`打开会话`})]}),(0,W.jsxs)(`button`,{className:`button danger`,type:`button`,onClick:()=>p(!0),children:[(0,W.jsx)(Ye,{size:15}),(0,W.jsx)(`span`,{children:`删除`})]})]})]}),v&&(0,W.jsx)(`div`,{className:`form-error`,style:{marginBottom:16},children:v}),(0,W.jsxs)(`div`,{className:`detail-layout`,children:[(0,W.jsxs)(`div`,{className:`detail-main`,children:[(0,W.jsxs)(`section`,{className:`detail-section`,children:[(0,W.jsx)(`div`,{className:`section-heading`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{children:`角色与任务`}),(0,W.jsx)(`p`,{children:`运行时注入的系统提示词和任务契约`})]})}),(0,W.jsxs)(`div`,{className:`readonly-field`,children:[(0,W.jsx)(`span`,{children:`系统提示词`}),(0,W.jsx)(`pre`,{children:x.spec.instructions?.system||``})]}),(0,W.jsxs)(`div`,{className:`readonly-field`,children:[(0,W.jsx)(`span`,{children:`任务契约`}),(0,W.jsx)(`pre`,{children:x.spec.instructions?.task||`未配置任务契约`})]})]}),(0,W.jsxs)(`section`,{className:`detail-section`,children:[(0,W.jsx)(`div`,{className:`section-heading`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{children:`能力绑定`}),(0,W.jsx)(`p`,{children:`构建时锁定版本和内容摘要`})]})}),(0,W.jsx)(`div`,{className:`binding-groups`,children:M.map(([e,t])=>(0,W.jsxs)(`div`,{className:`binding-group`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsx)(`div`,{className:`binding-items`,children:t.length?t.map(e=>(0,W.jsxs)(`span`,{className:`compact-resource`,children:[(0,W.jsx)(j,{size:13}),k(e)]},e)):(0,W.jsx)(`span`,{className:`compact-resource`,children:`未绑定`})})]},e))})]})]}),(0,W.jsxs)(`aside`,{className:`detail-aside`,children:[(0,W.jsx)(`div`,{className:`aside-title`,children:`运行摘要`}),(0,W.jsxs)(`dl`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Revision`}),(0,W.jsxs)(`dd`,{children:[`r`,x.metadata.revision]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Runtime`}),(0,W.jsx)(`dd`,{children:x.spec.runtime?.type||C[`agentkit.ksyun.com/framework`]||`adk`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`策略`}),(0,W.jsx)(`dd`,{children:x.spec.execution?.strategy||`-`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`最大步骤`}),(0,W.jsx)(`dd`,{children:x.spec.execution?.maxSteps??`-`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`超时`}),(0,W.jsx)(`dd`,{children:x.spec.execution?.timeoutSeconds?`${x.spec.execution.timeoutSeconds}s`:`-`})]})]}),(0,W.jsx)(`div`,{className:`aside-divider`}),(0,W.jsx)(`div`,{className:`build-state`,children:D?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`status-dot success`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`Bundle 已就绪`}),(0,W.jsx)(`span`,{children:BF(D.bundleDigest||D.id)})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`status-dot neutral`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`尚未构建`}),(0,W.jsx)(`span`,{children:`创建 Bundle 后即可对话`})]})]})})]})]}),d&&(0,W.jsx)(ca,{title:`确认删除 Agent「${x.metadata.name}」?`,description:`Agent ID:${x.metadata.id}。删除后其配置与 Revision 将移除,此操作不可撤销。`,confirmText:`确认删除`,busy:g,onConfirm:b,onCancel:()=>p(!1)}),m&&(0,W.jsx)(VF,{detail:o,catalog:l,buildId:D?.id,onClose:()=>h(!1)})]})}var UF=new Set([`SUCCEEDED`,`FAILED`,`CANCELLED`,`TIMED_OUT`]);async function WF(e){let t=await f(`/api/v1${e}`);return t.ok?(await t.text()).split(`
|
|
232
|
-
|
|
233
|
-
`).filter(Boolean).map(e=>{let t=e.split(`
|
|
234
|
-
`).find(e=>e.startsWith(`data:`));if(!t)return null;try{return JSON.parse(t.slice(5).trim())}catch{return null}}).filter(Boolean):[]}function GF(e,t=36){return e?e.length<=t?e:`${e.slice(0,t)}…`:`-`}function KF({currentAgentId:e,agents:t,onSelectAgent:n,onCreate:r}){let[i,a]=(0,s.useState)(null),[o,c]=(0,s.useState)(`IDLE`),[l,u]=(0,s.useState)(`选择 Agent 后开始本地构建。`),[d,p]=(0,s.useState)(`等待构建`),[m,h]=(0,s.useState)(!1),g=(0,s.useRef)(null),_=(0,s.useRef)(0),v=(0,s.useCallback)(async()=>{if(!e){a(null);return}try{let t=await f(`/api/v1/agents/${encodeURIComponent(e)}`);if(!t.ok)throw Error();a(await t.json())}catch{a(null)}},[e]);(0,s.useEffect)(()=>{v()},[v]);let y=i?.draft,b=i?.builds||[],x=b.find(e=>e.status===`SUCCEEDED`)||b[0]||null;(0,s.useEffect)(()=>{if(!m){if(!y){c(`IDLE`),u(`选择 Agent 后开始本地构建。`),p(`等待构建`);return}c(x?.status||`IDLE`),u(x?[`Build ${x.id||`-`}`,`Agent ${x.agentId||`-`}`,`Revision ${x.sourceRevision??`-`}`,`Resolved ${x.resolvedDigest||`-`}`,`Bundle ${x.bundleDigest||`-`}`,`Status ${x.status||`-`}`].join(`
|
|
235
|
-
`):`选择 Agent 后开始本地构建。`)}},[i,m]);function S(e){u(t=>t+e),requestAnimationFrame(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)})}async function C(){if(!y||m)return;let e=++_.current;h(!0),u(`提交本地构建...
|
|
236
|
-
`),c(`QUEUED`),p(`提交中`);try{let t=await f(`/api/v1/agents/${encodeURIComponent(y.metadata.id)}/builds`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":`build-${y.metadata.id}-r${y.metadata.revision}-${Date.now()}`},body:JSON.stringify({revision:y.metadata.revision,runEvaluation:!1})});if(!t.ok){let e=await t.text().catch(()=>``),n=`构建提交失败(${t.status})`;try{n=JSON.parse(e)?.error?.message||n}catch{}throw Error(n)}let n=await t.json();p(n.id);let r=0,i=null;for(let t=0;t<1200;t+=1){if(_.current!==e)return;let t=await WF(`/operations/${encodeURIComponent(n.id)}/events?after=${r}`);t.length&&(r=Math.max(r,...t.map(e=>Number(e.id)||0)),S(t.map(e=>`${String(e.id).padStart(2,`0`)} ${e.type}`).join(`
|
|
237
|
-
`)+`
|
|
238
|
-
`));let a=await f(`/api/v1/operations/${encodeURIComponent(n.id)}`).then(e=>e.json());if(c(a.status||`QUEUED`),UF.has(a.status)){i=a;break}await new Promise(e=>setTimeout(e,200))}if(!i)throw Error(`操作等待超时`);if(i.status!==`SUCCEEDED`)throw Error(i.error?.message||`构建未完成`);let a=await f(`/api/v1/builds/${encodeURIComponent(i.resourceId)}`).then(e=>e.json());await v(),Cm(`${y.spec?.runtime?.type||`Agent`} Bundle 构建完成`,GF(a.bundleDigest||``))}catch(t){_.current===e&&(c(`FAILED`),S(`\n${t.message}\n`),Cm(`构建失败`,t.message,`error`))}finally{_.current===e&&h(!1)}}let w=x?.runtimeName?`${x.runtimeName} ${x.runtimeVersion||``}`.trim():y?.spec?.runtime?.type||`未选择`;return(0,W.jsxs)(`div`,{className:`page-container`,"data-layout":`data`,"data-scroll-mode":`data`,children:[(0,W.jsxs)(`header`,{className:`page-header`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{children:`构建`}),(0,W.jsx)(`p`,{children:`将 Agent Draft 解析为不可变、可追溯的 AgentBundle。`})]}),(0,W.jsxs)(`button`,{className:`button accent`,type:`button`,onClick:C,disabled:!y||m,children:[(0,W.jsx)(Ee,{size:15}),(0,W.jsx)(`span`,{children:m?`构建中`:`构建当前 Agent`})]})]}),(0,W.jsxs)(`div`,{className:`data-page-body`,children:[t.length===0&&(0,W.jsxs)(`div`,{className:`empty-state`,children:[(0,W.jsx)(`span`,{className:`empty-icon`,children:(0,W.jsx)(Ee,{size:24})}),(0,W.jsx)(`h2`,{children:`还没有可构建的 Agent`}),(0,W.jsx)(`p`,{children:`先创建一个 Agent,再来构建与运行。`}),(0,W.jsxs)(`button`,{className:`button accent`,type:`button`,onClick:r,children:[(0,W.jsx)(Pe,{size:15}),(0,W.jsx)(`span`,{children:`创建 Agent`})]})]}),(0,W.jsxs)(`div`,{className:`build-workspace`,children:[(0,W.jsxs)(`div`,{className:`build-summary`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`当前 Agent`}),(0,W.jsx)(`strong`,{children:y?.metadata?.name||`未选择`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`Revision`}),(0,W.jsx)(`strong`,{children:y?`r${y.metadata.revision}`:`-`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`状态`}),(0,W.jsx)(`strong`,{children:(0,W.jsx)(`span`,{className:`status-badge ${o}`,children:o})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`Bundle`}),(0,W.jsx)(`strong`,{className:`mono truncate`,children:x?.bundleDigest||`-`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`Source SHA`}),(0,W.jsx)(`strong`,{className:`mono truncate`,children:x?.manifestSha256||x?.sourceDigest||x?.resolvedDigest||`-`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`Runtime`}),(0,W.jsx)(`strong`,{children:w})]})]}),(0,W.jsxs)(`div`,{className:`build-log`,children:[(0,W.jsxs)(`div`,{className:`log-header`,children:[(0,W.jsx)(`span`,{children:`构建事件`}),(0,W.jsx)(`span`,{children:d})]}),(0,W.jsx)(`pre`,{ref:g,children:l})]})]})]})]})}function qF({onCreate:e}){return(0,W.jsxs)(`div`,{className:`page-container`,"data-layout":`data`,"data-scroll-mode":`data`,children:[(0,W.jsx)(`header`,{className:`page-header`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{children:`部署`}),(0,W.jsx)(`p`,{children:`把本地生成的同一 AgentBundle 发布至云端运行环境。`})]})}),(0,W.jsx)(`div`,{className:`data-page-body`,children:(0,W.jsxs)(`div`,{className:`empty-page-state`,children:[(0,W.jsx)(`span`,{className:`empty-icon`,children:(0,W.jsx)(V,{size:24})}),(0,W.jsx)(`h2`,{children:`选择已构建的 AgentBundle`}),(0,W.jsx)(`p`,{children:`从 Agent 详情或构建页面发起部署,云端仅注入环境绑定,不重新构建。`})]})})]})}var JF=e=>typeof e==`boolean`||e instanceof Boolean,YF=e=>typeof e==`number`||e instanceof Number,XF=e=>typeof e==`bigint`||e instanceof BigInt,ZF=e=>!!e&&e instanceof Date,QF=e=>typeof e==`string`||e instanceof String,$F=e=>Array.isArray(e),eI=e=>typeof e==`object`&&!!e,tI=e=>!!e&&e instanceof Object&&typeof e==`function`;function nI(e,t){return t===void 0&&(t=!1),!e||t?`"${e}"`:e}function rI(e,t,n){return n?JSON.stringify(e):t?`"${e}"`:e}function iI(e){let{field:t,value:n,data:r,lastElement:i,openBracket:a,closeBracket:o,level:c,style:l,shouldExpandNode:u,clickToExpandNode:d,outerRef:f,beforeExpandChange:p}=e,m=(0,s.useRef)(!1),[h,g]=(0,s.useState)(()=>u(c,n,t)),_=(0,s.useRef)(null);(0,s.useEffect)(()=>{m.current?g(u(c,n,t)):m.current=!0},[u]);let v=(0,s.useId)();if(r.length===0)return aI({field:t,openBracket:a,closeBracket:o,lastElement:i,style:l});let y=h?l.collapseIcon:l.expandIcon,b=h?l.ariaLables.collapseJson:l.ariaLables.expandJson,x=c+1,S=r.length-1,C=e=>{h!==e&&(!p||p({level:c,value:n,field:t,newExpandValue:e}))&&g(e)},w=e=>{if(e.key===`ArrowRight`||e.key===`ArrowLeft`)e.preventDefault(),C(e.key===`ArrowRight`);else if(e.key===`ArrowUp`||e.key===`ArrowDown`){e.preventDefault();let t=e.key===`ArrowUp`?-1:1;if(!f.current)return;let n=f.current.querySelectorAll(`[role=button]`),r=-1;for(let e=0;e<n.length;e++)if(n[e].tabIndex===0){r=e;break}if(r<0)return;let i=(r+t+n.length)%n.length;n[r].tabIndex=-1,n[i].tabIndex=0,n[i].focus()}},T=()=>{C(!h);let e=_.current;if(!e)return;let t=f.current?.querySelector(`[role=button][tabindex="0"]`);t&&(t.tabIndex=-1),e.tabIndex=0,e.focus()};return(0,s.createElement)(`div`,{className:l.basicChildStyle,role:`treeitem`,"aria-expanded":h,"aria-selected":void 0},(0,s.createElement)(`span`,{className:y,onClick:T,onKeyDown:w,role:`button`,"aria-label":b,"aria-expanded":h,"aria-controls":h?v:void 0,ref:_,tabIndex:c===0?0:-1}),(t||t===``)&&(d?(0,s.createElement)(`span`,{className:l.clickableLabel,onClick:T,onKeyDown:w},nI(t,l.quotesForFieldNames),`:`):(0,s.createElement)(`span`,{className:l.label},nI(t,l.quotesForFieldNames),`:`)),(0,s.createElement)(`span`,{className:l.punctuation},a),h?(0,s.createElement)(`ul`,{id:v,role:`group`,className:l.childFieldsContainer},r.map((e,t)=>(0,s.createElement)(lI,{key:e[0]||t,field:e[0],value:e[1],style:l,lastElement:t===S,level:x,shouldExpandNode:u,clickToExpandNode:d,beforeExpandChange:p,outerRef:f}))):(0,s.createElement)(`span`,{className:l.collapsedContent,onClick:T,onKeyDown:w}),(0,s.createElement)(`span`,{className:l.punctuation},o),!i&&(0,s.createElement)(`span`,{className:l.punctuation},`,`))}function aI(e){let{field:t,openBracket:n,closeBracket:r,lastElement:i,style:a}=e;return(0,s.createElement)(`div`,{className:a.basicChildStyle,role:`treeitem`,"aria-selected":void 0},(t||t===``)&&(0,s.createElement)(`span`,{className:a.label},nI(t,a.quotesForFieldNames),`:`),(0,s.createElement)(`span`,{className:a.punctuation},n),(0,s.createElement)(`span`,{className:a.punctuation},r),!i&&(0,s.createElement)(`span`,{className:a.punctuation},`,`))}function oI(e){let{field:t,value:n,style:r,lastElement:i,shouldExpandNode:a,clickToExpandNode:o,level:s,outerRef:c,beforeExpandChange:l}=e;return iI({field:t,value:n,lastElement:i||!1,level:s,openBracket:`{`,closeBracket:`}`,style:r,shouldExpandNode:a,clickToExpandNode:o,data:Object.keys(n).map(e=>[e,n[e]]),outerRef:c,beforeExpandChange:l})}function sI(e){let{field:t,value:n,style:r,lastElement:i,level:a,shouldExpandNode:o,clickToExpandNode:s,outerRef:c,beforeExpandChange:l}=e;return iI({field:t,value:n,lastElement:i||!1,level:a,openBracket:`[`,closeBracket:`]`,style:r,shouldExpandNode:o,clickToExpandNode:s,data:n.map(e=>[void 0,e]),outerRef:c,beforeExpandChange:l})}function cI(e){let{field:t,value:n,style:r,lastElement:i}=e,a,o=r.otherValue;return n===null?(a=`null`,o=r.nullValue):n===void 0?(a=`undefined`,o=r.undefinedValue):QF(n)?(a=rI(n,!r.noQuotesForStringValues,r.stringifyStringValues),o=r.stringValue):JF(n)?(a=n?`true`:`false`,o=r.booleanValue):YF(n)?(a=n.toString(),o=r.numberValue):XF(n)?(a=`${n.toString()}n`,o=r.numberValue):a=ZF(n)?n.toISOString():tI(n)?`function() { }`:n.toString(),(0,s.createElement)(`div`,{className:r.basicChildStyle,role:`treeitem`,"aria-selected":void 0},(t||t===``)&&(0,s.createElement)(`span`,{className:r.label},nI(t,r.quotesForFieldNames),`:`),(0,s.createElement)(`span`,{className:o},a),!i&&(0,s.createElement)(`span`,{className:r.punctuation},`,`))}function lI(e){let t=e.value;return $F(t)?(0,s.createElement)(sI,Object.assign({},e)):eI(t)&&!ZF(t)&&!tI(t)?(0,s.createElement)(oI,Object.assign({},e)):(0,s.createElement)(cI,Object.assign({},e))}var uI={"container-base":`_GzYRV`,"punctuation-base":`_3eOF8`,pointer:`_1MFti`,"expander-base":`_f10Tu _1MFti`,"expand-icon":`_1UmXx`,"collapse-icon":`_1LId0`,"collapsed-content-base":`_1pNG9 _1MFti`,"container-light":`_2IvMF _GzYRV`,"basic-element-style":`_2bkNM`,"child-fields-container":`_1BXBN`,"label-light":`_1MGIk`,"clickable-label-light":`_2YKJg _1MGIk _1MFti`,"punctuation-light":`_3uHL6 _3eOF8`,"value-null-light":`_2T6PJ`,"value-undefined-light":`_1Gho6`,"value-string-light":`_vGjyY`,"value-number-light":`_1bQdo`,"value-boolean-light":`_3zQKs`,"value-other-light":`_1xvuR`,"collapse-icon-light":`_oLqym _f10Tu _1MFti _1LId0`,"expand-icon-light":`_2AXVT _f10Tu _1MFti _1UmXx`,"collapsed-content-light":`_2KJWg _1pNG9 _1MFti`,"container-dark":`_11RoI _GzYRV`,"expand-icon-dark":`_17H2C _f10Tu _1MFti _1UmXx`,"collapse-icon-dark":`_3QHg2 _f10Tu _1MFti _1LId0`,"collapsed-content-dark":`_3fDAz _1pNG9 _1MFti`,"label-dark":`_2bSDX`,"clickable-label-dark":`_1RQEj _2bSDX _1MFti`,"punctuation-dark":`_gsbQL _3eOF8`,"value-null-dark":`_LaAZe`,"value-undefined-dark":`_GTKgm`,"value-string-dark":`_Chy1W`,"value-number-dark":`_2bveF`,"value-boolean-dark":`_2vRm-`,"value-other-dark":`_1prJR`},dI={container:uI[`container-light`],basicChildStyle:uI[`basic-element-style`],childFieldsContainer:uI[`child-fields-container`],label:uI[`label-light`],clickableLabel:uI[`clickable-label-light`],nullValue:uI[`value-null-light`],undefinedValue:uI[`value-undefined-light`],stringValue:uI[`value-string-light`],booleanValue:uI[`value-boolean-light`],numberValue:uI[`value-number-light`],otherValue:uI[`value-other-light`],punctuation:uI[`punctuation-light`],collapseIcon:uI[`collapse-icon-light`],expandIcon:uI[`expand-icon-light`],collapsedContent:uI[`collapsed-content-light`],noQuotesForStringValues:!1,quotesForFieldNames:!1,ariaLables:{collapseJson:`collapse JSON`,expandJson:`expand JSON`},stringifyStringValues:!1};uI[`container-dark`],uI[`basic-element-style`],uI[`child-fields-container`],uI[`label-dark`],uI[`clickable-label-dark`],uI[`value-null-dark`],uI[`value-undefined-dark`],uI[`value-string-dark`],uI[`value-boolean-dark`],uI[`value-number-dark`],uI[`value-other-dark`],uI[`punctuation-dark`],uI[`collapse-icon-dark`],uI[`expand-icon-dark`],uI[`collapsed-content-dark`];var fI=()=>!0,pI=e=>e<1,mI=e=>{let{data:t,style:n=dI,shouldExpandNode:r=fI,clickToExpandNode:i=!1,beforeExpandChange:a,compactTopLevel:o,...c}=e,l=(0,s.useRef)(null);return(0,s.createElement)(`div`,Object.assign({"aria-label":`JSON view`},c,{className:n.container,ref:l,role:`tree`}),o&&eI(t)?Object.entries(t).map(e=>{let[t,o]=e;return(0,s.createElement)(lI,{key:t,field:t,value:o,style:{...dI,...n},lastElement:!0,level:1,shouldExpandNode:r,clickToExpandNode:i,beforeExpandChange:a,outerRef:l})}):(0,s.createElement)(lI,{value:t,style:{...dI,...n},lastElement:!0,level:0,shouldExpandNode:r,clickToExpandNode:i,outerRef:l,beforeExpandChange:a}))};function hI(e,t=18){let n=String(e||``);return n.length>t?`${n.slice(0,t)}…`:n}function gI(e,t=`-`){return e==null||e===``?t:String(e)}function _I(e){if(e==null||Number.isNaN(Number(e)))return`未上报`;let t=Number(e);return t<1?`${t.toFixed(3)} ms`:t<1e3?`${Math.round(t)} ms`:`${(t/1e3).toFixed(t<1e4?2:1)} s`}function vI(e){return e==null?`未上报`:new Intl.NumberFormat(`zh-CN`).format(Number(e))}function yI(e){try{let t=Number(BigInt(String(e||`0`))/1000000n);return t?new Date(t).toISOString():`-`}catch{return`-`}}function bI(e){if(!e)return`刚刚`;let t=new Date(e);return Number.isNaN(t.getTime())?`未知时间`:new Intl.DateTimeFormat(`zh-CN`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}).format(t)}function xI(e){try{return JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t,2)}catch{return String(e)}}function SI(e){return e==null?`-`:typeof e==`object`?xI(e):String(e)}var CI={container:`otlp-json`,childFieldsContainer:`otlp-json-children`,basicChildStyle:`otlp-json-row`,collapseIcon:`otlp-json-toggle otlp-json-collapse`,expandIcon:`otlp-json-toggle otlp-json-expand`,collapsedContent:`otlp-json-collapsed`,label:`otlp-json-key`,clickableLabel:`otlp-json-key otlp-json-key-clickable`,nullValue:`otlp-json-null`,undefinedValue:`otlp-json-null`,numberValue:`otlp-json-number`,stringValue:`otlp-json-string`,booleanValue:`otlp-json-boolean`,otherValue:`otlp-json-other`,punctuation:`otlp-json-punctuation`,quotesForFieldNames:!0,stringifyStringValues:!0,ariaLables:{collapseJson:`收起 JSON 节点`,expandJson:`展开 JSON 节点`}},wI=[`agentkit.event.text`,`agentkit.event.delta`,`agentkit.event.content`,`agentkit.event.output`,`agentkit.event.args`,`agentkit.event.command`,`agentkit.event.input`,`agentkit.event.prompt`];function TI(e){if(!e)return``;for(let t of wI){let n=e[t];if(typeof n==`string`&&n.trim())return n;if(typeof n==`number`||typeof n==`boolean`)return String(n)}return``}function EI(e){let t=[],n=``,r=null,i=0,a=(e=!1)=>{r&&n.trim()&&t.push({kind:r,text:n,segments:i,final:e}),n=``,i=0},o={};for(let t of e||[]){let e=TI(t.attributes);if(t.name===`thinking.delta`||t.name===`message.delta`){let o=t.name===`thinking.delta`?`thinking`:`message`;r!==o&&(a(),r=o),n+=e,i+=1}else if(t.name===`thinking.completed`||t.name===`message.completed`){let n=t.name===`thinking.completed`?`thinking`:`message`;e&&(o[n]=e)}}a();for(let e of[`thinking`,`message`]){let n=o[e];if(!n)continue;let r=t.findIndex(t=>t.kind===e);r>=0?t[r]={kind:e,text:n,segments:t[r].segments,final:!0}:t.push({kind:e,text:n,segments:1,final:!0})}return t}async function DI(e){try{await navigator.clipboard.writeText(e);return}catch{}let t=document.createElement(`textarea`);t.value=e,document.body.appendChild(t),t.select();try{document.execCommand(`copy`)}catch{}t.remove()}function OI({text:e,className:t}){let[n,r]=(0,s.useState)(!1);return(0,W.jsx)(`button`,{type:`button`,className:`copy-btn ${t||``}`,title:`复制`,onClick:t=>{t.stopPropagation(),DI(e),r(!0),setTimeout(()=>r(!1),1500)},children:n?(0,W.jsx)(j,{size:12,style:{color:`var(--success)`}}):(0,W.jsx)(te,{size:12})})}function kI({label:e,text:t,tone:n,icon:r,meta:i}){let[a,o]=(0,s.useState)(!1),c=t.length>600,l=a||!c?t:`${t.slice(0,600)}…`;return(0,W.jsxs)(`div`,{className:`io-block io-${n}`,children:[(0,W.jsxs)(`div`,{className:`io-head`,children:[(0,W.jsxs)(`span`,{className:`io-label`,children:[r,e]}),i&&(0,W.jsx)(`span`,{className:`io-meta`,children:i}),(0,W.jsx)(`span`,{style:{flex:1}}),(0,W.jsx)(OI,{text:t,className:`copy-visible`})]}),(0,W.jsx)(`div`,{className:`io-text`,children:l}),c&&(0,W.jsx)(`button`,{type:`button`,className:`io-expand`,onClick:()=>o(!a),children:a?`收起`:`展开全文(${t.length} 字符)`})]})}function AI({span:e}){let t=e.attributes||{},n=t[`agentkit.tool.input`],r=t[`agentkit.tool.output`],i=EI(e.events||[]);return n!=null&&n!==``||r!=null&&r!==``||i.length>0?(0,W.jsxs)(`div`,{className:`io-stack`,children:[n!=null&&n!==``&&(0,W.jsx)(kI,{label:`工具输入`,text:SI(n),tone:`tool`}),r!=null&&r!==``&&(0,W.jsx)(kI,{label:`工具输出`,text:SI(r),tone:`tool`}),i.map((e,t)=>(0,W.jsx)(kI,{label:e.kind===`message`?`模型输出`:`思考过程`,text:e.text,tone:e.kind,icon:e.kind===`message`?(0,W.jsx)(be,{size:12}):(0,W.jsx)(A,{size:12}),meta:e.final?`完整`:`${e.segments} 段增量`},t))]}):(0,W.jsx)(`div`,{className:`trace-stage-empty compact`,children:(0,W.jsx)(`p`,{children:`该 Span 没有捕获内容(可在 设置 → 可观测 开启 Trace 内容记录)。`})})}function jI({values:e}){let t=Object.entries(e||{}).sort(([e],[t])=>e.localeCompare(t));return t.length?(0,W.jsx)(`dl`,{className:`trace-kv-list`,children:t.map(([e,t])=>(0,W.jsxs)(`div`,{className:`trace-kv-row`,children:[(0,W.jsx)(`dt`,{className:`trace-kv-key`,children:e}),(0,W.jsx)(`dd`,{className:`trace-kv-value`,children:SI(t)}),(0,W.jsx)(OI,{text:SI(t),className:`trace-kv-copy`})]},e))}):(0,W.jsx)(`div`,{className:`trace-stage-empty compact`,children:(0,W.jsx)(`p`,{children:`没有可展示的字段。`})})}var MI=[{id:`summary`,label:`概览`},{id:`attributes`,label:`Attributes`},{id:`events`,label:`Events`},{id:`resource`,label:`Resource`},{id:`raw`,label:`Raw OTLP`}],NI=50;function PI({refreshTick:e}){let[t,n]=(0,s.useState)([]),[r,i]=(0,s.useState)([]),[a,o]=(0,s.useState)(``),[c,l]=(0,s.useState)(``),[u,d]=(0,s.useState)(``),[p,m]=(0,s.useState)(`24h`),[h,g]=(0,s.useState)(null),[_,v]=(0,s.useState)(null),[y,b]=(0,s.useState)(null),[x,S]=(0,s.useState)(`summary`),[C,E]=(0,s.useState)(null),[D,O]=(0,s.useState)(!1),[k,A]=(0,s.useState)(!0),[j,N]=(0,s.useState)(!1),[P,I]=(0,s.useState)(!1),[L,R]=(0,s.useState)(0),[z,B]=(0,s.useState)([null]),[V,H]=(0,s.useState)(null),[U,ee]=(0,s.useState)(0),[ne,re]=(0,s.useState)(!0),[ie,ae]=(0,s.useState)(``),oe=(0,s.useRef)(0),se=(0,s.useRef)(0);(0,s.useEffect)(()=>{f(`/api/v1/agents?limit=100`).then(e=>e.json()).then(e=>{i((e.items||[]).map(e=>({id:e.metadata.id,name:e.metadata.name,appearance:e.metadata.appearance})))}).catch(()=>{})},[e]);let ce=(0,s.useCallback)(async e=>{let t=++oe.current;try{let n=await f(`/api/v1/traces/${encodeURIComponent(e)}`).then(e=>e.json());if(oe.current!==t)return;v(n),b(n.rootSpanId||n.spans?.[0]?.spanId||null),S(`summary`),E(null),A(!0),N(!1),I(!1)}catch{}},[]),le=(0,s.useCallback)(async e=>{let t=++se.current,r=new URLSearchParams({limit:String(NI),sort:`startedAt:desc`});c&&r.set(`agentId`,c),u&&r.set(`status`,u),a.trim()&&r.set(`query`,a.trim()),e&&r.set(`cursor`,e),re(!0),ae(``);try{let e=await f(`/api/v1/traces?${r}`);if(!e.ok)throw Error(`Trace 列表加载失败(${e.status})`);let i=await e.json();if(se.current!==t)return;let a=i.items||[];n(a),H(i.nextCursor||null),ee(Number(i.total)||0)}catch(e){if(se.current!==t)return;n([]),H(null),ee(0),ae(e instanceof Error?e.message:`Trace 列表加载失败`)}finally{se.current===t&&re(!1)}},[c,a,u]);(0,s.useEffect)(()=>{B([null]),R(0),le(null)},[le,e]),(0,s.useEffect)(()=>{let e=new URLSearchParams({range:p});c&&e.set(`agentId`,c),u&&e.set(`status`,u),f(`/api/v1/traces/overview?${e}`).then(e=>e.ok?e.json():Promise.reject(Error())).then(g).catch(()=>g(null))},[c,p,e,u]),(0,s.useEffect)(()=>{if(x!==`raw`||!_||C)return;let e=_.traceId;O(!0),f(`/api/v1/traces/${encodeURIComponent(e)}/otlp`).then(e=>e.json()).then(e=>{E(e),O(!1)}).catch(()=>O(!1))},[x,_,C]);let ue=_?.spans?.find(e=>e.spanId===y)||null,de=(0,s.useMemo)(()=>{let e=_?.spans||[],t=new Map;e.forEach(e=>{let n=e.parentSpanId||``;t.has(n)||t.set(n,[]),t.get(n).push(e)}),t.forEach(e=>e.sort((e,t)=>{try{return Number(BigInt(e.startTimeUnixNano||`0`)-BigInt(t.startTimeUnixNano||`0`))}catch{return 0}}));let n=[],r=new Set,i=(e,a)=>{!e||r.has(e.spanId)||(r.add(e.spanId),n.push({span:e,depth:a}),(t.get(e.spanId)||[]).forEach(e=>i(e,a+1)))};return i(e.find(e=>e.spanId===_?.rootSpanId)||e.find(e=>!e.parentSpanId),0),e.forEach(e=>i(e,+!!e.parentSpanId)),n},[_]),fe=de.find(e=>e.span.spanId===_?.rootSpanId)?.span||de[0]?.span,pe=(0,s.useMemo)(()=>{if(!fe)return{start:0n,duration:1};try{let e=BigInt(fe.startTimeUnixNano||`0`),t=BigInt(fe.endTimeUnixNano||fe.startTimeUnixNano||`0`);return{start:e,duration:Number(t>e?t-e:1n)}}catch{return{start:0n,duration:1}}},[fe]),me=_?.metrics||{},he=r.find(e=>e.id===_?.agentId),ge=(0,s.useMemo)(()=>[{id:`status`,header:`状态`,width:130,cell:e=>(0,W.jsxs)(`span`,{className:`trace-table-status ${e.status}`,children:[(0,W.jsx)(`span`,{className:`trace-list-status ${e.status}`}),e.status]})},{id:`identity`,header:`Agent / Run`,minWidth:270,cell:e=>{let t=r.find(t=>t.id===e.agentId),n=t?.name||e.agentId||`unknown-agent`;return(0,W.jsxs)(`button`,{type:`button`,className:`trace-table-open trace-table-agent`,onClick:()=>ce(e.traceId),children:[(0,W.jsx)(nt,{name:n,appearance:t?.appearance,size:`xs`}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:n}),(0,W.jsx)(`small`,{children:hI(e.runId||e.traceId,32)})]})]})}},{id:`startedAt`,header:`开始时间`,minWidth:140,cell:e=>bI(e.startedAt)},{id:`duration`,header:`耗时`,width:110,cell:e=>_I(e.durationMs)},{id:`model`,header:`模型`,minWidth:140,cell:e=>e.model||`-`},{id:`tokens`,header:`Token`,width:110,cell:e=>e.usageReported?vI(e.totalTokens):`未上报`},{id:`spans`,header:`Span`,width:80,cell:e=>e.spanCount||0},{id:`actions`,header:(0,W.jsx)(`span`,{className:`sr-only`,children:`操作`}),width:110,className:`actions-column`,headerClassName:`actions-column`,cell:e=>(0,W.jsx)(`button`,{type:`button`,className:`button tertiary small`,onClick:()=>ce(e.traceId),children:`查看详情`})}],[r,ce]),_e=(0,s.useCallback)(()=>{if(_?.traceId){ce(_.traceId);return}le(z[L]||null)},[_?.traceId,z,L,le,ce]),ye=(0,s.useCallback)(()=>{if(L<=0)return;let e=L-1;R(e),le(z[e]||null)},[z,L,le]),be=(0,s.useCallback)(()=>{if(!V)return;let e=L+1;B(t=>{let n=t.slice(0,e);return n[e]=V,n}),R(e),le(V)},[L,le,V]);async function xe(){!_?.traceId||!_.rootSpanId||(await DI(`00-${_.traceId}-${_.rootSpanId}-01`),Cm(`traceparent 已复制`,hI(_.traceId,24)))}async function Ce(){if(!_)return;let e=C;e||(e=await f(`/api/v1/traces/${encodeURIComponent(_.traceId)}/otlp`).then(e=>e.json()).catch(()=>null),e&&E(e)),e&&(await DI(JSON.stringify(e,null,2)),Cm(`Raw OTLP 已复制`,hI(_.traceId,24)))}return(0,W.jsxs)(`div`,{className:`page-container observability-page`,id:`traceExplorer`,"data-layout":`data`,"data-scroll-mode":_?`workbench`:`data`,children:[(0,W.jsxs)(`header`,{className:`page-header trace-page-header`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{children:`Trace Explorer`}),(0,W.jsx)(`p`,{children:`基于 OpenTelemetry 检查 Agent、模型与 Tool 的完整调用链。`})]}),(0,W.jsxs)(`div`,{className:`header-actions`,children:[_&&(0,W.jsxs)(`button`,{className:`button tertiary`,type:`button`,onClick:()=>{oe.current+=1,v(null),b(null),N(!1),I(!1)},children:[(0,W.jsx)(T,{size:15}),(0,W.jsx)(`span`,{children:`返回 Trace 列表`})]}),(0,W.jsxs)(`button`,{className:`button secondary`,type:`button`,onClick:_e,children:[(0,W.jsx)(Fe,{size:15}),(0,W.jsx)(`span`,{children:`刷新`})]})]})]}),(0,W.jsxs)(`div`,{className:`data-page-body observability-body`,children:[(0,W.jsx)(FI,{overview:h,range:p,onRangeChange:m}),!_&&(0,W.jsxs)(`div`,{className:`trace-toolbar`,"aria-label":`Trace 筛选`,children:[(0,W.jsxs)(`div`,{className:`search-field trace-search-field`,children:[(0,W.jsx)(Ie,{size:14}),(0,W.jsx)(`input`,{type:`search`,placeholder:`搜索 Trace、Run 或 Session`,value:a,onChange:e=>o(e.target.value)})]}),(0,W.jsx)(Tf,{className:`compact-select`,ariaLabel:`按 Agent 筛选`,value:c||`__all__`,options:[{value:`__all__`,label:`全部 Agent`},...r.map(e=>({value:e.id,label:e.name}))],onValueChange:e=>l(e===`__all__`?``:e)}),(0,W.jsx)(Tf,{className:`compact-select`,ariaLabel:`按状态筛选`,value:u||`__all__`,options:[{value:`__all__`,label:`全部状态`},{value:`COMPLETED`,label:`成功`},{value:`FAILED`,label:`失败`},{value:`CANCELLED`,label:`已取消`}],onValueChange:e=>d(e===`__all__`?``:e)}),(0,W.jsx)(`span`,{className:`trace-standard-label`,children:`OTLP · W3C Trace Context`})]}),_&&(0,W.jsxs)(`section`,{className:`trace-metrics`,"aria-label":`Trace 指标`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`Trace 状态`}),(0,W.jsx)(`strong`,{children:_?.status||`未选择`}),(0,W.jsx)(`small`,{children:_?`${_.spans?.length||0} Span · ${_.target?.name||`本地工作区`}`:`选择一条 Trace 查看`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`总耗时`}),(0,W.jsx)(`strong`,{children:_?_I(me.durationMs):`未上报`}),(0,W.jsx)(`small`,{children:_?me.durationMs===null||me.durationMs===void 0?`Runtime 未上报`:me.durationSource===`runtime`?`Runtime 精确上报`:`Studio 时钟回退`:`等待 Runtime 上报`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`Token`}),(0,W.jsx)(`strong`,{children:_&&me.usageReported?vI(me.totalTokens):`未上报`}),(0,W.jsx)(`small`,{children:_&&me.usageReported?`${vI(me.inputTokens)} 输入 · ${vI(me.outputTokens)} 输出`:`输入 / 输出`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`模型`}),(0,W.jsx)(`strong`,{children:_?.model||`-`}),(0,W.jsx)(`small`,{children:_?`${_.runtimeType||`unknown`} · ${me.usageSource||`Usage 未上报`}`:`Runtime`})]})]}),!_&&(0,W.jsxs)(`section`,{className:`trace-list-page`,"aria-label":`Trace 列表`,children:[(0,W.jsxs)(`header`,{className:`trace-list-page-header`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`Traces`}),(0,W.jsxs)(`span`,{children:[`服务端游标分页 · 每页 `,NI,` 条`]})]}),(0,W.jsxs)(`span`,{children:[U,` 条结果`]})]}),(0,W.jsx)(rc,{columns:ge,data:t,getRowId:e=>e.traceId,caption:`Trace 列表`,minWidth:1060,loading:ne,error:ie,onRetry:_e,onRowActivate:e=>ce(e.traceId),rowAriaLabel:e=>`${e.agentId||`Agent`} ${e.runId||e.traceId}`,empty:{icon:(0,W.jsx)(w,{size:20}),title:`还没有 Trace`,description:`运行一次 Agent 后在这里查看调用链,或调整筛选条件。`},pagination:{pageIndex:L,pageSize:NI,total:U,hasNextPage:!!V,onPreviousPage:ye,onNextPage:be}})]}),_&&(0,W.jsxs)(`div`,{className:`trace-workbench detail-route${j?` detail-expanded`:``}${P?` detail-collapsed`:``}`,children:[(0,W.jsxs)(`section`,{className:`trace-span-panel`,"aria-label":`Span 时间瀑布`,children:[(0,W.jsxs)(`div`,{className:`trace-panel-header trace-span-header`,children:[(0,W.jsx)(nt,{name:he?.name||_.agentId||`Agent`,appearance:he?.appearance,size:`sm`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:_?`${he?.name||_.agentId||`Agent`} · ${_.runId||`Run`}`:`选择一条 Trace`}),(0,W.jsx)(`span`,{className:`mono`,children:_?.traceId||`-`})]}),(0,W.jsxs)(`button`,{className:`button tertiary small`,type:`button`,disabled:!_,onClick:xe,children:[(0,W.jsx)(te,{size:14}),(0,W.jsx)(`span`,{children:`复制 traceparent`})]}),P&&(0,W.jsxs)(`button`,{className:`button secondary small trace-detail-reopen`,type:`button`,onClick:()=>I(!1),children:[(0,W.jsx)(F,{size:14}),(0,W.jsx)(`span`,{children:`展开详情`})]})]}),(0,W.jsxs)(`div`,{className:`trace-axis`,"aria-hidden":`true`,children:[(0,W.jsx)(`span`,{children:`Span`}),(0,W.jsx)(`span`,{children:`0%`}),(0,W.jsx)(`span`,{children:`50%`}),(0,W.jsx)(`span`,{children:`100%`}),(0,W.jsx)(`span`,{children:`耗时`})]}),(0,W.jsx)(`div`,{className:`trace-span-tree`,children:de.length===0?(0,W.jsxs)(`div`,{className:`trace-stage-empty`,children:[(0,W.jsx)(Te,{size:20}),(0,W.jsx)(`p`,{children:_?`该 OTLP Trace 没有 Span。`:`选择左侧 Trace,查看 Agent、模型和 Tool 的父子关系与耗时。`})]}):de.map(({span:e,depth:t})=>{let n=0,r=0;try{let t=BigInt(e.startTimeUnixNano||`0`),i=BigInt(e.endTimeUnixNano||e.startTimeUnixNano||`0`);n=Math.max(0,Math.min(100,Number(t-pe.start)/pe.duration*100)),r=Math.max(0,Math.min(100-n,Number(i-t)/pe.duration*100))}catch{}return(0,W.jsxs)(`button`,{type:`button`,className:`trace-span-row${e.spanId===y?` active`:``}`,"data-kind":e.kind,"data-status":e.status,onClick:()=>{b(e.spanId),S(`summary`)},children:[(0,W.jsxs)(`span`,{className:`trace-span-name`,children:[(0,W.jsx)(`span`,{className:`trace-span-guides`,children:Array.from({length:t},(e,t)=>(0,W.jsx)(`span`,{className:`trace-span-guide`},t))}),(0,W.jsx)(`span`,{className:`trace-span-status ${e.status}`}),(0,W.jsxs)(`span`,{className:`trace-span-name-copy`,children:[(0,W.jsx)(`strong`,{children:e.name}),(0,W.jsxs)(`span`,{children:[e.kind,` · `,hI(e.spanId,16)]})]})]}),(0,W.jsx)(`span`,{className:`trace-waterfall-track`,children:(0,W.jsx)(`span`,{className:`trace-waterfall-bar`,style:{"--span-left":`${n.toFixed(3)}%`,"--span-width":`${r.toFixed(3)}%`}})}),(0,W.jsx)(`span`,{className:`trace-span-duration`,children:_I(e.durationMs)})]},e.spanId)})})]}),(0,W.jsxs)(`aside`,{className:`trace-detail-panel${P?` is-collapsed`:``}`,"aria-label":`Span 详情`,children:[(0,W.jsxs)(`div`,{className:`trace-panel-header`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:ue?gI(ue.name):`Span 详情`}),(0,W.jsx)(`span`,{children:ue?`${gI(ue.kind)} · ${gI(ue.status)}`:`尚未选择 Span`})]}),(0,W.jsxs)(`div`,{className:`trace-detail-actions`,children:[!P&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`button`,{className:`button tertiary small`,type:`button`,disabled:!_,onClick:Ce,children:[(0,W.jsx)(te,{size:14}),(0,W.jsx)(`span`,{children:`复制 Raw OTLP`})]}),(0,W.jsxs)(`button`,{className:`button tertiary small trace-detail-expand`,type:`button`,"aria-pressed":j,title:j?`退出放大详情`:`放大详情`,onClick:()=>N(!j),children:[j?(0,W.jsx)(Se,{size:14}):(0,W.jsx)(ve,{size:14}),(0,W.jsx)(`span`,{children:j?`退出放大`:`放大详情`})]})]}),(0,W.jsxs)(`button`,{className:`button tertiary small trace-detail-collapse`,type:`button`,"aria-expanded":!P,title:P?`展开 Trace 详情`:`收起 Trace 详情`,onClick:()=>{I(e=>!e),P||N(!1)},children:[P?(0,W.jsx)(F,{size:14}):(0,W.jsx)(M,{size:14}),(0,W.jsx)(`span`,{children:P?`展开详情`:`收起详情`})]})]})]}),!P&&(0,W.jsx)(`div`,{className:`trace-tabs`,role:`tablist`,"aria-label":`Trace 详情分类`,children:MI.map(e=>(0,W.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":x===e.id,className:x===e.id?`active`:``,onClick:()=>S(e.id),children:e.label},e.id))}),!P&&(0,W.jsxs)(`div`,{className:`trace-detail-body${x===`raw`?` raw-active`:``}`,children:[x!==`raw`&&(0,W.jsxs)(`div`,{children:[!ue&&(0,W.jsx)(`div`,{className:`trace-stage-empty compact`,children:(0,W.jsx)(`p`,{children:`选择一个 Span 查看标准属性。`})}),ue&&x===`summary`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(AI,{span:ue}),(0,W.jsxs)(`dl`,{className:`trace-detail-grid`,style:{marginTop:14},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Trace ID`}),(0,W.jsx)(`dd`,{children:_?.traceId})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Span ID`}),(0,W.jsx)(`dd`,{children:ue.spanId})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Parent`}),(0,W.jsx)(`dd`,{children:ue.parentSpanId||`Root`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Kind`}),(0,W.jsx)(`dd`,{children:ue.kind})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Status`}),(0,W.jsx)(`dd`,{children:ue.status})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`开始`}),(0,W.jsx)(`dd`,{children:yI(ue.startTimeUnixNano)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`耗时`}),(0,W.jsx)(`dd`,{children:_I(ue.durationMs)})]})]})]}),ue&&x===`attributes`&&(0,W.jsx)(jI,{values:ue.attributes||{}}),ue&&x===`events`&&(0,W.jsx)(RI,{events:ue.events||[]}),ue&&x===`resource`&&(0,W.jsx)(jI,{values:{..._?.resource||{},"otel.scope.name":_?.scope?.name,"otel.scope.version":_?.scope?.version}})]}),(0,W.jsxs)(`div`,{className:`trace-raw`,hidden:x!==`raw`,children:[x===`raw`&&!D&&C&&(0,W.jsxs)(`div`,{className:`trace-raw-toolbar`,children:[(0,W.jsx)(`span`,{children:`JSON Tree`}),(0,W.jsxs)(`div`,{role:`group`,"aria-label":`JSON 展开控制`,children:[(0,W.jsx)(`button`,{type:`button`,className:k?``:`active`,onClick:()=>A(!1),children:`全部收起`}),(0,W.jsx)(`button`,{type:`button`,className:k?`active`:``,onClick:()=>A(!0),children:`全部展开`})]})]}),x===`raw`&&D&&(0,W.jsx)(`div`,{className:`trace-raw-loading`,children:`正在读取 OTLP JSON…`}),x===`raw`&&!D&&C&&(0,W.jsx)(`div`,{className:`trace-raw-tree`,children:(0,W.jsx)(mI,{"aria-label":`Raw OTLP JSON`,data:C,style:CI,shouldExpandNode:k?fI:pI,clickToExpandNode:!0})}),x===`raw`&&!D&&!C&&(0,W.jsx)(`div`,{className:`trace-raw-loading`,children:`没有可显示的 OTLP JSON。`})]})]})]})]})]})]})}function FI({overview:e,range:t,onRangeChange:n}){let r=e?.total||0,i=e?.completed||0,a=e?.successRate==null?`-`:`${Math.round(e.successRate*100)}%`,o=e?.averageDurationMs==null?`-`:_I(e.averageDurationMs),s=e?.totalTokens||0,c=e?.inputTokens||0,l=e?.outputTokens||0;return(0,W.jsxs)(`section`,{className:`observability-overview`,"aria-label":`运行概览`,children:[(0,W.jsxs)(`div`,{className:`overview-metric-grid`,children:[(0,W.jsx)(II,{icon:(0,W.jsx)(w,{size:15}),label:`总运行`,value:String(r),note:t===`7d`?`近 7 天`:`近 24 小时`}),(0,W.jsx)(II,{icon:(0,W.jsx)(L,{size:15}),label:`成功率`,value:a,note:r?`${i} / ${r}`:`暂无运行`,tone:`success`}),(0,W.jsx)(II,{icon:(0,W.jsx)(B,{size:15}),label:`平均耗时`,value:o,note:i?`${i} 个完成运行`:`无完成运行`}),(0,W.jsx)(II,{icon:(0,W.jsx)(ee,{size:15}),label:`Token 总量`,value:vI(s),note:s?`${vI(c)} 输入 · ${vI(l)} 输出`:`未上报`})]}),(0,W.jsxs)(`div`,{className:`overview-chart-card`,children:[(0,W.jsxs)(`div`,{className:`overview-chart-header`,children:[(0,W.jsx)(`strong`,{children:`运行趋势`}),(0,W.jsxs)(`div`,{className:`overview-range-tabs`,children:[(0,W.jsx)(`button`,{type:`button`,className:t===`24h`?`active`:``,onClick:()=>n(`24h`),children:`24 小时`}),(0,W.jsx)(`button`,{type:`button`,className:t===`7d`?`active`:``,onClick:()=>n(`7d`),children:`7 天`})]})]}),(0,W.jsx)(LI,{buckets:e?.buckets||[],range:t}),(0,W.jsxs)(`div`,{className:`overview-chart-legend`,children:[(0,W.jsx)(`span`,{className:`legend-runs`}),`运行数`,(0,W.jsx)(`span`,{className:`legend-success`}),`成功数`]})]})]})}function II({icon:e,label:t,value:n,note:r,tone:i=`neutral`}){return(0,W.jsxs)(`article`,{className:`overview-metric-card ${i}`,children:[(0,W.jsxs)(`div`,{className:`overview-metric-label`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsx)(`small`,{children:t})]}),(0,W.jsx)(`strong`,{children:n}),(0,W.jsx)(`p`,{children:r})]})}function LI({buckets:e,range:t}){let n=e.map(e=>{let n=new Date(e.startedAt),r=t===`7d`?`${n.getMonth()+1}/${n.getDate()}`:`${String(n.getHours()).padStart(2,`0`)}:00`;return{...e,label:r,success:e.completed}});if(!n.length)return(0,W.jsx)(`div`,{className:`trace-stage-empty compact`,children:(0,W.jsx)(`p`,{children:`正在读取运行趋势…`})});let r=Math.max(1,...n.map(e=>e.runs)),i={l:30,r:10,t:10,b:22},a=800-i.l-i.r,o=118-i.t-i.b,s=a/Math.max(1,n.length-1),c=e=>i.t+o-e/r*o,l=n.map((e,t)=>`${i.l+t*s},${c(e.runs)}`).join(` `),u=n.map((e,t)=>`${i.l+t*s},${c(e.success)}`).join(` `),d=`M ${i.l},${i.t+o} L ${l.split(` `).join(` L `)} L ${i.l+(n.length-1)*s},${i.t+o} Z`,f=Math.ceil(n.length/6);return(0,W.jsxs)(`svg`,{className:`overview-chart`,viewBox:`0 0 800 118`,preserveAspectRatio:`none`,"aria-label":`运行趋势曲线`,children:[[0,.25,.5,.75,1].map(e=>{let t=i.t+o-e*o;return(0,W.jsx)(`line`,{x1:i.l,y1:t,x2:800-i.r,y2:t,stroke:`var(--border)`,strokeWidth:`1`,strokeDasharray:e===0?`0`:`3 3`},e)}),(0,W.jsx)(`path`,{d,fill:`var(--accent-soft)`,opacity:`0.6`}),(0,W.jsx)(`polyline`,{points:l,fill:`none`,stroke:`var(--accent)`,strokeWidth:`2`,strokeLinejoin:`round`,strokeLinecap:`round`}),(0,W.jsx)(`polyline`,{points:u,fill:`none`,stroke:`var(--success)`,strokeWidth:`2`,strokeLinejoin:`round`,strokeLinecap:`round`,strokeDasharray:`4 3`}),n.map((e,t)=>(0,W.jsx)(`circle`,{cx:i.l+t*s,cy:c(e.runs),r:`2.5`,fill:`var(--accent)`,children:(0,W.jsx)(`title`,{children:`${e.label}:${e.runs} 次运行,${e.success} 次成功`})},t)),n.map((e,t)=>(t%f===0||t===n.length-1)&&(0,W.jsx)(`text`,{x:i.l+t*s,y:110,textAnchor:`middle`,fill:`var(--text-tertiary)`,fontSize:`11`,children:e.label},`l${t}`))]})}function RI({events:e}){let t=(0,s.useMemo)(()=>{let t=[],n=``,r=null,i=0,a=()=>{r&&n.trim()&&t.push({type:`card`,card:{kind:r,text:n,segments:i,final:!1}}),n=``,i=0,r=null};for(let o of e)if(o.name===`thinking.delta`||o.name===`message.delta`){let e=o.name===`thinking.delta`?`thinking`:`message`;r!==e&&a(),r=e,n+=TI(o.attributes),i+=1}else o.name===`thinking.completed`||o.name===`message.completed`||(a(),t.push({type:`event`,event:o}));return a(),t},[e]);return e.length?(0,W.jsx)(`div`,{className:`io-stack`,children:t.map((e,t)=>e.type===`card`?(0,W.jsx)(kI,{label:e.card.kind===`message`?`模型输出流`:`思考流`,text:e.card.text,tone:e.card.kind,icon:e.card.kind===`message`?(0,W.jsx)(be,{size:12}):(0,W.jsx)(A,{size:12}),meta:`${e.card.segments} 段增量`},t):(0,W.jsxs)(`article`,{className:`trace-event-card`,children:[(0,W.jsx)(`strong`,{children:e.event.name}),(0,W.jsx)(`span`,{children:yI(e.event.timeUnixNano)}),(0,W.jsx)(jI,{values:e.event.attributes||{}})]},t))}):(0,W.jsx)(`div`,{className:`trace-stage-empty compact`,children:(0,W.jsx)(`p`,{children:`该 Span 没有 Events。`})})}var zI=[{kind:`model`,label:`Model Profile`,icon:re},{kind:`tool`,label:`Tool`,icon:Qe},{kind:`mcp`,label:`MCP Server`,icon:Te},{kind:`skill`,label:`Skill`,icon:He}];function BI(e){return e.requiredSecretRefs?.[0]||e.contract?.credentialRef||``}function VI({refreshTick:e}){let[t,n]=(0,s.useState)([]),[r,i]=(0,s.useState)({}),[a,o]=(0,s.useState)(0),[c,l]=(0,s.useState)(``),[u,d]=(0,s.useState)(null),p=(0,s.useCallback)(async()=>{let[e,t,r,a]=await Promise.all([f(`/api/v1/catalog/resources?limit=200`).then(e=>e.json()).catch(()=>({items:[]})),f(`/api/v1/catalog/models`).then(e=>e.json()).catch(()=>null),f(`/api/v1/runs?limit=200`).then(e=>e.json()).catch(()=>({items:[]})),f(`/api/v1/system/bootstrap`).then(e=>e.json()).catch(()=>null)]),s=e.items||[];t?.items?.length&&(s=[...s.filter(e=>e.kind!==`model`||e.source===`local`||e.source===`market`),...t.items]),n(s),o((r.items||[]).length),l(a?.workspace?.path||``),d(!!a?.workspace);let c=[...new Set(s.filter(e=>e.kind===`model`).map(BI).filter(Boolean))],u=await Promise.all(c.map(async e=>{try{return[e,await(await f(`/api/v1/credentials/${encodeURIComponent(e.replace(/^env:\/\//,``))}`)).json()]}catch{return[e,{configured:!1}]}}));i(Object.fromEntries(u))},[]);(0,s.useEffect)(()=>{p()},[p,e]);let m=e=>e.kind===`model`?r[BI(e)]?.configured?`ready`:`missing-secret`:e.status,h=t.filter(e=>e.kind===`model`).filter(e=>m(e)===`ready`),g=t.filter(e=>[`tool`,`mcp`,`skill`].includes(e.kind)).filter(e=>m(e)===`ready`);return(0,W.jsxs)(`div`,{className:`page-container runtime-resource-page`,"data-layout":`data`,"data-scroll-mode":`data`,children:[(0,W.jsx)(`header`,{className:`page-header`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{children:`运行资源`}),(0,W.jsx)(`p`,{children:`查看当前端侧 Runtime、模型和能力资源的真实就绪状态。`})]})}),(0,W.jsxs)(`div`,{className:`data-page-body`,children:[(0,W.jsxs)(`div`,{className:`runtime-overview-grid`,children:[(0,W.jsxs)(`div`,{className:`runtime-metric edge`,children:[(0,W.jsx)(`span`,{children:`端侧 Runtime`}),(0,W.jsx)(`strong`,{children:u==null?`检查中`:u?`Ready`:`Disconnected`}),(0,W.jsx)(`small`,{children:c||`本地工作区`})]}),(0,W.jsxs)(`div`,{className:`runtime-metric cloud`,children:[(0,W.jsx)(`span`,{children:`云端连接`}),(0,W.jsx)(`strong`,{children:`未连接`}),(0,W.jsx)(`small`,{children:`一期保留部署入口`})]}),(0,W.jsxs)(`div`,{className:`runtime-metric`,children:[(0,W.jsx)(`span`,{children:`可用模型`}),(0,W.jsx)(`strong`,{children:h.length}),(0,W.jsx)(`small`,{children:`Model Profile`})]}),(0,W.jsxs)(`div`,{className:`runtime-metric`,children:[(0,W.jsx)(`span`,{children:`能力资源`}),(0,W.jsx)(`strong`,{children:g.length}),(0,W.jsx)(`small`,{children:`Tool · MCP · Skill`})]}),(0,W.jsxs)(`div`,{className:`runtime-metric`,children:[(0,W.jsx)(`span`,{children:`运行记录`}),(0,W.jsx)(`strong`,{children:a}),(0,W.jsx)(`small`,{children:`当前工作区`})]})]}),(0,W.jsxs)(`section`,{className:`runtime-resource-section`,children:[(0,W.jsx)(`div`,{className:`section-heading`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{children:`本地能力清单`}),(0,W.jsx)(`p`,{children:`仅展示 Catalog 返回的资源和状态,不使用模拟硬件指标。`})]})}),(0,W.jsx)(`div`,{className:`runtime-resource-groups`,children:zI.map(e=>{let n=t.filter(t=>t.kind===e.kind),r=e.icon;return(0,W.jsxs)(`article`,{className:`runtime-resource-group`,children:[(0,W.jsxs)(`header`,{children:[(0,W.jsx)(`span`,{className:`runtime-group-icon`,children:(0,W.jsx)(r,{size:15})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.label}),(0,W.jsxs)(`small`,{children:[n.length,` 个已发现`]})]})]}),(0,W.jsx)(`div`,{className:`runtime-resource-list`,children:n.length===0?(0,W.jsx)(`div`,{className:`runtime-resource-empty`,children:`当前工作区未发现此类资源`}):n.map(e=>{let t=m(e);return(0,W.jsxs)(`div`,{className:`runtime-resource-row`,children:[(0,W.jsx)(`span`,{className:`resource-state ${t===`ready`?`ready`:`warning`}`}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:e.displayName}),(0,W.jsx)(`small`,{children:e.version||e.source||e.name})]}),(0,W.jsx)(`span`,{className:`status-badge ${t===`ready`?`success`:`warning`}`,children:t===`ready`?`Ready`:t})]},e.resourceId)})})]},e.kind)})})]})]})]})}function HI(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=HI(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var UI={value:()=>{}};function WI(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new GI(n)}function GI(e){this._=e}function KI(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}GI.prototype=WI.prototype={constructor:GI,on:function(e,t){var n=this._,r=KI(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=qI(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=JI(n[i],e.name,t);else if(t==null)for(i in n)n[i]=JI(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new GI(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function qI(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function JI(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=UI,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var YI={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function XI(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),YI.hasOwnProperty(t)?{space:YI[t],local:e}:e}function ZI(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function QI(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function $I(e){var t=XI(e);return(t.local?QI:ZI)(t)}function eL(){}function tL(e){return e==null?eL:function(){return this.querySelector(e)}}function nL(e){typeof e!=`function`&&(e=tL(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new WR(r,this._parents)}function rL(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function iL(){return[]}function aL(e){return e==null?iL:function(){return this.querySelectorAll(e)}}function oL(e){return function(){return rL(e.apply(this,arguments))}}function sL(e){e=typeof e==`function`?oL(e):aL(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new WR(r,i)}function cL(e){return function(){return this.matches(e)}}function lL(e){return function(t){return t.matches(e)}}var uL=Array.prototype.find;function dL(e){return function(){return uL.call(this.children,e)}}function fL(){return this.firstElementChild}function pL(e){return this.select(e==null?fL:dL(typeof e==`function`?e:lL(e)))}var mL=Array.prototype.filter;function hL(){return Array.from(this.children)}function gL(e){return function(){return mL.call(this.children,e)}}function _L(e){return this.selectAll(e==null?hL:gL(typeof e==`function`?e:lL(e)))}function vL(e){typeof e!=`function`&&(e=cL(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new WR(r,this._parents)}function yL(e){return Array(e.length)}function bL(){return new WR(this._enter||this._groups.map(yL),this._parents)}function xL(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}xL.prototype={constructor:xL,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function SL(e){return function(){return e}}function CL(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new xL(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function wL(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new xL(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function TL(e){return e.__data__}function EL(e,t){if(!arguments.length)return Array.from(this,TL);var n=t?wL:CL,r=this._parents,i=this._groups;typeof e!=`function`&&(e=SL(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=DL(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new WR(o,r),o._enter=s,o._exit=c,o}function DL(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function OL(){return new WR(this._exit||this._groups.map(yL),this._parents)}function kL(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function AL(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new WR(s,this._parents)}function jL(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function ML(e){e||=NL;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new WR(i,this._parents).order()}function NL(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function PL(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function FL(){return Array.from(this)}function IL(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function LL(){let e=0;for(let t of this)++e;return e}function RL(){return!this.node()}function zL(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function BL(e){return function(){this.removeAttribute(e)}}function VL(e){return function(){this.removeAttributeNS(e.space,e.local)}}function HL(e,t){return function(){this.setAttribute(e,t)}}function UL(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function WL(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function GL(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function KL(e,t){var n=XI(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?VL:BL:typeof t==`function`?n.local?GL:WL:n.local?UL:HL)(n,t))}function qL(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function JL(e){return function(){this.style.removeProperty(e)}}function YL(e,t,n){return function(){this.style.setProperty(e,t,n)}}function XL(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function ZL(e,t,n){return arguments.length>1?this.each((t==null?JL:typeof t==`function`?XL:YL)(e,t,n??``)):QL(this.node(),e)}function QL(e,t){return e.style.getPropertyValue(t)||qL(e).getComputedStyle(e,null).getPropertyValue(t)}function $L(e){return function(){delete this[e]}}function eR(e,t){return function(){this[e]=t}}function tR(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function nR(e,t){return arguments.length>1?this.each((t==null?$L:typeof t==`function`?tR:eR)(e,t)):this.node()[e]}function rR(e){return e.trim().split(/^|\s+/)}function iR(e){return e.classList||new aR(e)}function aR(e){this._node=e,this._names=rR(e.getAttribute(`class`)||``)}aR.prototype={add:function(e){this._names.indexOf(e)<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 oR(e,t){for(var n=iR(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function sR(e,t){for(var n=iR(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function cR(e){return function(){oR(this,e)}}function lR(e){return function(){sR(this,e)}}function uR(e,t){return function(){(t.apply(this,arguments)?oR:sR)(this,e)}}function dR(e,t){var n=rR(e+``);if(arguments.length<2){for(var r=iR(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?uR:t?cR:lR)(n,t))}function fR(){this.textContent=``}function pR(e){return function(){this.textContent=e}}function mR(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function hR(e){return arguments.length?this.each(e==null?fR:(typeof e==`function`?mR:pR)(e)):this.node().textContent}function gR(){this.innerHTML=``}function _R(e){return function(){this.innerHTML=e}}function vR(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function yR(e){return arguments.length?this.each(e==null?gR:(typeof e==`function`?vR:_R)(e)):this.node().innerHTML}function bR(){this.nextSibling&&this.parentNode.appendChild(this)}function xR(){return this.each(bR)}function SR(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function CR(){return this.each(SR)}function wR(e){var t=typeof e==`function`?e:$I(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function TR(){return null}function ER(e,t){var n=typeof e==`function`?e:$I(e),r=t==null?TR:typeof t==`function`?t:tL(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function DR(){var e=this.parentNode;e&&e.removeChild(this)}function OR(){return this.each(DR)}function kR(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function AR(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function jR(e){return this.select(e?AR:kR)}function MR(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function NR(e){return function(t){e.call(this,t,this.__data__)}}function PR(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function FR(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function IR(e,t,n){return function(){var r=this.__on,i,a=NR(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function LR(e,t,n){var r=PR(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?IR:FR,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function RR(e,t,n){var r=qL(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function zR(e,t){return function(){return RR(this,e,t)}}function BR(e,t){return function(){return RR(this,e,t.apply(this,arguments))}}function VR(e,t){return this.each((typeof t==`function`?BR:zR)(e,t))}function*HR(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var UR=[null];function WR(e,t){this._groups=e,this._parents=t}function GR(){return new WR([[document.documentElement]],UR)}function KR(){return this}WR.prototype=GR.prototype={constructor:WR,select:nL,selectAll:sL,selectChild:pL,selectChildren:_L,filter:vL,data:EL,enter:bL,exit:OL,join:kL,merge:AL,selection:KR,order:jL,sort:ML,call:PL,nodes:FL,node:IL,size:LL,empty:RL,each:zL,attr:KL,style:ZL,property:nR,classed:dR,text:hR,html:yR,raise:xR,lower:CR,append:wR,insert:ER,remove:OR,clone:jR,datum:MR,on:LR,dispatch:VR,[Symbol.iterator]:HR};function qR(e){return typeof e==`string`?new WR([[document.querySelector(e)]],[document.documentElement]):new WR([[e]],UR)}function JR(e){let t;for(;t=e.sourceEvent;)e=t;return e}function YR(e,t){if(e=JR(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var XR={passive:!1},ZR={capture:!0,passive:!1};function QR(e){e.stopImmediatePropagation()}function $R(e){e.preventDefault(),e.stopImmediatePropagation()}function ez(e){var t=e.document.documentElement,n=qR(e).on(`dragstart.drag`,$R,ZR);`onselectstart`in t?n.on(`selectstart.drag`,$R,ZR):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function tz(e,t){var n=e.document.documentElement,r=qR(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,$R,ZR),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var nz=e=>()=>e;function rz(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){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:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}rz.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function iz(e){return!e.ctrlKey&&!e.button}function az(){return this.parentNode}function oz(e,t){return t??{x:e.x,y:e.y}}function sz(){return navigator.maxTouchPoints||`ontouchstart`in this}function cz(){var e=iz,t=az,n=oz,r=sz,i={},a=WI(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,XR).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(qR(n.view).on(`mousemove.drag`,m,ZR).on(`mouseup.drag`,h,ZR),ez(n.view),QR(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if($R(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){qR(e.view).on(`mousemove.drag mouseup.drag`,null),tz(e.view,l),$R(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(QR(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&($R(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(QR(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=YR(l||r,t),p,m,h;if((h=n.call(e,new rz(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=YR(l||a,t),_=o}u.call(r,e,new rz(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:nz(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:nz(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:nz(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:nz(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function lz(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function uz(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function dz(){}var fz=.7,pz=1/fz,mz=`\\s*([+-]?\\d+)\\s*`,hz=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,gz=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,_z=/^#([0-9a-f]{3,8})$/,vz=RegExp(`^rgb\\(${mz},${mz},${mz}\\)$`),yz=RegExp(`^rgb\\(${gz},${gz},${gz}\\)$`),bz=RegExp(`^rgba\\(${mz},${mz},${mz},${hz}\\)$`),xz=RegExp(`^rgba\\(${gz},${gz},${gz},${hz}\\)$`),Sz=RegExp(`^hsl\\(${hz},${gz},${gz}\\)$`),Cz=RegExp(`^hsla\\(${hz},${gz},${gz},${hz}\\)$`),wz={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};lz(dz,kz,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Tz,formatHex:Tz,formatHex8:Ez,formatHsl:Dz,formatRgb:Oz,toString:Oz});function Tz(){return this.rgb().formatHex()}function Ez(){return this.rgb().formatHex8()}function Dz(){return Hz(this).formatHsl()}function Oz(){return this.rgb().formatRgb()}function kz(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=_z.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Az(t):n===3?new Pz(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?jz(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?jz(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=vz.exec(e))?new Pz(t[1],t[2],t[3],1):(t=yz.exec(e))?new Pz(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=bz.exec(e))?jz(t[1],t[2],t[3],t[4]):(t=xz.exec(e))?jz(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Sz.exec(e))?Vz(t[1],t[2]/100,t[3]/100,1):(t=Cz.exec(e))?Vz(t[1],t[2]/100,t[3]/100,t[4]):wz.hasOwnProperty(e)?Az(wz[e]):e===`transparent`?new Pz(NaN,NaN,NaN,0):null}function Az(e){return new Pz(e>>16&255,e>>8&255,e&255,1)}function jz(e,t,n,r){return r<=0&&(e=t=n=NaN),new Pz(e,t,n,r)}function Mz(e){return e instanceof dz||(e=kz(e)),e?(e=e.rgb(),new Pz(e.r,e.g,e.b,e.opacity)):new Pz}function Nz(e,t,n,r){return arguments.length===1?Mz(e):new Pz(e,t,n,r??1)}function Pz(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}lz(Pz,Nz,uz(dz,{brighter(e){return e=e==null?pz:pz**+e,new Pz(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?fz:fz**+e,new Pz(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Pz(zz(this.r),zz(this.g),zz(this.b),Rz(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:Fz,formatHex:Fz,formatHex8:Iz,formatRgb:Lz,toString:Lz}));function Fz(){return`#${Bz(this.r)}${Bz(this.g)}${Bz(this.b)}`}function Iz(){return`#${Bz(this.r)}${Bz(this.g)}${Bz(this.b)}${Bz((isNaN(this.opacity)?1:this.opacity)*255)}`}function Lz(){let e=Rz(this.opacity);return`${e===1?`rgb(`:`rgba(`}${zz(this.r)}, ${zz(this.g)}, ${zz(this.b)}${e===1?`)`:`, ${e})`}`}function Rz(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function zz(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Bz(e){return e=zz(e),(e<16?`0`:``)+e.toString(16)}function Vz(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Wz(e,t,n,r)}function Hz(e){if(e instanceof Wz)return new Wz(e.h,e.s,e.l,e.opacity);if(e instanceof dz||(e=kz(e)),!e)return new Wz;if(e instanceof Wz)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new Wz(o,s,c,e.opacity)}function Uz(e,t,n,r){return arguments.length===1?Hz(e):new Wz(e,t,n,r??1)}function Wz(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}lz(Wz,Uz,uz(dz,{brighter(e){return e=e==null?pz:pz**+e,new Wz(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?fz:fz**+e,new Wz(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 Pz(qz(e>=240?e-240:e+120,i,r),qz(e,i,r),qz(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Wz(Gz(this.h),Kz(this.s),Kz(this.l),Rz(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(){let e=Rz(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Gz(this.h)}, ${Kz(this.s)*100}%, ${Kz(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Gz(e){return e=(e||0)%360,e<0?e+360:e}function Kz(e){return Math.max(0,Math.min(1,e||0))}function qz(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Jz=e=>()=>e;function Yz(e,t){return function(n){return e+n*t}}function Xz(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Zz(e){return(e=+e)==1?Qz:function(t,n){return n-t?Xz(t,n,e):Jz(isNaN(t)?n:t)}}function Qz(e,t){var n=t-e;return n?Yz(e,n):Jz(isNaN(e)?t:e)}var $z=(function e(t){var n=Zz(t);function r(e,t){var r=n((e=Nz(e)).r,(t=Nz(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Qz(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function eB(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function tB(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function nB(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=dB(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function rB(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function iB(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function aB(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=dB(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var oB=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,sB=new RegExp(oB.source,`g`);function cB(e){return function(){return e}}function lB(e){return function(t){return e(t)+``}}function uB(e,t){var n=oB.lastIndex=sB.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=oB.exec(e))&&(i=sB.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:iB(r,i)})),n=sB.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?lB(c[0].x):cB(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function dB(e,t){var n=typeof t,r;return t==null||n===`boolean`?Jz(t):(n===`number`?iB:n===`string`?(r=kz(t))?(t=r,$z):uB:t instanceof kz?$z:t instanceof Date?rB:tB(t)?eB:Array.isArray(t)?nB:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?aB:iB)(e,t)}var fB=180/Math.PI,pB={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function mB(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*fB,skewX:Math.atan(c)*fB,scaleX:o,scaleY:s}}var hB;function gB(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?pB:mB(t.a,t.b,t.c,t.d,t.e,t.f)}function _B(e){return e==null||(hB||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),hB.setAttribute(`transform`,e),!(e=hB.transform.baseVal.consolidate()))?pB:(e=e.matrix,mB(e.a,e.b,e.c,e.d,e.e,e.f))}function vB(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:iB(e,i)},{i:c-2,x:iB(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:iB(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:iB(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:iB(e,n)},{i:s-2,x:iB(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var yB=vB(gB,`px, `,`px)`,`deg)`),bB=vB(_B,`, `,`)`,`)`),xB=1e-12;function SB(e){return((e=Math.exp(e))+1/e)/2}function CB(e){return((e=Math.exp(e))-1/e)/2}function wB(e){return((e=Math.exp(2*e))-1)/(e+1)}var TB=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<xB)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=SB(y),c=s/(n*g)*(i*wB(t*r+y)-CB(y));return[a+c*d,o+c*f,s*i/SB(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),EB=0,DB=0,OB=0,kB=1e3,AB,jB,MB=0,NB=0,PB=0,FB=typeof performance==`object`&&performance.now?performance:Date,IB=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function LB(){return NB||=(IB(RB),FB.now()+PB)}function RB(){NB=0}function zB(){this._call=this._time=this._next=null}zB.prototype=BB.prototype={constructor:zB,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?LB():+n)+(t==null?0:+t),!this._next&&jB!==this&&(jB?jB._next=this:AB=this,jB=this),this._call=e,this._time=n,GB()},stop:function(){this._call&&(this._call=null,this._time=1/0,GB())}};function BB(e,t,n){var r=new zB;return r.restart(e,t,n),r}function VB(){LB(),++EB;for(var e=AB,t;e;)(t=NB-e._time)>=0&&e._call.call(void 0,t),e=e._next;--EB}function HB(){NB=(MB=FB.now())+PB,EB=DB=0;try{VB()}finally{EB=0,WB(),NB=0}}function UB(){var e=FB.now(),t=e-MB;t>kB&&(PB-=t,MB=e)}function WB(){for(var e,t=AB,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:AB=n);jB=e,GB(r)}function GB(e){EB||(DB&&=clearTimeout(DB),e-NB>24?(e<1/0&&(DB=setTimeout(HB,e-FB.now()-PB)),OB&&=clearInterval(OB)):(OB||=(MB=FB.now(),setInterval(UB,kB)),EB=1,IB(HB)))}function KB(e,t,n){var r=new zB;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var qB=WI(`start`,`end`,`cancel`,`interrupt`),JB=[];function YB(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;$B(e,n,{name:t,index:r,group:i,on:qB,tween:JB,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function XB(e,t){var n=QB(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function ZB(e,t){var n=QB(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function QB(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function $B(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=BB(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return KB(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(KB(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function eV(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function tV(e){return this.each(function(){eV(this,e)})}function nV(e,t){var n,r;return function(){var i=ZB(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function rV(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=ZB(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function iV(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=QB(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?nV:rV)(n,e,t))}function aV(e,t,n){var r=e._id;return e.each(function(){var e=ZB(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return QB(e,r).value[t]}}function oV(e,t){var n;return(typeof t==`number`?iB:t instanceof kz?$z:(n=kz(t))?(t=n,$z):uB)(e,t)}function sV(e){return function(){this.removeAttribute(e)}}function cV(e){return function(){this.removeAttributeNS(e.space,e.local)}}function lV(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function uV(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function dV(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function fV(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function pV(e,t){var n=XI(e),r=n===`transform`?bB:oV;return this.attrTween(e,typeof t==`function`?(n.local?fV:dV)(n,r,aV(this,`attr.`+e,t)):t==null?(n.local?cV:sV)(n):(n.local?uV:lV)(n,r,t))}function mV(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function hV(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function gV(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&hV(e,i)),n}return i._value=t,i}function _V(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&mV(e,i)),n}return i._value=t,i}function vV(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=XI(e);return this.tween(n,(r.local?gV:_V)(r,t))}function yV(e,t){return function(){XB(this,e).delay=+t.apply(this,arguments)}}function bV(e,t){return t=+t,function(){XB(this,e).delay=t}}function xV(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?yV:bV)(t,e)):QB(this.node(),t).delay}function SV(e,t){return function(){ZB(this,e).duration=+t.apply(this,arguments)}}function CV(e,t){return t=+t,function(){ZB(this,e).duration=t}}function wV(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?SV:CV)(t,e)):QB(this.node(),t).duration}function TV(e,t){if(typeof t!=`function`)throw Error();return function(){ZB(this,e).ease=t}}function EV(e){var t=this._id;return arguments.length?this.each(TV(t,e)):QB(this.node(),t).ease}function DV(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();ZB(this,e).ease=n}}function OV(e){if(typeof e!=`function`)throw Error();return this.each(DV(this._id,e))}function kV(e){typeof e!=`function`&&(e=cL(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new iH(r,this._parents,this._name,this._id)}function AV(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new iH(o,this._parents,this._name,this._id)}function jV(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function MV(e,t,n){var r,i,a=jV(t)?XB:ZB;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function NV(e,t){var n=this._id;return arguments.length<2?QB(this.node(),n).on.on(e):this.each(MV(n,e,t))}function PV(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function FV(){return this.on(`end.remove`,PV(this._id))}function IV(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=tL(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,YB(l[f],t,n,f,l,QB(u,n)));return new iH(a,this._parents,t,n)}function LV(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=aL(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=QB(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&YB(p,t,n,h,f,m);a.push(f),o.push(u)}return new iH(a,o,t,n)}var RV=GR.prototype.constructor;function zV(){return new RV(this._groups,this._parents)}function BV(e,t){var n,r,i;return function(){var a=QL(this,e),o=(this.style.removeProperty(e),QL(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function VV(e){return function(){this.style.removeProperty(e)}}function HV(e,t,n){var r,i=n+``,a;return function(){var o=QL(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function UV(e,t,n){var r,i,a;return function(){var o=QL(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),QL(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function WV(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=ZB(this,e),l=c.on,u=c.value[a]==null?s||=VV(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function GV(e,t,n){var r=(e+=``)==`transform`?yB:oV;return t==null?this.styleTween(e,BV(e,r)).on(`end.style.`+e,VV(e)):typeof t==`function`?this.styleTween(e,UV(e,r,aV(this,`style.`+e,t))).each(WV(this._id,e)):this.styleTween(e,HV(e,r,t),n).on(`end.style.`+e,null)}function KV(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function qV(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&KV(e,a,n)),r}return a._value=t,a}function JV(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,qV(e,t,n??``))}function YV(e){return function(){this.textContent=e}}function XV(e){return function(){var t=e(this);this.textContent=t??``}}function ZV(e){return this.tween(`text`,typeof e==`function`?XV(aV(this,`text`,e)):YV(e==null?``:e+``))}function QV(e){return function(t){this.textContent=e.call(this,t)}}function $V(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&QV(r)),t}return r._value=e,r}function eH(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,$V(e))}function tH(){for(var e=this._name,t=this._id,n=aH(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=QB(c,t);YB(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new iH(r,this._parents,e,n)}function nH(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=ZB(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var rH=0;function iH(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function aH(){return++rH}var oH=GR.prototype;iH.prototype={constructor:iH,select:IV,selectAll:LV,selectChild:oH.selectChild,selectChildren:oH.selectChildren,filter:kV,merge:AV,selection:zV,transition:tH,call:oH.call,nodes:oH.nodes,node:oH.node,size:oH.size,empty:oH.empty,each:oH.each,on:NV,attr:pV,attrTween:vV,style:GV,styleTween:JV,text:ZV,textTween:eH,remove:FV,tween:iV,delay:xV,duration:wV,ease:EV,easeVarying:OV,end:nH,[Symbol.iterator]:oH[Symbol.iterator]};function sH(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var cH={time:null,delay:0,duration:250,ease:sH};function lH(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function uH(e){var t,n;e instanceof iH?(t=e._id,e=e._name):(t=aH(),(n=cH).time=LB(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&YB(c,e,t,l,o,n||lH(c,t));return new iH(r,this._parents,e,t)}GR.prototype.interrupt=tV,GR.prototype.transition=uH;var dH=e=>()=>e;function fH(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 pH(e,t,n){this.k=e,this.x=t,this.y=n}pH.prototype={constructor:pH,scale:function(e){return e===1?this:new pH(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new pH(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 mH=new pH(1,0,0);hH.prototype=pH.prototype;function hH(e){for(;!e.__zoom;)if(!(e=e.parentNode))return mH;return e.__zoom}function gH(e){e.stopImmediatePropagation()}function _H(e){e.preventDefault(),e.stopImmediatePropagation()}function vH(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function yH(){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 bH(){return this.__zoom||mH}function xH(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function SH(){return navigator.maxTouchPoints||`ontouchstart`in this}function CH(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function wH(){var e=vH,t=yH,n=CH,r=xH,i=SH,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=TB,l=WI(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,bH).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,bH),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(mH.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new pH(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new pH(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new pH(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=qR(this.that).datum();l.call(e,this.that,new fH(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=YR(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],eV(this),s.start();_H(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=qR(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=YR(t,i),l=t.clientX,u=t.clientY;ez(t.view),gH(t),a.mouse=[c,this.__zoom.invert(c)],eV(this),a.start();function d(e){if(_H(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=YR(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),tz(e.view,a.moved),_H(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=YR(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);_H(r),s>0?qR(this).transition().duration(s).call(x,d,c,r):qR(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(gH(t),s=0;s<i;++s)c=r[s],l=YR(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),eV(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(_H(e),s=0;s<a;++s)c=i[s],l=YR(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(gH(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=YR(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=qR(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:dH(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:dH(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:dH(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:dH([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var TH={error001:(e=`react`)=>`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},EH=[[-1/0,-1/0],[1/0,1/0]],DH=[`Enter`,` `,`Escape`],OH={"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`},kH;(function(e){e.Strict=`strict`,e.Loose=`loose`})(kH||={});var AH;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(AH||={});var jH;(function(e){e.Partial=`partial`,e.Full=`full`})(jH||={});var MH={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},NH;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(NH||={});var PH;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(PH||={});var $;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})($||={});var FH={[$.Left]:$.Right,[$.Right]:$.Left,[$.Top]:$.Bottom,[$.Bottom]:$.Top};function IH(e){return e===null?null:e?`valid`:`invalid`}var LH=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,RH=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),zH=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),BH=(e,t=[0,0])=>{let{width:n,height:r}=bU(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},VH=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:nU(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):zH(n)?n:t.nodeLookup.get(n.id)),eU(e,i?iU(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),HH=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=eU(n,iU(e)),r=!0)}),r?nU(n):{x:0,y:0,width:0,height:0}},UH=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=oU(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},WH=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function GH(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{let i;if(t?.includeHiddenNodes){let{width:t,height:n}=bU(e);i=t>0&&n>0}else i=!!(e.measured.width&&e.measured.height&&!e.hidden);i&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function KH({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=_U(HH(GH(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function qH({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent){if(!s)a?.(`005`,TH.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&yU(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=yU(d)?XH(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,TH.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function JH({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=WH(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var YH=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),XH=(e={x:0,y:0},t,n)=>({x:YH(e.x,t[0][0],t[1][0]-(n?.width??0)),y:YH(e.y,t[0][1],t[1][1]-(n?.height??0))});function ZH(e,t,n){let{width:r,height:i}=bU(n),{x:a,y:o}=n.internals.positionAbsolute;return XH(e,[[a,o],[a+r,o+i]],t)}var QH=(e,t,n)=>e<t?YH(Math.abs(e-t),1,t)/t:e>n?-YH(Math.abs(e-n),1,t)/t:0,$H=(e,t,n=15,r=40)=>[QH(e.x,r,t.width-r)*n,QH(e.y,r,t.height-r)*n],eU=(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)}),tU=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),nU=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),rU=(e,t=[0,0])=>{let{x:n,y:r}=zH(e)?e.internals.positionAbsolute:BH(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},iU=(e,t=[0,0])=>{let{x:n,y:r}=zH(e)?e.internals.positionAbsolute:BH(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},aU=(e,t)=>nU(eU(tU(e),tU(t))),oU=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},sU=(e,t)=>oU(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),cU=e=>lU(e.width)&&lU(e.height)&&lU(e.x)&&lU(e.y),lU=e=>!isNaN(e)&&isFinite(e),uU=(e,t)=>(e,t)=>{},dU=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),fU=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?dU(s,o):s},pU=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function mU(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let 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 hU(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=mU(e,n),i=mU(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=mU(e.top??e.y??0,n),i=mU(e.bottom??e.y??0,n),a=mU(e.left??e.x??0,t),o=mU(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function gU(e,t,n,r,i,a){let{x:o,y:s}=pU(e,[t,n,r]),{x:c,y:l}=pU({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var _U=(e,t,n,r,i,a)=>{let o=hU(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=YH(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=gU(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},vU=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function yU(e){return e!=null&&e!==`parent`}function bU(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function xU(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function SU(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function CU(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function wU(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function TU(e){return{...OH,...e||{}}}function EU(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=MU(e),s=fU({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?dU(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var DU=e=>({width:e.offsetWidth,height:e.offsetHeight}),OU=e=>e?.getRootNode?.()||window?.document,kU=[`INPUT`,`SELECT`,`TEXTAREA`];function AU(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?kU.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var jU=e=>`clientX`in e,MU=(e,t)=>{let n=jU(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},NU=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...DU(t)}})};function PU({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function FU(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function IU({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case $.Left:return[t-FU(t-r,a),n];case $.Right:return[t+FU(r-t,a),n];case $.Top:return[t,n-FU(n-i,a)];case $.Bottom:return[t,n+FU(i-n,a)]}}function LU({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,curvature:o=.25}){let[s,c]=IU({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=IU({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=PU({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function RU({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function zU({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function BU({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=eU(iU(e),iU(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),sU({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},nU(a))>0}var VU=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,HU=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),UU=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,TH.error006()),t;let r=n.getEdgeId||VU,i;return i=LH(e)?{...e}:{...e,id:r(e)},HU(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function WU({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=RU({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var GU={[$.Left]:{x:-1,y:0},[$.Right]:{x:1,y:0},[$.Top]:{x:0,y:-1},[$.Bottom]:{x:0,y:1}},KU=({source:e,sourcePosition:t=$.Bottom,target:n})=>t===$.Left||t===$.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},qU=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function JU({source:e,sourcePosition:t=$.Bottom,target:n,targetPosition:r=$.Top,center:i,offset:a,stepPosition:o}){let s=GU[t],c=GU[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=KU({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=RU({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function YU(e,t,n,r){let i=Math.min(qU(e,t)/2,qU(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function XU({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=JU({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=YU(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function ZU(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function QU(e){let{sourceNode:t,targetNode:n}=e;if(!ZU(t)||!ZU(n))return null;let r=t.internals.handleBounds||$U(t.handles),i=n.internals.handleBounds||$U(n.handles),a=tW(r?.source??[],e.sourceHandle),o=tW(e.connectionMode===kH.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,TH.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||$.Bottom,c=o?.position||$.Top,l=eW(t,a,s),u=eW(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function $U(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function eW(e,t,n=$.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??bU(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case $.Top:return{x:i+o/2,y:a};case $.Right:return{x:i+o,y:a+s/2};case $.Bottom:return{x:i+o/2,y:a+s};case $.Left:return{x:i,y:a+s/2}}}function tW(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function nW(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function rW(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=nW(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var iW=1e3,aW=10,oW={nodeOrigin:[0,0],nodeExtent:EH,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},sW={...oW,checkEquality:!0};function cW(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function lW(e,t,n){let r=cW(oW,n);for(let n of e.values())if(n.parentId)mW(n,e,t,r);else{let e=XH(BH(n,r.nodeOrigin),yU(n.extent)?n.extent:r.nodeExtent,bU(n));n.internals.positionAbsolute=e}}function uW(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function dW(e){return e===`manual`}function fW(e,t,n,r={}){let i=cW(sW,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!dW(i.zIndexMode)?iW:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=XH(BH(u,i.nodeOrigin),yU(u.extent)?u.extent:i.nodeExtent,bU(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:uW(u,e),z:hW(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&mW(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function pW(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function mW(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=cW(oW,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}pW(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*aW),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=gW(e,u,o,s,a&&!dW(c)?iW:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function hW(e,t,n){let r=lU(e.zIndex)?e.zIndex:0;return dW(n)?r:r+(e.selected?t:0)}function gW(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=bU(e),l=BH(e,n),u=yU(e.extent)?XH(l,e.extent,c):l,d=XH({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=ZH(d,c,t));let f=hW(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function _W(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=aU(a.get(n.parentId)?.expandedRect??rU(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=bU(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function vW(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=DU(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=yU(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=ZH(h,s,n))}else m&&(h=XH(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:NU(`source`,r.nodeElement,p,d,e.id),target:NU(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&mW(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:rU(g,i)}))}}if(f.length>0){let e=_W(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function yW({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function bW(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function xW(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;bW(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),bW(`target`,s,c,e,i,o),t.set(r.id,r)}}function SW(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:SW(n,t):!1}function CW(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function wW(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!SW(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function TW({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function EW({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=dU(a,t);return{x:o.x-a.x,y:o.y-a.y}}function DW({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=qR(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?tU(HH(s)):null,x=v&&l?EW({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:dU(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=qH({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=TW({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=$H(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=EU(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=wW(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=TW({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=cz().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=EU(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=MU(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=EU(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=MU(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=MU(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=TW({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!CW(t,`.${g}`,v))&&(!_||CW(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function OW(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())sU(i,rU(e))>0&&r.push(e);return r}var kW=250;function AW(e,t,n,r){let i=[],a=1/0,o=OW(e,n,t+kW);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=eW(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function jW(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...eW(o,c,c.position,!0)}:c}function MW(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function NW(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var PW=()=>!0;function FW(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=PW,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=OU(e.target),E=0,D,{x:O,y:k}=MU(e),A=MW(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=jW(i,A,r,c,t);if(!N)return;let P=MU(e,j),F=!1,I=null,L=!1,R=null;function z(){if(!u||!j)return;let[e,t]=$H(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(z)}let B={...N,nodeId:i,type:A,position:N.position},V=c.get(i),H={inProgress:!0,isValid:null,from:eW(V,B,$.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:V,to:P,toHandle:null,toPosition:FH[B.position],toNode:null,pointer:P};function U(){M=!0,y(H),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&U();function ee(e){if(!M){let{x:t,y:n}=MU(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;U()}if(!x()||!B){te(e);return}let a=b();P=MU(e,j),D=AW(fU(P,a,!1,[1,1]),n,c,B),F||=(z(),!0);let s=IW(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=NW(!!D,s.isValid);let u=c.get(i),f=u?eW(u,B,$.Left,!0):H.from,p={...H,from:f,isValid:L,to:s.toHandle&&L?pU({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:FH[B.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),H=p}function te(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=H,r={...n,toPosition:H.toHandle?H.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,ee),T.removeEventListener(`mouseup`,te),T.removeEventListener(`touchmove`,ee),T.removeEventListener(`touchend`,te)}}T.addEventListener(`mousemove`,ee),T.addEventListener(`mouseup`,te),T.addEventListener(`touchmove`,ee),T.addEventListener(`touchend`,te)}function IW(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=PW,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=MU(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=MW(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===kH.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=jW(t,e,a,u,n,!0)}return _}var LW={onPointerDown:FW,isValid:IW};function RW({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=qR(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&vU()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=wH().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:YR}}var zW=e=>({x:e.x,y:e.y,zoom:e.k}),BW=({x:e,y:t,zoom:n})=>mH.translate(e,t).scale(n),VW=(e,t)=>e.target.closest(`.${t}`),HW=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),UW=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,WW=(e,t=0,n=UW,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},GW=e=>{let t=e.ctrlKey&&vU()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function KW({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(VW(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=YR(u),t=d*2**GW(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===AH.Vertical?0:u.deltaX*f,m=i===AH.Horizontal?0:u.deltaY*f;!vU()&&u.shiftKey&&i!==AH.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=zW(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,h):(e.isPanScrolling=!0,s?.(u,h)),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)}}function qW({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=VW(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function JW({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=zW(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function YW({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&HW(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,zW(a.transform))}}function XW({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&HW(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=zW(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function ZW({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(VW(d,`${l}-flow__node`)||VW(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||VW(d,s)&&m||VW(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function QW({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=[[0,0],[u.width,u.height]];(typeof ResizeObserver<`u`?new ResizeObserver(e=>{let t=e[0];t&&(d=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null)?.observe(e);let f=wH().extent(()=>d).scaleExtent([t,n]).translateExtent(r),p=qR(e).call(f);y({x:i.x,y:i.y,zoom:YH(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let m=p.on(`wheel.zoom`),h=p.on(`dblclick.zoom`);f.wheelDelta(GW);async function g(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?dB:TB).transform(WW(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function _({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:g,preventScrolling:_,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&v();let O=i&&!S&&!r;f.clickDistance(D?1/0:!lU(E)||E<0?0:E);let k=O?KW({zoomPanValues:l,noWheelClassName:e,d3Selection:p,d3Zoom:f,panOnScrollMode:d,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):qW({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:m});p.on(`wheel.zoom`,k,{passive:!1});let A=JW({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});f.on(`start`,A);let j=YW({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});f.on(`zoom`,j);let M=XW({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});f.on(`end`,M);let N=ZW({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});f.filter(N),x?p.on(`dblclick.zoom`,h):p.on(`dblclick.zoom`,null)}function v(){f.on(`zoom`,null)}async function y(e,t,n){let r=BW(e),i=f?.constrain()(r,t,n);return i&&await g(i),i}async function b(e,t){let n=BW(e);return await g(n,t),n}function x(e){if(p){let t=BW(e),n=p.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&f?.transform(p,t,null,{sync:!0})}}function S(){let e=p?hH(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function C(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?dB:TB).scaleTo(WW(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function w(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?dB:TB).scaleBy(WW(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function T(e){f?.scaleExtent(e)}function E(e){f?.translateExtent(e)}function D(e){let t=!lU(e)||e<0?0:e;f?.clickDistance(t)}return{update:_,destroy:v,setViewport:b,setViewportConstrained:y,getViewport:S,scaleTo:C,scaleBy:w,setScaleExtent:T,setTranslateExtent:E,syncViewport:x,setClickDistance:D}}var $W;(function(e){e.Line=`line`,e.Handle=`handle`})($W||={});function eG({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function tG(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function nG(e,t){return Math.max(0,t-e)}function rG(e,t){return Math.max(0,e-t)}function iG(e,t,n){return Math.max(0,t-e,e-n)}function aG(e,t){return e?!t:t}function oG(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=iG(E,h,g),j=iG(D,_,v);if(o){let e=0,t=0;c&&w<0?e=nG(y+w+O,o[0][0]):!c&&w>0&&(e=rG(y+E+O,o[1][0])),l&&T<0?t=nG(b+T+k,o[0][1]):!l&&T>0&&(t=rG(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=rG(y+w,s[0][0]):!c&&w<0&&(e=nG(y+E,s[1][0])),l&&T>0?t=rG(b+T,s[0][1]):!l&&T<0&&(t=nG(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=iG(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?rG(b+k+E/C,o[1][1])*C:nG(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?nG(b+E/C,s[1][1])*C:rG(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=iG(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?rG(y+D*C+O,o[1][0])/C:nG(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?nG(y+D*C,s[1][0])/C:rG(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(aG(c,l)?-w:w)/C:w=(aG(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var sG={width:0,height:0,x:0,y:0},cG={...sG,pointerX:0,pointerY:0,aspectRatio:1};function lG(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function uG({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=qR(e),o={controlDirection:tG(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...sG},h={...cG};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:tG(e)};let g,_=null,v=[],y,b,x,S=!1,C=cz().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=EU(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=yU(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=lG(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=EU(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=oG(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let F=eG({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)!==!1&&(S=!0,d?.(e,I),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var dG=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},fG=e=>e?dG(e):dG,{useDebugValue:pG}=s.default,{useSyncExternalStoreWithSelector:mG}=La.default,hG=e=>e;function gG(e,t=hG,n){let r=mG(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return pG(r),r}var _G=(e,t)=>{let n=fG(e),r=(e,r=t)=>gG(n,e,r);return Object.assign(r,n),r},vG=(e,t)=>e?_G(e,t):_G;function yG(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var bG=(0,s.createContext)(null),xG=bG.Provider,SG=TH.error001(`react`);function CG(e,t){let n=(0,s.useContext)(bG);if(n===null)throw Error(SG);return gG(n,e,t)}function wG(){let e=(0,s.useContext)(bG);if(e===null)throw Error(SG);return(0,s.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var TG={display:`none`},EG={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},DG=`react-flow__node-desc`,OG=`react-flow__edge-desc`,kG=`react-flow__aria-live`,AG=e=>e.ariaLiveMessage,jG=e=>e.ariaLabelConfig;function MG({rfId:e}){let t=CG(AG);return(0,W.jsx)(`div`,{id:`${kG}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:EG,children:t})}function NG({rfId:e,disableKeyboardA11y:t}){let n=CG(jG);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{id:`${DG}-${e}`,style:TG,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,W.jsx)(`div`,{id:`${OG}-${e}`,style:TG,children:n[`edge.a11yDescription.default`]}),!t&&(0,W.jsx)(MG,{rfId:e})]})}var PG=(0,s.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,W.jsx)(`div`,{className:HI([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});PG.displayName=`Panel`;var FG=`https://reactflow.dev?utm_source=attribution`;function IG({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,W.jsx)(PG,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${FG}`,children:(0,W.jsx)(`a`,{href:FG,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var LG=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},RG=e=>e.id;function zG(e,t){return yG(e.selectedNodes.map(RG),t.selectedNodes.map(RG))&&yG(e.selectedEdges.map(RG),t.selectedEdges.map(RG))}function BG({onSelectionChange:e}){let t=wG(),{selectedNodes:n,selectedEdges:r}=CG(LG,zG);return(0,s.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var VG=e=>!!e.onSelectionChangeHandlers;function HG({onSelectionChange:e}){let t=CG(VG);return e||t?(0,W.jsx)(BG,{onSelectionChange:e}):null}var UG=[0,0],WG={x:0,y:0,zoom:1},GG=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],KG=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),qG={translateExtent:EH,nodeOrigin:UG,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function JG(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:c,setDefaultNodesAndEdges:l}=CG(KG,yG),u=wG();(0,s.useEffect)(()=>(l(e.defaultNodes,e.defaultEdges),()=>{d.current=qG,c()}),[]);let d=(0,s.useRef)(qG);return(0,s.useEffect)(()=>{for(let s of GG){let c=e[s];c!==d.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?u.setState({ariaLabelConfig:TU(c)}):s===`fitView`?u.setState({fitViewQueued:c}):s===`fitViewOptions`?u.setState({fitViewOptions:c}):u.setState({[s]:c}))}d.current=e},GG.map(t=>e[t])),null}function YG(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function XG(e){let[t,n]=(0,s.useState)(e===`system`?null:e);return(0,s.useEffect)(()=>{if(e!==`system`){n(e);return}let t=YG(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?YG()?.matches?`dark`:`light`:t}var ZG=typeof document<`u`?document:null;function QG(e=null,t={target:ZG,actInsideInputWithModifier:!0}){let[n,r]=(0,s.useState)(!1),i=(0,s.useRef)(!1),a=(0,s.useRef)(new Set([])),[o,c]=(0,s.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,`
|
|
239
|
-
`).replace(`
|
|
240
|
-
|
|
241
|
-
`,`
|
|
242
|
-
+`).split(`
|
|
243
|
-
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,s.useEffect)(()=>{let n=t?.target??ZG,s=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!s)&&AU(e))return!1;let n=eK(e.code,c);if(a.current.add(e[n]),$G(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=eK(e.code,c);$G(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function $G(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function eK(e,t){return t.includes(e)?`code`:`key`}var tK=()=>{let e=wG();return(0,s.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=_U(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return fU(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=pU(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function nK(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)rK(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function rK(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing)}}function iK(e,t){return nK(e,t)}function aK(e,t){return nK(e,t)}function oK(e,t){return{id:e,type:`select`,selected:t}}function sK(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(oK(a.id,e)))}return r}function cK({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function lK(e){return{id:e.id,type:`remove`}}var uK=uU(`React Flow`,`https://reactflow.dev/`);function dK(e,t,n={}){return UU(e,t,{...n,onError:n.onError??uK})}var fK=e=>RH(e),pK=e=>LH(e);function mK(e){return(0,s.forwardRef)(e)}var hK=typeof window<`u`?s.useLayoutEffect:s.useEffect;function gK(e){let[t,n]=(0,s.useState)(BigInt(0)),[r]=(0,s.useState)(()=>_K(()=>n(e=>e+BigInt(1))));return hK(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function _K(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var vK=(0,s.createContext)(null);function yK({children:e}){let t=wG(),n=gK((0,s.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=cK({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=gK((0,s.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(cK({items:s,lookup:o}))},[])),i=(0,s.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,W.jsx)(vK.Provider,{value:i,children:e})}function bK(){let e=(0,s.useContext)(vK);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var xK=e=>!!e.panZoom;function SK(){let e=tK(),t=wG(),n=bK(),r=CG(xK),i=(0,s.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=fK(e)?e:n.get(e.id),a=i.parentId?SU(i.position,i.measured,i.parentId,n,r):i.position;return rU({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&fK(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&pK(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await JH({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(lK);o?.(f),c(e)}if(m){let e=d.map(lK);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=cU(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=rU(s?r:a),l=sU(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=cU(e)?e:a(e);if(!r)return!1;let i=sU(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return VH(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??wU();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,s.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var CK=e=>e.selected,wK=typeof window<`u`?window:void 0;function TK({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=wG(),{deleteElements:r}=SK(),i=QG(e,{actInsideInputWithModifier:!1}),a=QG(t,{target:wK});(0,s.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(CK),edges:e.filter(CK)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,s.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function EK(e){let t=wG();(0,s.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=DU(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,TH.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var DK={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},OK=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function kK({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=AH.Free,zoomOnDoubleClick:o=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:m=!0,children:h,noWheelClassName:g,noPanClassName:_,onViewportChange:v,isControlledViewport:y,paneClickDistance:b,selectionOnDrag:x}){let S=wG(),C=(0,s.useRef)(null),{userSelectionActive:w,lib:T,connectionInProgress:E}=CG(OK,yG),D=QG(p),O=(0,s.useRef)();EK(C);let k=(0,s.useCallback)(e=>{v?.({x:e[0],y:e[1],zoom:e[2]}),y||S.setState({transform:e})},[v,y]);return(0,s.useEffect)(()=>{if(C.current){O.current=QW({domNode:C.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:l,onDraggingChange:e=>S.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=S.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=S.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=S.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=O.current.getViewport();return S.setState({panZoom:O.current,transform:[e,t,n],domNode:C.current.closest(`.react-flow`)}),()=>{O.current?.destroy()}}},[]),(0,s.useEffect)(()=>{O.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:c,zoomActivationKeyPressed:D,preventScrolling:m,noPanClassName:_,userSelectionActive:w,noWheelClassName:g,lib:T,onTransformChange:k,connectionInProgress:E,selectionOnDrag:x,paneClickDistance:b})},[e,t,n,r,i,a,o,c,D,m,_,w,g,T,k,E,x,b]),(0,W.jsx)(`div`,{className:`react-flow__renderer`,ref:C,style:DK,children:h})}var AK=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function jK(){let{userSelectionActive:e,userSelectionRect:t}=CG(AK,yG);return e&&t?(0,W.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var MK=(e,t)=>n=>{n.target===t.current&&e?.(n)},NK=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function PK({isSelecting:e,selectionKeyPressed:t,selectionMode:n=jH.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:c,onSelectionEnd:l,onPaneClick:u,onPaneContextMenu:d,onPaneScroll:f,onPaneMouseEnter:p,onPaneMouseMove:m,onPaneMouseLeave:h,children:g}){let _=(0,s.useRef)(0),v=wG(),{userSelectionActive:y,elementsSelectable:b,dragging:x,panBy:S,autoPanSpeed:C}=CG(NK,yG),w=b&&(e||y),T=(0,s.useRef)(null),E=(0,s.useRef)(),D=(0,s.useRef)(new Set),O=(0,s.useRef)(new Set),k=(0,s.useRef)(!1),A=(0,s.useRef)(!1),j=(0,s.useRef)({x:0,y:0}),M=(0,s.useRef)(!1),N=e=>{if(A.current||k.current||v.getState().connection.inProgress){A.current=!1,k.current=!1;return}u?.(e),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},P=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}d?.(e)},F=f?e=>f(e):void 0,I=e=>{A.current&&=(e.stopPropagation(),!1)},L=n=>{let{domNode:r,transform:i}=v.getState();if(E.current=r?.getBoundingClientRect(),!E.current)return;let a=n.target===T.current;if(!a&&n.target.closest(`.nokey`)||!e||!(o&&a||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),A.current=!1;let{x:s,y:c}=MU(n.nativeEvent,E.current),l=fU({x:s,y:c},i);v.setState({userSelectionRect:{width:0,height:0,startX:l.x,startY:l.y,x:s,y:c}}),a||(n.stopPropagation(),n.preventDefault())};function R(e,t){let{userSelectionRect:r}=v.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=v.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=pU(d,i),m={startX:d.x,startY:d.y,x:e<f?e:f,y:t<p?t:p,width:Math.abs(e-f),height:Math.abs(t-p)},h=D.current,g=O.current;D.current=new Set(UH(a,m,i,n===jH.Partial,!0).map(e=>e.id)),O.current=new Set;let _=u?.selectable??!0;for(let e of D.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??_)&&O.current.add(e)}}CU(h,D.current)||c(sK(a,D.current,!0)),CU(g,O.current)||l(sK(o,O.current)),v.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!i||!E.current)return;let[e,t]=$H(j.current,E.current,C);S({x:e,y:t}).then(e=>{if(!A.current||!e){_.current=requestAnimationFrame(z);return}let{x:t,y:n}=j.current;R(t,n),_.current=requestAnimationFrame(z)})}let B=()=>{cancelAnimationFrame(_.current),_.current=0,M.current=!1};(0,s.useEffect)(()=>()=>B(),[]);let V=e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=v.getState();if(!E.current||!n)return;let{x:o,y:s}=MU(e.nativeEvent,E.current);j.current={x:o,y:s};let l=pU({x:n.startX,y:n.startY},r);if(!A.current){let n=t?0:a;if(Math.hypot(o-l.x,s-l.y)<=n)return;i(),c?.(e)}A.current=!0,M.current||=(z(),!0),R(o,s)},H=e=>{if(!w){e.target===T.current&&v.getState().connection.inProgress&&(k.current=!0);return}e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!y&&e.target===T.current&&v.getState().userSelectionRect&&N?.(e),v.setState({userSelectionActive:!1,userSelectionRect:null}),A.current&&(l?.(e),v.setState({nodesSelectionActive:D.current.size>0})),B())},U=e=>{e.target?.releasePointerCapture?.(e.pointerId),B()},ee=r===!0||Array.isArray(r)&&r.includes(0);return(0,W.jsxs)(`div`,{className:HI([`react-flow__pane`,{draggable:ee,dragging:x,selection:e}]),onClick:w?void 0:MK(N,T),onContextMenu:MK(P,T),onWheel:MK(F,T),onPointerEnter:w?void 0:p,onPointerMove:w?V:m,onPointerUp:H,onPointerCancel:w?U:void 0,onPointerDownCapture:w?L:void 0,onClickCapture:w?I:void 0,onPointerLeave:h,ref:T,style:DK,children:[g,(0,W.jsx)(jK,{})]})}function FK({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,TH.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function IK({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let c=wG(),[l,u]=(0,s.useState)(!1),d=(0,s.useRef)();return(0,s.useEffect)(()=>{if(!t)return d.current=DW({getStoreItems:()=>c.getState(),onNodeMouseDown:t=>{FK({id:t,store:c,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}}),()=>{d.current?.destroy(),d.current=void 0}},[t,c,e]),(0,s.useEffect)(()=>{t||!e.current||!d.current||d.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o})},[n,r,t,a,e,i,o]),l}var LK=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function RK(){let e=wG();return(0,s.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=LK(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=dU(t,i));let{position:a,positionAbsolute:s}=qH({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var zK=(0,s.createContext)(null),BK=zK.Provider;zK.Consumer;var VK=()=>(0,s.useContext)(zK),HK=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),UK=(0,s.createContext)(null);function WK({children:e}){let t=CG(HK,yG);return(0,W.jsx)(UK.Provider,{value:t,children:e})}function GK(){let e=(0,s.useContext)(UK);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var KK={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},qK=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return KK;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===kH.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function JK({type:e=`source`,position:t=$.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=wG(),_=VK(),{connectOnClick:v,noPanClassName:y,rfId:b}=GK(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=CG(qK(_,m,e),yG);_||g.getState().onError?.(`010`,TH.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(dK(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=jU(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();LW.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,W.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:HI([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=OU(t.target),h=n||c,{connection:v,isValid:y}=LW.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var YK=(0,s.memo)(mK(JK));function XK({data:e,isConnectable:t,sourcePosition:n=$.Bottom}){return(0,W.jsxs)(W.Fragment,{children:[e?.label,(0,W.jsx)(YK,{type:`source`,position:n,isConnectable:t})]})}function ZK({data:e,isConnectable:t,targetPosition:n=$.Top,sourcePosition:r=$.Bottom}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(YK,{type:`target`,position:n,isConnectable:t}),e?.label,(0,W.jsx)(YK,{type:`source`,position:r,isConnectable:t})]})}function QK(){return null}function $K({data:e,isConnectable:t,targetPosition:n=$.Top}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(YK,{type:`target`,position:n,isConnectable:t}),e?.label]})}var eq={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},tq={input:XK,default:ZK,output:$K,group:QK};function nq(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var rq=e=>{let{width:t,height:n,x:r,y:i}=HH(e.nodeLookup,{filter:e=>!!e.selected});return{width:lU(t)?t:null,height:lU(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function iq({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=wG(),{width:i,height:a,transformString:o,userSelectionActive:c}=CG(rq,yG),l=RK(),u=(0,s.useRef)(null);(0,s.useEffect)(()=>{n||u.current?.focus({preventScroll:!0})},[n]);let d=!c&&i!==null&&a!==null;if(IK({nodeRef:u,disabled:!d}),!d)return null;let f=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,W.jsx)(`div`,{className:HI([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,W.jsx)(`div`,{ref:u,className:`react-flow__nodesselection-rect`,onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(eq,e.key)&&(e.preventDefault(),l({direction:eq[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var aq=typeof window<`u`?window:void 0,oq=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function sq({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P,onViewportChange:F,isControlledViewport:I}){let{nodesSelectionActive:L,userSelectionActive:R}=CG(oq,yG),z=QG(l,{target:aq}),B=QG(h,{target:aq}),V=B||w,H=B||b,U=u&&V!==!0,ee=z||R||U;return TK({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,W.jsx)(kK,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:H,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!z&&V,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:F,isControlledViewport:I,paneClickDistance:s,selectionOnDrag:U,children:(0,W.jsxs)(PK,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:V,autoPanOnSelection:T,isSelecting:!!ee,selectionMode:d,selectionKeyPressed:z,paneClickDistance:s,selectionOnDrag:U,children:[e,L&&(0,W.jsx)(iq,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}sq.displayName=`FlowRenderer`;var cq=(0,s.memo)(sq),lq=e=>t=>e?UH(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function uq(e){return CG((0,s.useCallback)(lq(e),[e]),yG)}var dq=e=>e.updateNodeInternals;function fq(){let e=CG(dq),[t]=(0,s.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,s.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function pq({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=wG(),a=(0,s.useRef)(null),o=(0,s.useRef)(null),c=(0,s.useRef)(e.sourcePosition),l=(0,s.useRef)(e.targetPosition),u=(0,s.useRef)(t),d=n&&!!e.internals.handleBounds;return(0,s.useEffect)(()=>{a.current&&!e.hidden&&(!d||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[d,e.hidden]),(0,s.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,s.useEffect)(()=>{if(a.current){let n=u.current!==t,r=c.current!==e.sourcePosition,o=l.current!==e.targetPosition;(n||r||o)&&(u.current=t,c.current=e.sourcePosition,l.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function mq({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=CG(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},yG),S=y.type||`default`,C=g?.[S]||tq[S];C===void 0&&(v?.(`003`,TH.error003(S)),S=`default`,C=g?.default||tq.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=wG(),k=xU(y),A=pq({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=IK({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=RK();if(y.hidden)return null;let N=bU(y),P=nq(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,z=a?e=>a(e,{...b.userNode}):void 0,B=o?e=>o(e,{...b.userNode}):void 0,V=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&FK({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},H=t=>{if(!(AU(t.nativeEvent)||m)){if(DH.includes(t.key)&&T){let n=t.key===`Escape`;FK({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(eq,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:eq[t.key],factor:t.shiftKey?4:1})}}},U=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(UH(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,W.jsx)(`div`,{className:HI([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:z,onClick:V,onDoubleClick:B,onKeyDown:D?H:void 0,tabIndex:D?0:void 0,onFocus:D?U:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${DG}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,W.jsx)(BK,{value:e,children:(0,W.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var hq=(0,s.memo)(mq),gq=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function _q(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=CG(gq,yG),a=uq(e.onlyRenderVisibleElements),o=fq();return(0,W.jsx)(`div`,{className:`react-flow__nodes`,style:DK,children:a.map(a=>(0,W.jsx)(hq,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}_q.displayName=`NodeRenderer`;var vq=(0,s.memo)(_q);function yq(e){return CG((0,s.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&BU({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),yG)}var bq=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,W.jsx)(`polyline`,{className:`arrow`,style:n,strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`})},xq=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,W.jsx)(`polyline`,{className:`arrowclosed`,style:n,strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`})},Sq={[PH.Arrow]:bq,[PH.ArrowClosed]:xq};function Cq(e){let t=wG();return(0,s.useMemo)(()=>Object.prototype.hasOwnProperty.call(Sq,e)?Sq[e]:(t.getState().onError?.(`009`,TH.error009(e)),null),[e])}var wq=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=Cq(t);return c?(0,W.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,W.jsx)(c,{color:n,strokeWidth:o})}):null},Tq=({defaultColor:e,rfId:t})=>{let n=CG(e=>e.edges),r=CG(e=>e.defaultEdgeOptions),i=(0,s.useMemo)(()=>rW(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,W.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,W.jsx)(`defs`,{children:i.map(e=>(0,W.jsx)(wq,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};Tq.displayName=`MarkerDefinitions`;var Eq=(0,s.memo)(Tq);function Dq({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:c=2,children:l,className:u,...d}){let[f,p]=(0,s.useState)({x:1,y:0,width:0,height:0}),m=HI([`react-flow__edge-textwrapper`,u]),h=(0,s.useRef)(null);return(0,s.useEffect)(()=>{if(h.current){let e=h.current.getBBox();p({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,W.jsxs)(`g`,{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:m,visibility:f.width?`visible`:`hidden`,...d,children:[i&&(0,W.jsx)(`rect`,{width:f.width+2*o[0],x:-o[0],y:-o[1],height:f.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:c,ry:c}),(0,W.jsx)(`text`,{className:`react-flow__edge-text`,y:f.height/2,dy:`0.3em`,ref:h,style:r,children:n}),l]}):null}Dq.displayName=`EdgeText`;var Oq=(0,s.memo)(Dq);function kq({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{...u,d:e,fill:`none`,className:HI([`react-flow__edge-path`,u.className])}),l?(0,W.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&lU(t)&&lU(n)?(0,W.jsx)(Oq,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function Aq({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===$.Left||e===$.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function jq({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top}){let[o,s]=Aq({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=Aq({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=PU({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function Mq(e){return(0,s.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=jq({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s}),x=e.isInternal?void 0:t;return(0,W.jsx)(kq,{id:x,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var Nq=Mq({isInternal:!1}),Pq=Mq({isInternal:!0});Nq.displayName=`SimpleBezierEdge`,Pq.displayName=`SimpleBezierEdgeInternal`;function Fq(e){return(0,s.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=$.Bottom,targetPosition:m=$.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=XU({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition}),S=e.isInternal?void 0:t;return(0,W.jsx)(kq,{id:S,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var Iq=Fq({isInternal:!1}),Lq=Fq({isInternal:!0});Iq.displayName=`SmoothStepEdge`,Lq.displayName=`SmoothStepEdgeInternal`;function Rq(e){return(0,s.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,W.jsx)(Iq,{...n,id:r,pathOptions:(0,s.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var zq=Rq({isInternal:!1}),Bq=Rq({isInternal:!0});zq.displayName=`StepEdge`,Bq.displayName=`StepEdgeInternal`;function Vq(e){return(0,s.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=WU({sourceX:n,sourceY:r,targetX:i,targetY:a}),y=e.isInternal?void 0:t;return(0,W.jsx)(kq,{id:y,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var Hq=Vq({isInternal:!1}),Uq=Vq({isInternal:!0});Hq.displayName=`StraightEdge`,Uq.displayName=`StraightEdgeInternal`;function Wq(e){return(0,s.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=$.Bottom,targetPosition:s=$.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=LU({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature}),S=e.isInternal?void 0:t;return(0,W.jsx)(kq,{id:S,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var Gq=Wq({isInternal:!1}),Kq=Wq({isInternal:!0});Gq.displayName=`BezierEdge`,Kq.displayName=`BezierEdgeInternal`;var qq={default:Kq,straight:Uq,step:Bq,smoothstep:Lq,simplebezier:Pq},Jq={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Yq=(e,t,n)=>n===$.Left?e-t:n===$.Right?e+t:e,Xq=(e,t,n)=>n===$.Top?e-t:n===$.Bottom?e+t:e,Zq=`react-flow__edgeupdater`;function Qq({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,W.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:HI([Zq,`${Zq}-${s}`]),cx:Yq(t,r,e),cy:Xq(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function $q({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=wG(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;LW.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,W.jsxs)(W.Fragment,{children:[(e===!0||e===`source`)&&(0,W.jsx)(Qq,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,W.jsx)(Qq,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function eJ({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:c,onMouseMove:l,onMouseLeave:u,reconnectRadius:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:m,rfId:h,edgeTypes:g,noPanClassName:_,onError:v,disableKeyboardA11y:y}){let b=CG(t=>t.edgeLookup.get(e)),x=CG(e=>e.defaultEdgeOptions);b=x?{...x,...b}:b;let S=b.type||`default`,C=g?.[S]||qq[S];C===void 0&&(v?.(`011`,TH.error011(S)),S=`default`,C=g?.default||qq.default);let w=!!(b.focusable||t&&b.focusable===void 0),T=f!==void 0&&(b.reconnectable||n&&b.reconnectable===void 0),E=!!(b.selectable||r&&b.selectable===void 0),D=(0,s.useRef)(null),[O,k]=(0,s.useState)(!1),[A,j]=(0,s.useState)(!1),M=wG(),{zIndex:N=b.zIndex,sourceX:P,sourceY:F,targetX:I,targetY:L,sourcePosition:R,targetPosition:z}=CG((0,s.useCallback)(t=>{let n=t.nodeLookup.get(b.source),r=t.nodeLookup.get(b.target);if(!n||!r)return Jq;let i=QU({id:e,sourceNode:n,targetNode:r,sourceHandle:b.sourceHandle||null,targetHandle:b.targetHandle||null,connectionMode:t.connectionMode,onError:v}),a=zU({selected:b.selected,zIndex:b.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||Jq,zIndex:a}},[b.source,b.target,b.sourceHandle,b.targetHandle,b.selected,b.zIndex]),yG),B=(0,s.useMemo)(()=>b.markerStart?`url('#${nW(b.markerStart,h)}')`:void 0,[b.markerStart,h]),V=(0,s.useMemo)(()=>b.markerEnd?`url('#${nW(b.markerEnd,h)}')`:void 0,[b.markerEnd,h]);if(b.hidden||P===null||F===null||I===null||L===null)return null;let H=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=M.getState();E&&(M.setState({nodesSelectionActive:!1}),b.selected&&a?(r({nodes:[],edges:[b]}),D.current?.blur()):n([e])),i&&i(t,b)},U=a?e=>{a(e,{...b})}:void 0,ee=o?e=>{o(e,{...b})}:void 0,te=c?e=>{c(e,{...b})}:void 0,ne=l?e=>{l(e,{...b})}:void 0,re=u?e=>{u(e,{...b})}:void 0;return(0,W.jsx)(`svg`,{style:{zIndex:N},children:(0,W.jsxs)(`g`,{className:HI([`react-flow__edge`,`react-flow__edge-${S}`,b.className,_,{selected:b.selected,animated:b.animated,inactive:!E&&!i,updating:O,selectable:E}]),onClick:H,onDoubleClick:U,onContextMenu:ee,onMouseEnter:te,onMouseMove:ne,onMouseLeave:re,onKeyDown:w?t=>{if(!y&&DH.includes(t.key)&&E){let{unselectNodesAndEdges:n,addSelectedEdges:r}=M.getState();t.key===`Escape`?(D.current?.blur(),n({edges:[b]})):r([e])}}:void 0,tabIndex:w?0:void 0,role:b.ariaRole??(w?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":b.ariaLabel===null?void 0:b.ariaLabel||`Edge from ${b.source} to ${b.target}`,"aria-describedby":w?`${OG}-${h}`:void 0,ref:D,...b.domAttributes,children:[!A&&(0,W.jsx)(C,{id:e,source:b.source,target:b.target,type:b.type,selected:b.selected,animated:b.animated,selectable:E,deletable:b.deletable??!0,label:b.label,labelStyle:b.labelStyle,labelShowBg:b.labelShowBg,labelBgStyle:b.labelBgStyle,labelBgPadding:b.labelBgPadding,labelBgBorderRadius:b.labelBgBorderRadius,sourceX:P,sourceY:F,targetX:I,targetY:L,sourcePosition:R,targetPosition:z,data:b.data,style:b.style,sourceHandleId:b.sourceHandle,targetHandleId:b.targetHandle,markerStart:B,markerEnd:V,pathOptions:`pathOptions`in b?b.pathOptions:void 0,interactionWidth:b.interactionWidth}),T&&(0,W.jsx)($q,{edge:b,isReconnectable:T,reconnectRadius:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:m,sourceX:P,sourceY:F,targetX:I,targetY:L,sourcePosition:R,targetPosition:z,setUpdateHover:k,setReconnecting:j})]})})}var tJ=(0,s.memo)(eJ),nJ=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function rJ({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=CG(nJ,yG),b=yq(t);return(0,W.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,W.jsx)(Eq,{defaultColor:e,rfId:n}),b.map(e=>(0,W.jsx)(tJ,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}rJ.displayName=`EdgeRenderer`;var iJ=(0,s.memo)(rJ),aJ=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function oJ({children:e}){let t=wG(),n=(0,s.useRef)(null),[r]=(0,s.useState)(()=>t.getState().transform);return hK(()=>{let e=null,r=()=>{let r=t.getState().transform;e&&r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]||(e=r,n.current&&(n.current.style.transform=aJ(r)))};return r(),t.subscribe(r)},[t]),(0,W.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:aJ(r)},children:e})}function sJ(e){let t=SK(),n=(0,s.useRef)(!1);(0,s.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var cJ=e=>e.panZoom?.syncViewport;function lJ(e){let t=CG(cJ),n=wG();return(0,s.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function uJ(e){return e.connection.inProgress?{...e.connection,to:fU(e.connection.to,e.transform)}:{...e.connection}}function dJ(e){return e?t=>e(uJ(t)):uJ}function fJ(e){return CG(dJ(e),yG)}var pJ=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function mJ({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=CG(pJ,yG);return a&&i&&c?(0,W.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,W.jsx)(`g`,{className:HI([`react-flow__connection`,IH(s)]),children:(0,W.jsx)(hJ,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var hJ=({style:e,type:t=NH.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=fJ();if(!i)return;if(n)return(0,W.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:IH(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case NH.Bezier:[m]=LU(h);break;case NH.SimpleBezier:[m]=jq(h);break;case NH.Step:[m]=XU({...h,borderRadius:0});break;case NH.SmoothStep:[m]=XU(h);break;default:[m]=WU(h)}return(0,W.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};hJ.displayName=`ConnectionLine`;var gJ={};function _J(e=gJ){(0,s.useRef)(e),wG(),(0,s.useEffect)(()=>{},[e])}function vJ(){wG(),(0,s.useRef)(!1),(0,s.useEffect)(()=>{},[])}function yJ({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:z,autoPanOnSelection:B,onPaneClick:V,onPaneMouseEnter:H,onPaneMouseMove:U,onPaneMouseLeave:ee,onPaneScroll:te,onPaneContextMenu:ne,paneClickDistance:re,nodeClickDistance:ie,onEdgeContextMenu:ae,onEdgeMouseEnter:oe,onEdgeMouseMove:se,onEdgeMouseLeave:ce,reconnectRadius:le,onReconnect:ue,onReconnectStart:de,onReconnectEnd:fe,noDragClassName:pe,noWheelClassName:me,noPanClassName:he,disableKeyboardA11y:ge,nodeExtent:_e,rfId:ve,viewport:ye,onViewportChange:be,nodesDraggable:xe}){return _J(e),_J(t),vJ(),sJ(n),lJ(ye),(0,W.jsx)(cq,{onPaneClick:V,onPaneMouseEnter:H,onPaneMouseMove:U,onPaneMouseLeave:ee,onPaneContextMenu:ne,onPaneScroll:te,paneClickDistance:re,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:z,autoPanOnSelection:B,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:pe,noWheelClassName:me,noPanClassName:he,disableKeyboardA11y:ge,onViewportChange:be,isControlledViewport:!!ye,children:(0,W.jsxs)(oJ,{children:[(0,W.jsx)(iJ,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:ue,onReconnectStart:de,onReconnectEnd:fe,onlyRenderVisibleElements:T,onEdgeContextMenu:ae,onEdgeMouseEnter:oe,onEdgeMouseMove:se,onEdgeMouseLeave:ce,reconnectRadius:le,defaultMarkerColor:M,noPanClassName:he,disableKeyboardA11y:ge,rfId:ve}),(0,W.jsx)(mJ,{style:h,type:m,component:g,containerStyle:_}),(0,W.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,W.jsx)(vq,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:ie,onlyRenderVisibleElements:T,noPanClassName:he,noDragClassName:pe,disableKeyboardA11y:ge,nodeExtent:_e,rfId:ve,nodesDraggable:xe}),(0,W.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}yJ.displayName=`GraphView`;var bJ=(0,s.memo)(yJ),xJ=uU(`React Flow`,`https://reactflow.dev/`),SJ=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??EH;xW(h,g,_);let{nodesInitialized:x}=fW(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=_U(HH(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:EH,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:kH.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...MH},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:xJ,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:OH,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},CJ=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>vG((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await KH({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...SJ({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:o,nodesSelectionActive:s}=m(),{nodesInitialized:c,hasSelectedNodes:l}=fW(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o}),u=s&&l;a&&c?(h(),p({nodes:e,nodesInitialized:c,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:u})):p({nodes:e,nodesInitialized:c,nodesSelectionActive:u})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();xW(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=vW(e,n,r,i,a,o,l);d&&(lW(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=eW(e,o.fromHandle,$.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=_W(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(iK(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(aK(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>oK(e,!0)));return}i(sK(r,new Set([...e]),!0)),a(sK(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>oK(e,!0)));return}a(sK(n,new Set([...e]))),i(sK(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(oK(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(oK(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,oK(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,oK(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();(e[0][0]!==o[0][0]||e[0][1]!==o[0][1]||e[1][0]!==o[1][0]||e[1][1]!==o[1][1])&&(fW(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return yW({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...MH}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...SJ()})}},Object.is);function wJ({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:c,initialFitViewOptions:l,fitView:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:m}){let[h]=(0,s.useState)(()=>CJ({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:u,minZoom:o,maxZoom:c,fitViewOptions:l,nodeOrigin:d,nodeExtent:f,zIndexMode:p}));return(0,W.jsx)(xG,{value:h,children:(0,W.jsx)(yK,{children:(0,W.jsx)(WK,{children:m})})})}function TJ({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:c,fitViewOptions:l,minZoom:u,maxZoom:d,nodeOrigin:f,nodeExtent:p,zIndexMode:m}){return(0,s.useContext)(bG)?(0,W.jsx)(W.Fragment,{children:e}):(0,W.jsx)(wJ,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:c,initialFitViewOptions:l,initialMinZoom:u,initialMaxZoom:d,nodeOrigin:f,nodeExtent:p,zIndexMode:m,children:e})}var EJ={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function DJ({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:c,onEdgeClick:l,onInit:u,onMove:d,onMoveStart:f,onMoveEnd:p,onConnect:m,onConnectStart:h,onConnectEnd:g,onClickConnectStart:_,onClickConnectEnd:v,onNodeMouseEnter:y,onNodeMouseMove:b,onNodeMouseLeave:x,onNodeContextMenu:S,onNodeDoubleClick:C,onNodeDragStart:w,onNodeDrag:T,onNodeDragStop:E,onNodesDelete:D,onEdgesDelete:O,onDelete:k,onSelectionChange:A,onSelectionDragStart:j,onSelectionDrag:M,onSelectionDragStop:N,onSelectionContextMenu:P,onSelectionStart:F,onSelectionEnd:I,onBeforeDelete:L,connectionMode:R,connectionLineType:z=NH.Bezier,connectionLineStyle:B,connectionLineComponent:V,connectionLineContainerStyle:H,deleteKeyCode:U=`Backspace`,selectionKeyCode:ee=`Shift`,selectionOnDrag:te=!1,selectionMode:ne=jH.Full,panActivationKeyCode:re=`Space`,multiSelectionKeyCode:ie=vU()?`Meta`:`Control`,zoomActivationKeyCode:ae=vU()?`Meta`:`Control`,snapToGrid:oe,snapGrid:se,onlyRenderVisibleElements:ce=!1,selectNodesOnDrag:le,nodesDraggable:ue,autoPanOnNodeFocus:de,nodesConnectable:fe,nodesFocusable:pe,nodeOrigin:me=UG,edgesFocusable:he,edgesReconnectable:ge,elementsSelectable:_e=!0,defaultViewport:ve=WG,minZoom:ye=.5,maxZoom:be=2,translateExtent:xe=EH,preventScrolling:Se=!0,nodeExtent:Ce,defaultMarkerColor:we=`#b1b1b7`,zoomOnScroll:Te=!0,zoomOnPinch:Ee=!0,panOnScroll:De=!1,panOnScrollSpeed:Oe=.5,panOnScrollMode:ke=AH.Free,zoomOnDoubleClick:Ae=!0,panOnDrag:je=!0,onPaneClick:Me,onPaneMouseEnter:Ne,onPaneMouseMove:Pe,onPaneMouseLeave:Fe,onPaneScroll:Ie,onPaneContextMenu:Le,paneClickDistance:Re=1,nodeClickDistance:ze=0,children:Be,onReconnect:Ve,onReconnectStart:He,onReconnectEnd:Ue,onEdgeContextMenu:We,onEdgeDoubleClick:Ge,onEdgeMouseEnter:Ke,onEdgeMouseMove:qe,onEdgeMouseLeave:Je,reconnectRadius:Ye=10,onNodesChange:Xe,onEdgesChange:Ze,noDragClassName:Qe=`nodrag`,noWheelClassName:$e=`nowheel`,noPanClassName:et=`nopan`,fitView:tt,fitViewOptions:nt,connectOnClick:rt,attributionPosition:it,proOptions:at,defaultEdgeOptions:G,elevateNodesOnSelect:ot=!0,elevateEdgesOnSelect:st=!1,disableKeyboardA11y:ct=!1,autoPanOnConnect:lt,autoPanOnNodeDrag:ut,autoPanOnSelection:dt=!0,autoPanSpeed:ft,connectionRadius:pt,isValidConnection:mt,onError:ht,style:gt,id:_t,nodeDragThreshold:vt,connectionDragThreshold:yt,viewport:bt,onViewportChange:xt,width:St,height:Ct,colorMode:wt=`light`,debug:Tt,onScroll:Et,ariaLabelConfig:Dt,zIndexMode:Ot=`basic`,...kt},At){let jt=_t||`1`,Mt=XG(wt),Nt=(0,s.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Et?.(e)},[Et]);return(0,W.jsx)(`div`,{"data-testid":`rf__wrapper`,...kt,onScroll:Nt,style:{...gt,...EJ},ref:At,className:HI([`react-flow`,i,Mt]),id:_t,role:`application`,children:(0,W.jsxs)(TJ,{nodes:e,edges:t,width:St,height:Ct,fitView:tt,fitViewOptions:nt,minZoom:ye,maxZoom:be,nodeOrigin:me,nodeExtent:Ce,zIndexMode:Ot,children:[(0,W.jsx)(JG,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:h,onConnectEnd:g,onClickConnectStart:_,onClickConnectEnd:v,nodesDraggable:ue,autoPanOnNodeFocus:de,nodesConnectable:fe,nodesFocusable:pe,edgesFocusable:he,edgesReconnectable:ge,elementsSelectable:_e,elevateNodesOnSelect:ot,elevateEdgesOnSelect:st,minZoom:ye,maxZoom:be,nodeExtent:Ce,onNodesChange:Xe,onEdgesChange:Ze,snapToGrid:oe,snapGrid:se,connectionMode:R,translateExtent:xe,connectOnClick:rt,defaultEdgeOptions:G,fitView:tt,fitViewOptions:nt,onNodesDelete:D,onEdgesDelete:O,onDelete:k,onNodeDragStart:w,onNodeDrag:T,onNodeDragStop:E,onSelectionDrag:M,onSelectionDragStart:j,onSelectionDragStop:N,onMove:d,onMoveStart:f,onMoveEnd:p,noPanClassName:et,nodeOrigin:me,rfId:jt,autoPanOnConnect:lt,autoPanOnNodeDrag:ut,autoPanSpeed:ft,onError:ht,connectionRadius:pt,isValidConnection:mt,selectNodesOnDrag:le,nodeDragThreshold:vt,connectionDragThreshold:yt,onBeforeDelete:L,debug:Tt,ariaLabelConfig:Dt,zIndexMode:Ot}),(0,W.jsx)(bJ,{onInit:u,onNodeClick:c,onEdgeClick:l,onNodeMouseEnter:y,onNodeMouseMove:b,onNodeMouseLeave:x,onNodeContextMenu:S,onNodeDoubleClick:C,nodeTypes:a,edgeTypes:o,connectionLineType:z,connectionLineStyle:B,connectionLineComponent:V,connectionLineContainerStyle:H,selectionKeyCode:ee,selectionOnDrag:te,selectionMode:ne,deleteKeyCode:U,multiSelectionKeyCode:ie,panActivationKeyCode:re,zoomActivationKeyCode:ae,onlyRenderVisibleElements:ce,defaultViewport:ve,translateExtent:xe,minZoom:ye,maxZoom:be,preventScrolling:Se,zoomOnScroll:Te,zoomOnPinch:Ee,zoomOnDoubleClick:Ae,panOnScroll:De,panOnScrollSpeed:Oe,panOnScrollMode:ke,panOnDrag:je,autoPanOnSelection:dt,onPaneClick:Me,onPaneMouseEnter:Ne,onPaneMouseMove:Pe,onPaneMouseLeave:Fe,onPaneScroll:Ie,onPaneContextMenu:Le,paneClickDistance:Re,nodeClickDistance:ze,onSelectionContextMenu:P,onSelectionStart:F,onSelectionEnd:I,onReconnect:Ve,onReconnectStart:He,onReconnectEnd:Ue,onEdgeContextMenu:We,onEdgeDoubleClick:Ge,onEdgeMouseEnter:Ke,onEdgeMouseMove:qe,onEdgeMouseLeave:Je,reconnectRadius:Ye,defaultMarkerColor:we,noDragClassName:Qe,noWheelClassName:$e,noPanClassName:et,rfId:jt,disableKeyboardA11y:ct,nodeExtent:Ce,viewport:bt,onViewportChange:xt,nodesDraggable:ue}),(0,W.jsx)(HG,{onSelectionChange:A}),Be,(0,W.jsx)(IG,{proOptions:at,position:it}),(0,W.jsx)(NG,{rfId:jt,disableKeyboardA11y:ct})]})})}var OJ=mK(DJ);TH.error014();function kJ({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,W.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:HI([`react-flow__background-pattern`,n,r])})}function AJ({radius:e,className:t}){return(0,W.jsx)(`circle`,{cx:e,cy:e,r:e,className:HI([`react-flow__background-pattern`,`dots`,t])})}var jJ;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(jJ||={});var MJ={[jJ.Dots]:1,[jJ.Lines]:1,[jJ.Cross]:6},NJ=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function PJ({id:e,variant:t=jJ.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:c,style:l,className:u,patternClassName:d}){let f=(0,s.useRef)(null),{transform:p,patternId:m}=CG(NJ,yG),h=r||MJ[t],g=t===jJ.Dots,_=t===jJ.Cross,v=Array.isArray(n)?n:[n,n],y=[v[0]*p[2]||1,v[1]*p[2]||1],b=h*p[2],x=Array.isArray(a)?a:[a,a],S=_?[b,b]:y,C=[x[0]*p[2]||1+S[0]/2,x[1]*p[2]||1+S[1]/2],w=`${m}${e||``}`;return(0,W.jsxs)(`svg`,{className:HI([`react-flow__background`,u]),style:{...l,...DK,"--xy-background-color-props":c,"--xy-background-pattern-color-props":o},ref:f,"data-testid":`rf__background`,children:[(0,W.jsx)(`pattern`,{id:w,x:p[0]%y[0],y:p[1]%y[1],width:y[0],height:y[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${C[0]},-${C[1]})`,children:g?(0,W.jsx)(AJ,{radius:b/2,className:d}):(0,W.jsx)(kJ,{dimensions:S,lineWidth:i,variant:t,className:d})}),(0,W.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${w})`})]})}PJ.displayName=`Background`,(0,s.memo)(PJ);function FJ(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,W.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function IJ(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,W.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function LJ(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,W.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function RJ(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,W.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function zJ(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,W.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function BJ({children:e,className:t,...n}){return(0,W.jsx)(`button`,{type:`button`,className:HI([`react-flow__controls-button`,t]),...n,children:e})}var VJ=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function HJ({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=wG(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=CG(VJ,yG),{zoomIn:y,zoomOut:b,fitView:x}=SK();return(0,W.jsxs)(PG,{className:HI([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(BJ,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,W.jsx)(FJ,{})}),(0,W.jsx)(BJ,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,W.jsx)(IJ,{})})]}),n&&(0,W.jsx)(BJ,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,W.jsx)(LJ,{})}),r&&(0,W.jsx)(BJ,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,W.jsx)(zJ,{}):(0,W.jsx)(RJ,{})}),u]})}HJ.displayName=`Controls`;var UJ=(0,s.memo)(HJ);function WJ({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,W.jsx)(`rect`,{className:HI([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var GJ=(0,s.memo)(WJ),KJ=e=>e.nodes.map(e=>e.id),qJ=e=>e instanceof Function?e:()=>e;function JJ({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=GJ,onClick:o}){let s=CG(KJ,yG),c=qJ(t),l=qJ(e),u=qJ(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,W.jsx)(W.Fragment,{children:s.map(e=>(0,W.jsx)(XJ,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function YJ({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=CG(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=bU(r);return{node:r,x:i,y:a,width:o,height:s}},yG);return!l||l.hidden||!xU(l)?null:(0,W.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var XJ=(0,s.memo)(YJ),ZJ=(0,s.memo)(JJ),QJ=200,$J=150,eY=e=>!e.hidden,tY=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?aU(HH(e.nodeLookup,{filter:eY}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},nY=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,rY=(e,t)=>nY(e.viewBB,t.viewBB)&&nY(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,iY=`react-flow__minimap-desc`;function aY({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:c,bgColor:l,maskColor:u,maskStrokeColor:d,maskStrokeWidth:f,position:p=`bottom-right`,onClick:m,onNodeClick:h,pannable:g=!1,zoomable:_=!1,ariaLabel:v,inversePan:y,zoomStep:b=1,offsetScale:x=5}){let S=wG(),C=(0,s.useRef)(null),{boundingRect:w,viewBB:T,rfId:E,panZoom:D,translateExtent:O,flowWidth:k,flowHeight:A,ariaLabelConfig:j}=CG(tY,rY),M=e?.width??QJ,N=e?.height??$J,P=w.width/M,F=w.height/N,I=Math.max(P,F),L=I*M,R=I*N,z=x*I,B=w.x-(L-w.width)/2-z,V=w.y-(R-w.height)/2-z,H=L+z*2,U=R+z*2,ee=`${iY}-${E}`,te=(0,s.useRef)(0),ne=(0,s.useRef)();te.current=I,(0,s.useEffect)(()=>{if(C.current&&D)return ne.current=RW({domNode:C.current,panZoom:D,getTransform:()=>S.getState().transform,getViewScale:()=>te.current}),()=>{ne.current?.destroy()}},[D]),(0,s.useEffect)(()=>{ne.current?.update({translateExtent:O,width:k,height:A,inversePan:y,pannable:g,zoomStep:b,zoomable:_})},[g,_,y,b,O,k,A]);let re=m?e=>{let[t,n]=ne.current?.pointer(e)||[0,0];m(e,{x:t,y:n})}:void 0,ie=h?(0,s.useCallback)((e,t)=>{let n=S.getState().nodeLookup.get(t).internals.userNode;h(e,n)},[]):void 0,ae=v??j[`minimap.ariaLabel`];return(0,W.jsx)(PG,{position:p,style:{...e,"--xy-minimap-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-background-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof d==`string`?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof f==`number`?f*I:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:HI([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,W.jsxs)(`svg`,{width:M,height:N,viewBox:`${B} ${V} ${H} ${U}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":ee,ref:C,onClick:re,children:[ae&&(0,W.jsx)(`title`,{id:ee,children:ae}),(0,W.jsx)(ZJ,{onClick:ie,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:c}),(0,W.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${B-z},${V-z}h${H+z*2}v${U+z*2}h${-H-z*2}z
|
|
244
|
-
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}aY.displayName=`MiniMap`,(0,s.memo)(aY);var oY=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,sY={[$W.Line]:`right`,[$W.Handle]:`bottom-right`};function cY({nodeId:e,position:t,variant:n=$W.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:c=10,minHeight:l=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:p,autoScale:m=!0,shouldResize:h,onResizeStart:g,onResize:_,onResizeEnd:v}){let y=VK(),b=typeof e==`string`?e:y,x=wG(),S=(0,s.useRef)(null),C=n===$W.Handle,w=CG((0,s.useCallback)(oY(C&&m),[C,m]),yG),T=(0,s.useRef)(null),E=t??sY[n];(0,s.useEffect)(()=>{if(!(!S.current||!b))return T.current||=uG({domNode:S.current,nodeId:b,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=x.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=x.getState(),o=[],s={x:e.x,y:e.y},c=r.get(b);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=_W([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...SU({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:b,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:b,type:`dimensions`,resizing:!0,setAttributes:p?p===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:b,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};x.getState().triggerNodeChanges([n])}}),T.current.update({controlPosition:E,boundaries:{minWidth:c,minHeight:l,maxWidth:u,maxHeight:d},keepAspectRatio:f,resizeDirection:p,onResizeStart:g,onResize:_,onResizeEnd:v,shouldResize:h}),()=>{T.current?.destroy()}},[E,c,l,u,d,f,g,_,v,h]);let D=E.split(`-`);return(0,W.jsx)(`div`,{className:HI([`react-flow__resize-control`,`nodrag`,...D,n,r]),ref:S,style:{...i,scale:w,...o&&{[C?`backgroundColor`:`borderColor`]:o}},children:a})}(0,s.memo)(cY);var lY=204,uY=96,dY=84,fY={input:xe,runtime:H,model:re,capabilities:Te,output:R};function pY(e,t=34){return e?e.length<=t?e:`${e.slice(0,t)}…`:`-`}function mY(e){if(!e)return`刚刚`;let t=new Date(e);return Number.isNaN(t.getTime())?`未知时间`:new Intl.DateTimeFormat(`zh-CN`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}).format(t)}function hY({data:e}){let t=fY[e.icon];return(0,W.jsxs)(`div`,{className:`pipeline-node-card`,children:[(0,W.jsx)(YK,{id:`top`,type:`target`,position:$.Top}),(0,W.jsx)(YK,{id:`top-out`,type:`source`,position:$.Top}),(0,W.jsx)(YK,{id:`right`,type:`source`,position:$.Right}),(0,W.jsx)(YK,{id:`right-in`,type:`target`,position:$.Right}),(0,W.jsx)(YK,{id:`bottom`,type:`source`,position:$.Bottom}),(0,W.jsx)(YK,{id:`bottom-in`,type:`target`,position:$.Bottom}),(0,W.jsx)(YK,{id:`left`,type:`target`,position:$.Left}),(0,W.jsx)(YK,{id:`left-out`,type:`source`,position:$.Left}),(0,W.jsx)(`span`,{className:`pipeline-node-icon`,children:(0,W.jsx)(t,{size:15})}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:e.title}),(0,W.jsx)(`small`,{children:e.subtitle})]})]})}var gY={pipeline:hY};function _Y(e,t){let n=Math.max(560,t-96),r=Math.max(1,Math.min(n>=1120||n>=720?3:2,e.length)),i=r*lY+(r-1)*dY,a=Math.max(48,(Math.max(t,560)-i)/2),o=e.map((e,t)=>{let n=Math.floor(t/r),i=t%r,o=n%2==0?i:r-1-i;return{row:n,column:o,x:a+o*288,y:56+n*172}});return{nodes:e.map((e,t)=>({id:e.id,type:`pipeline`,position:{x:o[t].x,y:o[t].y},data:{title:e.title,subtitle:e.subtitle,icon:e.icon},style:{width:lY,height:uY}})),edges:e.slice(1).map((t,n)=>{let r=o[n],i=o[n+1],a=r.row!==i.row,s=i.column>r.column;return{id:`edge-${e[n].id}-${t.id}`,source:e[n].id,target:t.id,sourceHandle:a?`bottom`:s?`right`:`left-out`,targetHandle:a?`top`:s?`left`:`right-in`,type:`smoothstep`,label:t.incomingLabel,markerEnd:{type:PH.ArrowClosed,width:14,height:14}}})}}function vY(){let e=(0,s.useRef)(null),[t,n]=(0,s.useState)(960);return(0,s.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=e=>{e>0&&n(e)};r(t.getBoundingClientRect().width);let i=new ResizeObserver(e=>{r(e[0]?.contentRect.width||0)});return i.observe(t),()=>i.disconnect()},[]),{containerRef:e,width:t}}function yY({steps:e}){let{containerRef:t,width:n}=vY(),[r,i]=(0,s.useState)(null),a=(0,s.useMemo)(()=>_Y(e,n),[e,n]);return(0,s.useEffect)(()=>{r&&requestAnimationFrame(()=>r.fitView({padding:.16,duration:260}))},[a,r]),(0,W.jsx)(`div`,{ref:t,className:`orchestration-graph`,role:`application`,"aria-label":`执行链路画布`,"data-layout":`adaptive-serpentine`,"data-background":`plain`,children:(0,W.jsx)(OJ,{nodes:a.nodes,edges:a.edges,nodeTypes:gY,onInit:i,fitView:!0,fitViewOptions:{padding:.16},minZoom:.55,maxZoom:1.35,nodesConnectable:!1,elementsSelectable:!0,panOnScroll:!0,selectionOnDrag:!1,proOptions:{hideAttribution:!0},children:(0,W.jsx)(UJ,{showFitView:!1,position:`bottom-right`,children:(0,W.jsx)(BJ,{"aria-label":`适应画布`,title:`适应画布`,onClick:()=>r?.fitView({padding:.16,duration:260}),children:(0,W.jsx)(ve,{size:14})})})})})}function bY({currentAgentId:e,agents:t,onSelectAgent:n,onCreate:r}){let[i,a]=(0,s.useState)(null),[o,c]=(0,s.useState)([]),[l,u]=(0,s.useState)([]);(0,s.useEffect)(()=>{f(`/api/v1/catalog/resources?limit=200`).then(e=>e.json()).then(e=>u(e.items||[])).catch(()=>{})},[]),(0,s.useEffect)(()=>{if(!e){a(null),c([]);return}let t=!1;return Promise.all([f(`/api/v1/agents/${encodeURIComponent(e)}`).then(e=>e.json()),f(`/api/v1/runs?limit=200`).then(e=>e.json()).catch(()=>({items:[]}))]).then(([n,r])=>{t||(a(n.draft||null),c((r.items||[]).filter(t=>t.agentId===e)))}).catch(()=>{t||(a(null),c([]))}),()=>{t=!0}},[e]);let d=i?.spec?.bindings||{},p=i?.spec?.runtime?.type||i?.metadata?.labels?.[`agentkit.ksyun.com/framework`]||`runtime`,m=i?.spec?.execution?.strategy||`direct`,h=l.find(e=>e.resourceId===d.modelProfileId),g=(d.tools?.length||0)+(d.mcpServers?.length||0)+(d.skills?.length||0),_=o.slice(-5).reverse(),v=(0,s.useMemo)(()=>{let e=[{id:`input`,icon:`input`,title:`任务输入`,subtitle:`用户消息与会话上下文`},{id:`runtime`,icon:`runtime`,title:`${p} RuntimeAdapter`,subtitle:`${m} · 本地执行`,incomingLabel:`调度`},{id:`model`,icon:`model`,title:h?.displayName||d.modelProfileId||`未绑定模型`,subtitle:`Model Profile`,incomingLabel:`调用模型`}];return g>0&&e.push({id:`capabilities`,icon:`capabilities`,title:`${g} 个能力绑定`,subtitle:`${d.tools?.length||0} Tool · ${d.mcpServers?.length||0} MCP · ${d.skills?.length||0} Skill`,incomingLabel:`加载能力`}),e.push({id:`output`,icon:`output`,title:`结构化输出`,subtitle:`返回会话并写入 Trace`,incomingLabel:`写回结果`}),e},[d,g,h?.displayName,p,m]);return(0,W.jsxs)(`div`,{className:`page-container orchestration-page`,"data-layout":i?`workbench`:`document`,children:[(0,W.jsx)(`header`,{className:`page-header`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{children:`任务编排`}),(0,W.jsx)(`p`,{children:`把当前 Agent 的声明式配置映射为可检查的执行链路与端云路由。`})]})}),i?(0,W.jsxs)(`div`,{className:`orchestration-workbench`,children:[(0,W.jsxs)(`section`,{className:`orchestration-canvas`,children:[(0,W.jsxs)(`div`,{className:`section-heading`,children:[(0,W.jsx)(nt,{name:i.metadata?.name||`Agent`,appearance:i.metadata?.appearance,size:`md`}),(0,W.jsxs)(`div`,{className:`section-heading-copy`,children:[(0,W.jsx)(`h2`,{children:i.metadata?.name}),(0,W.jsxs)(`p`,{children:[i.metadata?.id,` · revision `,i.metadata?.revision,` · `,p,` · 本地执行`]})]})]}),(0,W.jsx)(yY,{steps:v})]}),(0,W.jsxs)(`aside`,{className:`orchestration-aside`,children:[(0,W.jsxs)(`section`,{className:`orchestration-aside-section`,children:[(0,W.jsx)(`div`,{className:`aside-title`,children:`路由与约束`}),(0,W.jsxs)(`dl`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Revision`}),(0,W.jsxs)(`dd`,{children:[`r`,i.metadata?.revision]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`执行位置`}),(0,W.jsx)(`dd`,{children:`Edge · Local`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Runtime`}),(0,W.jsx)(`dd`,{children:p})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`策略`}),(0,W.jsx)(`dd`,{children:m})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`最大步骤`}),(0,W.jsx)(`dd`,{children:i.spec?.execution?.maxSteps||`-`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`云端`}),(0,W.jsx)(`dd`,{children:`未连接`})]})]})]}),(0,W.jsx)(`div`,{className:`aside-divider`}),(0,W.jsxs)(`section`,{className:`orchestration-aside-section`,children:[(0,W.jsx)(`div`,{className:`aside-title`,children:`最近调度`}),(0,W.jsx)(`div`,{className:`dispatch-log`,children:_.length===0?(0,W.jsx)(`div`,{className:`dispatch-log-empty`,children:`当前 Agent 还没有运行记录`}):_.map(e=>(0,W.jsxs)(`div`,{className:`dispatch-log-row`,children:[(0,W.jsx)(`span`,{className:`dispatch-status ${String(e.status).toLowerCase()}`}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:pY(e.input||`Run`)}),(0,W.jsxs)(`small`,{children:[mY(e.startedAt),` · `,e.status]})]})]},e.id))})]})]})]}):(0,W.jsxs)(`div`,{className:`orchestration-empty`,children:[(0,W.jsx)(`span`,{className:`empty-icon`,children:(0,W.jsx)(Te,{size:24})}),(0,W.jsx)(`h2`,{children:`先选择或创建一个 Agent`}),(0,W.jsx)(`p`,{children:`编排视图会读取 Agent Revision、RuntimeRef 和能力绑定生成真实执行链路。`}),(0,W.jsxs)(`button`,{className:`button accent`,type:`button`,onClick:r,children:[(0,W.jsx)(Pe,{size:15}),(0,W.jsx)(`span`,{children:`创建 Agent`})]})]})]})}var xY=[{value:`system`,label:`跟随系统`,description:`随 macOS 或浏览器切换`,icon:Ce},{value:`light`,label:`浅色`,description:`始终使用明亮界面`,icon:Ge},{value:`dark`,label:`深色`,description:`始终使用暗色界面`,icon:we}];function SY({themePreference:e,onThemePreferenceChange:t,onClose:n}){let[r,i]=(0,s.useState)(null),a=cm({resolver:vm(oF),defaultValues:{sandbox:`read-only`,buildAfterCreate:!0,codexProxy:`auto`,cloudAccessKey:``,cloudSecretKey:``,cloudRegion:``}}),[o,c]=(0,s.useState)([]),[l,u]=(0,s.useState)([]),[d,p]=(0,s.useState)(!1),[m,h]=(0,s.useState)(null),g=(0,s.useCallback)(async()=>{try{let[e,t]=await Promise.all([f(`/api/v1/catalog/resources?limit=200`).then(e=>e.json()),f(`/api/v1/catalog/models`).then(e=>e.json()).catch(()=>null)]),n=(e.items||[]).filter(e=>e.kind===`model`);t?.items?.length&&(n=[...n.filter(e=>e.source===`local`||e.source===`market`),...t.items]);let r=[],i=new Set;for(let e of n){let t=e.requiredSecretRefs?.[0]||e.contract?.credentialRef||``;if(!t||i.has(t))continue;i.add(t);let n=t.replace(/^env:\/\//,``),a={configured:!1,source:`missing`};try{a=await f(`/api/v1/credentials/${encodeURIComponent(n)}`).then(e=>e.json())}catch{}r.push({ref:t,name:n,configured:!!a?.configured,source:a?.source||`missing`,model:e})}c(r)}catch{c([])}},[]);(0,s.useEffect)(()=>{(async()=>{try{let e=await f(`/api/v1/system/settings`).then(e=>e.json());i(e),a.reset({sandbox:e.sandbox||`read_only`,buildAfterCreate:e.buildAfterCreate!==!1,codexProxy:e.codexProxy||`auto`,cloudAccessKey:``,cloudSecretKey:``,cloudRegion:e.cloudRegion||``})}catch{i({})}await g();try{let e=await f(`/api/v1/system/bootstrap`).then(e=>e.json());u([[`工作区`,e?.workspace?.name||`-`],[`路径`,e?.workspace?.path||`-`],[`API 版本`,e?.apiVersion||`-`]])}catch{u([])}})()},[g,a]);async function _(e){p(!0);try{let t={sandbox:e.sandbox,buildAfterCreate:e.buildAfterCreate,codexProxy:e.codexProxy};e.cloudAccessKey.trim()&&(t.cloudAccessKey=e.cloudAccessKey.trim()),e.cloudSecretKey.trim()&&(t.cloudSecretKey=e.cloudSecretKey.trim()),e.cloudRegion.trim()&&(t.cloudRegion=e.cloudRegion.trim());let r=await f(`/api/v1/system/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!r.ok){let e=await r.json().catch(()=>null);if(Bg(e,a.setError)){p(!1);return}throw Error(e?.error?.message||`保存失败(${r.status})`)}n(),Cm(`设置已保存`,`工作区级配置已写入 .agentkit/settings.yaml。`)}catch(e){Cm(`保存失败`,e.message,`error`)}p(!1)}return(0,W.jsx)(Ap,{...a,children:(0,W.jsxs)(FC,{title:`设置`,subtitle:`工作区级配置,保存到 .agentkit/settings.yaml,重启后仍生效。`,wide:!0,onClose:n,footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:`button secondary`,type:`button`,onClick:n,children:`取消`}),(0,W.jsxs)(`button`,{className:`button accent`,type:`button`,onClick:a.handleSubmit(_),disabled:d||r==null,children:[(0,W.jsx)(j,{size:15}),(0,W.jsx)(`span`,{children:d?`保存中`:`保存`})]})]}),children:[(0,W.jsxs)(`section`,{className:`settings-group`,children:[(0,W.jsx)(`h3`,{children:`外观`}),(0,W.jsx)(`div`,{className:`appearance-options`,role:`radiogroup`,"aria-label":`颜色模式`,children:xY.map(n=>{let r=n.icon;return(0,W.jsxs)(`label`,{className:`appearance-option${e===n.value?` selected`:``}`,children:[(0,W.jsx)(r,{"aria-hidden":`true`}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:n.label}),(0,W.jsx)(`small`,{children:n.description})]}),(0,W.jsx)(`input`,{type:`radio`,name:`studio-theme`,value:n.value,checked:e===n.value,onChange:()=>t(n.value)})]},n.value)})}),(0,W.jsx)(`p`,{className:`appearance-note`,children:`外观仅保存到当前浏览器,并会立即应用到 Studio 与会话工作台。`})]}),(0,W.jsxs)(`section`,{className:`settings-group`,children:[(0,W.jsx)(`h3`,{children:`执行与沙箱`}),(0,W.jsx)(q,{label:`默认执行权限(Codex)`,requirement:`required`,htmlFor:`settingSandbox`,hint:`新 Agent 默认值;会话页可单次覆盖,下一轮对话生效。`,error:a.formState.errors.sandbox?.message,children:(0,W.jsx)(Tf,{id:`settingSandbox`,ariaLabel:`默认执行权限`,value:a.watch(`sandbox`),options:[{value:`read-only`,label:`只读沙箱(不可写)`},{value:`workspace-write`,label:`请求批准(写工作区,每次询问)`},{value:`workspace-write-auto`,label:`替我审批(写工作区,仅风险询问)`},{value:`full-access`,label:`完全访问(不受限读写)`}],onValueChange:e=>a.setValue(`sandbox`,e,{shouldDirty:!0,shouldValidate:!0})})}),(0,W.jsx)(`div`,{className:`studio-form-field`,children:(0,W.jsxs)(`label`,{className:`checkbox-row`,children:[(0,W.jsx)(`input`,{type:`checkbox`,...a.register(`buildAfterCreate`)}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:`创建后立即构建`}),(0,W.jsx)(`small`,{children:`新建 Agent 保存后自动构建并进入会话`})]})]})})]}),(0,W.jsxs)(`section`,{className:`settings-group`,children:[(0,W.jsx)(`h3`,{children:`凭证`}),o.length===0?(0,W.jsx)(`div`,{className:`settings-empty`,children:`暂无凭证`}):o.map(e=>(0,W.jsxs)(`div`,{className:`settings-credential`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:e.name}),(0,W.jsx)(`small`,{children:e.configured?`已配置 · ${e.source}`:`未配置`})]}),(0,W.jsx)(`button`,{className:`button secondary small`,type:`button`,onClick:()=>h(e.model),children:`配置`})]},e.ref))]}),(0,W.jsxs)(`section`,{className:`settings-group`,children:[(0,W.jsx)(`h3`,{children:`运行时`}),(0,W.jsx)(q,{label:`Codex Responses→Chat 代理`,requirement:`required`,htmlFor:`settingCodexProxy`,hint:`非原生 Responses 上游可启用兼容代理。`,error:a.formState.errors.codexProxy?.message,children:(0,W.jsx)(Tf,{id:`settingCodexProxy`,ariaLabel:`Codex Responses 代理`,value:a.watch(`codexProxy`),options:[{value:`auto`,label:`自动(探测)`},{value:`forced`,label:`强制启用`},{value:`direct`,label:`强制直连`}],onValueChange:e=>a.setValue(`codexProxy`,e,{shouldDirty:!0,shouldValidate:!0})})})]}),(0,W.jsxs)(`section`,{className:`settings-group`,children:[(0,W.jsx)(`h3`,{children:`云基础信息凭证`}),(0,W.jsx)(`p`,{className:`helper`,children:`用于 Agent 部署/销毁到金山云;自动从环境变量 KINGSOFTCLOUD_ACCESS_KEY/KINGSOFTCLOUD_SECRET_KEY/KSYUN_REGION 读取,留空保持环境值。`}),(0,W.jsxs)(`div`,{className:`form-grid two-columns`,children:[(0,W.jsx)(q,{label:`Access Key`,requirement:`optional`,htmlFor:`settingCloudAk`,error:a.formState.errors.cloudAccessKey?.message,children:(0,W.jsx)(`input`,{id:`settingCloudAk`,type:`password`,autoComplete:`new-password`,placeholder:r?.cloudAccessKey?`已配置(输入新值覆盖)`:`从 KINGSOFTCLOUD_ACCESS_KEY 读取`,...a.register(`cloudAccessKey`)})}),(0,W.jsx)(q,{label:`Secret Key`,requirement:`optional`,htmlFor:`settingCloudSk`,error:a.formState.errors.cloudSecretKey?.message,children:(0,W.jsx)(`input`,{id:`settingCloudSk`,type:`password`,autoComplete:`new-password`,placeholder:r?.cloudSecretKey?`已配置(输入新值覆盖)`:`从 KINGSOFTCLOUD_SECRET_KEY 读取`,...a.register(`cloudSecretKey`)})})]}),(0,W.jsx)(q,{label:`Region`,requirement:`optional`,htmlFor:`settingCloudRegion`,error:a.formState.errors.cloudRegion?.message,children:(0,W.jsx)(`input`,{id:`settingCloudRegion`,placeholder:`cn-beijing-6`,...a.register(`cloudRegion`)})})]}),(0,W.jsxs)(`section`,{className:`settings-group`,children:[(0,W.jsx)(`h3`,{children:`关于`}),(0,W.jsx)(`dl`,{className:`trace-detail-grid`,children:l.map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e}),(0,W.jsx)(`dd`,{children:t})]},e))})]}),m&&(0,W.jsx)(CF,{model:m,onClose:()=>h(null),onChanged:g})]})})}function CY(e,t){let n=Math.max(0,Number(t)||0),r=Number.isFinite(e)&&Number(e)>=0&&n>0,i=r?Math.max(0,Number(e)):0;return{known:r,usedTokens:i,limitTokens:n,percent:r?Math.max(0,Math.min(100,Math.round(i/n*100))):0}}function wY(e){return{title:`上下文窗口`,value:e.known?`${e.percent}% 已用`:`用量未上报`,detail:e.known?`已用 ${e.usedTokens.toLocaleString(`en-US`)} tokens,共 ${e.limitTokens.toLocaleString(`en-US`)}`:e.limitTokens>0?`上限 ${e.limitTokens.toLocaleString(`en-US`)} tokens`:`当前模型未提供上下文上限`}}function TY(e){return[...e].reverse().find(e=>e.usage?.reported===!0&&Number.isFinite(e.usage.inputTokens))?.usage?.inputTokens}var EY=new Set([`RUNNING`,`PAUSED`,`WAITING_INPUT`]);function DY(e){return[...e].filter(e=>EY.has(String(e.status||``))).sort((e,t)=>Date.parse(e.startedAt||`1970-01-01`)-Date.parse(t.startedAt||`1970-01-01`)).at(-1)}function OY(e,t){return t?e.filter(e=>e.id!==t):e}function kY(e){let t=e.completedAt||e.startedAt||``,n=Date.parse(t);return Number.isFinite(n)?n:0}function AY(e,t){let n=new Map;for(let r of e){if(r.agentId!==t||!r.sessionId)continue;let e=n.get(r.sessionId)||[];e.push(r),n.set(r.sessionId,e)}return[...n.entries()].map(([e,t])=>{let n=[...t].sort((e,t)=>kY(e)-kY(t)),r=n[0],i=n.at(-1),a=[...n].reverse().find(e=>EY.has(String(e.status||``)));return{id:e,title:r?.input?.trim()||`新会话`,updatedAt:i.completedAt||i.startedAt||``,running:!!a,activeStatus:a?.status,runs:n}}).sort((e,t)=>Date.parse(t.updatedAt||`1970-01-01`)-Date.parse(e.updatedAt||`1970-01-01`))}function jY(e,t){return{localId:e,responseId:e,sessionId:t,runId:``,reasoning:``,output:``,status:`streaming`,error:``,activities:[],surfaces:[]}}function MY(e){return e&&typeof e==`object`?e:{}}function NY(e,t){let n=String(t.type||``);if(n===`response.created`||n===`response.in_progress`){let n=MY(t.response);return{...e,responseId:String(n.id||e.responseId)}}if(n===`response.reasoning_summary_text.delta`)return{...e,reasoning:e.reasoning+String(t.delta||``)};if(n===`response.output_text.delta`)return{...e,output:e.output+String(t.delta||``)};if(n===`response.output_item.added`||n===`response.output_item.done`){let r=UY(MY(t.item),n.endsWith(`.done`));if(!r)return e;let i=e.activities.findIndex(e=>e.id===r.id),a=[...e.activities];return i<0?a.push(r):a[i]={...a[i],...r},{...e,activities:a}}if(n.startsWith(`a2ui.`))return LY(e,t);if(n===`response.paused`)return{...e,runId:String(t.runId||t.run_id||e.runId),status:`paused`};if(n===`response.resumed`)return{...e,runId:String(t.runId||t.run_id||e.runId),status:`streaming`};if(/^response\.(?:web_search_call|file_search_call|mcp_call)\./.test(n)){let r=String(t.item_id||t.itemId||t.call_id||t.callId||n.split(`.`)[1]),i=n.includes(`web_search`)?`网页搜索`:n.includes(`file_search`)?`文件搜索`:`MCP 调用`,a=n.endsWith(`.failed`)?`failed`:n.endsWith(`.completed`)?`completed`:`running`,o={id:`tool:${r}`,kind:`tool`,title:i,status:a,detail:``,data:MY(t)},s=e.activities.findIndex(e=>e.id===o.id),c=[...e.activities];return s<0?c.push(o):c[s]={...c[s],...o},{...e,activities:c}}if(n===`response.completed`){let n=MY(t.response),r=MY(n.metadata);return{...e,responseId:String(n.id||e.responseId),runId:String(r.runtime_run_id||r.runtimeRunId||e.runId),usage:MY(n.usage),status:`completed`}}if(n===`response.cancelled`||n===`response.canceled`)return{...e,status:`cancelled`};if(n===`response.failed`||n===`error`){let n=MY(t.response),r=MY(t.error||n.error);return{...e,status:`failed`,error:String(r.message||t.message||`Agent 运行失败`)}}return e}function PY(e){return{id:e,catalogId:``,components:{},roots:[],dataModel:{}}}function FY(e){let t=e.a2uiOperations??e.a2ui_operations??e.operations;return Array.isArray(t)?t.map(MY):[]}function IY(e,t){for(let n of t){let t=MY(n.createSurface);if(Object.keys(t).length){let n=String(t.surfaceId||t.surface_id||``);if(!n)continue;let r=e.get(n)||PY(n);e.set(n,{...r,catalogId:String(t.catalogId||t.catalog_id||r.catalogId)});continue}let r=MY(n.updateComponents);if(Object.keys(r).length){let t=String(r.surfaceId||r.surface_id||``);if(!t)continue;let n=e.get(t)||PY(t),i={...n.components},a=Array.isArray(r.components)?r.components.map(MY):[];for(let e of a){let t=String(e.id||e.componentId||e.component_id||``),n=String(e.component||e.type||``);t&&n&&(i[t]={...e,id:t,component:n})}let o=new Set;for(let e of Object.values(i)){let t=Array.isArray(e.children)?e.children:[];for(let e of t)typeof e==`string`&&o.add(e);typeof e.child==`string`&&o.add(e.child)}let s=Object.keys(i).filter(e=>!o.has(e));e.set(t,{...n,components:i,roots:s});continue}let i=MY(n.updateDataModel);if(Object.keys(i).length){let t=String(i.surfaceId||i.surface_id||``);if(!t)continue;let n=e.get(t)||PY(t),r=MY(i.value);e.set(t,{...n,dataModel:String(i.path||`/`)===`/`?r:{...n.dataModel,...r}});continue}let a=MY(n.deleteSurface);if(Object.keys(a).length){let t=String(a.surfaceId||a.surface_id||``);t&&e.delete(t)}}}function LY(e,t){let n=new Map(e.surfaces.map(e=>[e.id,{...e,components:{...e.components},dataModel:{...e.dataModel}}]));IY(n,FY(t));let r=String(t.type||``),i=String(t.surfaceId||t.surface_id||``);if(r===`a2ui.interaction`&&i){let e=n.get(i)||PY(i);n.set(i,{...e,interaction:{id:String(t.interactionId||t.interaction_id||``),kind:String(t.kind||`form`),status:`pending`,inputSchema:MY(t.inputSchema||t.input_schema)}})}if(r===`a2ui.action`&&i){let e=n.get(i);e?.interaction&&n.set(i,{...e,interaction:{...e.interaction,status:`resolved`}})}return{...e,runId:String(t.runId||t.run_id||e.runId),surfaces:[...n.values()],status:r===`a2ui.interaction`?`waiting_input`:r===`a2ui.action`?`streaming`:e.status}}function RY(e){let t=jY(`persisted`,`persisted`);for(let n of e)n.type.startsWith(`a2ui.`)&&(t=LY(t,{type:n.type,...n.data||{}}));return t.surfaces}function zY(e){let t=``,n=(e=!1)=>{t=t.replaceAll(`\r
|
|
245
|
-
`,`
|
|
246
|
-
`);let n=t.indexOf(`
|
|
247
|
-
|
|
248
|
-
`);for(;n>=0;)r(t.slice(0,n)),t=t.slice(n+2),n=t.indexOf(`
|
|
249
|
-
|
|
250
|
-
`);e&&t.trim()&&(r(t),t=``)},r=t=>{let n=`message`,r=[];for(let e of t.split(`
|
|
251
|
-
`))!e||e.startsWith(`:`)||(e.startsWith(`event:`)&&(n=e.slice(6).trim()),e.startsWith(`data:`)&&r.push(e.slice(5).trimStart()));if(!r.length)return;let i=r.join(`
|
|
252
|
-
`);if(i!==`[DONE]`)try{let t=JSON.parse(i);e({...t,type:String(t.type||n)})}catch{e({type:n,message:i})}};return{push(e){t+=e,n()},finish(){n(!0)}}}function BY(e,t){return String(e.callId||e.call_id||e.toolCallId||e.tool_call_id||t)}function VY(e,t){return String(e===`command`?t.command||t.name||`执行命令`:e===`tool`?t.name||t.tool||`调用工具`:t.kind||t.action||`等待批准`)}function HY(e){let t=e.output??e.result??e.message??e.error??``;return typeof t==`string`?t:t&&typeof t==`object`?JSON.stringify(t,null,2):t===``?``:String(t)}function UY(e,t){let n=String(e.type||``);if(![`function_call`,`mcp_call`,`shell_call`,`local_shell_call`,`file_search_call`,`web_search_call`,`approval_request`].includes(n))return null;let r=String(e.call_id||e.callId||e.id||`tool`),i=n===`shell_call`||n===`local_shell_call`,a=n===`approval_request`,o=a?`approval`:i?`command`:`tool`,s=MY(e.action),c=Array.isArray(s.commands)?s.commands.filter(e=>typeof e==`string`).join(` && `):``,l=a?String(s.title||s.kind||`等待批准`):i?c||String(e.name||`执行命令`):n===`web_search_call`?`网页搜索`:n===`file_search_call`?`文件搜索`:String(e.name||e.server_label||`调用工具`),u=String(e.status||``),d=u===`failed`||u===`error`||Number(e.exit_code??e.exitCode??0)!==0?`failed`:a&&!t?`waiting`:t?`completed`:`running`;return{id:`${o}:${r}`,kind:o,title:l,status:d,detail:HY(e),data:e}}function WY(e){let t=``,n=``,r=[],i=new Map;for(let a of e){let e=a.data||{};if(a.type===`thinking.delta`||a.type===`thinking.completed`){let n=String(e.text||e.delta||``);t=a.type===`thinking.completed`&&n?n:t+n;continue}if(a.type===`message.delta`||a.type===`message.completed`){let t=String(e.text||e.delta||``);n=a.type===`message.completed`&&t?t:n+t;continue}let o=null;if(a.type.startsWith(`command.`)?o=`command`:a.type.startsWith(`tool.`)?o=`tool`:a.type===`approval.requested`&&(o=`approval`),!o)continue;let s=BY(e,`${o}-${a.id}`),c=i.get(`${o}:${s}`),l=a.type.endsWith(`.completed`),u=a.type.endsWith(`.failed`)||!!e.error||Number(e.exitCode??e.exit_code??0)!==0,d=o===`approval`?`waiting`:u?`failed`:l?`completed`:`running`,f={id:`${o}:${s}`,kind:o,title:VY(o,e),status:d,detail:HY(e),data:e};if(c===void 0)i.set(f.id,r.length),r.push(f);else{let e=r[c];r[c]={...e,...f,title:f.title===VY(o,{})?e.title:f.title,detail:f.detail||e.detail}}}return{reasoning:t,output:n,activities:r}}function GY(e){let t=Number(e.totalTokens??e.total_tokens??0);return`${Number.isFinite(t)?t.toLocaleString(`en-US`):`0`} tokens`}function KY(e){let t=Number(e.durationMs??e.duration_ms);return!Number.isFinite(t)||t<0?``:t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(1)}s`}function qY(e){let t=[],n=new Map,r=e.some(e=>e.type===`run.started`),i=(e,r)=>{let i=n.get(e);if(i===void 0){n.set(e,t.length),t.push(r);return}t[i]={...t[i],...r}};for(let a of e){let e=a.data||{},o=a.type||``;if(o===`run.created`){if(r)continue;t.push({id:`run:${a.id}`,kind:`run`,title:`Run 创建`,summary:String(e.model||e.runtimeType||``),detail:``,status:`running`,createdAt:a.createdAt,data:e});continue}if(o===`run.started`){let n=MY(e.runtimeEvent);t.push({id:`run:${a.id}`,kind:`run`,title:`Run 启动`,summary:String(e.runtimeType||n.runtimeType||n.model||`Local Runtime`),detail:``,status:`running`,createdAt:a.createdAt,data:e});continue}if([`run.completed`,`run.failed`,`run.interrupted`,`run.cancelled`,`run.canceled`].includes(o)){let n=o===`run.failed`||o===`run.interrupted`,r=o===`run.cancelled`||o===`run.canceled`;t.push({id:`run:${a.id}`,kind:`run`,title:n?o===`run.interrupted`?`Run 中断`:`Run 失败`:r?`Run 取消`:`Run 完成`,summary:KY(e),detail:n?String(e.error||e.message||``):``,status:n?`failed`:`completed`,createdAt:a.createdAt,data:e});continue}if(o.startsWith(`thinking.`)||o.startsWith(`message.`)){let r=o.startsWith(`thinking.`)?`thinking`:`message`,s=`stream:${r}`,c=n.get(s),l=c===void 0?null:t[c],u=String(e.text||e.delta||``),d=o.endsWith(`.completed`),f=d&&u?u:`${l?.detail||``}${u}`;i(s,{id:s,kind:r,title:r===`thinking`?`思考过程`:`模型回复`,summary:f?`${f.length} 字`:``,detail:f,status:d?`completed`:`running`,createdAt:a.createdAt||l?.createdAt,data:e});continue}let s=null;if(o.startsWith(`command.`)?s=`command`:o.startsWith(`tool.`)?s=`tool`:o.startsWith(`approval.`)&&(s=`approval`),s){let r=`${s}:${BY(e,String(a.id))}`,c=n.get(r),l=c===void 0?null:t[c],u=o.endsWith(`.failed`)||!!e.error||Number(e.exitCode??e.exit_code??0)!==0,d=o.endsWith(`.completed`)||o.endsWith(`.resolved`),f=HY(e)||l?.detail||``,p=VY(s,e),m=VY(s,{});i(r,{id:r,kind:s,title:p===m&&l?.title?l.title:p,summary:KY(e),detail:f,status:u?`failed`:d?`completed`:s===`approval`?`waiting`:`running`,createdAt:a.createdAt||l?.createdAt,data:e});continue}o===`usage.reported`&&t.push({id:`usage:${a.id}`,kind:`usage`,title:`用量上报`,summary:GY(e),detail:``,status:`completed`,createdAt:a.createdAt,data:e})}if([...e].reverse().find(e=>[`run.completed`,`run.failed`,`run.interrupted`,`run.cancelled`,`run.canceled`].includes(e.type)))for(let e of t)e.status===`running`&&(e.kind===`thinking`||e.kind===`message`)&&(e.status=`completed`);return t}function JY(e){return!Number.isFinite(e)||Number(e)<0?`未上报`:Number(e)<1e3?`${Math.round(Number(e))}ms`:`${(Number(e)/1e3).toFixed(2)}s`}function YY(e){return Number.isFinite(e)?Number(e).toLocaleString():`未上报`}function XY(e){return e.length>20?`${e.slice(0,17)}…`:e}function ZY(e){return e===`RUNNING`||e===`CREATED`?`运行中`:e===`COMPLETED`?`已完成`:e===`CANCELLED`?`已取消`:e===`INTERRUPTED`?`已中断`:e===`TIMED_OUT`?`已超时`:`失败`}function QY(e){try{return BigInt(String(e.startTimeUnixNano||`0`))}catch{return 0n}}function $Y(e){if(!e.length)return[];let t=[...e].sort((e,t)=>QY(e)<QY(t)?-1:1),n=t.reduce((e,t)=>{let n=QY(t);return!e||n<e?n:e},0n),r=t.map(e=>Number(QY(e)-n)/1e6),i=Math.max(1,...t.map((e,t)=>r[t]+Math.max(0,Number(e.durationMs)||0))),a=new Map(t.map(e=>[e.spanId,e])),o=e=>{let t=0,n=e.parentSpanId,r=new Set;for(;n&&a.has(n)&&!r.has(n)&&t<3;)r.add(n),t+=1,n=a.get(n)?.parentSpanId;return t};return t.slice(0,8).map((e,t)=>({...e,left:Math.min(96,Math.max(0,r[t]/i*100)),width:Math.max(3,Math.min(100,Math.max(0,Number(e.durationMs)||0)/i*100)),depth:o(e)}))}function eX(e){return e.kind===`thinking`?(0,W.jsx)(k,{size:13}):e.kind===`message`?(0,W.jsx)(be,{size:13}):e.kind===`command`?(0,W.jsx)(qe,{size:13}):e.kind===`tool`?(0,W.jsx)(Qe,{size:13}):e.kind===`approval`?(0,W.jsx)(Be,{size:13}):e.kind===`usage`?(0,W.jsx)(de,{size:13}):(0,W.jsx)(Ne,{size:13})}async function tX(e){let t=await f(`/api/v1/runs/${encodeURIComponent(e)}/events`);if(!t.ok)return[];let n=[],r=zY(e=>{let{type:t,...r}=e;n.push({id:n.length+1,type:t,data:r})});return r.push(await t.text()),r.finish(),n}function nX({agentId:e,onOpenTrace:t,onClose:n}){let[r,i]=(0,s.useState)(null),[a,o]=(0,s.useState)([]),[c,l]=(0,s.useState)([]),[u,d]=(0,s.useState)(!0),[p,m]=(0,s.useState)(0);(0,s.useEffect)(()=>{let t=!1,n=null,r=0;async function a(){let s=++r;try{let n=((await f(`/api/v1/runs`).then(e=>e.json())).items||[]).filter(t=>!e||t.agentId===e).at(-1)||null;if(t||s!==r)return;if(i(n),!n){o([]),l([]);return}let[a,c]=await Promise.all([tX(n.id),f(`/api/v1/traces/${encodeURIComponent(n.traceId)}`).then(e=>e.ok?e.json():null).catch(()=>null)]);!t&&s===r&&(o(a),l(c?.spans||[]))}catch{}finally{!t&&s===r&&d(!1),t||(n=window.setTimeout(a,2500))}}return d(!0),a(),()=>{t=!0,r+=1,n!==null&&window.clearTimeout(n)}},[e,p]);let h=r?.status===`RUNNING`||r?.status===`CREATED`,g=r?/fail|error|interrupt|timed/i.test(r.status):!1,_=(0,s.useMemo)(()=>qY(a),[a]),v=(0,s.useMemo)(()=>$Y(c),[c]),y=r?.usage?.reported===!0;return(0,W.jsxs)(`aside`,{className:`chat-run-panel`,"aria-label":`运行检查器`,children:[(0,W.jsxs)(`div`,{className:`chat-run-head`,children:[(0,W.jsxs)(`span`,{className:`chat-run-title`,children:[(0,W.jsx)(w,{size:15}),` 运行检查器`]}),(0,W.jsx)(`span`,{className:`chat-run-head-spacer`}),(0,W.jsx)(`button`,{className:`icon-btn`,onClick:()=>m(e=>e+1),title:`刷新`,children:(0,W.jsx)(Fe,{size:14})}),(0,W.jsx)(`button`,{className:`icon-btn`,onClick:n,title:`收起`,children:(0,W.jsx)($e,{size:14})})]}),u&&!r?(0,W.jsxs)(`div`,{className:`chat-run-empty`,children:[(0,W.jsx)(_e,{size:16,className:`animate-spin`}),` 正在读取最近运行…`]}):r?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`chat-run-scroll`,children:[(0,W.jsxs)(`section`,{className:`chat-run-overview`,children:[(0,W.jsxs)(`div`,{className:`chat-run-status-row`,children:[(0,W.jsx)(`span`,{className:`chat-run-state-icon ${h?`running`:g?`failed`:`completed`}`,children:h?(0,W.jsx)(_e,{size:15,className:`animate-spin`}):g?(0,W.jsx)(z,{size:15}):(0,W.jsx)(R,{size:15})}),(0,W.jsxs)(`div`,{className:`chat-run-identity`,children:[(0,W.jsx)(`strong`,{children:ZY(r.status)}),(0,W.jsx)(`span`,{title:r.id,children:XY(r.id)})]}),(0,W.jsx)(`span`,{className:`chat-run-state ${h?`running`:g?`failed`:`completed`}`,children:r.status})]}),r.error?.message&&(0,W.jsxs)(`div`,{className:`chat-run-error`,role:`alert`,children:[(0,W.jsx)(z,{size:15}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:r.error.code||`运行失败`}),(0,W.jsx)(`span`,{children:r.error.message})]})]}),(0,W.jsxs)(`div`,{className:`chat-run-route`,children:[(0,W.jsx)(re,{size:13}),(0,W.jsx)(`span`,{children:`Edge · Local`}),(0,W.jsx)(`i`,{}),(0,W.jsxs)(`span`,{children:[r.runtimeType||`codex`,` Runtime`]}),(0,W.jsx)(`i`,{}),(0,W.jsx)(`span`,{children:r.model||`未指定模型`})]})]}),(0,W.jsxs)(`section`,{className:`chat-run-section`,children:[(0,W.jsxs)(`div`,{className:`chat-run-section-title`,children:[(0,W.jsx)(`span`,{children:`本次运行`}),(0,W.jsx)(`small`,{children:r.startedAt?new Date(r.startedAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):``})]}),(0,W.jsxs)(`div`,{className:`chat-run-metrics`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(B,{size:13}),(0,W.jsx)(`span`,{children:`耗时`}),(0,W.jsx)(`strong`,{children:JY(r.durationMs)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(ee,{size:13}),(0,W.jsx)(`span`,{children:`总 Token`}),(0,W.jsx)(`strong`,{children:y?YY(r.usage?.totalTokens):`未上报`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(be,{size:13}),(0,W.jsx)(`span`,{children:`输入 / 输出`}),(0,W.jsx)(`strong`,{children:y?`${YY(r.usage?.inputTokens)} / ${YY(r.usage?.outputTokens)}`:`未上报`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(fe,{size:13}),(0,W.jsx)(`span`,{children:`Span`}),(0,W.jsx)(`strong`,{children:c.length||`—`})]})]})]}),(0,W.jsxs)(`section`,{className:`chat-run-section`,children:[(0,W.jsxs)(`div`,{className:`chat-run-section-title`,children:[(0,W.jsx)(`span`,{children:`Trace 瀑布`}),(0,W.jsx)(`small`,{children:v.length?`${v.length} 个节点`:`等待 Span`})]}),v.length?(0,W.jsx)(`div`,{className:`chat-run-waterfall`,children:v.map(e=>{let t=/fail|error/i.test(e.status);return(0,W.jsxs)(`div`,{className:`chat-run-waterfall-row`,children:[(0,W.jsx)(`span`,{className:`chat-run-waterfall-label`,style:{paddingLeft:e.depth*8},title:e.name,children:e.name}),(0,W.jsx)(`span`,{className:`chat-run-waterfall-track`,children:(0,W.jsx)(`i`,{className:t?`failed`:``,style:{left:`${e.left}%`,width:`${e.width}%`}})}),(0,W.jsx)(`small`,{children:JY(e.durationMs)})]},e.spanId)})}):(0,W.jsx)(`div`,{className:`chat-run-inline-empty`,children:`运行开始后显示 Span 时序`})]}),(0,W.jsxs)(`section`,{className:`chat-run-section chat-run-events-section`,children:[(0,W.jsxs)(`div`,{className:`chat-run-section-title`,children:[(0,W.jsx)(`span`,{children:`执行事件`}),(0,W.jsx)(`small`,{children:_.length})]}),(0,W.jsx)(`div`,{className:`chat-run-timeline`,children:_.length?_.map(e=>(0,W.jsxs)(`div`,{className:`chat-run-event ${e.kind} ${e.status}`,children:[(0,W.jsx)(`span`,{className:`chat-run-event-icon`,children:eX(e)}),(0,W.jsxs)(`div`,{className:`chat-run-event-copy`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.title}),(0,W.jsx)(`small`,{children:e.summary})]}),e.detail&&(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:`查看详情`}),(0,W.jsx)(`pre`,{children:e.detail})]})]})]},e.id)):(0,W.jsx)(`div`,{className:`chat-run-inline-empty`,children:`正在建立 Runtime 连接…`})})]})]}),(0,W.jsx)(`div`,{className:`chat-run-footer`,children:(0,W.jsxs)(`button`,{className:`btn soft`,onClick:t,children:[`打开完整 Trace `,(0,W.jsx)(E,{size:14})]})})]}):(0,W.jsx)(`div`,{className:`chat-run-empty`,children:`发送一条消息后,这里会显示执行位置、用量与事件时间线。`})]})}var rX=Object.defineProperty,iX=(e,t)=>rX(e,`name`,{value:t,configurable:!0}),aX=!1;function oX(){let[e,t]=s.useState(aX);return s.useEffect(()=>{aX||(aX=!0,t(!0))},[]),e}iX(oX,`useIsHydrated`);var sX=s.useSyncExternalStore;function cX(){return()=>{}}iX(cX,`subscribe`);function lX(){return sX(cX,()=>!0,()=>!1)}iX(lX,`useIsHydratedModern`);var uX=typeof sX==`function`?lX:oX,dX=Object.defineProperty,fX=(e,t)=>dX(e,`name`,{value:t,configurable:!0}),pX=`rovingFocusGroup.onEntryFocus`,mX={bubbles:!1,cancelable:!0},hX=`RovingFocusGroup`,[gX,_X,vX]=lc(hX),[yX,bX]=vt(hX,[vX]),[xX,SX]=yX(hX),CX=s.forwardRef(fX(function(e,t){return(0,W.jsx)(gX.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,W.jsx)(gX.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,W.jsx)(wX,{...e,ref:t})})})},`RovingFocusGroup`)),wX=s.forwardRef(fX(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,p=s.useRef(null),m=mt(t,p),h=Cc(a),[g,_]=Pt({prop:o,defaultProp:c??null,onChange:l,caller:hX}),[v,y]=s.useState(!1),b=cn(u),x=_X(n),S=s.useRef(!1),[C,w]=s.useState(0);return s.useEffect(()=>{let e=p.current;if(e)return e.addEventListener(pX,b),()=>e.removeEventListener(pX,b)},[b]),(0,W.jsx)(xX,{scope:n,orientation:r,dir:h,loop:i,currentTabStopId:g,onItemFocus:s.useCallback(e=>_(e),[_]),onItemShiftTab:s.useCallback(()=>y(!0),[]),onFocusableItemAdd:s.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:s.useCallback(()=>w(e=>e-1),[]),children:(0,W.jsx)(rn.div,{tabIndex:v||C===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:`none`,...e.style},onMouseDown:G(e.onMouseDown,()=>{S.current=!0}),onFocus:G(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!v){let t=new CustomEvent(pX,mX);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);AX([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),d)}}S.current=!1}),onBlur:G(e.onBlur,()=>y(!1))})})},`RovingFocusGroupImpl`)),TX=`RovingFocusGroupItem`,EX=s.forwardRef(fX(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...c}=e,l=Tt(),u=a||l,d=SX(TX,n),f=d.currentTabStopId===u,p=_X(n),{onFocusableItemAdd:m,onFocusableItemRemove:h,currentTabStopId:g}=d,_=uX();return bt(()=>{if(!(!_||!r))return m(),()=>h()},[_,r,m,h]),s.useEffect(()=>{if(!(_||!r))return m(),()=>h()},[_,r,m,h]),(0,W.jsx)(gX.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:(0,W.jsx)(rn.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...c,ref:t,onMouseDown:G(e.onMouseDown,e=>{r?d.onItemFocus(u):e.preventDefault()}),onFocus:G(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:G(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){d.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=kX(e,d.orientation,d.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=p().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=d.loop?jX(n,r+1):n.slice(r+1)}setTimeout(()=>AX(n))}}),children:typeof o==`function`?o({isCurrentTabStop:f,hasTabStop:g!=null}):o})})},`RovingFocusGroupItem`)),DX={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function OX(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}fX(OX,`getDirectionAwareKey`);function kX(e,t,n){let r=OX(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return DX[r]}fX(kX,`getFocusIntent`);function AX(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}fX(AX,`focusFirst`);function jX(e,t){return e.map((n,r)=>e[(t+r)%e.length])}fX(jX,`wrapArray`);var MX=CX,NX=EX,PX=Object.defineProperty,FX=(e,t)=>PX(e,`name`,{value:t,configurable:!0}),IX=[`Enter`,` `],LX=[`ArrowDown`,`PageUp`,`Home`],RX=[`ArrowUp`,`PageDown`,`End`],zX=[...LX,...RX];[...IX],[...IX];var BX=`Menu`,[VX,HX,UX]=lc(BX),[WX,GX]=vt(BX,[UX,Wu,bX]),KX=Wu(),qX=bX(),[JX,YX]=WX(BX),[XX,ZX]=WX(BX),QX=FX(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,c=KX(t),[l,u]=s.useState(null),d=s.useRef(!1),f=cn(a),p=Cc(i);return s.useEffect(()=>{let e=FX(()=>{d.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=FX(()=>d.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),s.useEffect(()=>{if(!n)return;let e=FX(()=>f(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,f]),(0,W.jsx)(od,{...c,children:(0,W.jsx)(JX,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:(0,W.jsx)(XX,{scope:t,onClose:s.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:o,children:r})})})},`Menu`),$X=s.forwardRef(FX(function(e,t){let{__scopeMenu:n,...r}=e,i=KX(n);return(0,W.jsx)(sd,{...i,...r,ref:t})},`MenuAnchor`)),eZ=`MenuPortal`,[tZ,nZ]=WX(eZ,{forceMount:void 0}),rZ=FX(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=YX(eZ,t);return(0,W.jsx)(tZ,{scope:t,forceMount:n,children:(0,W.jsx)(Gn,{present:n||a.open,children:(0,W.jsx)(Vn,{asChild:!0,container:i,children:r})})})},`MenuPortal`),iZ=`MenuContent`,[aZ,oZ]=WX(iZ),sZ=s.forwardRef(FX(function(e,t){let n=nZ(iZ,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=YX(iZ,e.__scopeMenu),o=ZX(iZ,e.__scopeMenu);return(0,W.jsx)(VX.Provider,{scope:e.__scopeMenu,children:(0,W.jsx)(Gn,{present:r||a.open,children:(0,W.jsx)(VX.Slot,{scope:e.__scopeMenu,children:o.modal?(0,W.jsx)(cZ,{...i,ref:t}):(0,W.jsx)(lZ,{...i,ref:t})})})})},`MenuContent`)),cZ=s.forwardRef(FX(function(e,t){let n=YX(iZ,e.__scopeMenu),r=s.useRef(null),i=mt(t,r);return s.useEffect(()=>{let e=r.current;if(e)return Ci(e)},[]),(0,W.jsx)(dZ,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:G(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),lZ=s.forwardRef(FX(function(e,t){let n=YX(iZ,e.__scopeMenu);return(0,W.jsx)(dZ,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),uZ=Ht(`MenuContent.ScrollLock`),dZ=s.forwardRef(FX(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:c,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:h,...g}=e,_=YX(iZ,n),v=ZX(iZ,n),y=KX(n),b=qX(n),x=HX(n),[S,C]=s.useState(null),w=s.useRef(null),T=mt(t,w,_.onContentChange),E=s.useRef(0),D=s.useRef(``),O=s.useRef(0),k=s.useRef(null),A=s.useRef(`right`),j=s.useRef(0),M=h?mi:s.Fragment,N=h?{as:uZ,allowPinchZoom:!0}:void 0,P=FX(e=>{let t=D.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=FZ(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;FX((function e(t){D.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);s.useEffect(()=>()=>window.clearTimeout(E.current),[]),nr();let F=s.useCallback(e=>A.current===k.current?.side&&LZ(e,k.current?.area),[]);return(0,W.jsx)(aZ,{scope:n,searchRef:D,onItemEnter:s.useCallback(e=>{F(e)&&e.preventDefault()},[F]),onItemLeave:s.useCallback(e=>{F(e)||(w.current?.focus(),C(null))},[F]),onTriggerLeave:s.useCallback(e=>{F(e)&&e.preventDefault()},[F]),pointerGraceTimerRef:O,onPointerGraceIntentChange:s.useCallback(e=>{k.current=e},[]),children:(0,W.jsx)(M,{...N,children:(0,W.jsx)(On,{asChild:!0,trapped:i,onMountAutoFocus:G(a,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,W.jsx)(gn,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:(0,W.jsx)(MX,{asChild:!0,...b,dir:v.dir,orientation:`vertical`,loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:G(l,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,W.jsx)(cd,{role:`menu`,"aria-orientation":`vertical`,"data-state":AZ(_.open),"data-radix-menu-content":``,dir:v.dir,...y,...g,ref:T,style:{outline:`none`,...g.style},onKeyDown:G(g.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&P(e.key));let i=w.current;if(e.target!==i||!zX.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);RX.includes(e.key)&&a.reverse(),NZ(a)}),onBlur:G(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:G(e.onPointerMove,RZ(e=>{let t=e.target,n=j.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>j.current?`right`:`left`;A.current=t,j.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),fZ=s.forwardRef(FX(function(e,t){let{__scopeMenu:n,...r}=e;return(0,W.jsx)(rn.div,{role:`group`,...r,ref:t})},`MenuGroup`)),pZ=s.forwardRef(FX(function(e,t){let{__scopeMenu:n,...r}=e;return(0,W.jsx)(rn.div,{...r,ref:t})},`MenuLabel`)),mZ=`MenuItem`,hZ=`menu.itemSelect`,gZ=s.forwardRef(FX(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=s.useRef(null),o=ZX(mZ,e.__scopeMenu),c=oZ(mZ,e.__scopeMenu),l=mt(t,a),u=s.useRef(!1),d=FX(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(hZ,{bubbles:!0,cancelable:!0});e.addEventListener(hZ,e=>r?.(e),{once:!0}),an(e,t),t.defaultPrevented?u.current=!1:o.onClose()}},`handleSelect`);return(0,W.jsx)(_Z,{...i,ref:l,disabled:n,onClick:G(e.onClick,d),onPointerDown:t=>{e.onPointerDown?.(t),u.current=!0},onPointerUp:G(e.onPointerUp,e=>{u.current||e.currentTarget?.click()}),onKeyDown:G(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(c.searchRef.current===``||e.key!==` `)&&IX.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),_Z=s.forwardRef(FX(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=oZ(mZ,n),c=qX(n),l=s.useRef(null),u=mt(t,l),[d,f]=s.useState(!1),[p,m]=s.useState(``);return s.useEffect(()=>{let e=l.current;e&&m((e.textContent??``).trim())},[a.children]),(0,W.jsx)(VX.ItemSlot,{scope:n,disabled:r,textValue:i??p,children:(0,W.jsx)(NX,{asChild:!0,...c,focusable:!r,children:(0,W.jsx)(rn.div,{role:`menuitem`,"data-highlighted":d?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:u,onPointerMove:G(e.onPointerMove,RZ(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:G(e.onPointerLeave,RZ(e=>o.onItemLeave(e))),onFocus:G(e.onFocus,()=>f(!0)),onBlur:G(e.onBlur,()=>f(!1))})})})},`MenuItemImpl`)),[vZ,yZ]=WX(`MenuRadioGroup`,{value:void 0,onValueChange:FX(()=>{},`onValueChange`)}),bZ=s.forwardRef(FX(function(e,t){let{value:n,onValueChange:r,...i}=e,a=cn(r);return(0,W.jsx)(vZ,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,W.jsx)(fZ,{...i,ref:t})})},`MenuRadioGroup`)),xZ=`MenuRadioItem`,SZ=s.forwardRef(FX(function(e,t){let{value:n,...r}=e,i=yZ(xZ,e.__scopeMenu),a=n===i.value;return(0,W.jsx)(wZ,{scope:e.__scopeMenu,checked:a,children:(0,W.jsx)(gZ,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":MZ(a),onSelect:G(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),CZ=`MenuItemIndicator`,[wZ,TZ]=WX(CZ,{checked:!1}),EZ=s.forwardRef(FX(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=TZ(CZ,n);return(0,W.jsx)(Gn,{present:r||jZ(a.checked)||a.checked===!0,children:(0,W.jsx)(rn.span,{...i,ref:t,"data-state":MZ(a.checked)})})},`MenuItemIndicator`)),DZ=s.forwardRef(FX(function(e,t){let{__scopeMenu:n,...r}=e;return(0,W.jsx)(rn.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[OZ,kZ]=WX(`MenuSub`);function AZ(e){return e?`open`:`closed`}FX(AZ,`getOpenState`);function jZ(e){return e===`indeterminate`}FX(jZ,`isIndeterminate`);function MZ(e){return jZ(e)?`indeterminate`:e?`checked`:`unchecked`}FX(MZ,`getCheckedState`);function NZ(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}FX(NZ,`focusFirst`);function PZ(e,t){return e.map((n,r)=>e[(t+r)%e.length])}FX(PZ,`wrapArray`);function FZ(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=PZ(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}FX(FZ,`getNextMatch`);function IZ(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}FX(IZ,`isPointInPolygon`);function LZ(e,t){return t?IZ({x:e.clientX,y:e.clientY},t):!1}FX(LZ,`isPointerInGraceArea`);function RZ(e){return t=>t.pointerType===`mouse`?e(t):void 0}FX(RZ,`whenMouse`);var zZ=QX,BZ=$X,VZ=rZ,HZ=sZ,UZ=pZ,WZ=gZ,GZ=bZ,KZ=SZ,qZ=EZ,JZ=DZ,YZ=Object.defineProperty,XZ=(e,t)=>YZ(e,`name`,{value:t,configurable:!0}),ZZ=`DropdownMenu`,[QZ,$Z]=vt(ZZ,[GX]),eQ=GX(),[tQ,nQ]=QZ(ZZ),rQ=XZ(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:c=!0}=e,l=eQ(t),u=s.useRef(null),[d,f]=Pt({prop:i,defaultProp:a??!1,onChange:o,caller:ZZ});return(0,W.jsx)(tQ,{scope:t,triggerId:Tt(),triggerRef:u,contentId:Tt(),open:d,onOpenChange:f,onOpenToggle:s.useCallback(()=>f(e=>!e),[f]),modal:c,children:(0,W.jsx)(zZ,{...l,open:d,onOpenChange:f,dir:r,modal:c,children:n})})},`DropdownMenu`),iQ=`DropdownMenuTrigger`,aQ=s.forwardRef(XZ(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=nQ(iQ,n),o=eQ(n),s=mt(t,a.triggerRef);return(0,W.jsx)(BZ,{asChild:!0,...o,children:(0,W.jsx)(rn.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":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:G(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:G(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),oQ=XZ(e=>{let{__scopeDropdownMenu:t,...n}=e,r=eQ(t);return(0,W.jsx)(VZ,{...r,...n})},`DropdownMenuPortal`),sQ=`DropdownMenuContent`,cQ=s.forwardRef(XZ(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=nQ(sQ,n),a=eQ(n),o=s.useRef(!1);return(0,W.jsx)(HZ,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:G(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:G(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.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`)),lQ=s.forwardRef(XZ(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=eQ(n);return(0,W.jsx)(UZ,{...i,...r,ref:t})},`DropdownMenuLabel`)),uQ=s.forwardRef(XZ(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=eQ(n);return(0,W.jsx)(WZ,{...i,...r,ref:t})},`DropdownMenuItem`)),dQ=s.forwardRef(XZ(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=eQ(n);return(0,W.jsx)(GZ,{...i,...r,ref:t})},`DropdownMenuRadioGroup`)),fQ=s.forwardRef(XZ(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=eQ(n);return(0,W.jsx)(KZ,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),pQ=s.forwardRef(XZ(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=eQ(n);return(0,W.jsx)(qZ,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),mQ=s.forwardRef(XZ(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=eQ(n);return(0,W.jsx)(JZ,{...i,...r,ref:t})},`DropdownMenuSeparator`)),hQ=rQ,gQ=aQ,_Q=oQ,vQ=cQ,yQ=lQ,bQ=uQ,xQ=dQ,SQ=fQ,CQ=pQ,wQ=mQ,TQ=[{value:`ask`,label:`请求批准`,compactLabel:`请求批准`,description:`文件修改与外部写入会逐次请求确认`},{value:`risk`,label:`帮我批准`,compactLabel:`帮我批准`,description:`仅在检测到风险操作时请求确认`},{value:`full`,label:`完全访问权限`,compactLabel:`完全访问`,description:`不受限制地访问互联网和工作区文件`}];function EQ(e){return e===`ask`||e===`risk`||e===`full`?e:`risk`}function DQ(e){return`agentkit-studio:approval:${e}`}function OQ(e){return TQ.find(t=>t.value===e)||TQ[1]}function kQ(e){return Array.isArray(e)?e.map(e=>{if(typeof e==`string`)return{label:e,value:e,description:``};let t=e&&typeof e==`object`?e:{},n=String(t.value??t.id??t.label??``);return{label:String(t.label??t.title??n),value:n,description:String(t.description??t.help??``)}}).filter(e=>e.value):[]}function AQ(e){return(Array.isArray(e.children)?e.children:typeof e.child==`string`?[e.child]:[]).filter(e=>typeof e==`string`)}function jQ({surface:e,busy:t=!1,onSubmit:n}){let[r,i]=(0,s.useState)(()=>({...e.dataModel})),[a,o]=(0,s.useState)({}),c=(0,s.useRef)(new Set),l=e.interaction?.status===`pending`,u=t||!l,d=e.roots.length?e.roots:Object.keys(e.components).slice(0,1);(0,s.useEffect)(()=>{i(t=>{let n={...t};for(let[t,r]of Object.entries(e.dataModel))c.current.has(t)||(n[t]=r);return n})},[e.dataModel]);let f=(e,t)=>{c.current.add(e),i(n=>({...n,[e]:t}))},p=(t,i={})=>{if(!e.interaction||u)return;let o={...r};for(let[e,t]of Object.entries(a)){let n=t.trim();if(!n)continue;let r=o[e];o[e]=Array.isArray(r)?[...r.filter(e=>String(e)!==n),n]:n}n(e.interaction.id,t,{...o,...i})},m=(t,n)=>{let s=String(t.name||t.id),l=kQ(t.options),d=Array.isArray(r[s])?r[s]:[],p=String(r[s]??t.value??``),m=!!(t.allow_other??t.allowOther??t.is_other??t.isOther),h=a[s]??``;return(0,W.jsxs)(`fieldset`,{className:`a2ui-field a2ui-options`,children:[(0,W.jsx)(`legend`,{children:String(t.label||t.title||`请选择`)}),!!t.description&&(0,W.jsx)(`p`,{className:`a2ui-field-description`,children:String(t.description)}),(0,W.jsxs)(`div`,{className:`a2ui-choice-list`,role:n?`group`:`radiogroup`,children:[l.map((t,r)=>{let i=n?d.includes(t.value):p===t.value;return(0,W.jsxs)(`label`,{className:`a2ui-choice${i?` selected`:``}`,children:[(0,W.jsx)(`input`,{type:n?`checkbox`:`radio`,"aria-label":t.label,name:n?void 0:`${e.id}-${s}`,checked:i,disabled:u,onChange:e=>{n?f(s,e.target.checked?[...d,t.value]:d.filter(e=>e!==t.value)):(o(e=>({...e,[s]:``})),f(s,t.value))}}),(0,W.jsx)(`span`,{className:`a2ui-choice-index`,children:r+1}),(0,W.jsxs)(`span`,{className:`a2ui-choice-copy`,children:[(0,W.jsx)(`strong`,{children:t.label}),t.description&&(0,W.jsx)(`small`,{children:t.description})]})]},t.value)}),m&&(0,W.jsxs)(`label`,{className:`a2ui-other${h?` active`:``}`,children:[(0,W.jsx)(`span`,{className:`a2ui-other-icon`,children:(0,W.jsx)(Me,{size:14})}),(0,W.jsx)(`input`,{type:t.secret?`password`:`text`,"aria-label":`${String(t.label||t.title||s)}自定义输入`,value:h,placeholder:String(t.other_placeholder||t.otherPlaceholder||`其他,请输入…`),disabled:u,onChange:e=>{let t=e.target.value;c.current.add(s),o(e=>({...e,[s]:t})),n||i(e=>({...e,[s]:``}))}})]})]})]})},h=t=>{let n=e.components[t];if(!n)return null;let i=n.component,a=AQ(n).map(e=>(0,W.jsx)(`div`,{children:h(e)},e));if(i===`Card`)return(0,W.jsxs)(`section`,{className:`a2ui-card`,children:[!!n.title&&(0,W.jsx)(`h3`,{children:String(n.title)}),!!n.body&&(0,W.jsx)(`p`,{children:String(n.body)}),a.length>0&&(0,W.jsx)(`div`,{className:`a2ui-card-content`,children:a})]});if([`Column`,`Row`].includes(i))return(0,W.jsx)(`div`,{className:`a2ui-layout ${i.toLowerCase()}`,children:a});if(i===`Text`)return(0,W.jsx)(`p`,{className:`a2ui-text ${String(n.variant||`body`)}`,children:String(n.text||``)});if([`TextField`,`Input`].includes(i)){let e=String(n.name||n.id);return(0,W.jsxs)(`label`,{className:`a2ui-field`,children:[(0,W.jsx)(`span`,{children:String(n.label||n.title||e)}),(0,W.jsx)(`input`,{value:String(r[e]??n.value??``),placeholder:String(n.placeholder||``),disabled:u,onChange:t=>f(e,t.target.value)})]})}if([`Select`,`RadioGroup`,`MultipleChoice`].includes(i)){let e=String(n.name||n.id),t=kQ(n.options),a=i===`MultipleChoice`&&!!n.multiple;return i===`RadioGroup`||i===`MultipleChoice`?m(n,a):(0,W.jsxs)(`div`,{className:`a2ui-field`,children:[(0,W.jsx)(`span`,{children:String(n.label||n.title||`请选择`)}),(0,W.jsx)(Tf,{ariaLabel:String(n.label||n.title||`请选择`),value:String(r[e]??n.value??``),options:t,disabled:u,onValueChange:t=>f(e,t)})]})}if(i===`CheckboxGroup`)return m(n,!0);if(i===`ApprovalBar`)return(0,W.jsxs)(`div`,{className:`a2ui-approval`,role:`group`,"aria-label":`批准操作`,children:[(0,W.jsxs)(`span`,{className:`a2ui-approval-summary`,children:[(0,W.jsx)(Ve,{size:15}),String(n.summary||n.tool_name||`请确认此操作`)]}),(0,W.jsxs)(`span`,{className:`a2ui-actions`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`secondary`,disabled:u,onClick:()=>p(`deny`),children:[(0,W.jsx)($e,{size:14}),String(n.deny_label||`拒绝`)]}),(0,W.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>p(`approve`),children:[(0,W.jsx)(j,{size:14}),String(n.approve_label||`批准`)]})]})]});if(i===`Form`)return(0,W.jsxs)(`form`,{className:`a2ui-form`,onSubmit:e=>{e.preventDefault(),p(`submit`)},children:[!!n.title&&(0,W.jsx)(`strong`,{children:String(n.title)}),a,(0,W.jsx)(`div`,{className:`a2ui-form-actions`,children:(0,W.jsxs)(`button`,{type:`submit`,disabled:u,children:[String(n.submit_label||`提交`),(0,W.jsx)(ne,{size:14})]})})]});if(i===`Button`){let e=String(n.action||n.name||n.id||`submit`);return(0,W.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>p(e),children:String(n.label||n.text||`提交`)})}return(0,W.jsxs)(`div`,{className:`a2ui-unsupported`,children:[`此卡片包含暂不支持的组件:`,i||`unknown`]})},g=d.map(e=>(0,W.jsx)(`div`,{children:h(e)},e));return(0,W.jsxs)(`div`,{className:`a2ui-surface${l?` pending`:` resolved`}`,"data-surface-id":e.id,children:[g,e.interaction&&!l&&(0,W.jsxs)(`div`,{className:`a2ui-resolved`,children:[(0,W.jsx)(j,{size:14}),`已提交`]})]})}var MQ=[{id:`plan`,slash:`/plan`,label:`计划模式`,description:`下一轮只分析并形成可执行计划`},{id:`goal`,slash:`/goal`,label:`设定长期目标`,description:`启动可暂停、可持续的 Codex Goal`},{id:`default`,slash:`/default`,label:`默认模式`,description:`返回直接执行模式`}];function NQ(e){if(!e.startsWith(`/`)||/\s/.test(e))return[];let t=e.toLocaleLowerCase();return MQ.filter(e=>e.slash.startsWith(t))}function PQ(e){let t=e.trim();return t===`/plan`?{kind:`toggle-plan`}:t===`/default`?{kind:`set-default`}:t===`/goal`||t.startsWith(`/goal `)?{kind:`goal`,objective:t.slice(5).trim()}:{kind:`message`,text:t}}function FQ(e,t){let n=[];e.trim()&&n.push({type:`input_text`,text:e.trim()});for(let e of t)e.kind===`image`&&e.dataUrl?n.push({type:`input_image`,image_url:e.dataUrl,filename:e.name}):e.kind===`text`&&n.push({type:`input_text`,text:`\n\n<attachment name="${e.name.replaceAll(`"`,`"`)}">\n${e.text||``}\n</attachment>`});return[{role:`user`,content:n}]}var IQ=new Set([`txt`,`md`,`json`,`yaml`,`yml`,`csv`,`ts`,`tsx`,`js`,`jsx`,`py`,`go`,`rs`,`java`,`sh`,`css`,`html`,`xml`,`toml`,`ini`,`log`]),LQ=[`image/*`,`.txt`,`.md`,`.json`,`.yaml`,`.yml`,`.csv`,`.ts`,`.tsx`,`.js`,`.jsx`,`.py`,`.go`,`.rs`,`.java`,`.sh`,`.css`,`.html`,`.xml`,`.toml`,`.ini`,`.log`].join(`,`);function RQ(e){return new TextEncoder().encode(JSON.stringify(FQ(``,e))).byteLength}function zQ(e){return e.split(`.`).at(-1)?.toLocaleLowerCase()||``}function BQ(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(Error(`无法读取附件 ${e.name}`)),r.onload=()=>t(String(r.result||``)),r.readAsDataURL(e)})}function VQ(e){return typeof e.text==`function`?e.text():new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(Error(`无法读取附件 ${e.name}`)),r.onload=()=>t(String(r.result||``)),r.readAsText(e)})}async function HQ(e){let t={id:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,name:e.name,mimeType:e.type||`application/octet-stream`,size:e.size};if(e.type.startsWith(`image/`))return{...t,kind:`image`,dataUrl:await BQ(e)};if(e.type.startsWith(`text/`)||IQ.has(zQ(e.name)))return{...t,kind:`text`,text:await VQ(e)};throw Error(`暂不支持 ${e.name};请添加图片或 UTF-8 文本/代码文件`)}function UQ(e){return e<1024?`${e} B`:`${Math.max(.1,e/1024).toFixed(1)} KiB`}function WQ({id:e}){return e===`goal`?(0,W.jsx)(Ke,{size:16}):e==="default"?(0,W.jsx)(Xe,{size:16}):(0,W.jsx)(ge,{size:16})}function GQ({mode:e,disabled:t,onTogglePlan:n,onStartGoal:r,onFiles:i}){let a=(0,s.useRef)(null);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`input`,{ref:a,className:`composer-file-input`,type:`file`,tabIndex:-1,multiple:!0,accept:LQ,onChange:e=>{let t=[...e.target.files||[]];e.target.value=``,t.length&&i(t)}}),(0,W.jsxs)(hQ,{children:[(0,W.jsx)(gQ,{asChild:!0,children:(0,W.jsx)(`button`,{className:`chat-plus-trigger`,type:`button`,disabled:t,"aria-label":`添加附件或运行控制`,title:`添加附件或运行控制`,children:(0,W.jsx)(Pe,{size:17})})}),(0,W.jsx)(_Q,{children:(0,W.jsxs)(vQ,{className:`composer-action-menu`,side:`top`,align:`start`,sideOffset:10,collisionPadding:12,children:[(0,W.jsx)(yQ,{className:`composer-action-heading`,children:`添加到本轮`}),(0,W.jsxs)(bQ,{className:`composer-action-item`,onSelect:()=>a.current?.click(),children:[(0,W.jsx)(Ae,{size:16}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:`添加图片或文本`}),(0,W.jsx)(`small`,{children:`最多 4 个附件`})]})]}),(0,W.jsx)(wQ,{className:`composer-action-separator`}),(0,W.jsx)(yQ,{className:`composer-action-heading`,children:`运行控制`}),(0,W.jsxs)(bQ,{className:`composer-action-item`,onSelect:n,children:[(0,W.jsx)(ge,{size:16}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:`计划模式`}),(0,W.jsx)(`small`,{children:`下一轮使用 Codex Plan`})]}),e===`plan`&&(0,W.jsx)(j,{className:`composer-action-check`,size:15})]}),(0,W.jsxs)(bQ,{className:`composer-action-item`,onSelect:r,children:[(0,W.jsx)(Ke,{size:16}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:`设定长期目标`}),(0,W.jsx)(`small`,{children:`启动持久 Goal`})]})]})]})})]})]})}function KQ({input:e,activeIndex:t,onSelect:n}){let r=NQ(e);return r.length?(0,W.jsx)(yg,{className:`composer-command-menu`,shouldFilter:!1,"aria-label":`斜杠命令`,children:(0,W.jsx)(yg.List,{children:r.map((e,r)=>(0,W.jsxs)(yg.Item,{value:e.id,"data-active":r===t?`true`:`false`,onSelect:()=>n(e.id),children:[(0,W.jsx)(WQ,{id:e.id}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:e.label}),(0,W.jsx)(`small`,{children:e.description})]}),(0,W.jsx)(`kbd`,{children:e.slash})]},e.id))})}):null}function qQ(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n?`${n}时 ${r}分`:r?`${r}分 ${i}秒`:`${i}秒`}function JQ(e){if(!e)return`刚刚启动`;let t=new Date(e);return Number.isNaN(t.getTime())?`刚刚启动`:`${new Intl.DateTimeFormat(`zh-CN`,{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(t)} 启动`}function YQ({mode:e,status:t,objective:n,startedAt:r,elapsedMs:i,now:a,onPause:o,onResume:c,onStop:l}){let[u,d]=(0,s.useState)(a??Date.now()),f=(0,s.useMemo)(()=>r?Date.parse(r):NaN,[r]),p=t===`running`,m=t===`waiting`,h=t===`paused`,g=e===`goal`?Ke:ge,_=m?e===`goal`?`目标等待输入`:`计划等待输入`:h?e===`goal`?`目标已暂停`:`计划已暂停`:e===`goal`?`目标执行中`:`正在规划`,v=i??(Number.isFinite(f)?Math.max(0,u-f):0);return(0,s.useEffect)(()=>{if(!p||a!=null)return;let e=window.setInterval(()=>d(Date.now()),1e3);return()=>window.clearInterval(e)},[a,p]),(0,W.jsxs)(`div`,{className:`runtime-mode-bar ${e} ${t}`,"data-testid":`runtime-mode-bar`,children:[(0,W.jsx)(`span`,{className:`runtime-mode-icon`,children:(0,W.jsx)(g,{size:15})}),(0,W.jsxs)(`div`,{className:`runtime-mode-copy`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:_}),(0,W.jsx)(`span`,{children:n})]}),(0,W.jsxs)(`small`,{children:[(0,W.jsx)(B,{size:12}),` `,JQ(r),` · `,qQ(v)]})]}),(0,W.jsxs)(`div`,{className:`runtime-mode-actions`,children:[p&&o&&(0,W.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`暂停${e===`goal`?`目标`:`计划`}`,title:`暂停`,children:(0,W.jsx)(je,{size:14,fill:`currentColor`})}),h&&c&&(0,W.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`继续${e===`goal`?`目标`:`计划`}`,title:`继续`,children:(0,W.jsx)(Ne,{size:14,fill:`currentColor`})}),(0,W.jsx)(`button`,{type:`button`,onClick:l,"aria-label":`结束${e===`goal`?`目标`:`计划`}`,title:`结束`,children:(0,W.jsx)(We,{size:13,fill:`currentColor`})})]})]})}function XQ({value:e,onChange:t}){let n=OQ(e),r=e===`ask`?(0,W.jsx)(pe,{size:15}):e===`full`?(0,W.jsx)(ze,{size:15}):(0,W.jsx)(Be,{size:15});return(0,W.jsxs)(hQ,{children:[(0,W.jsx)(gQ,{asChild:!0,children:(0,W.jsxs)(`button`,{className:`chat-approval-trigger ${e}`,type:`button`,"aria-label":`批准模式:${n.label}`,title:`${n.label};下一轮生效`,children:[r,(0,W.jsx)(`span`,{children:n.compactLabel}),(0,W.jsx)(M,{size:13})]})}),(0,W.jsx)(_Q,{children:(0,W.jsxs)(vQ,{className:`chat-approval-menu`,side:`top`,sideOffset:9,align:`start`,collisionPadding:12,children:[(0,W.jsxs)(`div`,{className:`chat-approval-menu-heading`,children:[(0,W.jsx)(`strong`,{children:`如何批准 Agent 操作?`}),(0,W.jsx)(`span`,{children:`下一轮生效`})]}),(0,W.jsx)(xQ,{value:e,onValueChange:e=>t(EQ(e)),children:TQ.map(e=>(0,W.jsxs)(SQ,{value:e.value,className:`chat-approval-option ${e.value}`,children:[(0,W.jsx)(`span`,{className:`chat-approval-option-icon`,children:e.value===`ask`?(0,W.jsx)(pe,{size:17}):e.value===`full`?(0,W.jsx)(ze,{size:17}):(0,W.jsx)(Be,{size:17})}),(0,W.jsxs)(`span`,{className:`chat-approval-option-copy`,children:[(0,W.jsx)(`strong`,{children:e.label}),(0,W.jsx)(`small`,{children:e.description})]}),(0,W.jsx)(CQ,{className:`chat-approval-indicator`,children:(0,W.jsx)(j,{size:16})})]},e.value))})]})})]})}function ZQ({usedTokens:e,limitTokens:t,known:n,percent:r}){let i=(0,s.useId)(),a=wY({usedTokens:e,limitTokens:t,known:n,percent:r}),o=`${a.title}:${a.value},${a.detail}`;return(0,W.jsxs)(`span`,{className:`chat-context-ring${n?``:` unknown`}`,role:`img`,"aria-label":o,"aria-describedby":i,tabIndex:0,children:[(0,W.jsxs)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{className:`chat-context-track`,cx:`12`,cy:`12`,r:`8.5`,pathLength:`100`}),(0,W.jsx)(`circle`,{className:`chat-context-value`,cx:`12`,cy:`12`,r:`8.5`,pathLength:`100`,strokeDasharray:`${n?r:12} ${n?100-r:88}`})]}),(0,W.jsxs)(`span`,{id:i,role:`tooltip`,className:`chat-context-tooltip`,children:[(0,W.jsx)(`span`,{children:a.title}),(0,W.jsx)(`strong`,{children:a.value}),(0,W.jsx)(`small`,{children:a.detail})]})]})}function QQ({models:e,value:t,disabled:n,onChange:r}){let i=e.find(e=>e.id===t),a=i?.display_name||i?.displayName||i?.id||`默认模型`;return(0,W.jsxs)(hQ,{children:[(0,W.jsx)(gQ,{asChild:!0,children:(0,W.jsxs)(`button`,{className:`chat-model-trigger`,type:`button`,disabled:n,"aria-label":`选择模型,当前 ${a}`,title:`切换模型;下一轮生效`,children:[(0,W.jsx)(`span`,{children:a}),(0,W.jsx)(M,{size:13})]})}),(0,W.jsx)(_Q,{children:(0,W.jsxs)(vQ,{className:`chat-model-menu`,side:`top`,sideOffset:9,align:`end`,collisionPadding:12,children:[(0,W.jsx)(`div`,{className:`chat-model-menu-heading`,children:`选择下一轮使用的模型`}),(0,W.jsx)(xQ,{value:t,onValueChange:r,children:e.map(e=>{let t=e.display_name||e.displayName||e.id;return(0,W.jsxs)(SQ,{value:e.id,className:`chat-model-option`,children:[(0,W.jsx)(`span`,{children:t}),(0,W.jsx)(CQ,{children:(0,W.jsx)(j,{size:15})})]},e.id)})})]})})]})}function $Q(e){return`${e}_${typeof crypto.randomUUID==`function`?crypto.randomUUID().replaceAll(`-`,``):`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`}function e$(e){if(!e)return`刚刚`;let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=new Date;return t.toDateString()===n.toDateString()?new Intl.DateTimeFormat(`zh-CN`,{hour:`2-digit`,minute:`2-digit`}).format(t):new Intl.DateTimeFormat(`zh-CN`,{month:`2-digit`,day:`2-digit`}).format(t)}function t$(e){if(!e)return`刚刚`;let t=new Date(e);return Number.isNaN(t.getTime())?``:new Intl.DateTimeFormat(`zh-CN`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}).format(t)}function n$(e,t=34){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t)}…`:n}async function r$(e){let t=await e.clone().json().catch(()=>null);return t?.error?.message||t?.Message||t?.message||`请求失败(HTTP ${e.status})`}function i$(e){return e===`command`?(0,W.jsx)(qe,{size:14}):e===`approval`?(0,W.jsx)(ze,{size:14}):(0,W.jsx)(Qe,{size:14})}function a$(e){return e.kind===`command`?`命令`:e.kind===`approval`?`人工确认`:`工具`}function o$(e){let t=e.replace(/```[\s\S]*?```/g,` `).replace(/[`#>*_[\]()-]+/g,` `).replace(/\s+/g,` `).trim();return t?n$(t.split(/[。!?!?]+|\.(?=\s|$)/).map(e=>e.trim()).filter(Boolean).at(-1)||t,72):``}function s$({reasoning:e,activities:t,streaming:n=!1}){if(!e&&t.length===0)return null;let r=t.find(e=>e.status===`running`||e.status===`waiting`),i=n?r?`${r.status===`waiting`?`等待确认`:`正在处理`} · ${r.title}`:o$(e)?`正在思考 · ${o$(e)}`:`正在思考`:t.length>0?`已处理 ${t.length} 次工具调用`:`查看思考过程`;return(0,W.jsxs)(`details`,{className:`chat-processing-group`,children:[(0,W.jsxs)(`summary`,{children:[(0,W.jsx)(k,{size:15,className:`chat-processing-icon`}),(0,W.jsx)(`span`,{children:i}),n&&(0,W.jsx)(_e,{size:13,className:`animate-spin`}),(0,W.jsx)(M,{size:14,className:`details-chevron`})]}),(0,W.jsxs)(`div`,{className:`chat-processing-content`,children:[e&&(0,W.jsx)(`div`,{className:`chat-reasoning-content`,children:e}),t.map(e=>(0,W.jsx)(c$,{activity:e},e.id))]})]})}function c$({activity:e}){let t=!!e.detail||Object.keys(e.data).length>2,n=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`chat-activity-icon`,children:i$(e.kind)}),(0,W.jsxs)(`span`,{className:`chat-activity-copy`,children:[(0,W.jsx)(`small`,{children:a$(e)}),(0,W.jsx)(`strong`,{children:e.title})]}),(0,W.jsx)(`span`,{className:`chat-activity-status ${e.status}`,children:e.status===`completed`?`已完成`:e.status===`failed`?`失败`:e.status===`waiting`?`等待确认`:`运行中`})]});return t?(0,W.jsxs)(`details`,{className:`chat-activity-card ${e.kind}`,children:[(0,W.jsxs)(`summary`,{children:[n,(0,W.jsx)(M,{size:14,className:`details-chevron`})]}),(0,W.jsx)(`pre`,{children:e.detail||JSON.stringify(e.data,null,2)})]}):(0,W.jsx)(`div`,{className:`chat-activity-card ${e.kind}`,children:(0,W.jsx)(`div`,{className:`chat-activity-row`,children:n})})}function l$({runId:e,status:t,showOutput:n=!1,onInteraction:r}){let[i,a]=(0,s.useState)([]),[o,c]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let n=!1;async function r(){try{let t=await f(`/api/v1/runs/${encodeURIComponent(e)}/events`);if(!t.ok)throw Error(await r$(t));let r=[],i=zY(e=>{let{type:t,...n}=e;r.push({id:r.length+1,type:t,data:n})});i.push(await t.text()),i.finish(),n||a(r)}catch{}finally{n||c(!0)}}r();let i=[`RUNNING`,`PAUSED`,`WAITING_INPUT`].includes(String(t))?window.setInterval(r,500):null;return()=>{n=!0,i!==null&&window.clearInterval(i)}},[e,t]);let l=(0,s.useMemo)(()=>WY(i),[i]),u=(0,s.useMemo)(()=>RY(i),[i]);return!o&&[`RUNNING`,`PAUSED`,`WAITING_INPUT`].includes(String(t))?(0,W.jsxs)(`div`,{className:`chat-activity-loading`,children:[(0,W.jsx)(_e,{size:13,className:`animate-spin`}),` 正在读取运行事件`]}):!l.reasoning&&!l.output&&l.activities.length===0&&u.length===0?t===`RUNNING`?(0,W.jsxs)(`span`,{className:`message-loading`,"aria-label":`正在生成`,children:[(0,W.jsx)(`i`,{}),(0,W.jsx)(`i`,{}),(0,W.jsx)(`i`,{})]}):null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(s$,{reasoning:l.reasoning,activities:l.activities,streaming:t===`RUNNING`}),u.map(t=>(0,W.jsx)(jQ,{surface:t,onSubmit:(t,n,i)=>r(e,t,n,i)},t.id)),n&&l.output&&(0,W.jsx)(u$,{children:l.output})]})}function u$({children:e,streaming:t=!1}){return(0,W.jsx)(`div`,{className:`chat-markdown${t?` streaming`:``}`,children:(0,W.jsx)(gA,{remarkPlugins:[bN],components:{a:({href:e,children:t})=>(0,W.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:t}),code:({className:e,children:t})=>(0,W.jsx)(`code`,{className:e,children:t})},children:e})})}function d$({run:e,agentName:t,agentAppearance:n,onInteraction:r}){let i=e.status&&![`COMPLETED`,`RUNNING`,`PAUSED`,`WAITING_INPUT`].includes(e.status),a=e.output||e.error?.message||(i?`运行状态:${e.status}`:``);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`article`,{className:`message user`,children:[(0,W.jsxs)(`div`,{className:`message-meta`,children:[(0,W.jsx)(`strong`,{children:`你`}),(0,W.jsx)(`span`,{children:t$(e.startedAt)})]}),(0,W.jsx)(`div`,{className:`message-content`,children:(0,W.jsx)(`span`,{className:`plain-message`,children:e.input})})]}),(0,W.jsxs)(`article`,{className:`message assistant${i?` error`:``}`,children:[(0,W.jsxs)(`div`,{className:`message-meta`,children:[(0,W.jsx)(nt,{name:t,appearance:n,size:`xs`}),(0,W.jsx)(`strong`,{children:t}),(0,W.jsx)(`span`,{children:t$(e.completedAt||e.startedAt)}),e.model&&(0,W.jsx)(`span`,{className:`message-model`,children:e.model})]}),(0,W.jsxs)(`div`,{className:`message-content`,children:[(0,W.jsx)(l$,{runId:e.id,status:e.status,showOutput:[`RUNNING`,`PAUSED`,`WAITING_INPUT`].includes(String(e.status)),onInteraction:r}),[`RUNNING`,`PAUSED`,`WAITING_INPUT`].includes(String(e.status))?null:i?(0,W.jsx)(`span`,{className:`plain-message`,children:a}):a?(0,W.jsx)(u$,{children:a}):null]})]})]})}function f$({prompt:e,stream:t,agentName:n,agentAppearance:r,onInteraction:i}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`article`,{className:`message user`,children:[(0,W.jsxs)(`div`,{className:`message-meta`,children:[(0,W.jsx)(`strong`,{children:`你`}),(0,W.jsx)(`span`,{children:`刚刚`})]}),(0,W.jsx)(`div`,{className:`message-content`,children:(0,W.jsx)(`span`,{className:`plain-message`,children:e})})]}),(0,W.jsxs)(`article`,{className:`message assistant streaming-turn${t.status===`failed`?` error`:``}`,children:[(0,W.jsxs)(`div`,{className:`message-meta`,children:[(0,W.jsx)(nt,{name:n,appearance:r,size:`xs`}),(0,W.jsx)(`strong`,{children:n}),(0,W.jsx)(`span`,{children:t.status===`streaming`?`正在生成`:`刚刚`})]}),(0,W.jsxs)(`div`,{className:`message-content`,children:[(0,W.jsx)(s$,{reasoning:t.reasoning,activities:t.activities,streaming:t.status===`streaming`}),t.surfaces.map(e=>(0,W.jsx)(jQ,{surface:e,onSubmit:(e,n,r)=>i(t.runId,e,n,r)},e.id)),t.output?(0,W.jsx)(u$,{streaming:t.status===`streaming`,children:t.output}):t.error?(0,W.jsx)(`span`,{className:`plain-message`,children:t.error}):t.status===`cancelled`?(0,W.jsx)(`span`,{className:`plain-message`,children:`运行已停止`}):(0,W.jsxs)(`span`,{className:`message-loading`,children:[(0,W.jsx)(`i`,{}),(0,W.jsx)(`i`,{}),(0,W.jsx)(`i`,{})]})]})]})]})}function p$({agentId:e,agentName:t,agentAppearance:n,onRunChanged:r}){let[i,a]=(0,s.useState)([]),[o,c]=(0,s.useState)([]),[l,u]=(0,s.useState)(``),[d,p]=(0,s.useState)(``),[m,h]=(0,s.useState)(``),[g,_]=(0,s.useState)(``),[v,y]=(0,s.useState)(`risk`),[b,x]=(0,s.useState)(`default`),[S,C]=(0,s.useState)([]),[w,T]=(0,s.useState)(0),[E,D]=(0,s.useState)(null),[k,A]=(0,s.useState)(``),[j,M]=(0,s.useState)(!0),[N,P]=(0,s.useState)(``),[F,I]=(0,s.useState)(!1),L=(0,s.useRef)(null),R=(0,s.useRef)(null),z=(0,s.useRef)(null),B=(0,s.useRef)(!0),V=(0,s.useRef)(new Map),H=(0,s.useMemo)(()=>AY(i,e),[i,e]),U=(0,s.useMemo)(()=>{let e=m.trim().toLocaleLowerCase();return e?H.filter(t=>t.title.toLocaleLowerCase().includes(e)):H},[m,H]),ee=H.find(e=>e.id===d)?.runs||[],te=DY(ee),ne=E?.status||String(te?.status||``).toLowerCase(),re=[`streaming`,`paused`,`waiting_input`].includes(ne)||!!te,ie=OY(ee,E&&k&&E.sessionId===d?te?.id:void 0),ae=ne===`paused`?`PAUSED`:ne===`waiting_input`?`WAITING`:`RUNNING`,oe=E?.goalObjective||te?.goalObjective?`goal`:(E?.collaborationMode||te?.collaborationMode)===`plan`?`plan`:null,ce=ne===`paused`?`paused`:ne===`waiting_input`?`waiting`:`running`,le=E?.goalObjective||te?.goalObjective||k||te?.input||``,ue=E?.startedAt||te?.startedAt,de=ne===`paused`?te?.durationMs:void 0,fe=o.find(e=>e.id===l),pe=E?.usage,me=CY(pe?.input_tokens??pe?.inputTokens??TY(ee),fe?.context_window_tokens??fe?.contextWindowTokens),he=NQ(g),ve=(0,s.useCallback)(async()=>{let t=await f(`/api/v1/runs`);if(!t.ok)throw Error(await r$(t));let n=(await t.json()).items||[],r=AY(n,e);a(n),p(e=>e&&r.some(t=>t.id===e)?e:r[0]?.id||``)},[e]),be=(0,s.useCallback)(async()=>{let[,t]=await Promise.all([ve(),f(`/api/v1/agents/${encodeURIComponent(e)}/models`)]);if(!t.ok)throw Error(await r$(t));let n=await t.json(),r=n.Models||[];c(r),u(e=>r.some(t=>t.id===e)?e:String(n.Current||r[0]?.id||``))},[e,ve]);(0,s.useEffect)(()=>{let e=!1;return M(!0),a([]),p(``),be().catch(t=>{e||Cm(`会话加载失败`,t.message,`error`)}).finally(()=>{e||M(!1)}),()=>{e=!0,z.current?.abort()}},[e,be]),(0,s.useEffect)(()=>{y(EQ(localStorage.getItem(DQ(e))));let t=localStorage.getItem(`agentkit:chat:collaboration:${e}`);x(t===`plan`?`plan`:`default`),C([])},[e]),(0,s.useEffect)(()=>{T(0)},[g]),(0,s.useEffect)(()=>{if(!i.some(e=>[`RUNNING`,`PAUSED`,`WAITING_INPUT`].includes(String(e.status))))return;let e=window.setInterval(()=>{ve().catch(()=>{})},800);return()=>window.clearInterval(e)},[i,ve]),(0,s.useEffect)(()=>{let e=L.current;!e||!B.current||(e.scrollTop=e.scrollHeight)},[ee.length,E?.output,E?.reasoning,E?.status,E?.activities]),(0,s.useEffect)(()=>{let e=L.current;if(!e)return;let t=d?V.current.get(d):void 0;requestAnimationFrame(()=>{e.scrollTop=t??e.scrollHeight,B.current=t===void 0||e.scrollHeight-e.scrollTop-e.clientHeight<48})},[d]),(0,s.useEffect)(()=>{let e=R.current;e&&(e.style.height=`42px`,e.style.height=`${Math.min(Math.max(e.scrollHeight,42),160)}px`)},[g]);function xe(){re||(p(``),A(``),D(null),_(``),C([]),B.current=!0,requestAnimationFrame(()=>R.current?.focus()))}function Se(e){let t=L.current;t&&d&&V.current.set(d,t.scrollTop),p(e),B.current=!V.current.has(e)}function Ce(t){x(t),localStorage.setItem(`agentkit:chat:collaboration:${e}`,t)}function we(){let e=b===`plan`?`default`:`plan`;Ce(e),_(``),Cm(e===`plan`?`计划模式已开启`:`已返回默认模式`,`下一轮对话生效`,`success`),requestAnimationFrame(()=>R.current?.focus())}function Te(e){if(e===`goal`){_(`/goal `),requestAnimationFrame(()=>R.current?.focus());return}if(e==="default"){Ce(`default`),_(``),Cm(`已返回默认模式`,`下一轮对话生效`,`success`);return}we()}async function Ee(e){if(re)return;let t=Math.max(0,4-S.length);if(!t){Cm(`附件数量已达上限`,`每轮最多 4 个`,`error`);return}let n=e.slice(0,t);if(S.reduce((e,t)=>e+t.size,0)+n.reduce((e,t)=>e+t.size,0)>15e5){Cm(`附件体积过大`,`每轮附件总计不能超过 1.5 MiB`,`error`);return}let r=[];for(let e of n)try{r.push(await HQ(e))}catch(e){Cm(`无法添加附件`,e instanceof Error?e.message:String(e),`error`)}if(!r.length)return;let i=[...S,...r];if(RQ(i)>15e5){Cm(`附件编码后体积过大`,`每轮编码后的附件总计不能超过 1.5 MiB`,`error`);return}C(i)}async function De(){let t=PQ(g);if(re)return;if(t.kind===`toggle-plan`){we();return}if(t.kind===`set-default`){Ce(`default`),_(``),Cm(`已返回默认模式`,`下一轮对话生效`,`success`);return}if(t.kind===`goal`&&!t.objective){Cm(`请补充目标`,`在 /goal 后输入需要持续完成的目标`,`error`),requestAnimationFrame(()=>R.current?.focus());return}let n=t.kind===`goal`?t.objective:``,i=t.kind===`message`?t.text||(S.length?`请分析这些附件。`:``):n;if(!i&&!S.length)return;let a=d||$Q(`ses`),o=$Q(`resp`),s=v,c=new AbortController;z.current=c;let u={...jY(o,a),collaborationMode:b,goalObjective:n,startedAt:new Date().toISOString()};p(a),A(i),D(u),_(``);let m=S;C([]);try{let t=await f(`/v1/responses`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`same-origin`,signal:c.signal,body:JSON.stringify({model:l,input:FQ(i,m),stream:!0,metadata:{agent_id:e,session_id:a,invocation_id:o,approval_mode:s,collaboration_mode:b,goal_objective:n||void 0}})});if(!t.ok||!t.body)throw Error(await r$(t));let d=new TextDecoder,p=zY(e=>{u=NY(u,e),D(u)}),h=t.body.getReader();for(;;){let{value:e,done:t}=await h.read();if(e&&p.push(d.decode(e,{stream:!t})),t)break}if(p.finish(),u.status===`failed`)throw Error(u.error||`Agent 运行失败`);await ve(),D(null),A(``),r?.()}catch(e){if(c.signal.aborted)u={...u,status:`cancelled`},D(u);else{let t=e instanceof Error?e.message:String(e);u={...u,status:`failed`,error:t},D(u),Cm(`运行失败`,t,`error`)}}finally{z.current=null,requestAnimationFrame(()=>R.current?.focus())}}function Oe(t){y(t),localStorage.setItem(DQ(e),t)}async function ke(){if(re)try{let e=E?.status===`streaming`?await f(`/v1/responses/${encodeURIComponent(E.responseId)}:pause`,{method:`POST`,credentials:`same-origin`}):await f(`/api/v1/runs/${encodeURIComponent(te.id)}:pause`,{method:`POST`});if(!e.ok)throw Error(await r$(e));D(e=>e&&{...e,status:`paused`}),window.setTimeout(()=>{ve().catch(()=>{})},200)}catch(e){Cm(`暂停运行失败`,e instanceof Error?e.message:String(e),`error`)}}async function Ae(){try{let e=E?.status===`paused`?await f(`/v1/responses/${encodeURIComponent(E.responseId)}:resume`,{method:`POST`,credentials:`same-origin`}):await f(`/api/v1/runs/${encodeURIComponent(te.id)}:resume`,{method:`POST`});if(!e.ok)throw Error(await r$(e));D(e=>e&&{...e,status:`streaming`}),window.setTimeout(()=>{ve().catch(()=>{})},200)}catch(e){Cm(`继续运行失败`,e instanceof Error?e.message:String(e),`error`)}}async function Me(){if(re)try{let e=E?await f(`/v1/responses/${encodeURIComponent(E.responseId)}/cancel`,{method:`POST`,credentials:`same-origin`}):await f(`/api/v1/runs/${encodeURIComponent(te.id)}:cancel`,{method:`POST`});if(!e.ok)throw Error(await r$(e));z.current?.abort(),D(e=>e&&{...e,status:`cancelled`}),window.setTimeout(()=>{ve().catch(()=>{})},200)}catch(e){Cm(`结束运行失败`,e instanceof Error?e.message:String(e),`error`)}}async function Pe(e,t,n,r){if(!e)throw Error(`运行尚未创建,请稍后重试`);let i=await f(`/api/v1/runs/${encodeURIComponent(e)}/interactions/${encodeURIComponent(t)}:submit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:n,data:r})});if(!i.ok){let e=await r$(i);throw Cm(`提交交互失败`,e,`error`),Error(e)}D(e=>e&&{...e,status:`streaming`,surfaces:e.surfaces.map(e=>e.interaction?.id===t?{...e,interaction:{...e.interaction,status:`resolved`}}:e)}),await ve()}async function Fe(){if(N){I(!0);try{let e=await f(`/api/v1/sessions/${encodeURIComponent(N)}`,{method:`DELETE`});if(!e.ok)throw Error(await r$(e));d===N&&p(``),P(``),await ve(),Cm(`会话已删除`,`相关运行与 Trace 已从本地工作区移除。`)}catch(e){Cm(`删除失败`,e instanceof Error?e.message:String(e),`error`)}finally{I(!1)}}}return(0,W.jsxs)(`div`,{className:`studio-chat-shell`,"data-testid":`studio-chat-workbench`,children:[(0,W.jsxs)(`aside`,{className:`chat-session-sidebar`,"aria-label":`会话历史`,children:[(0,W.jsxs)(`header`,{className:`chat-session-header`,children:[(0,W.jsx)(`div`,{children:(0,W.jsx)(`strong`,{children:`会话`})}),(0,W.jsx)(`button`,{className:`icon-button tertiary`,type:`button`,"aria-label":`新对话`,title:`新对话`,onClick:xe,disabled:re,children:(0,W.jsx)(ye,{size:16})})]}),(0,W.jsxs)(`label`,{className:`chat-session-search`,children:[(0,W.jsx)(`span`,{className:`sr-only`,children:`搜索会话`}),(0,W.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:`搜索会话`})]}),(0,W.jsx)(`div`,{className:`chat-session-list`,children:j?(0,W.jsxs)(`div`,{className:`session-empty`,children:[(0,W.jsx)(_e,{size:15,className:`animate-spin`}),` 加载中`]}):U.length===0?(0,W.jsx)(`div`,{className:`session-empty`,children:m?`没有匹配的会话`:`还没有会话`}):U.map(e=>(0,W.jsxs)(`div`,{className:`chat-session-item${d===e.id?` active`:``}`,children:[(0,W.jsxs)(`button`,{className:`chat-session-main`,type:`button`,"aria-current":d===e.id?`true`:void 0,onClick:()=>Se(e.id),title:`${e.title} · ${e$(e.updatedAt)}`,children:[(0,W.jsx)(`strong`,{children:n$(e.title)}),e.running&&(0,W.jsx)(`span`,{className:`session-status ${String(e.activeStatus||`RUNNING`).toLowerCase()}`,"aria-label":e.activeStatus===`PAUSED`?`已暂停`:e.activeStatus===`WAITING_INPUT`?`等待输入`:`运行中`})]}),(0,W.jsx)(`button`,{className:`chat-session-delete`,type:`button`,"aria-label":`删除会话:${n$(e.title)}`,title:e.running||E?.status===`streaming`&&E.sessionId===e.id?`运行中不可删除`:`删除会话`,disabled:e.running||E?.status===`streaming`&&E.sessionId===e.id,onClick:()=>P(e.id),children:(0,W.jsx)(Ye,{size:14})})]},e.id))})]}),(0,W.jsxs)(`section`,{className:`chat-conversation`,"aria-label":`与 ${t} 对话`,children:[(0,W.jsxs)(`header`,{className:`chat-conversation-header`,children:[(0,W.jsx)(nt,{name:t,appearance:n,size:`sm`}),(0,W.jsx)(`div`,{children:(0,W.jsx)(`strong`,{children:t})}),re&&(0,W.jsx)(`span`,{className:`status-badge ${ae}`,children:ae})]}),(0,W.jsx)(`div`,{ref:L,className:`chat-message-list`,role:`log`,"aria-live":`polite`,"aria-relevant":`additions text`,onScroll:e=>{let t=e.currentTarget;B.current=t.scrollHeight-t.scrollTop-t.clientHeight<48,d&&V.current.set(d,t.scrollTop)},children:ee.length===0&&!E?(0,W.jsxs)(`div`,{className:`chat-empty`,children:[(0,W.jsx)(`span`,{className:`chat-empty-icon`,children:(0,W.jsx)(O,{size:22})}),(0,W.jsxs)(`h2`,{children:[`开始与 `,t,` 对话`]}),(0,W.jsx)(`p`,{children:`消息通过统一的 Responses API 发送;思考、工具调用和结果会在同一条时间线中呈现。`}),(0,W.jsx)(`div`,{className:`suggestion-list`,children:[`先介绍你的职责、能力和工作边界。`,`根据当前上下文给出一个清晰的执行计划。`,`列出完成任务还需要我提供的信息。`].map(e=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>{_(e),R.current?.focus()},children:e},e))})]}):(0,W.jsxs)(W.Fragment,{children:[ie.map(e=>(0,W.jsx)(d$,{run:e,agentName:t,agentAppearance:n,onInteraction:Pe},e.id)),E&&E.sessionId===d&&k&&(0,W.jsx)(f$,{prompt:k,stream:E,agentName:t,agentAppearance:n,onInteraction:Pe})]})}),(0,W.jsxs)(`footer`,{className:`chat-composer-wrap`,children:[re&&oe&&(0,W.jsx)(YQ,{mode:oe,status:ce,objective:le,startedAt:ue,elapsedMs:de,onPause:ce===`running`?ke:void 0,onResume:ce===`paused`?Ae:void 0,onStop:Me}),(0,W.jsxs)(`div`,{className:`chat-composer`,children:[(0,W.jsx)(KQ,{input:g,activeIndex:w,onSelect:Te}),S.length>0&&(0,W.jsx)(`div`,{className:`chat-attachment-list`,"aria-label":`本轮附件`,children:S.map(e=>(0,W.jsxs)(`div`,{className:`chat-attachment-chip ${e.kind}`,children:[e.kind===`image`&&e.dataUrl?(0,W.jsx)(`img`,{src:e.dataUrl,alt:``}):(0,W.jsx)(`span`,{className:`chat-attachment-icon`,children:(0,W.jsx)(se,{size:15})}),(0,W.jsxs)(`span`,{className:`chat-attachment-copy`,children:[(0,W.jsx)(`strong`,{children:e.name}),(0,W.jsxs)(`small`,{children:[e.kind===`image`?`图片`:`文本`,` · `,UQ(e.size)]})]}),(0,W.jsx)(`button`,{type:`button`,"aria-label":`移除附件 ${e.name}`,onClick:()=>C(t=>t.filter(t=>t.id!==e.id)),children:(0,W.jsx)($e,{size:13})})]},e.id))}),(0,W.jsx)(`textarea`,{ref:R,rows:1,value:g,onChange:e=>_(e.target.value),onKeyDown:e=>{if(he.length&&[`ArrowDown`,`ArrowUp`].includes(e.key)){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;T(e=>(e+t+he.length)%he.length);return}if(he.length&&e.key===`Escape`){e.preventDefault(),_(``);return}if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing){if(e.preventDefault(),he.length){Te(he[Math.min(w,he.length-1)].id);return}De()}},placeholder:b===`plan`?`描述需要规划的任务…`:`输入消息,或输入 / 使用命令…`,"aria-label":`消息`,disabled:re}),(0,W.jsxs)(`div`,{className:`chat-composer-footer`,children:[(0,W.jsx)(GQ,{mode:b,disabled:re,onTogglePlan:we,onStartGoal:()=>Te(`goal`),onFiles:Ee}),b===`plan`&&(0,W.jsxs)(`button`,{className:`chat-mode-chip`,type:`button`,title:`点击返回默认模式`,onClick:we,children:[(0,W.jsx)(ge,{size:14}),(0,W.jsx)(`span`,{children:`计划`})]}),(0,W.jsx)(XQ,{value:v,onChange:Oe}),(0,W.jsx)(`span`,{className:`chat-composer-spacer`}),(0,W.jsx)(ZQ,{...me}),(0,W.jsx)(QQ,{models:o,value:l,disabled:o.length<=1||re,onChange:u}),ne===`paused`?(0,W.jsx)(`button`,{className:`chat-send-button resume`,type:`button`,"aria-label":`继续生成`,title:`继续生成`,onClick:Ae,children:(0,W.jsx)(Ne,{size:15,fill:`currentColor`})}):ne===`waiting_input`?(0,W.jsx)(`button`,{className:`chat-send-button pause`,type:`button`,"aria-label":`等待交互输入`,title:`请先处理上方交互卡片`,disabled:!0,children:(0,W.jsx)(_e,{size:15,className:`animate-spin`})}):re?(0,W.jsx)(`button`,{className:`chat-send-button pause`,type:`button`,"aria-label":`暂停生成`,title:`暂停生成`,onClick:ke,children:(0,W.jsx)(je,{size:15,fill:`currentColor`})}):(0,W.jsx)(`button`,{className:`chat-send-button`,type:`button`,"aria-label":`发送消息`,title:`发送消息`,onClick:De,disabled:!g.trim()&&!S.length,children:(0,W.jsx)(Le,{size:15})})]})]})]})]}),N&&(0,W.jsx)(ca,{title:`删除这个会话?`,description:`相关 Run 与 Trace 会从当前本地工作区移除。`,confirmText:`删除会话`,busy:F,onConfirm:Fe,onCancel:()=>P(``)})]})}function m$(e){return e<=1023?`compact`:e<=1439?`laptop`:e<=1919?`desktop`:`wide`}function h$(){let[e,t]=(0,s.useState)(()=>m$(window.innerWidth));return(0,s.useEffect)(()=>{let e=()=>t(m$(window.innerWidth));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}var g$=`agentkit-studio-theme`,_$=`(prefers-color-scheme: dark)`;function v$(e){return e===`light`||e===`dark`||e===`system`?e:`system`}function y$(e,t){return e===`system`?t?`dark`:`light`:e}function b$(){try{return v$(window.localStorage.getItem(g$))}catch{return`system`}}function x$(){return typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}function S$(e){let t=document.documentElement;t.classList.toggle(`dark`,e===`dark`),t.dataset.theme=e,t.style.colorScheme=e}function C$(){let e=b$();return S$(y$(e,x$())),e}function w$(){let[e,t]=(0,s.useState)(b$),[n,r]=(0,s.useState)(x$),i=y$(e,n);return(0,s.useEffect)(()=>{let e=window.matchMedia(_$),t=()=>r(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,s.useLayoutEffect)(()=>{S$(i)},[i]),{preference:e,resolvedTheme:i,setPreference:(0,s.useCallback)(e=>{t(e);try{window.localStorage.setItem(g$,e)}catch{}},[])}}var T$=Object.defineProperty,E$=(e,t)=>T$(e,`name`,{value:t,configurable:!0}),[D$,O$]=vt(`Tooltip`,[Wu]),k$=Wu(),A$=`TooltipProvider`,j$=700,M$=`tooltip.open`,[N$,P$]=D$(A$),F$=E$(e=>{let{__scopeTooltip:t,delayDuration:n=j$,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=s.useRef(!0),c=s.useRef(!1),l=s.useRef(0);return s.useEffect(()=>{let e=l.current;return()=>window.clearTimeout(e)},[]),(0,W.jsx)(N$,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:s.useCallback(()=>{r<=0||(window.clearTimeout(l.current),o.current=!1)},[r]),onClose:s.useCallback(()=>{r<=0||(window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:c,onPointerInTransitChange:s.useCallback(e=>{c.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),I$=`Tooltip`,[L$,R$]=D$(I$),z$=E$(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:c}=e,l=P$(I$,e.__scopeTooltip),u=k$(t),[d,f]=s.useState(null),[p,m]=s.useState(void 0),h=Tt(),g=s.useRef(0),_=o??l.disableHoverableContent,v=c??l.delayDuration,y=s.useRef(!1),[b,x]=Pt({prop:r,defaultProp:i??!1,onChange:E$(e=>{e?(l.onOpen(),document.dispatchEvent(new CustomEvent(M$))):l.onClose(),a?.(e)},`onChange`),caller:I$}),S=s.useMemo(()=>b?y.current?`delayed-open`:`instant-open`:`closed`,[b]),C=s.useCallback(()=>{window.clearTimeout(g.current),g.current=0,y.current=!1,x(!0)},[x]),w=s.useCallback(()=>{window.clearTimeout(g.current),g.current=0,x(!1)},[x]),T=s.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{y.current=!0,x(!0),g.current=0},v)},[v,x]);s.useEffect(()=>()=>{g.current&&=(window.clearTimeout(g.current),0)},[]);let E=p??h;return(0,W.jsx)(od,{...u,children:(0,W.jsx)(L$,{scope:t,contentId:E,setContentId:m,open:b,stateAttribute:S,trigger:d,onTriggerChange:f,onTriggerEnter:s.useCallback(()=>{l.isOpenDelayedRef.current?T():C()},[l.isOpenDelayedRef,T,C]),onTriggerLeave:s.useCallback(()=>{_?w():(window.clearTimeout(g.current),g.current=0)},[w,_]),onOpen:C,onClose:w,disableHoverableContent:_,children:n})})},`Tooltip`),B$=`TooltipTrigger`,V$=s.forwardRef(E$(function(e,t){let{__scopeTooltip:n,...r}=e,i=R$(B$,n),a=P$(B$,n),o=k$(n),c=mt(t,s.useRef(null),i.onTriggerChange),l=s.useRef(!1),u=s.useRef(!1),d=s.useCallback(()=>l.current=!1,[]);return s.useEffect(()=>()=>document.removeEventListener(`pointerup`,d),[d]),(0,W.jsx)(sd,{asChild:!0,...o,children:(0,W.jsx)(rn.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:G(e.onPointerMove,e=>{e.pointerType!==`touch`&&!u.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:G(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:G(e.onPointerDown,()=>{i.open&&i.onClose(),l.current=!0,document.addEventListener(`pointerup`,d,{once:!0})}),onFocus:G(e.onFocus,()=>{l.current||i.onOpen()}),onBlur:G(e.onBlur,i.onClose),onClick:G(e.onClick,i.onClose)})})},`TooltipTrigger`)),H$=`TooltipPortal`,[U$,W$]=D$(H$,{forceMount:void 0}),G$=E$(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=R$(H$,t);return(0,W.jsx)(U$,{scope:t,forceMount:n,children:(0,W.jsx)(Gn,{present:n||a.open,children:(0,W.jsx)(Vn,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),K$=`TooltipContent`,q$=s.forwardRef(E$(function(e,t){let n=W$(K$,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=R$(K$,e.__scopeTooltip);return(0,W.jsx)(Gn,{present:r||o.open,children:o.disableHoverableContent?(0,W.jsx)(X$,{side:i,...a,ref:t}):(0,W.jsx)(J$,{side:i,...a,ref:t})})},`TooltipContent`)),J$=s.forwardRef(E$(function(e,t){let n=R$(K$,e.__scopeTooltip),r=P$(K$,e.__scopeTooltip),i=s.useRef(null),a=mt(t,i),[o,c]=s.useState(null),{trigger:l,onClose:u}=n,d=i.current,{onPointerInTransitChange:f}=r,p=s.useCallback(()=>{c(null),f(!1)},[f]),m=s.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=$$(r,Q$(r,n.getBoundingClientRect())),a=e1(t.getBoundingClientRect()),o=n1([...i,...a]);c(o),f(!0)},[f]);return s.useEffect(()=>()=>p(),[p]),s.useEffect(()=>{if(l&&d){let e=E$(e=>m(e,d),`handleTriggerLeave`),t=E$(e=>m(e,l),`handleContentLeave`);return l.addEventListener(`pointerleave`,e),d.addEventListener(`pointerleave`,t),()=>{l.removeEventListener(`pointerleave`,e),d.removeEventListener(`pointerleave`,t)}}},[l,d,m,p]),s.useEffect(()=>{if(o){let e=E$(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=l?.contains(t)||d?.contains(t),i=!t1(n,o);r?p():i&&(p(),u())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[l,d,o,u,p]),(0,W.jsx)(X$,{...e,ref:a})},`TooltipContentHoverable`)),Y$=Wt(`TooltipContent`),X$=s.forwardRef(E$(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:c,...l}=e,u=R$(K$,n),d=k$(n),{onClose:f}=u;s.useEffect(()=>(document.addEventListener(M$,f),()=>document.removeEventListener(M$,f)),[f]),s.useEffect(()=>{if(u.trigger){let e=E$(e=>{e.target instanceof Node&&e.target.contains(u.trigger)&&f()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[u.trigger,f]);let{setContentId:p}=u;return bt(()=>(p(a),()=>{p(void 0)}),[a,p]),(0,W.jsx)(gn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:e=>e.preventDefault(),onDismiss:f,children:(0,W.jsxs)(cd,{"data-state":u.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:u.contentId,...d,...l,ref:t,style:{...l.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:[(0,W.jsx)(Y$,{children:r}),i?(0,W.jsx)(gd,{id:u.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`)),Z$=s.forwardRef(E$(function(e,t){let{__scopeTooltip:n,...r}=e,i=k$(n);return(0,W.jsx)(ld,{...i,...r,ref:t})},`TooltipArrow`));function Q$(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}E$(Q$,`getExitSideFromRect`);function $$(e,t,n=5){let 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})}return r}E$($$,`getPaddedExitPoints`);function e1(e){let{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}]}E$(e1,`getPointsFromRect`);function t1(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}E$(t1,`isPointInPolygon`);function n1(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),r1(t)}E$(n1,`getHull`);function r1(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}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)}E$(r1,`getHullPresorted`);var i1=F$,a1=z$,o1=V$,s1=G$,c1=q$,l1=Z$,u1=`agentkit.studio.rail-expanded`,d1=[{group:`构建与运行`,items:[{id:`agents`,label:`Agent`,icon:O},{id:`conversations`,label:`会话`,icon:xe},{id:`builds`,label:`构建`,icon:Ee},{id:`deployments`,label:`部署`,icon:V}]},{group:`工程资源`,items:[{id:`resources`,label:`模型`,icon:re,kind:`model`},{id:`resources`,label:`Tool`,icon:Qe,kind:`tool`},{id:`resources`,label:`MCP`,icon:Te,kind:`mcp`},{id:`resources`,label:`Skill`,icon:He,kind:`skill`}]},{group:`治理`,items:[{id:`observability`,label:`可观测`,icon:w},{id:`runtime-resources`,label:`运行资源`,icon:re},{id:`orchestration`,label:`任务编排`,icon:Te}]}];function f1(){try{let e=window.localStorage.getItem(u1);return e===null?null:e===`true`}catch{return null}}function p1(e){try{window.localStorage.setItem(u1,String(e))}catch{}}function m1(e,t,n){return t===e.id&&(e.id!==`resources`||e.kind===n)||(t===`agent-detail`||t===`create`)&&e.id===`agents`}function h1({label:e,children:t}){return(0,W.jsxs)(a1,{children:[(0,W.jsx)(o1,{asChild:!0,children:t}),(0,W.jsx)(s1,{children:(0,W.jsxs)(c1,{className:`studio-tooltip`,side:`right`,sideOffset:8,children:[e,(0,W.jsx)(l1,{className:`studio-tooltip-arrow`})]})})]})}function g1({view:e,resourceKind:t,expanded:n,workspaceName:r,workspacePath:i,runtimeReady:a,onNavigate:o,onOpenSettings:s}){return(0,W.jsx)(i1,{delayDuration:320,skipDelayDuration:120,children:(0,W.jsxs)(`aside`,{className:`sidebar navigation-rail`,"data-state":n?`expanded`:`compact`,children:[(0,W.jsxs)(`div`,{className:`product`,children:[(0,W.jsx)(`span`,{className:`product-mark`,"aria-hidden":`true`,children:`K`}),(0,W.jsxs)(`span`,{className:`product-copy`,children:[(0,W.jsx)(`strong`,{children:`AgentKit`}),(0,W.jsx)(`span`,{children:`Studio`})]})]}),(0,W.jsx)(h1,{label:i,children:(0,W.jsxs)(`button`,{className:`workspace-switcher`,type:`button`,"aria-label":`${r} 工作区`,"aria-disabled":!a,children:[(0,W.jsx)(`span`,{className:`workspace-mark`,children:(0,W.jsx)(ue,{size:16})}),(0,W.jsx)(`span`,{className:`workspace-copy`,children:(0,W.jsx)(`strong`,{children:r})})]})}),(0,W.jsx)(`nav`,{className:`primary-nav`,"aria-label":`产品导航`,children:d1.map(r=>(0,W.jsxs)(`div`,{className:`nav-group`,children:[(0,W.jsx)(`div`,{className:`nav-label`,children:r.group}),r.items.map(r=>{let i=r.icon,a=m1(r,e,t),s=(0,W.jsxs)(`button`,{className:`nav-item${a?` active`:``}`,type:`button`,"aria-label":r.label,"aria-current":a?`page`:void 0,onClick:()=>o(r.id,r.kind),children:[(0,W.jsx)(i,{size:18}),(0,W.jsx)(`span`,{children:r.label})]},`${r.id}-${r.label}`);return n?s:(0,W.jsx)(h1,{label:r.label,children:s},`${r.id}-${r.label}`)})]},r.group))}),(0,W.jsxs)(`div`,{className:`sidebar-footer`,children:[(0,W.jsx)(h1,{label:`本地用户`,children:(0,W.jsx)(`span`,{className:`user-avatar`,"aria-label":`本地用户`,children:`A`})}),(0,W.jsx)(h1,{label:`设置`,children:(0,W.jsx)(`button`,{className:`icon-button tertiary`,type:`button`,"aria-label":`设置`,onClick:s,children:(0,W.jsx)(Re,{size:16})})})]})]})})}var _1={agents:`Agent`,create:`创建 Agent`,"agent-detail":`Agent 配置`,conversations:`会话`,resources:`工程资源`,builds:`构建`,deployments:`部署`,observability:`可观测`,"runtime-resources":`运行资源`,orchestration:`任务编排`},v1=Object.keys(_1);function y1(){let e=h$(),t=w$(),[n,r]=(0,s.useState)(()=>{let e=window.location.hash.replace(/^#\/?/,``);return v1.includes(e)?e:`agents`}),[i,a]=(0,s.useState)(`model`),[o,c]=(0,s.useState)([]),[l,u]=(0,s.useState)(!1),[d,p]=(0,s.useState)(``),[m,h]=(0,s.useState)(``),[g,_]=(0,s.useState)(``),[v,y]=(0,s.useState)(null),[b,x]=(0,s.useState)(!1),[S,C]=(0,s.useState)(!1),[w,T]=(0,s.useState)(n===`conversations`),[E,D]=(0,s.useState)(!1),[k,A]=(0,s.useState)(0),[j,N]=(0,s.useState)(f1);(0,s.useEffect)(()=>(document.body.classList.toggle(`create-mode`,n===`create`),()=>document.body.classList.remove(`create-mode`)),[n]),(0,s.useEffect)(()=>{let e=()=>{let e=window.location.hash.replace(/^#\/?/,``);v1.includes(e)&&r(e)};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);function P(e){r(e),window.history.replaceState(null,``,`#/${e}`)}let F=(0,s.useCallback)(async()=>{try{let e=(await f(`/api/v1/agents?limit=100`).then(e=>e.json())).items||[],t=await Promise.all(e.map(e=>f(`/api/v1/agents/${encodeURIComponent(e.metadata.id)}`).then(e=>e.ok?e.json():null).catch(()=>null))),n=e.map((e,n)=>({...e,builds:t[n]?.builds||[]}));c(n),p(e=>n.some(t=>t.metadata.id===e)?e:n[0]?.metadata.id||``)}catch{}finally{u(!0)}},[]);(0,s.useEffect)(()=>{F()},[F,k]),(0,s.useEffect)(()=>{f(`/api/v1/system/bootstrap`).then(e=>e.json()).then(e=>{y(e.workspace||null),x(!!e.workspace)}).catch(()=>x(!1))},[k]);let I=o.find(e=>e.metadata.id===d),L=I?.spec?.runtime?.type||I?.metadata.labels?.[`agentkit.ksyun.com/framework`]||``,R=b?`Ready`:`Connecting`;function z(e){e&&(p(e),n===`conversations`&&T(!0))}function B(e){let t=e||d||o[0]?.metadata.id||``;if(!t){H();return}p(t),T(!0),P(`conversations`)}function V(e){_(``),h(e),p(e),P(`agent-detail`)}function H(){_(``),P(`create`)}function U(e){_(e),p(e),P(`create`)}function ee(e){a(e),P(`resources`)}let te=n===`create`||n===`agent-detail`?`Agent`:null,ne=_1[n],re=v?.name||`Workspace`,ie=v?.path||(b?`本地工作区`:`正在连接本地工作区`),ae=n===`create`||n===`conversations`||n===`observability`,oe=e!==`compact`,se=oe&&(j??!1);function ce(){if(!oe)return;let e=!se;N(e),p1(e)}function le(e,t){e===`conversations`?B():e===`resources`?ee(t||`model`):P(e)}return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`a`,{className:`skip-link`,href:`#mainContent`,children:`跳到主要内容`}),(0,W.jsxs)(`div`,{className:`app-shell`,"data-view":n,"data-viewport":e,"data-focused":ae,"data-rail":se?`expanded`:`compact`,children:[(0,W.jsx)(g1,{view:n,resourceKind:i,expanded:se,workspaceName:re,workspacePath:ie,runtimeReady:b,onNavigate:le,onOpenSettings:()=>C(!0)}),(0,W.jsxs)(`div`,{className:`app-main`,children:[(0,W.jsxs)(`header`,{className:`global-header${te?` nested`:``}`,children:[oe&&(0,W.jsx)(`button`,{className:`icon-button tertiary rail-toggle`,type:`button`,"aria-label":se?`收起导航`:`展开导航`,title:se?`收起导航`:`展开导航`,onClick:ce,children:se?(0,W.jsx)(De,{size:16}):(0,W.jsx)(Oe,{size:16})}),te&&(0,W.jsxs)(`div`,{className:`breadcrumb`,"aria-label":`当前位置`,children:[(0,W.jsx)(`span`,{className:`muted`,children:te}),(0,W.jsx)(M,{size:13,style:{transform:`rotate(-90deg)`,color:`var(--text-tertiary)`}}),(0,W.jsx)(`span`,{children:ne})]}),(0,W.jsx)(`div`,{className:`header-spacer`}),(0,W.jsxs)(`div`,{className:`global-context`,"aria-label":`全局工作上下文`,children:[(0,W.jsxs)(`div`,{className:`context-field`,children:[(0,W.jsx)(`span`,{children:`Agent`}),(0,W.jsx)(Tf,{ariaLabel:`切换当前 Agent`,value:d,placeholder:`未选择`,options:o.map(e=>({value:e.metadata.id,label:e.metadata.name})),onValueChange:z})]}),(0,W.jsxs)(`div`,{className:`context-field`,children:[(0,W.jsx)(`span`,{children:`目标`}),(0,W.jsx)(Tf,{ariaLabel:`切换执行目标`,value:`local`,options:[{value:`local`,label:`Local`},{value:`cloud-unconnected`,label:`金山云 · 未连接`,disabled:!0}],onValueChange:()=>void 0})]}),(0,W.jsx)(`span`,{className:`runtime-badge`,children:L?`${L} RuntimeAdapter`:`Runtime 未选择`})]}),(0,W.jsxs)(`button`,{className:`runtime-indicator`,type:`button`,disabled:!b,children:[(0,W.jsx)(`span`,{className:`status-dot ${b?`success`:`warning`}`}),(0,W.jsx)(`span`,{children:`Local`}),(0,W.jsx)(`span`,{className:`runtime-state`,children:R}),(0,W.jsx)(M,{size:13})]}),(0,W.jsx)(`button`,{className:`icon-button tertiary`,type:`button`,"aria-label":`刷新`,title:`刷新`,onClick:()=>A(e=>e+1),children:(0,W.jsx)(Fe,{size:16})}),n===`conversations`&&w&&d&&(0,W.jsx)(`button`,{className:`icon-button tertiary`,type:`button`,"aria-label":`运行详情`,title:`运行详情`,onClick:()=>D(e=>!e),children:(0,W.jsx)(ke,{size:16})})]}),(0,W.jsxs)(`main`,{id:`mainContent`,children:[(0,W.jsxs)(`div`,{className:`chat-wrap`,"data-scroll-mode":`workbench`,style:{display:n===`conversations`?`flex`:`none`},children:[(0,W.jsxs)(`div`,{className:`chat-host`,children:[w&&d&&(0,W.jsx)(p$,{agentId:d,agentName:I?.metadata.name||`Agent`,agentAppearance:I?.metadata.appearance},d),w&&!d&&(0,W.jsxs)(`div`,{className:`empty-state chat-agent-empty`,role:`status`,children:[(0,W.jsx)(`span`,{className:`empty-icon`,children:(0,W.jsx)(O,{})}),(0,W.jsx)(`h2`,{children:l?`先创建 Agent 才能开始会话`:`正在载入 Agent`}),(0,W.jsx)(`p`,{children:l?`会话会使用当前 Agent 的模型、工具与运行时配置。`:`正在同步本地工作区…`}),l&&(0,W.jsx)(`button`,{className:`primary-button`,type:`button`,onClick:H,children:`创建 Agent`})]})]}),E&&w&&d&&(0,W.jsx)(nX,{agentId:d,onClose:()=>D(!1),onOpenTrace:()=>P(`observability`)})]}),(0,W.jsxs)(`div`,{style:{display:n===`conversations`?`none`:void 0},children:[n===`agents`&&(0,W.jsx)(Ef,{agents:o,runtimeReady:b,workspaceName:v?.name||``,onCreate:H,onDetail:V,onChat:B,onBuild:()=>P(`builds`),onChanged:F}),n===`create`&&(0,W.jsx)(zF,{editingAgentId:g||void 0,viewportMode:e,onAgentsChanged:F,onBack:()=>g?V(g):P(`agents`),onCreated:(e,t)=>{_(``),F(),e&&t?B(e):e?V(e):P(`agents`)}}),n===`agent-detail`&&m&&(0,W.jsx)(HF,{agentId:m,onBack:()=>P(`agents`),onChat:B,onBuild:()=>P(`builds`),onEdit:U,onChanged:F}),n===`resources`&&(0,W.jsx)(_F,{kind:i,onKindChange:a,refreshTick:k}),n===`builds`&&(0,W.jsx)(KF,{currentAgentId:d,agents:o,onSelectAgent:p,onCreate:H}),n===`deployments`&&(0,W.jsx)(qF,{onCreate:H}),n===`observability`&&(0,W.jsx)(PI,{refreshTick:k}),n===`runtime-resources`&&(0,W.jsx)(VI,{refreshTick:k}),n===`orchestration`&&(0,W.jsx)(bY,{currentAgentId:d,agents:o,onSelectAgent:p,onCreate:H})]})]})]}),S&&(0,W.jsx)(SY,{themePreference:t.preference,onThemePreferenceChange:t.setPreference,onClose:()=>C(!1)}),(0,W.jsx)(wm,{})]})]})}async function b1(){C$();try{await p()}catch{}(0,c.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(s.StrictMode,{children:(0,W.jsx)(y1,{})}))}b1();
|