agentengine-sdk-python 0.8.2__py3-none-any.whl → 0.8.4__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.2.dist-info → agentengine_sdk_python-0.8.4.dist-info}/METADATA +22 -28
- agentengine_sdk_python-0.8.4.dist-info/RECORD +1070 -0
- ksadk/_build_provenance.json +1 -0
- ksadk/agui/_agent_helpers.py +4 -0
- ksadk/api/client.py +108 -91
- ksadk/builders/code_builder.py +36 -9
- ksadk/builders/framework_requirements.py +2 -1
- ksadk/builders/ks3_uploader.py +36 -7
- ksadk/builders/managed_runtime_builder.py +4 -0
- ksadk/cli/__init__.py +38 -3
- ksadk/cli/cmd_managed_runtime.py +13 -1
- ksadk/cli/cmd_plugin.py +662 -0
- ksadk/cli/cmd_web.py +2 -5
- ksadk/cli/runtime_bootstrap.py +23 -1
- ksadk/codex/client.py +424 -96
- ksadk/codex/projection.py +24 -0
- ksadk/codex/runtime.py +83 -283
- ksadk/common/auth.py +16 -10
- ksadk/configs/env_registry.py +59 -3
- ksadk/configs/settings.py +9 -0
- ksadk/context_engine/contributors.py +73 -8
- ksadk/conversations/__init__.py +19 -0
- ksadk/conversations/context.py +104 -24
- ksadk/conversations/contracts.py +266 -0
- ksadk/conversations/message_projection.py +154 -15
- ksadk/conversations/projector.py +614 -0
- ksadk/conversations/reducer.py +98 -0
- ksadk/conversations/runtime_invocation.py +5 -0
- ksadk/conversations/runtime_payloads.py +1 -0
- ksadk/conversations/runtime_preparation.py +30 -27
- ksadk/conversations/runtime_resume.py +50 -2
- ksadk/conversations/runtime_stream_events.py +5 -0
- ksadk/conversations/runtime_streaming.py +25 -7
- ksadk/deployment/env_forward.py +2 -2
- ksadk/deployment/providers/serverless.py +1 -1
- ksadk/events/_v1_compat/projection.py +2 -0
- ksadk/events/adapters/_codex_validators.py +18 -7
- ksadk/events/adapters/codex.py +190 -0
- ksadk/events/adapters/langgraph.py +15 -1
- ksadk/events/canonical_store.py +3 -1
- ksadk/events/projections.py +1 -1
- ksadk/harness/__init__.py +45 -35
- ksadk/harness/config.py +2 -2
- ksadk/harness/runtime.py +75 -16
- ksadk/harness/tools.py +38 -13
- ksadk/interaction/provider.py +1 -0
- ksadk/interaction/providers/langgraph.py +1 -0
- ksadk/kernel/bootstrap.py +28 -4
- ksadk/kernel/contract_fingerprints.py +5 -4
- ksadk/kernel/contracts.py +8 -0
- ksadk/kernel/control.py +1 -0
- ksadk/kernel/ingress.py +36 -2
- ksadk/kernel/memory_store.py +1 -0
- ksadk/kernel/postgres_store.py +1 -0
- ksadk/kernel/sqlite_store.py +28 -0
- ksadk/kernel/store.py +3 -0
- ksadk/kernel/worker.py +76 -10
- ksadk/knowledge_base/client.py +57 -27
- ksadk/mcp_runtime/__init__.py +12 -4
- ksadk/memory/adk/backends/sdk_ltm_backend.py +161 -41
- ksadk/memory/adk/resilient_session_service.py +25 -17
- ksadk/memory/adk/short_term_memory.py +26 -9
- ksadk/memory/models.py +7 -4
- ksadk/memory/provider_resolver.py +3 -0
- ksadk/memory/providers/local_sqlite.py +7 -0
- ksadk/model_proxy/server.py +10 -5
- ksadk/plugins/__init__.py +171 -0
- ksadk/plugins/artifacts.py +275 -0
- ksadk/plugins/bridges/__init__.py +47 -0
- ksadk/plugins/bridges/codex.py +659 -0
- ksadk/plugins/bridges/dsh.py +1300 -0
- ksadk/plugins/builtins.py +746 -0
- ksadk/plugins/bundle.py +246 -0
- ksadk/plugins/bundle_security.py +191 -0
- ksadk/plugins/codex_manifest.py +983 -0
- ksadk/plugins/composition.py +537 -0
- ksadk/plugins/context_contributor.py +437 -0
- ksadk/plugins/contracts.py +569 -0
- ksadk/plugins/delivery.py +153 -0
- ksadk/plugins/dsh_installation_digest.py +71 -0
- ksadk/plugins/dsh_toolchain.py +1024 -0
- ksadk/plugins/ecosystem_bridge.py +1105 -0
- ksadk/plugins/ecosystem_probe.py +191 -0
- ksadk/plugins/host.py +787 -0
- ksadk/plugins/kernel_adapter.py +205 -0
- ksadk/plugins/providers/__init__.py +108 -0
- ksadk/plugins/providers/bundles/dsh-knowledge/cordis.patch.yml +3 -0
- ksadk/plugins/providers/bundles/dsh-knowledge/index.mjs +53 -0
- ksadk/plugins/providers/bundles/dsh-knowledge/package.json +16 -0
- ksadk/plugins/providers/bundles/dsh-memory/cordis.patch.yml +3 -0
- ksadk/plugins/providers/bundles/dsh-memory/index.mjs +175 -0
- ksadk/plugins/providers/bundles/dsh-memory/package.json +16 -0
- ksadk/plugins/providers/bundles/dsh-platform-resources/client.mjs +166 -0
- ksadk/plugins/providers/bundles/dsh-platform-resources/cordis.patch.yml +3 -0
- ksadk/plugins/providers/bundles/dsh-platform-resources/index.mjs +9 -0
- ksadk/plugins/providers/bundles/dsh-platform-resources/package.json +12 -0
- ksadk/plugins/providers/bundles/dsh-skill-center/cordis.patch.yml +3 -0
- ksadk/plugins/providers/bundles/dsh-skill-center/index.mjs +125 -0
- ksadk/plugins/providers/bundles/dsh-skill-center/package.json +16 -0
- ksadk/plugins/providers/bundles/ksadk-codex/cordis.patch.yml +3 -0
- ksadk/plugins/providers/bundles/ksadk-codex/index.mjs +18 -0
- ksadk/plugins/providers/bundles/ksadk-codex/package.json +19 -0
- ksadk/plugins/providers/bundles/ksadk-dsh-capability-host/cordis.patch.yml +3 -0
- ksadk/plugins/providers/bundles/ksadk-dsh-capability-host/index.mjs +870 -0
- ksadk/plugins/providers/bundles/ksadk-dsh-capability-host/package.json +27 -0
- ksadk/plugins/providers/bundles/ksadk-dsh-studio/client.js +92 -0
- ksadk/plugins/providers/bundles/ksadk-dsh-studio/index.mjs +15 -0
- ksadk/plugins/providers/bundles/ksadk-dsh-studio/package.json +7 -0
- ksadk/plugins/providers/bundles/ksadk-harness/cordis.patch.yml +3 -0
- ksadk/plugins/providers/bundles/ksadk-harness/index.mjs +19 -0
- ksadk/plugins/providers/bundles/ksadk-harness/package.json +19 -0
- ksadk/plugins/providers/codex.py +988 -0
- ksadk/plugins/providers/codex_dsh.py +83 -0
- ksadk/plugins/providers/codex_native.py +368 -0
- ksadk/plugins/providers/codex_turn.py +301 -0
- ksadk/plugins/providers/dsh.py +951 -0
- ksadk/plugins/providers/dsh_capabilities.py +1389 -0
- ksadk/plugins/providers/dsh_descriptor_host.py +226 -0
- ksadk/plugins/providers/dsh_mcp.py +467 -0
- ksadk/plugins/providers/harness.py +632 -0
- ksadk/plugins/providers/harness_dsh.py +91 -0
- ksadk/plugins/providers/legacy.py +215 -0
- ksadk/plugins/providers/legacy_catalog.py +100 -0
- ksadk/plugins/providers/mcp_projection.py +150 -0
- ksadk/plugins/providers/platform_resources.py +657 -0
- ksadk/plugins/providers/shipped_dsh.py +370 -0
- ksadk/plugins/resolver.py +338 -0
- ksadk/plugins/subagent_providers/__init__.py +12 -0
- ksadk/plugins/subagent_providers/codex.py +443 -0
- ksadk/plugins/subagents.py +333 -0
- ksadk/resource_runtime/__init__.py +4 -0
- ksadk/resource_runtime/broker.py +616 -0
- ksadk/resource_runtime/build_artifacts.py +165 -0
- ksadk/resource_runtime/contracts.py +138 -0
- ksadk/resource_runtime/discovery_receipts.py +100 -0
- ksadk/resource_runtime/discovery_skills.py +172 -0
- ksadk/resource_runtime/errors.py +6 -0
- ksadk/resource_runtime/ipc.py +142 -0
- ksadk/resource_runtime/kernel_approval.py +165 -0
- ksadk/resource_runtime/knowledge.py +114 -0
- ksadk/resource_runtime/langgraph.py +94 -0
- ksadk/resource_runtime/leases.py +191 -0
- ksadk/resource_runtime/managed_projection.py +186 -0
- ksadk/resource_runtime/mcp_server.py +138 -0
- ksadk/resource_runtime/memory_provider.py +318 -0
- ksadk/resource_runtime/memory_receipts.py +34 -0
- ksadk/resource_runtime/operation_ledger.py +211 -0
- ksadk/resource_runtime/plugin_config.py +48 -0
- ksadk/resource_runtime/policy_authorization.py +54 -0
- ksadk/resource_runtime/process.py +110 -0
- ksadk/resource_runtime/skill_artifacts.py +153 -0
- ksadk/resource_runtime/skill_runtime.py +42 -0
- ksadk/resource_runtime/skill_workspace.py +118 -0
- ksadk/resource_runtime/skills.py +215 -0
- ksadk/resource_runtime/snapshots.py +180 -0
- ksadk/resource_runtime/socket_server.py +103 -0
- ksadk/resource_runtime/supervisor.py +380 -0
- ksadk/resource_runtime/worker.py +504 -0
- ksadk/runners/_langgraph_runner_streams.py +74 -6
- ksadk/runners/adk_runner.py +149 -11
- ksadk/runners/base_runner.py +29 -1
- ksadk/runners/langgraph_runner.py +475 -145
- ksadk/runtime/_runner_adapter/stream_mapping.py +193 -60
- ksadk/runtime/adapter.py +3 -0
- ksadk/runtime/conversation_execution.py +92 -16
- ksadk/runtime/executor.py +78 -2
- ksadk/runtime/factory.py +30 -200
- ksadk/runtime/framework_adapters.py +41 -0
- ksadk/runtime/preprocessing.py +10 -2
- ksadk/runtime/runner_adapter.py +78 -14
- ksadk/runtime_context.py +40 -2
- ksadk/sandbox/__init__.py +2 -1
- ksadk/sandbox/backends/e2b.py +52 -11
- ksadk/sandbox/backends/local_process.py +9 -0
- ksadk/sandbox/base.py +2 -0
- ksadk/sandbox/e2b_connection.py +66 -0
- ksadk/sandbox/factory.py +72 -0
- ksadk/scheduler/__init__.py +18 -0
- ksadk/scheduler/calendar.py +102 -0
- ksadk/scheduler/contracts.py +254 -0
- ksadk/scheduler/dispatcher.py +129 -0
- ksadk/scheduler/engine.py +416 -0
- ksadk/scheduler/sqlite_store.py +581 -0
- ksadk/server/composition.py +2 -0
- ksadk/server/factory.py +5 -0
- ksadk/server/persistence_capability.py +516 -0
- ksadk/server/routes/control.py +210 -46
- ksadk/server/routes/dependencies.py +15 -0
- ksadk/server/routes/models.py +47 -4
- ksadk/server/routes/projection.py +252 -12
- ksadk/server/routes/sessions.py +284 -107
- ksadk/server/routes/streaming.py +43 -9
- ksadk/server/static/assets/{ArtifactsPanel-DSU1sWD_.js → ArtifactsPanel-CGbWlMNh.js} +1 -1
- ksadk/server/static/assets/{CodeBlock-DOH6MVcn.js → CodeBlock-b4C7upmO.js} +3 -3
- ksadk/server/static/assets/{MathMessageMarkdown-BL8my1R2.js → MathMessageMarkdown-DbdW5A4_.js} +4 -4
- ksadk/server/static/assets/{MermaidBlock-Dz4IP-Tx.js → MermaidBlock-BEBN4Ksz.js} +6 -6
- ksadk/server/static/assets/{NativeTerminalPanel-DUrK0JpZ.js → NativeTerminalPanel-zvL-WpAn.js} +1 -1
- ksadk/server/static/assets/{abnfDiagram-VCTEODGH-g20pFzNV.js → abnfDiagram-VCTEODGH-BYafW7Za.js} +1 -1
- ksadk/server/static/assets/{arc-C4FzinUA.js → arc-bTohInsS.js} +1 -1
- ksadk/server/static/assets/architecture-7GRP2DOG-BW5UtSnx.js +1 -0
- ksadk/server/static/assets/{architectureDiagram-5GKGNRK7-DpIqL5h4.js → architectureDiagram-5GKGNRK7-Ch5Lbzsi.js} +1 -1
- ksadk/server/static/assets/{blockDiagram-NRAW4CY4-BjkljTNz.js → blockDiagram-NRAW4CY4-kqF4MDOG.js} +1 -1
- ksadk/server/static/assets/{c4Diagram-UCG6FXSJ-Dk_ieq2X.js → c4Diagram-UCG6FXSJ-8uSRIODv.js} +1 -1
- ksadk/server/static/assets/channel-CF5Up3hQ.js +1 -0
- ksadk/server/static/assets/chunk-2Q5K7J3B-KkXX47WI.js +1 -0
- ksadk/server/static/assets/{chunk-5VM5RSS4-BVHAchFb.js → chunk-5VM5RSS4-DkhehZDr.js} +1 -1
- ksadk/server/static/assets/{chunk-F27PBJKO-C-ipQzuS.js → chunk-F27PBJKO-BdXhtPe9.js} +1 -1
- ksadk/server/static/assets/{chunk-G27WJ6UU-C2EyJbIK.js → chunk-G27WJ6UU-DPTpvpwi.js} +1 -1
- ksadk/server/static/assets/{chunk-JWPE2WC7-vYvVJb_M.js → chunk-JWPE2WC7-Pqoh38el.js} +1 -1
- ksadk/server/static/assets/{chunk-LCL6LL3I-BcI6ysPT.js → chunk-LCL6LL3I-DeU00qC-.js} +1 -1
- ksadk/server/static/assets/{chunk-POPQ4Y6H-C030x_Z1.js → chunk-POPQ4Y6H-CzxScFkr.js} +1 -1
- ksadk/server/static/assets/{chunk-RHFEMEQ7-yyGpsz4n.js → chunk-RHFEMEQ7-DpqMx-ux.js} +1 -1
- ksadk/server/static/assets/{chunk-SVP7TREG-BLTlmMU7.js → chunk-SVP7TREG-C6t0SypQ.js} +1 -1
- ksadk/server/static/assets/{chunk-XXDRQBXY-C_32ArgP.js → chunk-XXDRQBXY-DVaeafZk.js} +1 -1
- ksadk/server/static/assets/classDiagram-DTDB5LWJ-Cz81acRQ.js +1 -0
- ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-Cz81acRQ.js +1 -0
- ksadk/server/static/assets/{cose-bilkent-JH36ORCC-9YQYwdl0.js → cose-bilkent-JH36ORCC-Bf9D3tzJ.js} +1 -1
- ksadk/server/static/assets/cynefin-OW5HDTMX-DVWs8a2t.js +1 -0
- ksadk/server/static/assets/{cynefinDiagram-5FMLGOSQ-ErLF5N13.js → cynefinDiagram-5FMLGOSQ-B9cY3iTz.js} +1 -1
- ksadk/server/static/assets/{dagre-3AP2YEHR-DFiQF-6f.js → dagre-3AP2YEHR-CSwlx3CB.js} +1 -1
- ksadk/server/static/assets/{dagre-BuhGnRI1.js → dagre-UBpgon5q.js} +1 -1
- ksadk/server/static/assets/{diagram-S7CK7UJ4-Bt1v8-GC.js → diagram-S7CK7UJ4-C9akhN9a.js} +1 -1
- ksadk/server/static/assets/{diagram-UQ7AKVKN-DSCxJdBK.js → diagram-UQ7AKVKN-CgedhTPI.js} +1 -1
- ksadk/server/static/assets/{diagram-VSXAHHWV-DHfYwp_9.js → diagram-VSXAHHWV-Cjucz5BY.js} +1 -1
- ksadk/server/static/assets/{diagram-VX7I27RA-DdzD-4Le.js → diagram-VX7I27RA-Dd4Vleyn.js} +1 -1
- ksadk/server/static/assets/{diagram-Z3DM3KII-Du-nAJ9F.js → diagram-Z3DM3KII-CZ2jGtYW.js} +1 -1
- ksadk/server/static/assets/{dist-B7seoj3d.js → dist-B2_CVgKv.js} +1 -1
- ksadk/server/static/assets/{dist-CSh_DE14.js → dist-B3FR1SKK.js} +1 -1
- ksadk/server/static/assets/{dist-DUX-id_F.js → dist-BIr4DSRq.js} +1 -1
- ksadk/server/static/assets/{dist-C_wsv-Qd.js → dist-BgV_owcB.js} +1 -1
- ksadk/server/static/assets/{dist-W-TIVntx.js → dist-Bj730Ib4.js} +1 -1
- ksadk/server/static/assets/{dist-BytlxIDT.js → dist-BnaTiyzN.js} +1 -1
- ksadk/server/static/assets/{dist-CXYYBw3_.js → dist-C1NMAY5a.js} +1 -1
- ksadk/server/static/assets/{dist-dDdADKFA.js → dist-C5_ZAZsG.js} +1 -1
- ksadk/server/static/assets/{dist-BVDffZ0U.js → dist-CB9iJrvg.js} +1 -1
- ksadk/server/static/assets/{dist-Bf2M8m3N.js → dist-CFzsn6BG.js} +1 -1
- ksadk/server/static/assets/{dist-ngtN0DJB.js → dist-Cf125P_m.js} +1 -1
- ksadk/server/static/assets/{dist-BE7bu-DL.js → dist-ClYUxfeK.js} +1 -1
- ksadk/server/static/assets/{dist-DNp6rLRA.js → dist-DFD6Qa6T.js} +1 -1
- ksadk/server/static/assets/{dist-BX8z72IC.js → dist-DVCOWtha.js} +1 -1
- ksadk/server/static/assets/{dist-dydu68Fl.js → dist-D_ctSS2i.js} +1 -1
- ksadk/server/static/assets/{dist-ClxGviKw.js → dist-DiixqL0J.js} +1 -1
- ksadk/server/static/assets/{dist-BjU6y-A2.js → dist-DoVSwoDb.js} +1 -1
- ksadk/server/static/assets/{dist-Dq9gLD7L.js → dist-DvFK7p5S.js} +1 -1
- ksadk/server/static/assets/{dist-8hqcx0sU.js → dist-QfkEHOlb.js} +1 -1
- ksadk/server/static/assets/{dist-CttYUqzS.js → dist-btbmmX5O.js} +1 -1
- ksadk/server/static/assets/{dist-DmldrHd_.js → dist-fBO2v5Kt.js} +1 -1
- ksadk/server/static/assets/{dist-DnfXs8Vn.js → dist-ufY3F5p6.js} +1 -1
- ksadk/server/static/assets/{ebnfDiagram-PWID7BFC-Da9C9NO1.js → ebnfDiagram-PWID7BFC-Ci8NqqZu.js} +1 -1
- ksadk/server/static/assets/{erDiagram-SSCWMZ5O-EAGqqR79.js → erDiagram-SSCWMZ5O-CCIOhLZG.js} +1 -1
- ksadk/server/static/assets/eventmodeling-NTZA5JFV-CQqR2hg3.js +1 -0
- ksadk/server/static/assets/flowDiagram-A5DVABFB-DDRRbGPm.js +1 -0
- ksadk/server/static/assets/{ganttDiagram-EL5Y4UJY-DqJsKb59.js → ganttDiagram-EL5Y4UJY-Cp_r9Hb6.js} +1 -1
- ksadk/server/static/assets/gitGraph-4MIJSDKK-fgWEf7UD.js +1 -0
- ksadk/server/static/assets/{gitGraphDiagram-WWUBYQGX-B6g4dtDi.js → gitGraphDiagram-WWUBYQGX-Dlhc8Wr8.js} +1 -1
- ksadk/server/static/assets/index-DcTML1Up.css +2 -0
- ksadk/server/static/assets/index-Dh2XHqPK.js +244 -0
- ksadk/server/static/assets/info-A6RAGUB7-BUecLTdt.js +1 -0
- ksadk/server/static/assets/{infoDiagram-RXCK75RN-Djm_nbd5.js → infoDiagram-RXCK75RN-CO0rRTRA.js} +1 -1
- ksadk/server/static/assets/{ishikawaDiagram-5VMMS53U-DWya9SG2.js → ishikawaDiagram-5VMMS53U-CHiaedSS.js} +1 -1
- ksadk/server/static/assets/{journeyDiagram-EYS64GPL-DutxhSNI.js → journeyDiagram-EYS64GPL-CHcCIB09.js} +1 -1
- ksadk/server/static/assets/{kanban-definition-3QL26DDD-DJdOF8Fm.js → kanban-definition-3QL26DDD-CJ_ebBZf.js} +1 -1
- ksadk/server/static/assets/{katex-vFWytM5c.js → katex-B4weu383.js} +1 -1
- ksadk/server/static/assets/{linear-BHjG8b-J.js → linear-V-MgYHW1.js} +1 -1
- ksadk/server/static/assets/{mermaid-parser.core-KGSy4jWT.js → mermaid-parser.core-CBijEX_c.js} +2 -2
- ksadk/server/static/assets/{mindmap-definition-FBJOCRG2-9-HC88D4.js → mindmap-definition-FBJOCRG2-Bc-pQvpp.js} +1 -1
- ksadk/server/static/assets/packet-AYTQ26CC-BeW-btFv.js +1 -0
- ksadk/server/static/assets/{pegDiagram-XKGWAZYB-DrEZd4fD.js → pegDiagram-XKGWAZYB-D7genGLl.js} +1 -1
- ksadk/server/static/assets/pie-WAS4IAKB-X0xh4SaT.js +1 -0
- ksadk/server/static/assets/{pieDiagram-E7YTZNPT-DpjqOFFp.js → pieDiagram-E7YTZNPT-Bxj32zwD.js} +1 -1
- ksadk/server/static/assets/{quadrantDiagram-AXDQQJYC-BiNhgOXX.js → quadrantDiagram-AXDQQJYC-BURv2mGh.js} +1 -1
- ksadk/server/static/assets/radar-RG4KPBEZ-DzRMSqjd.js +1 -0
- ksadk/server/static/assets/railroad-74A4TZTK-Cc44icX-.js +1 -0
- ksadk/server/static/assets/railroad-abnf-HS5TGJTU-D6S4BdV-.js +1 -0
- ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-vD3aVE2o.js +1 -0
- ksadk/server/static/assets/railroad-peg-WCYAUIDC-CYbW_b4T.js +1 -0
- ksadk/server/static/assets/{railroadDiagram-O6MQD6OU-_Y3Ojg6G.js → railroadDiagram-O6MQD6OU-CCsh3avW.js} +1 -1
- ksadk/server/static/assets/{requirementDiagram-EFPCY7ZU-DeCFdg9K.js → requirementDiagram-EFPCY7ZU-_FRRBKEd.js} +1 -1
- ksadk/server/static/assets/{sankeyDiagram-P5KCCOFB-CPH75rhw.js → sankeyDiagram-P5KCCOFB-C-gr2o9M.js} +1 -1
- ksadk/server/static/assets/{sequenceDiagram-WJ2MYXX4-OEpQQdr4.js → sequenceDiagram-WJ2MYXX4-D97NmfKg.js} +1 -1
- ksadk/server/static/assets/{sizeCapture-X5ZJPWSS-heUErzhI.js → sizeCapture-X5ZJPWSS-DjrPC5FX.js} +1 -1
- ksadk/server/static/assets/{stateDiagram-HBIQ2CUA-DvA3jSMB.js → stateDiagram-HBIQ2CUA-DzMNg1hh.js} +1 -1
- ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-BIcjKFhF.js +1 -0
- ksadk/server/static/assets/{swimlanes-XN3QIQJK-CR-dfN_t.js → swimlanes-XN3QIQJK-Cssf_CsU.js} +1 -1
- ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-tq3K3Ybl.js +8 -0
- ksadk/server/static/assets/{timeline-definition-24CTP7MA-DAVJf1TX.js → timeline-definition-24CTP7MA-BWTHzyS1.js} +1 -1
- ksadk/server/static/assets/treeView-Q6P3EWNA-DBXt3GdU.js +1 -0
- ksadk/server/static/assets/treemap-WGGIJYW6-DrCy4E_l.js +1 -0
- ksadk/server/static/assets/{vennDiagram-4TSXK5OY-DwM8eDkh.js → vennDiagram-4TSXK5OY-BSKgJsmR.js} +1 -1
- ksadk/server/static/assets/wardley-WFR3VGLG-CefhOliM.js +1 -0
- ksadk/server/static/assets/{wardleyDiagram-VM6X3IG4-DZL-Zz2t.js → wardleyDiagram-VM6X3IG4-eflHNoaZ.js} +1 -1
- ksadk/server/static/assets/{xychartDiagram-S5SC5T6Z-Dy6Yh_hu.js → xychartDiagram-S5SC5T6Z-eYqrQ-v4.js} +1 -1
- ksadk/server/static/index.html +2 -2
- ksadk/session_context.py +66 -0
- ksadk/sessions/__init__.py +11 -21
- ksadk/sessions/_local_service_sync.py +263 -1
- ksadk/sessions/base.py +176 -0
- ksadk/sessions/errors.py +4 -0
- ksadk/sessions/in_memory.py +309 -19
- ksadk/sessions/local_service.py +83 -1
- ksadk/sessions/persistence.py +275 -0
- ksadk/sessions/postgres_service.py +358 -0
- ksadk/sessions/resilience.py +8 -0
- ksadk/sessions/resilient.py +362 -4
- ksadk/sessions/topology.py +135 -0
- ksadk/skills/models.py +26 -4
- ksadk/skills/package_store.py +186 -38
- ksadk/skills/runtime/agent.py +31 -6
- ksadk/skills/runtime/artifact_delivery.py +139 -0
- ksadk/skills/runtime/backends/e2b.py +98 -6
- ksadk/skills/runtime/backends/local.py +73 -8
- ksadk/skills/runtime/base.py +3 -0
- ksadk/skills/runtime/executor.py +2 -0
- ksadk/skills/runtime/loader.py +10 -2
- ksadk/skills/runtime/pinned.py +114 -0
- ksadk/skills/runtime/request.py +31 -0
- ksadk/skills/service_client.py +211 -24
- ksadk/studio/agent_lifecycle.py +26 -20
- ksadk/studio/api.py +714 -90
- ksadk/studio/api_catalog_routes.py +23 -0
- ksadk/studio/api_contracts.py +34 -1
- ksadk/studio/api_plugin_routes.py +911 -0
- ksadk/studio/api_resource_connections.py +183 -0
- ksadk/studio/attachment_store.py +187 -0
- ksadk/studio/authoring.py +10 -4
- ksadk/studio/authoring_coordinator.py +31 -16
- ksadk/studio/builder.py +199 -43
- ksadk/studio/cloud.py +346 -104
- ksadk/studio/cloud_shared_web.py +565 -0
- ksadk/studio/codex_agent_service.py +140 -27
- ksadk/studio/codex_builder.py +294 -16
- ksadk/studio/codex_credentials.py +90 -0
- ksadk/studio/codex_manifest.py +51 -4
- ksadk/studio/codex_plugin_store.py +746 -0
- ksadk/studio/codex_provider_build.py +231 -0
- ksadk/studio/codex_run.py +200 -29
- ksadk/studio/compatibility_report.py +456 -0
- ksadk/studio/compiler.py +84 -15
- ksadk/studio/contracts.py +249 -4
- ksadk/studio/dsh_application.py +137 -0
- ksadk/studio/dsh_capability_service.py +1107 -0
- ksadk/studio/dsh_models.py +59 -0
- ksadk/studio/dsh_provider_registration.py +1075 -0
- ksadk/studio/event_store.py +54 -6
- ksadk/studio/framework_run.py +37 -4
- ksadk/studio/hosted_kernel.py +89 -14
- ksadk/studio/mcp_runtime.py +11 -3
- ksadk/studio/model_client.py +2 -2
- ksadk/studio/operations.py +12 -2
- ksadk/studio/plugin_composition.py +468 -0
- ksadk/studio/plugin_kernel_adapter.py +28 -0
- ksadk/studio/plugin_runtime.py +831 -0
- ksadk/studio/resource_authority.py +637 -0
- ksadk/studio/resource_binding_validation.py +77 -0
- ksadk/studio/resource_build_admission.py +196 -0
- ksadk/studio/resource_build_materializer.py +149 -0
- ksadk/studio/resource_catalog.py +149 -3
- ksadk/studio/resource_connections.py +220 -0
- ksadk/studio/run_service.py +1144 -96
- ksadk/studio/runtime_source.py +24 -8
- ksadk/studio/scheduler_assistant.py +317 -0
- ksadk/studio/scheduler_runtime.py +383 -0
- ksadk/studio/scheduler_service.py +214 -0
- ksadk/studio/service.py +1131 -95
- ksadk/studio/shared_web.py +610 -87
- ksadk/studio/soul.py +52 -0
- ksadk/studio/static/assets/CodeBlock-DCUUY0PL-BLjA7kbS.js +41 -0
- ksadk/studio/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- ksadk/studio/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- ksadk/studio/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- ksadk/studio/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- ksadk/studio/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- ksadk/studio/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- ksadk/studio/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- ksadk/studio/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- ksadk/studio/static/assets/MathMessageMarkdown-CBcDrAw--BEOyPC3w.css +1 -0
- ksadk/studio/static/assets/MathMessageMarkdown-CBcDrAw--CUYIXwgI.js +8 -0
- ksadk/studio/static/assets/MermaidBlock-DBFTztfQ-BTYKWEbD.js +44 -0
- ksadk/studio/static/assets/PrismRenderer-wiXRHURw.js +3 -0
- ksadk/studio/static/assets/abnfDiagram-VCTEODGH-CLETGjKq.js +1 -0
- ksadk/studio/static/assets/arc-Pry-7G1_.js +1 -0
- ksadk/studio/static/assets/architecture-7GRP2DOG-hXMiO_AU.js +1 -0
- ksadk/studio/static/assets/architectureDiagram-5GKGNRK7-B5EQysk6.js +36 -0
- ksadk/studio/static/assets/array-BifhSqXX.js +1 -0
- ksadk/studio/static/assets/blockDiagram-I7D4REHJ-CFmPl1de.js +129 -0
- ksadk/studio/static/assets/c4Diagram-7LVT6UL2-BRrGu8qt.js +38 -0
- ksadk/studio/static/assets/channel-BqO-gtEw.js +1 -0
- ksadk/studio/static/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
- ksadk/studio/static/assets/chunk-4HAMMTFA-D220vUtq.js +62 -0
- ksadk/studio/static/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
- ksadk/studio/static/assets/chunk-75Z2AOVW-C8lLv_qc.js +2 -0
- ksadk/studio/static/assets/chunk-DU6HZSFF-C4DtVpCu.js +128 -0
- ksadk/studio/static/assets/chunk-F27PBJKO-Cpw14SNG.js +1 -0
- ksadk/studio/static/assets/chunk-FOHPRMQF-DHwB1DNv.js +161 -0
- ksadk/studio/static/assets/chunk-GMAD6QVW-DiQA-u2N.js +72 -0
- ksadk/studio/static/assets/chunk-GVQU2GXP-DUdNBUCi.js +1 -0
- ksadk/studio/static/assets/chunk-IMKFNOWR-BSlbjT_b.js +231 -0
- ksadk/studio/static/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
- ksadk/studio/static/assets/chunk-L3NEJ4N5-Db8Ab22W.js +1 -0
- ksadk/studio/static/assets/chunk-OSK3NFVY-M2m6G3j4.js +10 -0
- ksadk/studio/static/assets/chunk-P2QGCYS3-DezaQxiK.js +1 -0
- ksadk/studio/static/assets/chunk-POPQ4Y6H-DOpufJ3t.js +1 -0
- ksadk/studio/static/assets/chunk-PWAF6VOD-CfLb1gSc.js +1 -0
- ksadk/studio/static/assets/chunk-SHT3W25Y-DAyIVp5H.js +168 -0
- ksadk/studio/static/assets/chunk-SVP7TREG-DulomOrS.js +88 -0
- ksadk/studio/static/assets/chunk-TICWLB2K-bHJYoflj.js +206 -0
- ksadk/studio/static/assets/chunk-XXDRQBXY-7PcdR2B1.js +1 -0
- ksadk/studio/static/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
- ksadk/studio/static/assets/classDiagram-ZZMXUADV-D_bW8JjA.js +1 -0
- ksadk/studio/static/assets/classDiagram-v2-VYDZK3BY-D_bW8JjA.js +1 -0
- ksadk/studio/static/assets/cose-bilkent-JH36ORCC-snL88wkX.js +1 -0
- ksadk/studio/static/assets/cynefin-OW5HDTMX-Bd1YhRo1.js +1 -0
- ksadk/studio/static/assets/cynefinDiagram-5FMLGOSQ-BBrIG_mI.js +62 -0
- ksadk/studio/static/assets/cytoscape.esm-CGd-uY3x.js +321 -0
- ksadk/studio/static/assets/dagre-GXQ25YYZ-DtF1nGdY.js +4 -0
- ksadk/studio/static/assets/dagre-PrKaheQc.js +1 -0
- ksadk/studio/static/assets/defaultLocale-BFoDCU3G.js +1 -0
- ksadk/studio/static/assets/diagram-S7CK7UJ4-0BZ98mya.js +30 -0
- ksadk/studio/static/assets/diagram-UQ7AKVKN-6mLKEo6L.js +41 -0
- ksadk/studio/static/assets/diagram-VSXAHHWV-CJBIaiZ2.js +3 -0
- ksadk/studio/static/assets/diagram-VX7I27RA-BohLEE1C.js +24 -0
- ksadk/studio/static/assets/diagram-Z3DM3KII-D8KIGonG.js +24 -0
- ksadk/studio/static/assets/dist-v5Q1xZ2K.js +1 -0
- ksadk/studio/static/assets/ebnfDiagram-PWID7BFC-C99HU61t.js +1 -0
- ksadk/studio/static/assets/erDiagram-RLTQ6QDP-DLGry2Ap.js +99 -0
- ksadk/studio/static/assets/eventmodeling-NTZA5JFV-B1_5Ac8j.js +1 -0
- ksadk/studio/static/assets/flowDiagram-HODETNUW-DD5hmicn.js +1 -0
- ksadk/studio/static/assets/ganttDiagram-EL5Y4UJY-BPJrVLSG.js +292 -0
- ksadk/studio/static/assets/gitGraph-4MIJSDKK-Cy_ZQBGi.js +1 -0
- ksadk/studio/static/assets/gitGraphDiagram-WWUBYQGX-CZCUz4MT.js +106 -0
- ksadk/studio/static/assets/graphlib-DS17s2tU.js +1 -0
- ksadk/studio/static/assets/index-CeHL9ARV.css +2 -0
- ksadk/studio/static/assets/index-D9QEcVpL.js +320 -0
- ksadk/studio/static/assets/info-A6RAGUB7-DBzDQB_I.js +1 -0
- ksadk/studio/static/assets/infoDiagram-27XIBGKW-B-sq07Hi.js +2 -0
- ksadk/studio/static/assets/init-C-OQMol4.js +1 -0
- ksadk/studio/static/assets/ishikawaDiagram-5VMMS53U-CljI2wyf.js +70 -0
- ksadk/studio/static/assets/journeyDiagram-3NMN7TZE-D50Fo2sL.js +139 -0
- ksadk/studio/static/assets/kanban-definition-UXKFOSKX-DimfOTam.js +89 -0
- ksadk/studio/static/assets/katex-DhON-x74.js +257 -0
- ksadk/studio/static/assets/line-CX5BOOUP.js +1 -0
- ksadk/studio/static/assets/linear-BCxN9JLv.js +1 -0
- ksadk/studio/static/assets/mermaid-parser.core-BdCz8fkS.js +7 -0
- ksadk/studio/static/assets/mindmap-definition-YA3MSWOX-Bizzqy5R.js +96 -0
- ksadk/studio/static/assets/ordinal-BDEzSJ7C.js +1 -0
- ksadk/studio/static/assets/packet-AYTQ26CC-gPln-_kG.js +1 -0
- ksadk/studio/static/assets/path-fybaL0A-.js +1 -0
- ksadk/studio/static/assets/pegDiagram-XKGWAZYB-Dy3fB-gW.js +1 -0
- ksadk/studio/static/assets/pie-WAS4IAKB-qZdHMr7B.js +1 -0
- ksadk/studio/static/assets/pieDiagram-E7YTZNPT-B9mrFSDF.js +39 -0
- ksadk/studio/static/assets/quadrantDiagram-AXDQQJYC-NzUfCbMR.js +7 -0
- ksadk/studio/static/assets/radar-RG4KPBEZ-BZlnaea9.js +1 -0
- ksadk/studio/static/assets/railroad-74A4TZTK-Ce3__H9c.js +1 -0
- ksadk/studio/static/assets/railroad-abnf-HS5TGJTU-DqQn7EzD.js +1 -0
- ksadk/studio/static/assets/railroad-ebnf-LZEXJU2U-B55kCA8F.js +1 -0
- ksadk/studio/static/assets/railroad-peg-WCYAUIDC-DfQnvkHd.js +1 -0
- ksadk/studio/static/assets/railroadDiagram-O6MQD6OU-DnhMjZCk.js +1 -0
- ksadk/studio/static/assets/requirementDiagram-BXWQKSXE-BF3d103U.js +84 -0
- ksadk/studio/static/assets/rolldown-runtime-Dy4uBu1J-DK3Fl9T5.js +1 -0
- ksadk/studio/static/assets/rough.esm-Dy-Kn_BL.js +1 -0
- ksadk/studio/static/assets/sankeyDiagram-P5KCCOFB-Bo-JTwt0.js +40 -0
- ksadk/studio/static/assets/sequenceDiagram-WJ2MYXX4-Dh4wZtUm.js +162 -0
- ksadk/studio/static/assets/sizeCapture-INFHLROL-B0uUizjq.js +1 -0
- ksadk/studio/static/assets/src-SFn9St9H.js +1 -0
- ksadk/studio/static/assets/stateDiagram-D77RDMKH-DH774G6d.js +1 -0
- ksadk/studio/static/assets/stateDiagram-v2-MP3YSRHH-DZvVWPBo.js +1 -0
- ksadk/studio/static/assets/swimlanes-42K2YHIH-Bl13OvTX.js +1 -0
- ksadk/studio/static/assets/swimlanesDiagram-VR7AAH4N-BnFOTALJ.js +8 -0
- ksadk/studio/static/assets/timeline-definition-24CTP7MA-DxmSSjRB.js +120 -0
- ksadk/studio/static/assets/treeView-Q6P3EWNA-D5Nn9Swz.js +1 -0
- ksadk/studio/static/assets/treemap-WGGIJYW6-CgHgnQhE.js +1 -0
- ksadk/studio/static/assets/vennDiagram-4TSXK5OY-B9QEXcJq.js +34 -0
- ksadk/studio/static/assets/wardley-WFR3VGLG-DXrK2RRY.js +1 -0
- ksadk/studio/static/assets/wardleyDiagram-VM6X3IG4-Ba1AOWoe.js +78 -0
- ksadk/studio/static/assets/xychartDiagram-S5SC5T6Z-Cr5pt5Y-.js +7 -0
- ksadk/studio/static/index.html +2 -2
- ksadk/studio/validator.py +1 -1
- ksadk/studio/workspace.py +1 -0
- ksadk/version.py +1 -1
- ksadk_runtime_common/workspace_files/path_utils.py +41 -0
- agentengine_sdk_python-0.8.2.dist-info/RECORD +0 -778
- ksadk/server/static/assets/architecture-7GRP2DOG-DjKratdf.js +0 -1
- ksadk/server/static/assets/channel-4cQHKtx1.js +0 -1
- ksadk/server/static/assets/chunk-2Q5K7J3B-DmgWkESh.js +0 -1
- ksadk/server/static/assets/classDiagram-DTDB5LWJ-DLFd9Xi0.js +0 -1
- ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-DLFd9Xi0.js +0 -1
- ksadk/server/static/assets/cynefin-OW5HDTMX-DjEM48Qp.js +0 -1
- ksadk/server/static/assets/eventmodeling-NTZA5JFV-CMgMaJrC.js +0 -1
- ksadk/server/static/assets/flowDiagram-A5DVABFB-BBKL0x3P.js +0 -1
- ksadk/server/static/assets/gitGraph-4MIJSDKK-Dw63mrhw.js +0 -1
- ksadk/server/static/assets/index-8ipRcQ-M.js +0 -240
- ksadk/server/static/assets/index-ByFCqjlh.css +0 -2
- ksadk/server/static/assets/info-A6RAGUB7-B6iAblII.js +0 -1
- ksadk/server/static/assets/packet-AYTQ26CC-BOYAipuq.js +0 -1
- ksadk/server/static/assets/pie-WAS4IAKB-Ctq0Kbku.js +0 -1
- ksadk/server/static/assets/radar-RG4KPBEZ-DN0-ul_0.js +0 -1
- ksadk/server/static/assets/railroad-74A4TZTK-C6cC_to0.js +0 -1
- ksadk/server/static/assets/railroad-abnf-HS5TGJTU-BimjIuRc.js +0 -1
- ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-CvY65ABq.js +0 -1
- ksadk/server/static/assets/railroad-peg-WCYAUIDC-D72Iq_Tv.js +0 -1
- ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-BgQY03nz.js +0 -1
- ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-DLVw3q5Q.js +0 -8
- ksadk/server/static/assets/treeView-Q6P3EWNA-BMpO0wsB.js +0 -1
- ksadk/server/static/assets/treemap-WGGIJYW6-Et0aqzU3.js +0 -1
- ksadk/server/static/assets/wardley-WFR3VGLG-CbY0mhpl.js +0 -1
- ksadk/studio/static/assets/PrismRenderer-IYN-ffww.js +0 -3
- ksadk/studio/static/assets/index-BLpcdrgW.css +0 -1
- ksadk/studio/static/assets/index-CYekR2Xv.js +0 -260
- {agentengine_sdk_python-0.8.2.dist-info → agentengine_sdk_python-0.8.4.dist-info}/WHEEL +0 -0
- {agentengine_sdk_python-0.8.2.dist-info → agentengine_sdk_python-0.8.4.dist-info}/entry_points.txt +0 -0
- {agentengine_sdk_python-0.8.2.dist-info → agentengine_sdk_python-0.8.4.dist-info}/licenses/LICENSE +0 -0
- {agentengine_sdk_python-0.8.2.dist-info → agentengine_sdk_python-0.8.4.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./MathMessageMarkdown-DbdW5A4_.js","./CodeBlock-b4C7upmO.js","./MermaidBlock-BEBN4Ksz.js","./katex-B4weu383.js","./MathMessageMarkdown-BorAY7qD.css","./NativeTerminalPanel-zvL-WpAn.js","./NativeTerminalPanel-CHOd7Rch.css","./dist-ClYUxfeK.js","./dist-BgV_owcB.js","./dist-fBO2v5Kt.js","./dist-B2_CVgKv.js","./dist-B3FR1SKK.js","./dist-DoVSwoDb.js","./dist-ufY3F5p6.js","./dist-QfkEHOlb.js","./dist-DVCOWtha.js","./dist-CB9iJrvg.js","./dist-DFD6Qa6T.js","./dist-Cf125P_m.js","./dist-btbmmX5O.js","./dist-C1NMAY5a.js","./dist-C5_ZAZsG.js","./dist-BIr4DSRq.js","./dist-D_ctSS2i.js","./dist-DiixqL0J.js","./dist-CFzsn6BG.js","./dist-Bj730Ib4.js","./dockerfile-BLkNEvjs.js","./simple-mode-DRpGK0lJ.js","./factor-D7LVTn2l.js","./nsis-AQ_alPln.js","./pug-Bugr-47h.js","./javascript-9Tg8ixDm.js","./dist-DvFK7p5S.js","./dist-BnaTiyzN.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,T());else{var t=n(l);t!==null&&ae(x,t.startTime-e)}}var S=!1,ee=-1,C=5,w=-1;function te(){return g?!0:!(e.unstable_now()-w<C)}function ne(){if(g=!1,S){var t=e.unstable_now();w=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(ee),ee=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&te());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ae(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?T():S=!1}}}var T;if(typeof y==`function`)T=function(){y(ne)};else if(typeof MessageChannel<`u`){var re=new MessageChannel,ie=re.port2;re.port1.onmessage=ne,T=function(){ie.postMessage(null)}}else T=function(){_(ne,0)};function ae(t,n){ee=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):C=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(ee),ee=-1):h=!0,ae(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,T()))),r},e.unstable_shouldYield=te,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function ee(){}var C={H:null,A:null,T:null,S:null},w=Object.prototype.hasOwnProperty;function te(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function ne(e,t){return te(e.type,t,e.props)}function T(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function re(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ie=/\/+/g;function ae(e,t){return typeof e==`object`&&e&&e.key!=null?re(``+e.key):t.toString(36)}function oe(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(ee,ee):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function se(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,se(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ae(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(ie,`$&/`)+`/`),se(o,r,i,``,function(e){return e})):o!=null&&(T(o)&&(o=ne(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ie,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ae(a,u),c+=se(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ae(a,u++),c+=se(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return se(oe(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ce(e,t,n){if(e==null)return e;var r=[],i=0;return se(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function le(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var E=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},D={map:ce,forEach:function(e,t,n){ce(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ce(e,function(){t++}),t},toArray:function(e){return ce(e,function(e){return e})||[]},only:function(e){if(!T(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=D,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return C.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!w.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return te(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)w.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return te(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=T,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:le}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=C.T,n={};C.T=n;try{var r=e(),i=C.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(ee,E)}catch(e){E(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),C.T=t}},e.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},e.use=function(e){return C.H.use(e)},e.useActionState=function(e,t,n){return C.H.useActionState(e,t,n)},e.useCallback=function(e,t){return C.H.useCallback(e,t)},e.useContext=function(e){return C.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return C.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return C.H.useEffect(e,t)},e.useEffectEvent=function(e){return C.H.useEffectEvent(e)},e.useId=function(){return C.H.useId()},e.useImperativeHandle=function(e,t,n){return C.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return C.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return C.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return C.H.useMemo(e,t)},e.useOptimistic=function(e,t){return C.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return C.H.useReducer(e,t,n)},e.useRef=function(e){return C.H.useRef(e)},e.useState=function(e){return C.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return C.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return C.H.useTransition()},e.version=`19.2.4`})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=p();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.4`})),h=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=d(),n=p(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),ee=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),te=Symbol.for(`react.suspense_list`),ne=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),re=Symbol.for(`react.activity`),ie=Symbol.for(`react.memo_cache_sentinel`),ae=Symbol.iterator;function oe(e){return typeof e!=`object`||!e?null:(e=ae&&e[ae]||e[`@@iterator`],typeof e==`function`?e:null)}var se=Symbol.for(`react.client.reference`);function ce(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===se?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case w:return`Suspense`;case te:return`SuspenseList`;case re:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case ee:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ne:return t=e.displayName||null,t===null?ce(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return ce(e(t))}catch{}}return null}var le=Array.isArray,E=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue={pending:!1,data:null,method:null,action:null},de=[],fe=-1;function pe(e){return{current:e}}function me(e){0>fe||(e.current=de[fe],de[fe]=null,fe--)}function O(e,t){fe++,de[fe]=e.current,e.current=t}var he=pe(null),ge=pe(null),_e=pe(null),ve=pe(null);function ye(e,t){switch(O(_e,t),O(ge,e),O(he,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?sf(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=sf(t),e=cf(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}me(he),O(he,e)}function be(){me(he),me(ge),me(_e)}function xe(e){e.memoizedState!==null&&O(ve,e);var t=he.current,n=cf(t,e.type);t!==n&&(O(ge,e),O(he,n))}function Se(e){ge.current===e&&(me(he),me(ge)),ve.current===e&&(me(ve),gp._currentValue=ue)}var Ce,we;function Te(e){if(Ce===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ce=t&&t[1]||``,we=-1<e.stack.indexOf(`
|
|
3
|
+
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
|
+
`+Ce+e+we}var Ee=!1;function De(e,t){if(!e||Ee)return``;Ee=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
5
|
+
`),l=s.split(`
|
|
6
|
+
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
|
7
|
+
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Ee=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Te(n):``}function Oe(e,t){switch(e.tag){case 26:case 27:case 5:return Te(e.type);case 16:return Te(`Lazy`);case 13:return e.child!==t&&t!==null?Te(`Suspense Fallback`):Te(`Suspense`);case 19:return Te(`SuspenseList`);case 0:case 15:return De(e.type,!1);case 11:return De(e.type.render,!1);case 1:return De(e.type,!0);case 31:return Te(`Activity`);default:return``}}function ke(e){try{var t=``,n=null;do t+=Oe(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
8
|
+
Error generating stack: `+e.message+`
|
|
9
|
+
`+e.stack}}var Ae=Object.prototype.hasOwnProperty,je=t.unstable_scheduleCallback,Me=t.unstable_cancelCallback,Ne=t.unstable_shouldYield,Pe=t.unstable_requestPaint,Fe=t.unstable_now,Ie=t.unstable_getCurrentPriorityLevel,Le=t.unstable_ImmediatePriority,Re=t.unstable_UserBlockingPriority,ze=t.unstable_NormalPriority,Be=t.unstable_LowPriority,Ve=t.unstable_IdlePriority,He=t.log,Ue=t.unstable_setDisableYieldValue,We=null,Ge=null;function Ke(e){if(typeof He==`function`&&Ue(e),Ge&&typeof Ge.setStrictMode==`function`)try{Ge.setStrictMode(We,e)}catch{}}var qe=Math.clz32?Math.clz32:Xe,Je=Math.log,Ye=Math.LN2;function Xe(e){return e>>>=0,e===0?32:31-(Je(e)/Ye|0)|0}var Ze=256,Qe=262144,$e=4194304;function et(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function tt(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=et(n))):i=et(o):i=et(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=et(n))):i=et(o)):i=et(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function nt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function k(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function rt(){var e=$e;return $e<<=1,!($e&62914560)&&($e=4194304),e}function it(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function at(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ot(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-qe(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&st(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function st(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-qe(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function ct(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-qe(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function lt(e,t){var n=t&-t;return n=n&42?1:ut(n),(n&(e.suspendedLanes|t))===0?n:0}function ut(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function dt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function ft(){var e=D.p;return e===0?(e=window.event,e===void 0?32:Mp(e.type)):e}function pt(e,t){var n=D.p;try{return D.p=e,t()}finally{D.p=n}}var mt=Math.random().toString(36).slice(2),ht=`__reactFiber$`+mt,gt=`__reactProps$`+mt,_t=`__reactContainer$`+mt,vt=`__reactEvents$`+mt,yt=`__reactListeners$`+mt,bt=`__reactHandles$`+mt,xt=`__reactResources$`+mt,St=`__reactMarker$`+mt;function Ct(e){delete e[ht],delete e[gt],delete e[vt],delete e[yt],delete e[bt]}function wt(e){var t=e[ht];if(t)return t;for(var n=e.parentNode;n;){if(t=n[_t]||n[ht]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=kf(e);e!==null;){if(n=e[ht])return n;e=kf(e)}return t}e=n,n=e.parentNode}return null}function Tt(e){if(e=e[ht]||e[_t]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Et(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function Dt(e){var t=e[xt];return t||=e[xt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function Ot(e){e[St]=!0}var kt=new Set,At={};function jt(e,t){Mt(e,t),Mt(e+`Capture`,t)}function Mt(e,t){for(At[e]=t,e=0;e<t.length;e++)kt.add(t[e])}var Nt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Pt={},Ft={};function It(e){return Ae.call(Ft,e)?!0:Ae.call(Pt,e)?!1:Nt.test(e)?Ft[e]=!0:(Pt[e]=!0,!1)}function Lt(e,t,n){if(It(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function Rt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function zt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function Bt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Vt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Ht(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ut(e){if(!e._valueTracker){var t=Vt(e)?`checked`:`value`;e._valueTracker=Ht(e,t,``+e[t])}}function Wt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Vt(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function Gt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Kt=/[\n"\\]/g;function qt(e){return e.replace(Kt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Jt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Bt(t)):e.value!==``+Bt(t)&&(e.value=``+Bt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Xt(e,o,Bt(n)):Xt(e,o,Bt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Bt(s):e.removeAttribute(`name`)}function Yt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Ut(e);return}n=n==null?``:``+Bt(n),t=t==null?n:``+Bt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Ut(e)}function Xt(e,t,n){t===`number`&&Gt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Zt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Bt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Qt(e,t,n){if(t!=null&&(t=``+Bt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Bt(n)}function $t(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(le(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Bt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Ut(e)}function en(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var A=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function tn(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||A.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function nn(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&tn(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&tn(e,o,t[o])}function rn(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var an=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`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`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`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`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`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`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),on=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function sn(e){return on.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function cn(){}var ln=null;function un(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var dn=null,fn=null;function pn(e){var t=Tt(e);if(t&&(e=t.stateNode)){var n=e[gt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Jt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+qt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[gt]||null;if(!a)throw Error(i(90));Jt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Wt(r)}break a;case`textarea`:Qt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Zt(e,!!n.multiple,t,!1)}}}var mn=!1;function hn(e,t,n){if(mn)return e(t,n);mn=!0;try{return e(t)}finally{if(mn=!1,(dn!==null||fn!==null)&&(Lu(),dn&&(t=dn,e=fn,fn=dn=null,pn(t),e)))for(t=0;t<e.length;t++)pn(e[t])}}function gn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[gt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var _n=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),vn=!1;if(_n)try{var yn={};Object.defineProperty(yn,"passive",{get:function(){vn=!0}}),window.addEventListener(`test`,yn,yn),window.removeEventListener(`test`,yn,yn)}catch{vn=!1}var bn=null,xn=null,Sn=null;function Cn(){if(Sn)return Sn;var e,t=xn,n=t.length,r,i=`value`in bn?bn.value:bn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return Sn=i.slice(e,1<r?1-r:void 0)}function wn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Tn(){return!0}function En(){return!1}function Dn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?Tn:En,this.isPropagationStopped=En,this}return m(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=Tn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Tn)},persist:function(){},isPersistent:Tn}),t}var On={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},kn=Dn(On),An=m({},On,{view:0,detail:0}),jn=Dn(An),Mn,Nn,Pn,Fn=m({},An,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Kn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==Pn&&(Pn&&e.type===`mousemove`?(Mn=e.screenX-Pn.screenX,Nn=e.screenY-Pn.screenY):Nn=Mn=0,Pn=e),Mn)},movementY:function(e){return`movementY`in e?e.movementY:Nn}}),In=Dn(Fn),Ln=Dn(m({},Fn,{dataTransfer:0})),Rn=Dn(m({},An,{relatedTarget:0})),zn=Dn(m({},On,{animationName:0,elapsedTime:0,pseudoElement:0})),Bn=Dn(m({},On,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Vn=Dn(m({},On,{data:0})),Hn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Un={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},Wn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Gn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Wn[e])?!!t[e]:!1}function Kn(){return Gn}var qn=Dn(m({},An,{key:function(e){if(e.key){var t=Hn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=wn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Un[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Kn,charCode:function(e){return e.type===`keypress`?wn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?wn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Jn=Dn(m({},Fn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Yn=Dn(m({},An,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Kn})),Xn=Dn(m({},On,{propertyName:0,elapsedTime:0,pseudoElement:0})),Zn=Dn(m({},Fn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Qn=Dn(m({},On,{newState:0,oldState:0})),$n=[9,13,27,32],er=_n&&`CompositionEvent`in window,tr=null;_n&&`documentMode`in document&&(tr=document.documentMode);var nr=_n&&`TextEvent`in window&&!tr,rr=_n&&(!er||tr&&8<tr&&11>=tr),ir=` `,ar=!1;function or(e,t){switch(e){case`keyup`:return $n.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function sr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var cr=!1;function lr(e,t){switch(e){case`compositionend`:return sr(t);case`keypress`:return t.which===32?(ar=!0,ir):null;case`textInput`:return e=t.data,e===ir&&ar?null:e;default:return null}}function ur(e,t){if(cr)return e===`compositionend`||!er&&or(e,t)?(e=Cn(),Sn=xn=bn=null,cr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return rr&&t.locale!==`ko`?null:t.data;default:return null}}var dr={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function fr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!dr[e.type]:t===`textarea`}function pr(e,t,n,r){dn?fn?fn.push(r):fn=[r]:dn=r,t=Wd(t,`onChange`),0<t.length&&(n=new kn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var mr=null,hr=null;function gr(e){Id(e,0)}function _r(e){if(Wt(Et(e)))return e}function vr(e,t){if(e===`change`)return t}var yr=!1;if(_n){var br;if(_n){var xr=`oninput`in document;if(!xr){var Sr=document.createElement(`div`);Sr.setAttribute(`oninput`,`return;`),xr=typeof Sr.oninput==`function`}br=xr}else br=!1;yr=br&&(!document.documentMode||9<document.documentMode)}function Cr(){mr&&(mr.detachEvent(`onpropertychange`,wr),hr=mr=null)}function wr(e){if(e.propertyName===`value`&&_r(hr)){var t=[];pr(t,hr,e,un(e)),hn(gr,t)}}function Tr(e,t,n){e===`focusin`?(Cr(),mr=t,hr=n,mr.attachEvent(`onpropertychange`,wr)):e===`focusout`&&Cr()}function Er(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return _r(hr)}function Dr(e,t){if(e===`click`)return _r(t)}function Or(e,t){if(e===`input`||e===`change`)return _r(t)}function kr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Ar=typeof Object.is==`function`?Object.is:kr;function jr(e,t){if(Ar(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Ae.call(t,i)||!Ar(e[i],t[i]))return!1}return!0}function Mr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Nr(e,t){var n=Mr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Mr(n)}}function Pr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Pr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Fr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Gt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Gt(e.document)}return t}function Ir(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Lr=_n&&`documentMode`in document&&11>=document.documentMode,Rr=null,zr=null,Br=null,Vr=!1;function Hr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Vr||Rr==null||Rr!==Gt(r)||(r=Rr,`selectionStart`in r&&Ir(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Br&&jr(Br,r)||(Br=r,r=Wd(zr,`onSelect`),0<r.length&&(t=new kn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Rr)))}function Ur(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Wr={animationend:Ur(`Animation`,`AnimationEnd`),animationiteration:Ur(`Animation`,`AnimationIteration`),animationstart:Ur(`Animation`,`AnimationStart`),transitionrun:Ur(`Transition`,`TransitionRun`),transitionstart:Ur(`Transition`,`TransitionStart`),transitioncancel:Ur(`Transition`,`TransitionCancel`),transitionend:Ur(`Transition`,`TransitionEnd`)},Gr={},Kr={};_n&&(Kr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Wr.animationend.animation,delete Wr.animationiteration.animation,delete Wr.animationstart.animation),`TransitionEvent`in window||delete Wr.transitionend.transition);function qr(e){if(Gr[e])return Gr[e];if(!Wr[e])return e;var t=Wr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Kr)return Gr[e]=t[n];return e}var Jr=qr(`animationend`),Yr=qr(`animationiteration`),Xr=qr(`animationstart`),Zr=qr(`transitionrun`),Qr=qr(`transitionstart`),$r=qr(`transitioncancel`),ei=qr(`transitionend`),ti=new Map,ni=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);ni.push(`scrollEnd`);function ri(e,t){ti.set(e,t),jt(t,[e])}var ii=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},ai=[],oi=0,si=0;function ci(){for(var e=oi,t=si=oi=0;t<e;){var n=ai[t];ai[t++]=null;var r=ai[t];ai[t++]=null;var i=ai[t];ai[t++]=null;var a=ai[t];if(ai[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&fi(n,i,a)}}function li(e,t,n,r){ai[oi++]=e,ai[oi++]=t,ai[oi++]=n,ai[oi++]=r,si|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function ui(e,t,n,r){return li(e,t,n,r),pi(e)}function di(e,t){return li(e,null,null,t),pi(e)}function fi(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-qe(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function pi(e){if(50<Ou)throw Ou=0,ku=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var mi={};function hi(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function gi(e,t,n,r){return new hi(e,t,n,r)}function _i(e){return e=e.prototype,!(!e||!e.isReactComponent)}function vi(e,t){var n=e.alternate;return n===null?(n=gi(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function yi(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function bi(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)_i(e)&&(s=1);else if(typeof e==`string`)s=sp(e,n,he.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case re:return e=gi(31,n,t,a),e.elementType=re,e.lanes=o,e;case y:return xi(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=gi(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case w:return e=gi(13,n,t,a),e.elementType=w,e.lanes=o,e;case te:return e=gi(19,n,t,a),e.elementType=te,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case ee:s=10;break a;case S:s=9;break a;case C:s=11;break a;case ne:s=14;break a;case T:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=gi(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function xi(e,t,n,r){return e=gi(7,e,r,t),e.lanes=n,e}function Si(e,t,n){return e=gi(6,e,null,t),e.lanes=n,e}function Ci(e){var t=gi(18,null,null,0);return t.stateNode=e,t}function wi(e,t,n){return t=gi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Ti=new WeakMap;function Ei(e,t){if(typeof e==`object`&&e){var n=Ti.get(e);return n===void 0?(t={value:e,source:t,stack:ke(t)},Ti.set(e,t),t):n}return{value:e,source:t,stack:ke(t)}}var Di=[],Oi=0,ki=null,Ai=0,ji=[],Mi=0,Ni=null,Pi=1,Fi=``;function Ii(e,t){Di[Oi++]=Ai,Di[Oi++]=ki,ki=e,Ai=t}function Li(e,t,n){ji[Mi++]=Pi,ji[Mi++]=Fi,ji[Mi++]=Ni,Ni=e;var r=Pi;e=Fi;var i=32-qe(r)-1;r&=~(1<<i),n+=1;var a=32-qe(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Pi=1<<32-qe(t)+i|n<<i|r,Fi=a+e}else Pi=1<<a|n<<i|r,Fi=e}function Ri(e){e.return!==null&&(Ii(e,1),Li(e,1,0))}function zi(e){for(;e===ki;)ki=Di[--Oi],Di[Oi]=null,Ai=Di[--Oi],Di[Oi]=null;for(;e===Ni;)Ni=ji[--Mi],ji[Mi]=null,Fi=ji[--Mi],ji[Mi]=null,Pi=ji[--Mi],ji[Mi]=null}function Bi(e,t){ji[Mi++]=Pi,ji[Mi++]=Fi,ji[Mi++]=Ni,Pi=t.id,Fi=t.overflow,Ni=e}var Vi=null,Hi=null,Ui=!1,Wi=null,Gi=!1,Ki=Error(i(519));function qi(e){throw $i(Ei(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ki}function Ji(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[ht]=e,t[gt]=r,n){case`dialog`:Ld(`cancel`,t),Ld(`close`,t);break;case`iframe`:case`object`:case`embed`:Ld(`load`,t);break;case`video`:case`audio`:for(n=0;n<Pd.length;n++)Ld(Pd[n],t);break;case`source`:Ld(`error`,t);break;case`img`:case`image`:case`link`:Ld(`error`,t),Ld(`load`,t);break;case`details`:Ld(`toggle`,t);break;case`input`:Ld(`invalid`,t),Yt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Ld(`invalid`,t);break;case`textarea`:Ld(`invalid`,t),$t(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Xd(t.textContent,n)?(r.popover!=null&&(Ld(`beforetoggle`,t),Ld(`toggle`,t)),r.onScroll!=null&&Ld(`scroll`,t),r.onScrollEnd!=null&&Ld(`scrollend`,t),r.onClick!=null&&(t.onclick=cn),t=!0):t=!1,t||qi(e,!0)}function Yi(e){for(Vi=e.return;Vi;)switch(Vi.tag){case 5:case 31:case 13:Gi=!1;return;case 27:case 3:Gi=!0;return;default:Vi=Vi.return}}function Xi(e){if(e!==Vi)return!1;if(!Ui)return Yi(e),Ui=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||lf(e.type,e.memoizedProps)),n=!n),n&&Hi&&qi(e),Yi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Hi=Of(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Hi=Of(e)}else t===27?(t=Hi,_f(e.type)?(e=Df,Df=null,Hi=e):Hi=t):Hi=Vi?Ef(e.stateNode.nextSibling):null;return!0}function Zi(){Hi=Vi=null,Ui=!1}function Qi(){var e=Wi;return e!==null&&(mu===null?mu=e:mu.push.apply(mu,e),Wi=null),e}function $i(e){Wi===null?Wi=[e]:Wi.push(e)}var ea=pe(null),ta=null,na=null;function ra(e,t,n){O(ea,t._currentValue),t._currentValue=n}function ia(e){e._currentValue=ea.current,me(ea)}function aa(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function oa(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),aa(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),aa(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function sa(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;Ar(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===ve.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[gp]:e.push(gp))}a=a.return}e!==null&&oa(t,e,n,r),t.flags|=262144}function ca(e){for(e=e.firstContext;e!==null;){if(!Ar(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function la(e){ta=e,na=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function ua(e){return fa(ta,e)}function da(e,t){return ta===null&&la(e),fa(e,t)}function fa(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},na===null){if(e===null)throw Error(i(308));na=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else na=na.next=t;return n}var pa=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},ma=t.unstable_scheduleCallback,ha=t.unstable_NormalPriority,ga={$$typeof:ee,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function _a(){return{controller:new pa,data:new Map,refCount:0}}function va(e){e.refCount--,e.refCount===0&&ma(ha,function(){e.controller.abort()})}var ya=null,ba=0,xa=0,Sa=null;function Ca(e,t){if(ya===null){var n=ya=[];ba=0,xa=kd(),Sa={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return ba++,t.then(wa,wa),t}function wa(){if(--ba===0&&ya!==null){Sa!==null&&(Sa.status=`fulfilled`);var e=ya;ya=null,xa=0,Sa=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Ta(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var Ea=E.S;E.S=function(e,t){_u=Fe(),typeof t==`object`&&t&&typeof t.then==`function`&&Ca(e,t),Ea!==null&&Ea(e,t)};var Da=pe(null);function Oa(){var e=Da.current;return e===null?eu.pooledCache:e}function ka(e,t){t===null?O(Da,Da.current):O(Da,t.pool)}function Aa(){var e=Oa();return e===null?null:{parent:ga._currentValue,pool:e}}var ja=Error(i(460)),Ma=Error(i(474)),Na=Error(i(542)),Pa={then:function(){}};function Fa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Ia(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(cn,cn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ba(e),e;default:if(typeof t.status==`string`)t.then(cn,cn);else{if(e=eu,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ba(e),e}throw Ra=t,ja}}function La(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Ra=e,ja):e}}var Ra=null;function za(){if(Ra===null)throw Error(i(459));var e=Ra;return Ra=null,e}function Ba(e){if(e===ja||e===Na)throw Error(i(483))}var Va=null,Ha=0;function Ua(e){var t=Ha;return Ha+=1,Va===null&&(Va=[]),Ia(Va,e,t)}function Wa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ga(e,t){throw t.$$typeof===g?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ka(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=vi(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=Si(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===y?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===T&&La(i)===t.type)?(t=a(t,n.props),Wa(t,n),t.return=e,t):(t=bi(n.type,n.key,n.props,null,e.mode,r),Wa(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=wi(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=xi(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=Si(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=bi(t.type,t.key,t.props,null,e.mode,n),Wa(n,t),n.return=e,n;case v:return t=wi(t,e.mode,n),t.return=e,t;case T:return t=La(t),f(e,t,n)}if(le(t)||oe(t))return t=xi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Ua(t),n);if(t.$$typeof===ee)return f(e,da(e,t),n);Ga(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case _:return n.key===i?l(e,t,n,r):null;case v:return n.key===i?u(e,t,n,r):null;case T:return n=La(n),p(e,t,n,r)}if(le(n)||oe(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Ua(n),r);if(n.$$typeof===ee)return p(e,t,da(e,n),r);Ga(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case _:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case v:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case T:return r=La(r),m(e,t,n,r,i)}if(le(r)||oe(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Ua(r),i);if(r.$$typeof===ee)return m(e,t,n,da(t,r),i);Ga(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Ui&&Ii(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return Ui&&Ii(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),Ui&&Ii(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Ui&&Ii(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Ui&&Ii(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Ui&&Ii(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===T&&La(l)===r.type){n(e,r.sibling),c=a(r,o.props),Wa(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=xi(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=bi(o.type,o.key,o.props,null,e.mode,c),Wa(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=wi(o,e.mode,c),c.return=e,e=c}return s(e);case T:return o=La(o),b(e,r,o,c)}if(le(o))return h(e,r,o,c);if(oe(o)){if(l=oe(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Ua(o),c);if(o.$$typeof===ee)return b(e,r,da(e,o),c);Ga(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=Si(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ha=0;var i=b(e,t,n,r);return Va=null,i}catch(t){if(t===ja||t===Na)throw t;var a=gi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var qa=Ka(!0),Ja=Ka(!1),Ya=!1;function Xa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Za(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Qa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function $a(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,j&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=pi(e),fi(e,null,n),t}return li(e,r,t,n),pi(e)}function eo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ct(e,n)}}function to(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var no=!1;function ro(){if(no){var e=Sa;if(e!==null)throw e}}function io(e,t,n,r){no=!1;var i=e.updateQueue;Ya=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(tu&f)===f:(r&f)===f){f!==0&&f===xa&&(no=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=m({},d,f);break a;case 2:Ya=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),cu|=o,e.lanes=o,e.memoizedState=d}}function ao(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function oo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)ao(n[e],t)}var so=pe(null),co=pe(0);function lo(e,t){e=ou,O(co,e),O(so,t),ou=e|t.baseLanes}function uo(){O(co,ou),O(so,so.current)}function fo(){ou=co.current,me(so),me(co)}var po=pe(null),mo=null;function ho(e){var t=e.alternate;O(bo,bo.current&1),O(po,e),mo===null&&(t===null||so.current!==null||t.memoizedState!==null)&&(mo=e)}function go(e){O(bo,bo.current),O(po,e),mo===null&&(mo=e)}function _o(e){e.tag===22?(O(bo,bo.current),O(po,e),mo===null&&(mo=e)):vo(e)}function vo(){O(bo,bo.current),O(po,po.current)}function yo(e){me(po),mo===e&&(mo=null),me(bo)}var bo=pe(0);function xo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||wf(n)||F(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var So=0,Co=null,wo=null,To=null,Eo=!1,Do=!1,Oo=!1,ko=0,Ao=0,jo=null,Mo=0;function No(){throw Error(i(321))}function Po(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Ar(e[n],t[n]))return!1;return!0}function Fo(e,t,n,r,i,a){return So=a,Co=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,E.H=e===null||e.memoizedState===null?Qs:$s,Oo=!1,a=n(r,i),Oo=!1,Do&&(a=Lo(t,n,r,i)),Io(e),a}function Io(e){E.H=Zs;var t=wo!==null&&wo.next!==null;if(So=0,To=wo=Co=null,Eo=!1,Ao=0,jo=null,t)throw Error(i(300));e===null||gc||(e=e.dependencies,e!==null&&ca(e)&&(gc=!0))}function Lo(e,t,n,r){Co=e;var a=0;do{if(Do&&(jo=null),Ao=0,Do=!1,25<=a)throw Error(i(301));if(a+=1,To=wo=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}E.H=ec,o=t(n,r)}while(Do);return o}function Ro(){var e=E.H,t=e.useState()[0];return t=typeof t.then==`function`?Go(t):t,e=e.useState()[0],(wo===null?null:wo.memoizedState)!==e&&(Co.flags|=1024),t}function zo(){var e=ko!==0;return ko=0,e}function Bo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Vo(e){if(Eo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Eo=!1}So=0,To=wo=Co=null,Do=!1,Ao=ko=0,jo=null}function Ho(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return To===null?Co.memoizedState=To=e:To=To.next=e,To}function Uo(){if(wo===null){var e=Co.alternate;e=e===null?null:e.memoizedState}else e=wo.next;var t=To===null?Co.memoizedState:To.next;if(t!==null)To=t,wo=e;else{if(e===null)throw Co.alternate===null?Error(i(467)):Error(i(310));wo=e,e={memoizedState:wo.memoizedState,baseState:wo.baseState,baseQueue:wo.baseQueue,queue:wo.queue,next:null},To===null?Co.memoizedState=To=e:To=To.next=e}return To}function Wo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Go(e){var t=Ao;return Ao+=1,jo===null&&(jo=[]),e=Ia(jo,e,t),t=Co,(To===null?t.memoizedState:To.next)===null&&(t=t.alternate,E.H=t===null||t.memoizedState===null?Qs:$s),e}function Ko(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Go(e);if(e.$$typeof===ee)return ua(e)}throw Error(i(438,String(e)))}function qo(e){var t=null,n=Co.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Co.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Wo(),Co.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=ie;return t.index++,n}function Jo(e,t){return typeof t==`function`?t(e):t}function Yo(e){return Xo(Uo(),wo,e)}function Xo(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(So&f)===f:(tu&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===xa&&(d=!0);else if((So&p)===p){u=u.next,p===xa&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,Co.lanes|=p,cu|=p;f=u.action,Oo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,Co.lanes|=f,cu|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Ar(o,e.memoizedState)&&(gc=!0,d&&(n=Sa,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Zo(e){var t=Uo(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Ar(o,t.memoizedState)||(gc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Qo(e,t,n){var r=Co,a=Uo(),o=Ui;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Ar((wo||a).memoizedState,n);if(s&&(a.memoizedState=n,gc=!0),a=a.queue,Cs(ts.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||To!==null&&To.memoizedState.tag&1){if(r.flags|=2048,vs(9,{destroy:void 0},es.bind(null,r,a,n,t),null),eu===null)throw Error(i(349));o||So&127||$o(r,t,n)}return n}function $o(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Co.updateQueue,t===null?(t=Wo(),Co.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function es(e,t,n,r){t.value=n,t.getSnapshot=r,ns(t)&&rs(e)}function ts(e,t,n){return n(function(){ns(t)&&rs(e)})}function ns(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Ar(e,n)}catch{return!0}}function rs(e){var t=di(e,2);t!==null&&Mu(t,e,2)}function is(e){var t=Ho();if(typeof e==`function`){var n=e;if(e=n(),Oo){Ke(!0);try{n()}finally{Ke(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jo,lastRenderedState:e},t}function as(e,t,n,r){return e.baseState=n,Xo(e,wo,typeof r==`function`?r:Jo)}function os(e,t,n,r,a){if(Js(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};E.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,ss(t,o)):(o.next=n.next,t.pending=n.next=o)}}function ss(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=E.T,o={};E.T=o;try{var s=n(i,r),c=E.S;c!==null&&c(o,s),cs(e,t,s)}catch(n){us(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),E.T=a}}else try{a=n(i,r),cs(e,t,a)}catch(n){us(e,t,n)}}function cs(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){ls(e,t,n)},function(n){return us(e,t,n)}):ls(e,t,n)}function ls(e,t,n){t.status=`fulfilled`,t.value=n,ds(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,ss(e,n)))}function us(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,ds(t),t=t.next;while(t!==r)}e.action=null}function ds(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function fs(e,t){return t}function ps(e,t){if(Ui){var n=eu.formState;if(n!==null){a:{var r=Co;if(Ui){if(Hi){b:{for(var i=Hi,a=Gi;i.nodeType!==8;){if(!a){i=null;break b}if(i=Ef(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Hi=Ef(i.nextSibling),r=i.data===`F!`;break a}}qi(r)}r=!1}r&&(t=n[0])}}return n=Ho(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:fs,lastRenderedState:t},n.queue=r,n=Gs.bind(null,Co,r),r.dispatch=n,r=is(!1),a=qs.bind(null,Co,!1,r.queue),r=Ho(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=os.bind(null,Co,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function ms(e){return hs(Uo(),wo,e)}function hs(e,t,n){if(t=Xo(e,t,fs)[0],e=Yo(Jo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Go(t)}catch(e){throw e===ja?Na:e}else r=t;t=Uo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Co.flags|=2048,vs(9,{destroy:void 0},gs.bind(null,i,n),null)),[r,a,e]}function gs(e,t){e.action=t}function _s(e){var t=Uo(),n=wo;if(n!==null)return hs(t,n,e);Uo(),t=t.memoizedState,n=Uo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function vs(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Co.updateQueue,t===null&&(t=Wo(),Co.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function ys(){return Uo().memoizedState}function bs(e,t,n,r){var i=Ho();Co.flags|=e,i.memoizedState=vs(1|t,{destroy:void 0},n,r===void 0?null:r)}function xs(e,t,n,r){var i=Uo();r=r===void 0?null:r;var a=i.memoizedState.inst;wo!==null&&r!==null&&Po(r,wo.memoizedState.deps)?i.memoizedState=vs(t,a,n,r):(Co.flags|=e,i.memoizedState=vs(1|t,a,n,r))}function Ss(e,t){bs(8390656,8,e,t)}function Cs(e,t){xs(2048,8,e,t)}function ws(e){Co.flags|=4;var t=Co.updateQueue;if(t===null)t=Wo(),Co.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Ts(e){var t=Uo().memoizedState;return ws({ref:t,nextImpl:e}),function(){if(j&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Es(e,t){return xs(4,2,e,t)}function Ds(e,t){return xs(4,4,e,t)}function Os(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function ks(e,t,n){n=n==null?null:n.concat([e]),xs(4,4,Os.bind(null,t,e),n)}function As(){}function js(e,t){var n=Uo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Po(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Ms(e,t){var n=Uo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Po(t,r[1]))return r[0];if(r=e(),Oo){Ke(!0);try{e()}finally{Ke(!1)}}return n.memoizedState=[r,t],r}function Ns(e,t,n){return n===void 0||So&1073741824&&!(tu&261930)?e.memoizedState=t:(e.memoizedState=n,e=ju(),Co.lanes|=e,cu|=e,n)}function Ps(e,t,n,r){return Ar(n,t)?n:so.current===null?!(So&42)||So&1073741824&&!(tu&261930)?(gc=!0,e.memoizedState=n):(e=ju(),Co.lanes|=e,cu|=e,t):(e=Ns(e,n,r),Ar(e,t)||(gc=!0),e)}function Fs(e,t,n,r,i){var a=D.p;D.p=a!==0&&8>a?a:8;var o=E.T,s={};E.T=s,qs(e,!1,t,n);try{var c=i(),l=E.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ks(e,t,Ta(c,r),Au(e)):Ks(e,t,r,Au(e))}catch(n){Ks(e,t,{then:function(){},status:`rejected`,reason:n},Au())}finally{D.p=a,o!==null&&s.types!==null&&(o.types=s.types),E.T=o}}function Is(){}function Ls(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Rs(e).queue;Fs(e,a,t,ue,n===null?Is:function(){return zs(e),n(r)})}function Rs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ue,baseState:ue,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jo,lastRenderedState:ue},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function zs(e){var t=Rs(e);t.next===null&&(t=e.alternate.memoizedState),Ks(e,t.next.queue,{},Au())}function Bs(){return ua(gp)}function Vs(){return Uo().memoizedState}function Hs(){return Uo().memoizedState}function Us(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Au();e=Qa(n);var r=$a(t,e,n);r!==null&&(Mu(r,t,n),eo(r,t,n)),t={cache:_a()},e.payload=t;return}t=t.return}}function Ws(e,t,n){var r=Au();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Js(e)?Ys(t,n):(n=ui(e,t,n,r),n!==null&&(Mu(n,e,r),Xs(n,t,r)))}function Gs(e,t,n){Ks(e,t,n,Au())}function Ks(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Js(e))Ys(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Ar(s,o))return li(e,t,i,0),eu===null&&ci(),!1}catch{}if(n=ui(e,t,i,r),n!==null)return Mu(n,e,r),Xs(n,t,r),!0}return!1}function qs(e,t,n,r){if(r={lane:2,revertLane:kd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Js(e)){if(t)throw Error(i(479))}else t=ui(e,n,r,2),t!==null&&Mu(t,e,2)}function Js(e){var t=e.alternate;return e===Co||t!==null&&t===Co}function Ys(e,t){Do=Eo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Xs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ct(e,n)}}var Zs={readContext:ua,use:Ko,useCallback:No,useContext:No,useEffect:No,useImperativeHandle:No,useLayoutEffect:No,useInsertionEffect:No,useMemo:No,useReducer:No,useRef:No,useState:No,useDebugValue:No,useDeferredValue:No,useTransition:No,useSyncExternalStore:No,useId:No,useHostTransitionStatus:No,useFormState:No,useActionState:No,useOptimistic:No,useMemoCache:No,useCacheRefresh:No};Zs.useEffectEvent=No;var Qs={readContext:ua,use:Ko,useCallback:function(e,t){return Ho().memoizedState=[e,t===void 0?null:t],e},useContext:ua,useEffect:Ss,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),bs(4194308,4,Os.bind(null,t,e),n)},useLayoutEffect:function(e,t){return bs(4194308,4,e,t)},useInsertionEffect:function(e,t){bs(4,2,e,t)},useMemo:function(e,t){var n=Ho();t=t===void 0?null:t;var r=e();if(Oo){Ke(!0);try{e()}finally{Ke(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Ho();if(n!==void 0){var i=n(t);if(Oo){Ke(!0);try{n(t)}finally{Ke(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ws.bind(null,Co,e),[r.memoizedState,e]},useRef:function(e){var t=Ho();return e={current:e},t.memoizedState=e},useState:function(e){e=is(e);var t=e.queue,n=Gs.bind(null,Co,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:As,useDeferredValue:function(e,t){return Ns(Ho(),e,t)},useTransition:function(){var e=is(!1);return e=Fs.bind(null,Co,e.queue,!0,!1),Ho().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Co,a=Ho();if(Ui){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),eu===null)throw Error(i(349));tu&127||$o(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Ss(ts.bind(null,r,o,e),[e]),r.flags|=2048,vs(9,{destroy:void 0},es.bind(null,r,o,n,t),null),n},useId:function(){var e=Ho(),t=eu.identifierPrefix;if(Ui){var n=Fi,r=Pi;n=(r&~(1<<32-qe(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=ko++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Mo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Bs,useFormState:ps,useActionState:ps,useOptimistic:function(e){var t=Ho();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=qs.bind(null,Co,!0,n),n.dispatch=t,[e,t]},useMemoCache:qo,useCacheRefresh:function(){return Ho().memoizedState=Us.bind(null,Co)},useEffectEvent:function(e){var t=Ho(),n={impl:e};return t.memoizedState=n,function(){if(j&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},$s={readContext:ua,use:Ko,useCallback:js,useContext:ua,useEffect:Cs,useImperativeHandle:ks,useInsertionEffect:Es,useLayoutEffect:Ds,useMemo:Ms,useReducer:Yo,useRef:ys,useState:function(){return Yo(Jo)},useDebugValue:As,useDeferredValue:function(e,t){return Ps(Uo(),wo.memoizedState,e,t)},useTransition:function(){var e=Yo(Jo)[0],t=Uo().memoizedState;return[typeof e==`boolean`?e:Go(e),t]},useSyncExternalStore:Qo,useId:Vs,useHostTransitionStatus:Bs,useFormState:ms,useActionState:ms,useOptimistic:function(e,t){return as(Uo(),wo,e,t)},useMemoCache:qo,useCacheRefresh:Hs};$s.useEffectEvent=Ts;var ec={readContext:ua,use:Ko,useCallback:js,useContext:ua,useEffect:Cs,useImperativeHandle:ks,useInsertionEffect:Es,useLayoutEffect:Ds,useMemo:Ms,useReducer:Zo,useRef:ys,useState:function(){return Zo(Jo)},useDebugValue:As,useDeferredValue:function(e,t){var n=Uo();return wo===null?Ns(n,e,t):Ps(n,wo.memoizedState,e,t)},useTransition:function(){var e=Zo(Jo)[0],t=Uo().memoizedState;return[typeof e==`boolean`?e:Go(e),t]},useSyncExternalStore:Qo,useId:Vs,useHostTransitionStatus:Bs,useFormState:_s,useActionState:_s,useOptimistic:function(e,t){var n=Uo();return wo===null?(n.baseState=e,[e,n.queue.dispatch]):as(n,wo,e,t)},useMemoCache:qo,useCacheRefresh:Hs};ec.useEffectEvent=Ts;function tc(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:m({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var nc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Au(),i=Qa(r);i.payload=t,n!=null&&(i.callback=n),t=$a(e,i,r),t!==null&&(Mu(t,e,r),eo(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Au(),i=Qa(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=$a(e,i,r),t!==null&&(Mu(t,e,r),eo(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Au(),r=Qa(n);r.tag=2,t!=null&&(r.callback=t),t=$a(e,r,n),t!==null&&(Mu(t,e,n),eo(t,e,n))}};function rc(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!jr(n,r)||!jr(i,a):!0}function ic(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&nc.enqueueReplaceState(t,t.state,null)}function ac(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=m({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function oc(e){ii(e)}function sc(e){console.error(e)}function cc(e){ii(e)}function lc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function uc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function dc(e,t,n){return n=Qa(n),n.tag=3,n.payload={element:null},n.callback=function(){lc(e,t)},n}function fc(e){return e=Qa(e),e.tag=3,e}function pc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){uc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){uc(t,n,r),typeof i!=`function`&&(bu===null?bu=new Set([this]):bu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function mc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&sa(t,n,a,!0),n=po.current,n!==null){switch(n.tag){case 31:case 13:return mo===null?Wu():n.alternate===null&&su===0&&(su=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Pa?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),ld(e,r,a)),!1;case 22:return n.flags|=65536,r===Pa?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),ld(e,r,a)),!1}throw Error(i(435,n.tag))}return ld(e,r,a),Wu(),!1}if(Ui)return t=po.current,t===null?(r!==Ki&&(t=Error(i(423),{cause:r}),$i(Ei(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=Ei(r,n),a=dc(e.stateNode,r,a),to(e,a),su!==4&&(su=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Ki&&(e=Error(i(422),{cause:r}),$i(Ei(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=Ei(o,n),pu===null?pu=[o]:pu.push(o),su!==4&&(su=2),t===null)return!0;r=Ei(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=dc(n.stateNode,r,e),to(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(bu===null||!bu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=fc(a),pc(a,e,n,r),to(n,a),!1}n=n.return}while(n!==null);return!1}var hc=Error(i(461)),gc=!1;function _c(e,t,n,r){t.child=e===null?Ja(t,null,n,r):qa(t,e.child,n,r)}function vc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return la(t),r=Fo(e,t,n,o,a,i),s=zo(),e!==null&&!gc?(Bo(e,t,i),Hc(e,t,i)):(Ui&&s&&Ri(t),t.flags|=1,_c(e,t,r,i),t.child)}function yc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!_i(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,bc(e,t,a,r,i)):(e=bi(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Uc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?jr:n,n(o,r)&&e.ref===t.ref)return Hc(e,t,i)}return t.flags|=1,e=vi(a,r),e.ref=t.ref,e.return=t,t.child=e}function bc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(jr(a,r)&&e.ref===t.ref)if(gc=!1,t.pendingProps=r=a,Uc(e,i))e.flags&131072&&(gc=!0);else return t.lanes=e.lanes,Hc(e,t,i)}return Oc(e,t,n,r,i)}function xc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return Cc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ka(t,a===null?null:a.cachePool),a===null?uo():lo(t,a),_o(t);else return r=t.lanes=536870912,Cc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&ka(t,null),uo(),vo(t)):(ka(t,a.cachePool),lo(t,a),vo(t),t.memoizedState=null);return _c(e,t,i,n),t.child}function Sc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Cc(e,t,n,r,i){var a=Oa();return a=a===null?null:{parent:ga._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&ka(t,null),uo(),_o(t),e!==null&&sa(e,t,r,!0),t.childLanes=i,null}function wc(e,t){return t=Lc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Tc(e,t,n){return qa(t,e.child,null,n),e=wc(t,t.pendingProps),e.flags|=2,yo(t),t.memoizedState=null,e}function Ec(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Ui){if(r.mode===`hidden`)return e=wc(t,r),t.lanes=536870912,Sc(null,e);if(go(t),(e=Hi)?(e=Cf(e,Gi),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ni===null?null:{id:Pi,overflow:Fi},retryLane:536870912,hydrationErrors:null},n=Ci(e),n.return=t,t.child=n,Vi=t,Hi=null)):e=null,e===null)throw qi(t);return t.lanes=536870912,null}return wc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(go(t),a)if(t.flags&256)t.flags&=-257,t=Tc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(gc||sa(e,t,n,!1),a=(n&e.childLanes)!==0,gc||a){if(r=eu,r!==null&&(s=lt(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,di(e,s),Mu(r,e,s),hc;Wu(),t=Tc(e,t,n)}else e=o.treeContext,Hi=Ef(s.nextSibling),Vi=t,Ui=!0,Wi=null,Gi=!1,e!==null&&Bi(t,e),t=wc(t,r),t.flags|=4096;return t}return e=vi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Dc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Oc(e,t,n,r,i){return la(t),n=Fo(e,t,n,r,void 0,i),r=zo(),e!==null&&!gc?(Bo(e,t,i),Hc(e,t,i)):(Ui&&r&&Ri(t),t.flags|=1,_c(e,t,n,i),t.child)}function kc(e,t,n,r,i,a){return la(t),t.updateQueue=null,n=Lo(t,r,n,i),Io(e),r=zo(),e!==null&&!gc?(Bo(e,t,a),Hc(e,t,a)):(Ui&&r&&Ri(t),t.flags|=1,_c(e,t,n,a),t.child)}function Ac(e,t,n,r,i){if(la(t),t.stateNode===null){var a=mi,o=n.contextType;typeof o==`object`&&o&&(a=ua(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=nc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Xa(t),o=n.contextType,a.context=typeof o==`object`&&o?ua(o):mi,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(tc(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&nc.enqueueReplaceState(a,a.state,null),io(t,r,a,i),ro(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=ac(n,s);a.props=c;var l=a.context,u=n.contextType;o=mi,typeof u==`object`&&u&&(o=ua(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&ic(t,a,r,o),Ya=!1;var f=t.memoizedState;a.state=f,io(t,r,a,i),ro(),l=t.memoizedState,s||f!==l||Ya?(typeof d==`function`&&(tc(t,n,d,r),l=t.memoizedState),(c=Ya||rc(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Za(e,t),o=t.memoizedProps,u=ac(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=mi,typeof l==`object`&&l&&(c=ua(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&ic(t,a,r,c),Ya=!1,f=t.memoizedState,a.state=f,io(t,r,a,i),ro();var p=t.memoizedState;o!==d||f!==p||Ya||e!==null&&e.dependencies!==null&&ca(e.dependencies)?(typeof s==`function`&&(tc(t,n,s,r),p=t.memoizedState),(u=Ya||rc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&ca(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,Dc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=qa(t,e.child,null,i),t.child=qa(t,null,n,i)):_c(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Hc(e,t,i),e}function jc(e,t,n,r){return Zi(),t.flags|=256,_c(e,t,n,r),t.child}var Mc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Nc(e){return{baseLanes:e,cachePool:Aa()}}function Pc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=du),e}function Fc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(bo.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Ui){if(a?ho(t):vo(t),(e=Hi)?(e=Cf(e,Gi),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ni===null?null:{id:Pi,overflow:Fi},retryLane:536870912,hydrationErrors:null},n=Ci(e),n.return=t,t.child=n,Vi=t,Hi=null)):e=null,e===null)throw qi(t);return F(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(vo(t),a=t.mode,c=Lc({mode:`hidden`,children:c},a),r=xi(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=Nc(n),r.childLanes=Pc(e,s,n),t.memoizedState=Mc,Sc(null,r)):(ho(t),Ic(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(ho(t),t.flags&=-257,t=Rc(e,t,n)):t.memoizedState===null?(vo(t),c=r.fallback,a=t.mode,r=Lc({mode:`visible`,children:r.children},a),c=xi(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,qa(t,e.child,null,n),r=t.child,r.memoizedState=Nc(n),r.childLanes=Pc(e,s,n),t.memoizedState=Mc,t=Sc(null,r)):(vo(t),t.child=e.child,t.flags|=128,t=null);else if(ho(t),F(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,$i({value:r,source:null,stack:null}),t=Rc(e,t,n)}else if(gc||sa(e,t,n,!1),s=(n&e.childLanes)!==0,gc||s){if(s=eu,s!==null&&(r=lt(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,di(e,r),Mu(s,e,r),hc;wf(c)||Wu(),t=Rc(e,t,n)}else wf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Hi=Ef(c.nextSibling),Vi=t,Ui=!0,Wi=null,Gi=!1,e!==null&&Bi(t,e),t=Ic(t,r.children),t.flags|=4096);return t}return a?(vo(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=vi(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=xi(c,a,n,null),c.flags|=2):c=vi(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,Sc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=Nc(n):(a=c.cachePool,a===null?a=Aa():(l=ga._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=Pc(e,s,n),t.memoizedState=Mc,Sc(e.child,r)):(ho(t),n=e.child,e=n.sibling,n=vi(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function Ic(e,t){return t=Lc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Lc(e,t){return e=gi(22,e,null,t),e.lanes=0,e}function Rc(e,t,n){return qa(t,e.child,null,n),e=Ic(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function zc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),aa(e.return,t,n)}function Bc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Vc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=bo.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,O(bo,o),_c(e,t,r,n),r=Ui?Ai:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&zc(e,n,t);else if(e.tag===19)zc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&xo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Bc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&xo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Bc(t,!0,n,null,a,r);break;case`together`:Bc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Hc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),cu|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(sa(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=vi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=vi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Uc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&ca(e))):!0}function Wc(e,t,n){switch(t.tag){case 3:ye(t,t.stateNode.containerInfo),ra(t,ga,e.memoizedState.cache),Zi();break;case 27:case 5:xe(t);break;case 4:ye(t,t.stateNode.containerInfo);break;case 10:ra(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,go(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(ho(t),e=Hc(e,t,n),e===null?null:e.sibling):Fc(e,t,n):(ho(t),t.flags|=128,null);ho(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(sa(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Vc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),O(bo,bo.current),r)break;return null;case 22:return t.lanes=0,xc(e,t,n,t.pendingProps);case 24:ra(t,ga,e.memoizedState.cache)}return Hc(e,t,n)}function Gc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)gc=!0;else{if(!Uc(e,n)&&!(t.flags&128))return gc=!1,Wc(e,t,n);gc=!!(e.flags&131072)}else gc=!1,Ui&&t.flags&1048576&&Li(t,Ai,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=La(t.elementType),t.type=e,typeof e==`function`)_i(e)?(r=ac(e,r),t.tag=1,t=Ac(null,t,e,r,n)):(t.tag=0,t=Oc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===C){t.tag=11,t=vc(null,t,e,r,n);break a}else if(a===ne){t.tag=14,t=yc(null,t,e,r,n);break a}}throw t=ce(e)||e,Error(i(306,t,``))}}return t;case 0:return Oc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=ac(r,t.pendingProps),Ac(e,t,r,a,n);case 3:a:{if(ye(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Za(e,t),io(t,r,null,n);var s=t.memoizedState;if(r=s.cache,ra(t,ga,r),r!==o.cache&&oa(t,[ga],n,!0),ro(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=jc(e,t,r,n);break a}else if(r!==a){a=Ei(Error(i(424)),t),$i(a),t=jc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Hi=Ef(e.firstChild),Vi=t,Ui=!0,Wi=null,Gi=!0,n=Ja(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Zi(),r===a){t=Hc(e,t,n);break a}_c(e,t,r,n)}t=t.child}return t;case 26:return Dc(e,t),e===null?(n=qf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Ui||(n=t.type,e=t.pendingProps,r=of(_e.current).createElement(n),r[ht]=t,r[gt]=e,$d(r,n,e),Ot(r),t.stateNode=r):t.memoizedState=qf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return xe(t),e===null&&Ui&&(r=t.stateNode=Af(t.type,t.pendingProps,_e.current),Vi=t,Gi=!0,a=Hi,_f(t.type)?(Df=a,Hi=Ef(r.firstChild)):Hi=a),_c(e,t,t.pendingProps.children,n),Dc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ui&&((a=r=Hi)&&(r=xf(r,t.type,t.pendingProps,Gi),r===null?a=!1:(t.stateNode=r,Vi=t,Hi=Ef(r.firstChild),Gi=!1,a=!0)),a||qi(t)),xe(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,lf(a,o)?r=null:s!==null&&lf(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=Fo(e,t,Ro,null,null,n),gp._currentValue=a),Dc(e,t),_c(e,t,r,n),t.child;case 6:return e===null&&Ui&&((e=n=Hi)&&(n=Sf(n,t.pendingProps,Gi),n===null?e=!1:(t.stateNode=n,Vi=t,Hi=null,e=!0)),e||qi(t)),null;case 13:return Fc(e,t,n);case 4:return ye(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=qa(t,null,r,n):_c(e,t,r,n),t.child;case 11:return vc(e,t,t.type,t.pendingProps,n);case 7:return _c(e,t,t.pendingProps,n),t.child;case 8:return _c(e,t,t.pendingProps.children,n),t.child;case 12:return _c(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,ra(t,t.type,r.value),_c(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,la(t),a=ua(a),r=r(a),t.flags|=1,_c(e,t,r,n),t.child;case 14:return yc(e,t,t.type,t.pendingProps,n);case 15:return bc(e,t,t.type,t.pendingProps,n);case 19:return Vc(e,t,n);case 31:return Ec(e,t,n);case 22:return xc(e,t,n,t.pendingProps);case 24:return la(t),r=ua(ga),e===null?(a=Oa(),a===null&&(a=eu,o=_a(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Xa(t),ra(t,ga,a)):((e.lanes&n)!==0&&(Za(e,t),io(t,null,null,n),ro()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,ra(t,ga,r),r!==a.cache&&oa(t,[ga],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),ra(t,ga,r))),_c(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Kc(e){e.flags|=4}function qc(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(Vu())e.flags|=8192;else throw Ra=Pa,Ma}else e.flags&=-16777217}function Jc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!cp(t))if(Vu())e.flags|=8192;else throw Ra=Pa,Ma}function Yc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:rt(),e.lanes|=t,fu|=t)}function Xc(e,t){if(!Ui)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Zc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Qc(e,t,n){var r=t.pendingProps;switch(zi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Zc(t),null;case 1:return Zc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),ia(ga),be(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Xi(t)?Kc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Qi())),Zc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Kc(t),o===null?(Zc(t),qc(t,a,null,r,n)):(Zc(t),Jc(t,o))):o?o===e.memoizedState?(Zc(t),t.flags&=-16777217):(Kc(t),Zc(t),Jc(t,o)):(e=e.memoizedProps,e!==r&&Kc(t),Zc(t),qc(t,a,e,r,n)),null;case 27:if(Se(t),n=_e.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Kc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Zc(t),null}e=he.current,Xi(t)?Ji(t,e):(e=Af(a,r,n),t.stateNode=e,Kc(t))}return Zc(t),null;case 5:if(Se(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Kc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Zc(t),null}if(o=he.current,Xi(t))Ji(t,o);else{var s=of(_e.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[ht]=t,o[gt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch($d(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Kc(t)}}return Zc(t),qc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Kc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=_e.current,Xi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Vi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[ht]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Xd(e.nodeValue,n)),e||qi(t,!0)}else e=of(e).createTextNode(r),e[ht]=t,t.stateNode=e}return Zc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Xi(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[ht]=t}else Zi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Zc(t),e=!1}else n=Qi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(yo(t),t):(yo(t),null);if(t.flags&128)throw Error(i(558))}return Zc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Xi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[ht]=t}else Zi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Zc(t),a=!1}else a=Qi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(yo(t),t):(yo(t),null)}return yo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Yc(t,t.updateQueue),Zc(t),null);case 4:return be(),e===null&&Bd(t.stateNode.containerInfo),Zc(t),null;case 10:return ia(t.type),Zc(t),null;case 19:if(me(bo),r=t.memoizedState,r===null)return Zc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Xc(r,!1);else{if(su!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=xo(e),o!==null){for(t.flags|=128,Xc(r,!1),e=o.updateQueue,t.updateQueue=e,Yc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)yi(n,e),n=n.sibling;return O(bo,bo.current&1|2),Ui&&Ii(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Fe()>vu&&(t.flags|=128,a=!0,Xc(r,!1),t.lanes=4194304)}else{if(!a)if(e=xo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Yc(t,e),Xc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Ui)return Zc(t),null}else 2*Fe()-r.renderingStartTime>vu&&n!==536870912&&(t.flags|=128,a=!0,Xc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Zc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Fe(),e.sibling=null,n=bo.current,O(bo,a?n&1|2:n&1),Ui&&Ii(t,r.treeForkCount),e);case 22:case 23:return yo(t),fo(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Zc(t),t.subtreeFlags&6&&(t.flags|=8192)):Zc(t),n=t.updateQueue,n!==null&&Yc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&me(Da),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ia(ga),Zc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function $c(e,t){switch(zi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ia(ga),be(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Se(t),null;case 31:if(t.memoizedState!==null){if(yo(t),t.alternate===null)throw Error(i(340));Zi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(yo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Zi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return me(bo),null;case 4:return be(),null;case 10:return ia(t.type),null;case 22:case 23:return yo(t),fo(),e!==null&&me(Da),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ia(ga),null;case 25:return null;default:return null}}function el(e,t){switch(zi(t),t.tag){case 3:ia(ga),be();break;case 26:case 27:case 5:Se(t);break;case 4:be();break;case 31:t.memoizedState!==null&&yo(t);break;case 13:yo(t);break;case 19:me(bo);break;case 10:ia(t.type);break;case 22:case 23:yo(t),fo(),e!==null&&me(Da);break;case 24:ia(ga)}}function tl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){cd(t,t.return,e)}}function nl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){cd(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){cd(t,t.return,e)}}function rl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{oo(t,n)}catch(t){cd(e,e.return,t)}}}function il(e,t,n){n.props=ac(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){cd(e,t,n)}}function al(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){cd(e,t,n)}}function ol(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){cd(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){cd(e,t,n)}else n.current=null}function sl(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){cd(e,e.return,t)}}function cl(e,t,n){try{var r=e.stateNode;ef(r,e.type,n,t),r[gt]=t}catch(t){cd(e,e.return,t)}}function ll(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&_f(e.type)||e.tag===4}function ul(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||ll(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&_f(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function dl(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=cn));else if(r!==4&&(r===27&&_f(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(dl(e,t,n),e=e.sibling;e!==null;)dl(e,t,n),e=e.sibling}function fl(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&_f(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(fl(e,t,n),e=e.sibling;e!==null;)fl(e,t,n),e=e.sibling}function pl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);$d(t,r,n),t[ht]=e,t[gt]=n}catch(t){cd(e,e.return,t)}}var ml=!1,hl=!1,gl=!1,_l=typeof WeakSet==`function`?WeakSet:Set,vl=null;function yl(e,t){if(e=e.containerInfo,rf=Tp,e=Fr(e),Ir(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(af={focusedElem:e,selectionRange:n},Tp=!1,vl=t;vl!==null;)if(t=vl,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,vl=e;else for(;vl!==null;){switch(t=vl,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=ac(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){cd(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)bf(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:bf(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,vl=e;break}vl=t.return}}function bl(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Fl(e,n),r&4&&tl(5,n);break;case 1:if(Fl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){cd(n,n.return,e)}else{var i=ac(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){cd(n,n.return,e)}}r&64&&rl(n),r&512&&al(n,n.return);break;case 3:if(Fl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{oo(e,t)}catch(e){cd(n,n.return,e)}}break;case 27:t===null&&r&4&&pl(n);case 26:case 5:Fl(e,n),t===null&&r&4&&sl(n),r&512&&al(n,n.return);break;case 12:Fl(e,n);break;case 31:Fl(e,n),r&4&&El(e,n);break;case 13:Fl(e,n),r&4&&Dl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=fd.bind(null,n),Tf(e,n))));break;case 22:if(r=n.memoizedState!==null||ml,!r){t=t!==null&&t.memoizedState!==null||hl,i=ml;var a=hl;ml=r,(hl=t)&&!a?Ll(e,n,(n.subtreeFlags&8772)!=0):Fl(e,n),ml=i,hl=a}break;case 30:break;default:Fl(e,n)}}function xl(e){var t=e.alternate;t!==null&&(e.alternate=null,xl(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Ct(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Sl=null,Cl=!1;function wl(e,t,n){for(n=n.child;n!==null;)Tl(e,t,n),n=n.sibling}function Tl(e,t,n){if(Ge&&typeof Ge.onCommitFiberUnmount==`function`)try{Ge.onCommitFiberUnmount(We,n)}catch{}switch(n.tag){case 26:hl||ol(n,t),wl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:hl||ol(n,t);var r=Sl,i=Cl;_f(n.type)&&(Sl=n.stateNode,Cl=!1),wl(e,t,n),jf(n.stateNode),Sl=r,Cl=i;break;case 5:hl||ol(n,t);case 6:if(r=Sl,i=Cl,Sl=null,wl(e,t,n),Sl=r,Cl=i,Sl!==null)if(Cl)try{(Sl.nodeType===9?Sl.body:Sl.nodeName===`HTML`?Sl.ownerDocument.body:Sl).removeChild(n.stateNode)}catch(e){cd(n,t,e)}else try{Sl.removeChild(n.stateNode)}catch(e){cd(n,t,e)}break;case 18:Sl!==null&&(Cl?(e=Sl,vf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Zp(e)):vf(Sl,n.stateNode));break;case 4:r=Sl,i=Cl,Sl=n.stateNode.containerInfo,Cl=!0,wl(e,t,n),Sl=r,Cl=i;break;case 0:case 11:case 14:case 15:nl(2,n,t),hl||nl(4,n,t),wl(e,t,n);break;case 1:hl||(ol(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&il(n,t,r)),wl(e,t,n);break;case 21:wl(e,t,n);break;case 22:hl=(r=hl)||n.memoizedState!==null,wl(e,t,n),hl=r;break;default:wl(e,t,n)}}function El(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Zp(e)}catch(e){cd(t,t.return,e)}}}function Dl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Zp(e)}catch(e){cd(t,t.return,e)}}function Ol(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new _l),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new _l),t;default:throw Error(i(435,e.tag))}}function kl(e,t){var n=Ol(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=pd.bind(null,e,t);t.then(r,r)}})}function Al(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(_f(c.type)){Sl=c.stateNode,Cl=!1;break a}break;case 5:Sl=c.stateNode,Cl=!1;break a;case 3:case 4:Sl=c.stateNode.containerInfo,Cl=!0;break a}c=c.return}if(Sl===null)throw Error(i(160));Tl(o,s,a),Sl=null,Cl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Ml(t,e),t=t.sibling}var jl=null;function Ml(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Al(t,e),Nl(e),r&4&&(nl(3,e,e.return),tl(3,e),nl(5,e,e.return));break;case 1:Al(t,e),Nl(e),r&512&&(hl||n===null||ol(n,n.return)),r&64&&ml&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=jl;if(Al(t,e),Nl(e),r&512&&(hl||n===null||ol(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[St]||o[ht]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),$d(o,r,n),o[ht]=e,Ot(o),r=o;break a;case`link`:var s=ap(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),$d(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=ap(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),$d(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[ht]=e,Ot(o),r=o}e.stateNode=r}else op(a,e.type,e.stateNode);else e.stateNode=ep(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&cl(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?op(a,e.type,e.stateNode):ep(a,r,e.memoizedProps))}break;case 27:Al(t,e),Nl(e),r&512&&(hl||n===null||ol(n,n.return)),n!==null&&r&4&&cl(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Al(t,e),Nl(e),r&512&&(hl||n===null||ol(n,n.return)),e.flags&32){a=e.stateNode;try{en(a,``)}catch(t){cd(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,cl(e,a,n===null?a:n.memoizedProps)),r&1024&&(gl=!0);break;case 6:if(Al(t,e),Nl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){cd(e,e.return,t)}}break;case 3:if(ip=null,a=jl,jl=Pf(t.containerInfo),Al(t,e),jl=a,Nl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Zp(t.containerInfo)}catch(t){cd(e,e.return,t)}gl&&(gl=!1,Pl(e));break;case 4:r=jl,jl=Pf(e.stateNode.containerInfo),Al(t,e),Nl(e),jl=r;break;case 12:Al(t,e),Nl(e);break;case 31:Al(t,e),Nl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,kl(e,r)));break;case 13:Al(t,e),Nl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(gu=Fe()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,kl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=ml,d=hl;if(ml=u||a,hl=d||l,Al(t,e),hl=d,ml=u,Nl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||ml||hl||Il(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){cd(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){cd(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?yf(m,!0):yf(l.stateNode,!1)}catch(e){cd(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,kl(e,n))));break;case 19:Al(t,e),Nl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,kl(e,r)));break;case 30:break;case 21:break;default:Al(t,e),Nl(e)}}function Nl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(ll(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;fl(e,ul(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(en(o,``),n.flags&=-33),fl(e,ul(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;dl(e,ul(e),s);break;default:throw Error(i(161))}}catch(t){cd(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Pl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Pl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Fl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)bl(e,t.alternate,t),t=t.sibling}function Il(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:nl(4,t,t.return),Il(t);break;case 1:ol(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&il(t,t.return,n),Il(t);break;case 27:jf(t.stateNode);case 26:case 5:ol(t,t.return),Il(t);break;case 22:t.memoizedState===null&&Il(t);break;case 30:Il(t);break;default:Il(t)}e=e.sibling}}function Ll(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:Ll(i,a,n),tl(4,a);break;case 1:if(Ll(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){cd(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)ao(c[i],s)}catch(e){cd(r,r.return,e)}}n&&o&64&&rl(a),al(a,a.return);break;case 27:pl(a);case 26:case 5:Ll(i,a,n),n&&r===null&&o&4&&sl(a),al(a,a.return);break;case 12:Ll(i,a,n);break;case 31:Ll(i,a,n),n&&o&4&&El(i,a);break;case 13:Ll(i,a,n),n&&o&4&&Dl(i,a);break;case 22:a.memoizedState===null&&Ll(i,a,n),al(a,a.return);break;case 30:break;default:Ll(i,a,n)}t=t.sibling}}function Rl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&va(n))}function zl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&va(e))}function Bl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Vl(e,t,n,r),t=t.sibling}function Vl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Bl(e,t,n,r),i&2048&&tl(9,t);break;case 1:Bl(e,t,n,r);break;case 3:Bl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&va(e)));break;case 12:if(i&2048){Bl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){cd(t,t.return,e)}}else Bl(e,t,n,r);break;case 31:Bl(e,t,n,r);break;case 13:Bl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?Bl(e,t,n,r):(a._visibility|=2,Hl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?Bl(e,t,n,r):Ul(e,t),i&2048&&Rl(o,t);break;case 24:Bl(e,t,n,r),i&2048&&zl(t.alternate,t);break;default:Bl(e,t,n,r)}}function Hl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Hl(a,o,s,c,i),tl(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Hl(a,o,s,c,i)):u._visibility&2?Hl(a,o,s,c,i):Ul(a,o),i&&l&2048&&Rl(o.alternate,o);break;case 24:Hl(a,o,s,c,i),i&&l&2048&&zl(o.alternate,o);break;default:Hl(a,o,s,c,i)}t=t.sibling}}function Ul(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Ul(n,r),i&2048&&Rl(r.alternate,r);break;case 24:Ul(n,r),i&2048&&zl(r.alternate,r);break;default:Ul(n,r)}t=t.sibling}}var Wl=8192;function Gl(e,t,n){if(e.subtreeFlags&Wl)for(e=e.child;e!==null;)Kl(e,t,n),e=e.sibling}function Kl(e,t,n){switch(e.tag){case 26:Gl(e,t,n),e.flags&Wl&&e.memoizedState!==null&&lp(n,jl,e.memoizedState,e.memoizedProps);break;case 5:Gl(e,t,n);break;case 3:case 4:var r=jl;jl=Pf(e.stateNode.containerInfo),Gl(e,t,n),jl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Wl,Wl=16777216,Gl(e,t,n),Wl=r):Gl(e,t,n));break;default:Gl(e,t,n)}}function ql(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Jl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];vl=r,Zl(r,e)}ql(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Yl(e),e=e.sibling}function Yl(e){switch(e.tag){case 0:case 11:case 15:Jl(e),e.flags&2048&&nl(9,e,e.return);break;case 3:Jl(e);break;case 12:Jl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Xl(e)):Jl(e);break;default:Jl(e)}}function Xl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];vl=r,Zl(r,e)}ql(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:nl(8,t,t.return),Xl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Xl(t));break;default:Xl(t)}e=e.sibling}}function Zl(e,t){for(;vl!==null;){var n=vl;switch(n.tag){case 0:case 11:case 15:nl(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:va(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,vl=r;else a:for(n=e;vl!==null;){r=vl;var i=r.sibling,a=r.return;if(xl(r),r===n){vl=null;break a}if(i!==null){i.return=a,vl=i;break a}vl=a}}}var Ql={getCacheForType:function(e){var t=ua(ga),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return ua(ga).controller.signal}},$l=typeof WeakMap==`function`?WeakMap:Map,j=0,eu=null,M=null,tu=0,nu=0,ru=null,iu=!1,au=!1,N=!1,ou=0,su=0,cu=0,lu=0,uu=0,du=0,fu=0,pu=null,mu=null,hu=!1,gu=0,_u=0,vu=1/0,yu=null,bu=null,xu=0,Su=null,Cu=null,wu=0,Tu=0,Eu=null,Du=null,Ou=0,ku=null;function Au(){return j&2&&tu!==0?tu&-tu:E.T===null?ft():kd()}function ju(){if(du===0)if(!(tu&536870912)||Ui){var e=Qe;Qe<<=1,!(Qe&3932160)&&(Qe=262144),du=e}else du=536870912;return e=po.current,e!==null&&(e.flags|=32),du}function Mu(e,t,n){(e===eu&&(nu===2||nu===9)||e.cancelPendingCommit!==null)&&(zu(e,0),Iu(e,tu,du,!1)),at(e,n),(!(j&2)||e!==eu)&&(e===eu&&(!(j&2)&&(lu|=n),su===4&&Iu(e,tu,du,!1)),xd(e))}function Nu(e,t,n){if(j&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||nt(e,t),a=r?qu(e,t):Gu(e,t,!0),o=r;do{if(a===0){au&&!r&&Iu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!Fu(n)){a=Gu(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=pu;var l=c.current.memoizedState.isDehydrated;if(l&&(zu(c,s).flags|=256),s=Gu(c,s,!1),s!==2){if(N&&!l){c.errorRecoveryDisabledLanes|=o,lu|=o,a=4;break a}o=mu,mu=a,o!==null&&(mu===null?mu=o:mu.push.apply(mu,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){zu(e,0),Iu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:Iu(r,t,du,!iu);break a;case 2:mu=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=gu+300-Fe(),10<a)){if(Iu(r,t,du,!iu),tt(r,0,!0)!==0)break a;wu=t,r.timeoutHandle=ff(Pu.bind(null,r,n,mu,yu,hu,t,du,lu,fu,iu,o,`Throttled`,-0,0),a);break a}Pu(r,n,mu,yu,hu,t,du,lu,fu,iu,o,null,-0,0)}}break}while(1);xd(e)}function Pu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:cn},Kl(t,a,d);var m=(a&62914560)===a?gu-Fe():(a&4194048)===a?_u-Fe():0;if(m=dp(d,m),m!==null){wu=a,e.cancelPendingCommit=m(ed.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),Iu(e,a,o,!l);return}}ed(e,t,a,n,r,i,o,s,c)}function Fu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Ar(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Iu(e,t,n,r){t&=~uu,t&=~lu,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-qe(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&st(e,n,t)}function Lu(){return j&6?!0:(Sd(0,!1),!1)}function Ru(){if(M!==null){if(nu===0)var e=M.return;else e=M,na=ta=null,Vo(e),Va=null,Ha=0,e=M;for(;e!==null;)el(e.alternate,e),e=e.return;M=null}}function zu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,pf(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),wu=0,Ru(),eu=e,M=n=vi(e.current,null),tu=t,nu=0,ru=null,iu=!1,au=nt(e,t),N=!1,fu=du=uu=lu=cu=su=0,mu=pu=null,hu=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-qe(r),a=1<<i;t|=e[i],r&=~a}return ou=t,ci(),n}function Bu(e,t){Co=null,E.H=Zs,t===ja||t===Na?(t=za(),nu=3):t===Ma?(t=za(),nu=4):nu=t===hc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,ru=t,M===null&&(su=1,lc(e,Ei(t,e.current)))}function Vu(){var e=po.current;return e===null?!0:(tu&4194048)===tu?mo===null:(tu&62914560)===tu||tu&536870912?e===mo:!1}function Hu(){var e=E.H;return E.H=Zs,e===null?Zs:e}function Uu(){var e=E.A;return E.A=Ql,e}function Wu(){su=4,iu||(tu&4194048)!==tu&&po.current!==null||(au=!0),!(cu&134217727)&&!(lu&134217727)||eu===null||Iu(eu,tu,du,!1)}function Gu(e,t,n){var r=j;j|=2;var i=Hu(),a=Uu();(eu!==e||tu!==t)&&(yu=null,zu(e,t)),t=!1;var o=su;a:do try{if(nu!==0&&M!==null){var s=M,c=ru;switch(nu){case 8:Ru(),o=6;break a;case 3:case 2:case 9:case 6:po.current===null&&(t=!0);var l=nu;if(nu=0,ru=null,Zu(e,s,c,l),n&&au){o=0;break a}break;default:l=nu,nu=0,ru=null,Zu(e,s,c,l)}}Ku(),o=su;break}catch(t){Bu(e,t)}while(1);return t&&e.shellSuspendCounter++,na=ta=null,j=r,E.H=i,E.A=a,M===null&&(eu=null,tu=0,ci()),o}function Ku(){for(;M!==null;)Yu(M)}function qu(e,t){var n=j;j|=2;var r=Hu(),a=Uu();eu!==e||tu!==t?(yu=null,vu=Fe()+500,zu(e,t)):au=nt(e,t);a:do try{if(nu!==0&&M!==null){t=M;var o=ru;b:switch(nu){case 1:nu=0,ru=null,Zu(e,t,o,1);break;case 2:case 9:if(Fa(o)){nu=0,ru=null,Xu(t);break}t=function(){nu!==2&&nu!==9||eu!==e||(nu=7),xd(e)},o.then(t,t);break a;case 3:nu=7;break a;case 4:nu=5;break a;case 7:Fa(o)?(nu=0,ru=null,Xu(t)):(nu=0,ru=null,Zu(e,t,o,7));break;case 5:var s=null;switch(M.tag){case 26:s=M.memoizedState;case 5:case 27:var c=M;if(s?cp(s):c.stateNode.complete){nu=0,ru=null;var l=c.sibling;if(l!==null)M=l;else{var u=c.return;u===null?M=null:(M=u,Qu(u))}break b}}nu=0,ru=null,Zu(e,t,o,5);break;case 6:nu=0,ru=null,Zu(e,t,o,6);break;case 8:Ru(),su=6;break a;default:throw Error(i(462))}}Ju();break}catch(t){Bu(e,t)}while(1);return na=ta=null,E.H=r,E.A=a,j=n,M===null?(eu=null,tu=0,ci(),su):0}function Ju(){for(;M!==null&&!Ne();)Yu(M)}function Yu(e){var t=Gc(e.alternate,e,ou);e.memoizedProps=e.pendingProps,t===null?Qu(e):M=t}function Xu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=kc(n,t,t.pendingProps,t.type,void 0,tu);break;case 11:t=kc(n,t,t.pendingProps,t.type.render,t.ref,tu);break;case 5:Vo(t);default:el(n,t),t=M=yi(t,ou),t=Gc(n,t,ou)}e.memoizedProps=e.pendingProps,t===null?Qu(e):M=t}function Zu(e,t,n,r){na=ta=null,Vo(t),Va=null,Ha=0;var i=t.return;try{if(mc(e,i,t,n,tu)){su=1,lc(e,Ei(n,e.current)),M=null;return}}catch(t){if(i!==null)throw M=i,t;su=1,lc(e,Ei(n,e.current)),M=null;return}t.flags&32768?(Ui||r===1?e=!0:au||tu&536870912?e=!1:(iu=e=!0,(r===2||r===9||r===3||r===6)&&(r=po.current,r!==null&&r.tag===13&&(r.flags|=16384))),$u(t,e)):Qu(t)}function Qu(e){var t=e;do{if(t.flags&32768){$u(t,iu);return}e=t.return;var n=Qc(t.alternate,t,ou);if(n!==null){M=n;return}if(t=t.sibling,t!==null){M=t;return}M=t=e}while(t!==null);su===0&&(su=5)}function $u(e,t){do{var n=$c(e.alternate,e);if(n!==null){n.flags&=32767,M=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){M=e;return}M=e=n}while(e!==null);su=6,M=null}function ed(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do ad();while(xu!==0);if(j&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=si,ot(e,n,o,s,c,l),e===eu&&(M=eu=null,tu=0),Cu=t,Su=e,wu=n,Tu=o,Eu=a,Du=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,md(ze,function(){return od(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=E.T,E.T=null,a=D.p,D.p=2,s=j,j|=4;try{yl(e,t,n)}finally{j=s,D.p=a,E.T=r}}xu=1,td(),nd(),rd()}}function td(){if(xu===1){xu=0;var e=Su,t=Cu,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=E.T,E.T=null;var r=D.p;D.p=2;var i=j;j|=4;try{Ml(t,e);var a=af,o=Fr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&Pr(s.ownerDocument.documentElement,s)){if(c!==null&&Ir(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Nr(s,h),v=Nr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}Tp=!!rf,af=rf=null}finally{j=i,D.p=r,E.T=n}}e.current=t,xu=2}}function nd(){if(xu===2){xu=0;var e=Su,t=Cu,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=E.T,E.T=null;var r=D.p;D.p=2;var i=j;j|=4;try{bl(e,t.alternate,t)}finally{j=i,D.p=r,E.T=n}}xu=3}}function rd(){if(xu===4||xu===3){xu=0,Pe();var e=Su,t=Cu,n=wu,r=Du;t.subtreeFlags&10256||t.flags&10256?xu=5:(xu=0,Cu=Su=null,id(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(bu=null),dt(n),t=t.stateNode,Ge&&typeof Ge.onCommitFiberRoot==`function`)try{Ge.onCommitFiberRoot(We,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=E.T,i=D.p,D.p=2,E.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{E.T=t,D.p=i}}wu&3&&ad(),xd(e),i=e.pendingLanes,n&261930&&i&42?e===ku?Ou++:(Ou=0,ku=e):Ou=0,Sd(0,!1)}}function id(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,va(t)))}function ad(){return td(),nd(),rd(),od()}function od(){if(xu!==5)return!1;var e=Su,t=Tu;Tu=0;var n=dt(wu),r=E.T,a=D.p;try{D.p=32>n?32:n,E.T=null,n=Eu,Eu=null;var o=Su,s=wu;if(xu=0,Cu=Su=null,wu=0,j&6)throw Error(i(331));var c=j;if(j|=4,Yl(o.current),Vl(o,o.current,s,n),j=c,Sd(0,!1),Ge&&typeof Ge.onPostCommitFiberRoot==`function`)try{Ge.onPostCommitFiberRoot(We,o)}catch{}return!0}finally{D.p=a,E.T=r,id(e,t)}}function sd(e,t,n){t=Ei(n,t),t=dc(e.stateNode,t,2),e=$a(e,t,2),e!==null&&(at(e,2),xd(e))}function cd(e,t,n){if(e.tag===3)sd(e,e,n);else for(;t!==null;){if(t.tag===3){sd(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(bu===null||!bu.has(r))){e=Ei(n,e),n=fc(2),r=$a(t,n,2),r!==null&&(pc(n,r,t,e),at(r,2),xd(r));break}}t=t.return}}function ld(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new $l;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(N=!0,i.add(n),e=ud.bind(null,e,t,n),t.then(e,e))}function ud(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,eu===e&&(tu&n)===n&&(su===4||su===3&&(tu&62914560)===tu&&300>Fe()-gu?!(j&2)&&zu(e,0):uu|=n,fu===tu&&(fu=0)),xd(e)}function dd(e,t){t===0&&(t=rt()),e=di(e,t),e!==null&&(at(e,t),xd(e))}function fd(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),dd(e,n)}function pd(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),dd(e,n)}function md(e,t){return je(e,t)}var hd=null,gd=null,_d=!1,vd=!1,yd=!1,bd=0;function xd(e){e!==gd&&e.next===null&&(gd===null?hd=gd=e:gd=gd.next=e),vd=!0,_d||(_d=!0,Od())}function Sd(e,t){if(!yd&&vd){yd=!0;do for(var n=!1,r=hd;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-qe(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Dd(r,a))}else a=tu,a=tt(r,r===eu?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||nt(r,a)||(n=!0,Dd(r,a));r=r.next}while(n);yd=!1}}function Cd(){wd()}function wd(){vd=_d=!1;var e=0;bd!==0&&df()&&(e=bd);for(var t=Fe(),n=null,r=hd;r!==null;){var i=r.next,a=Td(r,t);a===0?(r.next=null,n===null?hd=i:n.next=i,i===null&&(gd=n)):(n=r,(e!==0||a&3)&&(vd=!0)),r=i}xu!==0&&xu!==5||Sd(e,!1),bd!==0&&(bd=0)}function Td(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-qe(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=k(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=eu,n=tu,n=tt(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(nu===2||nu===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Me(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||nt(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Me(r),dt(n)){case 2:case 8:n=Re;break;case 32:n=ze;break;case 268435456:n=Ve;break;default:n=ze}return r=Ed.bind(null,e),n=je(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Me(r),e.callbackPriority=2,e.callbackNode=null,2}function Ed(e,t){if(xu!==0&&xu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(ad()&&e.callbackNode!==n)return null;var r=tu;return r=tt(e,e===eu?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Nu(e,r,t),Td(e,Fe()),e.callbackNode!=null&&e.callbackNode===n?Ed.bind(null,e):null)}function Dd(e,t){if(ad())return null;Nu(e,t,!0)}function Od(){hf(function(){j&6?je(Le,Cd):wd()})}function kd(){if(bd===0){var e=xa;e===0&&(e=Ze,Ze<<=1,!(Ze&261888)&&(Ze=256)),bd=e}return bd}function Ad(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:sn(``+e)}function P(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function jd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Ad((i[gt]||null).action),o=r.submitter;o&&(t=(t=o[gt]||null)?Ad(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new kn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(bd!==0){var e=o?P(i,o):new FormData(i);Ls(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?P(i,o):new FormData(i),Ls(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Md=0;Md<ni.length;Md++){var Nd=ni[Md];ri(Nd.toLowerCase(),`on`+(Nd[0].toUpperCase()+Nd.slice(1)))}ri(Jr,`onAnimationEnd`),ri(Yr,`onAnimationIteration`),ri(Xr,`onAnimationStart`),ri(`dblclick`,`onDoubleClick`),ri(`focusin`,`onFocus`),ri(`focusout`,`onBlur`),ri(Zr,`onTransitionRun`),ri(Qr,`onTransitionStart`),ri($r,`onTransitionCancel`),ri(ei,`onTransitionEnd`),Mt(`onMouseEnter`,[`mouseout`,`mouseover`]),Mt(`onMouseLeave`,[`mouseout`,`mouseover`]),Mt(`onPointerEnter`,[`pointerout`,`pointerover`]),Mt(`onPointerLeave`,[`pointerout`,`pointerover`]),jt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),jt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),jt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),jt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),jt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),jt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var Pd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),Fd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Pd));function Id(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){ii(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){ii(e)}i.currentTarget=null,a=c}}}}function Ld(e,t){var n=t[vt];n===void 0&&(n=t[vt]=new Set);var r=e+`__bubble`;n.has(r)||(Vd(t,e,2,!1),n.add(r))}function Rd(e,t,n){var r=0;t&&(r|=4),Vd(n,e,r,t)}var zd=`_reactListening`+Math.random().toString(36).slice(2);function Bd(e){if(!e[zd]){e[zd]=!0,kt.forEach(function(t){t!==`selectionchange`&&(Fd.has(t)||Rd(t,!1,e),Rd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[zd]||(t[zd]=!0,Rd(`selectionchange`,!1,t))}}function Vd(e,t,n,r){switch(Mp(t)){case 2:var i=Ep;break;case 8:i=Dp;break;default:i=Op}n=i.bind(null,t,n,e),i=void 0,!vn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Hd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=wt(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}hn(function(){var r=a,i=un(n),s=[];a:{var c=ti.get(e);if(c!==void 0){var l=kn,u=e;switch(e){case`keypress`:if(wn(n)===0)break a;case`keydown`:case`keyup`:l=qn;break;case`focusin`:u=`focus`,l=Rn;break;case`focusout`:u=`blur`,l=Rn;break;case`beforeblur`:case`afterblur`:l=Rn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=In;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Ln;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Yn;break;case Jr:case Yr:case Xr:l=zn;break;case ei:l=Xn;break;case`scroll`:case`scrollend`:l=jn;break;case`wheel`:l=Zn;break;case`copy`:case`cut`:case`paste`:l=Bn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Jn;break;case`toggle`:case`beforetoggle`:l=Qn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=gn(m,p),g!=null&&d.push(Ud(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==ln&&(u=n.relatedTarget||n.fromElement)&&(wt(u)||u[_t]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?wt(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=In,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Jn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:Et(l),h=u==null?c:Et(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,wt(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Gd,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Kd(s,c,l,d,!1),u!==null&&f!==null&&Kd(s,f,u,d,!0)}}a:{if(c=r?Et(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=vr;else if(fr(c))if(yr)v=Or;else{v=Er;var y=Tr}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&rn(r.elementType)&&(v=vr):v=Dr;if(v&&=v(e,r)){pr(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Xt(c,`number`,c.value)}switch(y=r?Et(r):window,e){case`focusin`:(fr(y)||y.contentEditable===`true`)&&(Rr=y,zr=r,Br=null);break;case`focusout`:Br=zr=Rr=null;break;case`mousedown`:Vr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Vr=!1,Hr(s,n,i);break;case`selectionchange`:if(Lr)break;case`keydown`:case`keyup`:Hr(s,n,i)}var b;if(er)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else cr?or(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(rr&&n.locale!==`ko`&&(cr||x!==`onCompositionStart`?x===`onCompositionEnd`&&cr&&(b=Cn()):(bn=i,xn=`value`in bn?bn.value:bn.textContent,cr=!0)),y=Wd(r,x),0<y.length&&(x=new Vn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=sr(n),b!==null&&(x.data=b)))),(b=nr?lr(e,n):ur(e,n))&&(x=Wd(r,`onBeforeInput`),0<x.length&&(y=new Vn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),jd(s,e,r,n,i)}Id(s,t)})}function Ud(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Wd(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=gn(e,n),i!=null&&r.unshift(Ud(e,i,a)),i=gn(e,t),i!=null&&r.push(Ud(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Gd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Kd(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=gn(n,a),l!=null&&o.unshift(Ud(n,l,c))):i||(l=gn(n,a),l!=null&&o.push(Ud(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var qd=/\r\n?/g,Jd=/\u0000|\uFFFD/g;function Yd(e){return(typeof e==`string`?e:``+e).replace(qd,`
|
|
10
|
+
`).replace(Jd,``)}function Xd(e,t){return t=Yd(t),Yd(e)===t}function Zd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||en(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&en(e,``+r);break;case`className`:Rt(e,`class`,r);break;case`tabIndex`:Rt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Rt(e,n,r);break;case`style`:nn(e,r,o);break;case`data`:if(t!==`object`){Rt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=sn(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Zd(e,t,`name`,a.name,a,null),Zd(e,t,`formEncType`,a.formEncType,a,null),Zd(e,t,`formMethod`,a.formMethod,a,null),Zd(e,t,`formTarget`,a.formTarget,a,null)):(Zd(e,t,`encType`,a.encType,a,null),Zd(e,t,`method`,a.method,a,null),Zd(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=sn(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=cn);break;case`onScroll`:r!=null&&Ld(`scroll`,e);break;case`onScrollEnd`:r!=null&&Ld(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=sn(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Ld(`beforetoggle`,e),Ld(`toggle`,e),Lt(e,`popover`,r);break;case`xlinkActuate`:zt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:zt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:zt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:zt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:zt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:zt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:zt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:zt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:zt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Lt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=an.get(n)||n,Lt(e,n,r))}}function Qd(e,t,n,r,a,o){switch(n){case`style`:nn(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?en(e,r):(typeof r==`number`||typeof r==`bigint`)&&en(e,``+r);break;case`onScroll`:r!=null&&Ld(`scroll`,e);break;case`onScrollEnd`:r!=null&&Ld(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=cn);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!At.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[gt]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):Lt(e,n,r)}}}function $d(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Ld(`error`,e),Ld(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Zd(e,t,o,s,n,null)}}a&&Zd(e,t,`srcSet`,n.srcSet,n,null),r&&Zd(e,t,`src`,n.src,n,null);return;case`input`:Ld(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Zd(e,t,r,d,n,null)}}Yt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Ld(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Zd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Zt(e,!!r,n,!0):Zt(e,!!r,t,!1);return;case`textarea`:for(s in Ld(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Zd(e,t,s,c,n,null)}$t(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Zd(e,t,l,r,n,null)}return;case`dialog`:Ld(`beforetoggle`,e),Ld(`toggle`,e),Ld(`cancel`,e),Ld(`close`,e);break;case`iframe`:case`object`:Ld(`load`,e);break;case`video`:case`audio`:for(r=0;r<Pd.length;r++)Ld(Pd[r],e);break;case`image`:Ld(`error`,e),Ld(`load`,e);break;case`details`:Ld(`toggle`,e);break;case`embed`:case`source`:case`link`:Ld(`error`,e),Ld(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Zd(e,t,u,r,n,null)}return;default:if(rn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Qd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Zd(e,t,c,r,n,null))}function ef(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Zd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Zd(e,t,p,m,r,f)}}Jt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Zd(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Zd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Zt(e,!!n,n?[]:``,!1):Zt(e,!!n,t,!0)):Zt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Zd(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Zd(e,t,s,a,r,o)}Qt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Zd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Zd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Zd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Zd(e,t,u,p,r,m)}return;default:if(rn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Qd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Qd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Zd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Zd(e,t,f,p,r,m)}function tf(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function nf(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&tf(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&tf(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var rf=null,af=null;function of(e){return e.nodeType===9?e:e.ownerDocument}function sf(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function cf(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function lf(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var uf=null;function df(){var e=window.event;return e&&e.type===`popstate`?e===uf?!1:(uf=e,!0):(uf=null,!1)}var ff=typeof setTimeout==`function`?setTimeout:void 0,pf=typeof clearTimeout==`function`?clearTimeout:void 0,mf=typeof Promise==`function`?Promise:void 0,hf=typeof queueMicrotask==`function`?queueMicrotask:mf===void 0?ff:function(e){return mf.resolve(null).then(e).catch(gf)};function gf(e){setTimeout(function(){throw e})}function _f(e){return e===`head`}function vf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Zp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)jf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,jf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[St]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&jf(e.ownerDocument.body);n=i}while(n);Zp(t)}function yf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function bf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:bf(n),Ct(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function xf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[St])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=Ef(e.nextSibling),e===null)break}return null}function Sf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=Ef(e.nextSibling),e===null))return null;return e}function Cf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=Ef(e.nextSibling),e===null))return null;return e}function wf(e){return e.data===`$?`||e.data===`$~`}function F(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function Tf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function Ef(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var Df=null;function Of(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return Ef(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function kf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function Af(e,t,n){switch(t=of(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function jf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Ct(e)}var Mf=new Map,Nf=new Set;function Pf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Ff=D.d;D.d={f:If,r:Lf,D:Bf,C:Vf,L:Hf,m:Uf,X:Gf,S:Wf,M:Kf};function If(){var e=Ff.f(),t=Lu();return e||t}function Lf(e){var t=Tt(e);t!==null&&t.tag===5&&t.type===`form`?zs(t):Ff.r(e)}var Rf=typeof document>`u`?null:document;function zf(e,t,n){var r=Rf;if(r&&typeof t==`string`&&t){var i=qt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Nf.has(i)||(Nf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),$d(t,`link`,e),Ot(t),r.head.appendChild(t)))}}function Bf(e){Ff.D(e),zf(`dns-prefetch`,e,null)}function Vf(e,t){Ff.C(e,t),zf(`preconnect`,e,t)}function Hf(e,t,n){Ff.L(e,t,n);var r=Rf;if(r&&e&&t){var i=`link[rel="preload"][as="`+qt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+qt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+qt(n.imageSizes)+`"]`)):i+=`[href="`+qt(e)+`"]`;var a=i;switch(t){case`style`:a=Jf(e);break;case`script`:a=Qf(e)}Mf.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),Mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Yf(a))||t===`script`&&r.querySelector($f(a))||(t=r.createElement(`link`),$d(t,`link`,e),Ot(t),r.head.appendChild(t)))}}function Uf(e,t){Ff.m(e,t);var n=Rf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+qt(r)+`"][href="`+qt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Qf(e)}if(!Mf.has(a)&&(e=m({rel:`modulepreload`,href:e},t),Mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector($f(a)))return}r=n.createElement(`link`),$d(r,`link`,e),Ot(r),n.head.appendChild(r)}}}function Wf(e,t,n){Ff.S(e,t,n);var r=Rf;if(r&&e){var i=Dt(r).hoistableStyles,a=Jf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Yf(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=Mf.get(a))&&np(e,n);var c=o=r.createElement(`link`);Ot(c),$d(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,tp(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Gf(e,t){Ff.X(e,t);var n=Rf;if(n&&e){var r=Dt(n).hoistableScripts,i=Qf(e),a=r.get(i);a||(a=n.querySelector($f(i)),a||(e=m({src:e,async:!0},t),(t=Mf.get(i))&&rp(e,t),a=n.createElement(`script`),Ot(a),$d(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Kf(e,t){Ff.M(e,t);var n=Rf;if(n&&e){var r=Dt(n).hoistableScripts,i=Qf(e),a=r.get(i);a||(a=n.querySelector($f(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=Mf.get(i))&&rp(e,t),a=n.createElement(`script`),Ot(a),$d(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function qf(e,t,n,r){var a=(a=_e.current)?Pf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Jf(n.href),n=Dt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Jf(n.href);var o=Dt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Yf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),Mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Mf.set(e,n),o||Zf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Qf(n),n=Dt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Jf(e){return`href="`+qt(e)+`"`}function Yf(e){return`link[rel="stylesheet"][`+e+`]`}function Xf(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Zf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),$d(t,`link`,n),Ot(t),e.head.appendChild(t))}function Qf(e){return`[src="`+qt(e)+`"]`}function $f(e){return`script[async]`+e}function ep(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+qt(n.href)+`"]`);if(r)return t.instance=r,Ot(r),r;var a=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Ot(r),$d(r,`style`,a),tp(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Jf(n.href);var o=e.querySelector(Yf(a));if(o)return t.state.loading|=4,t.instance=o,Ot(o),o;r=Xf(n),(a=Mf.get(a))&&np(r,a),o=(e.ownerDocument||e).createElement(`link`),Ot(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),$d(o,`link`,r),t.state.loading|=4,tp(o,n.precedence,e),t.instance=o;case`script`:return o=Qf(n.src),(a=e.querySelector($f(o)))?(t.instance=a,Ot(a),a):(r=n,(a=Mf.get(o))&&(r=m({},n),rp(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Ot(a),$d(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,tp(r,n.precedence,e));return t.instance}function tp(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function np(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function rp(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var ip=null;function ap(e,t,n){if(ip===null){var r=new Map,i=ip=new Map;i.set(n,r)}else i=ip,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[St]||a[ht]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function op(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function sp(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function cp(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function lp(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Jf(r.href),a=t.querySelector(Yf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=fp.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Ot(a);return}a=t.ownerDocument||t,r=Xf(r),(i=Mf.get(i))&&np(r,i),a=a.createElement(`link`),Ot(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),$d(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=fp.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var up=0;function dp(e,t){return e.stylesheets&&e.count===0&&mp(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&mp(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&up===0&&(up=62500*nf());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&mp(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>up?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function fp(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)mp(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var pp=null;function mp(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,pp=new Map,t.forEach(hp,e),pp=null,fp.call(e))}function hp(e,t){if(!(t.state.loading&4)){var n=pp.get(e);if(n)var r=n.get(null);else{n=new Map,pp.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=fp.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var gp={$$typeof:ee,Provider:null,Consumer:null,_currentValue:ue,_currentValue2:ue,_threadCount:0};function _p(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=it(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=it(0),this.hiddenUpdates=it(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function vp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new _p(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=gi(3,null,null,t),e.current=a,a.stateNode=e,t=_a(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Xa(a),e}function yp(e){return e?(e=mi,e):mi}function bp(e,t,n,r,i,a){i=yp(i),r.context===null?r.context=i:r.pendingContext=i,r=Qa(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=$a(e,r,t),n!==null&&(Mu(n,e,t),eo(n,e,t))}function xp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Sp(e,t){xp(e,t),(e=e.alternate)&&xp(e,t)}function Cp(e){if(e.tag===13||e.tag===31){var t=di(e,67108864);t!==null&&Mu(t,e,67108864),Sp(e,67108864)}}function wp(e){if(e.tag===13||e.tag===31){var t=Au();t=ut(t);var n=di(e,t);n!==null&&Mu(n,e,t),Sp(e,t)}}var Tp=!0;function Ep(e,t,n,r){var i=E.T;E.T=null;var a=D.p;try{D.p=2,Op(e,t,n,r)}finally{D.p=a,E.T=i}}function Dp(e,t,n,r){var i=E.T;E.T=null;var a=D.p;try{D.p=8,Op(e,t,n,r)}finally{D.p=a,E.T=i}}function Op(e,t,n,r){if(Tp){var i=kp(r);if(i===null)Hd(e,t,r,Ap,n),Vp(e,r);else if(Up(i,e,t,n,r))r.stopPropagation();else if(Vp(e,r),t&4&&-1<Bp.indexOf(e)){for(;i!==null;){var a=Tt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=et(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-qe(o);s.entanglements[1]|=c,o&=~c}xd(a),!(j&6)&&(vu=Fe()+500,Sd(0,!1))}}break;case 31:case 13:s=di(a,2),s!==null&&Mu(s,a,2),Lu(),Sp(a,2)}if(a=kp(r),a===null&&Hd(e,t,r,Ap,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Hd(e,t,r,null,n)}}function kp(e){return e=un(e),jp(e)}var Ap=null;function jp(e){if(Ap=null,e=wt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Ap=e,null}function Mp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Ie()){case Le:return 2;case Re:return 8;case ze:case Be:return 32;case Ve:return 268435456;default:return 32}default:return 32}}var Np=!1,Pp=null,Fp=null,Ip=null,Lp=new Map,Rp=new Map,zp=[],Bp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Vp(e,t){switch(e){case`focusin`:case`focusout`:Pp=null;break;case`dragenter`:case`dragleave`:Fp=null;break;case`mouseover`:case`mouseout`:Ip=null;break;case`pointerover`:case`pointerout`:Lp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Rp.delete(t.pointerId)}}function Hp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Tt(t),t!==null&&Cp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Up(e,t,n,r,i){switch(t){case`focusin`:return Pp=Hp(Pp,e,t,n,r,i),!0;case`dragenter`:return Fp=Hp(Fp,e,t,n,r,i),!0;case`mouseover`:return Ip=Hp(Ip,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Lp.set(a,Hp(Lp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Rp.set(a,Hp(Rp.get(a)||null,e,t,n,r,i)),!0}return!1}function Wp(e){var t=wt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,pt(e.priority,function(){wp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,pt(e.priority,function(){wp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Gp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=kp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);ln=r,n.target.dispatchEvent(r),ln=null}else return t=Tt(n),t!==null&&Cp(t),e.blockedOn=n,!1;t.shift()}return!0}function Kp(e,t,n){Gp(e)&&n.delete(t)}function qp(){Np=!1,Pp!==null&&Gp(Pp)&&(Pp=null),Fp!==null&&Gp(Fp)&&(Fp=null),Ip!==null&&Gp(Ip)&&(Ip=null),Lp.forEach(Kp),Rp.forEach(Kp)}function Jp(e,n){e.blockedOn===n&&(e.blockedOn=null,Np||(Np=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,qp)))}var Yp=null;function Xp(e){Yp!==e&&(Yp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Yp===e&&(Yp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(jp(r||n)===null)continue;break}var a=Tt(n);a!==null&&(e.splice(t,3),t-=3,Ls(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Zp(e){function t(t){return Jp(t,e)}Pp!==null&&Jp(Pp,e),Fp!==null&&Jp(Fp,e),Ip!==null&&Jp(Ip,e),Lp.forEach(t),Rp.forEach(t);for(var n=0;n<zp.length;n++){var r=zp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<zp.length&&(n=zp[0],n.blockedOn===null);)Wp(n),n.blockedOn===null&&zp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[gt]||null;if(typeof a==`function`)o||Xp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[gt]||null)s=o.formAction;else if(jp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Xp(n)}}}function Qp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function $p(e){this._internalRoot=e}em.prototype.render=$p.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;bp(n,Au(),e,t,null,null)},em.prototype.unmount=$p.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;bp(e.current,2,null,e,null,null),Lu(),t[_t]=null}};function em(e){this._internalRoot=e}em.prototype.unstable_scheduleHydration=function(e){if(e){var t=ft();e={blockedOn:null,target:e,priority:t};for(var n=0;n<zp.length&&t!==0&&t<zp[n].priority;n++);zp.splice(n,0,e),n===0&&Wp(e)}};var tm=n.version;if(tm!==`19.2.4`)throw Error(i(527,tm,`19.2.4`));D.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:f(e),e=e===null?null:e.stateNode,e};var nm={bundleType:0,version:`19.2.4`,rendererPackageName:`react-dom`,currentDispatcherRef:E,reconcilerVersion:`19.2.4`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var rm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!rm.isDisabled&&rm.supportsFiber)try{We=rm.inject(nm),Ge=rm}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=oc,s=sc,c=cc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=vp(e,1,!1,null,null,n,r,null,o,s,c,Qp),e[_t]=t.current,Bd(e),new $p(t)}})),_=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=g()})),v=l(p(),1),y=l(_(),1),b=new class{initialized=!1;scope;blocked=!1;enter(e){if(e!==void 0&&!e.trim())throw Error(`authorizationScopeKey must be non-empty`);return this.blocked?`reload`:this.initialized&&this.scope!==e?(this.blocked=!0,`reload`):(this.initialized=!0,this.scope=e,`ready`)}matches(e){return this.initialized&&!this.blocked&&this.scope===e}key(e){return this.scope===void 0?e:`ksadk:authorization:${encodeURIComponent(this.scope)}:${e}`}get writable(){return!this.blocked}},x=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))},o=t=e(r,i,a);return a},S=(e=>e?x(e):x),ee=e=>e;function C(e,t=ee){let n=v.useSyncExternalStore(e.subscribe,v.useCallback(()=>t(e.getState()),[e,t]),v.useCallback(()=>t(e.getInitialState()),[e,t]));return v.useDebugValue(n),n}var w=e=>{let t=S(e),n=e=>C(t,e);return Object.assign(n,t),n},te=(e=>e?w(e):w);function ne(e=new Set,t=[]){let n=new Set(e);for(let e of t){let t=Number(e);Number.isFinite(t)&&t>0&&n.add(t)}return new Set(Array.from(n).sort((e,t)=>e-t))}function T({sessionsLength:e=0,total:t=0,page:n=0,pageSize:r=30,loadedPages:i=new Set}={}){let a=Math.max(0,Number(t)||0),o=Math.max(0,Number(e)||0);return{total:a,page:Math.max(0,Number(n)||0),pageSize:Math.max(1,Number(r)||30),loadedPages:ne(i),hasMore:o<a}}function re({total:e=0,pageSize:t=30,loadedPages:n=new Set}={}){let r=Math.max(0,Number(e)||0),i=Math.max(1,Number(t)||30);if(r<=0)return null;let a=Math.ceil(r/i);for(let e=1;e<=a;e+=1)if(!n.has(e))return e;return null}function ie(e){let t=e.UpdatedAt;if(typeof t==`string`){let e=Date.parse(t);return Number.isNaN(e)?0:e}return typeof t==`number`&&Number.isFinite(t)?t>1e11?t:t*1e3:0}var ae=`ksadk.pinnedSessionIds`;function oe(){try{let e=globalThis.localStorage?.getItem(b.key(ae)),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function se(e){if(b.writable)try{globalThis.localStorage?.setItem(b.key(ae),JSON.stringify(e))}catch{}}function ce(e,t){let n=new Set(t);return e.slice().sort((e,t)=>{let r=+!!n.has(e.SessionId),i=+!!n.has(t.SessionId);return r===i?ie(t)-ie(e):i-r})}function le(e,t,n){let r=new Map;for(let t of e)t?.SessionId&&r.set(t.SessionId,t);for(let e of t)e?.SessionId&&r.set(e.SessionId,{...r.get(e.SessionId)||{},...e});return ce(Array.from(r.values()),n)}var E=te()(e=>({sessions:[],currentSessionId:null,sessionsAgentId:``,sessionsTotal:0,sessionsPage:0,sessionsPageSize:30,loadedPages:new Set,hasMoreSessions:!1,isLoadingSessions:!0,pinnedSessionIds:oe(),messageHistory:{},setSessions:t=>e(e=>({sessions:ce(t,e.pinnedSessionIds)})),setCurrentSessionId:t=>e({currentSessionId:t}),upsertSessions:(t,n)=>e(e=>{let r=le(n?.replace?[]:e.sessions,t,e.pinnedSessionIds),i=n?.page??e.sessionsPage,a=n?.pageSize??e.sessionsPageSize,o=n?.total??Math.max(e.sessionsTotal,r.length),s=n?.replace?ne(new Set,[i]):ne(e.loadedPages,[i]),c=T({sessionsLength:r.length,total:o,page:i,pageSize:a,loadedPages:s});return{sessions:r,sessionsAgentId:n?.agentId??e.sessionsAgentId,sessionsTotal:c.total,sessionsPage:c.page,sessionsPageSize:c.pageSize,loadedPages:c.loadedPages,hasMoreSessions:c.hasMore}}),removeSession:t=>e(e=>{let n=e.sessions.filter(e=>e.SessionId!==t),r=Math.max(0,e.sessionsTotal-1);return{sessions:n,sessionsTotal:r,hasMoreSessions:T({sessionsLength:n.length,total:r,page:e.sessionsPage,pageSize:e.sessionsPageSize,loadedPages:e.loadedPages}).hasMore,pinnedSessionIds:e.pinnedSessionIds.filter(e=>e!==t)}}),setLoadingSessions:t=>e({isLoadingSessions:t}),resetSessionPagination:t=>e({sessions:[],sessionsAgentId:t,sessionsTotal:0,sessionsPage:0,loadedPages:new Set,hasMoreSessions:!1,isLoadingSessions:!1}),togglePinnedSession:t=>e(e=>{let n=new Set(e.pinnedSessionIds);n.has(t)?n.delete(t):n.add(t);let r=Array.from(n);return se(r),{pinnedSessionIds:r,sessions:ce(e.sessions,r)}}),setSessionMessageHistory:(t,n)=>e(e=>({messageHistory:{...e.messageHistory,[t]:{nextCursor:n.nextCursor,hasMore:n.hasMore,isLoadingInitial:!1,isLoadingOlder:n.isLoadingOlder??!1}}})),setSessionInitialMessageHistoryLoading:(t,n)=>e(e=>{let r=e.messageHistory[t];return{messageHistory:{...e.messageHistory,[t]:{nextCursor:r?.nextCursor??null,hasMore:r?.hasMore??!1,isLoadingInitial:n,isLoadingOlder:r?.isLoadingOlder??!1}}}}),setSessionMessageHistoryLoading:(t,n)=>e(e=>{let r=e.messageHistory[t];return r?{messageHistory:{...e.messageHistory,[t]:{...r,isLoadingOlder:n}}}:{}}),clearSessionMessageHistory:t=>e(e=>{if(!t)return{messageHistory:{}};let n={...e.messageHistory};return delete n[t],{messageHistory:n}})})),D=`ksadk.web.permission-mode`;function ue(){try{let e=globalThis.localStorage?.getItem(b.key(D));return e===`ask`||e===`full`||e===`risk`?e:`risk`}catch{return`risk`}}function de(e){if(b.writable)try{globalThis.localStorage?.setItem(b.key(D),e)}catch{}}var fe=te()(e=>({permissionMode:ue(),setPermissionMode:t=>{de(t),e({permissionMode:t})}})),pe=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),me=o(((e,t)=>{t.exports=pe()})),O=me();function he(){return(0,O.jsx)(`div`,{className:`ksadk-web`,children:(0,O.jsx)(`div`,{role:`status`,className:`fixed inset-0 flex items-center justify-center bg-background text-sm text-text-muted`,children:`正在初始化会话身份…`})})}function ge({authorizationScopeKey:e,children:t}){let[n,r]=(0,v.useState)(!1);return(0,v.useLayoutEffect)(()=>{if(b.enter(e)===`reload`){window.location.reload();return}E.setState({pinnedSessionIds:oe()}),fe.setState({permissionMode:ue()}),r(!0)},[e]),!n||!b.matches(e)?(0,O.jsx)(he,{}):t}function _e(e,t){return typeof t==`function`?t(e):t}var ve=te()(e=>({sidebarOpen:!0,mobileSidebarOpen:!1,mobileActionsOpen:!1,workspacePanelOpen:!1,workspacePanelWidth:820,workspacePanelFullscreen:!1,input:``,attachments:[],previewAttachment:null,previewImageSize:null,queuedDrafts:[],toasts:[],toggleSidebar:()=>e(e=>({sidebarOpen:!e.sidebarOpen})),setSidebarOpen:t=>e({sidebarOpen:t}),toggleMobileSidebar:()=>e(e=>({mobileSidebarOpen:!e.mobileSidebarOpen})),setMobileSidebarOpen:t=>e({mobileSidebarOpen:t}),toggleMobileActions:()=>e(e=>({mobileActionsOpen:!e.mobileActionsOpen})),setMobileActionsOpen:t=>e({mobileActionsOpen:t}),setWorkspacePanelOpen:t=>e({workspacePanelOpen:t}),setWorkspacePanelWidth:t=>e({workspacePanelWidth:t}),setWorkspacePanelFullscreen:t=>e({workspacePanelFullscreen:t}),setInput:t=>e({input:t}),setAttachments:t=>e(e=>({attachments:_e(e.attachments,t)})),setPreviewAttachment:t=>e({previewAttachment:t}),setPreviewImageSize:t=>e({previewImageSize:t}),setQueuedDrafts:t=>e(e=>({queuedDrafts:_e(e.queuedDrafts,t)})),pushToast:(t,n=`info`)=>e(e=>({toasts:[...e.toasts,{id:String(Date.now()+Math.random()),message:t,variant:n,createdAt:Date.now()}]})),dismissToast:t=>e(e=>({toasts:e.toasts.filter(e=>e.id!==t)}))})),ye=[`cancel`,`pause`,`resume`,`submit_interaction`,`attach`,`steer`,`inject`,`checkpoint`,`durable_restore`],be=[`goal`,`loop`,`plan`],xe=new Set([`native`,`emulated`,`unavailable`]),Se=new Set([`supported`,`mode`,`reason`]),Ce=new Set([`schema_version`,...ye,...be]);function we(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`${t} must be an object`);return e}function Te(e,t){let n=we(e,t);if(typeof n.supported!=`boolean`)throw Error(`${t}.supported must be a boolean`);if(!xe.has(n.mode))throw Error(`${t}.mode must be native, emulated, or unavailable`);if(n.reason!==void 0&&n.reason!==null&&(typeof n.reason!=`string`||n.reason.length===0))throw Error(`${t}.reason must be a non-empty string or null`);if(!n.supported&&(n.mode!==`unavailable`||!n.reason))throw Error(`${t}: unsupported capability requires mode=unavailable and reason`);return{supported:n.supported,mode:n.mode,reason:n.reason??null,extensions:Object.fromEntries(Object.entries(n).filter(([e])=>!Se.has(e)))}}function Ee(e){let t=we(e,`RuntimeCapabilityMatrix/v1`);if(t.schema_version!==1)throw Error(`schema_version must equal 1`);for(let e of ye)if(!(e in t))throw Error(`${e} is required`);let n={schema_version:1,extensions:Object.fromEntries(Object.entries(t).filter(([e])=>!Ce.has(e)))};for(let e of ye)n[e]=Te(t[e],e);for(let e of be)t[e]!==void 0&&t[e]!==null&&(n[e]=Te(t[e],e));return n}var De=[`responses`,`chat_completions`],Oe=new Map([[`openclaw`,`OpenClaw`],[`hermes`,`Hermes`]]);function ke(e){return String(e||``).trim().toLowerCase()}function Ae(...e){for(let t of e){let e=ke(t);if(e)return e}return``}function je(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Me(e){if(!Array.isArray(e))return De;let t=e.filter(e=>e===`responses`||e===`chat_completions`);return t.length>0?t:De}function Ne(e,t){return typeof e==`boolean`?e:t}function Pe(e){return Array.isArray(e)?e.map(e=>je(e)).filter(e=>typeof e.name==`string`&&e.name.trim()).map(e=>{let t={...e,name:e.name.trim(),group:typeof e.group==`string`?e.group:``,risk_level:typeof e.risk_level==`string`?e.risk_level:`low`,requires_approval:!!e.requires_approval,side_effects:Array.isArray(e.side_effects)?e.side_effects.filter(e=>typeof e==`string`):[],enabled:Ne(e.enabled,!0)};return typeof e.description==`string`&&(t.description=e.description),t}):[]}function Fe(e){let t=je(e),n=Array.isArray(t.Modes)?t.Modes.filter(e=>[`ask`,`risk`,`full`].includes(e)):[`ask`,`risk`,`full`],r=n.length>0?[...new Set(n)]:[`ask`,`risk`,`full`];return{Modes:r,DefaultMode:r.includes(t.DefaultMode)?t.DefaultMode:`risk`,RuntimeOverride:Ne(t.RuntimeOverride,!0)}}function Ie(e){if(e!=null)try{return Ee(e)}catch{return}}function Le(e,t){if(t!=null||Ae(je(e.Agent).Framework,e.Framework)!==`codex`)return;let n={supported:!1,mode:`unavailable`,reason:`legacy_bootstrap_not_advertised`,extensions:{}},r={supported:!0,mode:`emulated`,extensions:{}};return{schema_version:1,cancel:{...n},pause:{...n},resume:{...n},submit_interaction:{...n},attach:{...n},steer:{...n},inject:{...n},checkpoint:{...n},durable_restore:{...n},goal:{...r},plan:{...r},extensions:{compatibility:`legacy-codex`}}}function Re(e){return Array.isArray(e)?e.flatMap(e=>{let t=je(e),n=String(t.Protocol||``).trim().toLowerCase(),r=String(t.Endpoint||``).trim();if(![`ag-ui`,`responses`].includes(n)||!r.startsWith(`/`))return[];let i=je(t.Capabilities);return[{Protocol:n,Runtime:String(t.Runtime||``).trim(),Endpoint:r,Version:String(t.Version||``).trim(),Capabilities:{A2UI:!!i.A2UI,Interrupt:!!i.Interrupt,Cancel:!!i.Cancel}}]}):[]}function ze(e){let t=e?.Data||e||{},n=je(t.Capabilities),r=je(t.HostedRuntime),i=Ae(t.Agent?.Framework,r.Framework,r.Type),a=Oe.get(i)||``,o=Me(t.ApiFormats||n.HostedChat?.ApiFormats),s=i!==`openclaw`,c=!!a,l=!!a,u=je(n.HostedChat),d=je(n.NativeDashboard),f=je(n.NativeTerminal),p=je(n.RunLifecycle),m=je(t.HostedChat),h=Re(u.Transports||m.Transports),g=String(u.PreferredTransport||m.PreferredTransport||`responses`).trim().toLowerCase(),_=h.some(e=>e.Protocol===g)?g:`responses`,v=Ne(u.Enabled,s),y=Ne(d.Enabled,c),b=Ne(f.Enabled,l),x=Ne(p.Enabled,v),S=!!(n.interaction_v1?.enabled??n.Interaction?.V1??n.InteractionV1??!1),ee=n.RuntimeCapabilityMatrix??t.RuntimeCapabilityMatrix,C=Ie(ee)??Le(t,ee),w=n.ApprovalPolicy!==void 0&&n.ApprovalPolicy!==null;return{...n,Approval:Ne(n.Approval,w),RuntimeCapabilityMatrix:C,InteractionV1:S,ContextCompaction:n.ContextCompaction===!0,HostedChat:{Enabled:v,ApiFormats:Me(u.ApiFormats||o),PreferredTransport:_,Transports:h},NativeDashboard:{Enabled:y,Href:typeof d.Href==`string`?d.Href:y?`/`:null,Label:typeof d.Label==`string`?d.Label:y?`管理平台`:null},NativeTerminal:{Enabled:b,Mode:typeof f.Mode==`string`?f.Mode:b?`tui`:null,Protocol:typeof f.Protocol==`string`?f.Protocol:`ks-terminal.v1`,Path:typeof f.Path==`string`?f.Path:`/_ksadk/terminal/ws`},RunLifecycle:{Enabled:x,Resume:Ne(p.Resume,x),Abort:Ne(p.Abort,x),Checkpoints:Ne(p.Checkpoints,!1),CheckpointResume:Ne(p.CheckpointResume,!1),CheckpointResumePreview:Ne(p.CheckpointResumePreview,!1)},ApprovalPolicy:Fe(n.ApprovalPolicy),BuiltinTools:Pe(n.BuiltinTools)}}function Be(e){return ze({Data:{Capabilities:e}}).HostedChat.Enabled}function Ve(e,t={}){let n=ze({Data:{Capabilities:e}}).HostedChat,r=n.Transports.find(e=>e.Protocol===n.PreferredTransport),i=n.Transports.find(e=>e.Protocol===`responses`);return t.requireResumableRun&&i?i:r||i||{Protocol:`responses`,Runtime:`ksadk`,Endpoint:`/v1/responses`,Version:`v1`,Capabilities:{A2UI:!1,Interrupt:!1,Cancel:!1}}}var He=te()(e=>({agentId:`default-agent`,agentName:`Agent`,agentFramework:``,capabilities:ze({}),apiFormats:[`responses`,`chat_completions`],accessMode:`Owner`,workspaceFiles:null,status:`loading`,errorMessage:``,setAgentId:t=>e({agentId:t}),setAgentName:t=>e({agentName:t}),setAgentFramework:t=>e({agentFramework:t}),setCapabilities:t=>e({capabilities:t}),setApiFormats:t=>e({apiFormats:t}),setAccessMode:t=>e({accessMode:t}),setWorkspaceFiles:t=>e({workspaceFiles:t}),setStatus:(t,n=``)=>e({status:t,errorMessage:n})}));function Ue(e,t){let n=new Map;for(let t of e)t?.id&&n.set(t.id,t);for(let e of t)e?.id&&n.set(e.id,{...n.get(e.id)||{},...e});return Array.from(n.values()).sort((e,t)=>e.id.localeCompare(t.id))}var We=te()(e=>({availableModels:[],selectedModel:``,modelSource:``,modelCatalogLoaded:!1,thinkingMode:`auto`,upsertModels:t=>e(e=>({availableModels:Ue(e.availableModels,t)})),setSelectedModel:t=>e({selectedModel:t}),setModelSource:t=>e({modelSource:t}),setModelCatalogLoaded:t=>e({modelCatalogLoaded:t}),setThinkingMode:t=>e({thinkingMode:t}),resetCatalog:()=>e({availableModels:[],selectedModel:``,modelSource:``,modelCatalogLoaded:!1})}));function Ge(e,t){return`${e}${t}`}function Ke(e){return{...e}}var qe=class{runId=null;status=null;items=new Map;seenEventIds=new Set;apply(e){if(e.eventId){if(this.seenEventIds.has(e.eventId))return;this.seenEventIds.add(e.eventId)}switch(e.type){case`run_started`:this.runId=e.runId,this.status=`running`;return;case`run_interrupted`:this.status=`interrupted`;return;case`run_completed`:this.status=`completed`;return;case`run_failed`:this.status=`failed`;return;case`run_canceled`:this.status=`canceled`;return;case`item_started`:this.startItem(e);return;case`item_updated`:this.updateItem(e);return;case`item_snapshot_replaced`:this.replaceSnapshot(e);return;case`item_completed`:case`item_failed`:this.closeItem(e);return}}applyAll(e){for(let t of e)this.apply(t)}snapshot(){return{runId:this.runId,status:this.status,items:Array.from(this.items.values()).map(e=>({...e,parts:e.parts.map(Ke)}))}}ensureItem(e){this.runId===null&&(this.runId=e.runId);let t=Ge(e.scopeId,e.itemId),n=this.items.get(t);return n||(n={runId:e.runId,scopeId:e.scopeId,itemId:e.itemId,itemKind:e.itemKind||`message`,status:`open`,parts:[]},this.items.set(t,n)),n}startItem(e){let t=Ge(e.scopeId,e.itemId),n=this.items.get(t);if(n){e.phase!==void 0&&(n.phase=e.phase);return}let r=this.ensureItem(e);r.phase=e.phase,e.initialParts&&(r.parts=e.initialParts.map(Ke))}updateItem(e){let t=this.ensureItem(e),n=t.parts.findIndex(t=>t.partId===e.partId);if(n<0){t.parts.push(Ke(e.part));return}let r=t.parts[n];if(e.op===`replace`){t.parts[n]=Ke(e.part);return}t.parts[n]={...r,text:`${r.text||``}${e.part.text||``}`}}replaceSnapshot(e){let t=this.ensureItem(e);t.parts=e.parts.map(Ke)}closeItem(e){let t=this.ensureItem(e);e.parts&&(t.parts=e.parts.map(Ke)),t.status=e.type===`item_completed`?`completed`:`failed`}};function Je(e,t){return{partId:e,contentType:`text`,text:t}}var Ye=`text-0`;function Xe(e,t){return String(e?.id||e?.item_id||t?.item_id||t?.output_index||``)}function Ze(e){let t=e?.content;return Array.isArray(t)?t.map(e=>typeof e==`string`?e:String(e?.text||``)).join(``):String(e?.output_text||e?.text||``)}function Qe(e,t,n,r){let i=String(t?.type||e||``).trim(),a=t?.id?String(t.id):void 0,o=t?.item||t?.output_item||{},s=Xe(o,t),c=String(o?.type||``),l=c.includes(`reasoning`)?`reasoning`:`message`;if(i===`response.output_item.added`)return!s||c!==`message`&&!c.includes(`reasoning`)?[]:[{type:`item_started`,runId:n,scopeId:r,itemId:s,itemKind:l,phase:`final_answer`,eventId:a}];if(i===`response.output_text.delta`||i===`response.content_part.delta`){if(!s)return[];let e=String(t?.delta||t?.text||``);return e?[{type:`item_updated`,runId:n,scopeId:r,itemId:s,itemKind:l,partId:Ye,op:`append`,part:Je(Ye,e),eventId:a}]:[]}return i===`response.output_item.done`||i===`response.output_text.done`?s?[{type:`item_completed`,runId:n,scopeId:r,itemId:s,itemKind:l,parts:[Je(Ye,Ze(o)||String(t?.text||``))],eventId:a}]:[]:i===`response.completed`?[{type:`run_completed`,runId:n,scopeId:r,eventId:a}]:[]}var $e=e=>Object.keys(e).length>0,et={runId:null,status:null,items:[]},tt=new qe,nt=(e,t)=>{let n={...e};return delete n[t],n},k=te()((e,t)=>({isStreaming:!1,currentRunId:``,stopRequested:!1,activity:null,sessionActivities:{},sessionStreaming:{},banner:null,lastSeqId:0,activeInvocationId:``,runtimeItems:et,setStreaming:t=>e({isStreaming:t}),setBanner:t=>e({banner:t?{...t,createdAt:Date.now()}:null}),setLastSeqId:t=>e({lastSeqId:t}),setActiveInvocationId:t=>e({activeInvocationId:t}),setSessionStreaming:(t,n)=>e(e=>{let r=String(t||``);if(!r)return{isStreaming:n};let i=nt(e.sessionStreaming,r),a=n?{...i,[r]:!0}:i;return{sessionStreaming:a,isStreaming:$e(a)}}),isSessionStreaming:e=>{let n=String(e||``);return!!(n&&t().sessionStreaming[n])},getSessionActivity:e=>{let n=String(e||``);return n&&t().sessionActivities[n]||null},setCurrentRunId:t=>e({currentRunId:t}),requestStop:()=>e({stopRequested:!0}),beginActivity:t=>e({stopRequested:!1,activity:{runId:t.runId,source:t.source||`run`,status:t.status||`running`,phase:t.phase,detail:t.detail,startedAt:Date.now(),lastEventAt:Date.now(),eventCount:0}}),updateActivity:t=>e(e=>{let n=String(t.sessionId||``),r=n?e.sessionActivities[n]:e.activity,i=r?{...r,source:t.source||r.source,status:t.status||r.status,phase:t.phase||r.phase,detail:t.detail===void 0?r.detail:t.detail,lastEventAt:Date.now(),eventCount:r.eventCount+(t.countEvent===!1?0:1)}:{source:t.source||`run`,status:t.status||`running`,phase:t.phase||`正在运行`,detail:t.detail,startedAt:Date.now(),lastEventAt:Date.now(),eventCount:t.countEvent===!1?0:1};return n?{isStreaming:$e(e.sessionStreaming),sessionActivities:{...e.sessionActivities,[n]:i},activity:i}:{activity:i}}),stopActivity:t=>e(e=>({isStreaming:!1,stopRequested:!0,activity:e.activity?{...e.activity,status:`stopped`,phase:`已断开输出流`,detail:t||`前端已断开本次输出流;后台运行可稍后通过会话记录继续查看。`,lastEventAt:Date.now()}:null})),stopSessionActivity:(t,n)=>e(e=>{let r=String(t||``);if(!r)return{};let i=e.sessionActivities[r];if(!i)return{};let a={...i,status:`stopped`,phase:`已断开输出流`,detail:n||`前端已断开本次输出流;后台运行可稍后通过会话记录继续查看。`,lastEventAt:Date.now()},o={...e.sessionActivities,[r]:a},s=nt(e.sessionStreaming,r);return{isStreaming:$e(s),activity:a,sessionActivities:o,sessionStreaming:s}}),clearActivity:()=>e({activity:null}),clearSessionActivity:t=>e(e=>{let n=String(t||``);if(!n)return{};let{[n]:r,...i}=e.sessionActivities,a=nt(e.sessionStreaming,n);return{sessionActivities:i,sessionStreaming:a,isStreaming:$e(a),activity:e.activity===r?null:e.activity}}),applyRuntimeItemOperations:t=>{tt.applyAll(t),e({runtimeItems:tt.snapshot()})},resetRun:()=>{tt=new qe,e({isStreaming:!1,currentRunId:``,stopRequested:!1,activity:null,sessionActivities:{},sessionStreaming:{},lastSeqId:0,activeInvocationId:``,runtimeItems:et})}})),rt=te()(e=>({content:null,type:`html`,visible:!1,show:(t,n=`html`)=>e({content:t,type:n,visible:!0}),hide:()=>e({visible:!1}),setContent:(t,n)=>e(e=>({content:t,type:n??e.type}))})),it=.28;function at(e,t=768){return Number(e)<=t}function ot({isMobile:e,desktopSidebarOpen:t,mobileSidebarOpen:n}){return{desktopSidebarVisible:!e&&!!t,mobileDrawerVisible:!!(e&&n)}}function st({isMobile:e,viewportHeight:t,desktopMaxHeight:n=160}){if(!e)return n;let r=Number(t);if(!Number.isFinite(r)||r<=0)return n;let i=Math.floor(r*it);return Math.max(120,Math.min(n,i))}var ct=`/_ksadk/workspace/v1/files`,lt=new Set([`.md`,`.markdown`,`.mdx`]),ut=new Set([`.pdf`]),dt=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.svg`,`.bmp`,`.ico`]),ft=new Set(`.txt,.log,.json,.yaml,.yml,.xml,.html,.css,.js,.jsx,.ts,.tsx,.py,.sh,.sql,.csv,.tsv,.toml,.ini,.env,.lock,.conf,.c,.cc,.cpp,.go,.java,.rs`.split(`,`)),pt=new Set([`application/json`,`application/ld+json`,`application/xml`,`application/javascript`,`application/x-javascript`,`application/typescript`,`application/x-sh`,`application/x-yaml`,`application/yaml`,`text/csv`,`text/tab-separated-values`]);function mt(e){let t=String(e||``).trim().replace(/\\/g,`/`);if(!t||t===`/`)return`.`;let n=[];for(let e of t.split(`/`)){let t=e.trim();if(!(!t||t===`.`)){if(t===`..`){n.length>0&&n.pop();continue}n.push(t)}}return n.length>0?n.join(`/`):`.`}function ht(e){let t=mt(e);return t===`.`?``:t.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function gt(e){let t=ht(e);return t?`${ct}/${t}`:ct}function _t(e){let t=mt(e);if(t===`.`||!t.includes(`/`))return`${ct}/`;let n=ht(t.substring(0,t.lastIndexOf(`/`)));return n?`${ct}/${n}/`:`${ct}/`}function vt(e){return mt(e)===`.`}function yt(e){let t=mt(e);return t===`.`?`/`:`/${t}`}function bt(e){let t=String(e||``).split(`/`).pop()||``,n=t.lastIndexOf(`.`);return n>=0?t.slice(n).toLowerCase():``}function xt(e){return String(e||``).split(`;`)[0].trim().toLowerCase()}var St=new Set([`.html`,`.htm`]);function Ct({path:e,mimeType:t}){let n=bt(e),r=xt(t);return r===`text/html`||St.has(n)?`html`:r===`text/markdown`||lt.has(n)?`markdown`:r===`application/pdf`||ut.has(n)?`pdf`:r.startsWith(`image/`)||dt.has(n)?`image`:r.startsWith(`text/`)||pt.has(r)||ft.has(n)?`text`:`unsupported`}var wt=new Set([`.txt`,`.log`,`.csv`,`.tsv`,`.env`,`.ini`,`.conf`,`.lock`]);function Tt({path:e,mimeType:t}){let n=bt(e),r=xt(t);return St.has(n)||r===`text/html`?`html`:r===`text/markdown`||lt.has(n)?`markdown`:r===`application/pdf`||ut.has(n)||r.startsWith(`image/`)||dt.has(n)?null:wt.has(n)||r===`text/plain`?`text`:r.startsWith(`text/`)||pt.has(r)||ft.has(n)?`code`:null}function Et({isMobile:e}){return e?{renderMode:`sheet`,modal:!0,showOverlay:!0,preventOutsideClose:!1,side:`bottom`}:{renderMode:`inline`,modal:!1,showOverlay:!1,preventOutsideClose:!0,side:`right`}}function Dt(){let e=0;return{next(t){return e+=1,{path:t,version:e}},invalidate(){e+=1},isCurrent(t){return!!t&&t.version===e}}}function Ot({workspaceFiles:e,accessMode:t}){if(!e?.Enabled)return!1;let n=String(t||``).trim().toLowerCase();return n===`owner`||n===`private`}var kt=`ksadk:webui:selected-session:`;function At(e){return String(e||``).trim()||`default-agent`}function jt(e){if(e&&typeof e.getItem==`function`)return e;try{if(typeof window<`u`&&window.localStorage)return window.localStorage}catch{}return null}function Mt(e){return b.key(`${kt}${At(e)}`)}function Nt(e,t){let n=jt(t);if(!n)return null;try{return String(n.getItem(Mt(e))||``).trim()||null}catch{return null}}function Pt(e,t,n){if(!b.writable)return;let r=jt(n);if(!r)return;let i=Mt(e),a=String(t||``).trim();try{if(a){r.setItem(i,a);return}r.removeItem(i)}catch{}}function Ft(e,t){if(!Array.isArray(e)||e.length===0)return null;let n=String(t||``).trim();if(n&&e.some(e=>String(e?.SessionId||``).trim()===n))return n;for(let t of e){let e=String(t?.SessionId||``).trim();if(e)return e}return null}function It(e,t,n){let r=Array.isArray(e)?e:[],i=Array.isArray(t)?t:[],a=n instanceof Set?n:new Set(Array.isArray(n)?n:[]);if(a.size===0)return r;let o=new Set(r.map(e=>String(e?.SessionId||``).trim()).filter(Boolean)),s=i.filter(e=>{let t=String(e?.SessionId||``).trim();return t&&a.has(t)&&!o.has(t)});return s.length>0?[...r,...s]:r}var Lt=new Map([[`openclaw`,`OpenClaw`],[`hermes`,`Hermes`]]);function Rt(e){return String(e||``).trim().toLowerCase()}function zt(e){return String(e||``).trim().toLowerCase()}function Bt(e){try{return new URL(`/`,e).toString()}catch{return`/`}}function Vt({capability:e,agentFramework:t,accessMode:n,origin:r}){let i=Rt(n);if(i!==`owner`&&i!==`private`||!e?.Enabled)return null;let a=Lt.get(zt(t))||`运行时`;return{href:typeof e.Href==`string`&&e.Href?new URL(e.Href,Bt(r)).toString():Bt(r),label:typeof e.Label==`string`&&e.Label?e.Label:`管理平台`,title:`打开 ${a} 原生管理平台`}}var Ht=new Set([`auto`,`enabled`,`disabled`]);function Ut(e){let t=String(e||``).trim().toLowerCase();return Ht.has(t)?t:`auto`}function Wt(e){let t=Ut(e);if(t===`disabled`)return{thinking:{type:`disabled`}};if(t===`enabled`)return{thinking:{type:`enabled`}}}function Gt(){return typeof window>`u`?900:Math.round(window.visualViewport?.height||window.innerHeight||900)}function Kt(){return typeof window>`u`?{isMobile:!1,viewportHeight:900}:{isMobile:at(window.innerWidth,768),viewportHeight:Gt()}}function qt(){let[e,t]=(0,v.useState)(()=>Kt());return(0,v.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: 768px)`),n=()=>{t(Kt())};n();let r=typeof e.addEventListener==`function`?(e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)):(e.addListener(n),()=>e.removeListener(n));return window.addEventListener(`resize`,n),window.visualViewport?.addEventListener(`resize`,n),()=>{r(),window.removeEventListener(`resize`,n),window.visualViewport?.removeEventListener(`resize`,n)}},[]),e}var Jt=class extends Error{code;detail;constructor(e,t,n){super(t),this.name=`ApiError`,this.code=e,this.detail=n}},Yt=class extends Error{constructor(e=`请求已取消`){super(e),this.name=`CancelledError`}},Xt=`/agentengine/api/v1`;async function Zt(e){let t=await e.text(),n={};try{n=t?JSON.parse(t):{}}catch{let n=e.headers.get(`content-type`)?.toLowerCase()||``;if((e.status===401||e.status===403)&&(n.includes(`text/html`)||t.trimStart().startsWith(`<`)))throw new Jt(e.status,`访问会话已失效,请从 Dashboard 或 Studio 的云端会话重新打开 Agent。`);if(!e.ok){let n=t.trim();throw new Jt(e.status,n&&n.length<=256&&!n.startsWith(`<`)?n:e.statusText||`HTTP ${e.status}`,t)}throw new Jt(-2,`响应格式异常`)}if(!e.ok)throw new Jt(e.status,n?.Message||`HTTP ${e.status}`,n);if(n?.Code!==void 0&&n.Code!==0)throw new Jt(n.Code,n.Message||`请求失败`,n);return n.Data}function Qt(e){throw e instanceof DOMException&&e.name===`AbortError`?new Yt:e}var $t=class{fetcher;baseUrl;agentId;constructor(e={}){this.fetcher=e.fetch||((e,t)=>globalThis.fetch(e,t)),this.baseUrl=String(e.baseUrl||Xt).replace(/\/+$/,``),this.agentId=String(e.agentId||``).trim()}actionUrl(e){return`${this.baseUrl}/${e}`}scopedBody(e){return this.agentId&&!e.AgentId?{...e,AgentId:this.agentId}:e}async postJsonAction(e,t,n){let r;try{r=await this.fetcher(this.actionUrl(e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(this.scopedBody(t)),signal:n?.signal})}catch(e){throw Qt(e)}return Zt(r)}async postFormAction(e,t,n){let r;this.agentId&&!t.has(`AgentId`)&&t.append(`AgentId`,this.agentId);try{r=await this.fetcher(this.actionUrl(e),{method:`POST`,body:t,signal:n?.signal})}catch(e){throw Qt(e)}return Zt(r)}async getResource(e,t,n){let r=this.agentId&&!t.AgentId?{AgentId:this.agentId,...t}:t,i=new URLSearchParams(r).toString(),a=i?`${this.actionUrl(e)}?${i}`:this.actionUrl(e),o;try{o=await this.fetcher(a,{signal:n?.signal})}catch(e){throw Qt(e)}if(!o.ok)throw new Jt(o.status,`资源获取失败: ${o.statusText}`);try{return n?.asText?await o.text():await o.blob()}catch{throw new Jt(-3,`文件读取失败`)}}async streamAction(e,t,n){let r;try{r=await this.fetcher(this.actionUrl(e),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`text/event-stream`},body:JSON.stringify(this.scopedBody(t)),signal:n?.signal})}catch(e){throw Qt(e)}if(!r.ok)throw await Zt(r),new Jt(r.status,`流式请求失败: ${r.statusText}`);if((r.headers.get(`content-type`)?.toLowerCase()||``).includes(`application/json`)&&await Zt(r.clone()),!r.body)throw new Jt(-1,`无法获取响应流`);return r.body}async streamGetAction(e,t,n){let r=this.agentId&&!t.AgentId?{AgentId:this.agentId,...t}:t,i=new URLSearchParams(r).toString(),a=i?`${this.actionUrl(e)}?${i}`:this.actionUrl(e),o;try{o=await this.fetcher(a,{headers:{Accept:`text/event-stream`},signal:n?.signal})}catch(e){throw Qt(e)}if(!o.ok)throw new Jt(o.status,`流式订阅失败: ${o.statusText}`);if(!o.body)throw new Jt(-1,`无法获取响应流`);return o.body}};new $t;var en;function A(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 tn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},nn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(en=globalThis).__zod_globalConfig??(en.__zod_globalConfig={});var rn=globalThis.__zod_globalConfig;function an(e){return e&&Object.assign(rn,e),rn}function on(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 sn(e,t){return typeof t==`bigint`?t.toString():t}function cn(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function ln(e){return e==null}function un(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function dn(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 fn=Symbol(`evaluating`);function pn(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==fn)return r===void 0&&(r=fn,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function mn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function hn(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function gn(e){return JSON.stringify(e)}function _n(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var vn=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function yn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var bn=cn(()=>{if(rn.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function xn(e){if(yn(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(yn(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Sn(e){return xn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Cn=new Set([`string`,`number`,`symbol`]);function wn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Tn(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function En(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 Dn(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var On={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function kn(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 Tn(e,hn(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 mn(this,`shape`,e),e},checks:[]}))}function An(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 Tn(e,hn(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 mn(this,`shape`,r),r},checks:[]}))}function jn(e,t){if(!xn(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 Tn(e,hn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return mn(this,`shape`,n),n}}))}function Mn(e,t){if(!xn(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Tn(e,hn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return mn(this,`shape`,n),n}}))}function Nn(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Tn(e,hn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return mn(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Pn(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 Tn(t,hn(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 mn(this,`shape`,i),i},checks:[]}))}function Fn(e,t,n){return Tn(t,hn(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 mn(this,`shape`,i),i}}))}function In(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 Ln(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 Rn(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function zn(e){return typeof e==`string`?e:e?.message}function Bn(e,t,n){let r=e.message?e.message:zn(e.inst?._zod.def?.error?.(e))??zn(t?.error?.(e))??zn(n.customError?.(e))??zn(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 Vn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Hn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Un=(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,sn,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Wn=A(`$ZodError`,Un),Gn=A(`$ZodError`,Un,{Parent:Error});function Kn(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 qn(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 Jn=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 tn;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Bn(e,a,an())));throw vn(t,i?.callee),t}return o.value},Yn=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=>Bn(e,a,an())));throw vn(t,i?.callee),t}return o.value},Xn=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 tn;return a.issues.length?{success:!1,error:new(e??Wn)(a.issues.map(e=>Bn(e,i,an())))}:{success:!0,data:a.value}},Zn=Xn(Gn),Qn=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=>Bn(e,i,an())))}:{success:!0,data:a.value}},$n=Qn(Gn),er=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Jn(e)(t,n,i)},tr=e=>(t,n,r)=>Jn(e)(t,n,r),nr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Yn(e)(t,n,i)},rr=e=>async(t,n,r)=>Yn(e)(t,n,r),ir=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Xn(e)(t,n,i)},ar=e=>(t,n,r)=>Xn(e)(t,n,r),or=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Qn(e)(t,n,i)},sr=e=>async(t,n,r)=>Qn(e)(t,n,r),cr=/^[cC][0-9a-z]{6,}$/,lr=/^[0-9a-z]+$/,ur=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,dr=/^[0-9a-vA-V]{20}$/,fr=/^[A-Za-z0-9]{27}$/,pr=/^[a-zA-Z0-9_-]{21}$/,mr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,hr=/^([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})$/,gr=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)$/,_r=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,vr=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function yr(){return new RegExp(vr,`u`)}var br=/^(?:(?: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])$/,xr=/^(([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}|:))$/,Sr=/^((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])$/,Cr=/^(([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])$/,wr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Tr=/^[A-Za-z0-9_-]*$/,Er=/^https?$/,Dr=/^\+[1-9]\d{6,14}$/,Or=`(?:(?:\\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])))`,kr=RegExp(`^${Or}$`);function Ar(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 jr(e){return RegExp(`^${Ar(e)}$`)}function Mr(e){let t=Ar({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(`^${Or}T(?:${r})$`)}var Nr=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Pr=/^-?\d+$/,Fr=/^-?\d+(?:\.\d+)?$/,Ir=/^(?:true|false)$/i,Lr=/^[^A-Z]*$/,Rr=/^[^a-z]*$/,zr=A(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Br={number:`number`,bigint:`bigint`,object:`date`},Vr=A(`$ZodCheckLessThan`,(e,t)=>{zr.init(e,t);let n=Br[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})}}),Hr=A(`$ZodCheckGreaterThan`,(e,t)=>{zr.init(e,t);let n=Br[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})}}),Ur=A(`$ZodCheckMultipleOf`,(e,t)=>{zr.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):dn(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})}}),Wr=A(`$ZodCheckNumberFormat`,(e,t)=>{zr.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=On[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=Pr)}),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})}}),Gr=A(`$ZodCheckMaxLength`,(e,t)=>{var n;zr.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!ln(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=Vn(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Kr=A(`$ZodCheckMinLength`,(e,t)=>{var n;zr.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!ln(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=Vn(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),qr=A(`$ZodCheckLengthEquals`,(e,t)=>{var n;zr.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!ln(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=Vn(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})}}),Jr=A(`$ZodCheckStringFormat`,(e,t)=>{var n,r;zr.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=()=>{})}),Yr=A(`$ZodCheckRegex`,(e,t)=>{Jr.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})}}),Xr=A(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Lr,Jr.init(e,t)}),Zr=A(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Rr,Jr.init(e,t)}),Qr=A(`$ZodCheckIncludes`,(e,t)=>{zr.init(e,t);let n=wn(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})}}),$r=A(`$ZodCheckStartsWith`,(e,t)=>{zr.init(e,t);let n=RegExp(`^${wn(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})}}),ei=A(`$ZodCheckEndsWith`,(e,t)=>{zr.init(e,t);let n=RegExp(`.*${wn(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})}}),ti=A(`$ZodCheckOverwrite`,(e,t)=>{zr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),ni=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(`
|
|
11
|
+
`).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(`
|
|
12
|
+
`))}},ri={major:4,minor:4,patch:3},ii=A(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ri;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=In(e),i;for(let a of t){if(a._zod.def.when){if(Ln(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 tn;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=In(e,t))});else{if(e.issues.length===t)continue;r||=In(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(In(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new tn;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 tn;return o.then(e=>t(e,r,a))}return t(o,r,a)}}pn(e,`~standard`,()=>({validate:t=>{try{let n=Zn(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return $n(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),ai=A(`$ZodString`,(e,t)=>{ii.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Nr(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}}),oi=A(`$ZodStringFormat`,(e,t)=>{Jr.init(e,t),ai.init(e,t)}),si=A(`$ZodGUID`,(e,t)=>{t.pattern??=hr,oi.init(e,t)}),ci=A(`$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??=gr(e)}else t.pattern??=gr();oi.init(e,t)}),li=A(`$ZodEmail`,(e,t)=>{t.pattern??=_r,oi.init(e,t)}),ui=A(`$ZodURL`,(e,t)=>{oi.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===Er.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})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),di=A(`$ZodEmoji`,(e,t)=>{t.pattern??=yr(),oi.init(e,t)}),fi=A(`$ZodNanoID`,(e,t)=>{t.pattern??=pr,oi.init(e,t)}),pi=A(`$ZodCUID`,(e,t)=>{t.pattern??=cr,oi.init(e,t)}),mi=A(`$ZodCUID2`,(e,t)=>{t.pattern??=lr,oi.init(e,t)}),hi=A(`$ZodULID`,(e,t)=>{t.pattern??=ur,oi.init(e,t)}),gi=A(`$ZodXID`,(e,t)=>{t.pattern??=dr,oi.init(e,t)}),_i=A(`$ZodKSUID`,(e,t)=>{t.pattern??=fr,oi.init(e,t)}),vi=A(`$ZodISODateTime`,(e,t)=>{t.pattern??=Mr(t),oi.init(e,t)}),yi=A(`$ZodISODate`,(e,t)=>{t.pattern??=kr,oi.init(e,t)}),bi=A(`$ZodISOTime`,(e,t)=>{t.pattern??=jr(t),oi.init(e,t)}),xi=A(`$ZodISODuration`,(e,t)=>{t.pattern??=mr,oi.init(e,t)}),Si=A(`$ZodIPv4`,(e,t)=>{t.pattern??=br,oi.init(e,t),e._zod.bag.format=`ipv4`}),Ci=A(`$ZodIPv6`,(e,t)=>{t.pattern??=xr,oi.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})}}}),wi=A(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Sr,oi.init(e,t)}),Ti=A(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Cr,oi.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 Ei(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Di=A(`$ZodBase64`,(e,t)=>{t.pattern??=wr,oi.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Ei(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Oi(e){if(!Tr.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Ei(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var ki=A(`$ZodBase64URL`,(e,t)=>{t.pattern??=Tr,oi.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Oi(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Ai=A(`$ZodE164`,(e,t)=>{t.pattern??=Dr,oi.init(e,t)});function ji(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 Mi=A(`$ZodJWT`,(e,t)=>{oi.init(e,t),e._zod.check=n=>{ji(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Ni=A(`$ZodNumber`,(e,t)=>{ii.init(e,t),e._zod.pattern=e._zod.bag.pattern??Fr,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}}),Pi=A(`$ZodNumberFormat`,(e,t)=>{Wr.init(e,t),Ni.init(e,t)}),Fi=A(`$ZodBoolean`,(e,t)=>{ii.init(e,t),e._zod.pattern=Ir,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}}),Ii=A(`$ZodUnknown`,(e,t)=>{ii.init(e,t),e._zod.parse=e=>e}),Li=A(`$ZodNever`,(e,t)=>{ii.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Ri(e,t,n){e.issues.length&&t.issues.push(...Rn(n,e.issues)),t.value[n]=e.value}var zi=A(`$ZodArray`,(e,t)=>{ii.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=>Ri(t,n,e))):Ri(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Bi(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...Rn(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 Vi(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=Dn(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Hi(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=>Bi(e,n,i,t,u,d))):Bi(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 Ui=A(`$ZodObject`,(e,t)=>{if(ii.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=cn(()=>Vi(t));pn(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=yn,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=>Bi(n,t,e,s,r,i))):Bi(a,t,e,s,r,i)}return i?Hi(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Wi=A(`$ZodObjectJIT`,(e,t)=>{Ui.init(e,t);let n=e._zod.parse,r=cn(()=>Vi(t)),i=e=>{let t=new ni([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=gn(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=gn(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
13
|
+
if (${n}.issues.length) {
|
|
14
|
+
if (${o} in input) {
|
|
15
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
16
|
+
...iss,
|
|
17
|
+
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
18
|
+
})));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (${n}.value === undefined) {
|
|
23
|
+
if (${o} in input) {
|
|
24
|
+
newResult[${o}] = undefined;
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
newResult[${o}] = ${n}.value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
`):c?t.write(`
|
|
31
|
+
if (${n}.issues.length) {
|
|
32
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
33
|
+
...iss,
|
|
34
|
+
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
35
|
+
})));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (${n}.value === undefined) {
|
|
39
|
+
if (${o} in input) {
|
|
40
|
+
newResult[${o}] = undefined;
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
newResult[${o}] = ${n}.value;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
`):t.write(`
|
|
47
|
+
const ${n}_present = ${o} in input;
|
|
48
|
+
if (${n}.issues.length) {
|
|
49
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
50
|
+
...iss,
|
|
51
|
+
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
52
|
+
})));
|
|
53
|
+
}
|
|
54
|
+
if (!${n}_present && !${n}.issues.length) {
|
|
55
|
+
payload.issues.push({
|
|
56
|
+
code: "invalid_type",
|
|
57
|
+
expected: "nonoptional",
|
|
58
|
+
input: undefined,
|
|
59
|
+
path: [${o}]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (${n}_present) {
|
|
64
|
+
if (${n}.value === undefined) {
|
|
65
|
+
newResult[${o}] = undefined;
|
|
66
|
+
} else {
|
|
67
|
+
newResult[${o}] = ${n}.value;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=yn,s=!rn.jitless,c=s&&bn.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?Hi([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Gi(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=>!In(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=>Bn(e,r,an())))}),t)}var Ki=A(`$ZodUnion`,(e,t)=>{ii.init(e,t),pn(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),pn(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),pn(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),pn(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=>un(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=>Gi(t,r,e,i)):Gi(o,r,e,i)}}),qi=A(`$ZodIntersection`,(e,t)=>{ii.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])=>Yi(e,t,n)):Yi(e,i,a)}});function Ji(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(xn(e)&&xn(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=Ji(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=Ji(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 Yi(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}),In(e))return e;let o=Ji(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Xi=A(`$ZodRecord`,(e,t)=>{ii.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!xn(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>Bn(e,r,an())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...Rn(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...Rn(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Fr.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Bn(e,r,an())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Rn(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Rn(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Zi=A(`$ZodEnum`,(e,t)=>{ii.init(e,t);let n=on(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Cn.has(typeof e)).map(e=>typeof e==`string`?wn(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}}),Qi=A(`$ZodLiteral`,(e,t)=>{if(ii.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`?wn(e):e?wn(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}}),$i=A(`$ZodTransform`,(e,t)=>{ii.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new nn(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 tn;return n.value=i,n.fallback=!0,n}});function ea(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var ta=A(`$ZodOptional`,(e,t)=>{ii.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,pn(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),pn(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${un(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=>ea(e,r)):ea(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),na=A(`$ZodExactOptional`,(e,t)=>{ta.init(e,t),pn(e._zod,`values`,()=>t.innerType._zod.values),pn(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ra=A(`$ZodNullable`,(e,t)=>{ii.init(e,t),pn(e._zod,`optin`,()=>t.innerType._zod.optin),pn(e._zod,`optout`,()=>t.innerType._zod.optout),pn(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${un(e.source)}|null)$`):void 0}),pn(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)}),ia=A(`$ZodDefault`,(e,t)=>{ii.init(e,t),e._zod.optin=`optional`,pn(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=>aa(e,t)):aa(r,t)}});function aa(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var oa=A(`$ZodPrefault`,(e,t)=>{ii.init(e,t),e._zod.optin=`optional`,pn(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))}),sa=A(`$ZodNonOptional`,(e,t)=>{ii.init(e,t),pn(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=>ca(t,e)):ca(i,e)}});function ca(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 la=A(`$ZodCatch`,(e,t)=>{ii.init(e,t),e._zod.optin=`optional`,pn(e._zod,`optout`,()=>t.innerType._zod.optout),pn(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=>Bn(e,n,an()))},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=>Bn(e,n,an()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),ua=A(`$ZodPipe`,(e,t)=>{ii.init(e,t),pn(e._zod,`values`,()=>t.in._zod.values),pn(e._zod,`optin`,()=>t.in._zod.optin),pn(e._zod,`optout`,()=>t.out._zod.optout),pn(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=>da(e,t.in,n)):da(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>da(e,t.out,n)):da(r,t.out,n)}});function da(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 fa=A(`$ZodReadonly`,(e,t)=>{ii.init(e,t),pn(e._zod,`propValues`,()=>t.innerType._zod.propValues),pn(e._zod,`values`,()=>t.innerType._zod.values),pn(e._zod,`optin`,()=>t.innerType?._zod?.optin),pn(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(pa):pa(r)}});function pa(e){return e.value=Object.freeze(e.value),e}var ma=A(`$ZodCustom`,(e,t)=>{zr.init(e,t),ii.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=>ha(t,n,r,e));ha(i,n,r,e)}});function ha(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(Hn(e))}}var ga,_a=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 va(){return new _a}(ga=globalThis).__zod_globalRegistry??(ga.__zod_globalRegistry=va());var ya=globalThis.__zod_globalRegistry;function ba(e,t){return new e({type:`string`,...En(t)})}function xa(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...En(t)})}function Sa(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...En(t)})}function Ca(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...En(t)})}function wa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...En(t)})}function Ta(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...En(t)})}function Ea(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...En(t)})}function Da(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...En(t)})}function Oa(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...En(t)})}function ka(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...En(t)})}function Aa(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...En(t)})}function ja(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...En(t)})}function Ma(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...En(t)})}function Na(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...En(t)})}function Pa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...En(t)})}function Fa(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...En(t)})}function Ia(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...En(t)})}function La(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...En(t)})}function Ra(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...En(t)})}function za(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...En(t)})}function Ba(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...En(t)})}function Va(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...En(t)})}function Ha(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...En(t)})}function Ua(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...En(t)})}function Wa(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...En(t)})}function Ga(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...En(t)})}function Ka(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...En(t)})}function qa(e,t){return new e({type:`number`,checks:[],...En(t)})}function Ja(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...En(t)})}function Ya(e,t){return new e({type:`boolean`,...En(t)})}function Xa(e){return new e({type:`unknown`})}function Za(e,t){return new e({type:`never`,...En(t)})}function Qa(e,t){return new Vr({check:`less_than`,...En(t),value:e,inclusive:!1})}function $a(e,t){return new Vr({check:`less_than`,...En(t),value:e,inclusive:!0})}function eo(e,t){return new Hr({check:`greater_than`,...En(t),value:e,inclusive:!1})}function to(e,t){return new Hr({check:`greater_than`,...En(t),value:e,inclusive:!0})}function no(e,t){return new Ur({check:`multiple_of`,...En(t),value:e})}function ro(e,t){return new Gr({check:`max_length`,...En(t),maximum:e})}function io(e,t){return new Kr({check:`min_length`,...En(t),minimum:e})}function ao(e,t){return new qr({check:`length_equals`,...En(t),length:e})}function oo(e,t){return new Yr({check:`string_format`,format:`regex`,...En(t),pattern:e})}function so(e){return new Xr({check:`string_format`,format:`lowercase`,...En(e)})}function co(e){return new Zr({check:`string_format`,format:`uppercase`,...En(e)})}function lo(e,t){return new Qr({check:`string_format`,format:`includes`,...En(t),includes:e})}function uo(e,t){return new $r({check:`string_format`,format:`starts_with`,...En(t),prefix:e})}function fo(e,t){return new ei({check:`string_format`,format:`ends_with`,...En(t),suffix:e})}function po(e){return new ti({check:`overwrite`,tx:e})}function mo(e){return po(t=>t.normalize(e))}function ho(){return po(e=>e.trim())}function go(){return po(e=>e.toLowerCase())}function _o(){return po(e=>e.toUpperCase())}function vo(){return po(e=>_n(e))}function yo(e,t,n){return new e({type:`array`,element:t,...En(n)})}function bo(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...En(n)})}function xo(e,t){let n=So(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Hn(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(Hn(r))}},e(t.value,t)),t);return n}function So(e,t){let n=new zr({check:`custom`,...En(t)});return n._zod.check=e,n}function Co(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??ya,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 wo(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,wo(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`&&Do(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 To(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>
|
|
72
|
+
|
|
73
|
+
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 Eo(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:ko(t,`input`,e.processors),output:ko(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Do(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 Do(r.element,n);if(r.type===`set`)return Do(r.valueType,n);if(r.type===`lazy`)return Do(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 Do(r.innerType,n);if(r.type===`intersection`)return Do(r.left,n)||Do(r.right,n);if(r.type===`record`||r.type===`map`)return Do(r.keyType,n)||Do(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Do(r.in,n)||Do(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Do(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Do(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Do(e,n))return!0;return!!(r.rest&&Do(r.rest,n))}return!1}var Oo=(e,t={})=>n=>{let r=Co({...n,processors:t});return wo(e,r),To(r,e),Eo(r,e)},ko=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Co({...i??{},target:a,io:t,processors:n});return wo(e,o),To(o,e),Eo(o,e)},Ao={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},jo=(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=Ao[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}))])}},Mo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`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)},No=(e,t,n,r)=>{n.type=`boolean`},Po=(e,t,n,r)=>{n.not={}},Fo=(e,t,n,r)=>{let i=e._zod.def,a=on(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Io=(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},Lo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ro=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},zo=(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=wo(a.element,t,{...r,path:[...r.path,`items`]})},Bo=(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]=wo(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=wo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Vo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>wo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ho=(e,t,n,r)=>{let i=e._zod.def,a=wo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=wo(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]]},Uo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=wo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=wo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=wo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Wo=(e,t,n,r)=>{let i=e._zod.def,a=wo(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`}]},Go=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ko=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},qo=(e,t,n,r)=>{let i=e._zod.def;wo(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)))},Jo=(e,t,n,r)=>{let i=e._zod.def;wo(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},Yo=(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;wo(o,t,r);let s=t.seen.get(e);s.ref=o},Xo=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Zo=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Qo=A(`ZodISODateTime`,(e,t)=>{vi.init(e,t),Ts.init(e,t)});function $o(e){return Ua(Qo,e)}var es=A(`ZodISODate`,(e,t)=>{yi.init(e,t),Ts.init(e,t)});function ts(e){return Wa(es,e)}var ns=A(`ZodISOTime`,(e,t)=>{bi.init(e,t),Ts.init(e,t)});function rs(e){return Ga(ns,e)}var is=A(`ZodISODuration`,(e,t)=>{xi.init(e,t),Ts.init(e,t)});function as(e){return Ka(is,e)}var os=A(`ZodError`,(e,t)=>{Wn.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>qn(e,t)},flatten:{value:t=>Kn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,sn,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,sn,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),ss=Jn(os),cs=Yn(os),ls=Xn(os),us=Qn(os),ds=er(os),fs=tr(os),ps=nr(os),ms=rr(os),hs=ir(os),gs=ar(os),_s=or(os),vs=sr(os),ys=new WeakMap;function bs(e,t,n){let r=Object.getPrototypeOf(e),i=ys.get(r);if(i||(i=new Set,ys.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 xs=A(`ZodType`,(e,t)=>(ii.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ko(e,`input`),output:ko(e,`output`)}}),e.toJSONSchema=Oo(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>ss(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ls(e,t,n),e.parseAsync=async(t,n)=>cs(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>us(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ds(e,t,n),e.decode=(t,n)=>fs(e,t,n),e.encodeAsync=async(t,n)=>ps(e,t,n),e.decodeAsync=async(t,n)=>ms(e,t,n),e.safeEncode=(t,n)=>hs(e,t,n),e.safeDecode=(t,n)=>gs(e,t,n),e.safeEncodeAsync=async(t,n)=>_s(e,t,n),e.safeDecodeAsync=async(t,n)=>vs(e,t,n),bs(e,`ZodType`,{check(...e){let t=this.def;return this.clone(hn(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 Tn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ic(e,t))},superRefine(e,t){return this.check(Lc(e,t))},overwrite(e){return this.check(po(e))},optional(){return vc(this)},exactOptional(){return bc(this)},nullable(){return Sc(this)},nullish(){return vc(Sc(this))},nonoptional(e){return Oc(this,e)},array(){return nc(this)},or(e){return oc([this,e])},and(e){return cc(this,e)},transform(e){return Mc(this,gc(e))},default(e){return wc(this,e)},prefault(e){return Ec(this,e)},catch(e){return Ac(this,e)},pipe(e){return Mc(this,e)},readonly(){return Pc(this)},describe(e){let t=this.clone();return ya.add(t,{description:e}),t},meta(...e){if(e.length===0)return ya.get(this);let t=this.clone();return ya.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 ya.get(e)?.description},configurable:!0}),e)),Ss=A(`_ZodString`,(e,t)=>{ai.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,bs(e,`_ZodString`,{regex(...e){return this.check(oo(...e))},includes(...e){return this.check(lo(...e))},startsWith(...e){return this.check(uo(...e))},endsWith(...e){return this.check(fo(...e))},min(...e){return this.check(io(...e))},max(...e){return this.check(ro(...e))},length(...e){return this.check(ao(...e))},nonempty(...e){return this.check(io(1,...e))},lowercase(e){return this.check(so(e))},uppercase(e){return this.check(co(e))},trim(){return this.check(ho())},normalize(...e){return this.check(mo(...e))},toLowerCase(){return this.check(go())},toUpperCase(){return this.check(_o())},slugify(){return this.check(vo())}})}),Cs=A(`ZodString`,(e,t)=>{ai.init(e,t),Ss.init(e,t),e.email=t=>e.check(xa(Es,t)),e.url=t=>e.check(Da(ks,t)),e.jwt=t=>e.check(Ha(Ws,t)),e.emoji=t=>e.check(Oa(As,t)),e.guid=t=>e.check(Sa(Ds,t)),e.uuid=t=>e.check(Ca(Os,t)),e.uuidv4=t=>e.check(wa(Os,t)),e.uuidv6=t=>e.check(Ta(Os,t)),e.uuidv7=t=>e.check(Ea(Os,t)),e.nanoid=t=>e.check(ka(js,t)),e.guid=t=>e.check(Sa(Ds,t)),e.cuid=t=>e.check(Aa(Ms,t)),e.cuid2=t=>e.check(ja(Ns,t)),e.ulid=t=>e.check(Ma(Ps,t)),e.base64=t=>e.check(za(Vs,t)),e.base64url=t=>e.check(Ba(Hs,t)),e.xid=t=>e.check(Na(Fs,t)),e.ksuid=t=>e.check(Pa(Is,t)),e.ipv4=t=>e.check(Fa(Ls,t)),e.ipv6=t=>e.check(Ia(Rs,t)),e.cidrv4=t=>e.check(La(zs,t)),e.cidrv6=t=>e.check(Ra(Bs,t)),e.e164=t=>e.check(Va(Us,t)),e.datetime=t=>e.check($o(t)),e.date=t=>e.check(ts(t)),e.time=t=>e.check(rs(t)),e.duration=t=>e.check(as(t))});function ws(e){return ba(Cs,e)}var Ts=A(`ZodStringFormat`,(e,t)=>{oi.init(e,t),Ss.init(e,t)}),Es=A(`ZodEmail`,(e,t)=>{li.init(e,t),Ts.init(e,t)}),Ds=A(`ZodGUID`,(e,t)=>{si.init(e,t),Ts.init(e,t)}),Os=A(`ZodUUID`,(e,t)=>{ci.init(e,t),Ts.init(e,t)}),ks=A(`ZodURL`,(e,t)=>{ui.init(e,t),Ts.init(e,t)}),As=A(`ZodEmoji`,(e,t)=>{di.init(e,t),Ts.init(e,t)}),js=A(`ZodNanoID`,(e,t)=>{fi.init(e,t),Ts.init(e,t)}),Ms=A(`ZodCUID`,(e,t)=>{pi.init(e,t),Ts.init(e,t)}),Ns=A(`ZodCUID2`,(e,t)=>{mi.init(e,t),Ts.init(e,t)}),Ps=A(`ZodULID`,(e,t)=>{hi.init(e,t),Ts.init(e,t)}),Fs=A(`ZodXID`,(e,t)=>{gi.init(e,t),Ts.init(e,t)}),Is=A(`ZodKSUID`,(e,t)=>{_i.init(e,t),Ts.init(e,t)}),Ls=A(`ZodIPv4`,(e,t)=>{Si.init(e,t),Ts.init(e,t)}),Rs=A(`ZodIPv6`,(e,t)=>{Ci.init(e,t),Ts.init(e,t)}),zs=A(`ZodCIDRv4`,(e,t)=>{wi.init(e,t),Ts.init(e,t)}),Bs=A(`ZodCIDRv6`,(e,t)=>{Ti.init(e,t),Ts.init(e,t)}),Vs=A(`ZodBase64`,(e,t)=>{Di.init(e,t),Ts.init(e,t)}),Hs=A(`ZodBase64URL`,(e,t)=>{ki.init(e,t),Ts.init(e,t)}),Us=A(`ZodE164`,(e,t)=>{Ai.init(e,t),Ts.init(e,t)}),Ws=A(`ZodJWT`,(e,t)=>{Mi.init(e,t),Ts.init(e,t)}),Gs=A(`ZodNumber`,(e,t)=>{Ni.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),bs(e,`ZodNumber`,{gt(e,t){return this.check(eo(e,t))},gte(e,t){return this.check(to(e,t))},min(e,t){return this.check(to(e,t))},lt(e,t){return this.check(Qa(e,t))},lte(e,t){return this.check($a(e,t))},max(e,t){return this.check($a(e,t))},int(e){return this.check(Js(e))},safe(e){return this.check(Js(e))},positive(e){return this.check(eo(0,e))},nonnegative(e){return this.check(to(0,e))},negative(e){return this.check(Qa(0,e))},nonpositive(e){return this.check($a(0,e))},multipleOf(e,t){return this.check(no(e,t))},step(e,t){return this.check(no(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});function Ks(e){return qa(Gs,e)}var qs=A(`ZodNumberFormat`,(e,t)=>{Pi.init(e,t),Gs.init(e,t)});function Js(e){return Ja(qs,e)}var Ys=A(`ZodBoolean`,(e,t)=>{Fi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r)});function Xs(e){return Ya(Ys,e)}var Zs=A(`ZodUnknown`,(e,t)=>{Ii.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Qs(){return Xa(Zs)}var $s=A(`ZodNever`,(e,t)=>{Li.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r)});function ec(e){return Za($s,e)}var tc=A(`ZodArray`,(e,t)=>{zi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zo(e,t,n,r),e.element=t.element,bs(e,`ZodArray`,{min(e,t){return this.check(io(e,t))},nonempty(e){return this.check(io(1,e))},max(e,t){return this.check(ro(e,t))},length(e,t){return this.check(ao(e,t))},unwrap(){return this.element}})});function nc(e,t){return yo(tc,e,t)}var rc=A(`ZodObject`,(e,t)=>{Wi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bo(e,t,n,r),pn(e,`shape`,()=>t.shape),bs(e,`ZodObject`,{keyof(){return fc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Qs()})},loose(){return this.clone({...this._zod.def,catchall:Qs()})},strict(){return this.clone({...this._zod.def,catchall:ec()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return jn(this,e)},safeExtend(e){return Mn(this,e)},merge(e){return Nn(this,e)},pick(e){return kn(this,e)},omit(e){return An(this,e)},partial(...e){return Pn(_c,this,e[0])},required(...e){return Fn(Dc,this,e[0])}})});function ic(e,t){return new rc({type:`object`,shape:e??{},...En(t)})}var ac=A(`ZodUnion`,(e,t)=>{Ki.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vo(e,t,n,r),e.options=t.options});function oc(e,t){return new ac({type:`union`,options:e,...En(t)})}var sc=A(`ZodIntersection`,(e,t)=>{qi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ho(e,t,n,r)});function cc(e,t){return new sc({type:`intersection`,left:e,right:t})}var lc=A(`ZodRecord`,(e,t)=>{Xi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function uc(e,t,n){return!t||!t._zod?new lc({type:`record`,keyType:ws(),valueType:e,...En(t)}):new lc({type:`record`,keyType:e,valueType:t,...En(n)})}var dc=A(`ZodEnum`,(e,t)=>{Zi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(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 dc({...t,checks:[],...En(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 dc({...t,checks:[],...En(r),entries:i})}});function fc(e,t){return new dc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...En(t)})}var pc=A(`ZodLiteral`,(e,t)=>{Qi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(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 mc(e,t){return new pc({type:`literal`,values:Array.isArray(e)?e:[e],...En(t)})}var hc=A(`ZodTransform`,(e,t)=>{$i.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new nn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Hn(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(Hn(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 gc(e){return new hc({type:`transform`,transform:e})}var _c=A(`ZodOptional`,(e,t)=>{ta.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vc(e){return new _c({type:`optional`,innerType:e})}var yc=A(`ZodExactOptional`,(e,t)=>{na.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bc(e){return new yc({type:`optional`,innerType:e})}var xc=A(`ZodNullable`,(e,t)=>{ra.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Sc(e){return new xc({type:`nullable`,innerType:e})}var Cc=A(`ZodDefault`,(e,t)=>{ia.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function wc(e,t){return new Cc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Sn(t)}})}var Tc=A(`ZodPrefault`,(e,t)=>{oa.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ec(e,t){return new Tc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Sn(t)}})}var Dc=A(`ZodNonOptional`,(e,t)=>{sa.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Go(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Oc(e,t){return new Dc({type:`nonoptional`,innerType:e,...En(t)})}var kc=A(`ZodCatch`,(e,t)=>{la.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ac(e,t){return new kc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var jc=A(`ZodPipe`,(e,t)=>{ua.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r),e.in=t.in,e.out=t.out});function Mc(e,t){return new jc({type:`pipe`,in:e,out:t})}var Nc=A(`ZodReadonly`,(e,t)=>{fa.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pc(e){return new Nc({type:`readonly`,innerType:e})}var Fc=A(`ZodCustom`,(e,t)=>{ma.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r)});function Ic(e,t={}){return bo(Fc,e,t)}function Lc(e,t){return xo(e,t)}var Rc=class extends Error{constructor(e){super(e),this.name=`ContractMismatchError`}},zc=new Set([`schema_version`,`command_id`,`status`,`message_id`,`run_id`,`accepted_seq`,`error`]),Bc=ic({code:ws().min(1),message:ws(),retryable:Xs(),details:uc(ws(),Qs()).optional()});function Vc(e){let t=ic({schema_version:mc(1),command_id:ws().min(1),status:fc([`accepted`,`duplicate`,`rejected`,`unsupported`,`queue_full`,`persistence_uncertain`]),message_id:ws().min(1).nullable().optional(),run_id:ws().min(1).nullable().optional(),accepted_seq:Ks().int().min(0).nullable().optional(),error:Bc.nullable().optional()}).passthrough().safeParse(e);if(!t.success)throw new Rc(`AgentControlReceipt/v1 mismatch: ${t.error.message}`);let n=t.data;if((n.status===`rejected`||n.status===`unsupported`||n.status===`queue_full`||n.status===`persistence_uncertain`)&&!n.error)throw new Rc(`AgentControlReceipt/v1 mismatch: status ${n.status} requires error`);let r={};for(let[e,t]of Object.entries(n))zc.has(e)||(r[e]=t);let i=n.error?{...n.error,extensions:{}}:null;return{schema_version:1,command_id:n.command_id,status:n.status,message_id:n.message_id??null,run_id:n.run_id??null,accepted_seq:n.accepted_seq??null,error:i,extensions:r}}var Hc=new Set([`schema_version`,`event_id`,`session_id`,`seq`,`timestamp`,`family`,`family_version`,`event_type`,`payload`,`run_id`,`causation_id`,`correlation_id`,`actor_ref`]),Uc=new Map([[`control`,1],[`runtime`,2]]),Wc=ic({schema_version:mc(1),event_id:ws().min(1),session_id:ws().min(1),seq:Ks().int().min(0),timestamp:ws().min(1),family:ws().min(1),family_version:Ks().int().min(1),event_type:ws().min(1),payload:uc(ws(),Qs()),run_id:ws().min(1).nullable().optional(),causation_id:ws().min(1).nullable().optional(),correlation_id:ws().min(1).nullable().optional(),actor_ref:ws().min(1).nullable().optional()}).passthrough();function Gc(e){let t=Wc.safeParse(e);if(!t.success)return{ok:!1,error:new Rc(`SessionEventEnvelope/v1 mismatch: ${t.error.message}`)};let n=t.data,r=Uc.get(n.family);if(r!==void 0&&n.family_version!==r)return{ok:!1,error:new Rc(`SessionEventEnvelope/v1 mismatch: family ${n.family} requires family_version ${r}`)};let i={};for(let[e,t]of Object.entries(n))Hc.has(e)||(i[e]=t);return{ok:!0,value:{schema_version:1,event_id:n.event_id,session_id:n.session_id,seq:n.seq,timestamp:n.timestamp,family:n.family,family_version:n.family_version,event_type:n.event_type,payload:n.payload,run_id:n.run_id??null,causation_id:n.causation_id??null,correlation_id:n.correlation_id??null,actor_ref:n.actor_ref??null,extensions:i}}}var Kc=class{client;constructor(e={}){this.client=new $t(e)}async compactSession(e,t){return this.client.postJsonAction(`CompactSession`,{AgentId:e,SessionId:t})}async listSessions(e,t){let n=await this.client.postJsonAction(`ListSessions`,{AgentId:e,Page:t?.page,PageSize:t?.pageSize},t),r=n.Sessions??[];return{Sessions:r,Total:Number.isFinite(Number(n.Total))?Number(n.Total):r.length,Page:Number.isFinite(Number(n.Page))?Number(n.Page):t?.page??1,PageSize:Number.isFinite(Number(n.PageSize))?Number(n.PageSize):t?.pageSize??r.length}}async createSession(e,t){let n=await this.client.postJsonAction(`CreateSession`,{AgentId:e},t);return{SessionId:String(n.Session?.SessionId||``)}}async deleteSession(e,t){return this.client.postJsonAction(`DeleteSession`,{SessionId:e},t)}async getSession(e,t){return(await this.client.postJsonAction(`GetSession`,{SessionId:e},t)).Session}async listSessionEvents(e,t){let n=await this.client.postJsonAction(`ListSessionEvents`,{SessionId:e,Offset:t?.offset,Limit:t?.limit},t),r=n.Events??[];return{Events:r,Total:Number.isFinite(Number(n.Total))?Number(n.Total):r.length,Offset:Number.isFinite(Number(n.Offset))?Number(n.Offset):t?.offset??0,Limit:Number.isFinite(Number(n.Limit))?Number(n.Limit):t?.limit??r.length}}async listSessionMessages(e,t){let n=await this.client.postJsonAction(`ListSessionMessages`,{AgentId:t?.agentId,SessionId:e,AfterSeqId:t?.afterSeqId,BeforeSeqId:t?.beforeSeqId,Limit:t?.limit,IncludeReasoning:t?.includeReasoning,IncludeToolEvents:t?.includeToolEvents,IncludeAttachments:t?.includeAttachments},t);return{Messages:n.Messages??[],LatestSeqId:Number.isFinite(Number(n.LatestSeqId))?Number(n.LatestSeqId):0,HasMore:!!n.HasMore,NextCursor:n.NextCursor===null||n.NextCursor===void 0?null:Number.isFinite(Number(n.NextCursor))?Number(n.NextCursor):null}}async listSessionCheckpoints(e,t){return this.client.postJsonAction(`ListSessionCheckpoints`,{AgentId:e.agentId,SessionId:e.sessionId,...e.runId?{RunId:e.runId}:{}},t)}async previewCheckpointResume(e,t){return this.client.postJsonAction(`GetCheckpointResumePreview`,{AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId},t)}async listToolReceipts(e,t){return this.client.postJsonAction(`ListToolReceipts`,{AgentId:e.agentId,SessionId:e.sessionId,...e.runId?{RunId:e.runId}:{},...e.checkpointId?{CheckpointId:e.checkpointId}:{}},t)}async runAgent(e,t){return this.client.streamAction(`RunAgent`,e,t)}async resumeRun(e,t){return this.client.streamAction(`ResumeRun`,{AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId,Stream:!0,...e.resumeAttemptId?{ResumeAttemptId:e.resumeAttemptId}:{},...e.invocationId?{InvocationId:e.invocationId}:{}},t)}async subscribeRunEvents(e,t){return this.client.streamGetAction(`SubscribeRunEvents`,{SessionId:e.sessionId,InvocationId:e.invocationId,AfterSeqId:String(e.afterSeqId)},t)}async submitControl(e,t){return Vc(await this.client.postJsonAction(`SubmitAgentControl`,{CommandType:e.command_type,IdempotencyKey:e.idempotency_key,Payload:e.payload},t))}async submitInteraction(e,t){return Vc(await this.client.postJsonAction(`SubmitInteraction`,{...e},t))}async getAgentStatus(e){return this.client.postJsonAction(`GetAgentStatus`,{},e)}async subscribeSessionEvents(e,t,n){return this.client.streamGetAction(`SubscribeSessionEvents`,{SessionId:e,after_seq:String(t)},n)}async cancelRun(e,t,n,r){return this.client.postJsonAction(`CancelRun`,{AgentId:e,SessionId:t,InvocationId:n},r)}async getResponseFeedback(e,t){return this.client.postJsonAction(`GetResponseFeedback`,e,t)}async upsertResponseFeedback(e,t){return this.client.postJsonAction(`UpsertResponseFeedback`,e,t)}async deleteResponseFeedback(e,t){await this.client.postJsonAction(`DeleteResponseFeedback`,e,t)}async listWorkspaceFiles(e,t,n,r){return this.client.postJsonAction(`ListWorkspaceFiles`,{AgentId:e,Path:t,Recursive:n},r)}async addWorkspaceFile(e,t){return this.client.postFormAction(`AddWorkspaceFile`,e,t)}async deleteWorkspaceFile(e,t,n){await this.client.postJsonAction(`DeleteWorkspaceFile`,{AgentId:e,Path:t},n)}async getWorkspaceFileContent(e,t,n){return this.client.getResource(`GetWorkspaceFileContent`,{AgentId:e,Path:t},n)}async listAgentModels(e,t){return this.client.postJsonAction(`ListAgentModels`,{AgentId:e},t)}async getAgentUiBootstrap(e,t){return this.client.postJsonAction(`GetAgentUiBootstrap`,e?{AgentId:e}:{},t)}async uploadFile(e,t){return this.client.postFormAction(`UploadFile`,e,t)}};function qc(e){return e instanceof Jt&&(e.code===401||e.code===403)?`auth-required`:`error`}function Jc(e){if(!Array.isArray(e))return[`responses`,`chat_completions`];let t=e.filter(e=>e===`responses`||e===`chat_completions`);return t.length>0?t:[`responses`,`chat_completions`]}var Yc=new Kc;async function Xc(e,t=Yc){try{let n=await t.listAgentModels(e),r=n?.Models;Array.isArray(r)&&We.getState().upsertModels(r);let i=n;i?.Current&&!We.getState().selectedModel&&We.getState().setSelectedModel(String(i.Current)),i?.Source&&We.getState().setModelSource(String(i.Source))}catch(e){console.error(`Failed to fetch models:`,e)}finally{We.getState().setModelCatalogLoaded(!0)}}function Zc(e,t,n=Yc,r){(0,v.useEffect)(()=>{let i=new AbortController;return(async()=>{He.getState().setStatus(`loading`);try{let a=r??await n.getAgentUiBootstrap(t,{signal:i.signal});if(i.signal.aborted)return;let o=a,s=o?.Agent,c=String(s?.AgentId||`default-agent`);if(He.getState().setAgentId(c),s?.Name){let e=String(s.Name);He.getState().setAgentName(e),document.title=e}let l=String(s?.Framework||``).trim().toLowerCase();He.getState().setAgentFramework(l);let u=ze(a);He.getState().setCapabilities(u),He.getState().setApiFormats(Jc(u.HostedChat.ApiFormats)),He.getState().setAccessMode(String(o?.AccessMode||`Owner`));let d=u.WorkspaceFiles&&o?.WorkspaceFiles?o.WorkspaceFiles:null;He.getState().setWorkspaceFiles(d),d||ve.getState().setWorkspacePanelOpen(!1),Be(u)&&e.fetchSessions(c,Nt(c));let f=o?.Model;f?.id&&(We.getState().setSelectedModel(f.id),We.getState().upsertModels([f]),We.getState().setModelSource(f.source||``)),Xc(c,n),He.getState().setStatus(`ready`)}catch(e){if(i.signal.aborted)return;console.error(`Failed to fetch bootstrap:`,e);let t=qc(e);He.getState().setStatus(t,t===`auth-required`?`当前访问链接未授权或已过期。`:`无法加载 Agent 配置,请稍后重试。`)}})(),()=>i.abort()},[n,t,r])}var Qc=te()(e=>({messages:[],setMessages:t=>e({messages:t}),patchMessages:t=>e(e=>({messages:t(e.messages)}))}));function $c(){return{toolNames:new Map,toolArguments:new Map,callIds:new Map,currentResponseId:``,sawTextDelta:!1,sawReasoningDelta:!1}}function el(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>typeof e==`string`?e:e&&typeof e==`object`&&typeof e.text==`string`?e.text:``).join(``):e&&typeof e==`object`&&typeof e.text==`string`?e.text:``}function tl(e){return e==null?``:typeof e==`string`?e:typeof e==`object`?JSON.stringify(e,null,2):String(e)}function nl(...e){for(let t of e){let e=el(t);if(e)return e}return``}function rl(e,t){return String(e?.id||e?.item_id||e?.call_id||t?.item_id||t?.call_id||t?.output_index||``)}function il(e,t,n,r,i){t&&(e.toolNames.set(t,r),e.toolArguments.set(t,i));let a=String(n?.call_id||``);a&&(e.callIds.set(a,t||r),e.toolNames.set(a,r),e.toolArguments.set(a,i))}function al(e,t,n,r=`tool`){let i=String(n?.call_id||``);return String(n?.name||n?.tool_name||(t?e.toolNames.get(t):``)||(i?e.toolNames.get(i):``)||r)}function ol(e){if(!e||typeof e!=`object`)return``;let t=el(e.content);return nl(e.output_text,e.text,e.summary_text,e.summary,e.delta,t)}function sl(e){let t=e?.response&&typeof e.response==`object`?e.response:e,n=nl(t?.output_text,t?.text);if(n)return n;let r=Array.isArray(t?.output)?t.output:[];for(let e of r){let t=ol(e);if(t)return t}return``}function cl(e){let t=e?.response&&typeof e.response==`object`?e.response:e;return Array.isArray(t?.output)?t.output:[]}function ll(e){let t=e;if(typeof t==`string`)try{t=JSON.parse(t)}catch{return{}}return Array.isArray(t)&&(t=t[0]||{}),!t||typeof t!=`object`?{}:t.value&&typeof t.value==`object`&&!Array.isArray(t.value)?{...t.value,approval_request_id:t.value.approval_request_id||t.value.id||t.id}:t}function ul({data:e,state:t,status:n}){let r=e?.item||e?.output_item||e||{},i=String(r.type||``).trim(),a=rl(r,e);if(i===`function_call`){let e=al(t,a,r),i=tl(r.arguments??r.args??r.input);return il(t,a,r,e,i),[{type:`tool_upsert`,name:e,args:i,status:n}]}if(i===`function_call_output`)return[{type:`tool_result`,name:al(t,a,r),output:tl(r.output??r.result??r.content)}];if(i===`mcp_approval_request`){let n=String(r.name||`approval`),i=tl(r.arguments??r.args),a=String(r.id||r.approval_request_id||``),o=String(r.run_id||r.runId||e?.run_id||e?.runId||``);return[{type:`tool_upsert`,name:n,args:i,status:`paused`,approvalRequestId:a,previousResponseId:String(e?.response_id||t.currentResponseId||``),serverLabel:String(r.server_label||``)},{type:`approval_request`,approvalRequestId:a,previousResponseId:String(e?.response_id||t.currentResponseId||``),...o?{runId:o}:{},name:n,args:i}]}if(i===`reasoning`||i===`reasoning_summary`||i===`reasoning_summary_text`){let e=ol(r);return e?[{type:`reasoning_delta`,text:e}]:[]}if(i===`message`){let e=ol(r);return e?[{type:n===`completed`?`text_final`:`text_delta`,text:e}]:[]}return[]}function dl({eventName:e,data:t,state:n}){let r=String(t?.type||e||``).trim(),i=String(t?.id||t?.response?.id||t?.response_id||``);if(i.startsWith(`resp_`)&&(n.currentResponseId=i),r===`response.tool_call`)return[{type:`tool_upsert`,name:String(t?.name||t?.tool_name||`tool`),args:tl(t?.args??t?.arguments),status:`running`}];if(r===`response.tool_result`||r===`response.ksadk.tool_result`)return[{type:`tool_result`,name:String(t?.name||t?.tool_name||`tool`),output:tl(t?.output??t?.result)}];if(r===`response.output_item.added`)return ul({data:t,state:n,status:`running`});if(r===`response.output_item.done`)return ul({data:t,state:n,status:`completed`});if(r===`response.function_call_arguments.delta`){let e=String(t?.item_id||t?.call_id||``),r=al(n,e,t),i=`${n.toolArguments.get(e)||``}${String(t?.delta||``)}`;return n.toolArguments.set(e,i),[{type:`tool_upsert`,name:r,args:i,status:`running`}]}if(r===`response.function_call_arguments.done`){let e=String(t?.item_id||t?.call_id||``),r=al(n,e,t),i=tl(t?.arguments??n.toolArguments.get(e));return n.toolArguments.set(e,i),[{type:`tool_upsert`,name:r,args:i,status:`running`}]}if(r===`response.reasoning.delta`||r===`response.reasoning_text.delta`||r===`response.reasoning_summary.delta`||r===`response.reasoning_summary_text.delta`){let e=nl(t?.delta,t?.text);return e&&(n.sawReasoningDelta=!0),e?[{type:`reasoning_delta`,text:e}]:[]}if(r===`response.output_text.delta`){let e=nl(t?.delta,t?.text);return e&&(n.sawTextDelta=!0),e?[{type:`text_delta`,text:e}]:[]}if(r===`response.output_text.done`){let e=nl(t?.text,t?.delta);return e?[{type:`text_final`,text:e}]:[]}if(r===`response.content_part.delta`){let e=String(t?.part?.type||t?.delta?.type||t?.content_type||``),r=nl(t?.delta?.text,t?.delta,t?.text);return r?e.includes(`reasoning`)?(n.sawReasoningDelta=!0,[{type:`reasoning_delta`,text:r}]):(n.sawTextDelta=!0,[{type:`text_delta`,text:r}]):[]}if(r===`response.completed`){let e=sl(t),r=cl(t).flatMap(e=>ul({data:{...t,item:e},state:n,status:`completed`})).filter(e=>!(n.sawTextDelta&&e.type===`text_final`)&&!(n.sawReasoningDelta&&e.type===`reasoning_delta`)),i=r.some(e=>e.type===`text_final`);return[...r,...e&&!n.sawTextDelta&&!i?[{type:`text_final`,text:e}]:[],{type:`terminal`,status:`completed`}]}if(r===`response.failed`)return[{type:`failed`,message:t?.error?.message||`Agent 运行失败`},{type:`terminal`,status:`failed`}];if(r===`response.incomplete`)return[{type:`incomplete`},{type:`terminal`,status:`incomplete`}];if(r===`response.cancelled`)return[{type:`terminal`,status:`cancelled`}];if(r===`response.approval_request`||r===`response.ksadk.approval_request`){let e=ll(t?.interrupt_info),r=String(e.approval_request_id||e.id||``),i=String(t?.response_id||n.currentResponseId||``),a=String(t?.run_id||t?.runId||``),o=e.approval_requests&&typeof e.approval_requests==`object`?e.approval_requests:e,s=Array.isArray(o.action_requests)?o.action_requests:[];if(s.length>0){let e=s.map(e=>({type:`tool_upsert`,name:String(e?.name||`tool`),args:JSON.stringify(e?.args??{}),status:`paused`,approvalRequestId:r,previousResponseId:i})),t=s[0]||{};return[...e,{type:`approval_request`,approvalRequestId:r,previousResponseId:i,...a?{runId:a}:{},name:String(t?.name||`人工确认`),args:JSON.stringify(t?.args??{})}]}return[{type:`approval_request`,approvalRequestId:r,previousResponseId:i,...a?{runId:a}:{}}]}if(r===`response.approval_resolved`||r===`response.ksadk.approval_resolved`){let e=String(t?.decision||t?.outcome||``).toLowerCase(),n=e===`reject`||e===`rejected`||e===`denied`?`rejected`:e===`cancel`||e===`cancelled`||e===`canceled`?`cancelled`:`approved`;return[{type:`approval_resolved`,approvalRequestId:String(t?.approval_request_id||t?.approvalRequestId||t?.approval_id||t?.approvalId||``),decision:n,revision:Number(t?.revision||2)}]}if(new Set([`response.ksadk.a2ui_surface_begin`,`a2ui.surface.begin`,`response.a2ui.createSurface`,`a2ui.createSurface`,`createSurface`]).has(r)){let e=t?.surface&&typeof t.surface==`object`?t.surface:{};return[{type:`a2ui_surface_begin`,surfaceId:String(t?.surface_id||t?.surfaceId||e.surface_id||e.surfaceId||``),surface:e}]}if(new Set([`response.ksadk.a2ui_surface_update`,`a2ui.surface.update`,`response.a2ui.updateComponents`,`a2ui.updateComponents`,`updateComponents`]).has(r)){let e=t?.surface&&typeof t.surface==`object`?t.surface:{};return[{type:`a2ui_surface_update`,surfaceId:String(t?.surface_id||t?.surfaceId||e.surface_id||e.surfaceId||``),surface:e}]}if(new Set([`response.ksadk.a2ui_surface_end`,`a2ui.surface.end`,`response.a2ui.deleteSurface`,`a2ui.deleteSurface`,`deleteSurface`]).has(r))return[{type:`a2ui_surface_end`,surfaceId:String(t?.surface_id||t?.surfaceId||``)}];if(new Set([`response.ksadk.a2ui_interaction`,`a2ui.interaction`]).has(r))return[{type:`a2ui_interaction`,surfaceId:String(t?.surface_id||t?.surfaceId||``),interactionId:String(t?.interaction_id||t?.interactionId||``),kind:String(t?.kind||`input`),inputSchema:t?.input_schema&&typeof t.input_schema==`object`?t.input_schema:{}}];let a=t?.content?.parts?.[0]?.text;return a&&!t?.actions?.finishReason?[{type:`text_delta`,text:String(a)}]:[]}var fl=class{id=`responses`;createState(){return $c()}parseItemOperations(e,t,n){return Qe(e.eventName,e.data,t,n)}parse(e,t){return dl({eventName:e.eventName,data:e.data,state:t}).map(e=>{if(e.type===`tool_upsert`){let{approvalRequestId:t,previousResponseId:n,serverLabel:r,...i}=e;return{...i,extra:{...t?{approvalRequestId:t}:{},...n?{previousResponseId:n}:{},...r?{serverLabel:r}:{},...t?{approvalProtocol:`responses`}:{}}}}return e})}};function pl(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>typeof e==`string`?e:e&&typeof e==`object`&&`text`in e&&typeof e.text==`string`?e.text:``).join(``):``}function ml(e){return e&&typeof e==`object`?e:{}}function hl(e){let t=ml(e).choices,n=ml(Array.isArray(t)?t[0]:null),r=ml(n.delta),i=ml(n.message);return{content:pl(r.content),reasoning:pl(r.reasoning_content),finalText:pl(i.content)}}var gl=class{id=`chat_completions`;createState(){return{}}parse(e){let t=e.data;if(typeof t!=`object`||!t)return[];let n=hl(t),r=[];return n.reasoning&&r.push({type:`reasoning_delta`,text:n.reasoning}),n.content&&r.push({type:`text_delta`,text:n.content}),n.finalText&&r.push({type:`text_final`,text:n.finalText}),r}},_l=new Map;_l.set(`responses`,new fl),_l.set(`chat_completions`,new gl);function vl(e){return _l.get(e)||_l.get(`responses`)}function yl(e=[]){return e.some(e=>{if(e?.type!==`terminal`)return!1;let t=String(e.status||``).toLowerCase();return t===`failed`||t===`incomplete`||t===`cancelled`})}function bl(e){let t=[],n=e.trim();if(!n)return t;let r=n.split(`
|
|
74
|
+
`);if(r.every(e=>e.startsWith(`:`)))return t.push({eventName:`__ping__`,data:null}),t;let i=`message`,a=[];for(let e of r)e.startsWith(`:`)||(e.startsWith(`event:`)?i=e.substring(6).trim()||`message`:e.startsWith(`data:`)&&a.push(e.substring(5).trim()));let o=a.join(`
|
|
75
|
+
`).trim();if(o===`[DONE]`)return t.push({eventName:`__done__`,data:null}),t;if(!o)return t;try{let e=JSON.parse(o);t.push({eventName:i,data:e})}catch{t.push({eventName:i,data:o})}return t}function xl(e){let t=e.split(`
|
|
76
|
+
|
|
77
|
+
`);return{chunks:t,remainder:t.pop()||``}}function Sl(e){return e instanceof Error?e.message:String(e)}var Cl=l(h(),1),wl=1280;function Tl(e){let{apiFormats:t}=e;return t.includes(`responses`)?`responses`:t.includes(`chat_completions`)?`chat_completions`:`responses`}function El(e,t,n){let r=Math.min(wl,Math.max(420,t-n-360));return Math.min(Math.max(e,420),r)}var Dl={"run.started":`in_progress`,"run.progress":`in_progress`,"run.completed":`completed`,"run.failed":`failed`,"run.canceled":`cancelled`,"run.interrupted":`interrupted`},Ol=new Set([`completed`,`failed`,`cancelled`,`canceled`]);function kl(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Al(e){let t=kl(e.source),n=t?kl(t.metadata):null;return String(n?.native_item_kind||``)}function jl(e,t){let n=kl(e[t]);if(!n)return[];let r=n?.parts;return Array.isArray(r)?r:t===`update`?[n]:[]}function Ml(e){let t=kl(e);if(!t)return``;if(typeof t.text==`string`)return t.text;let n=kl(t.data);if(n){let e=n.content;if(Array.isArray(e))return e.map(e=>String(kl(e)?.text||``)).join(``);for(let e of[`text`,`output`,`stdout`,`stderr`])if(n[e]!=null)return String(n[e])}return``}function Nl(e){return e.map(Ml).join(``)}function Pl(e){return e.some(e=>kl(kl(e)?.data)?.type===`userMessage`)}function Fl(e){if(e.length===1){let t=kl(kl(e[0])?.data);if(t)return t}return Nl(e)||null}function Il(e){let t=kl(e);return t?kl(t.data)||t:null}function Ll(e){let t=Il(e);return String(t?.content_type||t?.type||``).trim().toLowerCase()}function Rl(e){for(let t of e){let e=Il(t);if(!e||Ll(t)!==`tool_call`)continue;let n=String(e.call_id||``).trim(),r=String(e.name||e.tool_name||``).trim();if(!(!n&&!r))return{callId:n,name:r,arguments:e.arguments??e.args??{}}}return null}function zl(e){for(let t of e){let e=Il(t);if(!e||Ll(t)!==`tool_result`)continue;let n=String(e.call_id||e.tool_call_id||``).trim(),r=e.is_error===!0||e.error!=null;return{callId:n,result:e.result??e.output??e.error??null,isError:r}}return null}function Bl(e,t,n,r){let i=String(e.item_id||``),a=String(r||i);return{RuntimeItem:{RunId:String(e.run_id||``),ScopeId:String(e.scope_id||e.run_id||``),ItemId:a,...n?{PartId:n}:{},Operation:t,SourceEventId:String(e.event_id||``),...i&&i!==a?{SourceItemId:i}:{}}}}var Vl=class{textByPart=new Map;toolNameByCallId=new Map;toolCallByItemId=new Map;toolResultByItemId=new Map;sessionId;constructor(e){this.sessionId=e}translate(e){if(!kl(e))return null;let t=Number(e.seq);if(!Number.isFinite(t)||t<=0)return null;let n=String(e.family||``),r=String(e.event_type||``),i=String(e.run_id||``),a=()=>({EventId:e.event_id?String(e.event_id):`kernel-${t}`,SessionId:this.sessionId,InvocationId:i||void 0,SeqId:t});if(n===`interaction`)return{...a(),EventType:r,payload:e};if(n===`control`){if(r===`control.run_transition`){let t=String(e.state||``).toLowerCase();if(Ol.has(t))return{...a(),EventType:`run_status`,Content:{status:t}}}return null}if(n!==`runtime`)return null;let o=Dl[r];if(o)return{...a(),EventType:`run_status`,Content:{status:o}};let s=Al(e);if(r===`item.started`){let t=jl(e,`initial`);if(e.item_kind===`tool_call`){let n=Rl(t),r=n?.callId||String(e.item_id||``),o=n?.name||`tool`;return r&&this.toolNameByCallId.set(r,o),e.item_id&&this.toolCallByItemId.set(String(e.item_id),{callId:r,name:o}),{...a(),EventType:`tool_call`,Metadata:{...Bl(e,`replace`,void 0,r),call_id:r,tool_name:o,run_id:i,tool_args:n?.arguments??Fl(t)}}}return e.item_kind===`tool_result`||s===`userMessage`||Pl(t)||s===`reasoning`||e.item_kind===`reasoning`?null:s===`agentMessage`||!s&&e.item_kind===`message`?{...a(),EventType:`assistant_stream_snapshot`,Content:{parts:[{text:``}]},Metadata:Bl(e,`replace`)}:s&&s!==`notification`?{...a(),EventType:`tool_call`,Metadata:{...Bl(e,`replace`),call_id:String(e.item_id||``),tool_name:s,run_id:i,tool_args:Fl(t)}}:null}if(r===`item.updated`){let n=jl(e,`update`);if(e.item_kind===`tool_call`){let t=zl(n);if(!t)return null;let r=this.toolCallByItemId.get(String(e.item_id||``)),o=t.callId||r?.callId||String(e.item_id||``),s=r?.name||this.toolNameByCallId.get(o)||`tool`,c=t.isError?{error:t.result}:t.result;return e.item_id&&this.toolResultByItemId.set(String(e.item_id),c),{...a(),EventType:`tool_result`,Metadata:{...Bl(e,`completed`,void 0,o),call_id:o,tool_name:s,run_id:i,tool_output:c}}}let r=kl(n[0]),o=String(r?.part_id||e.item_id||t),c=String(e.op||`replace`),l=Nl(n),u=this.textByPart.get(o)||``,d=c===`append`?u+l:l;return this.textByPart.set(o,d),s===`agentMessage`||!s&&e.item_kind===`message`?{...a(),EventType:`assistant_stream_snapshot`,Content:{parts:[{text:d}]},Metadata:Bl(e,`replace`,o)}:s===`reasoning`||e.item_kind===`reasoning`?{...a(),EventType:`reasoning`,Content:{parts:[{text:l}]},Metadata:Bl(e,c===`append`?`append`:`replace`,o)}:null}if(r===`item.snapshot_replaced`){let n=jl(e,`snapshot`),r=String(kl(n[0])?.part_id||e.item_id||t),i=Nl(n);return this.textByPart.set(r,i),s===`agentMessage`||!s&&e.item_kind===`message`?{...a(),EventType:`assistant_stream_snapshot`,Content:{parts:[{text:i}]},Metadata:Bl(e,`replace`,r)}:s===`reasoning`||e.item_kind===`reasoning`?{...a(),EventType:`reasoning`,Content:{parts:[{text:i}]},Metadata:Bl(e,`replace`,r)}:null}if(r===`item.completed`){let n=jl(e,`snapshot`);if(e.item_kind===`tool_call`){let t=Rl(n),r=zl(n),o=this.toolCallByItemId.get(String(e.item_id||``)),s=r?.callId||t?.callId||o?.callId||String(e.item_id||``),c=t?.name||o?.name||this.toolNameByCallId.get(s)||`tool`;if(s&&this.toolNameByCallId.set(s,c),r){let t=r.isError?{error:r.result}:r.result;return{...a(),EventType:`tool_result`,Metadata:{...Bl(e,`completed`,void 0,s),call_id:s,tool_name:c,run_id:i,tool_output:t}}}return{...a(),EventType:`tool_call`,Metadata:{...Bl(e,`replace`,void 0,s),call_id:s,tool_name:c,run_id:i,tool_args:t?.arguments??Fl(n)}}}if(e.item_kind===`tool_result`){let t=zl(n),r=t?.callId||String(e.item_id||``),o=this.toolNameByCallId.get(r)||s||`tool`,c=t?.isError?{error:t.result}:t?.result??Fl(n);return{...a(),EventType:`tool_result`,Metadata:{...Bl(e,`completed`,void 0,r),call_id:r,tool_name:o,run_id:i,tool_output:c}}}if(s===`userMessage`||Pl(n))return{...a(),EventType:`user_message`,Content:{parts:[{text:Nl(n)}]}};if(s===`agentMessage`||!s&&e.item_kind===`message`){let r=Nl(n),i=String(kl(n[0])?.part_id||e.item_id||t);return this.textByPart.set(i,r),{...a(),EventType:`assistant_message`,Content:{parts:[{text:r}]},Metadata:Bl(e,`completed`,i)}}if(s===`reasoning`||e.item_kind===`reasoning`){let r=String(kl(n[0])?.part_id||e.item_id||t);return{...a(),EventType:`reasoning`,Content:{parts:[{text:Nl(n)}]},Metadata:Bl(e,`completed`,r)}}return s&&s!==`notification`?{...a(),EventType:`tool_result`,Metadata:{...Bl(e,`completed`),call_id:String(e.item_id||``),tool_name:s,run_id:i,tool_output:Fl(n)}}:null}if(r===`item.failed`){if(e.item_kind===`tool_call`){let t=this.toolCallByItemId.get(String(e.item_id||``)),n=t?.callId||String(e.item_id||``),r=t?.name||this.toolNameByCallId.get(n)||`tool`,o=this.toolResultByItemId.get(String(e.item_id||``));return{...a(),EventType:`tool_result`,Metadata:{...Bl(e,`completed`,void 0,n),call_id:n,tool_name:r,run_id:i,tool_output:o??{error:kl(e.error)||e.error||`item failed`}}}}return s&&s!==`notification`&&s!==`agentMessage`&&s!==`reasoning`?{...a(),EventType:`tool_result`,Metadata:{...Bl(e,`completed`),call_id:String(e.item_id||``),tool_name:s,run_id:i,tool_output:{error:kl(e.error)||e.error||`item failed`}}}:null}return null}};async function Hl(e){let t=e.getReader(),n=new TextDecoder,r=``,i=null,a=!1,o=e=>e.includes(`data:`)||e.includes(`event:`)||e.includes(`:`);try{for(;;){let{value:e,done:s}=await t.read();if(e&&(r+=n.decode(e,{stream:!0})),s){a=!0;break}if(r.trimStart().startsWith(`{`)){if(Ul(r)){i=Wl(r);break}}else if(o(r))break}}catch{}let s=new TextEncoder().encode(r),c=new ReadableStream({start(e){if(s.length>0&&e.enqueue(s),a||i){e.close();return}let n=()=>t.read().then(({value:t,done:r})=>{if(t&&e.enqueue(t),r){e.close();return}return n()}).catch(()=>{try{e.close()}catch{}});n()},cancel(){t.cancel()}});return{receipt:i,stream:c}}function Ul(e){let t=e.trim();if(!t.endsWith(`}`))return!1;let n=0,r=!1,i=!1;for(let e of t){if(i){i=!1;continue}if(e===`\\`){i=!0;continue}e===`"`&&(r=!r),!r&&((e===`{`||e===`[`)&&(n+=1),(e===`}`||e===`]`)&&--n)}return n===0}function Wl(e){try{let t=kl(JSON.parse(e).Data),n=String(t?.ReceiptStatus||``);if(!n)return null;let r=kl(t?.Error);return{status:n,messageId:t?.MessageId??null,runId:t?.RunId??null,acceptedSeq:t?.AcceptedSeq??null,error:r?{code:String(r.code||``),message:String(r.message||``)}:null}}catch{return null}}var Gl=[];for(let e=0;e<256;++e)Gl.push((e+256).toString(16).slice(1));function Kl(e,t=0){return(Gl[e[t+0]]+Gl[e[t+1]]+Gl[e[t+2]]+Gl[e[t+3]]+`-`+Gl[e[t+4]]+Gl[e[t+5]]+`-`+Gl[e[t+6]]+Gl[e[t+7]]+`-`+Gl[e[t+8]]+Gl[e[t+9]]+`-`+Gl[e[t+10]]+Gl[e[t+11]]+Gl[e[t+12]]+Gl[e[t+13]]+Gl[e[t+14]]+Gl[e[t+15]]).toLowerCase()}var ql,Jl=new Uint8Array(16);function Yl(){if(!ql){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);ql=crypto.getRandomValues.bind(crypto)}return ql(Jl)}var Xl={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Zl(e,t,n){if(Xl.randomUUID&&!t&&!e)return Xl.randomUUID();e||={};let r=e.random??e.rng?.()??Yl();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return Kl(r)}var Ql;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(Ql||={});var $l;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})($l||={});var j=Ql.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),eu=e=>{switch(typeof e){case`undefined`:return j.undefined;case`string`:return j.string;case`number`:return Number.isNaN(e)?j.nan:j.number;case`boolean`:return j.boolean;case`function`:return j.function;case`bigint`:return j.bigint;case`symbol`:return j.symbol;case`object`:return Array.isArray(e)?j.array:e===null?j.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?j.promise:typeof Map<`u`&&e instanceof Map?j.map:typeof Set<`u`&&e instanceof Set?j.set:typeof Date<`u`&&e instanceof Date?j.date:j.object;default:return j.unknown}},M=Ql.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),tu=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ql.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};tu.create=e=>new tu(e);var nu=(e,t)=>{let n;switch(e.code){case M.invalid_type:n=e.received===j.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case M.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Ql.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ql.joinValues(e.keys,`, `)}`;break;case M.invalid_union:n=`Invalid input`;break;case M.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ql.joinValues(e.options)}`;break;case M.invalid_enum_value:n=`Invalid enum value. Expected ${Ql.joinValues(e.options)}, received '${e.received}'`;break;case M.invalid_arguments:n=`Invalid function arguments`;break;case M.invalid_return_type:n=`Invalid function return type`;break;case M.invalid_date:n=`Invalid date`;break;case M.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Ql.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case M.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case M.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case M.custom:n=`Invalid input`;break;case M.invalid_intersection_types:n=`Intersection results could not be merged`;break;case M.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case M.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,Ql.assertNever(e)}return{message:n}},ru=nu;function iu(){return ru}var au=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function N(e,t){let n=iu(),r=au({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===nu?void 0:nu].filter(e=>!!e)});e.common.issues.push(r)}var ou=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return su;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return su;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},su=Object.freeze({status:`aborted`}),cu=e=>({status:`dirty`,value:e}),lu=e=>({status:`valid`,value:e}),uu=e=>e.status===`aborted`,du=e=>e.status===`dirty`,fu=e=>e.status===`valid`,pu=e=>typeof Promise<`u`&&e instanceof Promise,mu;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(mu||={});var hu=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},gu=(e,t)=>{if(fu(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new tu(e.common.issues);return this._error=t,this._error}}};function _u(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var vu=class{get description(){return this._def.description}_getType(e){return eu(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:eu(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ou,ctx:{common:e.parent.common,data:e.data,parsedType:eu(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(pu(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:eu(e)};return gu(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:eu(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return fu(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>fu(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:eu(e)},r=this._parse({data:e,path:n.path,parent:n});return gu(n,await(pu(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:M.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new xd({schema:this,typeName:Ad.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return Sd.create(this,this._def)}nullable(){return Cd.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return nd.create(this)}promise(){return bd.create(this,this._def)}or(e){return ad.create([this,e],this._def)}and(e){return ld.create(this,e,this._def)}transform(e){return new xd({..._u(this._def),schema:this,typeName:Ad.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new wd({..._u(this._def),innerType:this,defaultValue:t,typeName:Ad.ZodDefault})}brand(){return new Dd({typeName:Ad.ZodBranded,type:this,..._u(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Td({..._u(this._def),innerType:this,catchValue:t,typeName:Ad.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Od.create(this,e)}readonly(){return kd.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},yu=/^c[^\s-]{8,}$/i,bu=/^[0-9a-z]+$/,xu=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Su=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Cu=/^[a-z0-9_-]{21}$/i,wu=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Tu=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Eu=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Du=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,Ou,ku=/^(?:(?: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])$/,Au=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,ju=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Mu=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Nu=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Pu=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Fu=`((\\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])))`,Iu=RegExp(`^${Fu}$`);function Lu(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Ru(e){return RegExp(`^${Lu(e)}$`)}function zu(e){let t=`${Fu}T${Lu(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Bu(e,t){return!!((t===`v4`||!t)&&ku.test(e)||(t===`v6`||!t)&&ju.test(e))}function Vu(e,t){if(!wu.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function Hu(e,t){return!!((t===`v4`||!t)&&Au.test(e)||(t===`v6`||!t)&&Mu.test(e))}var Uu=class e extends vu{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==j.string){let t=this._getOrReturnCtx(e);return N(t,{code:M.invalid_type,expected:j.string,received:t.parsedType}),su}let t=new ou,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),N(n,{code:M.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),N(n,{code:M.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?N(n,{code:M.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&N(n,{code:M.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)Eu.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:`email`,code:M.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)Ou||=new RegExp(Du,`u`),Ou.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:`emoji`,code:M.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Su.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:`uuid`,code:M.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)Cu.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:`nanoid`,code:M.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)yu.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:`cuid`,code:M.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)bu.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:`cuid2`,code:M.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)xu.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:`ulid`,code:M.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),N(n,{validation:`url`,code:M.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:`regex`,code:M.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),N(n,{code:M.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),N(n,{code:M.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),N(n,{code:M.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?zu(r).test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{code:M.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Iu.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{code:M.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Ru(r).test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{code:M.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?Tu.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:`duration`,code:M.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?Bu(e.data,r.version)||(n=this._getOrReturnCtx(e,n),N(n,{validation:`ip`,code:M.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?Vu(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),N(n,{validation:`jwt`,code:M.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?Hu(e.data,r.version)||(n=this._getOrReturnCtx(e,n),N(n,{validation:`cidr`,code:M.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?Nu.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:`base64`,code:M.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?Pu.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:`base64url`,code:M.invalid_string,message:r.message}),t.dirty()):Ql.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:M.invalid_string,...mu.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...mu.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...mu.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...mu.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...mu.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...mu.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...mu.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...mu.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...mu.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...mu.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...mu.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...mu.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...mu.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...mu.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...mu.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...mu.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...mu.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...mu.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...mu.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...mu.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...mu.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...mu.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...mu.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...mu.errToObj(t)})}nonempty(e){return this.min(1,mu.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Uu.create=e=>new Uu({checks:[],typeName:Ad.ZodString,coerce:e?.coerce??!1,..._u(e)});function Wu(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var Gu=class e extends vu{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==j.number){let t=this._getOrReturnCtx(e);return N(t,{code:M.invalid_type,expected:j.number,received:t.parsedType}),su}let t,n=new ou;for(let r of this._def.checks)r.kind===`int`?Ql.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),N(t,{code:M.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:M.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:M.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Wu(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),N(t,{code:M.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),N(t,{code:M.not_finite,message:r.message}),n.dirty()):Ql.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,mu.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,mu.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,mu.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,mu.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:mu.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:mu.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:mu.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:mu.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:mu.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:mu.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:mu.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:mu.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:mu.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:mu.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&Ql.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};Gu.create=e=>new Gu({checks:[],typeName:Ad.ZodNumber,coerce:e?.coerce||!1,..._u(e)});var Ku=class e extends vu{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==j.bigint)return this._getInvalidInput(e);let t,n=new ou;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:M.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:M.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),N(t,{code:M.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):Ql.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return N(t,{code:M.invalid_type,expected:j.bigint,received:t.parsedType}),su}gte(e,t){return this.setLimit(`min`,e,!0,mu.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,mu.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,mu.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,mu.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:mu.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:mu.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:mu.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:mu.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:mu.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:mu.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Ku.create=e=>new Ku({checks:[],typeName:Ad.ZodBigInt,coerce:e?.coerce??!1,..._u(e)});var qu=class extends vu{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==j.boolean){let t=this._getOrReturnCtx(e);return N(t,{code:M.invalid_type,expected:j.boolean,received:t.parsedType}),su}return lu(e.data)}};qu.create=e=>new qu({typeName:Ad.ZodBoolean,coerce:e?.coerce||!1,..._u(e)});var Ju=class e extends vu{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==j.date){let t=this._getOrReturnCtx(e);return N(t,{code:M.invalid_type,expected:j.date,received:t.parsedType}),su}if(Number.isNaN(e.data.getTime()))return N(this._getOrReturnCtx(e),{code:M.invalid_date}),su;let t=new ou,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),N(n,{code:M.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),N(n,{code:M.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):Ql.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:mu.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:mu.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Ju.create=e=>new Ju({checks:[],coerce:e?.coerce||!1,typeName:Ad.ZodDate,..._u(e)});var Yu=class extends vu{_parse(e){if(this._getType(e)!==j.symbol){let t=this._getOrReturnCtx(e);return N(t,{code:M.invalid_type,expected:j.symbol,received:t.parsedType}),su}return lu(e.data)}};Yu.create=e=>new Yu({typeName:Ad.ZodSymbol,..._u(e)});var Xu=class extends vu{_parse(e){if(this._getType(e)!==j.undefined){let t=this._getOrReturnCtx(e);return N(t,{code:M.invalid_type,expected:j.undefined,received:t.parsedType}),su}return lu(e.data)}};Xu.create=e=>new Xu({typeName:Ad.ZodUndefined,..._u(e)});var Zu=class extends vu{_parse(e){if(this._getType(e)!==j.null){let t=this._getOrReturnCtx(e);return N(t,{code:M.invalid_type,expected:j.null,received:t.parsedType}),su}return lu(e.data)}};Zu.create=e=>new Zu({typeName:Ad.ZodNull,..._u(e)});var Qu=class extends vu{constructor(){super(...arguments),this._any=!0}_parse(e){return lu(e.data)}};Qu.create=e=>new Qu({typeName:Ad.ZodAny,..._u(e)});var $u=class extends vu{constructor(){super(...arguments),this._unknown=!0}_parse(e){return lu(e.data)}};$u.create=e=>new $u({typeName:Ad.ZodUnknown,..._u(e)});var ed=class extends vu{_parse(e){let t=this._getOrReturnCtx(e);return N(t,{code:M.invalid_type,expected:j.never,received:t.parsedType}),su}};ed.create=e=>new ed({typeName:Ad.ZodNever,..._u(e)});var td=class extends vu{_parse(e){if(this._getType(e)!==j.undefined){let t=this._getOrReturnCtx(e);return N(t,{code:M.invalid_type,expected:j.void,received:t.parsedType}),su}return lu(e.data)}};td.create=e=>new td({typeName:Ad.ZodVoid,..._u(e)});var nd=class e extends vu{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==j.array)return N(t,{code:M.invalid_type,expected:j.array,received:t.parsedType}),su;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(N(t,{code:e?M.too_big:M.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(N(t,{code:M.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(N(t,{code:M.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new hu(t,e,t.path,n)))).then(e=>ou.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new hu(t,e,t.path,n)));return ou.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:mu.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:mu.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:mu.toString(n)}})}nonempty(e){return this.min(1,e)}};nd.create=(e,t)=>new nd({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ad.ZodArray,..._u(t)});function rd(e){if(e instanceof id){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Sd.create(rd(r))}return new id({...e._def,shape:()=>t})}else if(e instanceof nd)return new nd({...e._def,type:rd(e.element)});else if(e instanceof Sd)return Sd.create(rd(e.unwrap()));else if(e instanceof Cd)return Cd.create(rd(e.unwrap()));else if(e instanceof ud)return ud.create(e.items.map(e=>rd(e)));else return e}var id=class e extends vu{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=Ql.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==j.object){let t=this._getOrReturnCtx(e);return N(t,{code:M.invalid_type,expected:j.object,received:t.parsedType}),su}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ed&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new hu(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof ed){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(N(n,{code:M.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new hu(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>ou.mergeObjectSync(t,e)):ou.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return mu.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:mu.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ad.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of Ql.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of Ql.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return rd(this)}partial(t){let n={};for(let e of Ql.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of Ql.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Sd;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return _d(Ql.objectKeys(this.shape))}};id.create=(e,t)=>new id({shape:()=>e,unknownKeys:`strip`,catchall:ed.create(),typeName:Ad.ZodObject,..._u(t)}),id.strictCreate=(e,t)=>new id({shape:()=>e,unknownKeys:`strict`,catchall:ed.create(),typeName:Ad.ZodObject,..._u(t)}),id.lazycreate=(e,t)=>new id({shape:e,unknownKeys:`strip`,catchall:ed.create(),typeName:Ad.ZodObject,..._u(t)});var ad=class extends vu{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new tu(e.ctx.common.issues));return N(t,{code:M.invalid_union,unionErrors:n}),su}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new tu(e));return N(t,{code:M.invalid_union,unionErrors:i}),su}}get options(){return this._def.options}};ad.create=(e,t)=>new ad({options:e,typeName:Ad.ZodUnion,..._u(t)});var od=e=>e instanceof hd?od(e.schema):e instanceof xd?od(e.innerType()):e instanceof gd?[e.value]:e instanceof vd?e.options:e instanceof yd?Ql.objectValues(e.enum):e instanceof wd?od(e._def.innerType):e instanceof Xu?[void 0]:e instanceof Zu?[null]:e instanceof Sd?[void 0,...od(e.unwrap())]:e instanceof Cd?[null,...od(e.unwrap())]:e instanceof Dd||e instanceof kd?od(e.unwrap()):e instanceof Td?od(e._def.innerType):[],sd=class e extends vu{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==j.object)return N(t,{code:M.invalid_type,expected:j.object,received:t.parsedType}),su;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(N(t,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),su)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=od(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:Ad.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,..._u(r)})}};function cd(e,t){let n=eu(e),r=eu(t);if(e===t)return{valid:!0,data:e};if(n===j.object&&r===j.object){let n=Ql.objectKeys(t),r=Ql.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=cd(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===j.array&&r===j.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=cd(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===j.date&&r===j.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var ld=class extends vu{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(uu(e)||uu(r))return su;let i=cd(e.value,r.value);return i.valid?((du(e)||du(r))&&t.dirty(),{status:t.value,value:i.data}):(N(n,{code:M.invalid_intersection_types}),su)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};ld.create=(e,t,n)=>new ld({left:e,right:t,typeName:Ad.ZodIntersection,..._u(n)});var ud=class e extends vu{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==j.array)return N(n,{code:M.invalid_type,expected:j.array,received:n.parsedType}),su;if(n.data.length<this._def.items.length)return N(n,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),su;!this._def.rest&&n.data.length>this._def.items.length&&(N(n,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new hu(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>ou.mergeArray(t,e)):ou.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};ud.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new ud({items:e,typeName:Ad.ZodTuple,rest:null,..._u(t)})};var dd=class e extends vu{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==j.object)return N(n,{code:M.invalid_type,expected:j.object,received:n.parsedType}),su;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new hu(n,e,n.path,e)),value:a._parse(new hu(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?ou.mergeObjectAsync(t,r):ou.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof vu?new e({keyType:t,valueType:n,typeName:Ad.ZodRecord,..._u(r)}):new e({keyType:Uu.create(),valueType:t,typeName:Ad.ZodRecord,..._u(n)})}},fd=class extends vu{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==j.map)return N(n,{code:M.invalid_type,expected:j.map,received:n.parsedType}),su;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new hu(n,e,n.path,[a,`key`])),value:i._parse(new hu(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return su;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return su;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};fd.create=(e,t,n)=>new fd({valueType:t,keyType:e,typeName:Ad.ZodMap,..._u(n)});var pd=class e extends vu{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==j.set)return N(n,{code:M.invalid_type,expected:j.set,received:n.parsedType}),su;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(N(n,{code:M.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(N(n,{code:M.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return su;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new hu(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:mu.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:mu.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};pd.create=(e,t)=>new pd({valueType:e,minSize:null,maxSize:null,typeName:Ad.ZodSet,..._u(t)});var md=class e extends vu{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==j.function)return N(t,{code:M.invalid_type,expected:j.function,received:t.parsedType}),su;function n(e,n){return au({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,iu(),nu].filter(e=>!!e),issueData:{code:M.invalid_arguments,argumentsError:n}})}function r(e,n){return au({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,iu(),nu].filter(e=>!!e),issueData:{code:M.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof bd){let e=this;return lu(async function(...t){let o=new tu([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return lu(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new tu([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new tu([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:ud.create(t).rest($u.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||ud.create([]).rest($u.create()),returns:n||$u.create(),typeName:Ad.ZodFunction,..._u(r)})}},hd=class extends vu{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};hd.create=(e,t)=>new hd({getter:e,typeName:Ad.ZodLazy,..._u(t)});var gd=class extends vu{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return N(t,{received:t.data,code:M.invalid_literal,expected:this._def.value}),su}return{status:`valid`,value:e.data}}get value(){return this._def.value}};gd.create=(e,t)=>new gd({value:e,typeName:Ad.ZodLiteral,..._u(t)});function _d(e,t){return new vd({values:e,typeName:Ad.ZodEnum,..._u(t)})}var vd=class e extends vu{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return N(t,{expected:Ql.joinValues(n),received:t.parsedType,code:M.invalid_type}),su}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return N(t,{received:t.data,code:M.invalid_enum_value,options:n}),su}return lu(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};vd.create=_d;var yd=class extends vu{_parse(e){let t=Ql.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==j.string&&n.parsedType!==j.number){let e=Ql.objectValues(t);return N(n,{expected:Ql.joinValues(e),received:n.parsedType,code:M.invalid_type}),su}if(this._cache||=new Set(Ql.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=Ql.objectValues(t);return N(n,{received:n.data,code:M.invalid_enum_value,options:e}),su}return lu(e.data)}get enum(){return this._def.values}};yd.create=(e,t)=>new yd({values:e,typeName:Ad.ZodNativeEnum,..._u(t)});var bd=class extends vu{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==j.promise&&t.common.async===!1?(N(t,{code:M.invalid_type,expected:j.promise,received:t.parsedType}),su):lu((t.parsedType===j.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};bd.create=(e,t)=>new bd({type:e,typeName:Ad.ZodPromise,..._u(t)});var xd=class extends vu{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ad.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{N(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return su;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?su:r.status===`dirty`||t.value===`dirty`?cu(r.value):r});{if(t.value===`aborted`)return su;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?su:r.status===`dirty`||t.value===`dirty`?cu(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?su:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?su:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!fu(e))return su;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>fu(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):su);Ql.assertNever(r)}};xd.create=(e,t,n)=>new xd({schema:e,typeName:Ad.ZodEffects,effect:t,..._u(n)}),xd.createWithPreprocess=(e,t,n)=>new xd({schema:t,effect:{type:`preprocess`,transform:e},typeName:Ad.ZodEffects,..._u(n)});var Sd=class extends vu{_parse(e){return this._getType(e)===j.undefined?lu(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Sd.create=(e,t)=>new Sd({innerType:e,typeName:Ad.ZodOptional,..._u(t)});var Cd=class extends vu{_parse(e){return this._getType(e)===j.null?lu(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Cd.create=(e,t)=>new Cd({innerType:e,typeName:Ad.ZodNullable,..._u(t)});var wd=class extends vu{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===j.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};wd.create=(e,t)=>new wd({innerType:e,typeName:Ad.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,..._u(t)});var Td=class extends vu{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return pu(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new tu(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new tu(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Td.create=(e,t)=>new Td({innerType:e,typeName:Ad.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,..._u(t)});var Ed=class extends vu{_parse(e){if(this._getType(e)!==j.nan){let t=this._getOrReturnCtx(e);return N(t,{code:M.invalid_type,expected:j.nan,received:t.parsedType}),su}return{status:`valid`,value:e.data}}};Ed.create=e=>new Ed({typeName:Ad.ZodNaN,..._u(e)});var Dd=class extends vu{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Od=class e extends vu{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?su:e.status===`dirty`?(t.dirty(),cu(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?su:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:Ad.ZodPipeline})}},kd=class extends vu{_parse(e){let t=this._def.innerType._parse(e),n=e=>(fu(e)&&(e.value=Object.freeze(e.value)),e);return pu(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};kd.create=(e,t)=>new kd({innerType:e,typeName:Ad.ZodReadonly,..._u(t)}),id.lazycreate;var Ad;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(Ad||={});var P=Uu.create,jd=Gu.create;Ed.create,Ku.create;var Md=qu.create;Ju.create,Yu.create,Xu.create,Zu.create;var Nd=Qu.create,Pd=$u.create;ed.create,td.create;var Fd=nd.create,Id=id.create;id.strictCreate;var Ld=ad.create,Rd=sd.create;ld.create,ud.create;var zd=dd.create;fd.create,pd.create,md.create,hd.create;var Bd=gd.create,Vd=vd.create,Hd=yd.create;bd.create,xd.create,Sd.create,Cd.create,xd.createWithPreprocess,Od.create;var Ud=Id({name:P(),arguments:P()}),Wd=Id({id:P(),type:Bd(`function`),function:Ud,encryptedValue:P().optional()}),Gd=Id({id:P(),role:P(),content:P().optional(),name:P().optional(),encryptedValue:P().optional()}),Kd=Id({type:Bd(`text`),text:P()}),qd=Rd(`type`,[Id({type:Bd(`data`),value:P(),mimeType:P()}),Id({type:Bd(`url`),value:P(),mimeType:P().optional()})]),Jd=Id({type:Bd(`image`),source:qd,metadata:Pd().optional()}),Yd=Id({type:Bd(`audio`),source:qd,metadata:Pd().optional()}),Xd=Id({type:Bd(`video`),source:qd,metadata:Pd().optional()}),Zd=Id({type:Bd(`document`),source:qd,metadata:Pd().optional()}),Qd=Id({type:Bd(`binary`),mimeType:P(),id:P().optional(),url:P().optional(),data:P().optional(),filename:P().optional()}),$d=(e,t)=>{!e.id&&!e.url&&!e.data&&t.addIssue({code:M.custom,message:`BinaryInputContent requires at least one of id, url, or data.`,path:[`id`]})};Qd.superRefine((e,t)=>{$d(e,t)});var ef=Rd(`type`,[Kd,Jd,Yd,Xd,Zd,Qd]).superRefine((e,t)=>{e.type===`binary`&&$d(e,t)}),tf=Rd(`role`,[Gd.extend({role:Bd(`developer`),content:P()}),Gd.extend({role:Bd(`system`),content:P()}),Gd.extend({role:Bd(`assistant`),content:P().optional(),toolCalls:Fd(Wd).optional()}),Gd.extend({role:Bd(`user`),content:Ld([P(),Fd(ef)])}),Id({id:P(),content:P(),role:Bd(`tool`),toolCallId:P(),error:P().optional(),encryptedValue:P().optional()}),Id({id:P(),role:Bd(`activity`),activityType:P(),content:zd(Nd())}),Id({id:P(),role:Bd(`reasoning`),content:P(),encryptedValue:P().optional()})]);Ld([Bd(`developer`),Bd(`system`),Bd(`assistant`),Bd(`user`),Bd(`tool`),Bd(`activity`),Bd(`reasoning`)]);var nf=Id({description:P(),value:P()}),rf=Id({name:P(),description:P(),parameters:Nd(),metadata:zd(Nd()).optional()}),af=Id({id:P(),reason:P(),message:P().optional(),toolCallId:P().optional(),responseSchema:zd(Nd()).optional(),expiresAt:P().optional(),metadata:zd(Nd()).optional()}),of=Id({interruptId:P(),status:Vd([`resolved`,`cancelled`]),payload:Nd().optional()}),sf=Id({threadId:P(),runId:P(),parentRunId:P().optional(),state:Nd(),messages:Fd(tf),tools:Fd(rf),context:Fd(nf),forwardedProps:Nd(),resume:Fd(of).optional()}),cf=Nd(),lf=class extends Error{constructor(e){super(e)}},uf=class extends lf{constructor(){super(`Connect not implemented. This method is not supported by the current agent.`)}},df=Id({name:P(),description:P().optional()}),ff=Id({name:P().optional(),type:P().optional(),description:P().optional(),version:P().optional(),provider:P().optional(),documentationUrl:P().optional(),metadata:zd(Pd()).optional()}),pf=Id({streaming:Md().optional(),websocket:Md().optional(),httpBinary:Md().optional(),pushNotifications:Md().optional(),resumable:Md().optional()}),mf=Id({supported:Md().optional(),items:Fd(rf).optional(),parallelCalls:Md().optional(),clientProvided:Md().optional()}),hf=Id({structuredOutput:Md().optional(),supportedMimeTypes:Fd(P()).optional()}),gf=Id({snapshots:Md().optional(),deltas:Md().optional(),memory:Md().optional(),persistentState:Md().optional()}),_f=Id({supported:Md().optional(),delegation:Md().optional(),handoffs:Md().optional(),subAgents:Fd(df).optional()}),vf=Id({supported:Md().optional(),streaming:Md().optional(),encrypted:Md().optional()}),yf=Id({image:Md().optional(),audio:Md().optional(),video:Md().optional(),pdf:Md().optional(),file:Md().optional()}),bf=Id({image:Md().optional(),audio:Md().optional()}),xf=Id({input:yf.optional(),output:bf.optional()}),Sf=Id({codeExecution:Md().optional(),sandboxed:Md().optional(),maxIterations:jd().optional(),maxExecutionTime:jd().optional()}),Cf=Id({supported:Md().optional(),approvals:Md().optional(),interventions:Md().optional(),feedback:Md().optional(),interrupts:Md().optional(),approveWithEdits:Md().optional()});Id({identity:ff.optional(),transport:pf.optional(),tools:mf.optional(),output:hf.optional(),state:gf.optional(),multiAgent:_f.optional(),reasoning:vf.optional(),multimodal:xf.optional(),execution:Sf.optional(),humanInTheLoop:Cf.optional(),custom:zd(Pd()).optional()});var wf=Ld([Bd(`developer`),Bd(`system`),Bd(`assistant`),Bd(`user`)]),F=function(e){return e.TEXT_MESSAGE_START=`TEXT_MESSAGE_START`,e.TEXT_MESSAGE_CONTENT=`TEXT_MESSAGE_CONTENT`,e.TEXT_MESSAGE_END=`TEXT_MESSAGE_END`,e.TEXT_MESSAGE_CHUNK=`TEXT_MESSAGE_CHUNK`,e.TOOL_CALL_START=`TOOL_CALL_START`,e.TOOL_CALL_ARGS=`TOOL_CALL_ARGS`,e.TOOL_CALL_END=`TOOL_CALL_END`,e.TOOL_CALL_CHUNK=`TOOL_CALL_CHUNK`,e.TOOL_CALL_RESULT=`TOOL_CALL_RESULT`,e.THINKING_START=`THINKING_START`,e.THINKING_END=`THINKING_END`,e.THINKING_TEXT_MESSAGE_START=`THINKING_TEXT_MESSAGE_START`,e.THINKING_TEXT_MESSAGE_CONTENT=`THINKING_TEXT_MESSAGE_CONTENT`,e.THINKING_TEXT_MESSAGE_END=`THINKING_TEXT_MESSAGE_END`,e.STATE_SNAPSHOT=`STATE_SNAPSHOT`,e.STATE_DELTA=`STATE_DELTA`,e.MESSAGES_SNAPSHOT=`MESSAGES_SNAPSHOT`,e.ACTIVITY_SNAPSHOT=`ACTIVITY_SNAPSHOT`,e.ACTIVITY_DELTA=`ACTIVITY_DELTA`,e.RAW=`RAW`,e.CUSTOM=`CUSTOM`,e.RUN_STARTED=`RUN_STARTED`,e.RUN_FINISHED=`RUN_FINISHED`,e.RUN_ERROR=`RUN_ERROR`,e.STEP_STARTED=`STEP_STARTED`,e.STEP_FINISHED=`STEP_FINISHED`,e.REASONING_START=`REASONING_START`,e.REASONING_MESSAGE_START=`REASONING_MESSAGE_START`,e.REASONING_MESSAGE_CONTENT=`REASONING_MESSAGE_CONTENT`,e.REASONING_MESSAGE_END=`REASONING_MESSAGE_END`,e.REASONING_MESSAGE_CHUNK=`REASONING_MESSAGE_CHUNK`,e.REASONING_END=`REASONING_END`,e.REASONING_ENCRYPTED_VALUE=`REASONING_ENCRYPTED_VALUE`,e}({}),Tf=Id({type:Hd(F),timestamp:jd().optional(),rawEvent:Nd().optional()}).passthrough(),Ef=Tf.extend({type:Bd(F.TEXT_MESSAGE_START),messageId:P(),role:wf.default(`assistant`),name:P().optional()}),Df=Tf.extend({type:Bd(F.TEXT_MESSAGE_CONTENT),messageId:P(),delta:P()}),Of=Tf.extend({type:Bd(F.TEXT_MESSAGE_END),messageId:P()}),kf=Tf.extend({type:Bd(F.TEXT_MESSAGE_CHUNK),messageId:P().optional(),role:wf.optional(),delta:P().optional(),name:P().optional()}),Af=Tf.extend({type:Bd(F.THINKING_TEXT_MESSAGE_START)}),jf=Df.omit({messageId:!0,type:!0}).extend({type:Bd(F.THINKING_TEXT_MESSAGE_CONTENT)}),Mf=Tf.extend({type:Bd(F.THINKING_TEXT_MESSAGE_END)}),Nf=Tf.extend({type:Bd(F.TOOL_CALL_START),toolCallId:P(),toolCallName:P(),parentMessageId:P().optional()}),Pf=Tf.extend({type:Bd(F.TOOL_CALL_ARGS),toolCallId:P(),delta:P()}),Ff=Tf.extend({type:Bd(F.TOOL_CALL_END),toolCallId:P()}),If=Tf.extend({messageId:P(),type:Bd(F.TOOL_CALL_RESULT),toolCallId:P(),content:P(),role:Bd(`tool`).optional()}),Lf=Tf.extend({type:Bd(F.TOOL_CALL_CHUNK),toolCallId:P().optional(),toolCallName:P().optional(),parentMessageId:P().optional(),delta:P().optional()}),Rf=Tf.extend({type:Bd(F.THINKING_START),title:P().optional()}),zf=Tf.extend({type:Bd(F.THINKING_END)}),Bf=Tf.extend({type:Bd(F.STATE_SNAPSHOT),snapshot:cf}),Vf=Tf.extend({type:Bd(F.STATE_DELTA),delta:Fd(Nd())}),Hf=Tf.extend({type:Bd(F.MESSAGES_SNAPSHOT),messages:Fd(tf)}),Uf=Tf.extend({type:Bd(F.ACTIVITY_SNAPSHOT),messageId:P(),activityType:P(),content:zd(Nd()),replace:Md().optional().default(!0)}),Wf=Tf.extend({type:Bd(F.ACTIVITY_DELTA),messageId:P(),activityType:P(),patch:Fd(Nd())}),Gf=Tf.extend({type:Bd(F.RAW),event:Nd(),source:P().optional()}),Kf=Tf.extend({type:Bd(F.CUSTOM),name:P(),value:Nd()}),qf=Tf.extend({type:Bd(F.RUN_STARTED),threadId:P(),runId:P(),parentRunId:P().optional(),input:sf.optional()}),Jf=Rd(`type`,[Id({type:Bd(`success`)}).strict(),Id({type:Bd(`interrupt`),interrupts:Fd(af).min(1)}).strict()]),Yf=Tf.extend({type:Bd(F.RUN_FINISHED),threadId:P(),runId:P(),result:Nd().optional(),outcome:Jf.nullable().optional().transform(e=>e??void 0)}),Xf=Tf.extend({type:Bd(F.RUN_ERROR),message:P(),code:P().optional()}),Zf=Tf.extend({type:Bd(F.STEP_STARTED),stepName:P()}),Qf=Tf.extend({type:Bd(F.STEP_FINISHED),stepName:P()}),$f=Ld([Bd(`tool-call`),Bd(`message`)]),ep=Rd(`type`,[Ef,Df,Of,kf,Rf,zf,Af,jf,Mf,Nf,Pf,Ff,Lf,If,Bf,Vf,Hf,Uf,Wf,Gf,Kf,qf,Yf,Xf,Zf,Qf,Tf.extend({type:Bd(F.REASONING_START),messageId:P()}),Tf.extend({type:Bd(F.REASONING_MESSAGE_START),messageId:P(),role:Bd(`reasoning`)}),Tf.extend({type:Bd(F.REASONING_MESSAGE_CONTENT),messageId:P(),delta:P()}),Tf.extend({type:Bd(F.REASONING_MESSAGE_END),messageId:P()}),Tf.extend({type:Bd(F.REASONING_MESSAGE_CHUNK),messageId:P().optional(),delta:P().optional()}),Tf.extend({type:Bd(F.REASONING_END),messageId:P()}),Tf.extend({type:Bd(F.REASONING_ENCRYPTED_VALUE),subtype:$f,entityId:P(),encryptedValue:P()})]),tp=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),np=Object.prototype.hasOwnProperty;function rp(e,t){return np.call(e,t)}function ip(e){if(Array.isArray(e)){for(var t=Array(e.length),n=0;n<t.length;n++)t[n]=``+n;return t}if(Object.keys)return Object.keys(e);var r=[];for(var i in e)rp(e,i)&&r.push(i);return r}function ap(e){switch(typeof e){case`object`:return JSON.parse(JSON.stringify(e));case`undefined`:return null;default:return e}}function op(e){for(var t=0,n=e.length,r;t<n;){if(r=e.charCodeAt(t),r>=48&&r<=57){t++;continue}return!1}return!0}function sp(e){return e.indexOf(`/`)===-1&&e.indexOf(`~`)===-1?e:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function cp(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function lp(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var t=0,n=e.length;t<n;t++)if(lp(e[t]))return!0}else if(typeof e==`object`){for(var r=ip(e),i=r.length,a=0;a<i;a++)if(lp(e[r[a]]))return!0}}return!1}function up(e,t){var n=[e];for(var r in t){var i=typeof t[r]==`object`?JSON.stringify(t[r],null,2):t[r];i!==void 0&&n.push(r+`: `+i)}return n.join(`
|
|
78
|
+
`)}var dp=function(e){tp(t,e);function t(t,n,r,i,a){var o=this.constructor,s=e.call(this,up(t,{name:n,index:r,operation:i,tree:a}))||this;return s.name=n,s.index=r,s.operation=i,s.tree=a,Object.setPrototypeOf(s,o.prototype),s.message=up(t,{name:n,index:r,operation:i,tree:a}),s}return t}(Error),fp=s({JsonPatchError:()=>pp,_areEquals:()=>Cp,applyOperation:()=>vp,applyPatch:()=>yp,applyReducer:()=>bp,deepClone:()=>mp,getValueByPointer:()=>_p,validate:()=>Sp,validator:()=>xp}),pp=dp,mp=ap,hp={add:function(e,t,n){return e[t]=this.value,{newDocument:n}},remove:function(e,t,n){var r=e[t];return delete e[t],{newDocument:n,removed:r}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:function(e,t,n){var r=_p(n,this.path);r&&=ap(r);var i=vp(n,{op:`remove`,path:this.from}).removed;return vp(n,{op:`add`,path:this.path,value:i}),{newDocument:n,removed:r}},copy:function(e,t,n){var r=_p(n,this.from);return vp(n,{op:`add`,path:this.path,value:ap(r)}),{newDocument:n}},test:function(e,t,n){return{newDocument:n,test:Cp(e[t],this.value)}},_get:function(e,t,n){return this.value=e[t],{newDocument:n}}},gp={add:function(e,t,n){return op(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:n,index:t}},remove:function(e,t,n){return{newDocument:n,removed:e.splice(t,1)[0]}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:hp.move,copy:hp.copy,test:hp.test,_get:hp._get};function _p(e,t){if(t==``)return e;var n={op:`_get`,path:t};return vp(e,n),n.value}function vp(e,t,n,r,i,a){if(n===void 0&&(n=!1),r===void 0&&(r=!0),i===void 0&&(i=!0),a===void 0&&(a=0),n&&(typeof n==`function`?n(t,0,e,t.path):xp(t,0)),t.path===``){var o={newDocument:e};if(t.op===`add`)return o.newDocument=t.value,o;if(t.op===`replace`)return o.newDocument=t.value,o.removed=e,o;if(t.op===`move`||t.op===`copy`)return o.newDocument=_p(e,t.from),t.op===`move`&&(o.removed=e),o;if(t.op===`test`){if(o.test=Cp(e,t.value),o.test===!1)throw new pp(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o.newDocument=e,o}else if(t.op===`remove`)return o.removed=e,o.newDocument=null,o;else if(t.op===`_get`)return t.value=e,o;else if(n)throw new pp("Operation `op` property is not one of operations defined in RFC-6902",`OPERATION_OP_INVALID`,a,t,e);else return o}else{r||(e=ap(e));var s=(t.path||``).split(`/`),c=e,l=1,u=s.length,d=void 0,f=void 0,p=void 0;for(p=typeof n==`function`?n:xp;;){if(f=s[l],f&&f.indexOf(`~`)!=-1&&(f=cp(f)),i&&(f==`__proto__`||f==`prototype`&&l>0&&s[l-1]==`constructor`))throw TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&d===void 0&&(c[f]===void 0?d=s.slice(0,l).join(`/`):l==u-1&&(d=t.path),d!==void 0&&p(t,0,e,d)),l++,Array.isArray(c)){if(f===`-`)f=c.length;else if(n&&!op(f))throw new pp(`Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index`,`OPERATION_PATH_ILLEGAL_ARRAY_INDEX`,a,t,e);else op(f)&&(f=~~f);if(l>=u){if(n&&t.op===`add`&&f>c.length)throw new pp(`The specified index MUST NOT be greater than the number of elements in the array`,`OPERATION_VALUE_OUT_OF_BOUNDS`,a,t,e);var o=gp[t.op].call(t,c,f,e);if(o.test===!1)throw new pp(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}}else if(l>=u){var o=hp[t.op].call(t,c,f,e);if(o.test===!1)throw new pp(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}if(c=c[f],n&&l<u&&(!c||typeof c!=`object`))throw new pp(`Cannot perform operation at the desired path`,`OPERATION_PATH_UNRESOLVABLE`,a,t,e)}}}function yp(e,t,n,r,i){if(r===void 0&&(r=!0),i===void 0&&(i=!0),n&&!Array.isArray(t))throw new pp(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);r||(e=ap(e));for(var a=Array(t.length),o=0,s=t.length;o<s;o++)a[o]=vp(e,t[o],n,!0,i,o),e=a[o].newDocument;return a.newDocument=e,a}function bp(e,t,n){var r=vp(e,t);if(r.test===!1)throw new pp(`Test operation failed`,`TEST_OPERATION_FAILED`,n,t,e);return r.newDocument}function xp(e,t,n,r){if(typeof e!=`object`||!e||Array.isArray(e))throw new pp(`Operation is not an object`,`OPERATION_NOT_AN_OBJECT`,t,e,n);if(!hp[e.op])throw new pp("Operation `op` property is not one of operations defined in RFC-6902",`OPERATION_OP_INVALID`,t,e,n);if(typeof e.path!=`string`)throw new pp("Operation `path` property is not a string",`OPERATION_PATH_INVALID`,t,e,n);if(e.path.indexOf(`/`)!==0&&e.path.length>0)throw new pp('Operation `path` property must start with "/"',`OPERATION_PATH_INVALID`,t,e,n);if((e.op===`move`||e.op===`copy`)&&typeof e.from!=`string`)throw new pp("Operation `from` property is not present (applicable in `move` and `copy` operations)",`OPERATION_FROM_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&e.value===void 0)throw new pp("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&lp(e.value))throw new pp("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED`,t,e,n);if(n){if(e.op==`add`){var i=e.path.split(`/`).length,a=r.split(`/`).length;if(i!==a+1&&i!==a)throw new pp("Cannot perform an `add` operation at the desired path",`OPERATION_PATH_CANNOT_ADD`,t,e,n)}else if(e.op===`replace`||e.op===`remove`||e.op===`_get`){if(e.path!==r)throw new pp(`Cannot perform the operation at a path that does not exist`,`OPERATION_PATH_UNRESOLVABLE`,t,e,n)}else if(e.op===`move`||e.op===`copy`){var o=Sp([{op:`_get`,path:e.from,value:void 0}],n);if(o&&o.name===`OPERATION_PATH_UNRESOLVABLE`)throw new pp(`Cannot perform the operation from a path that does not exist`,`OPERATION_FROM_UNRESOLVABLE`,t,e,n)}}}function Sp(e,t,n){try{if(!Array.isArray(e))throw new pp(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);if(t)yp(ap(t),ap(e),n||!0);else{n||=xp;for(var r=0;r<e.length;r++)n(e[r],r,t,void 0)}}catch(e){if(e instanceof pp)return e;throw e}}function Cp(e,t){if(e===t)return!0;if(e&&t&&typeof e==`object`&&typeof t==`object`){var n=Array.isArray(e),r=Array.isArray(t),i,a,o;if(n&&r){if(a=e.length,a!=t.length)return!1;for(i=a;i--!==0;)if(!Cp(e[i],t[i]))return!1;return!0}if(n!=r)return!1;var s=Object.keys(e);if(a=s.length,a!==Object.keys(t).length)return!1;for(i=a;i--!==0;)if(!t.hasOwnProperty(s[i]))return!1;for(i=a;i--!==0;)if(o=s[i],!Cp(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}var wp=s({compare:()=>Fp,generate:()=>Np,observe:()=>Mp,unobserve:()=>jp}),Tp=new WeakMap,Ep=function(){function e(e){this.observers=new Map,this.obj=e}return e}(),Dp=function(){function e(e,t){this.callback=e,this.observer=t}return e}();function Op(e){return Tp.get(e)}function kp(e,t){return e.observers.get(t)}function Ap(e,t){e.observers.delete(t.callback)}function jp(e,t){t.unobserve()}function Mp(e,t){var n=[],r,i=Op(e);if(!i)i=new Ep(e),Tp.set(e,i);else{var a=kp(i,t);r=a&&a.observer}if(r)return r;if(r={},i.value=ap(e),t){r.callback=t,r.next=null;var o=function(){Np(r)},s=function(){clearTimeout(r.next),r.next=setTimeout(o)};typeof window<`u`&&(window.addEventListener(`mouseup`,s),window.addEventListener(`keyup`,s),window.addEventListener(`mousedown`,s),window.addEventListener(`keydown`,s),window.addEventListener(`change`,s))}return r.patches=n,r.object=e,r.unobserve=function(){Np(r),clearTimeout(r.next),Ap(i,r),typeof window<`u`&&(window.removeEventListener(`mouseup`,s),window.removeEventListener(`keyup`,s),window.removeEventListener(`mousedown`,s),window.removeEventListener(`keydown`,s),window.removeEventListener(`change`,s))},i.observers.set(t,new Dp(t,r)),r}function Np(e,t){t===void 0&&(t=!1);var n=Tp.get(e.object);Pp(n.value,e.object,e.patches,``,t),e.patches.length&&yp(n.value,e.patches);var r=e.patches;return r.length>0&&(e.patches=[],e.callback&&e.callback(r)),r}function Pp(e,t,n,r,i){if(t!==e){typeof t.toJSON==`function`&&(t=t.toJSON());for(var a=ip(t),o=ip(e),s=!1,c=o.length-1;c>=0;c--){var l=o[c],u=e[l];if(rp(t,l)&&!(t[l]===void 0&&u!==void 0&&Array.isArray(t)===!1)){var d=t[l];typeof u==`object`&&u&&typeof d==`object`&&d&&Array.isArray(u)===Array.isArray(d)?Pp(u,d,n,r+`/`+sp(l),i):u!==d&&(i&&n.push({op:`test`,path:r+`/`+sp(l),value:ap(u)}),n.push({op:`replace`,path:r+`/`+sp(l),value:ap(d)}))}else Array.isArray(e)===Array.isArray(t)?(i&&n.push({op:`test`,path:r+`/`+sp(l),value:ap(u)}),n.push({op:`remove`,path:r+`/`+sp(l)}),s=!0):(i&&n.push({op:`test`,path:r,value:e}),n.push({op:`replace`,path:r,value:t}))}if(!(!s&&a.length==o.length))for(var c=0;c<a.length;c++){var l=a[c];!rp(e,l)&&t[l]!==void 0&&n.push({op:`add`,path:r+`/`+sp(l),value:ap(t[l])})}}}function Fp(e,t,n){n===void 0&&(n=!1);var r=[];return Pp(e,t,r,``,n),r}var Ip=Object.assign({},fp,wp,{JsonPatchError:dp,deepClone:ap,escapePathComponent:sp,unescapePathComponent:cp}),Lp=function(e,t){return Lp=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])},Lp(e,t)};function Rp(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);Lp(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var zp=function(){return zp=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},zp.apply(this,arguments)};function Bp(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 Vp(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function Hp(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function Up(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function Wp(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function Gp(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))}function Kp(e){return this instanceof Kp?(this.v=e,this):new Kp(e)}function qp(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof Kp?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function Jp(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Up==`function`?Up(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function Yp(e){return typeof e==`function`}function Xp(e){var t=e(function(e){Error.call(e),e.stack=Error().stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var Zp=Xp(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
|
|
79
|
+
`+t.map(function(e,t){return t+1+`) `+e.toString()}).join(`
|
|
80
|
+
`):``,this.name=`UnsubscriptionError`,this.errors=t}});function Qp(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var $p=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,r,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var o=Up(a),s=o.next();!s.done;s=o.next())s.value.remove(this)}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else a.remove(this);var c=this.initialTeardown;if(Yp(c))try{c()}catch(e){i=e instanceof Zp?e.errors:[e]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var u=Up(l),d=u.next();!d.done;d=u.next()){var f=d.value;try{nm(f)}catch(e){i??=[],e instanceof Zp?i=Gp(Gp([],Wp(i)),Wp(e.errors)):i.push(e)}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}if(i)throw new Zp(i)}},e.prototype.add=function(t){if(t&&t!==this)if(this.closed)nm(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=this._finalizers??[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&Qp(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&Qp(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e}(),em=$p.EMPTY;function tm(e){return e instanceof $p||e&&`closed`in e&&Yp(e.remove)&&Yp(e.add)&&Yp(e.unsubscribe)}function nm(e){Yp(e)?e():e.unsubscribe()}var rm={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},im={setTimeout:function(e,t){var n=[...arguments].slice(2),r=im.delegate;return r?.setTimeout?r.setTimeout.apply(r,Gp([e,t],Wp(n))):setTimeout.apply(void 0,Gp([e,t],Wp(n)))},clearTimeout:function(e){return(im.delegate?.clearTimeout||clearTimeout)(e)},delegate:void 0};function am(e){im.setTimeout(function(){var t=rm.onUnhandledError;if(t)t(e);else throw e})}function om(){}var sm=(function(){return um(`C`,void 0,void 0)})();function cm(e){return um(`E`,void 0,e)}function lm(e){return um(`N`,e,void 0)}function um(e,t,n){return{kind:e,value:t,error:n}}var dm=null;function fm(e){if(rm.useDeprecatedSynchronousErrorHandling){var t=!dm;if(t&&(dm={errorThrown:!1,error:null}),e(),t){var n=dm,r=n.errorThrown,i=n.error;if(dm=null,r)throw i}}else e()}function pm(e){rm.useDeprecatedSynchronousErrorHandling&&dm&&(dm.errorThrown=!0,dm.error=e)}var mm=function(e){Rp(t,e);function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,tm(t)&&t.add(n)):n.destination=xm,n}return t.create=function(e,t,n){return new vm(e,t,n)},t.prototype.next=function(e){this.isStopped?bm(lm(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?bm(cm(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?bm(sm,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}($p),hm=Function.prototype.bind;function gm(e,t){return hm.call(e,t)}var _m=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){ym(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){ym(e)}else ym(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){ym(e)}},e}(),vm=function(e){Rp(t,e);function t(t,n,r){var i=e.call(this)||this,a;if(Yp(t)||!t)a={next:t??void 0,error:n??void 0,complete:r??void 0};else{var o;i&&rm.useDeprecatedNextContext?(o=Object.create(t),o.unsubscribe=function(){return i.unsubscribe()},a={next:t.next&&gm(t.next,o),error:t.error&&gm(t.error,o),complete:t.complete&&gm(t.complete,o)}):a=t}return i.destination=new _m(a),i}return t}(mm);function ym(e){rm.useDeprecatedSynchronousErrorHandling?pm(e):am(e)}function eee(e){throw e}function bm(e,t){var n=rm.onStoppedNotification;n&&im.setTimeout(function(){return n(e,t)})}var xm={closed:!0,next:om,error:eee,complete:om},Sm=(function(){return typeof Symbol==`function`&&Symbol.observable||`@@observable`})();function Cm(e){return e}function wm(){return Tm([...arguments])}function Tm(e){return e.length===0?Cm:e.length===1?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)}}var Em=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this,i=km(e)?e:new vm(e,t,n);return fm(function(){var e=r,t=e.operator,n=e.source;i.add(t?t.call(i,n):n?r._subscribe(i):r._trySubscribe(i))}),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return t=Dm(t),new t(function(t,r){var i=new vm({next:function(t){try{e(t)}catch(e){r(e),i.unsubscribe()}},error:r,complete:t});n.subscribe(i)})},e.prototype._subscribe=function(e){return this.source?.subscribe(e)},e.prototype[Sm]=function(){return this},e.prototype.pipe=function(){return Tm([...arguments])(this)},e.prototype.toPromise=function(e){var t=this;return e=Dm(e),new e(function(e,n){var r;t.subscribe(function(e){return r=e},function(e){return n(e)},function(){return e(r)})})},e.create=function(t){return new e(t)},e}();function Dm(e){return e??rm.Promise??Promise}function Om(e){return e&&Yp(e.next)&&Yp(e.error)&&Yp(e.complete)}function km(e){return e&&e instanceof mm||Om(e)&&tm(e)}function Am(e){return Yp(e?.lift)}function jm(e){return function(t){if(Am(t))return t.lift(function(t){try{return e(t,this)}catch(e){this.error(e)}});throw TypeError(`Unable to lift unknown Observable type`)}}function Mm(e,t,n,r,i){return new Nm(e,t,n,r,i)}var Nm=function(e){Rp(t,e);function t(t,n,r,i,a,o){var s=e.call(this,t)||this;return s.onFinalize=a,s.shouldUnsubscribe=o,s._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,s._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,s._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,s}return t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)==null||t.call(this))}},t}(mm),Pm=Xp(function(e){return function(){e(this),this.name=`ObjectUnsubscribedError`,this.message=`object unsubscribed`}}),Fm=function(e){Rp(t,e);function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return t.prototype.lift=function(e){var t=new Im(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new Pm},t.prototype.next=function(e){var t=this;fm(function(){var n,r;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||=Array.from(t.observers);try{for(var i=Up(t.currentObservers),a=i.next();!a.done;a=i.next())a.value.next(e)}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}})},t.prototype.error=function(e){var t=this;fm(function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}})},t.prototype.complete=function(){var e=this;fm(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){return this.observers?.length>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,i=n.isStopped,a=n.observers;return r||i?em:(this.currentObservers=null,a.push(e),new $p(function(){t.currentObservers=null,Qp(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,i=t.isStopped;n?e.error(r):i&&e.complete()},t.prototype.asObservable=function(){var e=new Em;return e.source=this,e},t.create=function(e,t){return new Im(e,t)},t}(Em),Im=function(e){Rp(t,e);function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return t.prototype.next=function(e){var t,n;(n=(t=this.destination)?.next)==null||n.call(t,e)},t.prototype.error=function(e){var t,n;(n=(t=this.destination)?.error)==null||n.call(t,e)},t.prototype.complete=function(){var e,t;(t=(e=this.destination)?.complete)==null||t.call(e)},t.prototype._subscribe=function(e){return this.source?.subscribe(e)??em},t}(Fm),Lm={now:function(){return(Lm.delegate||Date).now()},delegate:void 0},Rm=function(e){Rp(t,e);function t(t,n,r){t===void 0&&(t=1/0),n===void 0&&(n=1/0),r===void 0&&(r=Lm);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=n,i._timestampProvider=r,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,n),i}return t.prototype.next=function(t){var n=this,r=n.isStopped,i=n._buffer,a=n._infiniteTimeWindow,o=n._timestampProvider,s=n._windowTime;r||(i.push(t),!a&&i.push(o.now()+s)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),n=this,r=n._infiniteTimeWindow,i=n._buffer.slice(),a=0;a<i.length&&!e.closed;a+=r?1:2)e.next(i[a]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,n=e._timestampProvider,r=e._buffer,i=e._infiniteTimeWindow,a=(i?1:2)*t;if(t<1/0&&a<r.length&&r.splice(0,r.length-a),!i){for(var o=n.now(),s=0,c=1;c<r.length&&r[c]<=o;c+=2)s=c;s&&r.splice(0,s+1)}},t}(Fm),zm=new Em(function(e){return e.complete()});function Bm(e){return e&&Yp(e.schedule)}function tee(e){return e[e.length-1]}function nee(e){return Bm(tee(e))?e.pop():void 0}var Vm=(function(e){return e&&typeof e.length==`number`&&typeof e!=`function`});function Hm(e){return Yp(e?.then)}function Um(e){return Yp(e[Sm])}function Wm(e){return Symbol.asyncIterator&&Yp(e?.[Symbol.asyncIterator])}function Gm(e){return TypeError(`You provided `+(typeof e==`object`&&e?`an invalid object`:`'`+e+`'`)+` where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`)}function Km(){return typeof Symbol!=`function`||!Symbol.iterator?`@@iterator`:Symbol.iterator}var qm=Km();function Jm(e){return Yp(e?.[qm])}function Ym(e){return qp(this,arguments,function(){var t,n,r,i;return Hp(this,function(a){switch(a.label){case 0:t=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,Kp(t.read())];case 3:return n=a.sent(),r=n.value,i=n.done,i?[4,Kp(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,Kp(r)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function Xm(e){return Yp(e?.getReader)}function Zm(e){if(e instanceof Em)return e;if(e!=null){if(Um(e))return Qm(e);if(Vm(e))return $m(e);if(Hm(e))return eh(e);if(Wm(e))return nh(e);if(Jm(e))return th(e);if(Xm(e))return rh(e)}throw Gm(e)}function Qm(e){return new Em(function(t){var n=e[Sm]();if(Yp(n.subscribe))return n.subscribe(t);throw TypeError(`Provided object does not correctly implement Symbol.observable`)})}function $m(e){return new Em(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function eh(e){return new Em(function(t){e.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,am)})}function th(e){return new Em(function(t){var n,r;try{for(var i=Up(e),a=i.next();!a.done;a=i.next()){var o=a.value;if(t.next(o),t.closed)return}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}t.complete()})}function nh(e){return new Em(function(t){ih(e,t).catch(function(e){return t.error(e)})})}function rh(e){return nh(Ym(e))}function ih(e,t){var n,r,i,a;return Vp(this,void 0,void 0,function(){var o,s;return Hp(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),n=Jp(e),c.label=1;case 1:return[4,n.next()];case 2:if(r=c.sent(),r.done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=c.sent(),i={error:s},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(a=n.return)?[4,a.call(n)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function ah(e,t,n,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var a=t.schedule(function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(a),!i)return a}function oh(e,t){return t===void 0&&(t=0),jm(function(n,r){n.subscribe(Mm(r,function(n){return ah(r,e,function(){return r.next(n)},t)},function(){return ah(r,e,function(){return r.complete()},t)},function(n){return ah(r,e,function(){return r.error(n)},t)}))})}function sh(e,t){return t===void 0&&(t=0),jm(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function ch(e,t){return Zm(e).pipe(sh(t),oh(t))}function lh(e,t){return Zm(e).pipe(sh(t),oh(t))}function ree(e,t){return new Em(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function iee(e,t){return new Em(function(n){var r;return ah(n,t,function(){r=e[qm](),ah(n,t,function(){var e,t,i;try{e=r.next(),t=e.value,i=e.done}catch(e){n.error(e);return}i?n.complete():n.next(t)},0,!0)}),function(){return Yp(r?.return)&&r.return()}})}function uh(e,t){if(!e)throw Error(`Iterable cannot be null`);return new Em(function(n){ah(n,t,function(){var r=e[Symbol.asyncIterator]();ah(n,t,function(){r.next().then(function(e){e.done?n.complete():n.next(e.value)})},0,!0)})})}function aee(e,t){return uh(Ym(e),t)}function oee(e,t){if(e!=null){if(Um(e))return ch(e,t);if(Vm(e))return ree(e,t);if(Hm(e))return lh(e,t);if(Wm(e))return uh(e,t);if(Jm(e))return iee(e,t);if(Xm(e))return aee(e,t)}throw Gm(e)}function dh(e,t){return t?oee(e,t):Zm(e)}function fh(){var e=[...arguments];return dh(e,nee(e))}function ph(e,t){var n=Yp(e)?e:function(){return e},r=function(e){return e.error(n())};return new Em(t?function(e){return t.schedule(r,0,e)}:r)}var mh=Xp(function(e){return function(){e(this),this.name=`EmptyError`,this.message=`no elements in sequence`}});function hh(e,t){var n=typeof t==`object`;return new Promise(function(r,i){var a=!1,o;e.subscribe({next:function(e){o=e,a=!0},error:i,complete:function(){a?r(o):n?r(t.defaultValue):i(new mh)}})})}function gh(e,t){return jm(function(n,r){var i=0;n.subscribe(Mm(r,function(n){r.next(e.call(t,n,i++))}))})}function _h(e,t,n,r,i,a,o,s){var c=[],l=0,u=0,d=!1,f=function(){d&&!c.length&&!l&&t.complete()},p=function(e){return l<r?m(e):c.push(e)},m=function(e){a&&t.next(e),l++;var s=!1;Zm(n(e,u++)).subscribe(Mm(t,function(e){i?.(e),a?p(e):t.next(e)},function(){s=!0},void 0,function(){if(s)try{l--;for(var e=function(){var e=c.shift();o?ah(t,o,function(){return m(e)}):m(e)};c.length&&l<r;)e();f()}catch(e){t.error(e)}}))};return e.subscribe(Mm(t,p,function(){d=!0,f()})),function(){s?.()}}function vh(e,t,n){return n===void 0&&(n=1/0),Yp(t)?vh(function(n,r){return gh(function(e,i){return t(n,e,r,i)})(Zm(e(n,r)))},n):(typeof t==`number`&&(n=t),jm(function(t,r){return _h(t,r,e,n)}))}function yh(e){return e===void 0&&(e=1/0),vh(Cm,e)}function bh(e){return new Em(function(t){Zm(e()).subscribe(t)})}function xh(e){return jm(function(t,n){var r=null,i=!1,a;r=t.subscribe(Mm(n,void 0,void 0,function(o){a=Zm(e(o,xh(e)(t))),r?(r.unsubscribe(),r=null,a.subscribe(n)):i=!0})),i&&(r.unsubscribe(),r=null,a.subscribe(n))})}function Sh(e,t){return Yp(t)?vh(e,t,1):vh(e,1)}function Ch(e){return jm(function(t,n){var r=!1;t.subscribe(Mm(n,function(e){r=!0,n.next(e)},function(){r||n.next(e),n.complete()}))})}function wh(e){return jm(function(t,n){try{t.subscribe(n)}finally{n.add(e)}})}function Th(e,t){return jm(function(n,r){var i=null,a=0,o=!1,s=function(){return o&&!i&&r.complete()};n.subscribe(Mm(r,function(n){i?.unsubscribe();var o=0,c=a++;Zm(e(n,c)).subscribe(i=Mm(r,function(e){return r.next(t?t(n,e,c,o++):e)},function(){i=null,s()}))},function(){o=!0,s()}))})}function Eh(e){return jm(function(t,n){Zm(e).subscribe(Mm(n,function(){return n.complete()},om)),!n.closed&&t.subscribe(n)})}function Dh(e,t,n){var r=Yp(e)||t||n?{next:e,error:t,complete:n}:e;return r?jm(function(e,t){var n;(n=r.subscribe)==null||n.call(r);var i=!0;e.subscribe(Mm(t,function(e){var n;(n=r.next)==null||n.call(r,e),t.next(e)},function(){var e;i=!1,(e=r.complete)==null||e.call(r),t.complete()},function(e){var n;i=!1,(n=r.error)==null||n.call(r,e),t.error(e)},function(){var e,t;i&&((e=r.unsubscribe)==null||e.call(r)),(t=r.finalize)==null||t.call(r)}))}):Cm}function Oh(e){return` \r
|
|
81
|
+
`.indexOf(e)>=0}function kh(e){for(var t=[`topLevel`],n=0,r,i,a,o=function(e){return t.push(e)},s=function(e){return t[t.length-1]=e},c=function(e){r??(r=n,i=t.length,a=e)},l=function(e){e===a&&(r=void 0,i=void 0,a=void 0)},u=function(){return t.pop()},d=function(){return n--},f=function(e){if(`0`<=e&&e<=`9`){o(`number`);return}switch(e){case`"`:o(`string`);return;case`-`:o(`numberNeedsDigit`);return;case`t`:o(`true`);return;case`f`:o(`false`);return;case`n`:o(`null`);return;case`[`:o(`arrayNeedsValue`);return;case`{`:o(`objectNeedsKey`);return}},p=e.length;n<p;n++){var m=e[n];switch(t[t.length-1]){case`topLevel`:f(m);break;case`string`:switch(m){case`"`:u();break;case`\\`:c(`stringEscape`),o(`stringEscaped`);break}break;case`stringEscaped`:m===`u`?o(`stringUnicode`):(l(`stringEscape`),u());break;case`stringUnicode`:n-e.lastIndexOf(`u`,n)===4&&(l(`stringEscape`),u());break;case`number`:m===`.`?s(`numberNeedsDigit`):m===`e`||m===`E`?s(`numberNeedsExponent`):(m<`0`||m>`9`)&&(d(),u());break;case`numberNeedsDigit`:s(`number`);break;case`numberNeedsExponent`:s(m===`+`||m===`-`?`numberNeedsDigit`:`number`);break;case`true`:case`false`:case`null`:(m<`a`||m>`z`)&&(d(),u());break;case`arrayNeedsValue`:m===`]`?u():Oh(m)||(l(`collectionItem`),s(`arrayNeedsComma`),f(m));break;case`arrayNeedsComma`:m===`]`?u():m===`,`&&(c(`collectionItem`),s(`arrayNeedsValue`));break;case`objectNeedsKey`:m===`}`?u():m===`"`&&(c(`collectionItem`),s(`objectNeedsColon`),o(`string`));break;case`objectNeedsColon`:m===`:`&&s(`objectNeedsValue`);break;case`objectNeedsValue`:Oh(m)||(l(`collectionItem`),s(`objectNeedsComma`),f(m));break;case`objectNeedsComma`:m===`}`?u():m===`,`&&(c(`collectionItem`),s(`objectNeedsKey`));break}}i!=null&&(t.length=i);for(var h=[r==null?e:e.slice(0,r)],g=function(t){return h.push(t.slice(e.length-e.lastIndexOf(t[0])))},_=t.length-1;_>=0;_--)switch(t[_]){case`string`:h.push(`"`);break;case`numberNeedsDigit`:case`numberNeedsExponent`:h.push(`0`);break;case`true`:g(`true`);break;case`false`:g(`false`);break;case`null`:g(`null`);break;case`arrayNeedsValue`:case`arrayNeedsComma`:h.push(`]`);break;case`objectNeedsKey`:case`objectNeedsColon`:case`objectNeedsValue`:case`objectNeedsComma`:h.push(`}`);break}return h.join(``)}function Ah(){let e=0,t=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(n&15)<<28,t=(n&112)>>4,!(n&128))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(t|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}throw Error(`invalid varint`)}function jh(e,t,n){for(let r=0;r<28;r+=7){let i=e>>>r,a=!(!(i>>>7)&&t==0),o=(a?i|128:i)&255;if(n.push(o),!a)return}let r=e>>>28&15|(t&7)<<4,i=!!(t>>3);if(n.push((i?r|128:r)&255),i){for(let e=3;e<31;e+=7){let r=t>>>e,i=!!(r>>>7),a=(i?r|128:r)&255;if(n.push(a),!i)return}n.push(t>>>31&1)}}var Mh=4294967296;function Nh(e){let t=e[0]===`-`;t&&(e=e.slice(1));let n=1e6,r=0,i=0;function a(t,a){let o=Number(e.slice(t,a));i*=n,r=r*n+o,r>=Mh&&(i+=r/Mh|0,r%=Mh)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?Rh(r,i):Lh(r,i)}function Ph(e,t){let n=Lh(e,t),r=n.hi&2147483648;r&&(n=Rh(n.lo,n.hi));let i=Fh(n.lo,n.hi);return r?`-`+i:i}function Fh(e,t){if({lo:e,hi:t}=Ih(e,t),t<=2097151)return String(Mh*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535,a=n+r*6777216+i*6710656,o=r+i*8147497,s=i*2,c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(s+=Math.floor(o/c),o%=c),s.toString()+zh(o)+zh(a)}function Ih(e,t){return{lo:e>>>0,hi:t>>>0}}function Lh(e,t){return{lo:e|0,hi:t|0}}function Rh(e,t){return t=~t,e?e=~e+1:t+=1,Lh(e,t)}var zh=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function Bh(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e>>=7;t.push(1)}}function Vh(){let e=this.buf[this.pos++],t=e&127;if(!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let t=5;e&128&&t<10;t++)e=this.buf[this.pos++];if(e&128)throw Error(`invalid varint`);return this.assertBounds(),t>>>0}var Hh=Uh();function Uh(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt==`function`&&typeof e.getBigInt64==`function`&&typeof e.getBigUint64==`function`&&typeof e.setBigInt64==`function`&&typeof e.setBigUint64==`function`&&(globalThis.Deno||globalThis.Bun||typeof process!=`object`||{}.BUF_BIGINT_DISABLE!==`1`)){let t=BigInt(`-9223372036854775808`),n=BigInt(`9223372036854775807`),r=BigInt(`0`),i=BigInt(`18446744073709551615`);return{zero:BigInt(0),supported:!0,parse(e){let r=typeof e==`bigint`?e:BigInt(e);if(r>n||r<t)throw Error(`invalid int64: ${e}`);return r},uParse(e){let t=typeof e==`bigint`?e:BigInt(e);if(t>i||t<r)throw Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)},uDec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0)}}}return{zero:`0`,supported:!1,parse(e){return typeof e!=`string`&&(e=e.toString()),Wh(e),e},uParse(e){return typeof e!=`string`&&(e=e.toString()),Gh(e),e},enc(e){return typeof e!=`string`&&(e=e.toString()),Wh(e),Nh(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),Gh(e),Nh(e)},dec(e,t){return Ph(e,t)},uDec(e,t){return Fh(e,t)}}}function Wh(e){if(!/^-?[0-9]+$/.test(e))throw Error(`invalid int64: `+e)}function Gh(e){if(!/^[0-9]+$/.test(e))throw Error(`invalid uint64: `+e)}var Kh=Symbol.for(`@bufbuild/protobuf/text-encoding`);function qh(){if(globalThis[Kh]==null){let e=new globalThis.TextEncoder,t=new globalThis.TextDecoder,n;globalThis[Kh]={encodeUtf8(t){return e.encode(t)},decodeUtf8(e,r){return r?(n===void 0&&(n=new globalThis.TextDecoder(`utf-8`,{fatal:!0})),n.decode(e)):t.decode(e)},checkUtf8(e){try{return!0}catch{return!1}}}}return globalThis[Kh]}var Jh;(function(e){e[e.Varint=0]=`Varint`,e[e.Bit64=1]=`Bit64`,e[e.LengthDelimited=2]=`LengthDelimited`,e[e.StartGroup=3]=`StartGroup`,e[e.EndGroup=4]=`EndGroup`,e[e.Bit32=5]=`Bit32`})(Jh||={});var Yh=class{constructor(e=qh().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw Error(`invalid state, fork stack empty`);return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Zh(e);e>127;)this.buf.push(e&127|128),e>>>=7;return this.buf.push(e),this}int32(e){return Xh(e),Bh(e,this.buf),this}bool(e){return this.buf.push(+!!e),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.encodeUtf8(e);return this.uint32(t.byteLength),this.raw(t)}float(e){see(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){Zh(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Xh(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Xh(e),e=(e<<1^e>>31)>>>0,Bh(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=Hh.enc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=Hh.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=Hh.enc(e);return jh(t.lo,t.hi,this.buf),this}sint64(e){let t=Hh.enc(e),n=t.hi>>31;return jh(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=Hh.uEnc(e);return jh(t.lo,t.hi,this.buf),this}},I=class{constructor(e,t=qh().decodeUtf8){this.decodeUtf8=t,this.varint64=Ah,this.uint32=Vh,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.pos,t=this.uint32(),n=this.pos-e;if(n>5||n==5&&this.buf[this.pos-1]>15)throw Error(`illegal tag: varint overflows uint32`);let r=t>>>3,i=t&7;if(r<=0||i>5)throw Error(`illegal tag: field no `+r+` wire type `+i);return[r,i]}skip(e,t,n=100){let r=this.pos;switch(e){case Jh.Varint:for(;this.buf[this.pos++]&128;);break;case Jh.Bit64:this.pos+=4;case Jh.Bit32:this.pos+=4;break;case Jh.LengthDelimited:let r=this.uint32();this.pos+=r;break;case Jh.StartGroup:if(n<=0)throw Error(`maximum recursion depth reached`);for(;;){let[e,r]=this.tag();if(r===Jh.EndGroup){if(t!==void 0&&e!==t)throw Error(`invalid end group tag`);break}this.skip(r,e,n-1)}break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return Hh.dec(...this.varint64())}uint64(){return Hh.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,Hh.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Hh.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Hh.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(e){return this.decodeUtf8(this.bytes(),e)}};function Xh(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid int32: `+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw Error(`invalid int32: `+e)}function Zh(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid uint32: `+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw Error(`invalid uint32: `+e)}function see(e){if(typeof e==`string`){let t=e;if(e=Number(e),Number.isNaN(e)&&t!==`NaN`)throw Error(`invalid float32: `+t)}else if(typeof e!=`number`)throw Error(`invalid float32: `+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw Error(`invalid float32: `+e)}var Qh=function(e){return e[e.NULL_VALUE=0]=`NULL_VALUE`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({});function $h(){return{fields:{}}}var eg={encode(e,t=new Yh){return Object.entries(e.fields).forEach(([e,n])=>{n!==void 0&&ng.encode({key:e,value:n},t.uint32(10).fork()).join()}),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=$h();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:{if(e!==10)break;let t=ng.decode(n,n.uint32());t.value!==void 0&&(i.fields[t.key]=t.value);continue}}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return eg.fromPartial(e??{})},fromPartial(e){let t=$h();return t.fields=Object.entries(e.fields??{}).reduce((e,[t,n])=>(n!==void 0&&(e[t]=n),e),{}),t},wrap(e){let t=$h();if(e!==void 0)for(let n of Object.keys(e))t.fields[n]=e[n];return t},unwrap(e){let t={};if(e.fields)for(let n of Object.keys(e.fields))t[n]=e.fields[n];return t}};function tg(){return{key:``,value:void 0}}var ng={encode(e,t=new Yh){return e.key!==``&&t.uint32(10).string(e.key),e.value!==void 0&&ig.encode(ig.wrap(e.value),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=tg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.key=n.string();continue;case 2:if(e!==18)break;i.value=ig.unwrap(ig.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ng.fromPartial(e??{})},fromPartial(e){let t=tg();return t.key=e.key??``,t.value=e.value??void 0,t}};function rg(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var ig={encode(e,t=new Yh){return e.nullValue!==void 0&&t.uint32(8).int32(e.nullValue),e.numberValue!==void 0&&t.uint32(17).double(e.numberValue),e.stringValue!==void 0&&t.uint32(26).string(e.stringValue),e.boolValue!==void 0&&t.uint32(32).bool(e.boolValue),e.structValue!==void 0&&eg.encode(eg.wrap(e.structValue),t.uint32(42).fork()).join(),e.listValue!==void 0&&og.encode(og.wrap(e.listValue),t.uint32(50).fork()).join(),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=rg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==8)break;i.nullValue=n.int32();continue;case 2:if(e!==17)break;i.numberValue=n.double();continue;case 3:if(e!==26)break;i.stringValue=n.string();continue;case 4:if(e!==32)break;i.boolValue=n.bool();continue;case 5:if(e!==42)break;i.structValue=eg.unwrap(eg.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.listValue=og.unwrap(og.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ig.fromPartial(e??{})},fromPartial(e){let t=rg();return t.nullValue=e.nullValue??void 0,t.numberValue=e.numberValue??void 0,t.stringValue=e.stringValue??void 0,t.boolValue=e.boolValue??void 0,t.structValue=e.structValue??void 0,t.listValue=e.listValue??void 0,t},wrap(e){let t=rg();if(e===null)t.nullValue=Qh.NULL_VALUE;else if(typeof e==`boolean`)t.boolValue=e;else if(typeof e==`number`)t.numberValue=e;else if(typeof e==`string`)t.stringValue=e;else if(globalThis.Array.isArray(e))t.listValue=e;else if(typeof e==`object`)t.structValue=e;else if(e!==void 0)throw new globalThis.Error(`Unsupported any value type: `+typeof e);return t},unwrap(e){if(e.stringValue!==void 0)return e.stringValue;if(e?.numberValue!==void 0)return e.numberValue;if(e?.boolValue!==void 0)return e.boolValue;if(e?.structValue!==void 0)return e.structValue;if(e?.listValue!==void 0)return e.listValue;if(e?.nullValue!==void 0)return null}};function ag(){return{values:[]}}var og={encode(e,t=new Yh){for(let n of e.values)ig.encode(ig.wrap(n),t.uint32(10).fork()).join();return t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=ag();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.values.push(ig.unwrap(ig.decode(n,n.uint32())));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return og.fromPartial(e??{})},fromPartial(e){let t=ag();return t.values=e.values?.map(e=>e)||[],t},wrap(e){let t=ag();return t.values=e??[],t},unwrap(e){return e?.hasOwnProperty(`values`)&&globalThis.Array.isArray(e.values)?e.values:e}},sg=function(e){return e[e.ADD=0]=`ADD`,e[e.REMOVE=1]=`REMOVE`,e[e.REPLACE=2]=`REPLACE`,e[e.MOVE=3]=`MOVE`,e[e.COPY=4]=`COPY`,e[e.TEST=5]=`TEST`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({});function cg(){return{op:0,path:``,from:void 0,value:void 0}}var lg={encode(e,t=new Yh){return e.op!==0&&t.uint32(8).int32(e.op),e.path!==``&&t.uint32(18).string(e.path),e.from!==void 0&&t.uint32(26).string(e.from),e.value!==void 0&&ig.encode(ig.wrap(e.value),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=cg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==8)break;i.op=n.int32();continue;case 2:if(e!==18)break;i.path=n.string();continue;case 3:if(e!==26)break;i.from=n.string();continue;case 4:if(e!==34)break;i.value=ig.unwrap(ig.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return lg.fromPartial(e??{})},fromPartial(e){let t=cg();return t.op=e.op??0,t.path=e.path??``,t.from=e.from??void 0,t.value=e.value??void 0,t}};function ug(){return{id:``,type:``,function:void 0}}var dg={encode(e,t=new Yh){return e.id!==``&&t.uint32(10).string(e.id),e.type!==``&&t.uint32(18).string(e.type),e.function!==void 0&&pg.encode(e.function,t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=ug();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.id=n.string();continue;case 2:if(e!==18)break;i.type=n.string();continue;case 3:if(e!==26)break;i.function=pg.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return dg.fromPartial(e??{})},fromPartial(e){let t=ug();return t.id=e.id??``,t.type=e.type??``,t.function=e.function!==void 0&&e.function!==null?pg.fromPartial(e.function):void 0,t}};function fg(){return{name:``,arguments:``}}var pg={encode(e,t=new Yh){return e.name!==``&&t.uint32(10).string(e.name),e.arguments!==``&&t.uint32(18).string(e.arguments),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=fg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.name=n.string();continue;case 2:if(e!==18)break;i.arguments=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return pg.fromPartial(e??{})},fromPartial(e){let t=fg();return t.name=e.name??``,t.arguments=e.arguments??``,t}};function mg(){return{value:``,mimeType:``}}var hg={encode(e,t=new Yh){return e.value!==``&&t.uint32(10).string(e.value),e.mimeType!==``&&t.uint32(18).string(e.mimeType),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=mg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.value=n.string();continue;case 2:if(e!==18)break;i.mimeType=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return hg.fromPartial(e??{})},fromPartial(e){let t=mg();return t.value=e.value??``,t.mimeType=e.mimeType??``,t}};function gg(){return{value:``,mimeType:void 0}}var _g={encode(e,t=new Yh){return e.value!==``&&t.uint32(10).string(e.value),e.mimeType!==void 0&&t.uint32(18).string(e.mimeType),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=gg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.value=n.string();continue;case 2:if(e!==18)break;i.mimeType=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return _g.fromPartial(e??{})},fromPartial(e){let t=gg();return t.value=e.value??``,t.mimeType=e.mimeType??void 0,t}};function vg(){return{data:void 0,url:void 0}}var yg={encode(e,t=new Yh){return e.data!==void 0&&hg.encode(e.data,t.uint32(10).fork()).join(),e.url!==void 0&&_g.encode(e.url,t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=vg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.data=hg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.url=_g.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return yg.fromPartial(e??{})},fromPartial(e){let t=vg();return t.data=e.data!==void 0&&e.data!==null?hg.fromPartial(e.data):void 0,t.url=e.url!==void 0&&e.url!==null?_g.fromPartial(e.url):void 0,t}};function bg(){return{text:``}}var xg={encode(e,t=new Yh){return e.text!==``&&t.uint32(10).string(e.text),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=bg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.text=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return xg.fromPartial(e??{})},fromPartial(e){let t=bg();return t.text=e.text??``,t}};function Sg(){return{source:void 0,metadata:void 0}}var Cg={encode(e,t=new Yh){return e.source!==void 0&&yg.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&ig.encode(ig.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=Sg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=yg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=ig.unwrap(ig.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Cg.fromPartial(e??{})},fromPartial(e){let t=Sg();return t.source=e.source!==void 0&&e.source!==null?yg.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function wg(){return{source:void 0,metadata:void 0}}var Tg={encode(e,t=new Yh){return e.source!==void 0&&yg.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&ig.encode(ig.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=wg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=yg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=ig.unwrap(ig.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Tg.fromPartial(e??{})},fromPartial(e){let t=wg();return t.source=e.source!==void 0&&e.source!==null?yg.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function Eg(){return{source:void 0,metadata:void 0}}var Dg={encode(e,t=new Yh){return e.source!==void 0&&yg.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&ig.encode(ig.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=Eg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=yg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=ig.unwrap(ig.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Dg.fromPartial(e??{})},fromPartial(e){let t=Eg();return t.source=e.source!==void 0&&e.source!==null?yg.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function Og(){return{source:void 0,metadata:void 0}}var kg={encode(e,t=new Yh){return e.source!==void 0&&yg.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&ig.encode(ig.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=Og();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=yg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=ig.unwrap(ig.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return kg.fromPartial(e??{})},fromPartial(e){let t=Og();return t.source=e.source!==void 0&&e.source!==null?yg.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function Ag(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var jg={encode(e,t=new Yh){return e.text!==void 0&&xg.encode(e.text,t.uint32(10).fork()).join(),e.image!==void 0&&Cg.encode(e.image,t.uint32(18).fork()).join(),e.audio!==void 0&&Tg.encode(e.audio,t.uint32(26).fork()).join(),e.video!==void 0&&Dg.encode(e.video,t.uint32(34).fork()).join(),e.document!==void 0&&kg.encode(e.document,t.uint32(42).fork()).join(),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=Ag();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.text=xg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.image=Cg.decode(n,n.uint32());continue;case 3:if(e!==26)break;i.audio=Tg.decode(n,n.uint32());continue;case 4:if(e!==34)break;i.video=Dg.decode(n,n.uint32());continue;case 5:if(e!==42)break;i.document=kg.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return jg.fromPartial(e??{})},fromPartial(e){let t=Ag();return t.text=e.text!==void 0&&e.text!==null?xg.fromPartial(e.text):void 0,t.image=e.image!==void 0&&e.image!==null?Cg.fromPartial(e.image):void 0,t.audio=e.audio!==void 0&&e.audio!==null?Tg.fromPartial(e.audio):void 0,t.video=e.video!==void 0&&e.video!==null?Dg.fromPartial(e.video):void 0,t.document=e.document!==void 0&&e.document!==null?kg.fromPartial(e.document):void 0,t}};function Mg(){return{id:``,role:``,content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[]}}var Ng={encode(e,t=new Yh){e.id!==``&&t.uint32(10).string(e.id),e.role!==``&&t.uint32(18).string(e.role),e.content!==void 0&&t.uint32(26).string(e.content),e.name!==void 0&&t.uint32(34).string(e.name);for(let n of e.toolCalls)dg.encode(n,t.uint32(42).fork()).join();e.toolCallId!==void 0&&t.uint32(50).string(e.toolCallId),e.error!==void 0&&t.uint32(58).string(e.error);for(let n of e.contentParts)jg.encode(n,t.uint32(66).fork()).join();return t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=Mg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.id=n.string();continue;case 2:if(e!==18)break;i.role=n.string();continue;case 3:if(e!==26)break;i.content=n.string();continue;case 4:if(e!==34)break;i.name=n.string();continue;case 5:if(e!==42)break;i.toolCalls.push(dg.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.toolCallId=n.string();continue;case 7:if(e!==58)break;i.error=n.string();continue;case 8:if(e!==66)break;i.contentParts.push(jg.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ng.fromPartial(e??{})},fromPartial(e){let t=Mg();return t.id=e.id??``,t.role=e.role??``,t.content=e.content??void 0,t.name=e.name??void 0,t.toolCalls=e.toolCalls?.map(e=>dg.fromPartial(e))||[],t.toolCallId=e.toolCallId??void 0,t.error=e.error??void 0,t.contentParts=e.contentParts?.map(e=>jg.fromPartial(e))||[],t}};function Pg(){return{id:``,reason:``,message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0}}var Fg={encode(e,t=new Yh){return e.id!==``&&t.uint32(10).string(e.id),e.reason!==``&&t.uint32(18).string(e.reason),e.message!==void 0&&t.uint32(26).string(e.message),e.toolCallId!==void 0&&t.uint32(34).string(e.toolCallId),e.responseSchema!==void 0&&ig.encode(ig.wrap(e.responseSchema),t.uint32(42).fork()).join(),e.expiresAt!==void 0&&t.uint32(50).string(e.expiresAt),e.metadata!==void 0&&ig.encode(ig.wrap(e.metadata),t.uint32(58).fork()).join(),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=Pg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.id=n.string();continue;case 2:if(e!==18)break;i.reason=n.string();continue;case 3:if(e!==26)break;i.message=n.string();continue;case 4:if(e!==34)break;i.toolCallId=n.string();continue;case 5:if(e!==42)break;i.responseSchema=ig.unwrap(ig.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.expiresAt=n.string();continue;case 7:if(e!==58)break;i.metadata=ig.unwrap(ig.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Fg.fromPartial(e??{})},fromPartial(e){let t=Pg();return t.id=e.id??``,t.reason=e.reason??``,t.message=e.message??void 0,t.toolCallId=e.toolCallId??void 0,t.responseSchema=e.responseSchema??void 0,t.expiresAt=e.expiresAt??void 0,t.metadata=e.metadata??void 0,t}},cee=function(e){return e[e.TEXT_MESSAGE_START=0]=`TEXT_MESSAGE_START`,e[e.TEXT_MESSAGE_CONTENT=1]=`TEXT_MESSAGE_CONTENT`,e[e.TEXT_MESSAGE_END=2]=`TEXT_MESSAGE_END`,e[e.TOOL_CALL_START=3]=`TOOL_CALL_START`,e[e.TOOL_CALL_ARGS=4]=`TOOL_CALL_ARGS`,e[e.TOOL_CALL_END=5]=`TOOL_CALL_END`,e[e.STATE_SNAPSHOT=6]=`STATE_SNAPSHOT`,e[e.STATE_DELTA=7]=`STATE_DELTA`,e[e.MESSAGES_SNAPSHOT=8]=`MESSAGES_SNAPSHOT`,e[e.RAW=9]=`RAW`,e[e.CUSTOM=10]=`CUSTOM`,e[e.RUN_STARTED=11]=`RUN_STARTED`,e[e.RUN_FINISHED=12]=`RUN_FINISHED`,e[e.RUN_ERROR=13]=`RUN_ERROR`,e[e.STEP_STARTED=14]=`STEP_STARTED`,e[e.STEP_FINISHED=15]=`STEP_FINISHED`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({});function Ig(){return{type:0,timestamp:void 0,rawEvent:void 0}}var Lg={encode(e,t=new Yh){return e.type!==0&&t.uint32(8).int32(e.type),e.timestamp!==void 0&&t.uint32(16).int64(e.timestamp),e.rawEvent!==void 0&&ig.encode(ig.wrap(e.rawEvent),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=Ig();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==8)break;i.type=n.int32();continue;case 2:if(e!==16)break;i.timestamp=S_(n.int64());continue;case 3:if(e!==26)break;i.rawEvent=ig.unwrap(ig.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Lg.fromPartial(e??{})},fromPartial(e){let t=Ig();return t.type=e.type??0,t.timestamp=e.timestamp??void 0,t.rawEvent=e.rawEvent??void 0,t}};function Rg(){return{baseEvent:void 0,messageId:``,role:void 0,name:void 0}}var zg={encode(e,t=new Yh){return e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==``&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.name!==void 0&&t.uint32(34).string(e.name),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=Rg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.role=n.string();continue;case 4:if(e!==34)break;i.name=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return zg.fromPartial(e??{})},fromPartial(e){let t=Rg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t.role=e.role??void 0,t.name=e.name??void 0,t}};function Bg(){return{baseEvent:void 0,messageId:``,delta:``}}var Vg={encode(e,t=new Yh){return e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==``&&t.uint32(18).string(e.messageId),e.delta!==``&&t.uint32(26).string(e.delta),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=Bg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.delta=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Vg.fromPartial(e??{})},fromPartial(e){let t=Bg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t.delta=e.delta??``,t}};function Hg(){return{baseEvent:void 0,messageId:``}}var Ug={encode(e,t=new Yh){return e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==``&&t.uint32(18).string(e.messageId),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=Hg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ug.fromPartial(e??{})},fromPartial(e){let t=Hg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t}};function Wg(){return{baseEvent:void 0,toolCallId:``,toolCallName:``,parentMessageId:void 0}}var Gg={encode(e,t=new Yh){return e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),e.toolCallName!==``&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=Wg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.toolCallName=n.string();continue;case 4:if(e!==34)break;i.parentMessageId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Gg.fromPartial(e??{})},fromPartial(e){let t=Wg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t.toolCallName=e.toolCallName??``,t.parentMessageId=e.parentMessageId??void 0,t}};function Kg(){return{baseEvent:void 0,toolCallId:``,delta:``}}var qg={encode(e,t=new Yh){return e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),e.delta!==``&&t.uint32(26).string(e.delta),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=Kg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.delta=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return qg.fromPartial(e??{})},fromPartial(e){let t=Kg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t.delta=e.delta??``,t}};function Jg(){return{baseEvent:void 0,toolCallId:``}}var Yg={encode(e,t=new Yh){return e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=Jg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Yg.fromPartial(e??{})},fromPartial(e){let t=Jg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t}};function Xg(){return{baseEvent:void 0,snapshot:void 0}}var Zg={encode(e,t=new Yh){return e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.snapshot!==void 0&&ig.encode(ig.wrap(e.snapshot),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=Xg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.snapshot=ig.unwrap(ig.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Zg.fromPartial(e??{})},fromPartial(e){let t=Xg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.snapshot=e.snapshot??void 0,t}};function Qg(){return{baseEvent:void 0,delta:[]}}var $g={encode(e,t=new Yh){e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.delta)lg.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=Qg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.delta.push(lg.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return $g.fromPartial(e??{})},fromPartial(e){let t=Qg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.delta=e.delta?.map(e=>lg.fromPartial(e))||[],t}};function e_(){return{baseEvent:void 0,messages:[]}}var t_={encode(e,t=new Yh){e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.messages)Ng.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=e_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messages.push(Ng.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return t_.fromPartial(e??{})},fromPartial(e){let t=e_();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.messages=e.messages?.map(e=>Ng.fromPartial(e))||[],t}};function n_(){return{baseEvent:void 0,event:void 0,source:void 0}}var r_={encode(e,t=new Yh){return e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.event!==void 0&&ig.encode(ig.wrap(e.event),t.uint32(18).fork()).join(),e.source!==void 0&&t.uint32(26).string(e.source),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=n_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.event=ig.unwrap(ig.decode(n,n.uint32()));continue;case 3:if(e!==26)break;i.source=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return r_.fromPartial(e??{})},fromPartial(e){let t=n_();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.event=e.event??void 0,t.source=e.source??void 0,t}};function i_(){return{baseEvent:void 0,name:``,value:void 0}}var a_={encode(e,t=new Yh){return e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.name!==``&&t.uint32(18).string(e.name),e.value!==void 0&&ig.encode(ig.wrap(e.value),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=i_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.name=n.string();continue;case 3:if(e!==26)break;i.value=ig.unwrap(ig.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return a_.fromPartial(e??{})},fromPartial(e){let t=i_();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.name=e.name??``,t.value=e.value??void 0,t}};function o_(){return{baseEvent:void 0,threadId:``,runId:``}}var s_={encode(e,t=new Yh){return e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==``&&t.uint32(18).string(e.threadId),e.runId!==``&&t.uint32(26).string(e.runId),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=o_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.threadId=n.string();continue;case 3:if(e!==26)break;i.runId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return s_.fromPartial(e??{})},fromPartial(e){let t=o_();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??``,t.runId=e.runId??``,t}};function c_(){return{baseEvent:void 0,threadId:``,runId:``,result:void 0,outcome:``,interrupts:[]}}var l_={encode(e,t=new Yh){e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==``&&t.uint32(18).string(e.threadId),e.runId!==``&&t.uint32(26).string(e.runId),e.result!==void 0&&ig.encode(ig.wrap(e.result),t.uint32(34).fork()).join(),e.outcome!==``&&t.uint32(42).string(e.outcome);for(let n of e.interrupts)Fg.encode(n,t.uint32(50).fork()).join();return t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=c_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.threadId=n.string();continue;case 3:if(e!==26)break;i.runId=n.string();continue;case 4:if(e!==34)break;i.result=ig.unwrap(ig.decode(n,n.uint32()));continue;case 5:if(e!==42)break;i.outcome=n.string();continue;case 6:if(e!==50)break;i.interrupts.push(Fg.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return l_.fromPartial(e??{})},fromPartial(e){let t=c_();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??``,t.runId=e.runId??``,t.result=e.result??void 0,t.outcome=e.outcome??``,t.interrupts=e.interrupts?.map(e=>Fg.fromPartial(e))||[],t}};function u_(){return{baseEvent:void 0,code:void 0,message:``}}var d_={encode(e,t=new Yh){return e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.code!==void 0&&t.uint32(18).string(e.code),e.message!==``&&t.uint32(26).string(e.message),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=u_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.code=n.string();continue;case 3:if(e!==26)break;i.message=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return d_.fromPartial(e??{})},fromPartial(e){let t=u_();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.code=e.code??void 0,t.message=e.message??``,t}};function f_(){return{baseEvent:void 0,stepName:``}}var p_={encode(e,t=new Yh){return e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==``&&t.uint32(18).string(e.stepName),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=f_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.stepName=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return p_.fromPartial(e??{})},fromPartial(e){let t=f_();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??``,t}};function m_(){return{baseEvent:void 0,stepName:``}}var h_={encode(e,t=new Yh){return e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==``&&t.uint32(18).string(e.stepName),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=m_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.stepName=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return h_.fromPartial(e??{})},fromPartial(e){let t=m_();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??``,t}};function g_(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0}}var __={encode(e,t=new Yh){return e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==void 0&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.delta!==void 0&&t.uint32(34).string(e.delta),e.name!==void 0&&t.uint32(42).string(e.name),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=g_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.role=n.string();continue;case 4:if(e!==34)break;i.delta=n.string();continue;case 5:if(e!==42)break;i.name=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return __.fromPartial(e??{})},fromPartial(e){let t=g_();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??void 0,t.role=e.role??void 0,t.delta=e.delta??void 0,t.name=e.name??void 0,t}};function v_(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var y_={encode(e,t=new Yh){return e.baseEvent!==void 0&&Lg.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==void 0&&t.uint32(18).string(e.toolCallId),e.toolCallName!==void 0&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),e.delta!==void 0&&t.uint32(42).string(e.delta),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=v_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.toolCallName=n.string();continue;case 4:if(e!==34)break;i.parentMessageId=n.string();continue;case 5:if(e!==42)break;i.delta=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return y_.fromPartial(e??{})},fromPartial(e){let t=v_();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Lg.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??void 0,t.toolCallName=e.toolCallName??void 0,t.parentMessageId=e.parentMessageId??void 0,t.delta=e.delta??void 0,t}};function b_(){return{textMessageStart:void 0,textMessageContent:void 0,textMessageEnd:void 0,toolCallStart:void 0,toolCallArgs:void 0,toolCallEnd:void 0,stateSnapshot:void 0,stateDelta:void 0,messagesSnapshot:void 0,raw:void 0,custom:void 0,runStarted:void 0,runFinished:void 0,runError:void 0,stepStarted:void 0,stepFinished:void 0,textMessageChunk:void 0,toolCallChunk:void 0}}var x_={encode(e,t=new Yh){return e.textMessageStart!==void 0&&zg.encode(e.textMessageStart,t.uint32(10).fork()).join(),e.textMessageContent!==void 0&&Vg.encode(e.textMessageContent,t.uint32(18).fork()).join(),e.textMessageEnd!==void 0&&Ug.encode(e.textMessageEnd,t.uint32(26).fork()).join(),e.toolCallStart!==void 0&&Gg.encode(e.toolCallStart,t.uint32(34).fork()).join(),e.toolCallArgs!==void 0&&qg.encode(e.toolCallArgs,t.uint32(42).fork()).join(),e.toolCallEnd!==void 0&&Yg.encode(e.toolCallEnd,t.uint32(50).fork()).join(),e.stateSnapshot!==void 0&&Zg.encode(e.stateSnapshot,t.uint32(58).fork()).join(),e.stateDelta!==void 0&&$g.encode(e.stateDelta,t.uint32(66).fork()).join(),e.messagesSnapshot!==void 0&&t_.encode(e.messagesSnapshot,t.uint32(74).fork()).join(),e.raw!==void 0&&r_.encode(e.raw,t.uint32(82).fork()).join(),e.custom!==void 0&&a_.encode(e.custom,t.uint32(90).fork()).join(),e.runStarted!==void 0&&s_.encode(e.runStarted,t.uint32(98).fork()).join(),e.runFinished!==void 0&&l_.encode(e.runFinished,t.uint32(106).fork()).join(),e.runError!==void 0&&d_.encode(e.runError,t.uint32(114).fork()).join(),e.stepStarted!==void 0&&p_.encode(e.stepStarted,t.uint32(122).fork()).join(),e.stepFinished!==void 0&&h_.encode(e.stepFinished,t.uint32(130).fork()).join(),e.textMessageChunk!==void 0&&__.encode(e.textMessageChunk,t.uint32(138).fork()).join(),e.toolCallChunk!==void 0&&y_.encode(e.toolCallChunk,t.uint32(146).fork()).join(),t},decode(e,t){let n=e instanceof I?e:new I(e),r=t===void 0?n.len:n.pos+t,i=b_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.textMessageStart=zg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.textMessageContent=Vg.decode(n,n.uint32());continue;case 3:if(e!==26)break;i.textMessageEnd=Ug.decode(n,n.uint32());continue;case 4:if(e!==34)break;i.toolCallStart=Gg.decode(n,n.uint32());continue;case 5:if(e!==42)break;i.toolCallArgs=qg.decode(n,n.uint32());continue;case 6:if(e!==50)break;i.toolCallEnd=Yg.decode(n,n.uint32());continue;case 7:if(e!==58)break;i.stateSnapshot=Zg.decode(n,n.uint32());continue;case 8:if(e!==66)break;i.stateDelta=$g.decode(n,n.uint32());continue;case 9:if(e!==74)break;i.messagesSnapshot=t_.decode(n,n.uint32());continue;case 10:if(e!==82)break;i.raw=r_.decode(n,n.uint32());continue;case 11:if(e!==90)break;i.custom=a_.decode(n,n.uint32());continue;case 12:if(e!==98)break;i.runStarted=s_.decode(n,n.uint32());continue;case 13:if(e!==106)break;i.runFinished=l_.decode(n,n.uint32());continue;case 14:if(e!==114)break;i.runError=d_.decode(n,n.uint32());continue;case 15:if(e!==122)break;i.stepStarted=p_.decode(n,n.uint32());continue;case 16:if(e!==130)break;i.stepFinished=h_.decode(n,n.uint32());continue;case 17:if(e!==138)break;i.textMessageChunk=__.decode(n,n.uint32());continue;case 18:if(e!==146)break;i.toolCallChunk=y_.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return x_.fromPartial(e??{})},fromPartial(e){let t=b_();return t.textMessageStart=e.textMessageStart!==void 0&&e.textMessageStart!==null?zg.fromPartial(e.textMessageStart):void 0,t.textMessageContent=e.textMessageContent!==void 0&&e.textMessageContent!==null?Vg.fromPartial(e.textMessageContent):void 0,t.textMessageEnd=e.textMessageEnd!==void 0&&e.textMessageEnd!==null?Ug.fromPartial(e.textMessageEnd):void 0,t.toolCallStart=e.toolCallStart!==void 0&&e.toolCallStart!==null?Gg.fromPartial(e.toolCallStart):void 0,t.toolCallArgs=e.toolCallArgs!==void 0&&e.toolCallArgs!==null?qg.fromPartial(e.toolCallArgs):void 0,t.toolCallEnd=e.toolCallEnd!==void 0&&e.toolCallEnd!==null?Yg.fromPartial(e.toolCallEnd):void 0,t.stateSnapshot=e.stateSnapshot!==void 0&&e.stateSnapshot!==null?Zg.fromPartial(e.stateSnapshot):void 0,t.stateDelta=e.stateDelta!==void 0&&e.stateDelta!==null?$g.fromPartial(e.stateDelta):void 0,t.messagesSnapshot=e.messagesSnapshot!==void 0&&e.messagesSnapshot!==null?t_.fromPartial(e.messagesSnapshot):void 0,t.raw=e.raw!==void 0&&e.raw!==null?r_.fromPartial(e.raw):void 0,t.custom=e.custom!==void 0&&e.custom!==null?a_.fromPartial(e.custom):void 0,t.runStarted=e.runStarted!==void 0&&e.runStarted!==null?s_.fromPartial(e.runStarted):void 0,t.runFinished=e.runFinished!==void 0&&e.runFinished!==null?l_.fromPartial(e.runFinished):void 0,t.runError=e.runError!==void 0&&e.runError!==null?d_.fromPartial(e.runError):void 0,t.stepStarted=e.stepStarted!==void 0&&e.stepStarted!==null?p_.fromPartial(e.stepStarted):void 0,t.stepFinished=e.stepFinished!==void 0&&e.stepFinished!==null?h_.fromPartial(e.stepFinished):void 0,t.textMessageChunk=e.textMessageChunk!==void 0&&e.textMessageChunk!==null?__.fromPartial(e.textMessageChunk):void 0,t.toolCallChunk=e.toolCallChunk!==void 0&&e.toolCallChunk!==null?y_.fromPartial(e.toolCallChunk):void 0,t}};function S_(e){let t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error(`Value is larger than Number.MAX_SAFE_INTEGER`);if(t<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error(`Value is smaller than Number.MIN_SAFE_INTEGER`);return t}var C_=e=>{if(!(!e||typeof e!=`object`)){if(e.data)return{type:`data`,value:e.data.value,mimeType:e.data.mimeType};if(e.url)return{type:`url`,value:e.url.value,mimeType:e.url.mimeType}}},lee=e=>{if(!(!e||typeof e!=`object`)){if(e.text)return{type:`text`,text:e.text.text};if(e.image)return{type:`image`,source:C_(e.image.source),metadata:e.image.metadata};if(e.audio)return{type:`audio`,source:C_(e.audio.source),metadata:e.audio.metadata};if(e.video)return{type:`video`,source:C_(e.video.source),metadata:e.video.metadata};if(e.document)return{type:`document`,source:C_(e.document.source),metadata:e.document.metadata}}};function uee(e){let t=x_.decode(e),n=Object.values(t).find(e=>e!==void 0);if(!n)throw Error(`Invalid event`);if(n.type=cee[n.baseEvent.type],n.timestamp=n.baseEvent.timestamp,n.rawEvent=n.baseEvent.rawEvent,delete n.baseEvent,n.type===F.MESSAGES_SNAPSHOT)for(let e of n.messages){let t=e;if(t.role===`user`&&Array.isArray(t.contentParts)){let e=t.contentParts.map(e=>lee(e)).filter(e=>e!==void 0);e.length>0&&(t.content=e)}Array.isArray(t.contentParts)&&t.contentParts.length===0&&(t.contentParts=void 0),t.toolCalls?.length===0&&(t.toolCalls=void 0)}if(n.type===F.RUN_FINISHED){let e=n,t=typeof e.outcome==`string`&&e.outcome!==``?e.outcome:void 0,r=Array.isArray(e.interrupts)?e.interrupts:[];delete e.interrupts,t===`interrupt`?e.outcome={type:`interrupt`,interrupts:r}:t===`success`?e.outcome={type:`success`}:delete e.outcome}if(n.type===F.STATE_DELTA)for(let e of n.delta)e.op=sg[e.op].toLowerCase(),Object.keys(e).forEach(t=>{e[t]===void 0&&delete e[t]});return Object.keys(n).forEach(e=>{n[e]===void 0&&delete n[e]}),ep.parse(n)}var w_;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(w_||={});var dee;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(dee||={});var T_=w_.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),E_=e=>{switch(typeof e){case`undefined`:return T_.undefined;case`string`:return T_.string;case`number`:return Number.isNaN(e)?T_.nan:T_.number;case`boolean`:return T_.boolean;case`function`:return T_.function;case`bigint`:return T_.bigint;case`symbol`:return T_.symbol;case`object`:return Array.isArray(e)?T_.array:e===null?T_.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?T_.promise:typeof Map<`u`&&e instanceof Map?T_.map:typeof Set<`u`&&e instanceof Set?T_.set:typeof Date<`u`&&e instanceof Date?T_.date:T_.object;default:return T_.unknown}},L=w_.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),D_=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,w_.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};D_.create=e=>new D_(e);var O_=(e,t)=>{let n;switch(e.code){case L.invalid_type:n=e.received===T_.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case L.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,w_.jsonStringifyReplacer)}`;break;case L.unrecognized_keys:n=`Unrecognized key(s) in object: ${w_.joinValues(e.keys,`, `)}`;break;case L.invalid_union:n=`Invalid input`;break;case L.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${w_.joinValues(e.options)}`;break;case L.invalid_enum_value:n=`Invalid enum value. Expected ${w_.joinValues(e.options)}, received '${e.received}'`;break;case L.invalid_arguments:n=`Invalid function arguments`;break;case L.invalid_return_type:n=`Invalid function return type`;break;case L.invalid_date:n=`Invalid date`;break;case L.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:w_.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case L.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case L.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case L.custom:n=`Invalid input`;break;case L.invalid_intersection_types:n=`Intersection results could not be merged`;break;case L.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case L.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,w_.assertNever(e)}return{message:n}},fee=O_;function k_(){return fee}var A_=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function R(e,t){let n=k_(),r=A_({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===O_?void 0:O_].filter(e=>!!e)});e.common.issues.push(r)}var j_=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return M_;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return M_;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},M_=Object.freeze({status:`aborted`}),N_=e=>({status:`dirty`,value:e}),P_=e=>({status:`valid`,value:e}),F_=e=>e.status===`aborted`,I_=e=>e.status===`dirty`,L_=e=>e.status===`valid`,R_=e=>typeof Promise<`u`&&e instanceof Promise,z_;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(z_||={});var B_=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},V_=(e,t)=>{if(L_(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new D_(e.common.issues);return this._error=t,this._error}}};function H_(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var U_=class{get description(){return this._def.description}_getType(e){return E_(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:E_(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new j_,ctx:{common:e.parent.common,data:e.data,parsedType:E_(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(R_(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:E_(e)};return V_(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:E_(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return L_(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>L_(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:E_(e)},r=this._parse({data:e,path:n.path,parent:n});return V_(n,await(R_(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:L.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new Wv({schema:this,typeName:$v.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return Gv.create(this,this._def)}nullable(){return Kv.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Dv.create(this)}promise(){return Uv.create(this,this._def)}or(e){return Av.create([this,e],this._def)}and(e){return Pv.create(this,e,this._def)}transform(e){return new Wv({...H_(this._def),schema:this,typeName:$v.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new qv({...H_(this._def),innerType:this,defaultValue:t,typeName:$v.ZodDefault})}brand(){return new Xv({typeName:$v.ZodBranded,type:this,...H_(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Jv({...H_(this._def),innerType:this,catchValue:t,typeName:$v.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Zv.create(this,e)}readonly(){return Qv.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},W_=/^c[^\s-]{8,}$/i,G_=/^[0-9a-z]+$/,K_=/^[0-9A-HJKMNP-TV-Z]{26}$/i,q_=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,J_=/^[a-z0-9_-]{21}$/i,Y_=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,X_=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Z_=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Q_=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,$_,ev=/^(?:(?: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])$/,tv=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,nv=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,rv=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,iv=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,av=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ov=`((\\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])))`,sv=RegExp(`^${ov}$`);function cv(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function lv(e){return RegExp(`^${cv(e)}$`)}function uv(e){let t=`${ov}T${cv(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function dv(e,t){return!!((t===`v4`||!t)&&ev.test(e)||(t===`v6`||!t)&&nv.test(e))}function fv(e,t){if(!Y_.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function pv(e,t){return!!((t===`v4`||!t)&&tv.test(e)||(t===`v6`||!t)&&rv.test(e))}var mv=class e extends U_{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==T_.string){let t=this._getOrReturnCtx(e);return R(t,{code:L.invalid_type,expected:T_.string,received:t.parsedType}),M_}let t=new j_,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),R(n,{code:L.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),R(n,{code:L.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?R(n,{code:L.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&R(n,{code:L.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)Z_.test(e.data)||(n=this._getOrReturnCtx(e,n),R(n,{validation:`email`,code:L.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)$_||=new RegExp(Q_,`u`),$_.test(e.data)||(n=this._getOrReturnCtx(e,n),R(n,{validation:`emoji`,code:L.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)q_.test(e.data)||(n=this._getOrReturnCtx(e,n),R(n,{validation:`uuid`,code:L.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)J_.test(e.data)||(n=this._getOrReturnCtx(e,n),R(n,{validation:`nanoid`,code:L.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)W_.test(e.data)||(n=this._getOrReturnCtx(e,n),R(n,{validation:`cuid`,code:L.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)G_.test(e.data)||(n=this._getOrReturnCtx(e,n),R(n,{validation:`cuid2`,code:L.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)K_.test(e.data)||(n=this._getOrReturnCtx(e,n),R(n,{validation:`ulid`,code:L.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),R(n,{validation:`url`,code:L.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),R(n,{validation:`regex`,code:L.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),R(n,{code:L.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),R(n,{code:L.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),R(n,{code:L.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?uv(r).test(e.data)||(n=this._getOrReturnCtx(e,n),R(n,{code:L.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?sv.test(e.data)||(n=this._getOrReturnCtx(e,n),R(n,{code:L.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?lv(r).test(e.data)||(n=this._getOrReturnCtx(e,n),R(n,{code:L.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?X_.test(e.data)||(n=this._getOrReturnCtx(e,n),R(n,{validation:`duration`,code:L.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?dv(e.data,r.version)||(n=this._getOrReturnCtx(e,n),R(n,{validation:`ip`,code:L.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?fv(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),R(n,{validation:`jwt`,code:L.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?pv(e.data,r.version)||(n=this._getOrReturnCtx(e,n),R(n,{validation:`cidr`,code:L.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?iv.test(e.data)||(n=this._getOrReturnCtx(e,n),R(n,{validation:`base64`,code:L.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?av.test(e.data)||(n=this._getOrReturnCtx(e,n),R(n,{validation:`base64url`,code:L.invalid_string,message:r.message}),t.dirty()):w_.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:L.invalid_string,...z_.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...z_.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...z_.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...z_.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...z_.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...z_.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...z_.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...z_.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...z_.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...z_.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...z_.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...z_.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...z_.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...z_.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...z_.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...z_.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...z_.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...z_.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...z_.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...z_.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...z_.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...z_.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...z_.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...z_.errToObj(t)})}nonempty(e){return this.min(1,z_.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};mv.create=e=>new mv({checks:[],typeName:$v.ZodString,coerce:e?.coerce??!1,...H_(e)});function hv(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var gv=class e extends U_{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==T_.number){let t=this._getOrReturnCtx(e);return R(t,{code:L.invalid_type,expected:T_.number,received:t.parsedType}),M_}let t,n=new j_;for(let r of this._def.checks)r.kind===`int`?w_.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),R(t,{code:L.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),R(t,{code:L.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),R(t,{code:L.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?hv(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),R(t,{code:L.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),R(t,{code:L.not_finite,message:r.message}),n.dirty()):w_.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,z_.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,z_.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,z_.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,z_.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:z_.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:z_.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:z_.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:z_.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:z_.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:z_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:z_.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:z_.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:z_.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:z_.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&w_.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};gv.create=e=>new gv({checks:[],typeName:$v.ZodNumber,coerce:e?.coerce||!1,...H_(e)});var _v=class e extends U_{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==T_.bigint)return this._getInvalidInput(e);let t,n=new j_;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),R(t,{code:L.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),R(t,{code:L.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),R(t,{code:L.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):w_.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return R(t,{code:L.invalid_type,expected:T_.bigint,received:t.parsedType}),M_}gte(e,t){return this.setLimit(`min`,e,!0,z_.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,z_.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,z_.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,z_.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:z_.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:z_.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:z_.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:z_.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:z_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:z_.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};_v.create=e=>new _v({checks:[],typeName:$v.ZodBigInt,coerce:e?.coerce??!1,...H_(e)});var vv=class extends U_{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==T_.boolean){let t=this._getOrReturnCtx(e);return R(t,{code:L.invalid_type,expected:T_.boolean,received:t.parsedType}),M_}return P_(e.data)}};vv.create=e=>new vv({typeName:$v.ZodBoolean,coerce:e?.coerce||!1,...H_(e)});var yv=class e extends U_{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==T_.date){let t=this._getOrReturnCtx(e);return R(t,{code:L.invalid_type,expected:T_.date,received:t.parsedType}),M_}if(Number.isNaN(e.data.getTime()))return R(this._getOrReturnCtx(e),{code:L.invalid_date}),M_;let t=new j_,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),R(n,{code:L.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),R(n,{code:L.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):w_.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:z_.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:z_.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};yv.create=e=>new yv({checks:[],coerce:e?.coerce||!1,typeName:$v.ZodDate,...H_(e)});var bv=class extends U_{_parse(e){if(this._getType(e)!==T_.symbol){let t=this._getOrReturnCtx(e);return R(t,{code:L.invalid_type,expected:T_.symbol,received:t.parsedType}),M_}return P_(e.data)}};bv.create=e=>new bv({typeName:$v.ZodSymbol,...H_(e)});var xv=class extends U_{_parse(e){if(this._getType(e)!==T_.undefined){let t=this._getOrReturnCtx(e);return R(t,{code:L.invalid_type,expected:T_.undefined,received:t.parsedType}),M_}return P_(e.data)}};xv.create=e=>new xv({typeName:$v.ZodUndefined,...H_(e)});var Sv=class extends U_{_parse(e){if(this._getType(e)!==T_.null){let t=this._getOrReturnCtx(e);return R(t,{code:L.invalid_type,expected:T_.null,received:t.parsedType}),M_}return P_(e.data)}};Sv.create=e=>new Sv({typeName:$v.ZodNull,...H_(e)});var Cv=class extends U_{constructor(){super(...arguments),this._any=!0}_parse(e){return P_(e.data)}};Cv.create=e=>new Cv({typeName:$v.ZodAny,...H_(e)});var wv=class extends U_{constructor(){super(...arguments),this._unknown=!0}_parse(e){return P_(e.data)}};wv.create=e=>new wv({typeName:$v.ZodUnknown,...H_(e)});var Tv=class extends U_{_parse(e){let t=this._getOrReturnCtx(e);return R(t,{code:L.invalid_type,expected:T_.never,received:t.parsedType}),M_}};Tv.create=e=>new Tv({typeName:$v.ZodNever,...H_(e)});var Ev=class extends U_{_parse(e){if(this._getType(e)!==T_.undefined){let t=this._getOrReturnCtx(e);return R(t,{code:L.invalid_type,expected:T_.void,received:t.parsedType}),M_}return P_(e.data)}};Ev.create=e=>new Ev({typeName:$v.ZodVoid,...H_(e)});var Dv=class e extends U_{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==T_.array)return R(t,{code:L.invalid_type,expected:T_.array,received:t.parsedType}),M_;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(R(t,{code:e?L.too_big:L.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(R(t,{code:L.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(R(t,{code:L.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new B_(t,e,t.path,n)))).then(e=>j_.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new B_(t,e,t.path,n)));return j_.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:z_.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:z_.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:z_.toString(n)}})}nonempty(e){return this.min(1,e)}};Dv.create=(e,t)=>new Dv({type:e,minLength:null,maxLength:null,exactLength:null,typeName:$v.ZodArray,...H_(t)});function Ov(e){if(e instanceof kv){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Gv.create(Ov(r))}return new kv({...e._def,shape:()=>t})}else if(e instanceof Dv)return new Dv({...e._def,type:Ov(e.element)});else if(e instanceof Gv)return Gv.create(Ov(e.unwrap()));else if(e instanceof Kv)return Kv.create(Ov(e.unwrap()));else if(e instanceof Fv)return Fv.create(e.items.map(e=>Ov(e)));else return e}var kv=class e extends U_{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=w_.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==T_.object){let t=this._getOrReturnCtx(e);return R(t,{code:L.invalid_type,expected:T_.object,received:t.parsedType}),M_}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Tv&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new B_(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Tv){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(R(n,{code:L.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new B_(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>j_.mergeObjectSync(t,e)):j_.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return z_.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:z_.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:$v.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of w_.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of w_.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Ov(this)}partial(t){let n={};for(let e of w_.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of w_.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Gv;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Bv(w_.objectKeys(this.shape))}};kv.create=(e,t)=>new kv({shape:()=>e,unknownKeys:`strip`,catchall:Tv.create(),typeName:$v.ZodObject,...H_(t)}),kv.strictCreate=(e,t)=>new kv({shape:()=>e,unknownKeys:`strict`,catchall:Tv.create(),typeName:$v.ZodObject,...H_(t)}),kv.lazycreate=(e,t)=>new kv({shape:e,unknownKeys:`strip`,catchall:Tv.create(),typeName:$v.ZodObject,...H_(t)});var Av=class extends U_{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new D_(e.ctx.common.issues));return R(t,{code:L.invalid_union,unionErrors:n}),M_}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new D_(e));return R(t,{code:L.invalid_union,unionErrors:i}),M_}}get options(){return this._def.options}};Av.create=(e,t)=>new Av({options:e,typeName:$v.ZodUnion,...H_(t)});var jv=e=>e instanceof Rv?jv(e.schema):e instanceof Wv?jv(e.innerType()):e instanceof zv?[e.value]:e instanceof Vv?e.options:e instanceof Hv?w_.objectValues(e.enum):e instanceof qv?jv(e._def.innerType):e instanceof xv?[void 0]:e instanceof Sv?[null]:e instanceof Gv?[void 0,...jv(e.unwrap())]:e instanceof Kv?[null,...jv(e.unwrap())]:e instanceof Xv||e instanceof Qv?jv(e.unwrap()):e instanceof Jv?jv(e._def.innerType):[],Mv=class e extends U_{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==T_.object)return R(t,{code:L.invalid_type,expected:T_.object,received:t.parsedType}),M_;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(R(t,{code:L.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),M_)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=jv(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:$v.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...H_(r)})}};function Nv(e,t){let n=E_(e),r=E_(t);if(e===t)return{valid:!0,data:e};if(n===T_.object&&r===T_.object){let n=w_.objectKeys(t),r=w_.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Nv(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===T_.array&&r===T_.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Nv(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===T_.date&&r===T_.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Pv=class extends U_{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(F_(e)||F_(r))return M_;let i=Nv(e.value,r.value);return i.valid?((I_(e)||I_(r))&&t.dirty(),{status:t.value,value:i.data}):(R(n,{code:L.invalid_intersection_types}),M_)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Pv.create=(e,t,n)=>new Pv({left:e,right:t,typeName:$v.ZodIntersection,...H_(n)});var Fv=class e extends U_{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==T_.array)return R(n,{code:L.invalid_type,expected:T_.array,received:n.parsedType}),M_;if(n.data.length<this._def.items.length)return R(n,{code:L.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),M_;!this._def.rest&&n.data.length>this._def.items.length&&(R(n,{code:L.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new B_(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>j_.mergeArray(t,e)):j_.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Fv.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Fv({items:e,typeName:$v.ZodTuple,rest:null,...H_(t)})};var pee=class e extends U_{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==T_.object)return R(n,{code:L.invalid_type,expected:T_.object,received:n.parsedType}),M_;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new B_(n,e,n.path,e)),value:a._parse(new B_(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?j_.mergeObjectAsync(t,r):j_.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof U_?new e({keyType:t,valueType:n,typeName:$v.ZodRecord,...H_(r)}):new e({keyType:mv.create(),valueType:t,typeName:$v.ZodRecord,...H_(n)})}},Iv=class extends U_{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==T_.map)return R(n,{code:L.invalid_type,expected:T_.map,received:n.parsedType}),M_;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new B_(n,e,n.path,[a,`key`])),value:i._parse(new B_(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return M_;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return M_;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Iv.create=(e,t,n)=>new Iv({valueType:t,keyType:e,typeName:$v.ZodMap,...H_(n)});var Lv=class e extends U_{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==T_.set)return R(n,{code:L.invalid_type,expected:T_.set,received:n.parsedType}),M_;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(R(n,{code:L.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(R(n,{code:L.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return M_;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new B_(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:z_.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:z_.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Lv.create=(e,t)=>new Lv({valueType:e,minSize:null,maxSize:null,typeName:$v.ZodSet,...H_(t)});var mee=class e extends U_{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==T_.function)return R(t,{code:L.invalid_type,expected:T_.function,received:t.parsedType}),M_;function n(e,n){return A_({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,k_(),O_].filter(e=>!!e),issueData:{code:L.invalid_arguments,argumentsError:n}})}function r(e,n){return A_({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,k_(),O_].filter(e=>!!e),issueData:{code:L.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Uv){let e=this;return P_(async function(...t){let o=new D_([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return P_(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new D_([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new D_([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Fv.create(t).rest(wv.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Fv.create([]).rest(wv.create()),returns:n||wv.create(),typeName:$v.ZodFunction,...H_(r)})}},Rv=class extends U_{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Rv.create=(e,t)=>new Rv({getter:e,typeName:$v.ZodLazy,...H_(t)});var zv=class extends U_{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return R(t,{received:t.data,code:L.invalid_literal,expected:this._def.value}),M_}return{status:`valid`,value:e.data}}get value(){return this._def.value}};zv.create=(e,t)=>new zv({value:e,typeName:$v.ZodLiteral,...H_(t)});function Bv(e,t){return new Vv({values:e,typeName:$v.ZodEnum,...H_(t)})}var Vv=class e extends U_{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return R(t,{expected:w_.joinValues(n),received:t.parsedType,code:L.invalid_type}),M_}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return R(t,{received:t.data,code:L.invalid_enum_value,options:n}),M_}return P_(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};Vv.create=Bv;var Hv=class extends U_{_parse(e){let t=w_.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==T_.string&&n.parsedType!==T_.number){let e=w_.objectValues(t);return R(n,{expected:w_.joinValues(e),received:n.parsedType,code:L.invalid_type}),M_}if(this._cache||=new Set(w_.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=w_.objectValues(t);return R(n,{received:n.data,code:L.invalid_enum_value,options:e}),M_}return P_(e.data)}get enum(){return this._def.values}};Hv.create=(e,t)=>new Hv({values:e,typeName:$v.ZodNativeEnum,...H_(t)});var Uv=class extends U_{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==T_.promise&&t.common.async===!1?(R(t,{code:L.invalid_type,expected:T_.promise,received:t.parsedType}),M_):P_((t.parsedType===T_.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Uv.create=(e,t)=>new Uv({type:e,typeName:$v.ZodPromise,...H_(t)});var Wv=class extends U_{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{R(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return M_;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?M_:r.status===`dirty`||t.value===`dirty`?N_(r.value):r});{if(t.value===`aborted`)return M_;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?M_:r.status===`dirty`||t.value===`dirty`?N_(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?M_:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?M_:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!L_(e))return M_;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>L_(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):M_);w_.assertNever(r)}};Wv.create=(e,t,n)=>new Wv({schema:e,typeName:$v.ZodEffects,effect:t,...H_(n)}),Wv.createWithPreprocess=(e,t,n)=>new Wv({schema:t,effect:{type:`preprocess`,transform:e},typeName:$v.ZodEffects,...H_(n)});var Gv=class extends U_{_parse(e){return this._getType(e)===T_.undefined?P_(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Gv.create=(e,t)=>new Gv({innerType:e,typeName:$v.ZodOptional,...H_(t)});var Kv=class extends U_{_parse(e){return this._getType(e)===T_.null?P_(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Kv.create=(e,t)=>new Kv({innerType:e,typeName:$v.ZodNullable,...H_(t)});var qv=class extends U_{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===T_.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};qv.create=(e,t)=>new qv({innerType:e,typeName:$v.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...H_(t)});var Jv=class extends U_{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return R_(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new D_(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new D_(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Jv.create=(e,t)=>new Jv({innerType:e,typeName:$v.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...H_(t)});var Yv=class extends U_{_parse(e){if(this._getType(e)!==T_.nan){let t=this._getOrReturnCtx(e);return R(t,{code:L.invalid_type,expected:T_.nan,received:t.parsedType}),M_}return{status:`valid`,value:e.data}}};Yv.create=e=>new Yv({typeName:$v.ZodNaN,...H_(e)});var Xv=class extends U_{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Zv=class e extends U_{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?M_:e.status===`dirty`?(t.dirty(),N_(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?M_:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:$v.ZodPipeline})}},Qv=class extends U_{_parse(e){let t=this._def.innerType._parse(e),n=e=>(L_(e)&&(e.value=Object.freeze(e.value)),e);return R_(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Qv.create=(e,t)=>new Qv({innerType:e,typeName:$v.ZodReadonly,...H_(t)}),kv.lazycreate;var $v;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})($v||={});var ey=mv.create;gv.create,Yv.create,_v.create;var ty=vv.create;yv.create,bv.create,xv.create,Sv.create;var ny=Cv.create;wv.create,Tv.create,Ev.create,Dv.create;var ry=kv.create;kv.strictCreate,Av.create;var iy=Mv.create;Pv.create,Fv.create,pee.create,Iv.create,Lv.create,mee.create,Rv.create;var ay=zv.create,oy=Vv.create;Hv.create,Uv.create,Wv.create,Gv.create,Kv.create,Wv.createWithPreprocess,Zv.create;var sy=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,cy=e=>{if(typeof e!=`string`)throw TypeError(`Invalid argument expected string`);let t=e.match(sy);if(!t)throw Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},ly=e=>e===`*`||e===`x`||e===`X`,uy=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},dy=(e,t)=>typeof e==typeof t?[e,t]:[String(e),String(t)],fy=(e,t)=>{if(ly(e)||ly(t))return 0;let[n,r]=dy(uy(e),uy(t));return n>r?1:n<r?-1:0},py=(e,t)=>{for(let n=0;n<Math.max(e.length,t.length);n++){let r=fy(e[n]||`0`,t[n]||`0`);if(r!==0)return r}return 0},my=(e,t)=>{let n=cy(e),r=cy(t),i=n.pop(),a=r.pop(),o=py(n,r);return o===0?i&&a?py(i.split(`.`),a.split(`.`)):i||a?i?-1:1:0:o},hy=e=>{if(typeof structuredClone==`function`)return structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch{return Array.isArray(e)?[...e]:{...e}}};function gy(){return Zl()}function _y(e){if(Object.freeze(e),typeof e==`object`&&e)for(let t of Object.values(e))typeof t==`object`&&t&&!Object.isFrozen(t)&&_y(t);return e}var vy=512*1024;function yy(e,t,n){let r=0,i=[e,t],a=new WeakSet;for(;i.length>0;){let e=i.pop();if(typeof e==`string`){if(r+=e.length,r>n)return!0}else if(typeof e==`object`&&e){if(a.has(e))continue;if(a.add(e),Array.isArray(e))for(let t=0;t<e.length;t++)i.push(e[t]);else{let t=Object.keys(e);for(let a=0;a<t.length;a++){let o=t[a];if(r+=o.length,r>n)return!0;i.push(e[o])}}}}return!1}async function by(e,t,n,r){let i=typeof process<`u`&&!0,a=i&&!!{}.VITEST_WORKER_ID,o=i&&!!{}.VITEST_WORKER_ID,s=o&&!yy(t,n,vy),c=s?hy(t):t,l=s?hy(n):n,u=!1,d=!1,f;for(let t of e)try{s&&(_y(c),_y(l));let e=await r(t,c,l);if(e===void 0)continue;let n=!1;if(e.messages!==void 0&&e.messages!==c&&(c=hy(e.messages),u=!0,n=!0),e.state!==void 0&&e.state!==l&&(l=hy(e.state),d=!0,n=!0),s&&n&&yy(c,l,vy)&&(s=!1),f=e.stopPropagation,f===!0)break}catch(e){if(o&&e instanceof TypeError){if(a)throw e;console.error(`AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.`,e)}else a||console.error(`Subscriber error:`,e);continue}return{...u?{messages:Object.isFrozen(c)?hy(c):c}:{},...d?{state:Object.isFrozen(l)?hy(l):l}:{},...f===void 0?{}:{stopPropagation:f}}}function xy(e){if(!e)return{enabled:!1,events:!1,lifecycle:!1,verbose:!1};if(e===!0)return{enabled:!0,events:!0,lifecycle:!0,verbose:!0};let t=e.events??!0,n=e.lifecycle??!0,r=e.verbose??!1;return{enabled:t||n,events:t,lifecycle:n,verbose:r}}function Sy(e){if(e instanceof Cy)return e;if(e===!0)return new Cy(xy(!0))}var Cy=class{constructor(e){this.config=e}event(e,t,n,r){this.config.events&&(this.config.verbose?console.debug(`[${e}] ${t}`,typeof n==`string`?n:JSON.stringify(n)):console.debug(`[${e}] ${t}`,r??n))}lifecycle(e,t,n){this.config.lifecycle&&(n?console.debug(`[${e}] ${t}`,n):console.debug(`[${e}] ${t}`))}get eventsEnabled(){return this.config.events}get lifecycleEnabled(){return this.config.lifecycle}get enabled(){return this.config.enabled}};function wy(e){return e.enabled?new Cy(e):void 0}function Ty(e,t,n){if(t){let r=e.find(e=>e.id===t);if(r?.role===`assistant`)return r;r&&console.warn(`TOOL_CALL_START: parentMessageId '${t}' matches a '${r.role}' message, not assistant — falling back to toolCallId`);let i={id:r?n:t,role:`assistant`,toolCalls:[]};return e.push(i),i}let r={id:n,role:`assistant`,toolCalls:[]};return e.push(r),r}var Ey=(e,t,n,r,i)=>{let a=Sy(i),o=hy(n.messages),s=hy(e.state),c={},l=e=>{e.messages!==void 0&&(o=e.messages,c.messages=e.messages),e.state!==void 0&&(s=e.state,c.state=e.state)},u=()=>{let e=hy(c);return c={},e.messages!==void 0||e.state!==void 0?fh(e):zm};return t.pipe(Sh(async t=>{let i=await by(r,o,s,(r,i,a)=>r.onEvent?.({event:t,agent:n,input:e,messages:i,state:a}));if(l(i),i.stopPropagation===!0?a?.event(`APPLY`,`Event dropped:`,t,{type:t.type,reason:`stopPropagation by subscriber`}):a?.event(`APPLY`,`Event applied:`,t,{type:t.type,subscribers:r.length}),i.stopPropagation===!0)return u();switch(t.type){case F.TEXT_MESSAGE_START:{let i=await by(r,o,s,(r,i,a)=>r.onTextMessageStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{messageId:e,role:n=`assistant`,name:r}=t;if(!o.find(t=>t.id===e)){let t={id:e,role:n,content:``,...r!==void 0&&{name:r}};o.push(t),l({messages:o})}}return u()}case F.TEXT_MESSAGE_CONTENT:{let{messageId:i,delta:a}=t,c=o.find(e=>e.id===i);if(!c)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${i}'`),u();let d=await by(r,o,s,(r,i,a)=>r.onTextMessageContentEvent?.({event:t,messages:i,state:a,agent:n,input:e,textMessageBuffer:typeof c.content==`string`?c.content:``}));return l(d),d.stopPropagation!==!0&&(c.content=`${typeof c.content==`string`?c.content:``}${a}`,l({messages:o})),u()}case F.TEXT_MESSAGE_END:{let{messageId:i}=t,a=o.find(e=>e.id===i);return a?(l(await by(r,o,s,(r,i,o)=>r.onTextMessageEndEvent?.({event:t,messages:i,state:o,agent:n,input:e,textMessageBuffer:typeof a.content==`string`?a.content:``}))),await Promise.all(r.map(t=>{t.onNewMessage?.({message:a,messages:o,state:s,agent:n,input:e})})),u()):(console.warn(`TEXT_MESSAGE_END: No message found with ID '${i}'`),u())}case F.TOOL_CALL_START:{let i=await by(r,o,s,(r,i,a)=>r.onToolCallStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{toolCallId:e,toolCallName:n,parentMessageId:r}=t,i=Ty(o,r,e);i.toolCalls??=[],i.toolCalls.push({id:e,type:`function`,function:{name:n,arguments:``}}),l({messages:o})}return u()}case F.TOOL_CALL_ARGS:{let{toolCallId:i,delta:a}=t,c=o.find(e=>e.toolCalls?.some(e=>e.id===i));if(!c)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${i}'`),u();let d=c.toolCalls?.find(e=>e.id===i);if(!d)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${i}'`),u();let f=await by(r,o,s,(r,i,a)=>{let o=d.function.arguments,s=d.function.name,c={};try{c=kh(o)}catch{}return r.onToolCallArgsEvent?.({event:t,messages:i,state:a,agent:n,input:e,toolCallBuffer:o,toolCallName:s,partialToolCallArgs:c})});return l(f),f.stopPropagation!==!0&&(d.function.arguments+=a,l({messages:o})),u()}case F.TOOL_CALL_END:{let{toolCallId:i}=t,a=o.find(e=>e.toolCalls?.some(e=>e.id===i));if(!a)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${i}'`),u();let c=a.toolCalls?.find(e=>e.id===i);return c?(l(await by(r,o,s,(r,i,a)=>{let o=c.function.arguments,s=c.function.name,l={};try{l=JSON.parse(o)}catch{}return r.onToolCallEndEvent?.({event:t,messages:i,state:a,agent:n,input:e,toolCallName:s,toolCallArgs:l})})),await Promise.all(r.map(t=>{t.onNewToolCall?.({toolCall:c,messages:o,state:s,agent:n,input:e})})),u()):(console.warn(`TOOL_CALL_END: No tool call found with ID '${i}'`),u())}case F.TOOL_CALL_RESULT:{let i=await by(r,o,s,(r,i,a)=>r.onToolCallResultEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{messageId:i,toolCallId:a,content:c,role:u}=t,d={id:i,toolCallId:a,role:u||`tool`,content:c},f=o.findIndex(e=>e.role===`assistant`&&e.toolCalls?.some(e=>e.id===a));if(f===-1)o.push(d);else{let e=f+1;for(;e<o.length&&o[e].role===`tool`;)e++;o.splice(e,0,d)}await Promise.all(r.map(t=>{t.onNewMessage?.({message:d,messages:o,state:s,agent:n,input:e})})),l({messages:o})}return u()}case F.STATE_SNAPSHOT:{let i=await by(r,o,s,(r,i,a)=>r.onStateSnapshotEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{snapshot:e}=t;s=e,l({state:s})}return u()}case F.STATE_DELTA:{let i=await by(r,o,s,(r,i,a)=>r.onStateDeltaEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{delta:e}=t;try{s=Ip.applyPatch(s,e,!0,!1).newDocument,l({state:s})}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Failed to apply state patch:\nCurrent state: ${JSON.stringify(s,null,2)}\nPatch operations: ${JSON.stringify(e,null,2)}\nError: ${n}`)}}return u()}case F.MESSAGES_SNAPSHOT:{let i=await by(r,o,s,(r,i,a)=>r.onMessagesSnapshotEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{messages:e}=t,n=new Map(e.map(e=>[e.id,e])),r=e.some(e=>e.role===`reasoning`),i=e=>e.role===`activity`||e.role===`reasoning`&&!r;o=o.filter(e=>i(e)||n.has(e.id)).map(e=>i(e)?e:n.get(e.id));let a=new Set(o.map(e=>e.id));for(let t of e)a.has(t.id)||o.push(t);l({messages:o})}return u()}case F.ACTIVITY_SNAPSHOT:{let i=t,a=o.findIndex(e=>e.id===i.messageId),c=a>=0?o[a]:void 0,d=c?.role===`activity`?c:void 0,f=i.replace??!0,p=await by(r,o,s,(t,r,a)=>t.onActivitySnapshotEvent?.({event:i,messages:r,state:a,agent:n,input:e,activityMessage:d,existingMessage:c}));if(l(p),p.stopPropagation!==!0){let t={id:i.messageId,role:`activity`,activityType:i.activityType,content:hy(i.content)},c;a===-1?(o.push(t),c=t):d?f&&(o[a]={...d,activityType:i.activityType,content:hy(i.content)}):f&&(o[a]=t,c=t),l({messages:o}),c&&await Promise.all(r.map(t=>t.onNewMessage?.({message:c,messages:o,state:s,agent:n,input:e})))}return u()}case F.ACTIVITY_DELTA:{let i=t,a=o.findIndex(e=>e.id===i.messageId);if(a===-1)return u();let c=o[a];if(c.role!==`activity`)return console.warn(`ACTIVITY_DELTA: Message '${i.messageId}' is not an activity message`),u();let d=c,f=await by(r,o,s,(t,r,a)=>t.onActivityDeltaEvent?.({event:i,messages:r,state:a,agent:n,input:e,activityMessage:d}));if(l(f),f.stopPropagation!==!0)try{let e=hy(d.content??{}),t=Ip.applyPatch(e,i.patch??[],!0,!1).newDocument;o[a]={...d,content:hy(t),activityType:i.activityType},l({messages:o})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`Failed to apply activity patch for '${i.messageId}': ${t}`)}return u()}case F.RAW:return l(await by(r,o,s,(r,i,a)=>r.onRawEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case F.CUSTOM:return l(await by(r,o,s,(r,i,a)=>r.onCustomEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case F.RUN_STARTED:{let i=await by(r,o,s,(r,i,a)=>r.onRunStartedEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let e=t;if(e.input?.messages){for(let t of e.input.messages)o.find(e=>e.id===t.id)||o.push(t);l({messages:o})}}return u()}case F.RUN_FINISHED:{let i=t,a=i.outcome?.type===`interrupt`?{event:i,outcome:`interrupt`,interrupts:i.outcome.interrupts}:{event:i,outcome:`success`,result:i.result},c=await by(r,o,s,(t,r,i)=>t.onRunFinishedEvent?.({...a,messages:r,state:i,agent:n,input:e}));return l(c),c.stopPropagation!==!0&&(n.pendingInterrupts=a.outcome===`interrupt`?[...a.interrupts]:[]),u()}case F.RUN_ERROR:return l(await by(r,o,s,(r,i,a)=>r.onRunErrorEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case F.STEP_STARTED:return l(await by(r,o,s,(r,i,a)=>r.onStepStartedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case F.STEP_FINISHED:return l(await by(r,o,s,(r,i,a)=>r.onStepFinishedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case F.TEXT_MESSAGE_CHUNK:throw Error(`TEXT_MESSAGE_CHUNK must be tranformed before being applied`);case F.TOOL_CALL_CHUNK:throw Error(`TOOL_CALL_CHUNK must be tranformed before being applied`);case F.THINKING_START:return u();case F.THINKING_END:return u();case F.THINKING_TEXT_MESSAGE_START:return u();case F.THINKING_TEXT_MESSAGE_CONTENT:return u();case F.THINKING_TEXT_MESSAGE_END:return u();case F.REASONING_START:return l(await by(r,o,s,(r,i,a)=>r.onReasoningStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case F.REASONING_MESSAGE_START:{let i=await by(r,o,s,(r,i,a)=>r.onReasoningMessageStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{messageId:e}=t;if(!o.find(t=>t.id===e)){let t={id:e,role:`reasoning`,content:``};o.push(t),l({messages:o})}}return u()}case F.REASONING_MESSAGE_CONTENT:{let{messageId:i,delta:a}=t,c=o.find(e=>e.id===i);if(!c)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${i}'`),u();let d=await by(r,o,s,(r,i,a)=>r.onReasoningMessageContentEvent?.({event:t,messages:i,state:a,agent:n,input:e,reasoningMessageBuffer:typeof c.content==`string`?c.content:``}));return l(d),d.stopPropagation!==!0&&(c.content=`${typeof c.content==`string`?c.content:``}${a}`,l({messages:o})),u()}case F.REASONING_MESSAGE_END:{let{messageId:i}=t,a=o.find(e=>e.id===i);return a?(l(await by(r,o,s,(r,i,o)=>r.onReasoningMessageEndEvent?.({event:t,messages:i,state:o,agent:n,input:e,reasoningMessageBuffer:typeof a.content==`string`?a.content:``}))),await Promise.all(r.map(t=>{t.onNewMessage?.({message:a,messages:o,state:s,agent:n,input:e})})),u()):(console.warn(`REASONING_MESSAGE_END: No message found with ID '${i}'`),u())}case F.REASONING_MESSAGE_CHUNK:throw Error(`REASONING_MESSAGE_CHUNK must be transformed before being applied`);case F.REASONING_END:return l(await by(r,o,s,(r,i,a)=>r.onReasoningEndEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case F.REASONING_ENCRYPTED_VALUE:{let{subtype:i,entityId:a,encryptedValue:d}=t,f=await by(r,o,s,(r,i,a)=>r.onReasoningEncryptedValueEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(f),f.stopPropagation!==!0){let e=!1;if(i===`tool-call`){for(let t of o)if(t.role===`assistant`&&t.toolCalls){let n=t.toolCalls.find(e=>e.id===a);if(n){n.encryptedValue=d,e=!0;break}}}else{let t=o.find(e=>e.id===a);t?.role!==`activity`&&t&&(t.encryptedValue=d,e=!0)}e&&(c.messages=o)}return u()}}return t.type,u()}),yh(),r.length>0?Ch({}):e=>e)},Dy=e=>t=>{let n=Sy(e),r=new Map,i=new Map,a=!1,o=!1,s=!1,c=new Map,l=!1,u=!1,d=!1,f=()=>{r.clear(),i.clear(),c.clear(),l=!1,u=!1,a=!1,o=!1,d=!0};return t.pipe(vh(e=>{let t=e.type;if(n?.event(`VERIFY`,`Event:`,e,{type:e.type}),o)return ph(()=>new lf(`Cannot send event type '${t}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(a&&t!==F.RUN_ERROR&&t!==F.RUN_STARTED)return ph(()=>new lf(`Cannot send event type '${t}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(!s){if(s=!0,t!==F.RUN_STARTED&&t!==F.RUN_ERROR)return ph(()=>new lf(`First event must be 'RUN_STARTED'`))}else if(t===F.RUN_STARTED){if(d&&!a)return ph(()=>new lf(`Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run.`));a&&f()}switch(t){case F.TEXT_MESSAGE_START:{let t=e.messageId;return r.has(t)?ph(()=>new lf(`Cannot send 'TEXT_MESSAGE_START' event: A text message with ID '${t}' is already in progress. Complete it with 'TEXT_MESSAGE_END' first.`)):(r.set(t,!0),fh(e))}case F.TEXT_MESSAGE_CONTENT:{let t=e.messageId;return r.has(t)?fh(e):ph(()=>new lf(`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${t}'. Start a text message with 'TEXT_MESSAGE_START' first.`))}case F.TEXT_MESSAGE_END:{let t=e.messageId;return r.has(t)?(r.delete(t),fh(e)):ph(()=>new lf(`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${t}'. A 'TEXT_MESSAGE_START' event must be sent first.`))}case F.TOOL_CALL_START:{let t=e.toolCallId;return i.has(t)?ph(()=>new lf(`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${t}' is already in progress. Complete it with 'TOOL_CALL_END' first.`)):(i.set(t,!0),fh(e))}case F.TOOL_CALL_ARGS:{let t=e.toolCallId;return i.has(t)?fh(e):ph(()=>new lf(`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${t}'. Start a tool call with 'TOOL_CALL_START' first.`))}case F.TOOL_CALL_END:{let t=e.toolCallId;return i.has(t)?(i.delete(t),fh(e)):ph(()=>new lf(`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${t}'. A 'TOOL_CALL_START' event must be sent first.`))}case F.STEP_STARTED:{let t=e.stepName;return c.has(t)?ph(()=>new lf(`Step "${t}" is already active for 'STEP_STARTED'`)):(c.set(t,!0),fh(e))}case F.STEP_FINISHED:{let t=e.stepName;return c.has(t)?(c.delete(t),fh(e)):ph(()=>new lf(`Cannot send 'STEP_FINISHED' for step "${t}" that was not started`))}case F.RUN_STARTED:return d=!0,fh(e);case F.RUN_FINISHED:if(c.size>0){let e=Array.from(c.keys()).join(`, `);return ph(()=>new lf(`Cannot send 'RUN_FINISHED' while steps are still active: ${e}`))}if(r.size>0){let e=Array.from(r.keys()).join(`, `);return ph(()=>new lf(`Cannot send 'RUN_FINISHED' while text messages are still active: ${e}`))}if(i.size>0){let e=Array.from(i.keys()).join(`, `);return ph(()=>new lf(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${e}`))}return a=!0,fh(e);case F.RUN_ERROR:return o=!0,fh(e);case F.CUSTOM:return fh(e);case F.THINKING_TEXT_MESSAGE_START:return l?u?ph(()=>new lf(`Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.`)):(u=!0,fh(e)):ph(()=>new lf(`Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking step is not in progress. Create one with 'THINKING_START' first.`));case F.THINKING_TEXT_MESSAGE_CONTENT:return u?fh(e):ph(()=>new lf(`Cannot send 'THINKING_TEXT_MESSAGE_CONTENT' event: No active thinking message found. Start a message with 'THINKING_TEXT_MESSAGE_START' first.`));case F.THINKING_TEXT_MESSAGE_END:return u?(u=!1,fh(e)):ph(()=>new lf(`Cannot send 'THINKING_TEXT_MESSAGE_END' event: No active thinking message found. A 'THINKING_TEXT_MESSAGE_START' event must be sent first.`));case F.THINKING_START:return l?ph(()=>new lf(`Cannot send 'THINKING_START' event: A thinking step is already in progress. End it with 'THINKING_END' first.`)):(l=!0,fh(e));case F.THINKING_END:return l?(l=!1,fh(e)):ph(()=>new lf(`Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first.`));default:return fh(e)}}))},Oy=function(e){return e.HEADERS=`headers`,e.DATA=`data`,e}({}),ky=e=>bh(()=>dh(e())).pipe(Th(e=>{if(!e.ok){let t=e.headers.get(`content-type`)||``;return dh(e.text()).pipe(vh(n=>{let r=n;if(t.includes(`application/json`))try{r=JSON.parse(n)}catch{}let i=Error(`HTTP ${e.status}: ${typeof r==`string`?r:JSON.stringify(r)}`);return i.status=e.status,i.payload=r,ph(()=>i)}))}let t={type:Oy.HEADERS,status:e.status,headers:e.headers},n=e.body?.getReader();return n?new Em(e=>(e.next(t),(async()=>{try{for(;;){let{done:t,value:r}=await n.read();if(t)break;let i={type:Oy.DATA,data:r};e.next(i)}e.complete()}catch(t){e.error(t)}})(),()=>{n.cancel().catch(e=>{if(e?.name!==`AbortError`)throw e})})):ph(()=>Error(`Failed to getReader() from response`))})),Ay=(e,t)=>{let n=Sy(t),r=new Fm,i=new TextDecoder(`utf-8`,{fatal:!1}),a=``;e.subscribe({next:e=>{if(e.type!==Oy.HEADERS&&e.type===Oy.DATA&&e.data){let t=i.decode(e.data,{stream:!0});a+=t;let n=a.split(/\n\n/);a=n.pop()||``;for(let e of n)o(e)}},error:e=>r.error(e),complete:()=>{a&&(a+=i.decode(),o(a)),r.complete()}});function o(e){let t=e.split(`
|
|
82
|
+
`),i=[];for(let e of t)e.startsWith(`data:`)&&i.push(e.slice(5).replace(/^ /,``));if(i.length>0)try{let e=i.join(`
|
|
83
|
+
`),t=JSON.parse(e);n?.event(`SSE`,`Event received:`,t,{type:t.type}),r.next(t)}catch(e){r.error(e)}}return r.asObservable()},jy=e=>{let t=new Fm,n=new Uint8Array;e.subscribe({next:e=>{if(e.type!==Oy.HEADERS&&e.type===Oy.DATA&&e.data){let t=new Uint8Array(n.length+e.data.length);t.set(n,0),t.set(e.data,n.length),n=t,r()}},error:e=>t.error(e),complete:()=>{if(n.length>0)try{r()}catch{console.warn(`Incomplete or invalid protocol buffer data at stream end`)}t.complete()}});function r(){for(;n.length>=4;){let e=4+new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(n.length<e)break;try{let r=uee(n.slice(4,e));t.next(r),n=n.slice(e)}catch(e){let n=e instanceof Error?e.message:String(e);t.error(Error(`Failed to decode protocol buffer message: ${n}`));return}}}return t.asObservable()},My=(e,t)=>{let n=Sy(t),r=new Fm,i=new Rm,a=!1;return e.subscribe({next:e=>{if(i.next(e),e.type===Oy.HEADERS&&!a){a=!0;let t=e.headers.get(`content-type`);n?.lifecycle(`HTTP`,`Stream format detected:`,{contentType:t,parser:t===`application/vnd.ag-ui.event+proto`?`protobuf`:`sse`}),t===`application/vnd.ag-ui.event+proto`?jy(i).subscribe({next:e=>r.next(e),error:e=>r.error(e),complete:()=>r.complete()}):Ay(i,n).subscribe({next:e=>{try{let t=ep.parse(e);n?.event(`HTTP`,`Event validated:`,t,{type:t.type,valid:!0}),r.next(t)}catch(t){n?.event(`HTTP`,`Event invalid:`,{json:e,error:String(t)}),r.error(t)}},error:e=>{if(e?.name===`AbortError`){r.next({type:F.RUN_ERROR,message:e.message||`Request aborted`,code:`abort`,rawEvent:e}),r.complete();return}return r.error(e)},complete:()=>r.complete()})}else a||r.error(Error(`No headers event received before data events`))},error:e=>{i.error(e),r.error(e)},complete:()=>{i.complete()}}),r.asObservable()},Ny=oy([`TextMessageStart`,`TextMessageContent`,`TextMessageEnd`,`ActionExecutionStart`,`ActionExecutionArgs`,`ActionExecutionEnd`,`ActionExecutionResult`,`AgentStateMessage`,`MetaEvent`,`RunStarted`,`RunFinished`,`RunError`,`NodeStarted`,`NodeFinished`]),Py=oy([`LangGraphInterruptEvent`,`PredictState`,`Exit`]);iy(`type`,[ry({type:ay(Ny.enum.TextMessageStart),messageId:ey(),parentMessageId:ey().optional(),role:ey().optional()}),ry({type:ay(Ny.enum.TextMessageContent),messageId:ey(),content:ey()}),ry({type:ay(Ny.enum.TextMessageEnd),messageId:ey()}),ry({type:ay(Ny.enum.ActionExecutionStart),actionExecutionId:ey(),actionName:ey(),parentMessageId:ey().optional()}),ry({type:ay(Ny.enum.ActionExecutionArgs),actionExecutionId:ey(),args:ey()}),ry({type:ay(Ny.enum.ActionExecutionEnd),actionExecutionId:ey()}),ry({type:ay(Ny.enum.ActionExecutionResult),actionName:ey(),actionExecutionId:ey(),result:ey()}),ry({type:ay(Ny.enum.AgentStateMessage),threadId:ey(),agentName:ey(),nodeName:ey(),runId:ey(),active:ty(),role:ey(),state:ey(),running:ty()}),ry({type:ay(Ny.enum.MetaEvent),name:Py,value:ny()}),ry({type:ay(Ny.enum.RunError),message:ey(),code:ey().optional()})]),ry({id:ey(),role:ey(),content:ey(),parentMessageId:ey().optional()}),ry({id:ey(),name:ey(),arguments:ny(),parentMessageId:ey().optional()}),ry({id:ey(),result:ny(),actionExecutionId:ey(),actionName:ey()});var Fy=e=>{if(typeof e==`string`)return e;if(!Array.isArray(e))return;let t=e.filter(e=>e.type===`text`).map(e=>e.text).filter(e=>e.length>0);if(t.length!==0)return t.join(`
|
|
84
|
+
`)},Iy=(e,t,n)=>r=>{let i={},a=!0,o=!0,s=``,c=null,l=null,u=[],d={},f=e=>{typeof e==`object`&&e&&(`messages`in e&&delete e.messages,i=e)};return r.pipe(vh(r=>{switch(r.type){case F.TEXT_MESSAGE_START:{let e=r;return[{type:Ny.enum.TextMessageStart,messageId:e.messageId,role:e.role}]}case F.TEXT_MESSAGE_CONTENT:{let e=r;return[{type:Ny.enum.TextMessageContent,messageId:e.messageId,content:e.delta}]}case F.TEXT_MESSAGE_END:{let e=r;return[{type:Ny.enum.TextMessageEnd,messageId:e.messageId}]}case F.TOOL_CALL_START:{let e=r;return u.push({id:e.toolCallId,type:`function`,function:{name:e.toolCallName,arguments:``}}),o=!0,d[e.toolCallId]=e.toolCallName,[{type:Ny.enum.ActionExecutionStart,actionExecutionId:e.toolCallId,actionName:e.toolCallName,parentMessageId:e.parentMessageId}]}case F.TOOL_CALL_ARGS:{let c=r,d=u.find(e=>e.id===c.toolCallId);if(!d)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${c.toolCallId}'`),[];d.function.arguments+=c.delta;let p=!1;if(l){let e=l.find(e=>e.tool==d.function.name);if(e)try{let t=JSON.parse(kh(d.function.arguments));e.tool_argument&&e.tool_argument in t?(f({...i,[e.state_key]:t[e.tool_argument]}),p=!0):e.tool_argument||(f({...i,[e.state_key]:t}),p=!0)}catch{}}return[{type:Ny.enum.ActionExecutionArgs,actionExecutionId:c.toolCallId,args:c.delta},...p?[{type:Ny.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]:[]]}case F.TOOL_CALL_END:{let e=r;return[{type:Ny.enum.ActionExecutionEnd,actionExecutionId:e.toolCallId}]}case F.TOOL_CALL_RESULT:{let e=r;return[{type:Ny.enum.ActionExecutionResult,actionExecutionId:e.toolCallId,result:e.content,actionName:d[e.toolCallId]||`unknown`}]}case F.RAW:return[];case F.CUSTOM:{let e=r;switch(e.name){case`Exit`:a=!1;break;case`PredictState`:l=e.value;break}return[{type:Ny.enum.MetaEvent,name:e.name,value:e.value}]}case F.STATE_SNAPSHOT:return f(r.snapshot),[{type:Ny.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}];case F.STATE_DELTA:{let c=r,l=Ip.applyPatch(i,c.delta,!0,!1);return l?(f(l.newDocument),[{type:Ny.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]):[]}case F.MESSAGES_SNAPSHOT:return c=r.messages,[{type:Ny.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...c?{messages:c}:{}}),active:!0}];case F.RUN_STARTED:return[];case F.RUN_FINISHED:return c&&(i.messages=c),Object.keys(i).length===0?[]:[{type:Ny.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...c?{messages:Ly(c)}:{}}),active:!1}];case F.RUN_ERROR:{let e=r;return[{type:Ny.enum.RunError,message:e.message,code:e.code}]}case F.STEP_STARTED:return s=r.stepName,u=[],l=null,[{type:Ny.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!0}];case F.STEP_FINISHED:return u=[],l=null,[{type:Ny.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!1}];default:return[]}}))};function Ly(e){let t=[];for(let n of e)if(n.role===`assistant`||n.role===`user`||n.role===`system`){let e=Fy(n.content);if(e){let r={id:n.id,role:n.role,content:e};t.push(r)}if(n.role===`assistant`&&n.toolCalls&&n.toolCalls.length>0)for(let e of n.toolCalls){let r={id:e.id,name:e.function.name,arguments:JSON.parse(e.function.arguments),parentMessageId:n.id};t.push(r)}}else if(n.role===`tool`){let r=`unknown`;for(let t of e)if(t.role===`assistant`&&t.toolCalls?.length){for(let e of t.toolCalls)if(e.id===n.toolCallId){r=e.function.name;break}}let i={id:n.id,result:n.content,actionExecutionId:n.toolCallId,actionName:r};t.push(i)}return t}var Ry=e=>t=>{let n=Sy(e),r,i,a,o,s=()=>{if(!r||o!==`text`)throw Error(`No text message to close`);let e={type:F.TEXT_MESSAGE_END,messageId:r.messageId};return o=void 0,r=void 0,n?.event(`TRANSFORM`,`TEXT_MESSAGE_END`,e,{messageId:e.messageId}),e},c=()=>{if(!i||o!==`tool`)throw Error(`No tool call to close`);let e={type:F.TOOL_CALL_END,toolCallId:i.toolCallId};return o=void 0,i=void 0,n?.event(`TRANSFORM`,`TOOL_CALL_END`,e,{toolCallId:e.toolCallId}),e},l=()=>{if(!a||o!==`reasoning`)throw Error(`No reasoning message to close`);let e={type:F.REASONING_MESSAGE_END,messageId:a.messageId};return o=void 0,a=void 0,n?.event(`TRANSFORM`,`REASONING_MESSAGE_END`,e,{messageId:e.messageId}),e},u=()=>o===`text`?[s()]:o===`tool`?[c()]:o===`reasoning`?[l()]:[];return t.pipe(vh(e=>{switch(e.type){case F.TEXT_MESSAGE_START:case F.TEXT_MESSAGE_CONTENT:case F.TEXT_MESSAGE_END:case F.TOOL_CALL_START:case F.TOOL_CALL_ARGS:case F.TOOL_CALL_END:case F.TOOL_CALL_RESULT:case F.STATE_SNAPSHOT:case F.STATE_DELTA:case F.MESSAGES_SNAPSHOT:case F.CUSTOM:case F.RUN_STARTED:case F.RUN_FINISHED:case F.RUN_ERROR:case F.STEP_STARTED:case F.STEP_FINISHED:case F.THINKING_START:case F.THINKING_END:case F.THINKING_TEXT_MESSAGE_START:case F.THINKING_TEXT_MESSAGE_CONTENT:case F.THINKING_TEXT_MESSAGE_END:case F.REASONING_START:case F.REASONING_MESSAGE_START:case F.REASONING_MESSAGE_CONTENT:case F.REASONING_MESSAGE_END:case F.REASONING_END:return[...u(),e];case F.RAW:case F.ACTIVITY_SNAPSHOT:case F.ACTIVITY_DELTA:case F.REASONING_ENCRYPTED_VALUE:return[e];case F.TEXT_MESSAGE_CHUNK:let t=e,s=[];if((o!==`text`||t.messageId!==void 0&&t.messageId!==r?.messageId)&&s.push(...u()),o!==`text`){if(t.messageId===void 0)throw Error(`First TEXT_MESSAGE_CHUNK must have a messageId`);r={messageId:t.messageId,name:t.name},o=`text`;let e={type:F.TEXT_MESSAGE_START,messageId:t.messageId,role:t.role||`assistant`,...t.name!==void 0&&{name:t.name}};s.push(e),n?.event(`TRANSFORM`,`TEXT_MESSAGE_START`,e,{messageId:t.messageId})}if(t.delta!==void 0){let e={type:F.TEXT_MESSAGE_CONTENT,messageId:r.messageId,delta:t.delta};s.push(e),n?.event(`TRANSFORM`,`TEXT_MESSAGE_CONTENT`,e,{messageId:r.messageId})}return s;case F.TOOL_CALL_CHUNK:let c=e,l=[];if((o!==`tool`||c.toolCallId!==void 0&&c.toolCallId!==i?.toolCallId)&&l.push(...u()),o!==`tool`){if(c.toolCallId===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallId`);if(c.toolCallName===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallName`);i={toolCallId:c.toolCallId,toolCallName:c.toolCallName,parentMessageId:c.parentMessageId},o=`tool`;let e={type:F.TOOL_CALL_START,toolCallId:c.toolCallId,toolCallName:c.toolCallName,parentMessageId:c.parentMessageId};l.push(e),n?.event(`TRANSFORM`,`TOOL_CALL_START`,e,{toolCallId:c.toolCallId,toolCallName:c.toolCallName})}if(c.delta!==void 0){let e={type:F.TOOL_CALL_ARGS,toolCallId:i.toolCallId,delta:c.delta};l.push(e),n?.event(`TRANSFORM`,`TOOL_CALL_ARGS`,e,{toolCallId:i.toolCallId})}return l;case F.REASONING_MESSAGE_CHUNK:let d=e,f=[];if((o!==`reasoning`||d.messageId&&d.messageId!==a?.messageId)&&f.push(...u()),o!==`reasoning`){if(d.messageId===void 0)throw Error(`First REASONING_MESSAGE_CHUNK must have a messageId`);a={messageId:d.messageId},o=`reasoning`;let e={type:F.REASONING_MESSAGE_START,messageId:d.messageId};f.push(e),n?.event(`TRANSFORM`,`REASONING_MESSAGE_START`,e,{messageId:d.messageId})}if(d.delta!==void 0){let e={type:F.REASONING_MESSAGE_CONTENT,messageId:a.messageId,delta:d.delta};f.push(e),n?.event(`TRANSFORM`,`REASONING_MESSAGE_CONTENT`,e,{messageId:a.messageId})}return f}return e.type,[]}),wh(()=>{u()}))};function zy(e,t=new Date){return e.expiresAt===void 0?!1:new Date(e.expiresAt)<=t}function By(e,t){let n=new Set(e.map(e=>e.id)),r=new Set(Object.keys(t)),i=[...n].filter(e=>!r.has(e));if(i.length>0)throw Error(`buildResumeArray: missing responses for open interrupts: ${i.join(`, `)}`);let a=[...r].filter(e=>!n.has(e));if(a.length>0)throw Error(`buildResumeArray: responses reference unknown interrupt ids: ${a.join(`, `)}`);return e.map(e=>{let n=t[e.id];if(n.status===`resolved`){let t={interruptId:e.id,status:`resolved`};return n.payload!==void 0&&(t.payload=n.payload),t}return{interruptId:e.id,status:`cancelled`}})}var Vy=class{runNext(e,t){return t.run(e).pipe(Ry(!1))}runNextWithState(e,t){let n=hy(e.messages||[]),r=hy(e.state||{}),i=new Rm;return Ey(e,i,t,[]).subscribe(e=>{e.messages!==void 0&&(n=e.messages),e.state!==void 0&&(r=e.state)}),this.runNext(e,t).pipe(Sh(async e=>(i.next(e),await new Promise(e=>setTimeout(e,0)),{event:e,messages:hy(n),state:hy(r)})))}},Hy=class extends Vy{constructor(e){super(),this.fn=e}run(e,t){return this.fn(e,t)}};function Uy(e){let t=e.content;if(Array.isArray(t)){let n=t.filter(e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``);return{...e,content:n}}return typeof t==`string`?e:{...e,content:``}}var Wy=class extends Vy{run(e,t){let{parentRunId:n,...r}=e,i={...r,messages:r.messages.map(Uy)};return this.runNext(i,t)}},Gy=`THINKING_START`,Ky=`THINKING_END`,qy=`THINKING_TEXT_MESSAGE_START`,Jy=`THINKING_TEXT_MESSAGE_CONTENT`,Yy=`THINKING_TEXT_MESSAGE_END`,Xy=class extends Vy{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null}warnAboutTransformation(e,t){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is converting ${e} to ${t}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.runNext(e,t).pipe(gh(e=>this.transformEvent(e)))}transformEvent(e){switch(e.type){case Gy:{this.currentReasoningId=gy();let{title:t,...n}=e;return this.warnAboutTransformation(Gy,F.REASONING_START),{...n,type:F.REASONING_START,messageId:this.currentReasoningId}}case qy:return this.currentMessageId=gy(),this.warnAboutTransformation(qy,F.REASONING_MESSAGE_START),{...e,type:F.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:`assistant`};case Jy:{let{delta:t,...n}=e;return this.warnAboutTransformation(Jy,F.REASONING_MESSAGE_CONTENT),{...n,type:F.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??gy(),delta:t}}case Yy:{let t=this.currentMessageId??gy();return this.warnAboutTransformation(Yy,F.REASONING_MESSAGE_END),{...e,type:F.REASONING_MESSAGE_END,messageId:t}}case Ky:{let t=this.currentReasoningId??gy();return this.warnAboutTransformation(Ky,F.REASONING_END),{...e,type:F.REASONING_END,messageId:t}}default:return e}}};function Zy(e){return e.startsWith(`image/`)?`image`:e.startsWith(`audio/`)?`audio`:e.startsWith(`video/`)?`video`:`document`}function Qy(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`binary`&&`mimeType`in e&&typeof e.mimeType==`string`}function $y(e){let t=Zy(e.mimeType);return e.data?{type:t,source:{type:`data`,value:e.data,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:e.url?{type:t,source:{type:`url`,value:e.url,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:e}function eb(e){let t=e.content;if(!Array.isArray(t))return e;let n=t.map(e=>Qy(e)?$y(e):e);return{...e,content:n}}var tb=class extends Vy{run(e,t){let n={...e,messages:e.messages.map(eb)};return this.runNext(n,t)}},nb=`0.0.57`,rb=class{get maxVersion(){return nb}get debug(){return this._debug}set debug(e){this._debug=xy(e),this._debugLogger=wy(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(e){typeof e==`boolean`?this._debugLogger=e?wy(xy(!0)):void 0:this._debugLogger=e}constructor({agentId:e,description:t,threadId:n,initialMessages:r,initialState:i,debug:a}={}){this.subscribers=[],this.isRunning=!1,this.pendingInterrupts=[],this.middlewares=[],this.agentId=e,this.description=t??``,this.threadId=n??Zl(),this.messages=hy(r??[]),this.state=hy(i??{}),this._debug=xy(a),this._debugLogger=wy(this._debug),my(this.maxVersion,`0.0.39`)<=0&&this.middlewares.unshift(new Wy),my(this.maxVersion,`0.0.45`)<=0&&this.middlewares.unshift(new Xy),my(this.maxVersion,`0.0.47`)<=0&&this.middlewares.unshift(new tb)}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(t=>t!==e)}}}use(...e){let t=e.map(e=>typeof e==`function`?new Hy(e):e);return this.middlewares.push(...t),this}async runAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??Zl();let n=this.prepareRunAgentInput(e);this.debugLogger?.lifecycle(`LIFECYCLE`,`Run started:`,{agentId:this.agentId,threadId:this.threadId});let r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunFinishedEvent:e=>{e.outcome===`success`&&(r=e.result)}},...this.subscribers,t??{}];await this.onInitialize(n,a),this.activeRunDetach$=new Fm;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await hh(wm(()=>this.middlewares.length===0?this.run(n):this.middlewares.reduceRight((e,t)=>({run:n=>t.run(n,e),get messages(){return e.messages},get state(){return e.state}}),this).run(n),Ry(this.debugLogger),Dy(this.debugLogger),e=>e.pipe(Eh(this.activeRunDetach$)),e=>this.apply(n,e,a),e=>this.processApplyEvents(n,e,a),xh(e=>(this.debugLogger?.lifecycle(`LIFECYCLE`,`Run errored:`,{agentId:this.agentId,error:e instanceof Error?e.message:String(e)}),this.isRunning=!1,this.onError(n,e,a))),wh(()=>{this.debugLogger?.lifecycle(`LIFECYCLE`,`Run finished:`,{agentId:this.agentId,threadId:this.threadId}),this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(fh(null)));let s=hy(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}connect(e){throw new uf}async connectAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??Zl();let n=this.prepareRunAgentInput(e),r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunFinishedEvent:e=>{e.outcome===`success`&&(r=e.result)}},...this.subscribers,t??{}];await this.onInitialize(n,a),this.activeRunDetach$=new Fm;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await hh(wm(()=>bh(()=>this.connect(n)),Ry(this.debugLogger),Dy(this.debugLogger),e=>e.pipe(Eh(this.activeRunDetach$)),e=>this.apply(n,e,a),e=>this.processApplyEvents(n,e,a),xh(e=>(this.isRunning=!1,e instanceof uf?zm:this.onError(n,e,a))),wh(()=>{this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(fh(null)),{defaultValue:void 0});let s=hy(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}abortRun(){}async detachActiveRun(){if(!this.activeRunDetach$)return;let e=this.activeRunCompletionPromise??Promise.resolve();this.activeRunDetach$.next(),this.activeRunDetach$?.complete(),await e}apply(e,t,n){return Ey(e,t,this,n,this.debugLogger)}processApplyEvents(e,t,n){return t.pipe(Dh(t=>{t.messages&&(this.messages=t.messages,n.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),t.state&&(this.state=t.state,n.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))}))}prepareRunAgentInput(e){let t=hy(this.messages).filter(e=>e.role!==`activity`);return{threadId:this.threadId,runId:e?.runId||Zl(),tools:hy(e?.tools??[]),context:hy(e?.context??[]),forwardedProps:hy(e?.forwardedProps??{}),state:hy(this.state),messages:t,...e?.resume===void 0?{}:{resume:hy(e.resume)}}}async onInitialize(e,t){if(this.pendingInterrupts.length>0){let t=new Set((e.resume??[]).map(e=>e.interruptId)),n=this.pendingInterrupts.map(e=>e.id).filter(e=>!t.has(e));if(n.length>0)throw new lf(`Thread has ${n.length} pending interrupt(s) not addressed by resume: ${n.join(`, `)}`);for(let e of this.pendingInterrupts)if(zy(e))throw new lf(`Interrupt ${e.id} expired at ${e.expiresAt}`)}let n=await by(t,this.messages,this.state,(t,n,r)=>t.onRunInitialized?.({messages:n,state:r,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages&&(this.messages=n.messages,e.messages=n.messages,t.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state&&(this.state=n.state,e.state=n.state,t.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})})))}onError(e,t,n){return dh(by(n,this.messages,this.state,(n,r,i)=>n.onRunFailed?.({error:t,messages:r,state:i,agent:this,input:e}))).pipe(gh(r=>{let i=r;if((i.messages!==void 0||i.state!==void 0)&&(i.messages!==void 0&&(this.messages=i.messages,n.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),i.state!==void 0&&(this.state=i.state,n.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))),i.stopPropagation!==!0){let e=String(t);if(!(t.name===`AbortError`||t.message===`Fetch is aborted`||t.message===`signal is aborted without reason`||t.message===`component unmounted`||e===`component unmounted`))throw console.error(`Agent execution failed:`,t),t}return{}}))}async onFinalize(e,t){let n=await by(t,this.messages,this.state,(t,n,r)=>t.onRunFinalized?.({messages:n,state:r,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages!==void 0&&(this.messages=n.messages,t.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state!==void 0&&(this.state=n.state,t.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})})))}clone(){let e=Object.create(Object.getPrototypeOf(this));return e.agentId=this.agentId,e.description=this.description,e.threadId=this.threadId,e.messages=hy(this.messages),e.state=hy(this.state),e._debug=this._debug,e._debugLogger=this._debugLogger,e.isRunning=this.isRunning,e.subscribers=[...this.subscribers],e.middlewares=[...this.middlewares],e.pendingInterrupts=hy(this.pendingInterrupts),e}addMessage(e){this.messages.push(e),(async()=>{for(let t of this.subscribers)await t.onNewMessage?.({message:e,messages:this.messages,state:this.state,agent:this});if(e.role===`assistant`&&e.toolCalls)for(let t of e.toolCalls)for(let e of this.subscribers)await e.onNewToolCall?.({toolCall:t,messages:this.messages,state:this.state,agent:this});for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}addMessages(e){this.messages.push(...e),(async()=>{for(let t of e){for(let e of this.subscribers)await e.onNewMessage?.({message:t,messages:this.messages,state:this.state,agent:this});if(t.role===`assistant`&&t.toolCalls)for(let e of t.toolCalls)for(let t of this.subscribers)await t.onNewToolCall?.({toolCall:e,messages:this.messages,state:this.state,agent:this})}for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setMessages(e){this.messages=hy(e),(async()=>{for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(e){this.state=hy(e),(async()=>{for(let e of this.subscribers)await e.onStateChanged?.({messages:this.messages,state:this.state,agent:this})})()}legacy_to_be_removed_runAgentBridged(e){this.agentId=this.agentId??Zl();let t=this.prepareRunAgentInput(e);return(this.middlewares.length===0?this.run(t):this.middlewares.reduceRight((e,t)=>({run:n=>t.run(n,e),get messages(){return e.messages},get state(){return e.state}}),this).run(t)).pipe(Ry(this.debugLogger),Dy(this.debugLogger),Iy(this.threadId,t.runId,this.agentId),e=>e.pipe(gh(e=>(this.debugLogger?.event(`LEGACY`,`Event:`,e,{type:e.type}),e))))}},ib=class extends rb{requestInit(e){return{method:`POST`,headers:{...this.headers,"Content-Type":`application/json`,Accept:`text/event-stream`},body:JSON.stringify(e),signal:this.abortController.signal}}runAgent(e,t){return this.abortController=e?.abortController??new AbortController,super.runAgent(e,t)}abortRun(){this.abortController.abort(),super.abortRun()}constructor(e){super(e),this.abortController=new AbortController,this.url=e.url,this.headers=hy(e.headers??{}),this.fetch=e.fetch??((e,t)=>fetch(e,t))}run(e){return My(ky(()=>this.fetch(this.url,this.requestInit(e))),this.debugLogger)}clone(){let e=super.clone();e.url=this.url,e.headers=hy(this.headers??{}),e.fetch=this.fetch;let t=new AbortController,n=this.abortController.signal;return n.aborted&&t.abort(n.reason),e.abortController=t,e}},ab;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(ab||={});var ob;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(ob||={});var sb=ab.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),cb=e=>{switch(typeof e){case`undefined`:return sb.undefined;case`string`:return sb.string;case`number`:return Number.isNaN(e)?sb.nan:sb.number;case`boolean`:return sb.boolean;case`function`:return sb.function;case`bigint`:return sb.bigint;case`symbol`:return sb.symbol;case`object`:return Array.isArray(e)?sb.array:e===null?sb.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?sb.promise:typeof Map<`u`&&e instanceof Map?sb.map:typeof Set<`u`&&e instanceof Set?sb.set:typeof Date<`u`&&e instanceof Date?sb.date:sb.object;default:return sb.unknown}},z=ab.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),lb=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ab.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};lb.create=e=>new lb(e);var ub=(e,t)=>{let n;switch(e.code){case z.invalid_type:n=e.received===sb.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case z.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,ab.jsonStringifyReplacer)}`;break;case z.unrecognized_keys:n=`Unrecognized key(s) in object: ${ab.joinValues(e.keys,`, `)}`;break;case z.invalid_union:n=`Invalid input`;break;case z.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${ab.joinValues(e.options)}`;break;case z.invalid_enum_value:n=`Invalid enum value. Expected ${ab.joinValues(e.options)}, received '${e.received}'`;break;case z.invalid_arguments:n=`Invalid function arguments`;break;case z.invalid_return_type:n=`Invalid function return type`;break;case z.invalid_date:n=`Invalid date`;break;case z.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:ab.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case z.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case z.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case z.custom:n=`Invalid input`;break;case z.invalid_intersection_types:n=`Intersection results could not be merged`;break;case z.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case z.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,ab.assertNever(e)}return{message:n}},db=ub;function fb(){return db}var pb=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function B(e,t){let n=fb(),r=pb({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ub?void 0:ub].filter(e=>!!e)});e.common.issues.push(r)}var mb=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return hb;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return hb;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},hb=Object.freeze({status:`aborted`}),gb=e=>({status:`dirty`,value:e}),_b=e=>({status:`valid`,value:e}),vb=e=>e.status===`aborted`,yb=e=>e.status===`dirty`,bb=e=>e.status===`valid`,xb=e=>typeof Promise<`u`&&e instanceof Promise,Sb;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(Sb||={});var Cb=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},wb=(e,t)=>{if(bb(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new lb(e.common.issues);return this._error=t,this._error}}};function Tb(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var Eb=class{get description(){return this._def.description}_getType(e){return cb(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:cb(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new mb,ctx:{common:e.parent.common,data:e.data,parsedType:cb(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(xb(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:cb(e)};return wb(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:cb(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return bb(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>bb(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:cb(e)},r=this._parse({data:e,path:n.path,parent:n});return wb(n,await(xb(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:z.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new sx({schema:this,typeName:gx.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return cx.create(this,this._def)}nullable(){return lx.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Hb.create(this)}promise(){return ox.create(this,this._def)}or(e){return Gb.create([this,e],this._def)}and(e){return Yb.create(this,e,this._def)}transform(e){return new sx({...Tb(this._def),schema:this,typeName:gx.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new ux({...Tb(this._def),innerType:this,defaultValue:t,typeName:gx.ZodDefault})}brand(){return new px({typeName:gx.ZodBranded,type:this,...Tb(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new dx({...Tb(this._def),innerType:this,catchValue:t,typeName:gx.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return mx.create(this,e)}readonly(){return hx.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},hee=/^c[^\s-]{8,}$/i,gee=/^[0-9a-z]+$/,_ee=/^[0-9A-HJKMNP-TV-Z]{26}$/i,vee=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,yee=/^[a-z0-9_-]{21}$/i,bee=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,xee=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,See=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Cee=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,Db,wee=/^(?:(?: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])$/,Tee=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Eee=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Dee=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Oee=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,kee=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ob=`((\\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])))`,Aee=RegExp(`^${Ob}$`);function kb(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function jee(e){return RegExp(`^${kb(e)}$`)}function Mee(e){let t=`${Ob}T${kb(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Nee(e,t){return!!((t===`v4`||!t)&&wee.test(e)||(t===`v6`||!t)&&Eee.test(e))}function Pee(e,t){if(!bee.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function Fee(e,t){return!!((t===`v4`||!t)&&Tee.test(e)||(t===`v6`||!t)&&Dee.test(e))}var Ab=class e extends Eb{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==sb.string){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:sb.string,received:t.parsedType}),hb}let t=new mb,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:z.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:z.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?B(n,{code:z.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&B(n,{code:z.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)See.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`email`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)Db||=new RegExp(Cee,`u`),Db.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`emoji`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)vee.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`uuid`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)yee.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`nanoid`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)hee.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`cuid`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)gee.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`cuid2`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)_ee.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`ulid`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),B(n,{validation:`url`,code:z.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`regex`,code:z.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Mee(r).test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Aee.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?jee(r).test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?xee.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`duration`,code:z.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?Nee(e.data,r.version)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`ip`,code:z.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?Pee(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`jwt`,code:z.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?Fee(e.data,r.version)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`cidr`,code:z.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?Oee.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`base64`,code:z.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?kee.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`base64url`,code:z.invalid_string,message:r.message}),t.dirty()):ab.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:z.invalid_string,...Sb.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...Sb.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...Sb.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...Sb.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...Sb.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...Sb.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...Sb.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...Sb.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...Sb.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...Sb.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...Sb.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...Sb.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...Sb.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...Sb.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Sb.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...Sb.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...Sb.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...Sb.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...Sb.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...Sb.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...Sb.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...Sb.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...Sb.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...Sb.errToObj(t)})}nonempty(e){return this.min(1,Sb.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Ab.create=e=>new Ab({checks:[],typeName:gx.ZodString,coerce:e?.coerce??!1,...Tb(e)});function Iee(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var jb=class e extends Eb{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==sb.number){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:sb.number,received:t.parsedType}),hb}let t,n=new mb;for(let r of this._def.checks)r.kind===`int`?ab.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),B(t,{code:z.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Iee(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),B(t,{code:z.not_finite,message:r.message}),n.dirty()):ab.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,Sb.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Sb.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Sb.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Sb.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Sb.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:Sb.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:Sb.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:Sb.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:Sb.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:Sb.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Sb.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:Sb.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:Sb.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:Sb.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&ab.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};jb.create=e=>new jb({checks:[],typeName:gx.ZodNumber,coerce:e?.coerce||!1,...Tb(e)});var Mb=class e extends Eb{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==sb.bigint)return this._getInvalidInput(e);let t,n=new mb;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):ab.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:sb.bigint,received:t.parsedType}),hb}gte(e,t){return this.setLimit(`min`,e,!0,Sb.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Sb.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Sb.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Sb.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Sb.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:Sb.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:Sb.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:Sb.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:Sb.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Sb.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Mb.create=e=>new Mb({checks:[],typeName:gx.ZodBigInt,coerce:e?.coerce??!1,...Tb(e)});var Nb=class extends Eb{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==sb.boolean){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:sb.boolean,received:t.parsedType}),hb}return _b(e.data)}};Nb.create=e=>new Nb({typeName:gx.ZodBoolean,coerce:e?.coerce||!1,...Tb(e)});var Pb=class e extends Eb{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==sb.date){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:sb.date,received:t.parsedType}),hb}if(Number.isNaN(e.data.getTime()))return B(this._getOrReturnCtx(e),{code:z.invalid_date}),hb;let t=new mb,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:z.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:z.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):ab.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:Sb.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:Sb.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Pb.create=e=>new Pb({checks:[],coerce:e?.coerce||!1,typeName:gx.ZodDate,...Tb(e)});var Fb=class extends Eb{_parse(e){if(this._getType(e)!==sb.symbol){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:sb.symbol,received:t.parsedType}),hb}return _b(e.data)}};Fb.create=e=>new Fb({typeName:gx.ZodSymbol,...Tb(e)});var Ib=class extends Eb{_parse(e){if(this._getType(e)!==sb.undefined){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:sb.undefined,received:t.parsedType}),hb}return _b(e.data)}};Ib.create=e=>new Ib({typeName:gx.ZodUndefined,...Tb(e)});var Lb=class extends Eb{_parse(e){if(this._getType(e)!==sb.null){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:sb.null,received:t.parsedType}),hb}return _b(e.data)}};Lb.create=e=>new Lb({typeName:gx.ZodNull,...Tb(e)});var Rb=class extends Eb{constructor(){super(...arguments),this._any=!0}_parse(e){return _b(e.data)}};Rb.create=e=>new Rb({typeName:gx.ZodAny,...Tb(e)});var zb=class extends Eb{constructor(){super(...arguments),this._unknown=!0}_parse(e){return _b(e.data)}};zb.create=e=>new zb({typeName:gx.ZodUnknown,...Tb(e)});var Bb=class extends Eb{_parse(e){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:sb.never,received:t.parsedType}),hb}};Bb.create=e=>new Bb({typeName:gx.ZodNever,...Tb(e)});var Vb=class extends Eb{_parse(e){if(this._getType(e)!==sb.undefined){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:sb.void,received:t.parsedType}),hb}return _b(e.data)}};Vb.create=e=>new Vb({typeName:gx.ZodVoid,...Tb(e)});var Hb=class e extends Eb{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==sb.array)return B(t,{code:z.invalid_type,expected:sb.array,received:t.parsedType}),hb;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(B(t,{code:e?z.too_big:z.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(B(t,{code:z.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(B(t,{code:z.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new Cb(t,e,t.path,n)))).then(e=>mb.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new Cb(t,e,t.path,n)));return mb.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:Sb.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:Sb.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:Sb.toString(n)}})}nonempty(e){return this.min(1,e)}};Hb.create=(e,t)=>new Hb({type:e,minLength:null,maxLength:null,exactLength:null,typeName:gx.ZodArray,...Tb(t)});function Ub(e){if(e instanceof Wb){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=cx.create(Ub(r))}return new Wb({...e._def,shape:()=>t})}else if(e instanceof Hb)return new Hb({...e._def,type:Ub(e.element)});else if(e instanceof cx)return cx.create(Ub(e.unwrap()));else if(e instanceof lx)return lx.create(Ub(e.unwrap()));else if(e instanceof Xb)return Xb.create(e.items.map(e=>Ub(e)));else return e}var Wb=class e extends Eb{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=ab.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==sb.object){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:sb.object,received:t.parsedType}),hb}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Bb&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new Cb(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Bb){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(B(n,{code:z.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new Cb(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>mb.mergeObjectSync(t,e)):mb.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return Sb.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:Sb.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:gx.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of ab.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of ab.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Ub(this)}partial(t){let n={};for(let e of ab.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of ab.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof cx;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return rx(ab.objectKeys(this.shape))}};Wb.create=(e,t)=>new Wb({shape:()=>e,unknownKeys:`strip`,catchall:Bb.create(),typeName:gx.ZodObject,...Tb(t)}),Wb.strictCreate=(e,t)=>new Wb({shape:()=>e,unknownKeys:`strict`,catchall:Bb.create(),typeName:gx.ZodObject,...Tb(t)}),Wb.lazycreate=(e,t)=>new Wb({shape:e,unknownKeys:`strip`,catchall:Bb.create(),typeName:gx.ZodObject,...Tb(t)});var Gb=class extends Eb{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new lb(e.ctx.common.issues));return B(t,{code:z.invalid_union,unionErrors:n}),hb}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new lb(e));return B(t,{code:z.invalid_union,unionErrors:i}),hb}}get options(){return this._def.options}};Gb.create=(e,t)=>new Gb({options:e,typeName:gx.ZodUnion,...Tb(t)});var Kb=e=>e instanceof tx?Kb(e.schema):e instanceof sx?Kb(e.innerType()):e instanceof nx?[e.value]:e instanceof ix?e.options:e instanceof ax?ab.objectValues(e.enum):e instanceof ux?Kb(e._def.innerType):e instanceof Ib?[void 0]:e instanceof Lb?[null]:e instanceof cx?[void 0,...Kb(e.unwrap())]:e instanceof lx?[null,...Kb(e.unwrap())]:e instanceof px||e instanceof hx?Kb(e.unwrap()):e instanceof dx?Kb(e._def.innerType):[],qb=class e extends Eb{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==sb.object)return B(t,{code:z.invalid_type,expected:sb.object,received:t.parsedType}),hb;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(B(t,{code:z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),hb)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Kb(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:gx.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Tb(r)})}};function Jb(e,t){let n=cb(e),r=cb(t);if(e===t)return{valid:!0,data:e};if(n===sb.object&&r===sb.object){let n=ab.objectKeys(t),r=ab.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Jb(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===sb.array&&r===sb.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Jb(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===sb.date&&r===sb.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Yb=class extends Eb{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(vb(e)||vb(r))return hb;let i=Jb(e.value,r.value);return i.valid?((yb(e)||yb(r))&&t.dirty(),{status:t.value,value:i.data}):(B(n,{code:z.invalid_intersection_types}),hb)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Yb.create=(e,t,n)=>new Yb({left:e,right:t,typeName:gx.ZodIntersection,...Tb(n)});var Xb=class e extends Eb{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==sb.array)return B(n,{code:z.invalid_type,expected:sb.array,received:n.parsedType}),hb;if(n.data.length<this._def.items.length)return B(n,{code:z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),hb;!this._def.rest&&n.data.length>this._def.items.length&&(B(n,{code:z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new Cb(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>mb.mergeArray(t,e)):mb.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Xb.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Xb({items:e,typeName:gx.ZodTuple,rest:null,...Tb(t)})};var Zb=class e extends Eb{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==sb.object)return B(n,{code:z.invalid_type,expected:sb.object,received:n.parsedType}),hb;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new Cb(n,e,n.path,e)),value:a._parse(new Cb(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?mb.mergeObjectAsync(t,r):mb.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Eb?new e({keyType:t,valueType:n,typeName:gx.ZodRecord,...Tb(r)}):new e({keyType:Ab.create(),valueType:t,typeName:gx.ZodRecord,...Tb(n)})}},Qb=class extends Eb{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==sb.map)return B(n,{code:z.invalid_type,expected:sb.map,received:n.parsedType}),hb;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new Cb(n,e,n.path,[a,`key`])),value:i._parse(new Cb(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return hb;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return hb;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Qb.create=(e,t,n)=>new Qb({valueType:t,keyType:e,typeName:gx.ZodMap,...Tb(n)});var $b=class e extends Eb{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==sb.set)return B(n,{code:z.invalid_type,expected:sb.set,received:n.parsedType}),hb;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(B(n,{code:z.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(B(n,{code:z.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return hb;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new Cb(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:Sb.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:Sb.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};$b.create=(e,t)=>new $b({valueType:e,minSize:null,maxSize:null,typeName:gx.ZodSet,...Tb(t)});var ex=class e extends Eb{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==sb.function)return B(t,{code:z.invalid_type,expected:sb.function,received:t.parsedType}),hb;function n(e,n){return pb({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,fb(),ub].filter(e=>!!e),issueData:{code:z.invalid_arguments,argumentsError:n}})}function r(e,n){return pb({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,fb(),ub].filter(e=>!!e),issueData:{code:z.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ox){let e=this;return _b(async function(...t){let o=new lb([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return _b(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new lb([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new lb([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Xb.create(t).rest(zb.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Xb.create([]).rest(zb.create()),returns:n||zb.create(),typeName:gx.ZodFunction,...Tb(r)})}},tx=class extends Eb{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};tx.create=(e,t)=>new tx({getter:e,typeName:gx.ZodLazy,...Tb(t)});var nx=class extends Eb{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return B(t,{received:t.data,code:z.invalid_literal,expected:this._def.value}),hb}return{status:`valid`,value:e.data}}get value(){return this._def.value}};nx.create=(e,t)=>new nx({value:e,typeName:gx.ZodLiteral,...Tb(t)});function rx(e,t){return new ix({values:e,typeName:gx.ZodEnum,...Tb(t)})}var ix=class e extends Eb{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return B(t,{expected:ab.joinValues(n),received:t.parsedType,code:z.invalid_type}),hb}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return B(t,{received:t.data,code:z.invalid_enum_value,options:n}),hb}return _b(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};ix.create=rx;var ax=class extends Eb{_parse(e){let t=ab.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==sb.string&&n.parsedType!==sb.number){let e=ab.objectValues(t);return B(n,{expected:ab.joinValues(e),received:n.parsedType,code:z.invalid_type}),hb}if(this._cache||=new Set(ab.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=ab.objectValues(t);return B(n,{received:n.data,code:z.invalid_enum_value,options:e}),hb}return _b(e.data)}get enum(){return this._def.values}};ax.create=(e,t)=>new ax({values:e,typeName:gx.ZodNativeEnum,...Tb(t)});var ox=class extends Eb{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==sb.promise&&t.common.async===!1?(B(t,{code:z.invalid_type,expected:sb.promise,received:t.parsedType}),hb):_b((t.parsedType===sb.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};ox.create=(e,t)=>new ox({type:e,typeName:gx.ZodPromise,...Tb(t)});var sx=class extends Eb{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===gx.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{B(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return hb;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?hb:r.status===`dirty`||t.value===`dirty`?gb(r.value):r});{if(t.value===`aborted`)return hb;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?hb:r.status===`dirty`||t.value===`dirty`?gb(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?hb:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?hb:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!bb(e))return hb;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>bb(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):hb);ab.assertNever(r)}};sx.create=(e,t,n)=>new sx({schema:e,typeName:gx.ZodEffects,effect:t,...Tb(n)}),sx.createWithPreprocess=(e,t,n)=>new sx({schema:t,effect:{type:`preprocess`,transform:e},typeName:gx.ZodEffects,...Tb(n)});var cx=class extends Eb{_parse(e){return this._getType(e)===sb.undefined?_b(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};cx.create=(e,t)=>new cx({innerType:e,typeName:gx.ZodOptional,...Tb(t)});var lx=class extends Eb{_parse(e){return this._getType(e)===sb.null?_b(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};lx.create=(e,t)=>new lx({innerType:e,typeName:gx.ZodNullable,...Tb(t)});var ux=class extends Eb{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===sb.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ux.create=(e,t)=>new ux({innerType:e,typeName:gx.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...Tb(t)});var dx=class extends Eb{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return xb(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new lb(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new lb(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};dx.create=(e,t)=>new dx({innerType:e,typeName:gx.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...Tb(t)});var fx=class extends Eb{_parse(e){if(this._getType(e)!==sb.nan){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:sb.nan,received:t.parsedType}),hb}return{status:`valid`,value:e.data}}};fx.create=e=>new fx({typeName:gx.ZodNaN,...Tb(e)});var px=class extends Eb{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},mx=class e extends Eb{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?hb:e.status===`dirty`?(t.dirty(),gb(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?hb:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:gx.ZodPipeline})}},hx=class extends Eb{_parse(e){let t=this._def.innerType._parse(e),n=e=>(bb(e)&&(e.value=Object.freeze(e.value)),e);return xb(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};hx.create=(e,t)=>new hx({innerType:e,typeName:gx.ZodReadonly,...Tb(t)}),Wb.lazycreate;var gx;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(gx||={});var _x=Ab.create,vx=jb.create;fx.create,Mb.create;var yx=Nb.create;Pb.create,Fb.create,Ib.create,Lb.create;var bx=Rb.create;zb.create,Bb.create,Vb.create;var xx=Hb.create,Sx=Wb.create;Wb.strictCreate;var Cx=Gb.create;qb.create,Yb.create,Xb.create;var wx=Zb.create;Qb.create,$b.create,ex.create,tx.create;var Tx=nx.create,Ex=ix.create;ax.create,ox.create,sx.create,cx.create,lx.create;var Dx=sx.createWithPreprocess;mx.create;var Ox={string:(e=>Ab.create({...e,coerce:!0})),number:(e=>jb.create({...e,coerce:!0})),boolean:(e=>Nb.create({...e,coerce:!0})),bigint:(e=>Mb.create({...e,coerce:!0})),date:(e=>Pb.create({...e,coerce:!0}))},kx=class extends Error{constructor(e,t=`UNKNOWN_ERROR`){super(e),this.name=this.constructor.name,this.code=t,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Ax=class extends kx{constructor(e,t){super(e,`VALIDATION_ERROR`),this.details=t}},jx=class extends kx{constructor(e,t){super(e,`DATA_ERROR`),this.path=t}},Mx=class extends kx{constructor(e,t,n){super(e,`EXPRESSION_ERROR`),this.expression=t,this.details=n}},Nx=class extends kx{constructor(e){super(e,`STATE_ERROR`)}};function Px(e){return e&&typeof e==`object`&&`value`in e&&`peek`in e}function Fx(e,t){return{name:e.name,returnType:e.returnType,schema:e.schema,execute:t}}var Ix=class{constructor(e,t,n=[],r){this.id=e;let i=new Map;for(let e of t)i.set(e.name,e);this.components=i;let a=new Map;for(let e of n)a.set(e.name,e);this.functions=a,this.themeSchema=r,this.invoker=(e,t,n,r)=>{let i=this.functions.get(e);if(!i)throw new Mx(`Function not found in catalog '${this.id}': ${e}`,e);try{let e=i.schema.parse(t);return i.execute(e,n,r)}catch(t){throw t?.name===`ZodError`||t instanceof lb?new Mx(`Validation failed for function '${e}': ${t.message}`,e,t.errors??t.issues):t}}}},Lx=class{constructor(){this.listeners=new Set}subscribe(e){return this.listeners.add(e),{unsubscribe:()=>this.listeners.delete(e)}}async emit(e){for(let t of this.listeners)try{await t(e)}catch(e){console.error(`EventEmitter error:`,e)}}dispose(){this.listeners.clear()}},Rx=Symbol.for(`preact-signals`);function zx(){if(Gx>1)Gx--;else{var e,t=!1;for((function(){var e=Yx;for(Yx=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();Wx!==void 0;){var n=Wx;for(Wx=void 0,Kx++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&eS(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(Kx=0,Gx--,t)throw e}}function Bx(e){if(Gx>0)return e();Jx=++qx,Gx++;try{return e()}finally{zx()}}var Vx,Hx=void 0;function Ux(e){var t=Hx,n=Vx;Hx=void 0,Vx=void 0;try{return e()}finally{Hx=t,Vx=n}}var Wx=void 0,Gx=0,Kx=0,qx=0,Jx=0,Yx=void 0,Xx=0;function Zx(e){if(Hx!==void 0){var t=e.n;if(t===void 0||t.t!==Hx)return t={i:0,S:e,p:Hx.s,n:void 0,t:Hx,e:void 0,x:void 0,r:t},Hx.s!==void 0&&(Hx.s.n=t),Hx.s=t,e.n=t,32&Hx.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=Hx.s,t.n=void 0,Hx.s.n=t,Hx.s=t),t}}function Qx(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}Qx.prototype.brand=Rx,Qx.prototype.h=function(){return!0},Qx.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n===void 0?Ux(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},Qx.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&Ux(function(){var e;(e=t.Z)==null||e.call(t)}))}},Qx.prototype.subscribe=function(e){var t=this;return lS(function(){var n=t.value;Ux(function(){return e(n)})},{name:`sub`})},Qx.prototype.valueOf=function(){return this.value},Qx.prototype.toString=function(){return this.value+``},Qx.prototype.toJSON=function(){return this.value},Qx.prototype.peek=function(){var e=this;return Ux(function(){return e.value})},Object.defineProperty(Qx.prototype,"value",{get:function(){var e=Zx(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Kx>100)throw Error(`Cycle detected`);(function(e){Gx!==0&&Kx===0&&e.l!==Jx&&(e.l=Jx,Yx={S:e,v:e.v,i:e.i,o:Yx})})(this),this.v=e,this.i++,Xx++,Gx++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{zx()}}}});function $x(e,t){return new Qx(e,t)}function eS(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function tS(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function nS(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function rS(e,t){Qx.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Xx-1,this.f=4}rS.prototype=new Qx,rS.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Xx))return!0;if(this.g=Xx,this.f|=1,this.i>0&&!eS(this))return this.f&=-2,!0;var e=Hx;try{tS(this),Hx=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return Hx=e,nS(this),this.f&=-2,!0},rS.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}Qx.prototype.S.call(this,e)},rS.prototype.U=function(e){if(this.t!==void 0&&(Qx.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},rS.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(rS.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=Zx(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function iS(e,t){return new rS(e,t)}function aS(e){var t=e.m;if(e.m=void 0,typeof t==`function`){Gx++;var n=Hx;Hx=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,oS(e),t}finally{Hx=n,zx()}}}function oS(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,aS(e)}function sS(e){if(Hx!==this)throw Error(`Out-of-order effect`);nS(this),Hx=e,this.f&=-2,8&this.f&&oS(this),zx()}function cS(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Vx&&Vx.push(this)}cS.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t==`function`&&(this.m=t)}finally{e()}},cS.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,aS(this),tS(this),Gx++;var e=Hx;return Hx=this,sS.bind(this,e)},cS.prototype.N=function(){2&this.f||(this.f|=2,this.u=Wx,Wx=this)},cS.prototype.d=function(){this.f|=8,1&this.f||oS(this)},cS.prototype.dispose=function(){this.d()};function lS(e,t){var n=new cS(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}function uS(e){return/^\d+$/.test(e)}var dS=class{constructor(e={}){this.data={},this.signals=new Map,this.subscriptions=new Set,this.data=e}getSignal(e){let t=this.normalizePath(e);return this.signals.has(t)||this.signals.set(t,$x(this.get(t))),this.signals.get(t)}set(e,t){if(e==null)throw new jx(`Path cannot be null or undefined.`);if(e===`/`||e===``)return this.data=t,this.notifyAllSignals(),this;let n=this.parsePath(e),r=n.pop();this.data||={};let i=this.data;for(let t=0;t<n.length;t++){let a=n[t];if(Array.isArray(i)&&!uS(a))throw new jx(`Cannot use non-numeric segment '${a}' on an array in path '${e}'.`,e);if(i[a]!==void 0&&i[a]!==null&&typeof i[a]!=`object`)throw new jx(`Cannot set path '${e}': segment '${a}' is a primitive value.`,e);if(i[a]===void 0||i[a]===null){let e=t<n.length-1?n[t+1]:r;i[a]=uS(e)?[]:{}}i=i[a]}if(Array.isArray(i)&&!uS(r))throw new jx(`Cannot use non-numeric segment '${r}' on an array in path '${e}'.`,e);return t===void 0?Array.isArray(i)?i[parseInt(r,10)]=void 0:delete i[r]:i[r]=t,this.notifySignals(e),this}get(e){if(e==null)throw new jx(`Path cannot be null or undefined.`);if(e===`/`||e===``)return this.data;let t=this.parsePath(e),n=this.data;for(let e of t){if(n==null)return;n=n[e]}return n}subscribe(e,t){let n=this.getSignal(e),r=!0,i=n.peek(),a=lS(()=>{let e=n.value;i=e,r||t(e)});return r=!1,this.subscriptions.add(a),{get value(){return i},unsubscribe:()=>{a(),this.subscriptions.delete(a)}}}dispose(){for(let e of this.subscriptions)e();this.subscriptions.clear(),this.signals.clear()}normalizePath(e){return e.length>1&&e.endsWith(`/`)?e.slice(0,-1):e||`/`}parsePath(e){return e.split(`/`).filter(e=>e.length>0)}notifySignals(e){let t=this.normalizePath(e);Bx(()=>{this.updateSignal(t);let e=t;for(;e!==`/`&&e!==``;)e=e.substring(0,e.lastIndexOf(`/`))||`/`,this.updateSignal(e);for(let e of this.signals.keys())this.isDescendant(e,t)&&this.updateSignal(e)})}updateSignal(e){let t=this.signals.get(e);if(t){let n=this.get(e);Array.isArray(n)?t.value=[...n]:typeof n==`object`&&n?t.value={...n}:t.value=n}}notifyAllSignals(){Bx(()=>{for(let e of this.signals.keys())this.updateSignal(e)})}isDescendant(e,t){return t===`/`||t===``?e!==`/`:e.startsWith(t+`/`)}},fS=class{constructor(){this.components=new Map,this._onCreated=new Lx,this._onDeleted=new Lx,this.onCreated=this._onCreated,this.onDeleted=this._onDeleted}get(e){return this.components.get(e)}get entries(){return this.components.entries()}addComponent(e){if(this.components.has(e.id))throw new Nx(`Component with id '${e.id}' already exists.`);this.components.set(e.id,e),this._onCreated.emit(e)}removeComponent(e){let t=this.components.get(e);t&&(this.components.delete(e),t.dispose(),this._onDeleted.emit(e))}dispose(){for(let e of this.components.values())e.dispose();this.components.clear(),this._onCreated.dispose(),this._onDeleted.dispose()}},pS=Sx({name:_x().describe(`The name of the action, taken from the component's action.event.name property.`),surfaceId:_x().describe(`The id of the surface where the event originated.`),sourceComponentId:_x().describe(`The id of the component that triggered the event.`),timestamp:_x().datetime().describe(`An ISO 8601 timestamp of when the event occurred.`),context:wx(bx()).describe(`A JSON object containing the key-value pairs from the component's action.event.context, after resolving all data bindings.`)}).strict(),mS=Cx([Sx({code:Tx(`VALIDATION_FAILED`),surfaceId:_x().describe(`The id of the surface where the error occurred.`),path:_x().describe(`The JSON pointer to the field that failed validation (e.g. '/components/0/text').`),message:_x().describe(`A short one or two sentence description of why validation failed.`)}).strict(),Sx({code:_x().refine(e=>e!==`VALIDATION_FAILED`),message:_x().describe(`A short one or two sentence description of why the error occurred.`),surfaceId:_x().describe(`The id of the surface where the error occurred.`)}).passthrough()]);Sx({version:Tx(`v0.9`)}).and(Cx([Sx({action:pS}),Sx({error:mS})])),Sx({version:Tx(`v0.9`),surfaces:wx(Sx({}).passthrough()).describe(`A map of surface IDs to their current data models.`)}).strict();var hS=class{constructor(e,t,n={},r=!1){this.id=e,this.catalog=t,this.theme=n,this.sendDataModel=r,this._onAction=new Lx,this._onError=new Lx,this.onAction=this._onAction,this.onError=this._onError,this.dataModel=new dS({}),this.componentsModel=new fS}async dispatchAction(e,t){if(e&&typeof e==`object`&&`event`in e&&e.event){let n={name:e.event.name,surfaceId:this.id,sourceComponentId:t,timestamp:new Date().toISOString(),context:e.event.context||{}},r=pS.safeParse(n);r.success?await this._onAction.emit(r.data):console.error(`A2UI: Invalid action payload dispatched.`,r.error.format())}}async dispatchError(e){await this._onError.emit({...e,surfaceId:this.id})}dispose(){this.dataModel.dispose(),this.componentsModel.dispose(),this._onAction.dispose(),this._onError.dispose()}},gS=class{constructor(){this.surfaces=new Map,this.surfaceUnsubscribers=new Map,this._onSurfaceCreated=new Lx,this._onSurfaceDeleted=new Lx,this._onAction=new Lx,this.onSurfaceCreated=this._onSurfaceCreated,this.onSurfaceDeleted=this._onSurfaceDeleted,this.onAction=this._onAction}addSurface(e){if(this.surfaces.has(e.id)){console.warn(`Surface ${e.id} already exists. Ignoring.`);return}this.surfaces.set(e.id,e);let t=e.onAction.subscribe(e=>this._onAction.emit(e));this.surfaceUnsubscribers.set(e.id,t),this._onSurfaceCreated.emit(e)}deleteSurface(e){let t=this.surfaces.get(e);if(t){let n=this.surfaceUnsubscribers.get(e);n&&(n.unsubscribe(),this.surfaceUnsubscribers.delete(e)),this.surfaces.delete(e),t.dispose(),this._onSurfaceDeleted.emit(e)}}getSurface(e){return this.surfaces.get(e)}get surfacesMap(){return this.surfaces}dispose(){for(let e of Array.from(this.surfaces.keys()))this.deleteSurface(e);this._onSurfaceCreated.dispose(),this._onSurfaceDeleted.dispose(),this._onAction.dispose()}},_S=class{constructor(e,t,n){this.id=e,this.type=t,this._onUpdated=new Lx,this.onUpdated=this._onUpdated,this._properties=n}get properties(){return this._properties}set properties(e){this._properties=e,this._onUpdated.emit(this)}dispose(){this._onUpdated.dispose()}get componentTree(){return{id:this.id,type:this.type,...this._properties}}},vS=Symbol(`Let zodToJsonSchema decide on which parser to use`),yS={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,target:`jsonSchema7`,strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`,openAiAnyTypeName:`OpenAiAnyType`},bS=e=>typeof e==`string`?{...yS,name:e}:{...yS,...e},xS=e=>{let t=bS(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}};function SS(e,t,n,r){r?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function CS(e,t,n,r,i){e[t]=n,SS(e,t,r,i)}var wS=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)},TS;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(TS||={});var ES;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(ES||={});var DS=TS.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),OS=e=>{switch(typeof e){case`undefined`:return DS.undefined;case`string`:return DS.string;case`number`:return Number.isNaN(e)?DS.nan:DS.number;case`boolean`:return DS.boolean;case`function`:return DS.function;case`bigint`:return DS.bigint;case`symbol`:return DS.symbol;case`object`:return Array.isArray(e)?DS.array:e===null?DS.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?DS.promise:typeof Map<`u`&&e instanceof Map?DS.map:typeof Set<`u`&&e instanceof Set?DS.set:typeof Date<`u`&&e instanceof Date?DS.date:DS.object;default:return DS.unknown}},V=TS.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),kS=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,TS.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t=Object.create(null),n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};kS.create=e=>new kS(e);var AS=(e,t)=>{let n;switch(e.code){case V.invalid_type:n=e.received===DS.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case V.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,TS.jsonStringifyReplacer)}`;break;case V.unrecognized_keys:n=`Unrecognized key(s) in object: ${TS.joinValues(e.keys,`, `)}`;break;case V.invalid_union:n=`Invalid input`;break;case V.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${TS.joinValues(e.options)}`;break;case V.invalid_enum_value:n=`Invalid enum value. Expected ${TS.joinValues(e.options)}, received '${e.received}'`;break;case V.invalid_arguments:n=`Invalid function arguments`;break;case V.invalid_return_type:n=`Invalid function return type`;break;case V.invalid_date:n=`Invalid date`;break;case V.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:TS.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case V.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case V.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case V.custom:n=`Invalid input`;break;case V.invalid_intersection_types:n=`Intersection results could not be merged`;break;case V.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case V.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,TS.assertNever(e)}return{message:n}},jS=AS;function MS(){return jS}var NS=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function H(e,t){let n=MS(),r=NS({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===AS?void 0:AS].filter(e=>!!e)});e.common.issues.push(r)}var PS=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return FS;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return FS;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},FS=Object.freeze({status:`aborted`}),IS=e=>({status:`dirty`,value:e}),LS=e=>({status:`valid`,value:e}),RS=e=>e.status===`aborted`,zS=e=>e.status===`dirty`,BS=e=>e.status===`valid`,VS=e=>typeof Promise<`u`&&e instanceof Promise,HS;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(HS||={});var US=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},WS=(e,t)=>{if(BS(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new kS(e.common.issues);return this._error=t,this._error}}};function GS(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var KS=class{get description(){return this._def.description}_getType(e){return OS(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:OS(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new PS,ctx:{common:e.parent.common,data:e.data,parsedType:OS(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(VS(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:OS(e)};return WS(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:OS(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return BS(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>BS(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:OS(e)},r=this._parse({data:e,path:n.path,parent:n});return WS(n,await(VS(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:V.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new wC({schema:this,typeName:U.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return TC.create(this,this._def)}nullable(){return EC.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return cC.create(this)}promise(){return CC.create(this,this._def)}or(e){return dC.create([this,e],this._def)}and(e){return mC.create(this,e,this._def)}transform(e){return new wC({...GS(this._def),schema:this,typeName:U.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new DC({...GS(this._def),innerType:this,defaultValue:t,typeName:U.ZodDefault})}brand(){return new AC({typeName:U.ZodBranded,type:this,...GS(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new OC({...GS(this._def),innerType:this,catchValue:t,typeName:U.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return jC.create(this,e)}readonly(){return MC.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Lee=/^c[^\s-]{8,}$/i,Ree=/^[0-9a-z]+$/,zee=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Bee=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Vee=/^[a-z0-9_-]{21}$/i,Hee=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Uee=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Wee=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Gee=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,qS,Kee=/^(?:(?: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])$/,qee=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Jee=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Yee=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Xee=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Zee=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,JS=`((\\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])))`,Qee=RegExp(`^${JS}$`);function YS(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function $ee(e){return RegExp(`^${YS(e)}$`)}function ete(e){let t=`${JS}T${YS(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function tte(e,t){return!!((t===`v4`||!t)&&Kee.test(e)||(t===`v6`||!t)&&Jee.test(e))}function nte(e,t){if(!Hee.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function rte(e,t){return!!((t===`v4`||!t)&&qee.test(e)||(t===`v6`||!t)&&Yee.test(e))}var XS=class e extends KS{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==DS.string){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:DS.string,received:t.parsedType}),FS}let t=new PS,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:V.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:V.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?H(n,{code:V.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&H(n,{code:V.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)Wee.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:`email`,code:V.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)qS||=new RegExp(Gee,`u`),qS.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:`emoji`,code:V.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Bee.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:`uuid`,code:V.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)Vee.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:`nanoid`,code:V.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Lee.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:`cuid`,code:V.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Ree.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:`cuid2`,code:V.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)zee.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:`ulid`,code:V.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),H(n,{validation:`url`,code:V.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:`regex`,code:V.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),H(n,{code:V.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),H(n,{code:V.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),H(n,{code:V.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?ete(r).test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:V.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Qee.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:V.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?$ee(r).test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:V.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?Uee.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:`duration`,code:V.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?tte(e.data,r.version)||(n=this._getOrReturnCtx(e,n),H(n,{validation:`ip`,code:V.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?nte(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),H(n,{validation:`jwt`,code:V.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?rte(e.data,r.version)||(n=this._getOrReturnCtx(e,n),H(n,{validation:`cidr`,code:V.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?Xee.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:`base64`,code:V.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?Zee.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:`base64url`,code:V.invalid_string,message:r.message}),t.dirty()):TS.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:V.invalid_string,...HS.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...HS.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...HS.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...HS.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...HS.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...HS.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...HS.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...HS.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...HS.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...HS.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...HS.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...HS.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...HS.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...HS.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...HS.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...HS.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...HS.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...HS.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...HS.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...HS.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...HS.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...HS.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...HS.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...HS.errToObj(t)})}nonempty(e){return this.min(1,HS.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};XS.create=e=>new XS({checks:[],typeName:U.ZodString,coerce:e?.coerce??!1,...GS(e)});function ite(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var ZS=class e extends KS{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==DS.number){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:DS.number,received:t.parsedType}),FS}let t,n=new PS;for(let r of this._def.checks)r.kind===`int`?TS.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),H(t,{code:V.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),H(t,{code:V.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),H(t,{code:V.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?ite(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),H(t,{code:V.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),H(t,{code:V.not_finite,message:r.message}),n.dirty()):TS.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,HS.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,HS.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,HS.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,HS.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:HS.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:HS.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:HS.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:HS.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:HS.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:HS.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:HS.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:HS.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:HS.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:HS.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&TS.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};ZS.create=e=>new ZS({checks:[],typeName:U.ZodNumber,coerce:e?.coerce||!1,...GS(e)});var QS=class e extends KS{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==DS.bigint)return this._getInvalidInput(e);let t,n=new PS;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),H(t,{code:V.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),H(t,{code:V.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),H(t,{code:V.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):TS.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:DS.bigint,received:t.parsedType}),FS}gte(e,t){return this.setLimit(`min`,e,!0,HS.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,HS.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,HS.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,HS.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:HS.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:HS.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:HS.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:HS.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:HS.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:HS.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};QS.create=e=>new QS({checks:[],typeName:U.ZodBigInt,coerce:e?.coerce??!1,...GS(e)});var $S=class extends KS{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==DS.boolean){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:DS.boolean,received:t.parsedType}),FS}return LS(e.data)}};$S.create=e=>new $S({typeName:U.ZodBoolean,coerce:e?.coerce||!1,...GS(e)});var eC=class e extends KS{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==DS.date){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:DS.date,received:t.parsedType}),FS}if(Number.isNaN(e.data.getTime()))return H(this._getOrReturnCtx(e),{code:V.invalid_date}),FS;let t=new PS,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:V.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:V.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):TS.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:HS.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:HS.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};eC.create=e=>new eC({checks:[],coerce:e?.coerce||!1,typeName:U.ZodDate,...GS(e)});var tC=class extends KS{_parse(e){if(this._getType(e)!==DS.symbol){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:DS.symbol,received:t.parsedType}),FS}return LS(e.data)}};tC.create=e=>new tC({typeName:U.ZodSymbol,...GS(e)});var nC=class extends KS{_parse(e){if(this._getType(e)!==DS.undefined){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:DS.undefined,received:t.parsedType}),FS}return LS(e.data)}};nC.create=e=>new nC({typeName:U.ZodUndefined,...GS(e)});var rC=class extends KS{_parse(e){if(this._getType(e)!==DS.null){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:DS.null,received:t.parsedType}),FS}return LS(e.data)}};rC.create=e=>new rC({typeName:U.ZodNull,...GS(e)});var iC=class extends KS{constructor(){super(...arguments),this._any=!0}_parse(e){return LS(e.data)}};iC.create=e=>new iC({typeName:U.ZodAny,...GS(e)});var aC=class extends KS{constructor(){super(...arguments),this._unknown=!0}_parse(e){return LS(e.data)}};aC.create=e=>new aC({typeName:U.ZodUnknown,...GS(e)});var oC=class extends KS{_parse(e){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:DS.never,received:t.parsedType}),FS}};oC.create=e=>new oC({typeName:U.ZodNever,...GS(e)});var sC=class extends KS{_parse(e){if(this._getType(e)!==DS.undefined){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:DS.void,received:t.parsedType}),FS}return LS(e.data)}};sC.create=e=>new sC({typeName:U.ZodVoid,...GS(e)});var cC=class e extends KS{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==DS.array)return H(t,{code:V.invalid_type,expected:DS.array,received:t.parsedType}),FS;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(H(t,{code:e?V.too_big:V.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(H(t,{code:V.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(H(t,{code:V.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new US(t,e,t.path,n)))).then(e=>PS.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new US(t,e,t.path,n)));return PS.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:HS.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:HS.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:HS.toString(n)}})}nonempty(e){return this.min(1,e)}};cC.create=(e,t)=>new cC({type:e,minLength:null,maxLength:null,exactLength:null,typeName:U.ZodArray,...GS(t)});function lC(e){if(e instanceof uC){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=TC.create(lC(r))}return new uC({...e._def,shape:()=>t})}else if(e instanceof cC)return new cC({...e._def,type:lC(e.element)});else if(e instanceof TC)return TC.create(lC(e.unwrap()));else if(e instanceof EC)return EC.create(lC(e.unwrap()));else if(e instanceof hC)return hC.create(e.items.map(e=>lC(e)));else return e}var uC=class e extends KS{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=TS.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==DS.object){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:DS.object,received:t.parsedType}),FS}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof oC&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new US(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof oC){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(H(n,{code:V.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new US(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>PS.mergeObjectSync(t,e)):PS.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return HS.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:HS.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:U.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of TS.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of TS.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return lC(this)}partial(t){let n={};for(let e of TS.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of TS.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof TC;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return bC(TS.objectKeys(this.shape))}};uC.create=(e,t)=>new uC({shape:()=>e,unknownKeys:`strip`,catchall:oC.create(),typeName:U.ZodObject,...GS(t)}),uC.strictCreate=(e,t)=>new uC({shape:()=>e,unknownKeys:`strict`,catchall:oC.create(),typeName:U.ZodObject,...GS(t)}),uC.lazycreate=(e,t)=>new uC({shape:e,unknownKeys:`strip`,catchall:oC.create(),typeName:U.ZodObject,...GS(t)});var dC=class extends KS{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new kS(e.ctx.common.issues));return H(t,{code:V.invalid_union,unionErrors:n}),FS}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new kS(e));return H(t,{code:V.invalid_union,unionErrors:i}),FS}}get options(){return this._def.options}};dC.create=(e,t)=>new dC({options:e,typeName:U.ZodUnion,...GS(t)});var fC=e=>e instanceof vC?fC(e.schema):e instanceof wC?fC(e.innerType()):e instanceof yC?[e.value]:e instanceof xC?e.options:e instanceof SC?TS.objectValues(e.enum):e instanceof DC?fC(e._def.innerType):e instanceof nC?[void 0]:e instanceof rC?[null]:e instanceof TC?[void 0,...fC(e.unwrap())]:e instanceof EC?[null,...fC(e.unwrap())]:e instanceof AC||e instanceof MC?fC(e.unwrap()):e instanceof OC?fC(e._def.innerType):[],ate=class e extends KS{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==DS.object)return H(t,{code:V.invalid_type,expected:DS.object,received:t.parsedType}),FS;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(H(t,{code:V.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),FS)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=fC(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:U.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...GS(r)})}};function pC(e,t){let n=OS(e),r=OS(t);if(e===t)return{valid:!0,data:e};if(n===DS.object&&r===DS.object){let n=TS.objectKeys(t),r=TS.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=pC(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===DS.array&&r===DS.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=pC(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===DS.date&&r===DS.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var mC=class extends KS{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(RS(e)||RS(r))return FS;let i=pC(e.value,r.value);return i.valid?((zS(e)||zS(r))&&t.dirty(),{status:t.value,value:i.data}):(H(n,{code:V.invalid_intersection_types}),FS)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};mC.create=(e,t,n)=>new mC({left:e,right:t,typeName:U.ZodIntersection,...GS(n)});var hC=class e extends KS{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==DS.array)return H(n,{code:V.invalid_type,expected:DS.array,received:n.parsedType}),FS;if(n.data.length<this._def.items.length)return H(n,{code:V.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),FS;!this._def.rest&&n.data.length>this._def.items.length&&(H(n,{code:V.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new US(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>PS.mergeArray(t,e)):PS.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};hC.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new hC({items:e,typeName:U.ZodTuple,rest:null,...GS(t)})};var ote=class e extends KS{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==DS.object)return H(n,{code:V.invalid_type,expected:DS.object,received:n.parsedType}),FS;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new US(n,e,n.path,e)),value:a._parse(new US(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?PS.mergeObjectAsync(t,r):PS.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof KS?new e({keyType:t,valueType:n,typeName:U.ZodRecord,...GS(r)}):new e({keyType:XS.create(),valueType:t,typeName:U.ZodRecord,...GS(n)})}},gC=class extends KS{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==DS.map)return H(n,{code:V.invalid_type,expected:DS.map,received:n.parsedType}),FS;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new US(n,e,n.path,[a,`key`])),value:i._parse(new US(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return FS;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return FS;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};gC.create=(e,t,n)=>new gC({valueType:t,keyType:e,typeName:U.ZodMap,...GS(n)});var _C=class e extends KS{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==DS.set)return H(n,{code:V.invalid_type,expected:DS.set,received:n.parsedType}),FS;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(H(n,{code:V.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(H(n,{code:V.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return FS;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new US(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:HS.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:HS.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};_C.create=(e,t)=>new _C({valueType:e,minSize:null,maxSize:null,typeName:U.ZodSet,...GS(t)});var ste=class e extends KS{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==DS.function)return H(t,{code:V.invalid_type,expected:DS.function,received:t.parsedType}),FS;function n(e,n){return NS({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,MS(),AS].filter(e=>!!e),issueData:{code:V.invalid_arguments,argumentsError:n}})}function r(e,n){return NS({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,MS(),AS].filter(e=>!!e),issueData:{code:V.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof CC){let e=this;return LS(async function(...t){let o=new kS([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return LS(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new kS([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new kS([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:hC.create(t).rest(aC.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||hC.create([]).rest(aC.create()),returns:n||aC.create(),typeName:U.ZodFunction,...GS(r)})}},vC=class extends KS{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};vC.create=(e,t)=>new vC({getter:e,typeName:U.ZodLazy,...GS(t)});var yC=class extends KS{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return H(t,{received:t.data,code:V.invalid_literal,expected:this._def.value}),FS}return{status:`valid`,value:e.data}}get value(){return this._def.value}};yC.create=(e,t)=>new yC({value:e,typeName:U.ZodLiteral,...GS(t)});function bC(e,t){return new xC({values:e,typeName:U.ZodEnum,...GS(t)})}var xC=class e extends KS{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{expected:TS.joinValues(n),received:t.parsedType,code:V.invalid_type}),FS}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{received:t.data,code:V.invalid_enum_value,options:n}),FS}return LS(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};xC.create=bC;var SC=class extends KS{_parse(e){let t=TS.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==DS.string&&n.parsedType!==DS.number){let e=TS.objectValues(t);return H(n,{expected:TS.joinValues(e),received:n.parsedType,code:V.invalid_type}),FS}if(this._cache||=new Set(TS.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=TS.objectValues(t);return H(n,{received:n.data,code:V.invalid_enum_value,options:e}),FS}return LS(e.data)}get enum(){return this._def.values}};SC.create=(e,t)=>new SC({values:e,typeName:U.ZodNativeEnum,...GS(t)});var CC=class extends KS{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==DS.promise&&t.common.async===!1?(H(t,{code:V.invalid_type,expected:DS.promise,received:t.parsedType}),FS):LS((t.parsedType===DS.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};CC.create=(e,t)=>new CC({type:e,typeName:U.ZodPromise,...GS(t)});var wC=class extends KS{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===U.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{H(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return FS;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?FS:r.status===`dirty`||t.value===`dirty`?IS(r.value):r});{if(t.value===`aborted`)return FS;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?FS:r.status===`dirty`||t.value===`dirty`?IS(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?FS:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?FS:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!BS(e))return FS;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>BS(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):FS);TS.assertNever(r)}};wC.create=(e,t,n)=>new wC({schema:e,typeName:U.ZodEffects,effect:t,...GS(n)}),wC.createWithPreprocess=(e,t,n)=>new wC({schema:t,effect:{type:`preprocess`,transform:e},typeName:U.ZodEffects,...GS(n)});var TC=class extends KS{_parse(e){return this._getType(e)===DS.undefined?LS(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};TC.create=(e,t)=>new TC({innerType:e,typeName:U.ZodOptional,...GS(t)});var EC=class extends KS{_parse(e){return this._getType(e)===DS.null?LS(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};EC.create=(e,t)=>new EC({innerType:e,typeName:U.ZodNullable,...GS(t)});var DC=class extends KS{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===DS.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};DC.create=(e,t)=>new DC({innerType:e,typeName:U.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...GS(t)});var OC=class extends KS{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return VS(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new kS(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new kS(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};OC.create=(e,t)=>new OC({innerType:e,typeName:U.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...GS(t)});var kC=class extends KS{_parse(e){if(this._getType(e)!==DS.nan){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:DS.nan,received:t.parsedType}),FS}return{status:`valid`,value:e.data}}};kC.create=e=>new kC({typeName:U.ZodNaN,...GS(e)});var AC=class extends KS{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},jC=class e extends KS{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?FS:e.status===`dirty`?(t.dirty(),IS(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?FS:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:U.ZodPipeline})}},MC=class extends KS{_parse(e){let t=this._def.innerType._parse(e),n=e=>(BS(e)&&(e.value=Object.freeze(e.value)),e);return VS(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};MC.create=(e,t)=>new MC({innerType:e,typeName:U.ZodReadonly,...GS(t)}),uC.lazycreate;var U;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(U||={}),XS.create,ZS.create,kC.create,QS.create,$S.create,eC.create,tC.create,nC.create,rC.create,iC.create,aC.create,oC.create,sC.create,cC.create,uC.create,uC.strictCreate,dC.create,ate.create,mC.create,hC.create,ote.create,gC.create,_C.create,ste.create,vC.create,yC.create,xC.create,SC.create,CC.create,wC.create,TC.create,EC.create,wC.createWithPreprocess,jC.create;function NC(e){if(e.target!==`openAi`)return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy===`relative`?wS(t,e.currentPath):t.join(`/`)}}function PC(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==U.ZodAny&&(n.items=ww(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&CS(n,`minItems`,e.minLength.value,e.minLength.message,t),e.maxLength&&CS(n,`maxItems`,e.maxLength.value,e.maxLength.message,t),e.exactLength&&(CS(n,`minItems`,e.exactLength.value,e.exactLength.message,t),CS(n,`maxItems`,e.exactLength.value,e.exactLength.message,t)),n}function FC(e,t){let n={type:`integer`,format:`int64`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`min`:t.target===`jsonSchema7`?r.inclusive?CS(n,`minimum`,r.value,r.message,t):CS(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),CS(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?CS(n,`maximum`,r.value,r.message,t):CS(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),CS(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:CS(n,`multipleOf`,r.value,r.message,t);break}return n}function IC(){return{type:`boolean`}}function LC(e,t){return ww(e.type._def,t)}var RC=(e,t)=>ww(e.innerType._def,t);function zC(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((n,r)=>zC(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return BC(e,t)}}var BC=(e,t)=>{let n={type:`integer`,format:`unix-time`};if(t.target===`openApi3`)return n;for(let r of e.checks)switch(r.kind){case`min`:CS(n,`minimum`,r.value,r.message,t);break;case`max`:CS(n,`maximum`,r.value,r.message,t);break}return n};function VC(e,t){return{...ww(e.innerType._def,t),default:e.defaultValue()}}function HC(e,t){return t.effectStrategy===`input`?ww(e.schema._def,t):NC(t)}function UC(e){return{type:`string`,enum:Array.from(e.values)}}var WC=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function GC(e,t){let n=[ww(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),ww(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=t.target===`jsonSchema2019-09`?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(e=>{if(WC(e))i.push(...e.allOf),e.unevaluatedProperties===void 0&&(r=void 0);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}else r=void 0;i.push(t)}}),i.length?{allOf:i,...r}:void 0}function KC(e,t){let n=typeof e.value;return n!==`bigint`&&n!==`number`&&n!==`boolean`&&n!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:t.target===`openApi3`?{type:n===`bigint`?`integer`:n,enum:[e.value]}:{type:n===`bigint`?`integer`:n,const:e.value}}var qC=void 0,JC={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(qC===void 0&&(qC=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),qC),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function YC(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:CS(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t);break;case`max`:CS(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`email`:switch(t.emailStrategy){case`format:email`:$C(n,`email`,r.message,t);break;case`format:idn-email`:$C(n,`idn-email`,r.message,t);break;case`pattern:zod`:ew(n,JC.email,r.message,t);break}break;case`url`:$C(n,`uri`,r.message,t);break;case`uuid`:$C(n,`uuid`,r.message,t);break;case`regex`:ew(n,r.regex,r.message,t);break;case`cuid`:ew(n,JC.cuid,r.message,t);break;case`cuid2`:ew(n,JC.cuid2,r.message,t);break;case`startsWith`:ew(n,RegExp(`^${XC(r.value,t)}`),r.message,t);break;case`endsWith`:ew(n,RegExp(`${XC(r.value,t)}$`),r.message,t);break;case`datetime`:$C(n,`date-time`,r.message,t);break;case`date`:$C(n,`date`,r.message,t);break;case`time`:$C(n,`time`,r.message,t);break;case`duration`:$C(n,`duration`,r.message,t);break;case`length`:CS(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t),CS(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`includes`:ew(n,RegExp(XC(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&$C(n,`ipv4`,r.message,t),r.version!==`v4`&&$C(n,`ipv6`,r.message,t);break;case`base64url`:ew(n,JC.base64url,r.message,t);break;case`jwt`:ew(n,JC.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&ew(n,JC.ipv4Cidr,r.message,t),r.version!==`v4`&&ew(n,JC.ipv6Cidr,r.message,t);break;case`emoji`:ew(n,JC.emoji(),r.message,t);break;case`ulid`:ew(n,JC.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:$C(n,`binary`,r.message,t);break;case`contentEncoding:base64`:CS(n,`contentEncoding`,`base64`,r.message,t);break;case`pattern:zod`:ew(n,JC.base64,r.message,t);break}break;case`nanoid`:ew(n,JC.nanoid,r.message,t);case`toLowerCase`:case`toUpperCase`:case`trim`:break;default:(e=>{})(r)}return n}function XC(e,t){return t.patternStrategy===`escape`?QC(e):e}var ZC=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function QC(e){let t=``;for(let n=0;n<e.length;n++)ZC.has(e[n])||(t+=`\\`),t+=e[n];return t}function $C(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):CS(e,`format`,t,n,r)}function ew(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:tw(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):CS(e,`pattern`,tw(t,r),n,r)}function tw(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
|
|
85
|
+
]))`;continue}else if(r[e]===`$`){i+=`($|(?=[\r
|
|
86
|
+
]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r\n`:`[${r[e]}\r\n]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function nw(e,t){if(t.target===`openAi`&&console.warn(`Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.`),t.target===`openApi3`&&e.keyType?._def.typeName===U.ZodEnum)return{type:`object`,required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,r)=>({...n,[r]:ww(e.valueType._def,{...t,currentPath:[...t.currentPath,`properties`,r]})??NC(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let n={type:`object`,additionalProperties:ww(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(t.target===`openApi3`)return n;if(e.keyType?._def.typeName===U.ZodString&&e.keyType._def.checks?.length){let{type:r,...i}=YC(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===U.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===U.ZodBranded&&e.keyType._def.type._def.typeName===U.ZodString&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=LC(e.keyType._def,t);return{...n,propertyNames:i}}return n}function rw(e,t){return t.mapStrategy===`record`?nw(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[ww(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||NC(t),ww(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||NC(t)],minItems:2,maxItems:2}}}function iw(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function aw(e){return e.target===`openAi`?void 0:{not:NC({...e,currentPath:[...e.currentPath,`not`]})}}function ow(e){return e.target===`openApi3`?{enum:[`null`],nullable:!0}:{type:`null`}}var sw={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function cw(e,t){if(t.target===`openApi3`)return lw(e,t);let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in sw&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=sw[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return lw(e,t)}var lw=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>ww(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function uw(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target===`openApi3`?{type:sw[e.innerType._def.typeName],nullable:!0}:{type:[sw[e.innerType._def.typeName],`null`]};if(t.target===`openApi3`){let n=ww(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&`$ref`in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let n=ww(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function dw(e,t){let n={type:`number`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`int`:n.type=`integer`,SS(n,`type`,r.message,t);break;case`min`:t.target===`jsonSchema7`?r.inclusive?CS(n,`minimum`,r.value,r.message,t):CS(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),CS(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?CS(n,`maximum`,r.value,r.message,t):CS(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),CS(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:CS(n,`multipleOf`,r.value,r.message,t);break}return n}function fw(e,t){let n=t.target===`openAi`,r={type:`object`,properties:{}},i=[],a=e.shape();for(let e in a){let o=a[e];if(o===void 0||o._def===void 0)continue;let s=mw(o);s&&n&&(o._def.typeName===`ZodOptional`&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);let c=ww(o._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});c!==void 0&&(r.properties[e]=c,s||i.push(e))}i.length&&(r.required=i);let o=pw(e,t);return o!==void 0&&(r.additionalProperties=o),r}function pw(e,t){if(e.catchall._def.typeName!==`ZodNever`)return ww(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function mw(e){try{return e.isOptional()}catch{return!0}}var hw=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return ww(e.innerType._def,t);let n=ww(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:NC(t)},n]}:NC(t)},gw=(e,t)=>{if(t.pipeStrategy===`input`)return ww(e.in._def,t);if(t.pipeStrategy===`output`)return ww(e.out._def,t);let n=ww(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,ww(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function _w(e,t){return ww(e.type._def,t)}function vw(e,t){let n={type:`array`,uniqueItems:!0,items:ww(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&CS(n,`minItems`,e.minSize.value,e.minSize.message,t),e.maxSize&&CS(n,`maxItems`,e.maxSize.value,e.maxSize.message,t),n}function yw(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>ww(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:ww(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>ww(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function bw(e){return{not:NC(e)}}function xw(e){return NC(e)}var Sw=(e,t)=>ww(e.innerType._def,t),Cw=(e,t,n)=>{switch(t){case U.ZodString:return YC(e,n);case U.ZodNumber:return dw(e,n);case U.ZodObject:return fw(e,n);case U.ZodBigInt:return FC(e,n);case U.ZodBoolean:return IC();case U.ZodDate:return zC(e,n);case U.ZodUndefined:return bw(n);case U.ZodNull:return ow(n);case U.ZodArray:return PC(e,n);case U.ZodUnion:case U.ZodDiscriminatedUnion:return cw(e,n);case U.ZodIntersection:return GC(e,n);case U.ZodTuple:return yw(e,n);case U.ZodRecord:return nw(e,n);case U.ZodLiteral:return KC(e,n);case U.ZodEnum:return UC(e);case U.ZodNativeEnum:return iw(e);case U.ZodNullable:return uw(e,n);case U.ZodOptional:return hw(e,n);case U.ZodMap:return rw(e,n);case U.ZodSet:return vw(e,n);case U.ZodLazy:return()=>e.getter()._def;case U.ZodPromise:return _w(e,n);case U.ZodNaN:case U.ZodNever:return aw(n);case U.ZodEffects:return HC(e,n);case U.ZodAny:return NC(n);case U.ZodUnknown:return xw(n);case U.ZodDefault:return VC(e,n);case U.ZodBranded:return LC(e,n);case U.ZodReadonly:return Sw(e,n);case U.ZodCatch:return RC(e,n);case U.ZodPipeline:return gw(e,n);case U.ZodFunction:case U.ZodVoid:case U.ZodSymbol:return;default:return(e=>void 0)(t)}};function ww(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==vS)return i}if(r&&!n){let e=Tw(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=Cw(e,e.typeName,t),o=typeof a==`function`?ww(a(),t):a;if(o&&Ew(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var Tw=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:wS(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),NC(t)):t.$refStrategy===`seen`?NC(t):void 0}},Ew=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n),Dw=(e,t)=>{let n=xS(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:ww(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??NC(n)}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=ww(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??NC(n),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o),n.flags.hasReferencedOpenAiAnyType&&(r||={},r[n.openAiAnyTypeName]||(r[n.openAiAnyTypeName]={type:[`string`,`number`,`integer`,`boolean`,`array`,`null`],items:{$ref:n.$refStrategy===`relative`?`1`:[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join(`/`)}}));let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return n.target===`jsonSchema7`?s.$schema=`http://json-schema.org/draft-07/schema#`:(n.target===`jsonSchema2019-09`||n.target===`openAi`)&&(s.$schema=`https://json-schema.org/draft/2019-09/schema#`),n.target===`openAi`&&(`anyOf`in s||`oneOf`in s||`allOf`in s||`type`in s&&Array.isArray(s.type))&&console.warn(`Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.`),s},Ow=class{constructor(e,t){this.catalogs=e,this.actionHandler=t,this.model=new gS,this.actionHandler&&this.model.onAction.subscribe(this.actionHandler)}getClientCapabilities(e){let t={"v0.9":{supportedCatalogIds:this.catalogs.map(e=>e.id)}};return e?.includeInlineCatalogs&&(t[`v0.9`].inlineCatalogs=this.catalogs.map(e=>this.generateInlineCatalog(e))),t}generateInlineCatalog(e){let t={};for(let[n,r]of e.components.entries()){let e=Dw(r.schema,{target:`jsonSchema2019-09`});this.processRefs(e),t[n]={allOf:[{$ref:`common_types.json#/$defs/ComponentCommon`},{properties:{component:{const:n},...e.properties},required:[`component`,...e.required||[]]}]}}let n=[];for(let t of e.functions.values()){let e=Dw(t.schema,{target:`jsonSchema2019-09`});this.processRefs(e),n.push({name:t.name,description:t.schema.description,returnType:t.returnType,parameters:e})}let r;if(e.themeSchema){let t=Dw(e.themeSchema,{target:`jsonSchema2019-09`});this.processRefs(t),r=t.properties}return{catalogId:e.id,components:t,functions:n.length>0?n:void 0,theme:r}}processRefs(e){if(!(typeof e!=`object`||!e)){if(typeof e.description==`string`&&e.description.startsWith(`REF:`)){let t=e.description.substring(4).split(`|`),n=t[0],r=t[1]||``;for(let t of Object.keys(e))delete e[t];e.$ref=n,r&&(e.description=r);return}if(Array.isArray(e))for(let t of e)this.processRefs(t);else for(let t of Object.keys(e))this.processRefs(e[t])}}getClientDataModel(){let e={};for(let t of this.model.surfacesMap.values())t.sendDataModel&&(e[t.id]=t.dataModel.get(`/`));if(Object.keys(e).length!==0)return{version:`v0.9`,surfaces:e}}onSurfaceCreated(e){return this.model.onSurfaceCreated.subscribe(e)}onSurfaceDeleted(e){return this.model.onSurfaceDeleted.subscribe(e)}processMessages(e){for(let t of e)this.processMessage(t)}processMessage(e){let t=[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`].filter(t=>t in e);if(t.length>1)throw new Ax(`Message contains multiple update types: ${t.join(`, `)}.`);if(`createSurface`in e){this.processCreateSurfaceMessage(e);return}if(`deleteSurface`in e){this.processDeleteSurfaceMessage(e);return}if(`updateComponents`in e){this.processUpdateComponentsMessage(e);return}if(`updateDataModel`in e){this.processUpdateDataModelMessage(e);return}}processCreateSurfaceMessage(e){let{surfaceId:t,catalogId:n,theme:r,sendDataModel:i}=e.createSurface,a=this.catalogs.find(e=>e.id===n);if(!a)throw new Nx(`Catalog not found: ${n}`);if(this.model.getSurface(t))throw new Nx(`Surface ${t} already exists.`);let o=new hS(t,a,r,i??!1);this.model.addSurface(o)}processDeleteSurfaceMessage(e){let t=e.deleteSurface;t.surfaceId&&this.model.deleteSurface(t.surfaceId)}processUpdateComponentsMessage(e){let t=e.updateComponents;if(!t.surfaceId)return;let n=this.model.getSurface(t.surfaceId);if(!n)throw new Nx(`Surface not found for message: ${t.surfaceId}`);for(let e of t.components){let{id:t,component:r,...i}=e;if(!t)throw new Ax(`Component '${r}' is missing an 'id'.`);let a=n.componentsModel.get(t);if(a)if(r&&r!==a.type){n.componentsModel.removeComponent(t);let e=new _S(t,r,i);n.componentsModel.addComponent(e)}else a.properties=i;else{if(!r)throw new Ax(`Cannot create component ${t} without a type.`);let e=new _S(t,r,i);n.componentsModel.addComponent(e)}}}processUpdateDataModelMessage(e){let t=e.updateDataModel;if(!t.surfaceId)return;let n=this.model.getSurface(t.surfaceId);if(!n)throw new Nx(`Surface not found for message: ${t.surfaceId}`);let r=t.path||`/`,i=t.value;n.dataModel.set(r,i)}resolvePath(e,t){return e.startsWith(`/`)?e:t?`${t.endsWith(`/`)?t:`${t}/`}${e}`:`/${e}`}},kw=class e{constructor(e,t){this.surface=e,this.path=t,this.dataModel=e.dataModel,this.functionInvoker=e.catalog.invoker}set(e,t){let n=this.resolvePath(e);this.dataModel.set(n,t)}resolveDynamicValue(e){if(typeof e!=`object`||!e||Array.isArray(e))return e;if(`path`in e){let t=this.resolvePath(e.path);return this.dataModel.get(t)}if(`call`in e){let t=e,n={};for(let[e,r]of Object.entries(t.args))n[e]=this.resolveDynamicValue(r);let r=new AbortController,i=this.evaluateFunctionReactive(t.call,n,r.signal);return i===void 0?void 0:Px(i)?i.peek():i}return e}subscribeDynamicValue(e,t){let n=this.resolveSignal(e),r=!0,i=n.peek(),a=lS(()=>{let e=n.value;i=e,r||t(e)});return r=!1,{get value(){return i},unsubscribe:()=>{a(),n.unsubscribe&&n.unsubscribe()}}}resolveSignal(e){if(typeof e!=`object`||!e||Array.isArray(e))return $x(e);if(`path`in e){let t=this.resolvePath(e.path);return this.dataModel.getSignal(t)}if(`call`in e){let t=e,n={};for(let[e,r]of Object.entries(t.args))n[e]=this.resolveSignal(r);if(Object.keys(n).length===0){let e=new AbortController,n=this.evaluateFunctionReactive(t.call,{},e.signal),r=n instanceof Qx?n:$x(n);return r.unsubscribe=()=>e.abort(),r}let r=Object.keys(n),i=$x(void 0),a,o,s=iS(()=>{let e={};for(let t=0;t<r.length;t++)e[r[t]]=n[r[t]].value;return e}),c=lS(()=>{try{let e=s.value;a&&a.abort(),o&&=(o(),void 0),a=new AbortController;let n=this.evaluateFunctionReactive(t.call,e,a.signal);Px(n)?o=lS(()=>{i.value=n.value}):i.value=n}catch(e){this.dispatchExpressionError(e,t.call),i.value=void 0}});return i.unsubscribe=()=>{c(),o&&o(),a&&a.abort();for(let e=0;e<r.length;e++){let t=n[r[e]];t.unsubscribe&&t.unsubscribe()}},i}return $x(e)}resolveAction(e){if(`event`in e){let t={};if(e.event.context)for(let[n,r]of Object.entries(e.event.context))t[n]=this.resolveDynamicValue(r);return{event:{...e.event,context:t}}}return`functionCall`in e?this.resolveDynamicValue(e.functionCall):e}evaluateFunctionReactive(e,t,n){try{return this.functionInvoker(e,t,this,n)}catch(t){this.dispatchExpressionError(t,e);return}}dispatchExpressionError(e,t){if(e?.name===`ZodError`||e instanceof lb){let n=new Mx(`Validation failed for function '${t}': ${e.message}`,t,e.errors??e.issues);this.surface.dispatchError({code:`EXPRESSION_ERROR`,message:n.message,expression:t,details:n.details})}else e instanceof Mx?this.surface.dispatchError({code:`EXPRESSION_ERROR`,message:e.message,expression:e.expression,details:e.details}):this.surface.dispatchError({code:`EXPRESSION_ERROR`,message:e.message??`An unexpected error occurred in function ${t}.`,expression:t,details:{stack:e.stack}})}nested(t){let n=this.resolvePath(t);return new e(this.surface,n)}resolvePath(e){if(e.startsWith(`/`))return e;if(e===``||e===`.`)return this.path;let t=this.path;return t.endsWith(`/`)&&t.length>1&&(t=t.slice(0,-1)),t===`/`&&(t=``),`${t}/${e}`}},Aw=class{constructor(e,t,n=`/`){let r=e.componentsModel.get(t);if(!r)throw new Nx(`Component not found: ${t}`);this.componentModel=r,this.surfaceComponents=e.componentsModel,this.dataContext=new kw(e,n),this._actionDispatcher=t=>e.dispatchAction(t,this.componentModel.id)}dispatchAction(e){return this._actionDispatcher(e)}};function jw(e){return Mw(e)}function Mw(e,t){let n=e;for(;n._def.typeName===`ZodOptional`||n._def.typeName===`ZodNullable`||n._def.typeName===`ZodDefault`;)n=n._def.innerType;if(t===`checks`)return{type:`CHECKABLE`};if(n._def.typeName===`ZodUnion`){let e=n._def.options;if(e.some(e=>e._def.typeName===`ZodObject`&&e._def.shape().event))return{type:`ACTION`};if(e.some(e=>e._def.typeName===`ZodObject`&&e._def.shape().path&&!e._def.shape().componentId))return{type:`DYNAMIC`};if(e.some(e=>e._def.typeName===`ZodObject`&&e._def.shape().componentId&&e._def.shape().path))return{type:`STRUCTURAL`}}else n._def.typeName;if(n._def.typeName===`ZodArray`)return{type:`ARRAY`,element:Mw(n._def.type)};if(n._def.typeName===`ZodObject`){let e={},t=n._def.shape();for(let[n,r]of Object.entries(t))e[n]=Mw(r,n);return{type:`OBJECT`,shape:e}}return{type:`STATIC`}}var Nw=class{constructor(e,t){this.dataListeners=[],this.propsListeners=[],this.currentProps={},this.isConnected=!1,this.context=e,this.behaviorTree=jw(t),this.behaviorTree.type!==`OBJECT`&&(this.behaviorTree={type:`OBJECT`,shape:{}}),this.resolveInitialProps()}resolveInitialProps(){let e=this.context.componentModel.properties,t=this.resolveAndBind(e,this.behaviorTree,[],!0);this.currentProps={...this.currentProps,...t}}connect(){if(this.isConnected)return;this.isConnected=!0;let e=this.context.componentModel.onUpdated.subscribe(()=>{this.rebuildAllBindings()});this.compUnsub=()=>e.unsubscribe(),this.rebuildAllBindings()}rebuildAllBindings(){this.dataListeners.forEach(e=>e()),this.dataListeners=[];let e=this.context.componentModel.properties,t=this.resolveAndBind(e,this.behaviorTree,[],!1);this.currentProps={...this.currentProps,...t},this.notify()}resolveAndBind(e,t,n,r){if(e==null)return e;switch(t.type){case`DYNAMIC`:{let t=this.context.dataContext.subscribeDynamicValue(e,e=>{this.updateDeepValue(n,e),this.notify()});return r?t.unsubscribe():this.dataListeners.push(()=>t.unsubscribe()),t.value}case`ACTION`:return()=>{let t=e=>{if(typeof e!=`object`||!e)return e;if(`path`in e||`call`in e)return this.context.dataContext.resolveDynamicValue(e);if(Array.isArray(e))return e.map(t);let n={};for(let[r,i]of Object.entries(e))n[r]=t(i);return n};this.context.dispatchAction(t(e))};case`STRUCTURAL`:if(e&&typeof e==`object`&&e.path&&e.componentId){let t=this.context.dataContext.subscribeDynamicValue({path:e.path},t=>{let r=Array.isArray(t)?t:[],i=this.context.dataContext.nested(e.path),a=r.map((t,n)=>({id:e.componentId,basePath:i.nested(String(n)).path}));this.updateDeepValue(n,a),this.notify()});r?t.unsubscribe():this.dataListeners.push(()=>t.unsubscribe());let i=Array.isArray(t.value)?t.value:[],a=this.context.dataContext.nested(e.path);return i.map((t,n)=>({id:e.componentId,basePath:a.nested(String(n)).path}))}return e;case`CHECKABLE`:{let t=Array.isArray(e)?e:[],i=t.map(()=>({valid:!0,message:``})),a=n.slice(0,-1),o=()=>{let e=i.filter(e=>!e.valid).map(e=>e.message);this.updateDeepValue([...a,`isValid`],e.length===0),this.updateDeepValue([...a,`validationErrors`],e),this.notify()};t.forEach((e,t)=>{let n=e.condition||e,a=e.message||`Validation failed`;i[t].message=a;let s=this.context.dataContext.subscribeDynamicValue(n,e=>{i[t].valid=!!e,o()});r?s.unsubscribe():this.dataListeners.push(()=>s.unsubscribe()),i[t].valid=!!s.value});let s=i.filter(e=>!e.valid).map(e=>e.message);return this.updateDeepValue([...a,`isValid`],s.length===0),this.updateDeepValue([...a,`validationErrors`],s),e}case`STATIC`:return e;case`ARRAY`:return Array.isArray(e)?e.map((e,i)=>this.resolveAndBind(e,t.element,[...n,i.toString()],r)):e;case`OBJECT`:{if(typeof e!=`object`)return e;let i={};for(let[a,o]of Object.entries(e)){let e=t.shape[a]||{type:`STATIC`};i[a]=this.resolveAndBind(o,e,[...n,a],r)}for(let[n,r]of Object.entries(t.shape))if(r.type===`DYNAMIC`){let t=`set${n.charAt(0).toUpperCase()+n.slice(1)}`,r=e[n];i[t]=e=>{r&&typeof r==`object`&&`path`in r&&this.context.dataContext.set(r.path,e)}}return i}}}updateDeepValue(e,t){this.currentProps=this.cloneAndUpdate(this.currentProps,e,t)}cloneAndUpdate(e,t,n){if(t.length===0)return n;let[r,...i]=t;if(Array.isArray(e)){let t=[...e];return t[Number(r)]=this.cloneAndUpdate(t[Number(r)],i,n),t}else return{...e||{},[r]:this.cloneAndUpdate((e||{})[r],i,n)}}dispose(){this.isConnected&&(this.isConnected=!1,this.dataListeners.forEach(e=>e()),this.dataListeners=[],this.compUnsub&&=(this.compUnsub(),void 0))}notify(){this.propsListeners.forEach(e=>e(this.currentProps))}subscribe(e){return this.propsListeners.length===0&&this.connect(),this.propsListeners.push(e),{unsubscribe:()=>{this.propsListeners=this.propsListeners.filter(t=>t!==e),this.propsListeners.length===0&&this.dispose()}}}get snapshot(){return this.currentProps}},Pw=Sx({path:_x().describe(`A JSON Pointer path to a value in the data model.`)}).describe(`REF:common_types.json#/$defs/DataBinding|A JSON Pointer path to a value in the data model.`),Fw=Sx({call:_x().describe(`The name of the function to call.`),args:wx(bx()).describe(`Arguments passed to the function.`),returnType:Ex([`string`,`number`,`boolean`,`array`,`object`,`any`,`void`]).default(`boolean`)}).describe(`REF:common_types.json#/$defs/FunctionCall|Invokes a named function on the client.`),Iw=Cx([yx(),Pw,Fw]).describe(`REF:common_types.json#/$defs/DynamicBoolean|A boolean value that can be a literal, a path, or a function call returning a boolean.`),Lw=Cx([_x(),Pw,Fw]).describe(`REF:common_types.json#/$defs/DynamicString|Represents a string`),Rw=Cx([vx(),Pw,Fw]).describe(`REF:common_types.json#/$defs/DynamicNumber|Represents a value that can be either a literal number, a path to a number in the data model, or a function call returning a number.`),zw=Cx([xx(_x()),Pw,Fw]).describe(`REF:common_types.json#/$defs/DynamicStringList|Represents a value that can be either a literal array of strings, a path to a string array in the data model, or a function call returning a string array.`),Bw=Cx([_x(),vx(),yx(),xx(bx()),Pw,Fw]).describe(`REF:common_types.json#/$defs/DynamicValue|A value that can be a literal, a path, or a function call returning any type.`),Vw=_x().describe(`REF:common_types.json#/$defs/ComponentId|The unique identifier for a component.`),Hw=Cx([xx(Vw).describe(`A static list of child component IDs.`),Sx({componentId:Vw,path:_x().describe(`The path to the list of component property objects in the data model.`)}).describe(`A template for generating a dynamic list of children.`)]).describe(`REF:common_types.json#/$defs/ChildList`),Uw=Cx([Sx({event:Sx({name:_x(),context:wx(Bw).optional()})}).describe(`Triggers a server-side event.`),Sx({functionCall:Fw}).describe(`Executes a local client-side function.`)]).describe(`REF:common_types.json#/$defs/Action`),Ww=Sx({condition:Iw,message:_x().describe(`The error message to display if the check fails.`)}).describe(`REF:common_types.json#/$defs/CheckRule|A check rule consisting of a condition and an error message.`),Gw=Sx({checks:xx(Ww).optional().describe(`A list of checks to perform.`)}).describe(`REF:common_types.json#/$defs/Checkable|Properties for components that support client-side checks.`),Kw=Sx({label:Lw.optional().describe(`REF:common_types.json#/$defs/DynamicString|A short string used by assistive technologies to convey the purpose of an element.`),description:Lw.optional().describe(`REF:common_types.json#/$defs/DynamicString|Additional information provided by assistive technologies about an element.`)}).describe(`REF:common_types.json#/$defs/AccessibilityAttributes|Attributes to enhance accessibility.`),qw={ComponentId:Vw,ChildList:Hw,DataBinding:Pw,DynamicValue:Bw,DynamicString:Lw,DynamicNumber:Rw,DynamicBoolean:Iw,DynamicStringList:zw,FunctionCall:Fw,CheckRule:Ww,Checkable:Gw,Action:Uw,AccessibilityAttributes:Kw,AnyComponent:Sx({component:_x().describe(`The type name of the component.`),id:Vw.optional(),weight:vx().optional()}).passthrough().describe(`A generic A2UI component definition.`)};function Jw(e,t){let n=(0,v.memo)(t,(e,t)=>!(e.props!==t.props||e.context.componentModel.id!==t.context.componentModel.id||e.context.dataContext.path!==t.context.dataContext.path));return{name:e.name,schema:e.schema,render:({context:t,buildChild:r})=>{let i=(0,v.useRef)(null);i.current?i.current.context!==t&&(i.current.dispose(),i.current=new Nw(t,e.schema)):i.current=new Nw(t,e.schema);let a=i.current,o=(0,v.useSyncExternalStore)((0,v.useCallback)(e=>{let t=a.subscribe(e);return()=>t.unsubscribe()},[a]),(0,v.useCallback)(()=>a.snapshot,[a]));return(0,v.useEffect)(()=>()=>a.dispose(),[a]),(0,O.jsx)(n,{props:o||{},buildChild:r,context:t})}}}var Yw=`16px`,Xw=`1px solid #ccc`,Zw=e=>{switch(e){case`center`:return`center`;case`end`:return`flex-end`;case`spaceAround`:return`space-around`;case`spaceBetween`:return`space-between`;case`spaceEvenly`:return`space-evenly`;case`start`:return`flex-start`;case`stretch`:return`stretch`;default:return`flex-start`}},Qw=e=>{switch(e){case`start`:return`flex-start`;case`center`:return`center`;case`end`:return`flex-end`;case`stretch`:return`stretch`;default:return`stretch`}},$w=()=>({margin:`8px`,boxSizing:`border-box`}),eT=()=>({margin:`8px`,padding:Yw,border:Xw,borderRadius:`8px`,boxSizing:`border-box`}),tT=class e{static{this.MAX_DEPTH=10}parse(t,n=0){if(n>e.MAX_DEPTH)throw new Mx(`Max recursion depth reached in parse`);if(!t||!t.includes("${"))return[t];let r=[],i=new nT(t);for(;!i.isAtEnd();)if(i.matches("${")){i.advance(2);let e=this.extractInterpolationContent(i),t=this.parseExpression(e,n+1);t!==null&&r.push(t)}else if(i.peek()===`\\`&&i.peek(1)===`$`&&i.peek(2)===`{`)i.advance(),r.push("${"),i.advance(2);else{let e=i.pos;for(;!i.isAtEnd()&&!(i.matches("${")||i.peek()===`\\`&&i.peek(1)===`$`&&i.peek(2)===`{`);)i.advance();r.push(i.input.substring(e,i.pos))}return r.filter(e=>e!==null&&e!==``)}extractInterpolationContent(e){let t=e.pos,n=1;for(;!e.isAtEnd()&&n>0;){let t=e.advance();if(t===`{`)n++;else if(t===`}`)n--;else if(t===`'`||t===`"`){let n=t;for(;!e.isAtEnd();){let t=e.advance();if(t===`\\`)e.advance();else if(t===n)break}}}if(n>0)throw new Mx(`Unclosed interpolation: missing '}'`);return e.input.substring(t,e.pos-1)}parseExpression(e,t=0){if(e=e.trim(),!e)return``;let n=new nT(e),r=this.parseExpressionInternal(n,t);if(!n.isAtEnd())throw new Mx(`Unexpected characters at end of expression: '${n.input.substring(n.pos)}'`);return r}parseExpressionInternal(e,t){if(e.skipWhitespace(),e.isAtEnd())return``;if(e.matches("${")){e.advance(2);let n=this.extractInterpolationContent(e);return this.parseExpression(n,t+1)}if(e.matchesString(`'`)||e.matchesString(`"`))return this.parseStringLiteral(e);if(this.isDigit(e.peek()))return this.parseNumberLiteral(e);if(e.matchesKeyword(`true`))return!0;if(e.matchesKeyword(`false`))return!1;if(e.matchesKeyword(`null`))return``;let n=this.scanPathOrIdentifier(e);return e.skipWhitespace(),e.peek()===`(`?this.parseFunctionCall(n,e,t):n?{path:n}:``}scanPathOrIdentifier(e){let t=e.pos;for(;!e.isAtEnd();){let t=e.peek();if(this.isAlnum(t)||t===`/`||t===`.`||t===`_`||t===`-`)e.advance();else break}return e.input.substring(t,e.pos)}parseFunctionCall(e,t,n){t.match(`(`),t.skipWhitespace();let r={};for(;!t.isAtEnd()&&t.peek()!==`)`;){let i=this.scanIdentifier(t);if(t.skipWhitespace(),!t.match(`:`))throw new Mx(`Expected ':' after argument name '${i}' in function '${e}'`);t.skipWhitespace(),r[i]=this.parseExpressionInternal(t,n),t.skipWhitespace(),t.peek()===`,`&&(t.advance(),t.skipWhitespace())}if(!t.match(`)`))throw new Mx(`Expected ')' after function arguments for '${e}'`);return{call:e,args:r,returnType:`any`}}scanIdentifier(e){let t=e.pos;for(;!e.isAtEnd()&&(this.isAlnum(e.peek())||e.peek()===`_`);)e.advance();return e.input.substring(t,e.pos)}parseStringLiteral(e){let t=e.advance(),n=``;for(;!e.isAtEnd();){let r=e.advance();if(r===`\\`){let t=e.advance();t===`n`?n+=`
|
|
87
|
+
`:t===`t`?n+=` `:t===`r`?n+=`\r`:n+=t}else if(r===t)break;else n+=r}return n}parseNumberLiteral(e){let t=e.pos;for(;!e.isAtEnd()&&(this.isDigit(e.peek())||e.peek()===`.`);)e.advance();return Number(e.input.substring(t,e.pos))}isAlnum(e){return e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e>=`0`&&e<=`9`}isDigit(e){return e>=`0`&&e<=`9`}},nT=class{constructor(e){this.input=e,this.pos=0}isAtEnd(){return this.pos>=this.input.length}peek(e=0){return this.pos+e>=this.input.length?`\0`:this.input[this.pos+e]}advance(e=1){let t=this.input.substring(this.pos,this.pos+e);return this.pos+=e,t}match(e){return this.peek()===e?(this.advance(),!0):!1}matches(e){return!!this.input.startsWith(e,this.pos)}matchesString(e){return this.peek()===e}matchesKeyword(e){if(this.input.startsWith(e,this.pos)){let t=this.peek(e.length);if(!/[a-zA-Z0-9_]/.test(t))return this.advance(e.length),!0}return!1}skipWhitespace(){for(;!this.isAtEnd()&&/\s/.test(this.peek());)this.advance()}},rT=365.2425,iT=6048e5,aT=864e5,oT=3600*24;oT*7,oT*rT/12*3;var sT=Symbol.for(`constructDateFrom`);function cT(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&sT in e?e[sT](t):e instanceof Date?new e.constructor(t):new Date(t)}function lT(e,t){return cT(t||e,e)}var uT={};function dT(){return uT}function fT(e,t){let n=dT(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=lT(e,t?.in),a=i.getDay(),o=(a<r?7:0)+a-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function pT(e,t){return fT(e,{...t,weekStartsOn:1})}function mT(e,t){let n=lT(e,t?.in),r=n.getFullYear(),i=cT(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=pT(i),o=cT(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=pT(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function hT(e){let t=lT(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function gT(e,...t){let n=cT.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function _T(e,t){let n=lT(e,t?.in);return n.setHours(0,0,0,0),n}function vT(e,t,n){let[r,i]=gT(n?.in,e,t),a=_T(r),o=_T(i),s=+a-hT(a),c=+o-hT(o);return Math.round((s-c)/aT)}function yT(e,t){let n=mT(e,t),r=cT(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),pT(r)}function bT(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function xT(e){return!(!bT(e)&&typeof e!=`number`||isNaN(+lT(e)))}function ST(e,t){let n=lT(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}var CT={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},wT=(e,t,n)=>{let r,i=CT[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r};function TT(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var ET={date:TT({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:TT({formats:{full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},defaultWidth:`full`}),dateTime:TT({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},DT={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},OT=(e,t,n,r)=>DT[e];function kT(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}var AT={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},era:kT({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:kT({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:kT({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},defaultWidth:`wide`}),day:kT({values:{narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},defaultWidth:`wide`}),dayPeriod:kT({values:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},defaultFormattingWidth:`wide`})};function jT(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?NT(s,e=>e.test(o)):MT(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function MT(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function NT(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function PT(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}var FT={code:`en-US`,formatDistance:wT,formatLong:ET,formatRelative:OT,localize:AT,match:{ordinalNumber:PT({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:jT({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:`any`}),quarter:jT({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:jT({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:jT({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:jT({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function IT(e,t){let n=lT(e,t?.in);return vT(n,ST(n))+1}function LT(e,t){let n=lT(e,t?.in),r=pT(n)-+yT(n);return Math.round(r/iT)+1}function RT(e,t){let n=lT(e,t?.in),r=n.getFullYear(),i=dT(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=cT(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=fT(o,t),c=cT(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=fT(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function zT(e,t){let n=dT(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=RT(e,t),a=cT(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),fT(a,t)}function BT(e,t){let n=lT(e,t?.in),r=fT(n,t)-+zT(n,t);return Math.round(r/iT)+1}function VT(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var HT={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return VT(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):VT(n+1,2)},d(e,t){return VT(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return VT(e.getHours()%12||12,t.length)},H(e,t){return VT(e.getHours(),t.length)},m(e,t){return VT(e.getMinutes(),t.length)},s(e,t){return VT(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return VT(Math.trunc(r*10**(n-3)),t.length)}},UT={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},WT={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return HT.y(e,t)},Y:function(e,t,n,r){let i=RT(e,r),a=i>0?i:1-i;return t===`YY`?VT(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):VT(a,t.length)},R:function(e,t){return VT(mT(e),t.length)},u:function(e,t){return VT(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return VT(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return VT(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return HT.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return VT(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=BT(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):VT(i,t.length)},I:function(e,t,n){let r=LT(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):VT(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):HT.d(e,t)},D:function(e,t,n){let r=IT(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):VT(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return VT(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return VT(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return VT(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?UT.noon:r===0?UT.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?UT.evening:r>=12?UT.afternoon:r>=4?UT.morning:UT.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return HT.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):HT.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):VT(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):VT(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):HT.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):HT.s(e,t)},S:function(e,t){return HT.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return KT(r);case`XXXX`:case`XX`:return qT(r);default:return qT(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return KT(r);case`xxxx`:case`xx`:return qT(r);default:return qT(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+GT(r,`:`);default:return`GMT`+qT(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+GT(r,`:`);default:return`GMT`+qT(r,`:`)}},t:function(e,t,n){return VT(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return VT(+e,t.length)}};function GT(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+VT(a,2)}function KT(e,t){return e%60==0?(e>0?`-`:`+`)+VT(Math.abs(e)/60,2):qT(e,t)}function qT(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=VT(Math.trunc(r/60),2),a=VT(r%60,2);return n+i+t+a}var JT=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},YT=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},XT={p:YT,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return JT(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,JT(r,t)).replace(`{{time}}`,YT(i,t))}},ZT=/^D+$/,QT=/^Y+$/,$T=[`D`,`DD`,`YY`,`YYYY`];function eE(e){return ZT.test(e)}function tE(e){return QT.test(e)}function nE(e,t,n){let r=rE(e,t,n);if(console.warn(r),$T.includes(e))throw RangeError(r)}function rE(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var iE=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,aE=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,oE=/^'([^]*?)'?$/,sE=/''/g,cE=/[a-zA-Z]/;function lE(e,t,n){let r=dT(),i=n?.locale??r.locale??FT,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=lT(e,n?.in);if(!xT(s))throw RangeError(`Invalid time value`);let c=t.match(aE).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=XT[t];return n(e,i.formatLong)}return e}).join(``).match(iE).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:uE(e)};if(WT[t])return{isToken:!0,value:e};if(t.match(cE))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&tE(a)||!n?.useAdditionalDayOfYearTokens&&eE(a))&&nE(a,t,String(e));let o=WT[a[0]];return o(s,a,i.localize,l)}).join(``)}function uE(e){let t=e.match(oE);return t?t[1].replace(sE,`'`):e}var dE={name:`add`,returnType:`number`,schema:Sx({a:Dx(e=>e===null?void 0:e,Ox.number()),b:Dx(e=>e===null?void 0:e,Ox.number())})},fE={name:`subtract`,returnType:`number`,schema:Sx({a:Dx(e=>e===null?void 0:e,Ox.number()),b:Dx(e=>e===null?void 0:e,Ox.number())})},pE={name:`multiply`,returnType:`number`,schema:Sx({a:Dx(e=>e===null?void 0:e,Ox.number()),b:Dx(e=>e===null?void 0:e,Ox.number())})},mE={name:`divide`,returnType:`number`,schema:Sx({a:Dx(e=>e===null?void 0:e,Ox.number()),b:Dx(e=>e===null?void 0:e,Ox.number())})},hE={name:`equals`,returnType:`boolean`,schema:Sx({a:bx().refine(e=>e!==void 0,`Required`),b:bx().refine(e=>e!==void 0,`Required`)})},gE={name:`not_equals`,returnType:`boolean`,schema:Sx({a:bx().refine(e=>e!==void 0,`Required`),b:bx().refine(e=>e!==void 0,`Required`)})},_E={name:`greater_than`,returnType:`boolean`,schema:Sx({a:Dx(e=>e===null?void 0:e,Ox.number()),b:Dx(e=>e===null?void 0:e,Ox.number())})},vE={name:`less_than`,returnType:`boolean`,schema:Sx({a:Dx(e=>e===null?void 0:e,Ox.number()),b:Dx(e=>e===null?void 0:e,Ox.number())})},yE={name:`and`,returnType:`boolean`,schema:Sx({values:xx(bx()).min(2)})},bE={name:`or`,returnType:`boolean`,schema:Sx({values:xx(bx()).min(2)})},xE={name:`not`,returnType:`boolean`,schema:Sx({value:bx().refine(e=>e!==void 0,`Required`)})},SE={name:`contains`,returnType:`boolean`,schema:Sx({string:Dx(e=>e===void 0?void 0:String(e),_x()),substring:Dx(e=>e===void 0?void 0:String(e),_x())})},CE={name:`starts_with`,returnType:`boolean`,schema:Sx({string:Dx(e=>e===void 0?void 0:String(e),_x()),prefix:Dx(e=>e===void 0?void 0:String(e),_x())})},wE={name:`ends_with`,returnType:`boolean`,schema:Sx({string:Dx(e=>e===void 0?void 0:String(e),_x()),suffix:Dx(e=>e===void 0?void 0:String(e),_x())})},TE={name:`required`,returnType:`boolean`,schema:Sx({value:bx().refine(e=>e!==void 0,`Required`)})},EE={name:`regex`,returnType:`boolean`,schema:Sx({value:Dx(e=>e===void 0?void 0:String(e),_x()),pattern:Dx(e=>e===void 0?void 0:String(e),_x())})},DE={name:`length`,returnType:`boolean`,schema:Sx({value:bx().refine(e=>e!==void 0,`Required`),min:Ox.number().optional(),max:Ox.number().optional()}).refine(e=>e.min!==void 0||e.max!==void 0,{message:`Must provide either 'min' or 'max'`})},OE={name:`numeric`,returnType:`boolean`,schema:Sx({value:Ox.number(),min:Ox.number().optional(),max:Ox.number().optional()}).refine(e=>e.min!==void 0||e.max!==void 0,{message:`Must provide either 'min' or 'max'`})},kE={name:`email`,returnType:`boolean`,schema:Sx({value:Dx(e=>e===void 0?void 0:String(e),_x())})},AE={name:`formatString`,returnType:`any`,schema:Sx({value:Ox.string()})},jE={name:`formatNumber`,returnType:`string`,schema:Sx({value:Ox.number(),decimals:Ox.number().optional(),grouping:yx().default(!0)})},ME={name:`formatCurrency`,returnType:`string`,schema:Sx({value:Ox.number(),currency:Ox.string(),decimals:Ox.number().optional(),grouping:yx().default(!0)})},NE={name:`formatDate`,returnType:`string`,schema:Sx({value:bx().refine(e=>e!==void 0,`Required`),format:Ox.string()})},PE={name:`pluralize`,returnType:`string`,schema:Sx({value:Ox.number(),zero:Ox.string().optional(),one:Ox.string().optional(),two:Ox.string().optional(),few:Ox.string().optional(),many:Ox.string().optional(),other:Ox.string()}).passthrough()},FE={name:`openUrl`,returnType:`void`,schema:Sx({url:Dx(e=>e===void 0?void 0:String(e),_x())})},IE=[Fx(dE,e=>e.a+e.b),Fx(fE,e=>e.a-e.b),Fx(pE,e=>e.a*e.b),Fx(mE,e=>{let t=e.a,n=e.b;if(t==null||n==null)return NaN;let r=Number(t),i=Number(n);return Number.isNaN(r)||Number.isNaN(i)?NaN:i===0?1/0:r/i}),Fx(hE,e=>e.a===e.b),Fx(gE,e=>e.a!==e.b),Fx(_E,e=>e.a>e.b),Fx(vE,e=>e.a<e.b),Fx(yE,e=>e.values.every(e=>!!e)),Fx(bE,e=>e.values.some(e=>!!e)),Fx(xE,e=>!e.value),Fx(SE,e=>e.string.includes(e.substring)),Fx(CE,e=>e.string.startsWith(e.prefix)),Fx(wE,e=>e.string.endsWith(e.suffix)),Fx(TE,e=>{let t=e.value;return!(t==null||typeof t==`string`&&t===``||Array.isArray(t)&&t.length===0)}),Fx(EE,e=>{try{return new RegExp(e.pattern).test(e.value)}catch(t){throw new Mx(`Invalid regex pattern: ${e.pattern}`,`regex`,t)}}),Fx(DE,e=>{let t=e.value,n=0;return(typeof t==`string`||Array.isArray(t))&&(n=t.length),!(e.min!==void 0&&!isNaN(e.min)&&n<e.min||e.max!==void 0&&!isNaN(e.max)&&n>e.max)}),Fx(OE,e=>!(isNaN(e.value)||e.min!==void 0&&!isNaN(e.min)&&e.value<e.min||e.max!==void 0&&!isNaN(e.max)&&e.value>e.max)),Fx(kE,e=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(e.value)),Fx(AE,(e,t)=>{let n=e.value,r=new tT().parse(n);if(r.length===0)return``;let i=r.map(e=>typeof e!=`object`||!e||Array.isArray(e)?e:t.resolveSignal(e));return iS(()=>i.map(e=>Px(e)?e.value:e).join(``))}),Fx(jE,e=>isNaN(e.value)?``:new Intl.NumberFormat(`en-US`,{minimumFractionDigits:e.decimals,maximumFractionDigits:e.decimals,useGrouping:e.grouping}).format(e.value)),Fx(ME,e=>{if(isNaN(e.value))return``;try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:e.currency,minimumFractionDigits:e.decimals,maximumFractionDigits:e.decimals,useGrouping:e.grouping}).format(e.value)}catch{return e.value.toFixed(e.decimals||2)}}),Fx(NE,e=>{if(!e.value)return``;let t=new Date(e.value);if(isNaN(t.getTime()))return``;try{return e.format===`ISO`?t.toISOString():lE(t,e.format)}catch(e){return console.warn(`Error formatting date:`,e),t.toISOString()}}),Fx(PE,e=>{let t=new Intl.PluralRules(`en-US`).select(e.value);return String(e[t]||e.other||``)}),Fx(FE,e=>{e.url&&typeof window<`u`&&window.open&&window.open(e.url,`_blank`)})],LE={accessibility:Kw.optional(),weight:vx().describe(`The relative weight of this component within a Row or Column. This is similar to the CSS 'flex-grow' property. Note: this may ONLY be set when the component is a direct descendant of a Row or Column.`).optional()},RE={name:`Text`,schema:Sx({...LE,text:Lw.describe(`The text content to display. While simple Markdown formatting is supported (i.e. without HTML, images, or links), utilizing dedicated UI components is generally preferred for a richer and more structured presentation.`),variant:Ex([`h1`,`h2`,`h3`,`h4`,`h5`,`caption`,`body`]).default(`body`).describe(`A hint for the base text style.`).optional()}).strict()},zE={name:`Image`,schema:Sx({...LE,url:Lw.describe(`The URL of the image to display.`),description:Lw.describe(`The accessibility description of the image.`).optional(),fit:Ex([`contain`,`cover`,`fill`,`none`,`scaleDown`]).default(`fill`).describe(`Specifies how the image should be resized to fit its container. This corresponds to the CSS 'object-fit' property.`).optional(),variant:Ex([`icon`,`avatar`,`smallFeature`,`mediumFeature`,`largeFeature`,`header`]).default(`mediumFeature`).describe(`A hint for the image size and style.`).optional()}).strict()},BE=`accountCircle.add.arrowBack.arrowForward.attachFile.calendarToday.call.camera.check.close.delete.download.edit.event.error.fastForward.favorite.favoriteOff.folder.help.home.info.locationOn.lock.lockOpen.mail.menu.moreVert.moreHoriz.notificationsOff.notifications.pause.payment.person.phone.photo.play.print.refresh.rewind.search.send.settings.share.shoppingCart.skipNext.skipPrevious.star.starHalf.starOff.stop.upload.visibility.visibilityOff.volumeDown.volumeMute.volumeOff.volumeUp.warning`.split(`.`),VE={name:`Icon`,schema:Sx({...LE,name:Cx([Ex(BE),Sx({path:_x()}).strict()]).describe(`The name of the icon to display.`)}).strict()},HE={name:`Video`,schema:Sx({...LE,url:Lw.describe(`The URL of the video to display.`)}).strict()},UE={name:`AudioPlayer`,schema:Sx({...LE,url:Lw.describe(`The URL of the audio to be played.`),description:Lw.describe(`A description of the audio, such as a title or summary.`).optional()}).strict()},WE={name:`Row`,schema:Sx({...LE,children:Hw.describe(`Defines the children. Use an array of strings for a fixed set of children, or a template object to generate children from a data list. Children cannot be defined inline, they must be referred to by ID.`),justify:Ex([`center`,`end`,`spaceAround`,`spaceBetween`,`spaceEvenly`,`start`,`stretch`]).default(`start`).describe(`Defines the arrangement of children along the main axis (horizontally). Use 'spaceBetween' to push items to the edges, or 'start'/'end'/'center' to pack them together.`).optional(),align:Ex([`start`,`center`,`end`,`stretch`]).default(`stretch`).describe(`Defines the alignment of children along the cross axis (vertically). This is similar to the CSS 'align-items' property, but uses camelCase values (e.g., 'start').`).optional()}).strict().describe(`A layout component that arranges its children horizontally. To create a grid layout, nest Columns within this Row.`)},GE={name:`Column`,schema:Sx({...LE,children:Hw.describe(`Defines the children. Use an array of strings for a fixed set of children, or a template object to generate children from a data list. Children cannot be defined inline, they must be referred to by ID.`),justify:Ex([`start`,`center`,`end`,`spaceBetween`,`spaceAround`,`spaceEvenly`,`stretch`]).default(`start`).describe(`Defines the arrangement of children along the main axis (vertically). Use 'spaceBetween' to push items to the edges (e.g. header at top, footer at bottom), or 'start'/'end'/'center' to pack them together.`).optional(),align:Ex([`center`,`end`,`start`,`stretch`]).default(`stretch`).describe(`Defines the alignment of children along the cross axis (horizontally). This is similar to the CSS 'align-items' property.`).optional()}).strict().describe(`A layout component that arranges its children vertically. To create a grid layout, nest Rows within this Column.`)},KE={name:`List`,schema:Sx({...LE,children:Hw.describe(`Defines the children. Use an array of strings for a fixed set of children, or a template object to generate children from a data list.`),direction:Ex([`vertical`,`horizontal`]).default(`vertical`).describe(`The direction in which the list items are laid out.`).optional(),align:Ex([`start`,`center`,`end`,`stretch`]).default(`stretch`).describe(`Defines the alignment of children along the cross axis.`).optional()}).strict()},qE={name:`Card`,schema:Sx({...LE,child:Vw.describe(`The ID of the single child component to be rendered inside the card. To display multiple elements, you MUST wrap them in a layout component (like Column or Row) and pass that container's ID here. Do NOT pass multiple IDs or a non-existent ID. Do NOT define the child component inline.`)}).strict()},JE={name:`Tabs`,schema:Sx({...LE,tabs:xx(Sx({title:Lw.describe(`The tab title.`),child:Vw.describe(`The ID of the child component. Do NOT define the component inline.`)}).strict()).min(1).describe(`An array of objects, where each object defines a tab with a title and a child component.`)}).strict()},YE={name:`Modal`,schema:Sx({...LE,trigger:Vw.describe(`The ID of the component that opens the modal when interacted with (e.g., a button). Do NOT define the component inline.`),content:Vw.describe(`The ID of the component to be displayed inside the modal. Do NOT define the component inline.`)}).strict()},XE={name:`Divider`,schema:Sx({...LE,axis:Ex([`horizontal`,`vertical`]).default(`horizontal`).describe(`The orientation of the divider.`).optional()}).strict()},ZE={name:`Button`,schema:Sx({...LE,child:Vw.describe(`The ID of the child component. Use a 'Text' component for a labeled button. Only use an 'Icon' if the requirements explicitly ask for an icon-only button. Do NOT define the child component inline.`),variant:Ex([`default`,`primary`,`borderless`]).default(`default`).describe(`A hint for the button style. If omitted, a default button style is used. 'primary' indicates this is the main call-to-action button. 'borderless' means the button has no visual border or background, making its child content appear like a clickable link.`).optional(),action:Uw,checks:Gw.shape.checks}).strict()},QE={name:`TextField`,schema:Sx({...LE,label:Lw.describe(`The text label for the input field.`),value:Lw.describe(`The value of the text field.`).optional(),variant:Ex([`longText`,`number`,`shortText`,`obscured`]).default(`shortText`).describe(`The type of input field to display.`).optional(),validationRegexp:_x().describe(`A regular expression used for client-side validation of the input.`).optional(),checks:Gw.shape.checks}).strict()},$E={name:`CheckBox`,schema:Sx({...LE,label:Lw.describe(`The text to display next to the checkbox.`),value:Iw.describe(`The current state of the checkbox (true for checked, false for unchecked).`),checks:Gw.shape.checks}).strict()},eD={name:`ChoicePicker`,schema:Sx({...LE,label:Lw.describe(`The label for the group of options.`).optional(),variant:Ex([`multipleSelection`,`mutuallyExclusive`]).default(`mutuallyExclusive`).describe(`A hint for how the choice picker should be displayed and behave.`).optional(),options:xx(Sx({label:Lw.describe(`The text to display for this option.`),value:_x().describe(`The stable value associated with this option.`)}).strict()).describe(`The list of available options to choose from.`),value:zw.describe(`The list of currently selected values. This should be bound to a string array in the data model.`),displayStyle:Ex([`checkbox`,`chips`]).default(`checkbox`).describe(`The display style of the component.`).optional(),filterable:yx().default(!1).describe(`If true, displays a search input to filter the options.`).optional(),checks:Gw.shape.checks}).strict().describe(`A component that allows selecting one or more options from a list.`)},tD={name:`Slider`,schema:Sx({...LE,label:Lw.describe(`The label for the slider.`).optional(),min:vx().default(0).describe(`The minimum value of the slider.`).optional(),max:vx().describe(`The maximum value of the slider.`),value:Rw.describe(`The current value of the slider.`),checks:Gw.shape.checks}).strict()},nD={name:`DateTimeInput`,schema:Sx({...LE,value:Lw.describe(`The selected date and/or time value in ISO 8601 format. If not yet set, initialize with an empty string.`),enableDate:yx().default(!1).describe(`If true, allows the user to select a date.`).optional(),enableTime:yx().default(!1).describe(`If true, allows the user to select a time.`).optional(),min:Cx([Lw,_x().date(),_x().time(),_x().datetime()]).describe(`The minimum allowed date/time in ISO 8601 format.`).optional(),max:Cx([Lw,_x().date(),_x().time(),_x().datetime()]).describe(`The maximum allowed date/time in ISO 8601 format.`).optional(),label:Lw.describe(`The text label for the input field.`).optional(),checks:Gw.shape.checks}).strict()},rD=Jw(RE,({props:e})=>{let t=e.text??``,n={...$w(),display:`inline-block`};switch(e.variant){case`h1`:return(0,O.jsx)(`h1`,{style:n,children:t});case`h2`:return(0,O.jsx)(`h2`,{style:n,children:t});case`h3`:return(0,O.jsx)(`h3`,{style:n,children:t});case`h4`:return(0,O.jsx)(`h4`,{style:n,children:t});case`h5`:return(0,O.jsx)(`h5`,{style:n,children:t});case`caption`:return(0,O.jsx)(`small`,{style:{...n,color:`#666`,textAlign:`left`},children:t});default:return(0,O.jsx)(`span`,{style:n,children:t})}}),iD=Jw(zE,({props:e})=>{let t=e=>e===`scaleDown`?`scale-down`:e||`fill`,n={...$w(),objectFit:t(e.fit),width:`100%`,height:`auto`,display:`block`};return e.variant===`icon`?(n.width=`24px`,n.height=`24px`):e.variant===`avatar`?(n.width=`40px`,n.height=`40px`,n.borderRadius=`50%`):e.variant===`smallFeature`?n.maxWidth=`100px`:e.variant===`largeFeature`?n.maxHeight=`400px`:e.variant===`header`&&(n.height=`200px`,n.objectFit=`cover`),(0,O.jsx)(`img`,{src:e.url,alt:e.description||``,style:n})}),aD=Jw(VE,({props:e})=>{let t=typeof e.name==`string`?e.name:e.name?.path;return(0,O.jsx)(`span`,{className:`material-symbols-outlined`,style:{...$w(),fontSize:`24px`,width:`24px`,height:`24px`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`},children:t})}),oD=Jw(HE,({props:e})=>{let t={...$w(),width:`100%`,aspectRatio:`16/9`};return(0,O.jsx)(`video`,{src:e.url,controls:!0,style:t})}),sD=Jw(UE,({props:e})=>{let t={...$w(),width:`100%`};return(0,O.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`,width:`100%`},children:[e.description&&(0,O.jsx)(`span`,{style:{fontSize:`12px`,color:`#666`},children:e.description}),(0,O.jsx)(`audio`,{src:e.url,controls:!0,style:t})]})}),cD=({childList:e,buildChild:t})=>Array.isArray(e)?(0,O.jsx)(O.Fragment,{children:e.map((e,n)=>{if(e&&typeof e==`object`&&`id`in e){let r=e;return(0,O.jsx)(v.Fragment,{children:t(r.id,r.basePath)},`${r.id}-${n}`)}return typeof e==`string`?(0,O.jsx)(v.Fragment,{children:t(e)},`${e}-${n}`):null})}):null,lD=new Ix(`https://a2ui.org/specification/v0_9/basic_catalog.json`,[rD,iD,aD,oD,sD,Jw(WE,({props:e,buildChild:t,context:n})=>(0,O.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:Zw(e.justify),alignItems:Qw(e.align),width:`100%`,margin:0,padding:0},children:(0,O.jsx)(cD,{childList:e.children,buildChild:t,context:n})})),Jw(GE,({props:e,buildChild:t,context:n})=>(0,O.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,justifyContent:Zw(e.justify),alignItems:Qw(e.align),width:`100%`,margin:0,padding:0},children:(0,O.jsx)(cD,{childList:e.children,buildChild:t,context:n})})),Jw(KE,({props:e,buildChild:t,context:n})=>{let r=e.direction===`horizontal`;return(0,O.jsx)(`div`,{style:{display:`flex`,flexDirection:r?`row`:`column`,alignItems:Qw(e.align),overflowX:r?`auto`:`hidden`,overflowY:r?`hidden`:`auto`,width:`100%`,margin:0,padding:0},children:(0,O.jsx)(cD,{childList:e.children,buildChild:t,context:n})})}),Jw(qE,({props:e,buildChild:t})=>(0,O.jsx)(`div`,{style:{...eT(),backgroundColor:`#fff`,boxShadow:`0 2px 4px rgba(0,0,0,0.1)`,width:`100%`},children:e.child?t(e.child):null})),Jw(JE,({props:e,buildChild:t})=>{let[n,r]=(0,v.useState)(0),i=e.tabs||[],a=i[n];return(0,O.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100%`,margin:`8px`},children:[(0,O.jsx)(`div`,{style:{display:`flex`,borderBottom:`1px solid #ccc`,marginBottom:`8px`},children:i.map((e,t)=>(0,O.jsx)(`button`,{onClick:()=>r(t),style:{padding:`8px 16px`,border:`none`,background:`none`,borderBottom:n===t?`2px solid var(--a2ui-primary-color, #007bff)`:`none`,fontWeight:n===t?`bold`:`normal`,cursor:`pointer`,color:n===t?`var(--a2ui-primary-color, #007bff)`:`inherit`},children:e.title},t))}),(0,O.jsx)(`div`,{style:{flex:1},children:a?t(a.child):null})]})}),Jw(XE,({props:e})=>{let t=e.axis===`vertical`,n={margin:`8px`,border:`none`,backgroundColor:`#ccc`};return t?(n.width=`1px`,n.height=`100%`):(n.width=`100%`,n.height=`1px`),(0,O.jsx)(`div`,{style:n})}),Jw(YE,({props:e,buildChild:t})=>{let[n,r]=(0,v.useState)(!1);return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{onClick:()=>r(!0),style:{display:`inline-block`},children:e.trigger?t(e.trigger):null}),n&&(0,O.jsx)(`div`,{style:{position:`fixed`,top:0,left:0,right:0,bottom:0,backgroundColor:`rgba(0,0,0,0.5)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:1e3},onClick:()=>r(!1),children:(0,O.jsxs)(`div`,{style:{backgroundColor:`#fff`,padding:`24px`,borderRadius:`8px`,maxWidth:`90%`,maxHeight:`90%`,overflow:`auto`,display:`flex`,flexDirection:`column`},onClick:e=>e.stopPropagation(),children:[(0,O.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`},children:(0,O.jsx)(`button`,{onClick:()=>r(!1),style:{border:`none`,background:`none`,fontSize:`20px`,cursor:`pointer`,padding:`4px`},children:`×`})}),(0,O.jsx)(`div`,{style:{flex:1},children:e.content?t(e.content):null})]})})]})}),Jw(ZE,({props:e,buildChild:t})=>(0,O.jsx)(`button`,{style:{margin:`8px`,padding:`8px 16px`,cursor:`pointer`,border:e.variant===`borderless`?`none`:`1px solid #ccc`,backgroundColor:e.variant===`primary`?`var(--a2ui-primary-color, #007bff)`:e.variant===`borderless`?`transparent`:`#fff`,color:e.variant===`primary`?`#fff`:`inherit`,borderRadius:`4px`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,boxSizing:`border-box`},onClick:e.action,disabled:e.isValid===!1,children:e.child?t(e.child):null})),Jw(QE,({props:e})=>{let t=t=>{e.setValue(t.target.value)},n=e.variant===`longText`,r=e.variant===`number`?`number`:e.variant===`obscured`?`password`:`text`,i={padding:`8px`,width:`100%`,border:Xw,borderRadius:`8px`,boxSizing:`border-box`},a=v.useId(),o=e.validationErrors&&e.validationErrors.length>0;return(0,O.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`,width:`100%`,margin:`8px`},children:[e.label&&(0,O.jsx)(`label`,{htmlFor:a,style:{fontSize:`14px`,fontWeight:`bold`},children:e.label}),n?(0,O.jsx)(`textarea`,{id:a,style:{...i,border:o?`1px solid red`:Xw},value:e.value||``,onChange:t}):(0,O.jsx)(`input`,{id:a,type:r,style:{...i,border:o?`1px solid red`:Xw},value:e.value||``,onChange:t}),o&&(0,O.jsx)(`span`,{style:{fontSize:`12px`,color:`red`},children:e.validationErrors[0]})]})}),Jw($E,({props:e})=>{let t=t=>{e.setValue(t.target.checked)},n=v.useId(),r=e.validationErrors&&e.validationErrors.length>0;return(0,O.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,margin:`8px`},children:[(0,O.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,O.jsx)(`input`,{id:n,type:`checkbox`,checked:!!e.value,onChange:t,style:{cursor:`pointer`,outline:r?`1px solid red`:`none`}}),e.label&&(0,O.jsx)(`label`,{htmlFor:n,style:{cursor:`pointer`,color:r?`red`:`inherit`},children:e.label})]}),r&&(0,O.jsx)(`span`,{style:{fontSize:`12px`,color:`red`,marginTop:`4px`},children:e.validationErrors?.[0]})]})}),Jw(eD,({props:e,context:t})=>{let[n,r]=(0,v.useState)(``),i=Array.isArray(e.value)?e.value:[],a=e.variant===`mutuallyExclusive`,o=t=>{if(a)e.setValue([t]);else{let n=i.includes(t)?i.filter(e=>e!==t):[...i,t];e.setValue(n)}},s=(e.options||[]).filter(t=>!e.filterable||n===``||String(t.label).toLowerCase().includes(n.toLowerCase())),c={display:`flex`,flexDirection:`column`,gap:`8px`,margin:`8px`,width:`100%`},l={display:`flex`,flexDirection:e.displayStyle===`chips`?`row`:`column`,flexWrap:e.displayStyle===`chips`?`wrap`:`nowrap`,gap:`8px`};return(0,O.jsxs)(`div`,{style:c,children:[e.label&&(0,O.jsx)(`strong`,{style:{fontSize:`14px`},children:e.label}),e.filterable&&(0,O.jsx)(`input`,{type:`text`,placeholder:`Filter options...`,value:n,onChange:e=>r(e.target.value),style:{padding:`4px 8px`,border:`1px solid #ccc`,borderRadius:`8px`}}),(0,O.jsx)(`div`,{style:l,children:s.map((n,r)=>{let s=i.includes(n.value);return e.displayStyle===`chips`?(0,O.jsx)(`button`,{onClick:()=>o(n.value),style:{padding:`4px 12px`,borderRadius:`16px`,border:s?`1px solid var(--a2ui-primary-color, #007bff)`:Xw,backgroundColor:s?`var(--a2ui-primary-color, #007bff)`:`#fff`,color:s?`#fff`:`inherit`,cursor:`pointer`,fontSize:`12px`},children:n.label},r):(0,O.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`},children:[(0,O.jsx)(`input`,{type:a?`radio`:`checkbox`,checked:s,onChange:()=>o(n.value),name:a?`choice-${t.componentModel.id}`:void 0}),(0,O.jsx)(`span`,{style:{fontSize:`14px`},children:n.label})]},r)})})]})}),Jw(tD,({props:e})=>{let t=t=>{e.setValue(Number(t.target.value))},n=v.useId();return(0,O.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`,margin:`8px`,width:`100%`},children:[(0,O.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[e.label&&(0,O.jsx)(`label`,{htmlFor:n,style:{fontSize:`14px`,fontWeight:`bold`},children:e.label}),(0,O.jsx)(`span`,{style:{fontSize:`12px`,color:`#666`},children:e.value})]}),(0,O.jsx)(`input`,{id:n,type:`range`,min:e.min??0,max:e.max,value:e.value??0,onChange:t,style:{width:`100%`,cursor:`pointer`}})]})}),Jw(nD,({props:e})=>{let t=t=>{e.setValue(t.target.value)},n=v.useId(),r=`datetime-local`;e.enableDate&&!e.enableTime&&(r=`date`),!e.enableDate&&e.enableTime&&(r=`time`);let i={padding:`8px`,width:`100%`,border:Xw,borderRadius:`8px`,boxSizing:`border-box`};return(0,O.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`,width:`100%`,margin:`8px`},children:[e.label&&(0,O.jsx)(`label`,{htmlFor:n,style:{fontSize:`14px`,fontWeight:`bold`},children:e.label}),(0,O.jsx)(`input`,{id:n,type:r,style:i,value:e.value||``,onChange:t,min:typeof e.min==`string`?e.min:void 0,max:typeof e.max==`string`?e.max:void 0})]})})],IE),uD=(0,v.createContext)(void 0);function dD({theme:e,children:t}){return(0,O.jsx)(uD.Provider,{value:e??{},children:t})}var fD=(0,v.memo)(({surface:e,id:t,basePath:n,compImpl:r,componentModel:i})=>{let a=r.render,o=(0,v.useMemo)(()=>new Aw(e,t,n),[e,t,n,i]);return(0,O.jsx)(a,{context:o,buildChild:(0,v.useCallback)((t,n)=>{let r=n||o.dataContext.path;return(0,O.jsx)(pD,{surface:e,id:t,basePath:r},`${t}-${r}`)},[e,o.dataContext.path])})});fD.displayName=`ResolvedChild`;var pD=(0,v.memo)(({surface:e,id:t,basePath:n})=>{let r=(0,v.useMemo)(()=>{let n=0;return{subscribe:r=>{let i=e.componentsModel.onCreated.subscribe(e=>{e.id===t&&(n++,r())}),a=e.componentsModel.onDeleted.subscribe(e=>{e===t&&(n++,r())});return()=>{i.unsubscribe(),a.unsubscribe()}},getSnapshot:()=>{let r=e.componentsModel.get(t);return r?`${r.type}-${n}`:`missing-${n}`}}},[e,t]);(0,v.useSyncExternalStore)(r.subscribe,r.getSnapshot);let i=e.componentsModel.get(t);if(!i)return(0,O.jsx)(`div`,{style:{padding:`12px 16px`,borderRadius:`8px`,background:`linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%)`,backgroundSize:`200% 100%`,animation:`a2ui-shimmer 1.5s ease-in-out infinite`,minHeight:`2rem`},children:(0,O.jsx)(`style`,{children:`@keyframes a2ui-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }`})});let a=e.catalog.components.get(i.type);return a?(0,O.jsx)(fD,{surface:e,id:t,basePath:n,componentModel:i,compImpl:a}):(0,O.jsxs)(`div`,{style:{color:`red`},children:[`Unknown component: `,i.type]})});pD.displayName=`DeferredChild`;var mD=({surface:e})=>(0,O.jsx)(pD,{surface:e,id:`root`,basePath:`/`}),hD;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(hD||={});var gD;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(gD||={});var _D=hD.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),vD=e=>{switch(typeof e){case`undefined`:return _D.undefined;case`string`:return _D.string;case`number`:return Number.isNaN(e)?_D.nan:_D.number;case`boolean`:return _D.boolean;case`function`:return _D.function;case`bigint`:return _D.bigint;case`symbol`:return _D.symbol;case`object`:return Array.isArray(e)?_D.array:e===null?_D.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?_D.promise:typeof Map<`u`&&e instanceof Map?_D.map:typeof Set<`u`&&e instanceof Set?_D.set:typeof Date<`u`&&e instanceof Date?_D.date:_D.object;default:return _D.unknown}},W=hD.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),yD=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,hD.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};yD.create=e=>new yD(e);var bD=(e,t)=>{let n;switch(e.code){case W.invalid_type:n=e.received===_D.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case W.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,hD.jsonStringifyReplacer)}`;break;case W.unrecognized_keys:n=`Unrecognized key(s) in object: ${hD.joinValues(e.keys,`, `)}`;break;case W.invalid_union:n=`Invalid input`;break;case W.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${hD.joinValues(e.options)}`;break;case W.invalid_enum_value:n=`Invalid enum value. Expected ${hD.joinValues(e.options)}, received '${e.received}'`;break;case W.invalid_arguments:n=`Invalid function arguments`;break;case W.invalid_return_type:n=`Invalid function return type`;break;case W.invalid_date:n=`Invalid date`;break;case W.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:hD.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case W.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case W.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case W.custom:n=`Invalid input`;break;case W.invalid_intersection_types:n=`Intersection results could not be merged`;break;case W.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case W.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,hD.assertNever(e)}return{message:n}},xD=bD;function SD(){return xD}var CD=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function G(e,t){let n=SD(),r=CD({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===bD?void 0:bD].filter(e=>!!e)});e.common.issues.push(r)}var wD=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return TD;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return TD;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},TD=Object.freeze({status:`aborted`}),ED=e=>({status:`dirty`,value:e}),DD=e=>({status:`valid`,value:e}),OD=e=>e.status===`aborted`,kD=e=>e.status===`dirty`,AD=e=>e.status===`valid`,jD=e=>typeof Promise<`u`&&e instanceof Promise,MD;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(MD||={});var ND=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},PD=(e,t)=>{if(AD(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new yD(e.common.issues);return this._error=t,this._error}}};function FD(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var ID=class{get description(){return this._def.description}_getType(e){return vD(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:vD(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new wD,ctx:{common:e.parent.common,data:e.data,parsedType:vD(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(jD(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vD(e)};return PD(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vD(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return AD(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>AD(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vD(e)},r=this._parse({data:e,path:n.path,parent:n});return PD(n,await(jD(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:W.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new _O({schema:this,typeName:EO.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return vO.create(this,this._def)}nullable(){return yO.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return tO.create(this)}promise(){return gO.create(this,this._def)}or(e){return iO.create([this,e],this._def)}and(e){return sO.create(this,e,this._def)}transform(e){return new _O({...FD(this._def),schema:this,typeName:EO.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new bO({...FD(this._def),innerType:this,defaultValue:t,typeName:EO.ZodDefault})}brand(){return new CO({typeName:EO.ZodBranded,type:this,...FD(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new xO({...FD(this._def),innerType:this,catchValue:t,typeName:EO.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return wO.create(this,e)}readonly(){return TO.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},LD=/^c[^\s-]{8,}$/i,RD=/^[0-9a-z]+$/,zD=/^[0-9A-HJKMNP-TV-Z]{26}$/i,cte=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,lte=/^[a-z0-9_-]{21}$/i,ute=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,dte=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,fte=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,pte=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,BD,mte=/^(?:(?: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])$/,hte=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,gte=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,_te=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,vte=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,yte=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,VD=`((\\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])))`,bte=RegExp(`^${VD}$`);function HD(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function xte(e){return RegExp(`^${HD(e)}$`)}function Ste(e){let t=`${VD}T${HD(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Cte(e,t){return!!((t===`v4`||!t)&&mte.test(e)||(t===`v6`||!t)&>e.test(e))}function wte(e,t){if(!ute.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function Tte(e,t){return!!((t===`v4`||!t)&&hte.test(e)||(t===`v6`||!t)&&_te.test(e))}var UD=class e extends ID{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_D.string){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:_D.string,received:t.parsedType}),TD}let t=new wD,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),G(n,{code:W.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),G(n,{code:W.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?G(n,{code:W.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&G(n,{code:W.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)fte.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`email`,code:W.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)BD||=new RegExp(pte,`u`),BD.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`emoji`,code:W.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)cte.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`uuid`,code:W.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)lte.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`nanoid`,code:W.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)LD.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`cuid`,code:W.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)RD.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`cuid2`,code:W.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)zD.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`ulid`,code:W.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),G(n,{validation:`url`,code:W.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`regex`,code:W.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),G(n,{code:W.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),G(n,{code:W.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),G(n,{code:W.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Ste(r).test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{code:W.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?bte.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{code:W.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?xte(r).test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{code:W.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?dte.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`duration`,code:W.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?Cte(e.data,r.version)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`ip`,code:W.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?wte(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`jwt`,code:W.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?Tte(e.data,r.version)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`cidr`,code:W.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?vte.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`base64`,code:W.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?yte.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`base64url`,code:W.invalid_string,message:r.message}),t.dirty()):hD.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:W.invalid_string,...MD.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...MD.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...MD.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...MD.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...MD.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...MD.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...MD.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...MD.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...MD.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...MD.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...MD.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...MD.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...MD.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...MD.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...MD.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...MD.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...MD.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...MD.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...MD.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...MD.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...MD.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...MD.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...MD.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...MD.errToObj(t)})}nonempty(e){return this.min(1,MD.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};UD.create=e=>new UD({checks:[],typeName:EO.ZodString,coerce:e?.coerce??!1,...FD(e)});function Ete(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var WD=class e extends ID{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_D.number){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:_D.number,received:t.parsedType}),TD}let t,n=new wD;for(let r of this._def.checks)r.kind===`int`?hD.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),G(t,{code:W.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),G(t,{code:W.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),G(t,{code:W.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Ete(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),G(t,{code:W.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),G(t,{code:W.not_finite,message:r.message}),n.dirty()):hD.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,MD.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,MD.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,MD.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,MD.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:MD.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:MD.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:MD.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:MD.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:MD.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:MD.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:MD.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:MD.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:MD.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:MD.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&hD.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};WD.create=e=>new WD({checks:[],typeName:EO.ZodNumber,coerce:e?.coerce||!1,...FD(e)});var GD=class e extends ID{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==_D.bigint)return this._getInvalidInput(e);let t,n=new wD;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),G(t,{code:W.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),G(t,{code:W.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),G(t,{code:W.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):hD.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:_D.bigint,received:t.parsedType}),TD}gte(e,t){return this.setLimit(`min`,e,!0,MD.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,MD.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,MD.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,MD.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:MD.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:MD.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:MD.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:MD.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:MD.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:MD.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};GD.create=e=>new GD({checks:[],typeName:EO.ZodBigInt,coerce:e?.coerce??!1,...FD(e)});var KD=class extends ID{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_D.boolean){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:_D.boolean,received:t.parsedType}),TD}return DD(e.data)}};KD.create=e=>new KD({typeName:EO.ZodBoolean,coerce:e?.coerce||!1,...FD(e)});var qD=class e extends ID{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_D.date){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:_D.date,received:t.parsedType}),TD}if(Number.isNaN(e.data.getTime()))return G(this._getOrReturnCtx(e),{code:W.invalid_date}),TD;let t=new wD,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),G(n,{code:W.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),G(n,{code:W.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):hD.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:MD.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:MD.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};qD.create=e=>new qD({checks:[],coerce:e?.coerce||!1,typeName:EO.ZodDate,...FD(e)});var JD=class extends ID{_parse(e){if(this._getType(e)!==_D.symbol){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:_D.symbol,received:t.parsedType}),TD}return DD(e.data)}};JD.create=e=>new JD({typeName:EO.ZodSymbol,...FD(e)});var YD=class extends ID{_parse(e){if(this._getType(e)!==_D.undefined){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:_D.undefined,received:t.parsedType}),TD}return DD(e.data)}};YD.create=e=>new YD({typeName:EO.ZodUndefined,...FD(e)});var XD=class extends ID{_parse(e){if(this._getType(e)!==_D.null){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:_D.null,received:t.parsedType}),TD}return DD(e.data)}};XD.create=e=>new XD({typeName:EO.ZodNull,...FD(e)});var ZD=class extends ID{constructor(){super(...arguments),this._any=!0}_parse(e){return DD(e.data)}};ZD.create=e=>new ZD({typeName:EO.ZodAny,...FD(e)});var QD=class extends ID{constructor(){super(...arguments),this._unknown=!0}_parse(e){return DD(e.data)}};QD.create=e=>new QD({typeName:EO.ZodUnknown,...FD(e)});var $D=class extends ID{_parse(e){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:_D.never,received:t.parsedType}),TD}};$D.create=e=>new $D({typeName:EO.ZodNever,...FD(e)});var eO=class extends ID{_parse(e){if(this._getType(e)!==_D.undefined){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:_D.void,received:t.parsedType}),TD}return DD(e.data)}};eO.create=e=>new eO({typeName:EO.ZodVoid,...FD(e)});var tO=class e extends ID{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==_D.array)return G(t,{code:W.invalid_type,expected:_D.array,received:t.parsedType}),TD;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(G(t,{code:e?W.too_big:W.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(G(t,{code:W.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(G(t,{code:W.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new ND(t,e,t.path,n)))).then(e=>wD.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new ND(t,e,t.path,n)));return wD.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:MD.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:MD.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:MD.toString(n)}})}nonempty(e){return this.min(1,e)}};tO.create=(e,t)=>new tO({type:e,minLength:null,maxLength:null,exactLength:null,typeName:EO.ZodArray,...FD(t)});function nO(e){if(e instanceof rO){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=vO.create(nO(r))}return new rO({...e._def,shape:()=>t})}else if(e instanceof tO)return new tO({...e._def,type:nO(e.element)});else if(e instanceof vO)return vO.create(nO(e.unwrap()));else if(e instanceof yO)return yO.create(nO(e.unwrap()));else if(e instanceof cO)return cO.create(e.items.map(e=>nO(e)));else return e}var rO=class e extends ID{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=hD.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==_D.object){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:_D.object,received:t.parsedType}),TD}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof $D&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new ND(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof $D){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(G(n,{code:W.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new ND(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>wD.mergeObjectSync(t,e)):wD.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return MD.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:MD.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:EO.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of hD.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of hD.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return nO(this)}partial(t){let n={};for(let e of hD.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of hD.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof vO;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return pO(hD.objectKeys(this.shape))}};rO.create=(e,t)=>new rO({shape:()=>e,unknownKeys:`strip`,catchall:$D.create(),typeName:EO.ZodObject,...FD(t)}),rO.strictCreate=(e,t)=>new rO({shape:()=>e,unknownKeys:`strict`,catchall:$D.create(),typeName:EO.ZodObject,...FD(t)}),rO.lazycreate=(e,t)=>new rO({shape:e,unknownKeys:`strip`,catchall:$D.create(),typeName:EO.ZodObject,...FD(t)});var iO=class extends ID{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new yD(e.ctx.common.issues));return G(t,{code:W.invalid_union,unionErrors:n}),TD}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new yD(e));return G(t,{code:W.invalid_union,unionErrors:i}),TD}}get options(){return this._def.options}};iO.create=(e,t)=>new iO({options:e,typeName:EO.ZodUnion,...FD(t)});var aO=e=>e instanceof dO?aO(e.schema):e instanceof _O?aO(e.innerType()):e instanceof fO?[e.value]:e instanceof mO?e.options:e instanceof hO?hD.objectValues(e.enum):e instanceof bO?aO(e._def.innerType):e instanceof YD?[void 0]:e instanceof XD?[null]:e instanceof vO?[void 0,...aO(e.unwrap())]:e instanceof yO?[null,...aO(e.unwrap())]:e instanceof CO||e instanceof TO?aO(e.unwrap()):e instanceof xO?aO(e._def.innerType):[],Dte=class e extends ID{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_D.object)return G(t,{code:W.invalid_type,expected:_D.object,received:t.parsedType}),TD;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(G(t,{code:W.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),TD)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=aO(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:EO.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...FD(r)})}};function oO(e,t){let n=vD(e),r=vD(t);if(e===t)return{valid:!0,data:e};if(n===_D.object&&r===_D.object){let n=hD.objectKeys(t),r=hD.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=oO(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===_D.array&&r===_D.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=oO(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===_D.date&&r===_D.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var sO=class extends ID{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(OD(e)||OD(r))return TD;let i=oO(e.value,r.value);return i.valid?((kD(e)||kD(r))&&t.dirty(),{status:t.value,value:i.data}):(G(n,{code:W.invalid_intersection_types}),TD)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};sO.create=(e,t,n)=>new sO({left:e,right:t,typeName:EO.ZodIntersection,...FD(n)});var cO=class e extends ID{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_D.array)return G(n,{code:W.invalid_type,expected:_D.array,received:n.parsedType}),TD;if(n.data.length<this._def.items.length)return G(n,{code:W.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),TD;!this._def.rest&&n.data.length>this._def.items.length&&(G(n,{code:W.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new ND(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>wD.mergeArray(t,e)):wD.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};cO.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new cO({items:e,typeName:EO.ZodTuple,rest:null,...FD(t)})};var Ote=class e extends ID{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_D.object)return G(n,{code:W.invalid_type,expected:_D.object,received:n.parsedType}),TD;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new ND(n,e,n.path,e)),value:a._parse(new ND(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?wD.mergeObjectAsync(t,r):wD.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof ID?new e({keyType:t,valueType:n,typeName:EO.ZodRecord,...FD(r)}):new e({keyType:UD.create(),valueType:t,typeName:EO.ZodRecord,...FD(n)})}},lO=class extends ID{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_D.map)return G(n,{code:W.invalid_type,expected:_D.map,received:n.parsedType}),TD;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new ND(n,e,n.path,[a,`key`])),value:i._parse(new ND(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return TD;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return TD;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};lO.create=(e,t,n)=>new lO({valueType:t,keyType:e,typeName:EO.ZodMap,...FD(n)});var uO=class e extends ID{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_D.set)return G(n,{code:W.invalid_type,expected:_D.set,received:n.parsedType}),TD;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(G(n,{code:W.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(G(n,{code:W.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return TD;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new ND(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:MD.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:MD.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};uO.create=(e,t)=>new uO({valueType:e,minSize:null,maxSize:null,typeName:EO.ZodSet,...FD(t)});var kte=class e extends ID{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_D.function)return G(t,{code:W.invalid_type,expected:_D.function,received:t.parsedType}),TD;function n(e,n){return CD({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,SD(),bD].filter(e=>!!e),issueData:{code:W.invalid_arguments,argumentsError:n}})}function r(e,n){return CD({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,SD(),bD].filter(e=>!!e),issueData:{code:W.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof gO){let e=this;return DD(async function(...t){let o=new yD([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return DD(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new yD([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new yD([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:cO.create(t).rest(QD.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||cO.create([]).rest(QD.create()),returns:n||QD.create(),typeName:EO.ZodFunction,...FD(r)})}},dO=class extends ID{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};dO.create=(e,t)=>new dO({getter:e,typeName:EO.ZodLazy,...FD(t)});var fO=class extends ID{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return G(t,{received:t.data,code:W.invalid_literal,expected:this._def.value}),TD}return{status:`valid`,value:e.data}}get value(){return this._def.value}};fO.create=(e,t)=>new fO({value:e,typeName:EO.ZodLiteral,...FD(t)});function pO(e,t){return new mO({values:e,typeName:EO.ZodEnum,...FD(t)})}var mO=class e extends ID{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return G(t,{expected:hD.joinValues(n),received:t.parsedType,code:W.invalid_type}),TD}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return G(t,{received:t.data,code:W.invalid_enum_value,options:n}),TD}return DD(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};mO.create=pO;var hO=class extends ID{_parse(e){let t=hD.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_D.string&&n.parsedType!==_D.number){let e=hD.objectValues(t);return G(n,{expected:hD.joinValues(e),received:n.parsedType,code:W.invalid_type}),TD}if(this._cache||=new Set(hD.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=hD.objectValues(t);return G(n,{received:n.data,code:W.invalid_enum_value,options:e}),TD}return DD(e.data)}get enum(){return this._def.values}};hO.create=(e,t)=>new hO({values:e,typeName:EO.ZodNativeEnum,...FD(t)});var gO=class extends ID{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==_D.promise&&t.common.async===!1?(G(t,{code:W.invalid_type,expected:_D.promise,received:t.parsedType}),TD):DD((t.parsedType===_D.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};gO.create=(e,t)=>new gO({type:e,typeName:EO.ZodPromise,...FD(t)});var _O=class extends ID{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===EO.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{G(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return TD;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?TD:r.status===`dirty`||t.value===`dirty`?ED(r.value):r});{if(t.value===`aborted`)return TD;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?TD:r.status===`dirty`||t.value===`dirty`?ED(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?TD:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?TD:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!AD(e))return TD;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>AD(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):TD);hD.assertNever(r)}};_O.create=(e,t,n)=>new _O({schema:e,typeName:EO.ZodEffects,effect:t,...FD(n)}),_O.createWithPreprocess=(e,t,n)=>new _O({schema:t,effect:{type:`preprocess`,transform:e},typeName:EO.ZodEffects,...FD(n)});var vO=class extends ID{_parse(e){return this._getType(e)===_D.undefined?DD(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vO.create=(e,t)=>new vO({innerType:e,typeName:EO.ZodOptional,...FD(t)});var yO=class extends ID{_parse(e){return this._getType(e)===_D.null?DD(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};yO.create=(e,t)=>new yO({innerType:e,typeName:EO.ZodNullable,...FD(t)});var bO=class extends ID{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===_D.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};bO.create=(e,t)=>new bO({innerType:e,typeName:EO.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...FD(t)});var xO=class extends ID{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return jD(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new yD(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new yD(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};xO.create=(e,t)=>new xO({innerType:e,typeName:EO.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...FD(t)});var SO=class extends ID{_parse(e){if(this._getType(e)!==_D.nan){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:_D.nan,received:t.parsedType}),TD}return{status:`valid`,value:e.data}}};SO.create=e=>new SO({typeName:EO.ZodNaN,...FD(e)});var CO=class extends ID{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},wO=class e extends ID{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?TD:e.status===`dirty`?(t.dirty(),ED(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?TD:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:EO.ZodPipeline})}},TO=class extends ID{_parse(e){let t=this._def.innerType._parse(e),n=e=>(AD(e)&&(e.value=Object.freeze(e.value)),e);return jD(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};TO.create=(e,t)=>new TO({innerType:e,typeName:EO.ZodReadonly,...FD(t)}),rO.lazycreate;var EO;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(EO||={});var Ate=UD.create;WD.create,SO.create,GD.create,KD.create,qD.create,JD.create,YD.create,XD.create,ZD.create;var jte=QD.create;$D.create,eO.create,tO.create;var DO=rO.create;rO.strictCreate,iO.create,Dte.create,sO.create,cO.create,Ote.create,lO.create,uO.create,kte.create,dO.create,fO.create;var OO=mO.create;hO.create,gO.create,_O.create,vO.create,yO.create,_O.createWithPreprocess,wO.create;var Mte=Jw({name:`Text`,schema:DO({text:qw.DynamicString,variant:OO([`h1`,`h2`,`h3`,`h4`,`h5`,`caption`,`body`]).optional()})},({props:e})=>{let t=e.text??``;switch(e.variant){case`h1`:return(0,O.jsx)(`h1`,{children:t});case`h2`:return(0,O.jsx)(`h2`,{children:t});case`h3`:return(0,O.jsx)(`h3`,{children:t});case`h4`:return(0,O.jsx)(`h4`,{children:t});case`h5`:return(0,O.jsx)(`h5`,{children:t});case`caption`:return(0,O.jsx)(`small`,{children:t});default:return(0,O.jsx)(`span`,{children:t})}}),Nte=Jw({name:`Button`,schema:DO({child:qw.ComponentId,action:qw.Action,variant:OO([`primary`,`borderless`]).optional()})},({props:e,buildChild:t})=>(0,O.jsx)(`button`,{style:{padding:`8px 16px`,cursor:`pointer`,border:e.variant===`borderless`?`none`:`1px solid #ccc`,backgroundColor:e.variant===`primary`?`#007bff`:`transparent`,color:e.variant===`primary`?`#fff`:`inherit`,borderRadius:`4px`},onClick:e.action,children:e.child?t(e.child):null})),kO=({childList:e,buildChild:t})=>Array.isArray(e)?(0,O.jsx)(O.Fragment,{children:e.map((e,n)=>{if(e&&typeof e==`object`&&`id`in e){let r=e;return(0,O.jsx)(v.Fragment,{children:t(r.id,r.basePath)},`${r.id}-${n}`)}return typeof e==`string`?(0,O.jsx)(v.Fragment,{children:t(e)},`${e}-${n}`):null})}):null,Pte=DO({children:qw.ChildList,justify:OO([`center`,`end`,`spaceAround`,`spaceBetween`,`spaceEvenly`,`start`,`stretch`]).optional(),align:OO([`start`,`center`,`end`,`stretch`]).optional()}),Fte=e=>{switch(e){case`center`:return`center`;case`end`:return`flex-end`;case`spaceAround`:return`space-around`;case`spaceBetween`:return`space-between`;case`spaceEvenly`:return`space-evenly`;case`start`:return`flex-start`;case`stretch`:return`stretch`;default:return`flex-start`}},Ite=e=>{switch(e){case`start`:return`flex-start`;case`center`:return`center`;case`end`:return`flex-end`;case`stretch`:return`stretch`;default:return`stretch`}},Lte=Jw({name:`Row`,schema:Pte},({props:e,buildChild:t})=>(0,O.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:Fte(e.justify),alignItems:Ite(e.align)},children:(0,O.jsx)(kO,{childList:e.children,buildChild:t})})),Rte=DO({children:qw.ChildList,justify:OO([`start`,`center`,`end`,`spaceBetween`,`spaceAround`,`spaceEvenly`,`stretch`]).optional(),align:OO([`center`,`end`,`start`,`stretch`]).optional()}),zte=e=>{switch(e){case`center`:return`center`;case`end`:return`flex-end`;case`spaceAround`:return`space-around`;case`spaceBetween`:return`space-between`;case`spaceEvenly`:return`space-evenly`;case`start`:return`flex-start`;case`stretch`:return`stretch`;default:return`flex-start`}},Bte=e=>{switch(e){case`start`:return`flex-start`;case`center`:return`center`;case`end`:return`flex-end`;case`stretch`:return`stretch`;default:return`stretch`}};new Ix(`https://a2ui.org/specification/v0_9/catalogs/minimal/minimal_catalog.json`,[Mte,Nte,Lte,Jw({name:`Column`,schema:Rte},({props:e,buildChild:t})=>(0,O.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,justifyContent:zte(e.justify),alignItems:Bte(e.align),gap:`8px`},children:(0,O.jsx)(kO,{childList:e.children,buildChild:t})})),Jw({name:`TextField`,schema:DO({label:qw.DynamicString,value:qw.DynamicString,variant:OO([`longText`,`number`,`shortText`,`obscured`]).optional(),validationRegexp:Ate().optional()})},({props:e,context:t})=>{let n=t=>{e.setValue&&e.setValue(t.target.value)},r=e.variant===`longText`,i=e.variant===`number`?`number`:e.variant===`obscured`?`password`:`text`,a={padding:`8px`,width:`100%`,border:`1px solid #ccc`,borderRadius:`4px`,boxSizing:`border-box`},o=`textfield-${t.componentModel.id}`;return(0,O.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`,width:`100%`},children:[e.label&&(0,O.jsx)(`label`,{htmlFor:o,style:{fontSize:`14px`,fontWeight:`bold`},children:e.label}),r?(0,O.jsx)(`textarea`,{id:o,style:a,value:e.value||``,onChange:n}):(0,O.jsx)(`input`,{id:o,type:i,style:a,value:e.value||``,onChange:n})]})})],[Fx({name:`capitalize`,returnType:`string`,schema:DO({value:jte()})},e=>{let t=e.value;return typeof t==`string`?t.toUpperCase():t})]);var AO=(0,v.createContext)(null),jO=(0,v.createContext)(null);function Vte({onAction:e,theme:t,catalog:n,children:r}){let i=(0,v.useRef)(e??null);i.current=e??null;let a=(0,v.useRef)(null);a.current||=new Ow([n??lD],e=>{if(i.current){let t={userAction:{name:e?.name??`unknown`,surfaceId:e?.surfaceId??`default`,sourceComponentId:e?.sourceComponentId,context:e?.context,timestamp:e?.timestamp??new Date().toISOString()}};i.current(t)}});let o=a.current,[s,c]=(0,v.useState)(0),[l,u]=(0,v.useState)(null),d=(0,v.useRef)(null);d.current||={processMessages:e=>{try{o.processMessages(e)}catch(e){console.warn(`[A2UI] processMessages error:`,e),u(e instanceof Error?e.message:String(e));return}u(null),c(e=>e+1)},dispatch:e=>{i.current&&i.current(e)},getSurface:e=>o.model.getSurface(e),clearSurfaces:()=>{let e=o.model.surfacesMap;for(let[t]of e)o.processMessages([{version:`v0.9`,deleteSurface:{surfaceId:t}}]);c(e=>e+1)}};let f=d.current,p=(0,v.useMemo)(()=>({version:s,error:l}),[s,l]);return(0,O.jsx)(AO.Provider,{value:f,children:(0,O.jsx)(jO.Provider,{value:p,children:(0,O.jsx)(dD,{theme:t,children:r})})})}function Hte(){let e=(0,v.useContext)(AO);if(!e)throw Error(`useA2UIActions must be used within an A2UIProvider`);return e}function Ute(){let e=(0,v.useContext)(jO);if(!e)throw Error(`useA2UIState must be used within an A2UIProvider`);return e}function MO(){let e=Hte(),t=Ute();return{processMessages:e.processMessages,getSurface:e.getSurface,clearSurfaces:e.clearSurfaces,version:t.version}}function NO(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=NO(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function PO(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=NO(e))&&(r&&(r+=` `),r+=t);return r}function Wte(...e){return PO(e)}var Gte=(0,v.memo)(function(){return(0,O.jsx)(`div`,{className:`a2ui-loading`,style:{padding:`16px`,opacity:.5},children:`Loading...`})}),Kte=(0,v.memo)(function({surfaceId:e,className:t,fallback:n=null,loadingFallback:r}){let{getSurface:i,version:a}=MO(),o=i(e);if(!o)return(0,O.jsx)(O.Fragment,{children:n});let s=r??(0,O.jsx)(Gte,{});return(0,O.jsx)(`div`,{className:Wte(`a2ui-surface`,t),"data-surface-id":e,"data-version":a,children:(0,O.jsx)(v.Suspense,{fallback:s,children:(0,O.jsx)(mD,{surface:o})})})}),qte=`https://a2ui.org/specification/v0_9/basic_catalog.json`,Jte=`A2UI Component Schema — available components for generating UI surfaces. Use these component names and properties when creating A2UI operations.`;function Yte(e){for(let t of lD.components.keys())if(!e.components.has(t))return!1;return!0}function Xte(e){let t=[];for(let n of e.components.keys())lD.components.has(n)||t.push(n);return t}function Zte(e){let t=e??lD,n=[];if(n.push(`Available A2UI catalog:`),t.id===qte)return n.push(`- ${t.id} (basic catalog)`),n.join(`
|
|
88
|
+
`);let r=Yte(t),i=Xte(t);n.push(`- ${t.id}`),r?n.push(` Extends the basic catalog with all standard components plus:`):(n.push(` Custom catalog (does NOT include all basic components).`),n.push(` Custom components:`));for(let e of i){let r=t.components.get(e);if(!r)continue;let i=Dw(r.schema);n.push(` - ${e}:`),n.push(` ${JSON.stringify(i,null,2).split(`
|
|
89
|
+
`).join(`
|
|
90
|
+
`)}`)}return n.join(`
|
|
91
|
+
`)}var FO=lD,Qte={description:Jte,value:Zte(FO)};function IO(e){return e.map(e=>{let t=e.updateComponents;if(!t||typeof t!=`object`||Array.isArray(t))return e;let n=t.components;if(!Array.isArray(n))return e;let r=n.filter(e=>!!(e&&typeof e==`object`&&!Array.isArray(e)));if(r.some(e=>e.id===`root`))return e;let i=r.filter(e=>typeof e.id==`string`&&e.id.endsWith(`-root`));if(i.length!==1)return e;let a=i[0];return{...e,updateComponents:{...t,components:n.map(e=>e===a?{...a,id:`root`}:e)}}})}function $te(e){for(let t of e){let e=t.updateComponents?.components;if(!Array.isArray(e)||!e.some(e=>e.component===`Form`&&e.id===`form`))continue;let n=e.filter(e=>e.component===`MultipleChoice`);if(n.length)return n.map(e=>String(e.description||e.label||e.id))}return null}function ene(e){return String(e.type||``).toUpperCase()}function tne(e,t){return String(e.messageId||t)}function nne(e,t){return String(e.runId||t)}function LO(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function rne(e){if(Array.isArray(e))return IO(e.filter(e=>!!(e&&typeof e==`object`)));if(e&&typeof e==`object`){let t=e.a2ui_operations;return Array.isArray(t)?IO(t.filter(e=>!!(e&&typeof e==`object`))):[e]}return[]}function ine(e){return e==null||e===``?``:typeof e==`string`?e:JSON.stringify(e,null,2)}var ane=class{agent;onEvent;tools=new Map;runMessageIds=new Map;pendingByRun=new Map;activeRunId=``;constructor(e){this.agent=new ib({url:e.url,agentId:e.agentId,threadId:e.threadId,fetch:e.fetch}),this.onEvent=e.onEvent}async run(e,t,n){return this.activeRunId=t,this.agent.addMessage({id:`${t}:user`,role:`user`,content:e}),this.execute({runId:t,abortController:this.controllerFor(n)})}async resume(e,t){let n=this.agent.pendingInterrupts.length>0?this.agent.pendingInterrupts:this.pendingByRun.get(this.activeRunId)||[],r=By(n.length>0?n:[{id:t.interruptId,reason:`approval`}],{[t.interruptId]:t.status===`resolved`?{status:`resolved`,payload:t.payload}:{status:`cancelled`}});if(!r.some(e=>e.interruptId===t.interruptId))throw Error(`AG-UI interrupt ${t.interruptId} is not pending`);return this.activeRunId=e,this.execute({runId:e,resume:r})}abort(){this.agent.abortRun()}controllerFor(e){if(!e)return;let t=new AbortController;return e.aborted&&t.abort(e.reason),e.addEventListener(`abort`,()=>t.abort(e.reason),{once:!0}),t}async execute(e){let t=`completed`,n=await this.agent.runAgent({runId:e.runId,context:[Qte],forwardedProps:{injectA2UITool:!0},resume:e.resume,abortController:e.abortController},{onEvent:({event:n})=>{let r=this.project(n,e.runId);r.status&&(t=r.status),r.events.forEach(e=>this.onEvent(e))},onRunFinishedEvent:({outcome:e})=>{t=e===`interrupt`?`interrupted`:`completed`},onRunErrorEvent:()=>{t=`failed`}}),r=this.agent.pendingInterrupts.slice();return r.length>0&&(this.pendingByRun.set(e.runId,r),t=`interrupted`),{status:t,result:n}}project(e,t){let n=ene(e),r=nne(e,t),i=tne(e,`${r}:assistant`),a=e,o=[];if(n===`RUN_STARTED`)o.push({type:`activity`,phase:`AG-UI 运行已创建`,status:`running`,countEvent:!1});else if(n===`TEXT_MESSAGE_START`)this.runMessageIds.set(r,i),o.push({type:`assistant_message_created`,messageId:i});else if(n===`TEXT_MESSAGE_CONTENT`)o.push({type:`text_delta`,messageId:this.runMessageIds.get(r)||i,delta:String(a.delta||``)});else if(n===`TEXT_MESSAGE_END`)o.push({type:`activity`,phase:`生成回复内容`,status:`running`});else if(n===`REASONING_MESSAGE_CONTENT`)o.push({type:`reasoning_delta`,messageId:this.runMessageIds.get(r)||i,delta:String(a.delta||``)});else if(n===`TOOL_CALL_START`){let e=String(a.toolCallId||`tool`);this.tools.set(e,{name:String(a.toolCallName||`tool`),args:``}),o.push({type:`tool_upsert`,messageId:this.runMessageIds.get(r)||`${r}:assistant`,name:String(a.toolCallName||`tool`),args:``,status:`running`})}else if(n===`TOOL_CALL_ARGS`){let e=String(a.toolCallId||`tool`),t=this.tools.get(e)||{name:`tool`,args:``};t.args+=String(a.delta||``),this.tools.set(e,t),o.push({type:`tool_upsert`,messageId:this.runMessageIds.get(r)||`${r}:assistant`,name:t.name,args:t.args,status:`running`})}else if(n===`TOOL_CALL_RESULT`){let e=String(a.toolCallId||`tool`),t=this.tools.get(e)||{name:`tool`,args:``};o.push({type:`tool_result`,messageId:this.runMessageIds.get(r)||`${r}:assistant`,name:t.name,output:String(a.content||``)})}else if(n===`ACTIVITY_SNAPSHOT`){let e=a.content,t=LO(e),n=String(t.surfaceId||t.surface_id||a.messageId||`default`);o.push({type:`agui_activity`,messageId:this.runMessageIds.get(r)||i,surfaceId:n,messages:rne(t.content??e)})}else if(n===`RUN_FINISHED`){let e=LO(a.outcome);if(String(e.type||``).toLowerCase()===`interrupt`){let t=Array.isArray(e.interrupts)?e.interrupts:[];this.pendingByRun.set(r,t);for(let e of t){let t=LO(e.metadata),n=e.toolCallId?this.tools.get(e.toolCallId):void 0,i=String(t.tool_name||t.toolName||n?.name||e.reason||`人工确认`),a=ine(t.arguments??t.tool_args??t.args??n?.args);o.push({type:`approval_requested`,messageId:this.runMessageIds.get(r)||`${r}:assistant`,approvalRequestId:e.id,protocol:`ag-ui`,name:i,args:a,...e.message?{message:e.message}:{},...t.approval_level?{approvalLevel:String(t.approval_level)}:{}})}return o.push({type:`activity`,phase:`等待人工确认`,status:`waiting`}),{events:o,status:`interrupted`}}o.push({type:`terminal`,status:`completed`})}else if(n===`RUN_ERROR`)return o.push({type:`error`,error:Error(`AG-UI 运行失败`)}),{events:o,status:`failed`};return{events:o}}},RO=class extends Error{code;status;capability;runId;cursor;cause;constructor(e,t,n={}){super(t),this.name=`ConversationClientError`,this.code=e,this.status=n.status,this.capability=n.capability,this.runId=n.runId,this.cursor=n.cursor,this.cause=n.cause}},zO=`conversation.ksadk.io/v1`,BO=/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/,one=new Set([`native`,`translated`,`degraded`,`unavailable`]),sne=new Set([`user_message`,`assistant_text`,`reasoning`,`tool_call`,`approval`,`progress`,`plan`,`goal`,`artifact`,`a2ui`,`error`,`unknown`]),cne=new Set([`append`,`replace`,`completed`]),lne=new Set([`pending`,`streaming`,`completed`,`failed`]),une=new Set([`public`,`internal`,`hidden`]),dne=new Set([`apiVersion`,`kind`,`inputId`,`sessionId`,`idempotencyKey`,`parts`,`modelRef`,`reasoning`,`extensions`]),fne=new Set([`kind`,`text`]),pne=new Set([`kind`,`attachmentRef`,`mediaType`,`name`]),VO=`ksadk.approval`,HO=`ksadk.collaboration`,UO=`ksadk.goal`;function WO(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function GO(e,t){return typeof e==`string`&&e.length>0&&e.length<=t}function KO(e,t,n=!1){return e==null||typeof e==`string`&&e.length<=t&&(n||e.length>0)}function qO(e,t){return Object.keys(e).every(e=>t.has(e))}function mne(e){let t=WO(e);return!t||typeof t.kind!=`string`?null:t.kind===`text`?!qO(t,fne)||!GO(t.text,131072)?null:{kind:`text`,text:t.text}:t.kind===`attachment`?!qO(t,pne)||!GO(t.attachmentRef,2048)||!GO(t.mediaType,256)||!KO(t.name,1024,!0)?null:{kind:`attachment`,attachmentRef:t.attachmentRef,mediaType:t.mediaType,...t.name===void 0?{}:{name:t.name}}:null}function hne(e){if(e===void 0)return{};let t=WO(e);if(!t||Object.keys(t).some(e=>!BO.test(e)||!e.includes(`.`)))return null;let n=t[VO],r=t[HO],i=t[UO];return n!==void 0&&![`ask`,`risk`,`full`].includes(String(n))||r!==void 0&&![`default`,`plan`].includes(String(r))||i!==void 0&&!GO(i,4096)?null:{...t}}function gne(e){let t=WO(e);if(!t||!qO(t,dne)||t.apiVersion!==zO||t.kind!==`ConversationInput`||!GO(t.inputId,256)||!GO(t.sessionId,256)||!GO(t.idempotencyKey,512)||!Array.isArray(t.parts)||t.parts.length===0||!KO(t.modelRef,256)||!KO(t.reasoning,64))return null;let n=t.parts.map(mne),r=hne(t.extensions);return n.some(e=>e===null)||r===null?null:{apiVersion:zO,kind:`ConversationInput`,inputId:t.inputId,sessionId:t.sessionId,idempotencyKey:t.idempotencyKey,parts:n,...t.modelRef===void 0?{}:{modelRef:t.modelRef},...t.reasoning===void 0?{}:{reasoning:t.reasoning},...t.extensions===void 0?{}:{extensions:r}}}function _ne(e){let t=gne({...e,apiVersion:e.apiVersion||zO,kind:e.kind||`ConversationInput`});if(!t)throw new RO(`conversation_contract_mismatch`,`Conversation input does not match conversation.ksadk.io/v1.`);return t}function JO(e){let t=e.parts.map(e=>e.kind===`text`?`text`:e.mediaType.toLowerCase().startsWith(`image/`)?`attachment.image`:`attachment.file`);e.modelRef&&t.push(`model.select`),e.reasoning&&t.push(`reasoning.effort`);for(let n of Object.keys(e.extensions||{}))n===VO?t.push(`approval`):n===HO?e.extensions?.[n]===`plan`&&t.push(`plan`):n===UO?t.push(`goal`):t.push(n);return[...new Set(t)]}function YO(e,t){if(e.sessionId!==t.sessionId)throw new RO(`conversation_session_mismatch`,`Conversation input session does not match the active surface.`);for(let n of JO(t))if(!ek(e,n))throw new RO(`conversation_input_unsupported`,`Conversation input is not declared by the active surface.`,{capability:n});return t}function XO(e){let t=WO(e);return!t||!GO(t.name,128)||!BO.test(t.name)||!one.has(t.mode)||!KO(t.reason,512,!0)||(t.mode===`degraded`||t.mode===`unavailable`)&&!GO(t.reason,512)?null:{name:t.name,mode:t.mode,...t.reason===void 0?{}:{reason:t.reason}}}function ZO(e){if(e===void 0)return[];if(!Array.isArray(e))return null;let t=e.map(XO);if(t.some(e=>e===null))return null;let n=t;return new Set(n.map(e=>e.name)).size===n.length?n:null}function QO(e){let t=WO(e);if(!t||t.apiVersion!==zO||t.kind!==`ConversationSurface`||!GO(t.surfaceId,256)||!GO(t.sessionId,256)||!GO(t.providerRef,256))return null;let n=ZO(t.inputs),r=ZO(t.outputs);return!n||!r?null:{apiVersion:zO,kind:`ConversationSurface`,surfaceId:t.surfaceId,sessionId:t.sessionId,providerRef:t.providerRef,inputs:n,outputs:r}}function $O(e){let t=WO(e);if(!t||t.apiVersion!==zO||t.kindVersion!==1||!GO(t.itemId,512)||!KO(t.parentItemId,512)||!Array.isArray(t.sourceEventIds)||t.sourceEventIds.length===0||t.sourceEventIds.some(e=>typeof e!=`string`||e.length===0)||new Set(t.sourceEventIds).size!==t.sourceEventIds.length||!GO(t.sessionId,256)||!GO(t.runId,256)||!GO(t.kind,128)||!cne.has(t.operation)||!lne.has(t.lifecycle)||t.visibility!==void 0&&!une.has(t.visibility)||!GO(t.payloadSchemaRef,256)||!KO(t.capabilityRef,256,!0))return null;let n=t.operation,r=t.lifecycle;if(n===`completed`&&r!==`completed`&&r!==`failed`)return null;let i=t.payload===void 0?{}:WO(t.payload),a=t.nativeRef===void 0?{}:WO(t.nativeRef);if(!i||!a)return null;let o=String(t.kind||`unknown`),s=sne.has(o)?o:`unknown`;return{apiVersion:zO,kindVersion:1,itemId:t.itemId,...t.parentItemId===void 0?{}:{parentItemId:t.parentItemId},sourceEventIds:[...t.sourceEventIds],sessionId:t.sessionId,runId:t.runId,kind:s,operation:n,lifecycle:r,visibility:s===`unknown`&&o!==`unknown`?`hidden`:t.visibility||`public`,payloadSchemaRef:t.payloadSchemaRef,payload:s===`unknown`&&o!==`unknown`?{originalKind:o,summary:`This content type is not supported by the current renderer.`}:{...i},...t.capabilityRef===void 0?{}:{capabilityRef:t.capabilityRef},nativeRef:{...a}}}function ek(e,...t){return e.inputs.some(e=>t.includes(e.name)&&(e.mode===`native`||e.mode===`translated`))}var tk={user_message:`conversation.item.user_message/v1`,assistant_text:`conversation.item.assistant_text/v1`,reasoning:`conversation.item.reasoning/v1`,tool_call:`conversation.item.tool-call/v1`,approval:`conversation.item.approval/v1`,artifact:`conversation.item.artifact/v1`,a2ui:`conversation.item.a2ui/v1`,error:`conversation.item.error/v1`};function nk(e){return e.lifecycle===`completed`||e.lifecycle===`failed`}var rk=new Set([`aborted`,`canceled`,`cancelled`,`failed`,`incomplete`,`interrupted`]);function ik(e){if(e.kind!==`progress`&&e.kind!==`error`||!nk(e))return;let t=typeof e.payload.status==`string`?e.payload.status.toLowerCase():``;if(t===`completed`)return`completed`;if(rk.has(t))return`failed`}function ak(e){let t=tk[e.kind];return t===void 0||t===e.payloadSchemaRef}function ok(e){if(typeof e!=`string`||e.length===0)return null;try{let t=new URL(e);return t.protocol!==`http:`&&t.protocol!==`https:`||t.username||t.password?null:t.toString()}catch{return null}}function sk(e){return{id:e.itemId,parentId:e.parentItemId||null,runId:e.runId,kind:e.kind,text:typeof e.payload.text==`string`?e.payload.text:``,lifecycle:e.lifecycle}}function ck(e){return{id:e.itemId,name:typeof e.payload.name==`string`&&e.payload.name?e.payload.name:`Artifact`,mimeType:typeof e.payload.mimeType==`string`&&e.payload.mimeType?e.payload.mimeType:`application/octet-stream`,uri:ok(e.payload.uri)}}function lk(e,t){let n=e.payload[t];return typeof n==`string`&&n?n:null}function uk(e){if(e.kind===`tool_call`){let t=lk(e,`callId`);if(t)return`tool:${t}`}if(e.kind===`approval`){let t=lk(e,`interactionId`);if(t)return`approval:${t}`}if(e.kind===`a2ui`){let t=lk(e,`surfaceId`);if(t)return`a2ui:${t}`}return`item:${e.itemId}`}function dk(e,t){let n=nk(e)&&!nk(t);return{...e,...t,itemId:e.itemId,parentItemId:e.parentItemId,sourceEventIds:[...new Set([...e.sourceEventIds,...t.sourceEventIds])],payload:{...e.payload,...t.payload},nativeRef:{...e.nativeRef,...t.nativeRef},...n?{lifecycle:e.lifecycle,operation:e.operation}:{}}}function fk(e){let t=[],n=new Map;for(let r of e){let e=uk(r),i=n.get(e);if(i===void 0){n.set(e,t.length),t.push({key:e,item:r,sourceItemIds:[r.itemId]});continue}let a=t[i];t[i]={key:e,item:dk(a.item,r),sourceItemIds:[...new Set([...a.sourceItemIds,r.itemId])]}}return t}function pk(e,t={}){let n=e.items.filter(e=>e.visibility===`public`||t.includeInternal===!0&&e.visibility===`internal`),r=n.filter(ak),i=n.filter(e=>!ak(e)),a=new Set([`user_message`,`assistant_text`,`reasoning`]),o=r.filter(e=>a.has(e.kind)).map(sk),s=e=>r.filter(t=>t.kind===e).map(e=>typeof e.payload.text==`string`?e.payload.text:``).join(``),c=[...r.filter(e=>e.kind===`unknown`),...i],l=r.filter(e=>e.kind===`error`),u=[...r].reverse().find(e=>ik(e)!==void 0);return{timeline:fk(r.filter(e=>e.kind!==`progress`)),output:s(`assistant_text`),reasoning:s(`reasoning`),textItems:o,toolItems:r.filter(e=>e.kind===`tool_call`),approvalItems:r.filter(e=>e.kind===`approval`),structuredInputItems:r.filter(e=>e.kind===`progress`&&e.payloadSchemaRef===`conversation.item.structured-input/v1`),a2uiItems:r.filter(e=>e.kind===`a2ui`),artifacts:r.filter(e=>e.kind===`artifact`).map(ck),fallbacks:[...c.map(e=>({id:e.itemId,title:`Unsupported content`,detail:String(e.payload.summary||e.payload.originalKind||e.payloadSchemaRef),failed:e.lifecycle===`failed`})),...l.map(e=>({id:e.itemId,title:`Run failed`,detail:String(e.payload.error||`The agent run failed.`),failed:!0}))],runId:n.at(-1)?.runId||``,terminalStatus:u?ik(u):void 0}}function mk(){return{items:[],appliedSources:[]}}function hk(e){return e.lifecycle===`completed`||e.lifecycle===`failed`}function gk(e,t){let n={...e,...t};typeof e.text==`string`&&typeof t.text==`string`&&(n.text=e.text+t.text);for(let r of[`data`,`operations`])Array.isArray(e[r])&&Array.isArray(t[r])&&(n[r]=[...e[r],...t[r]]);return n}function _k(e,t){let n=t.sourceEventIds.map(e=>JSON.stringify([t.itemId,e])),r=new Set(e.appliedSources);if(n.every(e=>r.has(e)))return e;n.forEach(e=>r.add(e));let i=e.items.findIndex(e=>e.itemId===t.itemId),a=i>=0?e.items[i]:void 0;if(a&&hk(a)&&!hk(t))return{...e,appliedSources:[...r]};let o=[...e.items];if(!a)o.push(t);else{let e=[...new Set([...a.sourceEventIds,...t.sourceEventIds])];a.kind===t.kind?t.operation===`append`?o[i]={...t,payload:gk(a.payload,t.payload),sourceEventIds:e}:o[i]={...t,sourceEventIds:e}:o[i]={...t,kind:`unknown`,operation:`replace`,payloadSchemaRef:`conversation.item.unknown/v1`,payload:{summary:`The content type changed for the same item and was safely degraded.`},sourceEventIds:e}}return{items:o,appliedSources:[...r]}}var vk=class{state=mk();apply(e){let t=_k(this.state,e);if(t===this.state)return!1;let n=t.items!==this.state.items;return this.state=t,n}applyAll(e){for(let t of e)this.apply(t)}snapshot(){return{items:this.state.items.map(e=>({...e,sourceEventIds:[...e.sourceEventIds],payload:{...e.payload},nativeRef:{...e.nativeRef}})),appliedSources:[...this.state.appliedSources]}}},yk=8;function bk(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function xk(e){if(e?.aborted)throw new RO(`conversation_aborted`,`Conversation request was aborted.`)}function Sk(e,t){return t?.aborted===!0||e instanceof Error&&e.name===`AbortError`}function Ck(e){let t=e.trim().replace(/\/+$/,``);if(!t)return``;if(!t.includes(`://`))return t.startsWith(`/`)?t:`/${t}`;try{let e=new URL(t);if(e.protocol!==`http:`&&e.protocol!==`https:`||e.username||e.password)throw Error(`unsafe URL`);return e.toString().replace(/\/$/,``)}catch(e){throw new RO(`conversation_contract_mismatch`,`Conversation base URL must be an HTTP(S) URL without embedded credentials.`,{cause:e})}}function wk(e){return Math.min(200*2**Math.max(0,e-1),2e3)}function Tk(e){return new Promise(t=>{setTimeout(t,e)})}async function Ek(e,t,n){if(xk(n),!n){await e(t);return}await new Promise((r,i)=>{let a=()=>i(new RO(`conversation_aborted`,`Conversation request was aborted.`));n.addEventListener(`abort`,a,{once:!0}),e(t).then(r,i).finally(()=>{n.removeEventListener(`abort`,a)})})}function Dk(e,t,n){let r=e.snapshot();return{cursor:t,runId:n,state:r,presentation:pk(r)}}function Ok(e,t){let n,r=[];for(let t of e.split(/\r?\n/)){let e=t.endsWith(`\r`)?t.slice(0,-1):t;if(!e||e.startsWith(`:`))continue;let i=e.indexOf(`:`),a=i<0?e:e.slice(0,i),o=i<0?``:e.slice(i+1),s=o.startsWith(` `)?o.slice(1):o;if(a===`id`){if(!/^\d+$/.test(s)||!Number.isSafeInteger(Number(s)))throw new RO(`conversation_stream_error`,`Conversation stream contains an invalid replay cursor.`);n=Number(s)}else a===`data`&&r.push(s)}if(r.length===0)return;let i=r.join(`
|
|
92
|
+
`);if(!i||i===`[DONE]`)return;let a;try{a=JSON.parse(i)}catch(e){throw new RO(`conversation_contract_mismatch`,`Conversation stream contains invalid JSON.`,{cause:e})}let o=bk(a);if(!o||o.conversationItem===void 0){n!==void 0&&(t.cursor=Math.max(t.cursor,n));return}if(n===void 0)throw new RO(`conversation_stream_error`,`Canonical conversation items require an SSE replay cursor.`);let s=$O(o.conversationItem);if(!s)throw new RO(`conversation_contract_mismatch`,`Conversation stream item does not match conversation.ksadk.io/v1.`);if(t.runId&&t.runId!==s.runId)throw new RO(`conversation_contract_mismatch`,`Conversation stream changed canonical run identity.`,{runId:t.runId,cursor:t.cursor});t.runId=s.runId;let c=t.reducer.apply(s);t.cursor=Math.max(t.cursor,n),c&&t.options.onItem?.(s),t.options.onUpdate?.(Dk(t.reducer,t.cursor,t.runId))}async function kk(e,t){if(!e.body)throw new RO(`conversation_stream_error`,`Conversation response has no event stream body.`);let n=e.body.getReader(),r=new TextDecoder,i=``;try{for(;;){xk(t.options.signal);let{value:e,done:a}=await n.read();if(a)break;i+=r.decode(e,{stream:!0});let o=/\r?\n\r?\n/.exec(i);for(;o?.index!==void 0;){let e=o.index,n=o[0].length;Ok(i.slice(0,e),t),i=i.slice(e+n),o=/\r?\n\r?\n/.exec(i)}}i+=r.decode(),i.trim()&&Ok(i,t)}catch(e){throw e instanceof RO?e:(Sk(e,t.options.signal)&&xk(t.options.signal),new RO(`conversation_stream_error`,`Conversation event stream was interrupted.`,{cause:e,runId:t.runId||void 0,cursor:t.cursor}))}finally{n.releaseLock()}}function Ak(e){return e.state.items.some(e=>ik(e)!==void 0)}var jk=class{fetcher;baseUrl;maxReconnects;sleep;retryDelayMs;constructor(e={}){if(!Number.isInteger(e.maxReconnects??yk)||(e.maxReconnects??yk)<0||(e.maxReconnects??yk)>32)throw new RO(`conversation_contract_mismatch`,`Conversation reconnect limit must be an integer from 0 to 32.`);this.fetcher=e.fetch,this.baseUrl=Ck(e.baseUrl||``),this.maxReconnects=e.maxReconnects??yk,this.sleep=e.sleep||Tk,this.retryDelayMs=e.retryDelayMs||wk}fetch(){if(this.fetcher)return this.fetcher;if(typeof globalThis.fetch==`function`)return globalThis.fetch.bind(globalThis);throw new RO(`conversation_http_error`,`No fetch implementation is available for the conversation client.`)}url(e){return`${this.baseUrl}${e}`}async request(e,t,n,r=`conversation_stream_error`){xk(n);try{return await this.fetch()(e,t)}catch(e){throw e instanceof RO?e:(Sk(e,n)&&xk(n),new RO(r,`Conversation network request failed.`,{cause:e}))}}assertOk(e){if(!e.ok)throw new RO(`conversation_http_error`,`Conversation endpoint returned HTTP ${e.status}.`,{status:e.status})}async getSurface(e,t,n={}){if(!e||!t)throw new RO(`conversation_contract_mismatch`,`Agent and session identities are required to get a conversation surface.`);let r=n.signal?{signal:n.signal}:void 0,i=await this.request(this.url(`/api/v1/agents/${encodeURIComponent(e)}/conversation-surface?sessionId=${encodeURIComponent(t)}`),r,n.signal,`conversation_http_error`);this.assertOk(i);let a;try{a=await i.json()}catch(e){throw new RO(`conversation_contract_mismatch`,`Conversation surface response is not valid JSON.`,{cause:e})}let o=bk(a),s=QO(o?.surface);if(!o||typeof o.buildId!=`string`||!o.buildId||!s)throw new RO(`conversation_contract_mismatch`,`Conversation surface response does not match conversation.ksadk.io/v1.`);return{buildId:o.buildId,surface:s}}async streamTurn(e){xk(e.signal),YO(e.bootstrap.surface,e.input);let t={cursor:0,runId:``,reducer:new vk,options:e},n={method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":e.input.idempotencyKey},body:JSON.stringify({input:e.input}),...e.signal?{signal:e.signal}:{}},r=await this.request(this.url(`/api/v1/builds/${encodeURIComponent(e.bootstrap.buildId)}/conversation:stream`),n,e.signal);this.assertOk(r);try{await kk(r,t)}catch(e){if(!(e instanceof RO)||e.code!==`conversation_stream_error`||!t.runId)throw e}let i=Dk(t.reducer,t.cursor,t.runId);if(Ak(i))return i;if(!t.runId)throw new RO(`conversation_run_identity_missing`,`The stream ended before a canonical item supplied its run identity.`,{cursor:t.cursor});for(let n=1;n<=this.maxReconnects;n+=1){await Ek(this.sleep,this.retryDelayMs(n),e.signal),xk(e.signal);let r;try{r=await this.request(this.url(`/api/v1/runs/${encodeURIComponent(t.runId)}/events?after=${t.cursor}`),{method:`GET`,headers:{"Last-Event-ID":String(t.cursor)},...e.signal?{signal:e.signal}:{}},e.signal),this.assertOk(r),await kk(r,t)}catch(e){if(e instanceof RO&&e.code===`conversation_aborted`||e instanceof RO&&e.code===`conversation_contract_mismatch`||e instanceof RO&&e.code===`conversation_http_error`&&e.status!==void 0&&e.status<500)throw e;continue}if(i=Dk(t.reducer,t.cursor,t.runId),Ak(i))return i}throw new RO(`conversation_reconnect_exhausted`,`Conversation replay stopped after the configured reconnect limit.`,{runId:t.runId,cursor:t.cursor})}},Mk=new Set([`completed`,`failed`,`error`,`cancelled`,`canceled`,`aborted`,`interrupted`,`resume_failed`]);function Nk(e){if(e.EventType!==`run_status`)return null;let t=String(e.Content?.status||``).trim().toLowerCase();return Mk.has(t)?t:null}function Pk(e,t){let n=String(t?.type||e||``).trim();if(n===`response.created`)return{phase:`运行已创建`,status:`running`};if(n===`response.in_progress`)return{phase:`等待运行时输出`,status:`waiting`};if(n===`response.output_item.added`){let e=t?.item;return e?.type===`function_call`?{phase:`调用工具 ${e.name||`tool`}`,status:`running`}:String(e?.type||``).includes(`reasoning`)?{phase:`生成思考过程`,status:`running`}:{phase:`生成回复内容`,status:`running`}}return n.includes(`reasoning`)?{phase:`生成思考过程`,status:`running`}:n.includes(`function_call`)||n===`response.tool_call`?{phase:`调用工具`,status:`running`}:n.includes(`tool_result`)?{phase:`收到工具结果`,status:`running`}:n.includes(`output_text`)||n.includes(`content_part`)?{phase:`生成回复内容`,status:`running`}:n===`response.completed`?{phase:`运行完成`,status:`completed`}:n===`response.failed`?{phase:`运行失败`,status:`failed`}:n===`response.incomplete`?{phase:`运行中断`,status:`failed`}:null}function Fk(){let e=globalThis.crypto;return e&&typeof e.randomUUID==`function`?`run_${e.randomUUID()}`:`run_${Date.now()}_${Math.random().toString(16).slice(2)}`}var Ik={idle:[`creating-session`,`uploading-files`,`connecting`,`error`],"creating-session":[`uploading-files`,`connecting`,`error`,`idle`],"uploading-files":[`connecting`,`error`,`idle`],connecting:[`streaming`,`error`,`idle`],streaming:[`completing`,`stopping`,`recovering`,`error`],stopping:[`cancelled`,`idle`],completing:[`idle`],recovering:[`streaming`,`error`,`idle`],error:[`connecting`,`idle`],cancelled:[`idle`]},Lk=class{_stage=`idle`;listeners=new Set;abortController=null;activeCompactionId=null;activeSessionId=null;aguiClient=null;aguiThreadSessionId=null;api;controlStateValue={phase:`idle`};lastControlCommand=null;config={agentId:`default-agent`,apiFormats:[`responses`],agentFramework:``,selectedModel:``,thinkingMode:`auto`};constructor(e){this.api=e}get stage(){return this._stage}get controlState(){return this.controlStateValue}async submitControl(e){this.lastControlCommand=e;let t;try{t=Vc(await this.api.submitControl(e))}catch(e){if(e instanceof Rc)return this.controlStateValue={phase:`contract_mismatch`,error:null,receipt:null},this.emit({type:`system_message`,content:`【系统提示】控制指令响应不符合 agent-kernel/v1 合同,已停止变更本地状态。`}),this.controlStateValue;throw e}return this.controlStateValue=this.controlStateFor(t,e),t.status===`accepted`||t.status===`duplicate`?this.emit({type:`activity`,phase:`指令已入队,等待运行时处理`,status:`waiting`,countEvent:!1}):t.status===`queue_full`?this.emit({type:`system_message`,content:`【系统提示】指令队列已满,可点击重试;重试将复用同一幂等键。`}):t.status===`unsupported`?this.emit({type:`system_message`,content:`【系统提示】运行时不支持该操作:${t.error?.message||``}`}):t.status===`persistence_uncertain`?this.emit({type:`system_message`,content:`【系统提示】指令提交结果待确认,正在查询状态…`}):t.status===`rejected`&&this.emit({type:`system_message`,content:`【系统提示】指令被拒绝:${t.error?.message||``}`}),this.controlStateValue}controlStateFor(e,t){switch(e.status){case`accepted`:case`duplicate`:return{phase:`queued`,receipt:e,error:null};case`queue_full`:return{phase:`retryable`,retryKey:t.idempotency_key,receipt:e,error:e.error};case`unsupported`:return{phase:`unsupported`,receipt:e,error:e.error};case`persistence_uncertain`:return{phase:`confirming`,retryKey:t.idempotency_key,receipt:e,error:e.error};default:return{phase:`rejected`,receipt:e,error:e.error}}}async retryControl(){let e=this.lastControlCommand;if(!e||this.controlStateValue.phase!==`retryable`&&this.controlStateValue.phase!==`confirming`)return this.controlStateValue;if(this.controlStateValue.phase===`confirming`)try{await this.api.getAgentStatus()}catch(e){console.warn(`[RunEngine] status query after persistence_uncertain failed:`,e)}return this.submitControl(e)}updateConfig(e){this.config={...e,apiFormats:[...e.apiFormats]}}emit(e){let t=`sessionId`in e?e:{...e,sessionId:this.activeSessionId};for(let e of this.listeners)e(t)}getAguiClient(e){let t=this.config.hostedChatTransport;return t?.Protocol!==`ag-ui`||!t.Endpoint?null:((!this.aguiClient||this.aguiThreadSessionId!==e)&&(this.aguiClient=new ane({url:t.Endpoint,agentId:this.config.agentId,threadId:e,onEvent:e=>this.emit(e)}),this.aguiThreadSessionId=e),this.aguiClient)}setStage(e){let t=Ik[this._stage];t&&!t.includes(e)&&console.warn(`[RunEngine] Invalid transition: ${this._stage} → ${e}`),this._stage=e,this.emit({type:`stage_changed`,stage:e})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}start(e){if(this._stage!==`idle`)return!1;this.abortController=new AbortController;let t=e.responsesInput!==void 0;return(async()=>{let n=e.sessionId||null;try{n||=await this.createSession(e),n||=`default-session-${Date.now()}`,this.activeSessionId=n;let r=Fk();k.getState().setCurrentRunId(r),k.getState().setActiveInvocationId(r),k.getState().setLastSeqId(0);let i=t?null:await this.getConversationBootstrap(n);if(i&&this.config.conversationClient){let t=await this.buildCanonicalConversationInput(i,n,r,e);this.setStage(`connecting`),this.emit({type:`activity`,phase:`连接会话运行时`,status:`connecting`,countEvent:!1}),this.setStage(`streaming`),this.emit({type:`activity`,phase:`等待会话输出`,status:`waiting`,countEvent:!1});let a=await this.config.conversationClient.streamTurn({bootstrap:i,input:t,signal:this.abortController?.signal,onUpdate:e=>{e.runId&&(k.getState().setCurrentRunId(e.runId),k.getState().setActiveInvocationId(e.runId)),this.emit({type:`conversation_snapshot`,result:e,sessionId:n})}});if(a.presentation.terminalStatus===`failed`){this.setStage(`error`),this.emit({type:`activity`,phase:`运行失败`,status:`failed`,countEvent:!1});return}this.setStage(`completing`),this.emit({type:`activity`,phase:`运行完成`,status:`completed`,countEvent:!1}),this.emit({type:`stream_ended`,sessionId:n,runId:a.runId});return}let a=await this.uploadFiles(e,t);this.setStage(`connecting`),this.emit({type:`activity`,phase:`连接运行时`,status:`connecting`,countEvent:!1});let o=t?`responses`:Tl({agentFramework:this.config.agentFramework,apiFormats:this.config.apiFormats}),s=vl(o),c=s.createState(),l=this.config.hostedChatTransport,u=!t&&!e.executionMode&&e.attachments.length===0&&l?.Protocol===`ag-ui`?this.getAguiClient(n):null;if(u&&l){this.setStage(`streaming`),this.emit({type:`activity`,phase:`等待 AG-UI 输出`,status:`waiting`,countEvent:!1});let t=await u.run(e.text,r,this.abortController?.signal);if(t.status===`interrupted`){this.setStage(`completing`),this.emit({type:`stream_ended`});return}if(t.status!==`completed`){this.setStage(`error`),this.emit({type:`activity`,phase:`AG-UI 运行失败`,status:`failed`,countEvent:!1});return}this.setStage(`completing`),this.emit({type:`activity`,phase:`运行完成`,status:`completed`,countEvent:!1}),this.emit({type:`stream_ended`});return}let d=this.buildRequestBody(n,o,t,e,a,r),f=await this.api.runAgent(d,{signal:this.abortController?.signal});this.setStage(`streaming`),this.emit({type:`activity`,phase:`等待首个输出`,status:`waiting`,countEvent:!1});let p=`msg-${Date.now()}`,m=await Hl(f),h;if(h=m.receipt?await this.consumeKernelRunEvents(n,r,m.receipt,p):await this.consumeStream(m.stream,s,c,p,r),h.terminalStatus===`cancelled`){this.setStage(`stopping`),k.getState().stopActivity(`运行时已取消本次执行。`),this.emit({type:`activity`,phase:`运行已取消`,status:`stopped`,countEvent:!1}),this.setStage(`cancelled`);return}if(h.terminalStatus&&h.terminalStatus!==`completed`){this.setStage(`error`),this.emit({type:`activity`,phase:h.terminalStatus===`incomplete`?`运行中断`:`运行失败`,status:`failed`,countEvent:!1});return}this.setStage(`completing`),this.emit({type:`activity`,phase:`运行完成`,status:`completed`,countEvent:!1}),this.emit({type:`stream_ended`})}catch(e){if(this.failCompaction(),!(e instanceof DOMException&&e.name===`AbortError`||e instanceof RO&&e.code===`conversation_aborted`))if(console.error(`[RunEngine] start() error:`,e),e instanceof TypeError&&e.message.includes(`fetch`)){this.setStage(`recovering`),this.emit({type:`activity`,phase:`网络异常,尝试重连`,status:`waiting`,countEvent:!1});let e=k.getState().lastSeqId,t=k.getState().activeInvocationId;if(e>0&&t&&this.activeSessionId)try{this.resumeRun({sessionId:this.activeSessionId,invocationId:t,afterSeqId:e});return}catch(e){console.warn(`[RunEngine] afterSeqId resume failed, fall back to error:`,e)}}else e instanceof Jt&&e.code===429?(this.setStage(`error`),this.emit({type:`rate_limited`,message:e.message||`请求过于频繁,请稍后重试`,sessionId:n})):(this.setStage(`error`),this.emit({type:`error`,error:e instanceof Error?e:Error(String(e))}))}finally{k.getState().setSessionStreaming(n,!1),this.setStage(`idle`),this.activeCompactionId=null,this.activeSessionId=null,e.onSettled?.(n)}})(),!0}stop(){if(this._stage===`idle`)return;this.setStage(`stopping`);let e=k.getState().currentRunId;e&&this.activeSessionId&&this.api.cancelRun(this.config.agentId,this.activeSessionId,e).catch(e=>{console.warn(`[RunEngine] cancelRun on stop failed:`,e)}),this.abortController?.abort(),this.aguiClient?.abort(),k.getState().stopActivity(e?`已向运行时发送取消请求;如果当前框架只支持协作式取消,后台可能会在下一个安全点停止。`:void 0),k.getState().setCurrentRunId(``),this.setStage(`cancelled`),this.emit({type:`system_message`,content:e?`已请求取消本次运行。`:`已停止接收本次输出;如果运行时不支持取消,后台执行可能仍会继续。`})}disconnect(){this._stage!==`idle`&&(this.abortController?.abort(),this.aguiClient?.abort(),k.getState().setSessionStreaming(this.activeSessionId,!1),k.getState().clearActivity(),this._stage=`idle`,this.activeCompactionId=null,this.activeSessionId=null)}async cancelRemote(e){try{this.activeSessionId&&await this.api.cancelRun(this.config.agentId,this.activeSessionId,e)}catch(e){console.warn(`[RunEngine] cancelRemote failed:`,e)}this.stop()}resumeRun(e){this.abortController?.abort(),this.abortController=new AbortController,this.activeSessionId=e.sessionId,k.getState().setCurrentRunId(e.invocationId),this.setStage(`connecting`),this.emit({type:`activity`,phase:`恢复运行事件订阅`,status:`connecting`,countEvent:!1}),(async()=>{let t=null;try{let n=await this.api.subscribeRunEvents({sessionId:e.sessionId,invocationId:e.invocationId,afterSeqId:e.afterSeqId},{signal:this.abortController?.signal});this.setStage(`streaming`),this.emit({type:`activity`,phase:`等待恢复事件`,status:`waiting`,countEvent:!1});let r=n.getReader(),i=new TextDecoder,a=``;for(;;){let{value:e,done:n}=await r.read();if(n)break;a+=i.decode(e,{stream:!0});let{chunks:o,remainder:s}=xl(a);a=s;for(let e of o){if(!e.trim())continue;let n=bl(e);for(let e of n)e.eventName===`__done__`||e.eventName===`__ping__`||(this.emit({type:`activity`,phase:`收到恢复事件`,status:`running`}),this.emit({type:`stream_event`,event:e.data}),t=Nk(e.data)||t)}}this.setStage(`completing`),t===`cancelled`||t===`canceled`||t===`aborted`?this.emit({type:`activity`,phase:`后台长任务已取消`,status:`stopped`,countEvent:!1}):t===`interrupted`?this.emit({type:`activity`,phase:`后台长任务已中断`,status:`stopped`,countEvent:!1}):t===`failed`||t===`error`?this.emit({type:`activity`,phase:`后台长任务失败`,status:`failed`,countEvent:!1}):t===`resume_failed`?this.emit({type:`activity`,phase:`后台长任务恢复失败`,status:`failed`,countEvent:!1}):this.emit({type:`activity`,phase:`后台长任务已完成`,status:`completed`,countEvent:!1}),this.emit({type:`stream_ended`}),e.onSessionReloadNeeded?.()}catch(e){e instanceof DOMException&&e.name===`AbortError`||console.error(`Failed to subscribe to run events:`,e)}finally{k.getState().setSessionStreaming(e.sessionId,!1),k.getState().setCurrentRunId(``),this.setStage(`idle`),this.activeSessionId=null}})()}resumeCheckpoint(e){if(this._stage!==`idle`)return!1;this.abortController=new AbortController,this.activeSessionId=e.sessionId;let t=Fk();return k.getState().setCurrentRunId(t),(async()=>{try{if(this.setStage(`connecting`),this.emit({type:`activity`,source:`restore`,phase:`从 checkpoint 恢复运行`,status:`connecting`,countEvent:!1}),this.config.checkpointResumePreviewEnabled)try{let t=(await this.api.previewCheckpointResume({agentId:this.config.agentId,sessionId:e.sessionId,runId:e.runId,checkpointId:e.checkpointId},{signal:this.abortController?.signal})).Preview?.Risk?.Level||`unknown`;this.emit({type:`activity`,source:`restore`,phase:`恢复预览完成:${String(t)} 风险`,status:`waiting`,countEvent:!1})}catch(e){console.warn(`[RunEngine] checkpoint resume preview failed:`,e)}let n=await this.api.resumeRun({agentId:this.config.agentId,sessionId:e.sessionId,runId:e.runId,checkpointId:e.checkpointId,resumeAttemptId:e.resumeAttemptId,invocationId:t},{signal:this.abortController?.signal}),r=vl(`responses`),i=r.createState();this.setStage(`streaming`),this.emit({type:`activity`,source:`restore`,phase:`等待恢复输出`,status:`waiting`,countEvent:!1});let a=`msg-${Date.now()}`,o=await this.consumeStream(n,r,i,a,t);if(o.terminalStatus&&o.terminalStatus!==`completed`){if(o.terminalStatus===`cancelled`){this.setStage(`stopping`),k.getState().stopActivity(`运行时已取消本次恢复。`),this.emit({type:`activity`,source:`restore`,phase:`恢复已取消`,status:`stopped`,countEvent:!1}),this.setStage(`cancelled`);return}this.setStage(`error`),this.emit({type:`activity`,source:`restore`,phase:o.terminalStatus===`incomplete`?`恢复中断`:`恢复失败`,status:`failed`,countEvent:!1});return}this.setStage(`completing`),this.emit({type:`activity`,source:`restore`,phase:`恢复完成`,status:`completed`,countEvent:!1}),this.emit({type:`stream_ended`})}catch(e){e instanceof DOMException&&e.name===`AbortError`||(console.error(`[RunEngine] resumeCheckpoint() error:`,e),this.setStage(`error`),this.emit({type:`error`,error:e instanceof Error?e:Error(String(e))}))}finally{k.getState().setSessionStreaming(e.sessionId,!1),k.getState().setCurrentRunId(``),this.setStage(`idle`),this.activeSessionId=null,e.onSettled?.(e.sessionId)}})(),!0}resumeAguiInterrupt(e){if(this._stage!==`idle`)return!1;let t=e.sessionId||this.aguiThreadSessionId;if(!t)return!1;let n=this.getAguiClient(t);if(!n)return!1;this.activeSessionId=t;let r=Fk();return k.getState().setCurrentRunId(r),this.setStage(`connecting`),this.emit({type:`activity`,phase:`提交人工确认`,status:`connecting`,countEvent:!1}),(async()=>{try{this.setStage(`streaming`);let t=await n.resume(r,{interruptId:e.interruptId,status:e.status,payload:e.payload}),i=e.payload&&typeof e.payload==`object`?e.payload:{},a=String(i.decision||i.type||``).toLowerCase();if(this.emit({type:`approval_resolved`,approvalRequestId:e.interruptId,decision:e.status===`cancelled`?`cancelled`:a===`reject`||a===`rejected`?`rejected`:`approved`}),t.status===`interrupted`){this.setStage(`completing`),this.emit({type:`stream_ended`});return}if(t.status!==`completed`){this.setStage(`error`),this.emit({type:`activity`,phase:`人工确认恢复失败`,status:`failed`,countEvent:!1});return}this.setStage(`completing`),this.emit({type:`activity`,phase:`运行完成`,status:`completed`,countEvent:!1}),this.emit({type:`stream_ended`})}catch(e){this.setStage(`error`),this.emit({type:`error`,error:e instanceof Error?e:Error(String(e))})}finally{k.getState().setCurrentRunId(``),this.setStage(`idle`),this.activeSessionId=null,e.onSettled?.(t)}})(),!0}async createSession(e){this.setStage(`creating-session`);try{let t=(await this.api.createSession(this.config.agentId,{signal:this.abortController?.signal})).SessionId||null;return t&&(e.onSessionCreated?.(t),e.onSessionUpsert?.(t)),t}catch(e){return e instanceof DOMException&&e.name===`AbortError`||console.error(`Failed to create session:`,e),null}}async getConversationBootstrap(e){let t=this.config.conversationClient;if(!t)return null;try{return await t.getSurface(this.config.agentId,e,{signal:this.abortController?.signal})}catch(e){if(e instanceof RO&&e.code===`conversation_http_error`&&e.status===404)return null;throw e}}async buildCanonicalConversationInput(e,t,n,r){let i=[],a=r.text.trim();a&&i.push({kind:`text`,text:a});for(let t of r.attachments){let n=t.type.startsWith(`image/`)?`attachment.image`:`attachment.file`;if(!ek(e.surface,n))throw new RO(`conversation_input_unsupported`,`Conversation attachment is not declared by the active surface.`,{capability:n})}r.attachments.length>0&&i.push(...await this.uploadCanonicalAttachments(r.attachments));let o=Ut(this.config.thinkingMode),s=_ne({inputId:`input:${n}`,sessionId:t,idempotencyKey:`conversation:${n}`,parts:i,...this.config.selectedModel&&ek(e.surface,`model.select`)?{modelRef:this.config.selectedModel}:{},...o!==`auto`&&ek(e.surface,`reasoning.effort`)?{reasoning:o}:{},extensions:{...this.config.permissionMode&&ek(e.surface,`approval`)?{"ksadk.approval":this.config.permissionMode}:{},...r.executionMode===`plan`?{"ksadk.collaboration":`plan`}:{},...r.executionMode===`goal`&&a?{"ksadk.goal":a}:{}}});return YO(e.surface,s)}async uploadCanonicalAttachments(e){this.setStage(`uploading-files`);let t=[];for(let n of e){if(n.size>100*1024*1024)throw new RO(`conversation_input_unsupported`,`Conversation attachment exceeds the Hosted UI upload limit.`,{capability:n.type.startsWith(`image/`)?`attachment.image`:`attachment.file`});let e=new FormData;e.append(`file`,n),e.append(`AgentId`,this.config.agentId);let r;try{r=await this.api.uploadFile(e,{signal:this.abortController?.signal})}catch(e){throw new RO(`conversation_http_error`,`Conversation attachment upload failed.`,{cause:e})}let i=r?.FileData?.fileUri;if(!i)throw new RO(`conversation_contract_mismatch`,`Conversation attachment upload did not return an attachment reference.`);t.push({kind:`attachment`,attachmentRef:i,mediaType:r.FileData.mimeType||n.type||`application/octet-stream`,name:r.FileData.displayName||n.name})}return t}async uploadFiles(e,t){let n=[];if(t||e.attachments.length===0)return n;this.setStage(`uploading-files`);for(let t of e.attachments){if(t.size>100*1024*1024){this.emit({type:`system_message`,content:`【系统提示】文件 ${t.name} 超过 100MB 限制,未发送。`});continue}if(t.type.startsWith(`image/`)){try{n.push({type:`input_image`,image_url:await this.imageFileToDataUrl(t)})}catch(e){this.emit({type:`system_message`,content:`【系统提示】图片 ${t.name} 读取失败,原因: ${Sl(e)}`})}continue}let e=new FormData;e.append(`file`,t),e.append(`AgentId`,this.config.agentId);try{let r=await this.api.uploadFile(e,{signal:this.abortController?.signal});r?.FileData?.fileUri&&n.push({type:`input_file`,filename:r.FileData.displayName||t.name,file_url:r.FileData.fileUri})}catch(e){this.emit({type:`system_message`,content:`【系统提示】文件 ${t.name} 上传失败,原因: ${Sl(e)}`})}}return n}async imageFileToDataUrl(e){let t=new Uint8Array(await e.arrayBuffer()),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return`data:${e.type||`application/octet-stream`};base64,${btoa(n)}`}buildRequestBody(e,t,n,r,i,a){let o=this.buildExecutionMetadata(r),s={AgentId:this.config.agentId,SessionId:e,InvocationId:a,Stream:!0,ApiFormat:t,Model:this.config.selectedModel||void 0,ModelMetadata:this.config.selectedModelMetadata||void 0,ModelOptions:Wt(Ut(this.config.thinkingMode)),Metadata:{agentengine:{tool_approval_mode:this.config.permissionMode||`risk`,...o}}};if(n)s.ResponsesInput=r.responsesInput,s.PreviousResponseId=r.previousResponseId;else{let e=[{type:`input_text`,text:r.text.trim()}];e.push(...i),t===`responses`&&(s.ResponsesInput=[{role:`user`,content:e}]),s.Messages=[{role:`user`,content:e}]}return s}buildExecutionMetadata(e){let t=e.executionMode;if(!t)return{};let n=this.config.runtimeCapabilityMatrix?.[t];if(!n?.supported||n.mode===`unavailable`)return{};if(t===`plan`)return{collaboration_mode:`plan`};if(t===`goal`){let t=e.text.trim();return t?{collaboration_mode:`default`,goal_objective:t}:{}}return{}}async consumeKernelRunEvents(e,t,n,r){if(n.status===`rejected`||n.status===`unsupported`)return this.setStage(`error`),this.emit({type:`error`,error:Error(n.error?.message||`运行提交被拒绝(${n.status})`)}),{terminalStatus:`failed`};if(n.status===`queue_full`)return this.setStage(`error`),this.emit({type:`rate_limited`,message:`运行队列已满,请稍后重试`}),{terminalStatus:`failed`};n.status===`persistence_uncertain`&&this.emit({type:`system_message`,content:`提交结果未知,正在从事件流确认运行状态…`}),this.emit({type:`assistant_message_created`,messageId:r,invocationId:t}),this.emit({type:`activity`,phase:`已提交运行,订阅事件流`,status:`running`,countEvent:!1});let i=new Vl(e),a,o=0;for(;a===void 0&&o<6;)try{let t=k.getState().lastSeqId||0,n=await this.api.subscribeSessionEvents(e,t,{signal:this.abortController?.signal});o=0;let r=n.getReader(),s=new TextDecoder,c=``;for(;a===void 0;){let{value:t,done:n}=await r.read();if(n)break;c+=s.decode(t,{stream:!0});let o=xl(c);c=o.remainder;for(let t of o.chunks)if(t.trim())for(let n of bl(t)){let t=n.data;if(!t||typeof t!=`object`)continue;let r=i.translate(t),o=Number(t.seq);if(Number.isFinite(o)&&o>0&&k.getState().setLastSeqId(o),r&&(this.emit({type:`stream_event`,event:r,sessionId:e}),r.EventType===`run_status`)){let e=String(r.Content?.status||``).toLowerCase();e!==`interrupted`&&Mk.has(e)&&(a=e)}}}a===void 0&&await new Promise(e=>setTimeout(e,3e3))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return{terminalStatus:`cancelled`};if(o+=1,o>=6)break;await new Promise(e=>setTimeout(e,800*o))}return a===void 0&&(a=`interrupted`),{terminalStatus:a}}async consumeStream(e,t,n,r,i){let a=e.getReader(),o=new TextDecoder,s=``,c=!1,l=0;try{for(;;){let{value:e,done:u}=await a.read();if(u)break;l+=e.byteLength,c||(c=!0,this.emit({type:`assistant_message_created`,messageId:r,invocationId:i})),s+=o.decode(e,{stream:!0});let{chunks:d,remainder:f}=xl(s);s=f;for(let e of d){if(!e.trim())continue;if(this.isCompactionChunk(e)){let t=bl(e);for(let e of t)e.eventName.startsWith(`response.compaction`)&&this.upsertCompactionMessage({...e.data,phase:e.eventName.split(`.`).pop()});continue}let i=bl(e),o=!1,s;for(let e of i){if(e.eventName===`__done__`){o=!0;continue}let i=Pk(e.eventName,e.data);i&&this.emit({type:`activity`,...i});let a=t.parse(e,n);for(let e of a)this.dispatchAction(e,r);if(yl(a)){o=!0;let e=a.find(e=>e.type===`terminal`);s=e&&`status`in e?String(e.status||``):void 0}}if(o)return a.cancel().catch(()=>{}),{terminalStatus:s}}}}catch(e){if(!(e instanceof DOMException&&e.name===`AbortError`))throw e}if(l===0)throw Error(`运行时返回了空响应流,请稍后重试;若问题持续,请检查运行时状态。`);return{}}isCompactionChunk(e){return e.includes(`response.compaction.start`)||e.includes(`response.compaction.done`)||e.includes(`response.compaction.failed`)}dispatchAction(e,t){switch(e.type){case`text_delta`:this.emit({type:`text_delta`,messageId:t,delta:e.text});break;case`text_final`:this.emit({type:`text_final`,messageId:t,text:e.text});break;case`reasoning_delta`:this.emit({type:`reasoning_delta`,messageId:t,delta:e.text});break;case`tool_upsert`:this.emit({type:`tool_upsert`,messageId:t,name:e.name,args:e.args,status:e.status,extra:e.extra});break;case`tool_result`:this.emit({type:`tool_result`,messageId:t,name:e.name,output:e.output});break;case`approval_request`:this.emit({type:`approval_requested`,messageId:t,approvalRequestId:e.approvalRequestId,protocol:`responses`,runId:e.runId,name:e.name||`人工确认`,args:e.args||``,message:e.message||`本次运行需要人工审批后才能继续。`});break;case`approval_resolved`:this.emit({type:`approval_resolved`,approvalRequestId:e.approvalRequestId,decision:e.decision,revision:e.revision});break;case`incomplete`:break;case`failed`:this.emit({type:`text_final`,messageId:t,text:`生成失败:${e.message}`});break;case`terminal`:this.emit({type:`terminal`,status:e.status});break;case`compaction`:this.emit({type:`compaction`,phase:e.phase,trigger:e.trigger,compactedUntilSeqId:e.compactedUntilSeqId});break;case`a2ui_surface_begin`:this.emit({type:`a2ui_surface_begin`,surfaceId:e.surfaceId,surface:e.surface});break;case`a2ui_surface_update`:this.emit({type:`a2ui_surface_update`,surfaceId:e.surfaceId,surface:e.surface});break;case`a2ui_surface_end`:this.emit({type:`a2ui_surface_end`,surfaceId:e.surfaceId});break;case`a2ui_interaction`:this.emit({type:`a2ui_interaction`,surfaceId:e.surfaceId,interactionId:e.interactionId,kind:e.kind,inputSchema:e.inputSchema});break}}upsertCompactionMessage(e){let t=typeof e.eventName==`string`?e.eventName.split(`.`).pop():void 0,n=String(e.phase||t||`start`);this.emit({type:`compaction`,phase:n,trigger:e.trigger?String(e.trigger):void 0,compactedUntilSeqId:e.compacted_until_seq_id?Number(e.compacted_until_seq_id):void 0}),n!==`start`&&(this.activeCompactionId=null)}failCompaction(){this.activeCompactionId&&=(this.emit({type:`compaction`,phase:`failed`}),null)}},Rk=0;function zk(e){return Rk+=1,`${e}-${Rk}`}function Bk(e){return e.map(e=>e.type===`thinking`&&e.status===`streaming`?{...e,status:`done`}:e)}function Vk(e,t){let n=[...e??[]],r=n[n.length-1];return r?.type===`thinking`&&r.status===`streaming`?(n[n.length-1]={...r,content:r.content+t},n):[...n,{id:zk(`thinking`),type:`thinking`,content:t,status:`streaming`}]}function Hk(e,t){let n=[...Bk(e??[])],r=n[n.length-1];return r?.type===`text`&&r.status===`streaming`?(n[n.length-1]={...r,content:r.content+t},n):[...n,{id:zk(`text`),type:`text`,content:t,status:`streaming`}]}function Uk(e,t){let n=Bk(e??[]);if(n.filter(e=>e.type===`text`).map(e=>e.content).join(``)===t)return n.map(e=>e.type===`text`&&e.status===`streaming`?{...e,status:`done`}:e);let r=[...n],i=r.map(e=>e.type).lastIndexOf(`text`);return i>=0&&r[i].type===`text`?(r[i]={...r[i],content:t,status:`done`},r):[...r,{id:zk(`text`),type:`text`,content:t,status:`done`}]}function Wk(e,t){if(!t)return[...e??[]];let n=[...e??[]],r=n[n.length-1];if(r?.type!==`thinking`||!r.content.endsWith(t))return n;let i=r.content.slice(0,-t.length);return i?(n[n.length-1]={...r,content:i},n):(n.pop(),n)}function Gk(e,t,n){let r=[...Bk(e??[])],i=r.findIndex(e=>e.type===`tool`&&e.toolName===t);if(i>=0&&r[i].type===`tool`){let e=r[i],t=e.status===`error`||e.status===`completed`,a=n.output!==void 0,o=n.extra&&(n.extra.approvalRequestId||n.extra.approvalStatus);if(t&&!a&&!o)return r;let s=n.extra??e.extra;return r[i]={...e,...n,extra:s},r}return[...r,{id:zk(`tool`),type:`tool`,toolName:t,args:n.args??``,output:n.output,status:n.status??`running`,extra:n.extra}]}function Kk(e){return Bk(e??[])}function qk(e){let t=[];if(e.reasoning&&e.reasoning.trim()&&t.push({id:zk(`thinking`),type:`thinking`,content:e.reasoning,status:`done`}),e.tools)for(let n of Object.values(e.tools))t.push({id:zk(`tool`),type:`tool`,toolName:n.name,args:n.args??``,output:n.output,status:n.status??`completed`,...n.callId?{extra:{callId:n.callId}}:{}});return e.content&&e.content.trim()&&t.push({id:zk(`text`),type:`text`,content:e.content,status:`done`}),t}var Jk=new Set([`resolved`,`cancelled`,`expired`]);function Yk(e){return Jk.has(e)}function Xk(e,t){return`interaction:${e}:revision-${t}`}function Zk(e,t){let n=t.approved;if(typeof n==`boolean`)return n?`已同意`:`已拒绝`;let r=Object.keys(t);return r.length===0?e===`approve`?`已同意`:e===`reject`?`已拒绝`:e===`cancel`?`已取消`:`已提交`:`${e}(${r.slice(0,3).map(e=>{let n=t[e];return`${e}=${typeof n==`string`?n.length>24?`${n.slice(0,24)}…`:n:typeof n==`object`&&n?`[object]`:String(n)}`}).join(`, `)})`}var Qk=class{records=new Map;terminalRuns=new Set;listeners=new Set;key(e,t){return`${e}\u0000${t}`}runKey(e,t){return`${e}\u0000${t}`}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}emit(e){for(let t of this.listeners)t(e)}get(e,t){return this.records.get(this.key(e,t))||null}listPending(e){return this.listAll(e).filter(e=>e.status===`pending`)}listAll(e){return this.all().filter(t=>t.sessionId===e)}all(){return[...this.records.values()].sort((e,t)=>String(e.createdAt).localeCompare(String(t.createdAt)))}upsert(e){e.runId&&!Yk(e.status)&&this.terminalRuns.has(this.runKey(e.sessionId,e.runId))&&(e={...e,status:`expired`,outcome:`expired`,resolvedAt:e.resolvedAt??new Date().toISOString(),responseSummary:e.responseSummary??`运行已结束`});let t=this.get(e.sessionId,e.interactionId),n,r;return t?Yk(t.status)&&!Yk(e.status)||e.revision<t.revision||e.revision===t.revision&&Yk(t.status)&&!Yk(e.status)||t.status===`resolving`&&!Yk(e.status)?(n=t,r={type:`interaction_updated`,interaction:n}):Yk(e.status)?(n={...t,...e,title:t.title||e.title,kind:t.kind||e.kind,message:t.message||e.message,runId:e.runId??t.runId,requestSchema:t.requestSchema??e.requestSchema,presentation:t.presentation??e.presentation,actor:e.actor??t.actor,outcome:e.outcome??t.outcome,resolvedAt:e.resolvedAt??t.resolvedAt,responseSummary:e.responseSummary??t.responseSummary},r={type:`interaction_resolved`,interaction:n}):(n={...t,...e},r={type:`interaction_updated`,interaction:n}):(n=e,r={type:`interaction_requested`,interaction:n}),this.records.set(this.key(n.sessionId,n.interactionId),n),this.emit(r),r}markResolving(e,t){let n=this.get(e,t);!n||n.status!==`pending`||(this.records.set(this.key(e,t),{...n,status:`resolving`}),this.emit({type:`interaction_updated`,interaction:this.get(e,t)}))}resolveLocally(e,t,n){let r=this.get(e,t);if(!r)return;let i={...r,...n,resolvedAt:n.resolvedAt??r.resolvedAt??new Date().toISOString(),revision:n.revision??r.revision};this.records.set(this.key(e,t),i),this.emit({type:`interaction_resolved`,interaction:i})}recordIdempotencyKey(e,t,n){let r=this.get(e,t);if(!r)return;let i={...r,extensions:{...r.extensions,idempotency_key:n}};this.records.set(this.key(e,t),i),this.emit({type:`interaction_updated`,interaction:i})}markFailed(e,t,n){let r=this.get(e,t);if(!r||r.status!==`resolving`)return;let i={...r,status:`failed`,extensions:{...r.extensions,submit_error:n}};this.records.set(this.key(e,t),i),this.emit({type:`interaction_updated`,interaction:i})}revertToPending(e,t){let n=this.get(e,t);if(!n||n.status!==`resolving`)return;let r={...n,status:`pending`};this.records.set(this.key(e,t),r),this.emit({type:`interaction_updated`,interaction:r})}markRunTerminal(e,t){if(!(!e||!t)){this.terminalRuns.add(this.runKey(e,t));for(let n of this.listAll(e)){if(n.runId!==t||Yk(n.status))continue;let r={...n,status:`expired`,outcome:`expired`,resolvedAt:n.resolvedAt??new Date().toISOString(),responseSummary:n.responseSummary??`运行已结束`};this.records.set(this.key(e,n.interactionId),r),this.emit({type:`interaction_resolved`,interaction:r})}}}markSessionTerminal(e){if(!e)return;let t=new Set(this.listAll(e).filter(e=>!Yk(e.status)).map(e=>e.runId).filter(e=>!!e));for(let n of t)this.markRunTerminal(e,n);for(let t of this.listAll(e)){if(t.runId||Yk(t.status))continue;let n={...t,status:`expired`,outcome:`expired`,resolvedAt:t.resolvedAt??new Date().toISOString(),responseSummary:t.responseSummary??`运行已结束`};this.records.set(this.key(e,t.interactionId),n),this.emit({type:`interaction_resolved`,interaction:n})}}remove(e,t){let n=this.key(e,t);this.records.has(n)&&(this.records.delete(n),this.emit({type:`interaction_removed`,interactionId:t}))}clearSession(e){for(let t of this.listAll(e))this.remove(e,t.interactionId);let t=`${e}\u0000`;for(let e of this.terminalRuns)e.startsWith(t)&&this.terminalRuns.delete(e)}},$k={approve:`approved`,reject:`rejected`,submit:`submitted`,cancel:`cancelled`};function eA(e,t){return{schema_version:1,command_id:`local-${t}`,status:e,message_id:null,run_id:null,accepted_seq:null,error:null,extensions:{}}}var tA=class{store;deps;inFlight=new Map;constructor(e){this.deps=e,this.store=e.store||new Qk}listPending(e){return this.store.listPending(e)}setInteractionV1Enabled(e){this.deps.interactionV1Enabled=e}subscribe(e){return this.store.subscribe(e)}ingest(e){this.store.upsert(e)}ingestHistory(e){for(let t of e)this.store.upsert(t);for(let[e]of this.inFlight){let t=this.findByInteractionId(e);t&&t.status!==`pending`&&t.status!==`resolving`&&this.inFlight.delete(e)}}findByInteractionId(e){return this.store.all().find(t=>t.interactionId===e)||null}async respond(e){let t=this.findByInteractionId(e.interactionId);if(!t)return eA(`rejected`,e.interactionId);if(t.status===`resolved`||t.status===`cancelled`||t.status===`expired`||t.status===`resolving`)return eA(`duplicate`,e.interactionId);let n=e.idempotencyKey||Xk(e.interactionId,e.expectedRevision),r=this.inFlight.get(e.interactionId);if(r)return eA(r===n?`duplicate`:`rejected`,e.interactionId);this.inFlight.set(e.interactionId,n),this.store.markResolving(t.sessionId,e.interactionId);let i=this.deps.interactionV1Enabled||t.source===`interaction_v1`;try{if(!i&&t.source===`responses`&&this.deps.legacyResponsesApproval)return this.deps.legacyResponsesApproval(e.interactionId,e.action===`approve`),this.resolveLocal(t,e,n),eA(`accepted`,e.interactionId);if(!i&&t.source===`agui`&&this.deps.legacyAguiResume)return this.deps.legacyAguiResume(String(t.extensions.interrupt_id||e.interactionId),e.action===`cancel`?`cancelled`:`resolved`,e.response)?(this.resolveLocal(t,e,n),eA(`accepted`,e.interactionId)):(this.store.revertToPending(t.sessionId,e.interactionId),eA(`rejected`,e.interactionId));let r=Vc(await this.deps.submitInteraction({AgentId:this.deps.agentId,SessionId:t.sessionId,RunId:t.runId||``,InteractionId:e.interactionId,ExpectedRevision:e.expectedRevision,Action:e.action,Response:e.response,IdempotencyKey:n}));return r.status===`accepted`||r.status===`duplicate`?this.store.recordIdempotencyKey(t.sessionId,e.interactionId,n):r.status===`queue_full`?this.store.revertToPending(t.sessionId,e.interactionId):this.store.markFailed(t.sessionId,e.interactionId,{code:r.error?.code??String(r.status),message:r.error?.message??`提交未通过(${r.status})`,retryable:r.error?.retryable??!1}),r}catch(n){let r=n instanceof Error?n.message:String(n||`交互提交失败`);throw this.store.markFailed(t.sessionId,e.interactionId,{code:`interaction_submit_failed`,message:r,retryable:!0}),n}finally{this.inFlight.delete(e.interactionId)}}resolveLocal(e,t,n){let r=t.action===`cancel`?`cancelled`:`resolved`;this.store.resolveLocally(e.sessionId,t.interactionId,{status:r,outcome:$k[t.action],actor:`user`,responseSummary:Zk(t.action,t.response),revision:t.expectedRevision});let i=this.store.get(e.sessionId,t.interactionId);i&&this.store.upsert({...i,extensions:{...i.extensions,idempotency_key:n}})}},nA=new Set([`approval`,`structured_input`,`plan_review`,`custom`]),rA=new Set([`pending`,`resolving`,`failed`,`resolved`,`cancelled`,`expired`]),iA=new Set([`approved`,`rejected`,`submitted`,`cancelled`,`expired`]);function aA(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function oA(e){return typeof e==`string`&&e.length>0?e:null}function sA(e){let t=String(e.kind||`approval`),n=String(e.status||`pending`),r=String(e.outcome||``),i=aA(e.presentation),a=i?aA(i.a2ui):null;return{interactionId:e.interactionId,sessionId:e.sessionId,runId:oA(e.runId),kind:nA.has(t)?t:`custom`,title:typeof e.title==`string`&&e.title?e.title:`人工确认`,message:typeof e.message==`string`&&e.message?e.message:`本次运行需要人工处理后才能继续。`,requestSchema:aA(e.requestSchema),presentation:a?{a2ui:{wireVersion:String(a.wire_version??a.wireVersion??``),catalogDigest:String(a.catalog_digest??a.catalogDigest??``),messages:Array.isArray(a.messages)?a.messages.filter(e=>typeof e==`object`):[]}}:null,status:rA.has(n)?n:`pending`,revision:Number.isFinite(Number(e.revision))&&Number(e.revision)>0?Number(e.revision):1,createdAt:oA(e.createdAt)||new Date().toISOString(),expiresAt:oA(e.expiresAt),resolvedAt:oA(e.resolvedAt),actor:oA(e.actor),outcome:iA.has(r)?r:null,responseSummary:oA(e.responseSummary),source:e.source,extensions:e.extensions||{}}}var cA=new Set([`interaction.requested`,`interaction_requested`,`ksadk.interaction/v1.requested`,`InteractionRequested`,`approval.requested`,`a2ui.interaction`]),lA=new Set([`interaction.resolved`,`interaction_resolved`,`ksadk.interaction/v1.resolved`,`InteractionResolved`,`interaction.cancelled`,`interaction.cancel`,`interaction.expired`,`approval.resolved`,`a2ui.action`]);function uA(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function dA(e,t){let n=uA(e);if(!n)return null;let r=String(n.event_type||n.EventType||``).trim();if(!r)return null;let i=uA(n.payload??n.Content)||{},a=uA(i.interaction)||uA(i.Interaction)||uA(i.interaction_request)||i,o=String(a.interaction_id||a.interactionId||a.InteractionId||a.approval_id||a.approvalId||i.interaction_id||i.interactionId||i.InteractionId||i.approval_id||i.approvalId||``);if(!o)return null;let s=String(n.session_id||n.SessionId||a.session_id||a.sessionId||t||``);if(!s)return null;if(cA.has(r)){let e={...uA(a.extensions)||{},...a.detail===void 0?{}:{detail:a.detail},...(a.call_id??a.callId)===void 0?{}:{call_id:a.call_id??a.callId}};return sA({interactionId:o,sessionId:s,runId:a.run_id??a.runId??n.run_id??n.InvocationId,kind:r===`approval.requested`?`approval`:a.kind??`approval`,title:a.title,message:a.message??a.description??uA(a.detail)?.command,requestSchema:a.request_schema??a.requestSchema??a.input_schema??a.inputSchema??a.RequestSchema,presentation:a.presentation,status:`pending`,revision:a.revision??1,createdAt:a.created_at??a.createdAt??n.timestamp??n.Timestamp,expiresAt:a.expires_at,source:`interaction_v1`,extensions:e})}if(lA.has(r)){let e={...uA(a.extensions)||{},...a.detail===void 0?{}:{detail:a.detail},...(a.call_id??a.callId)===void 0?{}:{call_id:a.call_id??a.callId}},t=r===`interaction.cancelled`||r===`interaction.cancel`?`cancelled`:r===`interaction.expired`?`expired`:`resolved`,c=String(i.outcome??a.outcome??a.status??``).toLowerCase(),l=String(i.action??a.action??i.name??a.name??``).toLowerCase(),u=c;u||=l===`approve`?`approved`:l===`reject`?`rejected`:l===`submit`?`submitted`:l===`cancel`||t===`cancelled`?`cancelled`:t===`expired`?`expired`:`submitted`;let d=t===`resolved`?`resolved`:t;return sA({interactionId:o,sessionId:s,runId:a.run_id??a.runId??n.run_id??n.InvocationId,kind:a.kind,title:a.title,message:a.message,requestSchema:a.request_schema,presentation:a.presentation,status:d,revision:a.revision,createdAt:a.created_at??n.timestamp,expiresAt:a.expires_at,resolvedAt:i.resolved_at??i.resolvedAt??a.resolved_at??a.resolvedAt??n.timestamp??n.Timestamp,actor:i.actor??a.actor??n.actor_ref,outcome:u,responseSummary:i.response_summary??a.response_summary??(l?`${l}`:void 0),source:`interaction_v1`,extensions:e})}return null}function fA(e){return!e.approvalRequestId||!e.sessionId?null:sA({interactionId:e.approvalRequestId,sessionId:e.sessionId,runId:e.runId??null,kind:`approval`,title:e.name?`审批:${e.name}`:`人工确认`,message:e.message||`本次运行需要人工审批后才能继续。`,requestSchema:e.requestSchema??null,status:`pending`,revision:1,source:`responses`,extensions:{...e.approvalLevel?{approval_level:e.approvalLevel}:{},...e.args?{arguments:e.args}:{}}})}function pA(e){return!e.interruptId||!e.sessionId?null:sA({interactionId:e.interruptId,sessionId:e.sessionId,runId:e.runId??null,kind:`approval`,title:e.name?`确认:${e.name}`:`人工确认`,message:e.message||`本次运行需要人工确认后才能继续。`,requestSchema:e.requestSchema??null,status:`pending`,revision:1,source:`agui`,extensions:{interrupt_id:e.interruptId,...e.toolCallId?{tool_call_id:e.toolCallId}:{},...e.reason?{reason:e.reason}:{}}})}function mA(e){let t=typeof e==`object`&&e?e.components:null,n=Array.isArray(t)?t:[],r=[];for(let e of n)typeof e==`object`&&e&&typeof e.id==`string`&&r.push(e.id);return r.sort()}function hA(e){let t=mA(e).join(`|`),n=2166136261,r=16777619;for(let e=0;e<t.length;e+=1){let i=t.charCodeAt(e);n=(n^i)>>>0,n=Math.imul(n,16777619)>>>0,r=r+Math.imul(i+e,2246822507)>>>0}return`fnv1a-${n.toString(16)}-${r.toString(16)}`}function gA(e,t){if(!e)return _A(null);if(e.wireVersion!==`0.9.1`||!e.messages||e.messages.length===0)return _A(e);if(e.catalogDigest){let n=hA(t);if(e.catalogDigest!==n)return`json-schema-form`}return`a2ui`}function _A(e){return e&&vA(e)?`json-schema-form`:`basic-controls`}function vA(e){return e.messages.some(e=>{let t=e.inputSchema??e.input_schema??e.schema;return typeof t==`object`&&!!t})}function yA(e){return String(e||``).replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}function bA(e){let t=String(e||``).trim();for(let e=0;e<3;e+=1){if(!t)return t;let e=t[0],n=t[t.length-1];if(!(e===`{`&&n===`}`||e===`[`&&n===`]`||e===`"`&&n===`"`))return t.replace(/\\n/g,`
|
|
93
|
+
`).replace(/\\"/g,`"`);try{let e=JSON.parse(t);if(typeof e!=`string`)return xA(e);t=e.trim()}catch{return yA(t).replace(/\\n/g,`
|
|
94
|
+
`).replace(/\\"/g,`"`)}}return t}function xA(e){return typeof e==`string`?bA(e):Array.isArray(e)?e.map(e=>xA(e)):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,xA(t)]))}function SA(e){return typeof e==`string`?bA(e):xA(e)}function CA(e){return e===!1?!0:typeof e==`string`?e.trim().toLowerCase()===`false`:!1}function wA(e){return e===!0?!0:typeof e==`string`?e.trim().toLowerCase()===`true`:!1}function TA(e){return e==null||e===!1?!1:typeof e==`string`?e.trim().length>0:typeof e==`object`?Object.keys(e).length>0:!0}function EA(e){return String(e?.status||``).trim().toLowerCase()===`accepted_not_extracted`}function DA(e,t=0){if(!e||t>4)return!1;if(typeof e==`string`){let n=bA(e);return n!==e&&DA(n,t+1)}if(Array.isArray(e))return e.some(e=>DA(e,t+1));if(typeof e!=`object`||EA(e))return!1;if(CA(e.ok)||CA(e.success))return!0;let n=wA(e.ok)||wA(e.success),r=String(e.status||``).trim().toLowerCase();return!n&&[`error`,`failed`,`failure`].includes(r)||!n&&(TA(e.error_type)||TA(e.error_message)||TA(e.error))?!0:Object.values(e).some(e=>DA(e,t+1))}function OA(e){return e==null||e===``?!1:DA(SA(e))}function kA(e){if(e==null||e===``)return``;let t=SA(e);return typeof t==`string`?t:JSON.stringify(t,null,2)}var AA=new Set([`completed`,`failed`,`error`,`cancelled`,`canceled`,`aborted`,`interrupted`,`resume_failed`]),jA=new Set([`tool_call`,`tool_result`,`stage_tool_call`,`stage_tool_result`]),MA={"run.started":`in_progress`,"run.progress":`in_progress`,"run.interrupted":`interrupted`,"run.completed":`completed`,"run.failed":`failed`,"run.canceled":`cancelled`};function NA(e){let t=e?.Content?.payload;return t&&typeof t==`object`?t:{}}function PA(e,t){let n=String(e||``),r=String(t||``);return n?!r||n.endsWith(r)?n:r.startsWith(n)?r:`${n}${r}`:r}function FA(e){let t=String(e?.EventType||``),n=NA(e);return MA[t]?{...e,EventType:`run_status`,Content:{status:String(n.status||MA[t]),...n.detail?{detail:String(n.detail)}:{}}}:t===`reasoning.delta`||t===`reasoning.completed`?{...e,EventType:`reasoning`,Content:{role:`model`,parts:[{text:String(n.text||``)}]}}:t===`tool.call.begin`?{...e,EventType:`tool_call`,Metadata:{...e.Metadata||{},tool_name:n.name,tool_args:n.args,tool_call_id:n.call_id},Content:{role:`model`,parts:[]}}:t===`tool.call.end`?{...e,EventType:`tool_result`,Metadata:{...e.Metadata||{},tool_name:n.name,tool_output:n.error||n.result,tool_call_id:n.call_id},Content:{role:`model`,parts:[]}}:e}function IA(e){let t=[],n=new Map;for(let r of Array.isArray(e)?e:[]){let e=String(r?.EventType||``);if(e===`text.delta`||e===`text.completed`){let e=String(r?.InvocationId||``).trim();if(!e)continue;let t=n.get(e);n.set(e,{event:r,text:PA(t?.text,NA(r).text)});continue}t.push(FA(r))}for(let{event:e,text:r}of n.values())t.push({...e,EventType:`assistant_stream_snapshot`,Content:{role:`model`,parts:[{text:r}]},Metadata:{...e.Metadata||{},stream_snapshot:!0}});return t.sort((e,t)=>ZA(e)-ZA(t))}function LA(e){let t=String(e?.EventType||``).trim();if(t!==`run_status`&&!t.startsWith(`run.`))return``;let n=NA(e);return String(e?.Content?.status||n.status||MA[t]||``).trim().toLowerCase()}function RA(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>typeof e==`string`?e:e&&typeof e==`object`&&typeof e.text==`string`?e.text:``).join(``):``}function zA(e){let t=String(e||``).trim();return t?`/agentengine/api/v1/AttachmentContent?FileUri=${encodeURIComponent(t)}`:``}function BA(e){return String(e||``).match(/^data:([^;,]+)/)?.[1]||``}function VA(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return!n||!r||n===r?!0:n.endsWith(`/*`)?r.startsWith(n.slice(0,-1)):r.endsWith(`/*`)?n.startsWith(r.slice(0,-1)):!1}function HA(e){let t=e?.Content?.parts||[],n=[],r=new Map,i=e=>{let t=`${e.fileUri||e.url||e.name}|${e.type}`;r.has(t)||r.set(t,e)};for(let e of t){if(e?.type===`input_text`||e?.text){n.push(e.text||``);continue}if(e?.type===`input_file`&&e.inlineData){i({name:e.inlineData.displayName||`attachment`,url:`data:${e.inlineData.mimeType||`application/octet-stream`};base64,${e.inlineData.data}`,type:e.inlineData.mimeType||`application/octet-stream`});continue}if(e?.type===`input_file`&&typeof e.file_data==`string`&&e.file_data){i({name:e.filename||e.displayName||e.display_name||`attachment`,url:`data:${e.mime_type||e.mimeType||`application/octet-stream`};base64,${e.file_data}`,type:e.mime_type||e.mimeType||`application/octet-stream`});continue}if(e?.type===`input_file`&&typeof e.file_url==`string`&&e.file_url.trim()){let t=e.file_url.trim();i({name:e.filename||e.displayName||e.display_name||`attachment`,url:zA(t),type:e.mime_type||e.mimeType||`application/octet-stream`,fileUri:t});continue}if(e?.type===`input_image`||e?.type===`image_url`){let t=typeof e.image_url==`string`?e.image_url:e.image_url?.url;t&&i({name:e.filename||e.displayName||e.display_name||`uploaded_image`,url:t,type:e.mime_type||e.mimeType||BA(t)||`image/*`});continue}if(e?.type===`input_file`&&e.fileData){let t=String(e.fileData.fileUri||``).trim();i({name:e.fileData.displayName||`attachment`,url:zA(t),type:e.fileData.mimeType||`application/octet-stream`,fileUri:t})}}let a=Array.isArray(e?.Metadata?.attachments)?e.Metadata.attachments:[];for(let e of a){let t=String(e.file_uri||``).trim(),n={name:e.display_name||`attachment`,url:zA(t),type:e.mime_type||`application/octet-stream`,fileUri:t};!n.url&&!n.fileUri&&Array.from(r.values()).some(e=>e.name===n.name&&VA(e.type,n.type)&&(e.url||e.fileUri))||i(n)}let o=Array.from(r.values());return{text:n.join(``),attachments:o.length>0?o:void 0}}function UA(e){let t=e?.Metadata?.responses_output;if(!Array.isArray(t))return{};let n=$c(),r=dl({eventName:`response.completed`,data:{response:{id:String(e.Metadata?.response_id||``),output:t}},state:n}),i=``,a={};for(let e of r){if(e.type===`reasoning_delta`){i+=e.text;continue}if(e.type===`tool_upsert`){a[e.name]={...a[e.name]||{name:e.name,args:``},name:e.name,args:e.args,status:e.status,...e.approvalRequestId?{approvalRequestId:e.approvalRequestId}:{},...e.previousResponseId?{previousResponseId:e.previousResponseId}:{},...e.serverLabel?{serverLabel:e.serverLabel}:{},...e.approvalRequestId?{approvalStatus:`pending`}:{}};continue}e.type===`tool_result`&&(a[e.name]={...a[e.name]||{name:e.name,args:``},name:e.name,output:e.output,status:OA(e.output)?`error`:`completed`})}return{...i?{reasoning:i}:{},...Object.keys(a).length>0?{tools:a}:{}}}function WA(e,t,n){return t===`running`?e===`prompt_too_long`?`检测到上下文过长,正在自动压缩历史后重试`:`正在自动压缩上下文`:n?e===`prompt_too_long`?`上下文过长,系统已自动压缩历史并重试`:`系统已自动压缩较早的对话上下文`:t===`failed`?`自动压缩上下文未完成`:e===`prompt_too_long`?`已完成上下文压缩,并继续当前回复`:`已完成上下文压缩`}function GA(e,t){return t?.itemId?[`runtime-item`,t.runId||e,t.scopeId||e,t.itemId].join(`\0`):[e,t.content||``,t.reasoning||``].join(`\0`)}function KA(e){let t=String(e?.InvocationId||``).trim(),n=e?.Metadata?.RuntimeItem;return n?.ItemId?[`runtime-item`,n.RunId||t,n.ScopeId||t,n.ItemId].join(`\0`):t}function qA(e){let t=e?.Metadata?.RuntimeItem;return t?.ItemId?{id:`runtime:${t.RunId||e.InvocationId||`run`}:${t.ScopeId||e.InvocationId||`scope`}:${t.ItemId}`,runId:String(t.RunId||e.InvocationId||``),scopeId:String(t.ScopeId||e.InvocationId||``),itemId:String(t.ItemId),partId:t.PartId?String(t.PartId):void 0}:null}function JA(e){return e?.Metadata?.responses_mirror===!0||String(e?.Metadata?.responses_mirror||``).trim().toLowerCase()===`true`}function YA(e){if(e?.EventType!==`user_message`)return``;let t=HA(e),n=(t.attachments||[]).map(e=>[e.name||``,e.fileUri||``,e.url||``,e.type||``].join(``)).sort().join(``);return[String(t.text||``).trim(),n].join(`\0`)}function XA(e){return e?.EventType===`assistant_stream_snapshot`}function ZA(e){let t=Number(e?.SeqId||0);if(Number.isFinite(t)&&t>0)return t;let n=Number(e?.Timestamp||0);return Number.isFinite(n)?n:0}function QA(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function $A(e){let t=String(e?.EventType||``);if(!jA.has(t))return null;let n=String(e.Metadata?.tool_name||e.Metadata?.name||e.Metadata?.function_name||RA(e.Content?.parts)||`tool`).trim()||`tool`,r=String(e.Metadata?.call_id||e.Metadata?.callId||e.Metadata?.RuntimeItem?.ToolCallId||``).trim(),i={name:n,...r?{callId:r}:{},args:``,status:`running`},a=t===`tool_result`||t===`stage_tool_result`?(()=>{let t=QA(e.Metadata?.tool_output??e.Metadata?.output??e.Metadata?.result??RA(e.Content?.parts));return{...i,output:t,status:OA(t)?`error`:`completed`}})():{...i,args:QA(e.Metadata?.tool_args??e.Metadata?.arguments??e.Metadata?.args??{})},o=qA(e);return{id:o?.id||e.EventId||String(Date.now()+Math.random()),role:`model`,content:``,timestamp:e.Timestamp||Date.now(),eventType:t,...o||{},tools:{[n]:a}}}function ej(e={},t={}){let n={...e||{}};for(let[e,r]of Object.entries(t||{}))n[e]={...n[e]||{},...r||{},name:e,args:r?.args||n[e]?.args||``};return n}function tj(e={},t=``){let n=String(t||``).trim().toLowerCase(),r=n===`completed`?`completed`:AA.has(n)?`error`:``;if(!r)return e;let i=!1,a={};for(let[t,n]of Object.entries(e||{}))n?.status===`running`?(i=!0,a[t]={...n,status:r}):a[t]=n;return i?a:e}function nj(e,t){return{...e,reasoning:rj(e.reasoning,t.reasoning),tools:ej(e.tools,t.tools),eventId:t.eventId||e.eventId,responseId:t.responseId||e.responseId,traceId:t.traceId||e.traceId,rootSpanId:t.rootSpanId||e.rootSpanId,timestamp:Math.max(Number(e.timestamp||0),Number(t.timestamp||0))||t.timestamp||e.timestamp,id:t.responseId||t.reasoning||t.tools?t.id:e.id}}function rj(e=``,t=``){let n=String(e||``),r=String(t||``);return n?!r||n.endsWith(r)?n:r.startsWith(n)?r:`${n}${r}`:r}function ij(e){return{id:e.id,role:`system`,eventType:`context_checkpoint`,status:e.status,trigger:e.trigger,compactedUntilSeqId:e.compactedUntilSeqId,summary:e.summary,historical:e.historical,timestamp:e.timestamp,content:WA(e.trigger,e.status,e.historical)}}function aj(e){let t=e?.EventType||``,n=qA(e);if(t===`run_status`)return e.Content?.status===`failed`?{id:e.EventId||String(Date.now()+Math.random()),role:`system`,content:e.Content?.detail||`本轮运行失败。`,eventType:t,status:`failed`,timestamp:e.Timestamp||Date.now()}:e.Content?.status===`cancelled`?{id:e.EventId||String(Date.now()+Math.random()),role:`system`,content:e.Content?.detail||`本轮输出已停止。`,eventType:t,status:`cancelled`,timestamp:e.Timestamp||Date.now()}:null;if(t===`context_checkpoint`){let t=HA(e);return ij({id:e.EventId||String(Date.now()+Math.random()),timestamp:e.Timestamp||Date.now(),status:`completed`,trigger:String(e.Metadata?.trigger||`auto`),compactedUntilSeqId:Number(e.Metadata?.compacted_until_seq_id||0)||void 0,summary:t.text||void 0,historical:!0})}if(t===`reasoning`){let r=HA(e).text||RA(e.Metadata?.reasoning);return r?{id:n?.id||e.EventId||String(Date.now()+Math.random()),role:`model`,content:``,reasoning:r,timestamp:e.Timestamp||Date.now(),eventType:t,...n||{}}:null}if(jA.has(t))return $A(e);if(t!==`user_message`&&t!==`assistant_message`&&t!==`assistant_stream_snapshot`)return null;let r=HA(e),i=t===`assistant_message`?UA(e):{};if(!r.text&&!r.attachments?.length&&!i.reasoning&&!i.tools)return null;let a=String(e.Metadata?.response_id||e.Metadata?.ResponseId||``).trim(),o=String(e.Metadata?.trace_id||e.Metadata?.TraceId||``).trim(),s=String(e.Metadata?.root_span_id||e.Metadata?.rootSpanId||e.Metadata?.RootSpanId||``).trim();return{id:n?.id||e.EventId||String(Date.now()+Math.random()),role:t===`user_message`?`user`:`model`,content:r.text,timestamp:e.Timestamp||Date.now(),eventType:t,eventId:e.EventId||void 0,responseId:a||void 0,traceId:o||void 0,rootSpanId:s||void 0,attachments:r.attachments,...n||{},...i}}function oj(e=[]){let t=new Map,n=new Map,r=new Set,i=new Set,a=new Set,o=new Set,s=IA(e),c=[];for(let e of s){let t=String(e?.EventId||``).trim();if(t){if(o.has(t))continue;o.add(t)}c.push(e)}let l=new Set,u=new Set,d=new Map;for(let e of c){if(e?.EventType!==`user_message`||JA(e)){if(e?.EventType===`assistant_message`){let t=KA(e);t&&u.add(t)}if(XA(e)){let t=KA(e);if(t){let n=d.get(t);(!n||ZA(e)>=ZA(n))&&d.set(t,e)}}continue}let t=YA(e);t&&l.add(t)}let f=c.filter(e=>{if(XA(e)){let t=KA(e);return t?u.has(t)?!1:d.get(t)===e:!0}if(e?.EventType!==`user_message`||!JA(e))return!0;let t=YA(e);return!t||!l.has(t)});for(let e of f){let a=String(e.InvocationId||``).trim();a&&e.EventType===`user_message`&&i.add(a),a&&[`assistant_message`,`assistant_stream_snapshot`,`reasoning`,`tool_call`,`tool_result`,`stage_tool_call`,`stage_tool_result`].includes(String(e.EventType||``))&&r.add(a),e.EventType===`run_status`&&a&&(t.set(a,String(e.Content?.status||``).trim()),n.set(a,e))}let p=[],m=new Map,h=new Map,g=null,_=new Map,v=e=>{let t=e?.itemId?`${e.runId||e.invocationId||``}\u0000${e.scopeId||e.invocationId||``}\u0000${e.itemId}`:``,n=t?h.get(t):void 0;if(n!==void 0){p[n]=nj(p[n],e);return}let r=String(e?.responseId||``).trim(),i=r?m.get(r):void 0;if(i!==void 0){p[i]=nj(p[i],e);return}r&&m.set(r,p.length),t&&h.set(t,p.length),p.push(e)},y=()=>{g&&=(v(g),null)},b=(e,n=``)=>{let r=String(e||``).trim();if(!r)return{};let i=_.get(r);return i?(_.delete(r),{tools:tj(i.tools,t.get(r)||n)}):{}};for(let e of f){if(e.EventType===`run_status`)continue;let t=aj(e);if(!t)continue;let n=String(e.InvocationId||``).trim();if(n&&(t.invocationId=n),jA.has(t.eventType)){let n=String(e.InvocationId||``).trim();if(t.itemId){y(),v(t);continue}if(!n){y(),v(t);continue}let r=_.get(n);_.set(n,{...r||{id:t.id,role:`model`,content:``,timestamp:t.timestamp,invocationId:n},timestamp:Math.max(Number(r?.timestamp||0),Number(t.timestamp||0)),tools:ej(r?.tools,t.tools)});continue}if(t.eventType===`reasoning`){let n=String(e.InvocationId||``).trim(),r=String(e.Metadata?.RuntimeItem?.Operation||``).toLowerCase(),i=!!(t.itemId&&g?.itemId===t.itemId&&g?.runId===t.runId&&g?.scopeId===t.scopeId),a=!!(!t.itemId&&!g?.itemId&&n&&g?.invocationId===n);if(g&&(i||a)){g.reasoning=r===`replace`||r===`completed`?t.reasoning:`${g.reasoning||``}${t.reasoning||``}`,g.timestamp=t.timestamp;continue}y(),g={...t,...n?{invocationId:n}:{}};continue}let r=t.eventType===`assistant_message`||t.eventType===`assistant_stream_snapshot`;if(r&&g){let n=String(e.InvocationId||``).trim(),r=GA(n,t);if(t.eventType===`assistant_message`&&n&&a.has(r)){g=null;continue}t.eventType===`assistant_message`&&n&&a.add(r),v({...t,...b(n,t.eventType===`assistant_message`?`completed`:``),reasoning:rj(g.reasoning,t.reasoning)}),g=null;continue}if(y(),r){let n=String(e.InvocationId||``).trim(),r=GA(n,t);if(t.eventType===`assistant_message`&&n&&a.has(r))continue;t.eventType===`assistant_message`&&n&&a.add(r),v({...t,...b(n,t.eventType===`assistant_message`?`completed`:``)});continue}v(t)}y();for(let[e,n]of _.entries())v({...n,tools:tj(n.tools,t.get(e))});for(let[e,a]of t.entries()){if(a!==`in_progress`||r.has(e)||!i.has(e))continue;let t=n.get(e)||{};v({id:`run-placeholder-${e}`,role:`model`,content:``,status:`running`,eventType:`run_status`,timestamp:t.Timestamp||Date.now()})}return p}function sj(e=[],t=[]){let n=[],r=new Set;for(let i of[...Array.isArray(e)?e:[],...Array.isArray(t)?t:[]]){let e=String(i?.EventId||``).trim();if(e){if(r.has(e))continue;r.add(e)}n.push(i)}return n.sort((e,t)=>{let n=Number(e?.SeqId||0),r=Number(t?.SeqId||0);return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?n-r:Number(e?.Timestamp||0)-Number(t?.Timestamp||0)})}function cj(e=[]){return(Array.isArray(e)?e:[]).reduce((e,t)=>{let n=Number(t.SeqId||0);return Number.isFinite(n)?Math.max(e,n):e},0)}function lj(e){return AA.has(LA(e))}var uj=new Set([`completed`,`failed`,`error`,`cancelled`,`canceled`,`aborted`,`interrupted`,`resume_failed`]),dj=new Qk;function fj(e,t){let n=dA(e,t);n&&dj.upsert(n);let r=typeof e==`object`&&e?e:null,i=r?LA(r):null;if(i!==null&&uj.has(i)){let e=typeof r?.Content==`object`&&r.Content!==null?r.Content:{},n=typeof e.payload==`object`&&e.payload!==null?e.payload:{},i=String(r?.SessionId||r?.session_id||t||``),a=String(r?.InvocationId||r?.run_id||n.run_id||n.runId||``);dj.markRunTerminal(i,a)}return n}function pj(e){let t=e.sessionId||``;if(!t||!e.approvalRequestId)return null;let n=e.protocol===`ag-ui`?pA({interruptId:e.approvalRequestId,sessionId:t,name:e.name,message:e.message,reason:e.approvalLevel}):fA({approvalRequestId:e.approvalRequestId,sessionId:t,runId:e.runId,name:e.name,message:e.message,args:e.args,approvalLevel:e.approvalLevel});return n&&dj.upsert(n),n}function mj(e){let t=e.sessionId||``;return!t||!e.approvalRequestId?null:fj({EventType:`approval.resolved`,Content:{approvalId:e.approvalRequestId,revision:e.revision||2,outcome:e.decision,actor:`user`,resolvedAt:new Date().toISOString()}},t)}var hj=[],gj=[];function _j(e){return typeof e==`string`?e.trim():``}function vj(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:void 0}function yj(e){return typeof e==`string`||typeof e==`number`?e:void 0}function bj(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function xj(e){return e!==null}function Sj(e){return e!==null}function Cj(e){return[...e].sort((e,t)=>{let n=t.seqId??-1,r=e.seqId??-1;return n===r?(Date.parse(String(t.timestamp||``))||0)-(Date.parse(String(e.timestamp||``))||0):n-r})}function wj(e){return[...e].sort((e,t)=>{let n=t.seqId??-1,r=e.seqId??-1;return n===r?(Date.parse(String(t.timestamp||``))||0)-(Date.parse(String(e.timestamp||``))||0):n-r})}function Tj(e){return Cj(e)[0]?.runId||``}function Ej(e){let t=Tj(e);return t?e.filter(e=>e.runId===t):[]}function Dj(e){let t=bj(e);if(!t)return null;let n=bj(t.Metadata??t.metadata),r=bj(t.Content??t.content),i=_j(t.CheckpointId??t.checkpointId??t.checkpoint_id??n?.checkpoint_id??n?.checkpointId??r?.checkpoint_id??r?.checkpointId),a=_j(t.RunId??t.runId??t.run_id??n?.run_id??n?.runId??r?.run_id??r?.runId);return!i||!a?null:{checkpointId:i,runId:a,sessionId:_j(t.SessionId??t.sessionId??t.session_id)||void 0,invocationId:_j(t.InvocationId??t.invocationId??t.invocation_id)||void 0,seqId:vj(t.SeqId??t.seqId??t.seq_id),timestamp:yj(t.Timestamp??t.timestamp??t.CreatedAt??t.createdAt),framework:_j(t.Framework??t.framework??n?.framework??r?.framework)||void 0,frameworkRef:bj(t.FrameworkRef??t.frameworkRef??t.framework_ref??n?.framework_ref??n?.frameworkRef),phase:_j(t.Phase??t.phase??n?.phase??r?.phase)||void 0,stage:_j(t.Stage??t.stage??n?.stage??n?.title)||void 0,summary:_j(t.Summary??t.summary??n?.summary??n?.description)||void 0,nextAction:_j(t.NextAction??t.nextAction??t.next_action??n?.nextAction??n?.next_action)||void 0,status:_j(t.Status??t.status??n?.status??r?.status)||void 0,metadata:n}}function Oj(e){let t=bj(e);if(!t)return null;let n=_j(t.ReceiptId??t.receiptId??t.receipt_id),r=_j(t.IdempotencyKey??t.idempotencyKey??t.idempotency_key),i=_j(t.ToolName??t.toolName??t.tool_name);return!n||!r||!i?null:{receiptId:n,idempotencyKey:r,toolName:i,toolCallId:_j(t.ToolCallId??t.toolCallId??t.tool_call_id)||void 0,runId:_j(t.RunId??t.runId??t.run_id)||void 0,checkpointId:_j(t.CheckpointId??t.checkpointId??t.checkpoint_id)||void 0,sessionId:_j(t.SessionId??t.sessionId??t.session_id)||void 0,invocationId:_j(t.InvocationId??t.invocationId??t.invocation_id)||void 0,seqId:vj(t.SeqId??t.seqId??t.seq_id),timestamp:yj(t.Timestamp??t.timestamp??t.CreatedAt??t.createdAt),status:_j(t.Status??t.status)||void 0,replayed:!!(t.Replayed??t.replayed),metadata:bj(t.Metadata??t.metadata)}}var kj=te()((e,t)=>({checkpointsBySessionId:{},toolReceiptsBySessionId:{},setSessionCheckpoints:(t,n)=>e(e=>({checkpointsBySessionId:{...e.checkpointsBySessionId,[t]:Cj(Ej(n.map(Dj).filter(xj).map(e=>({...e,sessionId:e.sessionId||t}))))}})),upsertSessionCheckpoint:(t,n)=>{let r=Dj(n);r&&e(e=>{let n=e.checkpointsBySessionId[t]||[];r.sessionId=r.sessionId||t;let i=new Map(n.map(e=>[e.checkpointId,e]));i.set(r.checkpointId,{...i.get(r.checkpointId),...r});let a=Ej([...i.values()]);return{checkpointsBySessionId:{...e.checkpointsBySessionId,[t]:Cj(a)}}})},getSessionCheckpoints:e=>{let n=String(e||``);return n&&t().checkpointsBySessionId[n]||hj},setSessionToolReceipts:(t,n)=>e(e=>({toolReceiptsBySessionId:{...e.toolReceiptsBySessionId,[t]:wj(n.map(Oj).filter(Sj).map(e=>({...e,sessionId:e.sessionId||t})))}})),getSessionToolReceipts:e=>{let n=String(e||``);return n&&t().toolReceiptsBySessionId[n]||gj},clearSessionCheckpoints:t=>e(e=>{let n=String(t||``);if(!n)return{checkpointsBySessionId:{},toolReceiptsBySessionId:{}};let r={...e.checkpointsBySessionId},i={...e.toolReceiptsBySessionId};return delete r[n],delete i[n],{checkpointsBySessionId:r,toolReceiptsBySessionId:i}})}));function Aj(e,t,n){let r=e.filter(e=>e.role===`model`&&e.invocationId===n),i=oj(t).filter(e=>e.role===`model`),a=i.map(e=>({...e,id:!e.itemId&&i.length===1?r[0]?.id||`${n}:assistant`:e.id,invocationId:n,blocks:qk({content:e.content,reasoning:e.reasoning,tools:e.tools})}));if(a.length===0)return e;let o=e.findIndex(e=>e.role===`model`&&e.invocationId===n),s=e.filter(e=>!(e.role===`model`&&e.invocationId===n)),c=o<0?s.length:Math.min(o,s.length);return[...s.slice(0,c),...a,...s.slice(c)]}var jj=`conversation_item_v1`;function Mj(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Nj(e){return typeof e==`string`&&e.trim()?e:null}function Pj(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Fj(e){return{id:`conversation:${e.runId}:${e.itemId}`,timestamp:0,eventType:jj,eventId:e.sourceEventIds.at(-1),runId:e.runId,itemId:e.itemId,status:e.lifecycle===`failed`?`failed`:e.lifecycle===`completed`?`completed`:`running`}}function Ij(e){return e.lifecycle===`failed`?`error`:e.lifecycle===`completed`?`done`:`streaming`}function Lj(e){let t=typeof e.payload.text==`string`?e.payload.text:``;if(e.kind===`user_message`)return{...Fj(e),role:`user`,content:t,eventType:`user_message`};let n=e.kind===`reasoning`?{id:`conversation-block:${e.itemId}`,type:`thinking`,content:t,status:Ij(e)}:{id:`conversation-block:${e.itemId}`,type:`text`,content:t,status:Ij(e)};return{...Fj(e),role:`model`,content:e.kind===`assistant_text`?t:``,reasoning:e.kind===`reasoning`?t:void 0,blocks:[n]}}function Rj(e){let t=Nj(e.payload.tool)||`Tool`,n=Nj(e.payload.callId),r=Pj(e.payload.args),i=Object.prototype.hasOwnProperty.call(e.payload,`output`)?Pj(e.payload.output):void 0,a=e.lifecycle===`failed`||e.payload.isError===!0?`error`:e.lifecycle===`completed`?`completed`:`running`;return{...Fj(e),role:`model`,content:``,blocks:[{id:`conversation-block:${e.itemId}`,type:`tool`,toolName:t,args:r,output:i,status:a,...n?{extra:{callId:n}}:{}}],tools:{[t]:{name:t,...n?{callId:n}:{},args:r,output:i,status:a}}}}function zj(e){return e===`structured_input`?`structured_input`:e===`plan_review`?`plan_review`:e===`custom`?`custom`:`approval`}function Bj(e){let t=Nj(e.payload.interactionId),n=e.payload.revision;if(!t||!Number.isInteger(n)||Number(n)<1)return null;let r=Pj(e.payload.detail),i=Nj(e.payload.prompt)||r,a=zj(e.payload.interactionKind),o=e.lifecycle===`completed`;return{interactionId:t,sessionId:e.sessionId,runId:e.runId,kind:a,title:Nj(e.payload.title)||(a===`approval`?`审批:${Nj(e.payload.kind)||`操作`}`:`需要补充信息`),message:i||`运行需要人工确认。`,requestSchema:Mj(e.payload.inputSchema),presentation:null,status:o?`resolved`:`pending`,revision:Number(n),createdAt:Nj(e.payload.createdAt)||``,expiresAt:Nj(e.payload.expiresAt),resolvedAt:o?Nj(e.payload.resolvedAt):null,actor:o?Nj(e.payload.actor):null,outcome:o&&[`approved`,`rejected`,`submitted`,`cancelled`,`expired`].includes(String(e.payload.outcome||``))?e.payload.outcome:null,responseSummary:o?Nj(e.payload.responseSummary):null,source:`interaction_v1`,extensions:{conversation_item_id:e.itemId,...Nj(e.payload.callId)?{call_id:Nj(e.payload.callId)}:{}}}}function Vj(e,t){let n=Nj(e.payload.kind)||`approval`,r=Pj(e.payload.detail),i=t.status===`resolved`?t.outcome===`rejected`?`rejected`:t.outcome===`cancelled`||t.outcome===`expired`?`cancelled`:`approved`:`pending`,a=t.status===`pending`?`paused`:`completed`,o={approvalRequestId:t.interactionId,approvalStatus:i,approvalMessage:t.message};return{...Fj(e),role:`model`,content:``,blocks:[{id:`conversation-block:${e.itemId}`,type:`tool`,toolName:n,args:r,status:a,extra:o}],tools:{[n]:{name:n,args:r,status:a,approvalRequestId:t.interactionId,approvalStatus:i,approvalMessage:t.message}}}}function Hj(e){for(let t of[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`]){let n=Nj(Mj(e[t])?.surfaceId);if(n)return n}return null}function Uj(e){let t=Array.isArray(e.payload.data)?e.payload.data:Array.isArray(e.payload.operations)?e.payload.operations:null;if(!t)return null;let n=t.map(Mj);if(n.some(e=>e===null))return null;let r=n,i=Nj(e.payload.surfaceId)||r.map(Hj).find(e=>e!==null)||null;return i?{...Fj(e),role:`a2ui`,content:``,aguiActivity:{surfaceId:i,messages:r}}:null}function Wj(e,t,n,r=!1){return{...Fj(e),role:`system`,content:n?`${t}: ${n}`:t,status:r?`failed`:Fj(e).status}}function Gj(e){let t=e.presentation,n=new Map(t.textItems.map(e=>[e.id,e])),r=new Set(t.toolItems.map(e=>e.itemId)),i=new Set(t.approvalItems.map(e=>e.itemId)),a=new Set(t.structuredInputItems.map(e=>e.itemId)),o=new Set(t.a2uiItems.map(e=>e.itemId)),s=new Map(t.artifacts.map(e=>[e.id,e])),c=new Map(t.fallbacks.map(e=>[e.id,e])),l=[],u=[];for(let{item:e}of t.timeline){if(n.has(e.itemId)){l.push(Lj(e));continue}if(r.has(e.itemId)){l.push(Rj(e));continue}if(i.has(e.itemId)||a.has(e.itemId)){let t=Bj(e);t?(u.push(t),l.push(Vj(e,t))):l.push(Wj(e,`Interaction unavailable`,`The server did not provide a durable interaction revision; this card is read-only.`));continue}if(o.has(e.itemId)){let t=Uj(e);l.push(t||Wj(e,`Unsupported content`,`A2UI payload is not a valid passive operation list.`));continue}let t=s.get(e.itemId);if(t){l.push(t.uri?{...Fj(e),role:`model`,content:t.name,attachments:[{name:t.name,type:t.mimeType,url:t.uri}]}:Wj(e,`Artifact unavailable`,`The artifact URI is not a safe HTTP(S) link.`));continue}let d=c.get(e.itemId);if(d){if(e.kind===`error`&&[`cancelled`,`canceled`].includes(String(e.payload.status||``).toLowerCase()))continue;l.push(Wj(e,d.title,d.detail,d.failed))}}return{messages:l,interactions:u}}function Kj(e,t){let n=Gj(t).messages;if(!n.length)return e;let r=e.filter(e=>e.eventType!==`optimistic_assistant_placeholder`);{let e=-1;for(let t=r.length-1;t>=0;--t){let n=r[t];if(n.role===`user`&&n.eventType===`optimistic_user_message`){e=t;break}}if(e>=0){let i=r[e],a=String(i.content||``).trim();if(r=[...r.slice(0,e),...r.slice(e+1)],!n.some(e=>e.role===`user`)&&a){let e=r.filter(e=>!(e.eventType===jj&&e.runId===t.runId||e.invocationId===t.runId)),a=r.findIndex(e=>e.eventType===jj&&e.runId===t.runId||e.invocationId===t.runId),o=a<0?e.length:a;return[...e.slice(0,o),{...i,timestamp:Date.now()},...n,...e.slice(o)]}}}let i=e=>e.eventType===jj&&e.runId===t.runId||e.invocationId===t.runId,a=r.findIndex(i),o=r.filter(e=>!i(e)),s=a<0?o.length:a;return[...o.slice(0,s),...n,...o.slice(s)]}var qj=`连接断开或生成出错,请重试`;function Jj(e){let t=String(e.message||``).trim();return/runtime agent kernel is not ready/i.test(t)?`云端运行时尚未就绪,请检查部署状态后重试`:!t||/failed to fetch|networkerror/i.test(t)?qj:t.length<=240?t:qj}var Yj=new Set([`completed`]),Xj=new Set([`failed`,`error`,`cancelled`,`canceled`,`aborted`,`incomplete`]),Zj=new Map;function Qj(e,t){Qc.getState().patchMessages(n=>{if(n.some(t=>t.id===e))return t?n.map(n=>n.id===e?{...n,invocationId:t}:n):n;let r=-1;for(let e=n.length-1;e>=0;--e)if(n[e]?.eventType===`optimistic_assistant_placeholder`){r=e;break}return r>=0?n.map((n,i)=>i===r?{...n,id:e,eventType:void 0,invocationId:t}:n):[...n,{id:e,role:`model`,content:``,timestamp:Date.now(),reasoning:``,invocationId:t}]})}function $j(e){return e.filter(e=>e.eventType!==`optimistic_assistant_placeholder`)}function eM(e){let t=String(e||``).trim().toLowerCase(),n=Yj.has(t)?`completed`:Xj.has(t)?`error`:null;n&&Qc.getState().patchMessages(e=>e.map(e=>{if(!e.tools)return e;let t=!1,r=Object.fromEntries(Object.entries(e.tools).map(([e,r])=>r.status===`running`?(t=!0,[e,{...r,status:n}]):[e,r]));return t?{...e,tools:r}:e}))}function tM(e){let t=!!(e.sessionId&&E.getState().currentSessionId!==e.sessionId);if(t&&![`activity`,`stage_changed`,`stream_ended`,`error`,`rate_limited`,`terminal`].includes(e.type))return;let n=Qc.getState(),r=e=>{e&&k.getState().updateActivity({sessionId:e})};switch(e.type){case`activity`:k.getState().updateActivity({sessionId:e.sessionId,source:e.source,status:e.status,phase:e.phase,detail:e.detail,countEvent:e.countEvent});break;case`user_message_added`:k.getState().setBanner(null),n.patchMessages(t=>[...t,{id:e.messageId,role:`user`,content:``,timestamp:Date.now()}]);break;case`assistant_message_created`:Qj(e.messageId,e.invocationId);break;case`text_delta`:Qj(e.messageId),r(e.sessionId),n.patchMessages(t=>t.map(t=>t.id===e.messageId?{...t,content:t.content+e.delta,blocks:Hk(t.blocks,e.delta)}:t));break;case`text_final`:Qj(e.messageId),r(e.sessionId),n.patchMessages(t=>t.map(t=>t.id===e.messageId?(()=>{let n=!!(e.text&&!t.content&&t.reasoning?.endsWith(e.text)),r=n?t.reasoning.slice(0,-e.text.length):t.reasoning,i=n?Wk(t.blocks,e.text):t.blocks;return{...t,reasoning:r,content:e.text,blocks:Uk(i,e.text)}})():t));break;case`reasoning_delta`:Qj(e.messageId),r(e.sessionId),n.patchMessages(t=>t.map(t=>t.id===e.messageId?{...t,reasoning:(t.reasoning||``)+e.delta,blocks:Vk(t.blocks,e.delta)}:t));break;case`tool_upsert`:Qj(e.messageId),r(e.sessionId),n.patchMessages(t=>t.map(t=>{if(t.id!==e.messageId)return t;let n=t.tools?.[e.name],r=n?.approvalStatus===`approved`||n?.approvalStatus===`rejected`||n?.approvalStatus===`cancelled`,i=e.status,a=n?.approvalStatus===`rejected`||n?.approvalStatus===`cancelled`?`completed`:n?.status===`error`&&i!==`error`?`error`:i;return{...t,blocks:Gk(t.blocks,e.name,{args:e.args,status:a,extra:e.extra}),tools:{...t.tools||{},[e.name]:{...n||{name:e.name,args:``},name:e.name,args:e.args,status:a,...e.extra||{},...e.extra?.approvalRequestId&&!r?{approvalStatus:`pending`}:{}}}}}));break;case`tool_result`:Qj(e.messageId),r(e.sessionId),n.patchMessages(t=>t.map(t=>{if(t.id!==e.messageId)return t;let n=OA(e.output)?`error`:`completed`;return{...t,blocks:Gk(t.blocks,e.name,{output:e.output,status:n}),tools:{...t.tools||{},[e.name]:{...t.tools?.[e.name]||{name:e.name,args:``},output:e.output,status:n}}}}));break;case`approval_requested`:Qj(e.messageId),pj({approvalRequestId:e.approvalRequestId,protocol:e.protocol,runId:e.runId,name:e.name,message:e.message,args:e.args,approvalLevel:e.approvalLevel,sessionId:e.sessionId}),n.patchMessages(t=>t.map(t=>{if(t.id!==e.messageId)return t;let n=t.tools?.[e.approvalRequestId],r=n?.approvalStatus===`approved`||n?.approvalStatus===`rejected`||n?.approvalStatus===`cancelled`,i={approvalRequestId:e.approvalRequestId,approvalProtocol:e.protocol,approvalStatus:r?n.approvalStatus:`pending`,...e.message?{approvalMessage:e.message}:{},...e.approvalLevel?{approvalLevel:e.approvalLevel}:{}},a=r?n.status:`paused`;return{...t,blocks:Gk(t.blocks,e.name,{args:e.args,status:a,extra:i}),tools:{...t.tools||{},[e.approvalRequestId]:{...n||{},name:e.name,args:e.args,status:a,...i}}}}));break;case`approval_resolved`:mj({approvalRequestId:e.approvalRequestId,decision:e.decision,revision:e.revision,sessionId:e.sessionId}),n.patchMessages(t=>t.map(t=>{if(!t.tools)return t;let n=!1,r=Object.fromEntries(Object.entries(t.tools).map(([t,r])=>{if(r.approvalRequestId!==e.approvalRequestId)return[t,r];n=!0;let i=e.decision===`rejected`||e.decision===`cancelled`?`completed`:r.status===`paused`?`running`:r.status;return[t,{...r,status:i,approvalStatus:e.decision}]}));return n?{...t,tools:r,blocks:t.blocks?.map(t=>{if(t.type!==`tool`||t.extra?.approvalRequestId!==e.approvalRequestId)return t;let n=e.decision===`rejected`||e.decision===`cancelled`?`completed`:t.status===`paused`?`running`:t.status;return{...t,status:n,extra:{...t.extra,approvalStatus:e.decision}}})}:t}));break;case`system_message`:n.patchMessages(t=>[...t,{id:String(Date.now()+Math.random()),role:`system`,content:e.content,timestamp:Date.now()}]);break;case`compaction`:{let t=`compaction-${Date.now()}`,r=e.phase===`start`?`running`:e.phase===`failed`?`failed`:`completed`,i=ij({id:t,timestamp:Date.now(),status:r,trigger:e.trigger,compactedUntilSeqId:e.compactedUntilSeqId});n.patchMessages(e=>e.findIndex(e=>e.id===t)<0?[...e,i]:e.map(e=>e.id===t?{...e,...i}:e));break}case`stage_changed`:e.stage===`streaming`||e.stage===`connecting`?k.getState().setSessionStreaming(e.sessionId,!0):(e.stage===`completing`||e.stage===`error`||e.stage===`cancelled`)&&k.getState().setSessionStreaming(e.sessionId,!1);break;case`stream_ended`:k.getState().setSessionStreaming(e.sessionId,!1),t||Qc.getState().patchMessages(t=>$j(t).map(t=>!(!e.runId||t.runId===e.runId||t.invocationId===e.runId)||t.role!==`model`||!t.blocks?.some(e=>e.status===`streaming`)?t:{...t,blocks:Kk(t.blocks.map(e=>e.type===`text`&&e.status===`streaming`?{...e,status:`done`}:e))})),globalThis.setTimeout(()=>{let t=k.getState();t.getSessionActivity(e.sessionId)?.status===`completed`&&t.clearSessionActivity(e.sessionId)},2400);break;case`error`:{let r=Jj(e.error);k.getState().setSessionStreaming(e.sessionId,!1),k.getState().updateActivity({sessionId:e.sessionId,status:`failed`,phase:`运行失败`,detail:r,countEvent:!1}),t||(k.getState().setBanner({kind:`error`,message:r,sessionId:e.sessionId}),n.patchMessages(e=>[...$j(e),{id:String(Date.now()),role:`model`,content:`运行失败:${r}`,timestamp:Date.now()}]));break}case`rate_limited`:k.getState().setSessionStreaming(e.sessionId,!1),k.getState().updateActivity({sessionId:e.sessionId,status:`failed`,phase:`请求被限流`,countEvent:!1}),t||(k.getState().setBanner({kind:`rate_limited`,message:e.message||`请求过于频繁,请稍后重试`,retryAfterSec:e.retryAfterSec,sessionId:e.sessionId}),n.patchMessages($j));break;case`terminal`:e.sessionId&&String(e.status||``).trim().toLowerCase()!==`incomplete`&&dj.markSessionTerminal(e.sessionId),t||eM(e.status);break;case`stream_event`:{let t=e.sessionId||e.event.SessionId;fj(e.event,t||void 0);let n=e.event.SeqId;typeof n==`number`&&n>0&&k.getState().setLastSeqId(n),t&&k.getState().updateActivity({sessionId:t});let r=String(e.event.InvocationId||``).trim();if(t&&r){let n=`${t}:${r}`,i=sj(Zj.get(n)||[],[e.event]);Zj.set(n,i),Qc.getState().patchMessages(e=>e.some(e=>e.eventType===`conversation_item_v1`&&e.runId===r)?e:Aj(e,i,r)),lj(e.event)&&Zj.delete(n)}e.event.EventType===`run_checkpoint`&&t&&kj.getState().upsertSessionCheckpoint(t,e.event);{let n=LA(e.event);n===`completed`?k.getState().updateActivity({sessionId:t,status:`completed`,phase:`后台长任务已完成`,countEvent:!1}):n===`cancelled`||n===`canceled`||n===`aborted`?k.getState().updateActivity({sessionId:t,status:`stopped`,phase:`后台长任务已取消`,countEvent:!1}):(n===`failed`||n===`error`)&&k.getState().updateActivity({sessionId:t,status:`failed`,phase:`后台长任务失败`,countEvent:!1})}break}case`conversation_snapshot`:{let t=Gj(e.result);for(let e of t.interactions)dj.upsert(e);n.patchMessages(t=>Kj(t,e.result)),r(e.sessionId);break}case`a2ui_surface_begin`:{let t=`a2ui-${e.surfaceId}`;Qc.getState().patchMessages(n=>[...n.filter(e=>e.id!==t),{id:t,role:`a2ui`,content:``,timestamp:Date.now(),a2ui:{surfaceId:e.surfaceId,surface:e.surface}}]);break}case`a2ui_surface_update`:{let t=`a2ui-${e.surfaceId}`;Qc.getState().patchMessages(n=>n.map(n=>n.id===t&&n.a2ui?{...n,a2ui:{...n.a2ui,surface:e.surface}}:n));break}case`a2ui_surface_end`:{let t=`a2ui-${e.surfaceId}`;Qc.getState().patchMessages(e=>e.map(e=>e.id===t&&e.a2ui?{...e,a2ui:{...e.a2ui,ended:!0}}:e));break}case`a2ui_interaction`:{let t=`a2ui-${e.surfaceId}`;Qc.getState().patchMessages(n=>n.map(n=>n.id===t&&n.a2ui?{...n,a2ui:{...n.a2ui,pendingInteraction:{interactionId:e.interactionId,kind:e.kind,inputSchema:e.inputSchema}}}:n));break}case`agui_activity`:{let t=`agui-a2ui-${e.surfaceId}`;Qc.getState().patchMessages(n=>{let r={surfaceId:e.surfaceId,messages:e.messages},i=!1,a=n.map(t=>{if(t.id!==e.messageId)return t;i=!0;let n=[...(t.aguiActivities||[]).filter(t=>t.surfaceId!==e.surfaceId),r];return{...t,aguiActivities:n}});if(i)return a;let o=n.find(e=>e.id===t),s={id:t,role:`a2ui`,content:``,timestamp:o?.timestamp||Date.now(),aguiActivity:r};return o?n.map(e=>e.id===t?s:e):[...n,s]});break}}}function nM(){Zj.clear()}function rM(e){let t=(0,v.useRef)(new Map),n=(0,v.useRef)(()=>{}),r=(0,v.useMemo)(()=>new jk,[]),i=e.conversationClient===void 0?r:e.conversationClient,{agentId:a,apiFormats:o,agentFramework:s,selectedModel:c,selectedModelMetadata:l,thinkingMode:u,permissionMode:d,currentSessionIdRef:f,queuedDraftRef:p,onRunSettled:m,onSessionCreated:h,waitForPendingSessionCreation:g,uiCapabilities:_}=e,y=(0,v.useCallback)(e=>{e.updateConfig({agentId:a,apiFormats:o,agentFramework:s,selectedModel:c,selectedModelMetadata:l,thinkingMode:_.Thinking?u:`auto`,permissionMode:d,runtimeCapabilityMatrix:_.RuntimeCapabilityMatrix,hostedChatTransport:Ve(_,{requireResumableRun:!!(_.RunLifecycle?.Enabled&&_.RunLifecycle.Resume)}),checkpointResumePreviewEnabled:!!_.RunLifecycle?.CheckpointResumePreview,conversationClient:i||void 0})},[a,o,s,c,l,u,d,_,i]),b=(0,v.useCallback)(n=>{let r=String(n||`new-session`),i=t.current.get(r);return i?y(i):(i=new Lk(e.api),y(i),i.subscribe(tM),t.current.set(r,i)),i},[e.api,y]);(0,v.useEffect)(()=>{for(let e of t.current.values())y(e)},[y]);let x=(0,v.useCallback)(e=>{p.current.push(e),ve.getState().setQueuedDrafts(t=>[...t,e])},[p]),S=(0,v.useCallback)(e=>{let t=e.text.trim(),n=e.attachments.map(e=>({name:e.name,url:URL.createObjectURL(e),type:e.type||`application/octet-stream`}));if(!t&&n.length===0)return;let r=`optimistic-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return Qc.getState().patchMessages(e=>[...e,{id:r,role:`user`,content:t,timestamp:Date.now(),eventType:`optimistic_user_message`,attachments:n.length?n:void 0}]),r},[]),ee=(0,v.useCallback)(()=>{let e=`optimistic-assistant-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return Qc.getState().patchMessages(t=>[...t,{id:e,role:`model`,content:``,reasoning:``,timestamp:Date.now(),eventType:`optimistic_assistant_placeholder`}]),e},[]),C=(0,v.useCallback)(e=>{let r=f.current,i=b(r);if(i.stage!==`idle`)return!1;nM(),ve.getState().setMobileActionsOpen(!1),k.getState().setSessionStreaming(r,!0),e.optimisticMessageId||S(e),e.optimisticAssistantMessageId||ee();let o=i.start({text:e.text,attachments:e.attachments,responsesInput:e.responsesInput,previousResponseId:e.previousResponseId,executionMode:e.executionMode,sessionId:r,onSessionCreated:e=>{h?h(e):(E.getState().upsertSessions([{SessionId:e,UpdatedAt:new Date().toISOString()}]),f.current=e,E.getState().setCurrentSessionId(e)),Pt(a,e),r!==e&&t.current.set(e,i)},onSessionUpsert:()=>{},onSettled:e=>{m?.(e),n.current()}});return o||k.getState().setSessionStreaming(r,!1),o},[a,ee,S,f,b,m,h]);(0,v.useEffect)(()=>{n.current=()=>{let e=p.current.shift();if(!e){ve.getState().setQueuedDrafts([]);return}ve.getState().setQueuedDrafts(e=>e.slice(1)),queueMicrotask(()=>{C(e)||(p.current.unshift(e),ve.getState().setQueuedDrafts(t=>[e,...t]))})}},[p,C]);let w=(0,v.useCallback)(async(e,t,n,r,i)=>{let a={text:e,attachments:t,responsesInput:n,previousResponseId:r,executionMode:i,optimisticMessageId:S({text:e,attachments:t}),optimisticAssistantMessageId:ee()};if(await g?.(),b(f.current).stage!==`idle`&&k.getState().isSessionStreaming(f.current)){n===void 0&&x({text:e,attachments:t,executionMode:i,optimisticMessageId:a.optimisticMessageId,optimisticAssistantMessageId:a.optimisticAssistantMessageId});return}!C(a)&&n===void 0&&x({text:e,attachments:t,executionMode:i,optimisticMessageId:a.optimisticMessageId,optimisticAssistantMessageId:a.optimisticAssistantMessageId})},[ee,S,f,x,b,C,g]),te=(0,v.useCallback)(()=>{b(f.current).stop()},[f,b]),ne=(0,v.useCallback)(()=>{b(f.current).disconnect()},[f,b]),T=(0,v.useCallback)(e=>{let t=b(e.sessionId);if(t.stage!==`idle`)return!1;nM(),ve.getState().setMobileActionsOpen(!1),k.getState().setSessionStreaming(e.sessionId,!0);let r=t.resumeCheckpoint({...e,onSettled:e=>{m?.(e),n.current()}});return r||k.getState().setSessionStreaming(e.sessionId,!1),r},[b,m]),re=(0,v.useCallback)(()=>{nM()},[]);return{submitDraft:w,stopGeneration:te,disconnectRun:ne,resumeCheckpoint:T,submitAguiAction:(0,v.useCallback)(e=>{let t=e.userAction;if(!t)return!1;let n=t.context||{},r=String(n.interruptId||n.interrupt_id||``);if(!r)return!1;let i=f.current;if(!i)return!1;let a=b(i),o=n.status===`cancelled`?`cancelled`:`resolved`,s=Object.prototype.hasOwnProperty.call(n,`payload`)?n.payload:{action:t.name,sourceComponentId:t.sourceComponentId,context:n};return a.resumeAguiInterrupt({sessionId:i,interruptId:r,status:o,payload:s,onSettled:m})},[f,b,m]),respondToAguiApproval:(0,v.useCallback)(e=>{if(!e.interruptId)return!1;let t=f.current;if(!t)return!1;let n=b(t);if(n.stage!==`idle`)return!1;k.getState().setSessionStreaming(t,!0);let r=n.resumeAguiInterrupt({sessionId:t,interruptId:e.interruptId,status:`resolved`,payload:{decision:e.approve?`approve`:`reject`},onSettled:m});return r||k.getState().setSessionStreaming(t,!1),r},[f,b,m]),resetCompaction:re}}function iM(e){return String(e||``).trim()}function aM(e){let t=iM(e).toLowerCase();return t===`up`||t===`down`?t:``}function oM(e){if(!e||typeof e!=`object`)return null;let t=aM(e.Rating||e.rating);return t?{agentId:iM(e.AgentId||e.agentId),sessionId:iM(e.SessionId||e.sessionId),responseId:iM(e.ResponseId||e.responseId),eventId:iM(e.EventId||e.eventId),rating:t,comment:String(e.Comment??e.comment??``),traceId:iM(e.TraceId||e.traceId),rootSpanId:iM(e.RootSpanId||e.rootSpanId),updatedAt:iM(e.UpdatedAt||e.updatedAt)}:null}function sM(e,t,n){return!!(e?.role===`model`&&iM(e.responseId)&&!(t&&n))}function cM({agentId:e,sessionId:t,message:n}){let r=iM(n?.responseId);if(!r)throw Error(`Message missing response id`);return{AgentId:iM(e),SessionId:iM(t),ResponseId:r}}function lM({agentId:e,sessionId:t,message:n,rating:r,comment:i=``}){let a=aM(r);if(!a)throw Error(`Feedback rating must be up or down`);return{...cM({agentId:e,sessionId:t,message:n}),Rating:a,Comment:String(i||``),TraceId:iM(n?.traceId),RootSpanId:iM(n?.rootSpanId)}}function uM(e,{messageId:t,rating:n,comment:r=``}){let i=e.find(e=>e.id===t),a=i?.feedback?{...i.feedback}:null,o=aM(n);return{nextMessages:e.map(e=>e.id===t?{...e,feedback:{...e.feedback||{},responseId:iM(e.responseId),eventId:iM(e.eventId),rating:o,comment:String(r||``),pending:!0,error:``}}:e),previousFeedback:a}}function dM(e,{messageId:t,feedback:n}){let r=oM(n)||n;return e.map(e=>e.id===t?{...e,feedback:r?{...r,pending:!1,error:``}:void 0}:e)}function fM(e,{messageId:t,previousFeedback:n}){return e.map(e=>{if(e.id!==t)return e;if(!n){let{feedback:t,...n}=e;return n}return{...e,feedback:n}})}function pM(e,{messageId:t}){return e.map(e=>{if(e.id!==t)return e;let{feedback:n,...r}=e;return r})}function mM(e){let{agentId:t,currentSessionId:n,isStreaming:r,api:i,submitDraft:a}=e;return{submitResponseFeedback:(0,v.useCallback)(async e=>{if(!n)return;let r=null;Qc.getState().patchMessages(t=>{let n=uM(t,{messageId:e.message.id,rating:e.rating,comment:e.comment||``});return r=n.previousFeedback,n.nextMessages});try{let r=oM((await i.upsertResponseFeedback(lM({agentId:t,sessionId:n,message:e.message,rating:e.rating,comment:e.comment||``})))?.Feedback);r&&Qc.getState().patchMessages(t=>dM(t,{messageId:e.message.id,feedback:r}))}catch(t){console.error(`Failed to submit response feedback:`,t),Qc.getState().patchMessages(t=>fM(t,{messageId:e.message.id,previousFeedback:r}))}},[t,n,i]),deleteResponseFeedback:(0,v.useCallback)(async e=>{if(!n)return;let r=e.feedback?{...e.feedback}:null;Qc.getState().patchMessages(t=>pM(t,{messageId:e.id}));try{await i.deleteResponseFeedback(cM({agentId:t,sessionId:n,message:e}))}catch(t){console.error(`Failed to delete response feedback:`,t),Qc.getState().patchMessages(t=>fM(t,{messageId:e.id,previousFeedback:r}))}},[t,n,i]),respondToApproval:(0,v.useCallback)(e=>{!e.approvalRequestId||r||(Qc.getState().patchMessages(t=>t.map(t=>{let n=e.approve?`approved`:`rejected`,r=t=>e.approve&&t===`paused`?`running`:e.approve?t:`completed`;return{...t,tools:t.tools?Object.fromEntries(Object.entries(t.tools).map(([t,i])=>[t,i.approvalRequestId===e.approvalRequestId?{...i,status:r(i.status),approvalStatus:n}:i])):t.tools,blocks:t.blocks?.map(t=>t.type===`tool`&&t.extra?.approvalRequestId===e.approvalRequestId?{...t,status:r(t.status),extra:{...t.extra,approvalStatus:n}}:t)}})),a(``,[],[{type:`mcp_approval_response`,approval_request_id:e.approvalRequestId,approve:e.approve}],e.previousResponseId))},[r,a])}}function hM(e){let[t]=(0,v.useState)(()=>new tA({agentId:e.agentId,store:dj,submitInteraction:t=>e.api.submitInteraction({...t,AgentId:e.getAgentId?.()??t.AgentId}),interactionV1Enabled:e.interactionV1Enabled,legacyResponsesApproval:e.legacyResponsesApproval,legacyAguiResume:e.legacyAguiResume}));(0,v.useEffect)(()=>{t.setInteractionV1Enabled(e.interactionV1Enabled)},[t,e.interactionV1Enabled]);let[n,r]=(0,v.useState)(0);(0,v.useEffect)(()=>dj.subscribe(()=>r(e=>e+1)),[]);let i=(0,v.useMemo)(()=>e.currentSessionId?dj.listAll(e.currentSessionId).filter(e=>e.status===`pending`||e.status===`resolving`||e.status===`failed`):[],[n,e.currentSessionId]),a=(0,v.useMemo)(()=>e.currentSessionId?dj.listAll(e.currentSessionId):[],[n,e.currentSessionId]),{currentSessionId:o,interactionV1Enabled:s,onAcceptedInteraction:c}=e;return{client:t,pending:i,records:a,respond:(0,v.useCallback)(e=>{let n=o?dj.get(o,e.interactionId):null;return t.respond(e).then(e=>(s&&n&&(e.status===`accepted`||e.status===`duplicate`)&&c?.(n),e))},[t,o,s,c]),localCatalog:FO}}var gM={running:`running`,completed:`completed`,failed:`error`,paused:`paused`,approved:`completed`,denied:`completed`},_M={paused:`pending`,approved:`approved`,denied:`rejected`};function vM(e){if(typeof e==`number`&&Number.isFinite(e))return e>0&&e<1e11?e*1e3:e;if(typeof e==`string`){let t=Number(e.trim());if(e.trim()&&Number.isFinite(t))return t>0&&t<1e11?t*1e3:t;let n=Date.parse(e);if(Number.isFinite(n))return n}return Date.now()}function yM(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`){if(typeof e.text==`string`)return e.text;if(Array.isArray(e.parts))return e.parts.map(e=>e&&typeof e==`object`&&typeof e.text==`string`?e.text:``).join(``)}return``}function bM(e){let t={},n=new Map;for(let t of e??[])t?.Name&&n.set(t.Name,(n.get(t.Name)||0)+1);for(let r of e??[]){if(!r?.Name)continue;let e=gM[String(r.Status??`completed`).toLowerCase()]??`completed`,i={name:r.Name,args:r.Args===void 0?``:typeof r.Args==`string`?r.Args:JSON.stringify(r.Args),status:e};r.Result!==void 0&&(i.output=typeof r.Result==`string`?r.Result:JSON.stringify(r.Result)),r.ApprovalRequestId&&(i.approvalRequestId=r.ApprovalRequestId,i.approvalStatus=_M[String(r.Status??`paused`).toLowerCase()]??`pending`,i.approvalProtocol=String(r.Protocol??``).toLowerCase()===`ag-ui`?`ag-ui`:`responses`,r.ApprovalMessage&&(i.approvalMessage=String(r.ApprovalMessage)),r.ApprovalLevel&&(i.approvalLevel=String(r.ApprovalLevel))),r.ToolCallId&&(i.previousResponseId=r.ToolCallId);let a=n.get(r.Name)>1&&r.ToolCallId?r.ToolCallId:r.Name;t[a]=i}return t}function xM(e){if(Array.isArray(e))return e.map(e=>({name:e.name||``,url:e.url||``,type:e.mime||``,fileUri:e.file_uri}))}function SM(e){return e==null?``:typeof e==`string`?e:JSON.stringify(e)}function CM(e){if(!(!Array.isArray(e)||!e.length))return e.flatMap((e,t)=>{let n=String(e?.Type||``).toLowerCase(),r=e?.SeqId??t;if(n===`thinking`||n===`text`){let t=String(e?.Content||``);return t?[{id:`history-${n}-${r}`,type:n,content:t,status:`done`}]:[]}if(n!==`tool`)return[];let i=gM[String(e?.Status||`completed`).toLowerCase()]??`completed`;return[{id:`history-tool-${r}`,type:`tool`,toolName:String(e?.Name||`tool`),args:SM(e?.Args),...e?.Result===void 0?{}:{output:SM(e.Result)},status:i,...e?.ToolCallId?{extra:{previousResponseId:String(e.ToolCallId)}}:{}}]})}function wM(e){let t=e.Role===`assistant`?`model`:e.Role||`user`,n=e.ToolEvents?.length?bM(e.ToolEvents):void 0,r=xM(e.Attachments),i=CM(e.Blocks),a=e.Reasoning?.length?e.Reasoning.map(e=>e.text).join(``):void 0,o={id:e.MessageId||`msg-${e.SeqId??Math.random().toString(36).slice(2)}`,role:t,content:yM(e.Content),timestamp:vM(e.Timestamp),eventType:t===`user`?`user_message`:`assistant_message`,reasoning:a,tools:n,attachments:r};return t===`model`&&(o.blocks=i??qk({reasoning:a,tools:n,content:o.content})),e.MessageId&&(o.eventId=e.MessageId),e.InvocationId&&(o.invocationId=e.InvocationId),e.ResponseId&&(o.responseId=e.ResponseId),e.TraceId&&(o.traceId=e.TraceId),e.RootSpanId&&(o.rootSpanId=e.RootSpanId),o}function TM(e){return Array.isArray(e.Activities)?e.Activities.flatMap((t,n)=>{let r=String(t?.SurfaceId||``);if(!r)return[];let i=t?.Content,a=Array.isArray(i?.a2ui_operations)?i.a2ui_operations:Array.isArray(i)?i:[];if(!a.length||r.startsWith(`approval-`)&&a.some(e=>{let t=e?.updateComponents?.components||e?.update_components?.components;return Array.isArray(t)&&t.some(e=>e?.component===`ApprovalBar`)}))return[];let o=String(t.MessageId||``);return[{id:o&&o!==String(e.MessageId||``)?o:`${o||e.MessageId||e.SeqId||`message`}:a2ui:${r}:${n}`,role:`a2ui`,content:``,timestamp:vM(e.Timestamp),aguiActivity:{surfaceId:r,messages:IO(a)}}]}):[]}function EM(e){return e.flatMap(e=>[wM(e),...TM(e)])}function DM(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function OM(e){if(typeof e==`number`&&Number.isFinite(e))return e>0&&e<1e11?e*1e3:e;if(typeof e==`string`&&e.trim()){let t=Number(e.trim());if(Number.isFinite(t))return t>0&&t<1e11?t*1e3:t}let t=Date.parse(String(e||``));return Number.isFinite(t)?t:Date.now()}function kM(e){let t=DM(e?.Content?.runtime_event||e?.Content?.runtimeEvent);if(t&&String(t.event_type||``))return{...t,family:`runtime`,seq:Number(e.SeqId||t.seq||0),timestamp:e.Timestamp||t.timestamp};let n=DM(e?.Content?.session_event||e?.Content?.sessionEvent);if(!n||String(n.family||``)!==`runtime`)return null;let r=DM(n.payload);return!r||!String(r.event_type||n.event_type||``)?null:{...r,family:`runtime`,event_type:r.event_type||n.event_type,run_id:r.run_id||n.run_id,seq:Number(e.SeqId||n.seq||r.seq||0),timestamp:e.Timestamp||n.timestamp||r.timestamp}}function AM(e){return e.role===`model`?{...e,blocks:e.blocks?.length?e.blocks:qk({content:e.content,reasoning:e.reasoning,tools:e.tools})}:e}function jM(e,t){let n=t.find(e=>e.role===`user`),r=e.some(e=>e.role===`user`),i=t.filter(e=>e.role===`model`),a=e.filter(e=>e.role===`model`).at(-1),o=i.at(-1),s=e.map(e=>e.role===`user`&&n?{...e,...n,invocationId:e.invocationId||n.invocationId}:AM(e===a&&o?{...e,responseId:o.responseId||e.responseId,traceId:o.traceId||e.traceId,rootSpanId:o.rootSpanId||e.rootSpanId}:e));return n&&!r?[n,...s]:s}function MM(e,t){let n=t.filter(e=>e.role===`model`),r=n.reduce((e,t)=>({...e,...t.tools||{}}),{}),i=n.map(e=>String(e.reasoning||``).trim()).filter(Boolean).join(`
|
|
95
|
+
|
|
96
|
+
`),a=[...e].reverse().find(e=>e.role===`model`);return!a||Object.keys(r).length===0&&!i?e:e.map(e=>e===a?AM({...e,reasoning:e.reasoning||i||void 0,tools:Object.keys(r).length>0?{...e.tools||{},...r}:e.tools}):e)}function NM(e){return new Set(e.filter(e=>e.role===`model`&&e.eventType===`assistant_message`&&!!String(e.content||``).trim()&&!!e.invocationId).map(e=>String(e.invocationId)))}var PM=new Set([`approval.resolved`,`interaction.resolved`,`interaction.cancelled`,`interaction.canceled`,`a2ui.action`]);function FM(e){let t=new Set;for(let n of e){let e=DM(n.Content)||{},r=DM(e.runtime_event||e.runtimeEvent)||{},i=DM(e.payload)||DM(r.payload)||{},a=String(n.EventType||e.event_type||e.eventType||r.event_type||``).toLowerCase();if(!PM.has(a))continue;let o=String(e.outcome||e.action||e.name||e.status||i.outcome||i.action||i.name||i.status||``).toLowerCase();if(![`cancel`,`cancelled`,`canceled`].includes(o))continue;let s=String(n.InvocationId||e.runId||e.run_id||i.runId||i.run_id||r.run_id||``).trim();s&&t.add(s)}return t}function IM(e,t,n){let r=new Vl(n),i=[],a=new Set,o=new Set,s=[...t||[]].sort((e,t)=>Number(e.SeqId||0)-Number(t.SeqId||0)),c=Number(s[0]?.SeqId||0)<=1;for(let e of s){let t=kM(e);if(!t)continue;let n=String(t.run_id||``).trim();if(n){a.add(n);let e=DM(DM(t.source)?.metadata),r=String(t.event_type||``)===`run.started`,i=e?.native_item_kind===`userMessage`;(c||r||i)&&o.add(n)}let s=r.translate(t);s&&i.push({...s,SeqId:Number(e.SeqId||s.SeqId||0),Timestamp:OM(e.Timestamp||s.Timestamp)})}let l=oj(i).filter(e=>e.invocationId&&a.has(e.invocationId)),u=new Map;for(let t of e){let e=String(t.invocationId||``);e&&u.set(e,[...u.get(e)||[],t])}let d=new Set([...NM(l)].filter(e=>o.has(e))),f=FM(s),p=[...d].flatMap(e=>jM(l.filter(t=>t.invocationId===e),u.get(e)||[])),m=new Map;for(let[e,t]of u)d.has(e)||!a.has(e)||m.set(e,MM(t,l.filter(t=>t.invocationId===e)));let h=new Map([...m.values()].flat().map(e=>[e.id,e]));return{messages:[...e.filter(e=>!(e.role===`model`&&e.invocationId&&f.has(e.invocationId))&&(e.role===`a2ui`||!e.invocationId||!d.has(e.invocationId))).map(e=>h.get(e.id)||e),...p].sort((e,t)=>Number(e.timestamp||0)-Number(t.timestamp||0)),canonicalRunIds:[...d],translatedEvents:i}}var LM=class extends Error{seq;constructor(e){super(`Session event seq ${e} was received twice with conflicting content`),this.name=`SessionEventConflictError`,this.seq=e}};function RM(e){return Array.isArray(e)?`[${e.map(RM).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>e<t?-1:+(e>t)).map(([e,t])=>`${JSON.stringify(e)}:${RM(t)}`).join(`,`)}}`:JSON.stringify(e)??`null`}var zM=new Set([`runtime`]),BM=class{eventsBySeq=new Map;lastSeqValue=0;accept(e){let t=Gc(e);if(!t.ok)throw t.error;let n=t.value,r=this.eventsBySeq.get(n.seq);if(r){if(RM(r)!==RM(n))throw new LM(n.seq);return}this.eventsBySeq.set(n.seq,n),this.lastSeqValue=Math.max(this.lastSeqValue,n.seq)}get lastSeq(){return this.lastSeqValue}reconnectAfterSeq(){return this.lastSeqValue}displayableEvents(){return[...this.eventsBySeq.values()].filter(e=>zM.has(e.family)).sort((e,t)=>e.seq-t.seq)}};function VM(){return new BM}var HM=500,UM=30,WM=50,GM=200,KM=8,qM=1800*1e3;function JM(e){return new Promise(t=>{if(e.aborted){t();return}let n=globalThis.setTimeout(t,HM);e.addEventListener(`abort`,()=>{globalThis.clearTimeout(n),t()},{once:!0})})}var YM=new Set([`in_progress`,`running`,`resuming`,`starting`]);function XM(e){let t=e.ActiveRunUpdatedAt||e.UpdatedAt,n=typeof t==`number`?t>1e11?t:t*1e3:Date.parse(String(t||``));return Number.isFinite(n)&&n<=Date.now()+qM&&Date.now()-n<=qM}function ZM(e){let t=LA(e);return t?t===`completed`?{status:`completed`,phase:`后台长任务已完成`}:t===`cancelled`||t===`canceled`||t===`aborted`?{status:`stopped`,phase:`后台长任务已取消`}:t===`interrupted`?{status:`stopped`,phase:`后台长任务已中断`}:t===`failed`||t===`error`?{status:`failed`,phase:`后台长任务失败`}:t===`resume_failed`?{status:`failed`,phase:`后台长任务恢复失败`}:null:null}function QM(e){let{agentId:t,api:n,isMobile:r,resetCompaction:i,uiCapabilities:a,disconnectRun:o}=e,s=(0,v.useRef)(e.currentSessionId),c=(0,v.useRef)(e.agentId),l=(0,v.useRef)(null),u=(0,v.useRef)(VM()),d=(0,v.useRef)(0),f=(0,v.useRef)(new Map),p=(0,v.useRef)(new Map),m=(0,v.useRef)(new Map),h=(0,v.useRef)(new Map),g=(0,v.useRef)(new Map),_=(0,v.useRef)(new Map),y=(0,v.useRef)(null),b=(0,v.useRef)(null),x=(0,v.useRef)(null),S=(0,v.useCallback)(async(e,t,r)=>{let i=r.filter(e=>sM(e,!1,!1));if(!i.length)return;let a=await Promise.all(i.map(async r=>{try{let i=await n.getResponseFeedback({AgentId:e,SessionId:t,ResponseId:r.responseId,EventId:r.eventId}),a=i?.Feedback?oM(i.Feedback):null;return a?{messageId:r.id,feedback:a}:null}catch(e){return console.error(`Failed to load response feedback:`,e),null}}));if(s.current!==t)return;let o=new Map(a.filter(e=>!!e).map(e=>[e.messageId,e.feedback]));o.size&&Qc.getState().patchMessages(e=>e.map(e=>o.has(e.id)?{...e,feedback:o.get(e.id)}:e))},[n]),ee=(0,v.useCallback)(async e=>{l.current?.abort();let t=new AbortController;l.current=t;let r=!1,i=!1,a=e.afterSeqId,o=()=>l.current===t&&s.current===e.sessionId;try{for(k.getState().setCurrentRunId(e.invocationId),k.getState().setActiveInvocationId(e.invocationId),k.getState().setSessionStreaming(e.sessionId,!0),k.getState().updateActivity({sessionId:e.sessionId,status:`running`,phase:`后台长任务运行中`,detail:e.invocationId,countEvent:!1});!i&&o();){try{let s=await n.subscribeRunEvents({sessionId:e.sessionId,invocationId:e.invocationId,afterSeqId:a},{signal:t.signal});if(!o()){t.abort();return}let c=s.getReader(),l=new TextDecoder,d=``;for(;!i&&o();){let{value:t,done:n}=await c.read();if(n)break;d+=l.decode(t,{stream:!0});let s=xl(d);d=s.remainder;for(let t of s.chunks)if(t.trim()){for(let n of bl(t)){if(n.eventName===`__ping__`){k.getState().updateActivity({sessionId:e.sessionId,status:`running`,countEvent:!1});continue}if(n.eventName===`__done__`){i=!0,r=!0;break}if(!n.data||typeof n.data!=`object`)continue;let t=n.data;if(!o())break;if(t.InvocationId&&t.InvocationId!==e.invocationId)continue;if(typeof t.seq==`number`){try{u.current.accept(t)}catch(e){console.error(`[SessionLifecycle] session event cursor conflict:`,e)}a=Math.max(a,u.current.reconnectAfterSeq()),tM({type:`stream_event`,sessionId:e.sessionId,event:t}),i||=lj(t),r||=i;let n=ZM(t);n&&k.getState().updateActivity({sessionId:e.sessionId,status:n.status,phase:n.phase,detail:e.invocationId,countEvent:!1});continue}let s=Number(t.SeqId||0);Number.isFinite(s)&&(a=Math.max(a,s)),tM({type:`stream_event`,sessionId:e.sessionId,event:t}),i||=lj(t),r||=i;let c=ZM(t);if(c&&k.getState().updateActivity({sessionId:e.sessionId,status:c.status,phase:c.phase,detail:e.invocationId,countEvent:!1}),i)break}if(i)break}}i&&c.cancel().catch(()=>{})}catch(t){if(t instanceof DOMException&&t.name===`AbortError`||!o())break;console.warn(`Run event subscription disconnected; retrying:`,t),k.getState().updateActivity({sessionId:e.sessionId,status:`waiting`,phase:`恢复连接中`,detail:e.invocationId,countEvent:!1})}!i&&o()&&await JM(t.signal)}i&&o()&&tM({type:`stream_ended`,sessionId:e.sessionId})}catch(e){e instanceof DOMException&&e.name===`AbortError`||console.error(`Failed to subscribe run events:`,e)}finally{let n=l.current===t;n&&(l.current=null),n&&s.current===e.sessionId&&(k.getState().setCurrentRunId(``),k.getState().setActiveInvocationId(``),r&&b.current?.(e.sessionId),x.current?.(c.current,e.sessionId))}},[n]),C=(0,v.useCallback)(e=>{!a.RunLifecycle.Enabled||!e.runId||c.current!==t||s.current!==e.sessionId||l.current||ee({sessionId:e.sessionId,invocationId:e.runId,afterSeqId:cj(g.current.get(e.sessionId)?.events||[])})},[t,ee,a.RunLifecycle.Enabled]),w=(0,v.useCallback)(async e=>{let t=s.current,o=++d.current,u=(e,t)=>{let n=m.current;for(n.delete(e),n.set(e,t);n.size>KM;){let e=n.keys().next().value;if(!e)break;n.delete(e)}},f=m.current.get(e);t&&t!==e&&(u(t,Qc.getState().messages),Qc.getState().setMessages(f||[]),E.getState().clearSessionMessageHistory(e),kj.getState().setSessionCheckpoints(e,[]),kj.getState().setSessionToolReceipts(e,[]),k.getState().setCurrentRunId(``),k.getState().clearActivity()),s.current=e;let _=()=>s.current===e&&d.current===o;E.getState().setCurrentSessionId(e),E.getState().setSessionInitialMessageHistoryLoading(e,!f),i(),l.current?.abort(),r&&ve.getState().setMobileSidebarOpen(!1);try{let t={limit:WM,includeReasoning:!0,includeToolEvents:!0,includeAttachments:!0},r;try{r=await n.listSessionMessages(e,t)}catch(i){if(i instanceof Yt)throw i;if(await new Promise(e=>globalThis.setTimeout(e,180)),!_())return;r=await n.listSessionMessages(e,t)}if(!_())return;let i=EM(r.Messages);h.current.set(e,i);let o=i,s=0,l=[];f||(Qc.getState().setMessages(i),u(e,i)),E.getState().setSessionMessageHistory(e,{nextCursor:r.NextCursor,hasMore:r.HasMore}),E.getState().setSessionInitialMessageHistoryLoading(e,!1);try{let t=await n.listSessionEvents(e,{offset:0,limit:GM});if(!_())return;let a={events:t.Events||[],loadedCount:t.Events?.length||0,total:Math.max(0,Number(t.Total??t.Events?.length??0)||0)};if(g.current.set(e,a),E.getState().setSessionMessageHistory(e,{nextCursor:r.NextCursor,hasMore:!!(r.HasMore||a.loadedCount<a.total)}),a.events.length>0){s=cj(a.events);let t=IM(i,a.events,e);l=t.canonicalRunIds,o=t.messages;for(let t of a.events)fj(t,e)}}catch(e){console.warn(`[SessionLifecycle] canonical history replay failed:`,e)}if(!_())return;p.current.set(e,new Set(l)),Qc.getState().setMessages(o),u(e,o),S(c.current,e,o);let d=Math.max(r.LatestSeqId||0,s),m=He.getState().capabilities||a;if(m.RunLifecycle.Enabled&&m.RunLifecycle.Checkpoints?(n.listSessionCheckpoints({agentId:c.current,sessionId:e}).then(t=>{_()&&kj.getState().setSessionCheckpoints(e,t.Checkpoints||[])}).catch(t=>{_()&&(console.warn(`[SessionLifecycle] checkpoint load failed:`,t),kj.getState().setSessionCheckpoints(e,[]))}),n.listToolReceipts({agentId:c.current,sessionId:e}).then(t=>{_()&&kj.getState().setSessionToolReceipts(e,t.ToolReceipts||[])}).catch(t=>{_()&&(console.warn(`[SessionLifecycle] tool receipt load failed:`,t),kj.getState().setSessionToolReceipts(e,[]))})):kj.getState().clearSessionCheckpoints(e),m.RunLifecycle.Enabled&&m.RunLifecycle.Resume)try{let t=await n.getSession(e);if(!_())return;let r=String(t.ActiveRunStatus||``).toLowerCase();t.ActiveInvocationId&&(YM.has(r)||r===``&&XM(t))&&ee({sessionId:e,invocationId:t.ActiveInvocationId,afterSeqId:d})}catch(e){console.warn(`[SessionLifecycle] getSession for reconnect failed:`,e)}}catch(e){console.error(`Failed to load session messages:`,e)}finally{_()&&E.getState().setSessionInitialMessageHistoryLoading(e,!1)}},[n,r,S,i,ee,a]),te=(0,v.useCallback)(async(e=`default-agent`,t=null)=>{try{let r=E.getState();r.sessionsAgentId&&r.sessionsAgentId!==e&&r.resetSessionPagination(e),E.getState().setLoadingSessions(!0);let i=await n.listSessions(e,{page:1,pageSize:UM}),a=i.Sessions||[];for(let e of a)_.current.delete(e.SessionId);let c=new Set(Array.from(_.current.entries()).filter(([,t])=>t===e).map(([e])=>e)),u=It(a,E.getState().sessions,c);if(E.getState().upsertSessions(u,{agentId:e,total:Number(i.Total??i.Sessions?.length??0),page:Number(i.Page??1),pageSize:Number(i.PageSize??UM),replace:!0}),y.current)return;let f=E.getState().sessions,p=s.current,m=Ft(f,p||t||Nt(e));m&&m!==p?w(m):!m&&p&&(d.current+=1,l.current?.abort(),o?.(),s.current=null,E.getState().setCurrentSessionId(null),Qc.getState().setMessages([]),E.getState().clearSessionMessageHistory(),kj.getState().clearSessionCheckpoints(),k.getState().setCurrentRunId(``),k.getState().clearActivity())}catch(e){if(e instanceof Yt)return;console.error(`Failed to fetch sessions:`,e)}finally{E.getState().setLoadingSessions(!1)}},[n,o,w]),ne=(0,v.useCallback)(async()=>{let e=E.getState();if(e.isLoadingSessions||!e.hasMoreSessions)return;let t=re({total:e.sessionsTotal,pageSize:e.sessionsPageSize||UM,loadedPages:e.loadedPages});if(!t)return;let r=e.sessionsPageSize||UM,i=e.sessionsAgentId||c.current||`default-agent`;try{E.getState().setLoadingSessions(!0);let a=await n.listSessions(i,{page:t,pageSize:r});E.getState().upsertSessions(a.Sessions||[],{agentId:i,total:Number(a.Total??e.sessionsTotal),page:Number(a.Page??t),pageSize:Number(a.PageSize??r)})}catch(e){if(e instanceof Yt)return;console.error(`Failed to load more sessions:`,e)}finally{E.getState().setLoadingSessions(!1)}},[n]);(0,v.useEffect)(()=>{b.current=w},[w]),(0,v.useEffect)(()=>{x.current=te},[te]);let T=(0,v.useCallback)((e,t=!1)=>{d.current+=1,l.current?.abort(),_.current.set(e,c.current),E.getState().upsertSessions([{SessionId:e,UpdatedAt:new Date().toISOString()}]),s.current=e,E.getState().setCurrentSessionId(e),t||(Qc.getState().setMessages([]),k.getState().setCurrentRunId(``),k.getState().clearActivity()),E.getState().clearSessionMessageHistory(e),kj.getState().setSessionCheckpoints(e,[]),kj.getState().setSessionToolReceipts(e,[]),r&&(ve.getState().setMobileSidebarOpen(!1),ve.getState().setMobileActionsOpen(!1))},[r]),ie=(0,v.useCallback)(async()=>{d.current+=1,l.current?.abort(),s.current=null,E.getState().setCurrentSessionId(null),Qc.getState().setMessages([]);let e=n.createSession(t).then(e=>{let t=e.SessionId||null;return t&&T(t,Qc.getState().messages.some(e=>e.eventType===`optimistic_user_message`||e.eventType===`optimistic_assistant_placeholder`)),t}).catch(e=>(e instanceof Yt||console.error(`Failed to create session:`,e),null));y.current=e;try{await e}finally{y.current===e&&(y.current=null)}},[T,t,n]),ae=(0,v.useCallback)(async()=>(await y.current,s.current),[]),oe=(0,v.useCallback)(async e=>{try{if((await n.deleteSession(e)).Deleted===!1){ve.getState().pushToast(`会话暂未删除,云端运行时仍在同步,请稍后重试。`,`error`),te(t,s.current??void 0);return}E.getState().removeSession(e),E.getState().clearSessionMessageHistory(e),m.current.delete(e),h.current.delete(e),g.current.delete(e),p.current.delete(e),_.current.delete(e),s.current===e&&(d.current+=1,l.current?.abort(),o?.(),s.current=null,Qc.getState().setMessages([]),kj.getState().clearSessionCheckpoints(e),E.getState().setCurrentSessionId(null),k.getState().setCurrentRunId(``),k.getState().clearActivity(),te(t))}catch(e){if(e instanceof Yt)return;console.error(`Failed to delete session`,e),ve.getState().pushToast(`删除会话失败,请稍后重试。`,`error`)}},[t,n,o,te]);return{followAcceptedInteraction:C,fetchSessions:te,loadMoreSessions:ne,loadSession:w,loadOlderSessionMessages:(0,v.useCallback)(async e=>{let t=E.getState().messageHistory[e],r=g.current.get(e),i=!!(t?.hasMore&&t.nextCursor!==null),a=!!(r&&r.loadedCount<r.total);if(!t||t.isLoadingOlder||!i&&!a)return;let o=d.current,l=Symbol(e);f.current.set(e,l);try{E.getState().setSessionMessageHistoryLoading(e,!0);let[u,_]=await Promise.all([i?n.listSessionMessages(e,{beforeSeqId:t.nextCursor??void 0,limit:WM,includeReasoning:!0,includeToolEvents:!0,includeAttachments:!0}):Promise.resolve(null),a&&r?n.listSessionEvents(e,{offset:r.loadedCount,limit:GM}):Promise.resolve(null)]);if(s.current!==e||d.current!==o||f.current.get(e)!==l)return;let v=u?EM(u.Messages):[],y=new Set(v.map(e=>e.id)),b=[...v,...(h.current.get(e)||[]).filter(e=>!y.has(e.id))];h.current.set(e,b);let x=r?.events||[],ee=r?.loadedCount||0,C=r?.total||0;if(_){let t=_.Events||[];x=sj(t,x),C=Math.max(C,Number(_.Total??0)||0),ee=t.length>0?Math.min(C,ee+t.length):C,g.current.set(e,{events:x,loadedCount:ee,total:C});for(let n of t)fj(n,e)}let w=IM(b,x,e),te=w.messages;p.current.set(e,new Set(w.canonicalRunIds)),Qc.getState().setMessages(te),m.current.delete(e),m.current.set(e,te),E.getState().setSessionMessageHistory(e,{nextCursor:u?u.NextCursor:t.nextCursor,hasMore:!!(u&&u.HasMore||ee<C)}),S(c.current,e,v)}catch(e){e instanceof Yt||console.error(`Failed to load older session messages:`,e)}finally{f.current.get(e)===l&&(f.current.delete(e),E.getState().setSessionMessageHistoryLoading(e,!1))}},[n,S]),createNewSession:ie,adoptCreatedSession:T,waitForPendingSessionCreation:ae,deleteSession:oe,currentSessionIdRef:s,agentIdRef:c,runSubscriptionAbortRef:l}}var $M=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),eN=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),tN=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),nN=e=>{let t=tN(e);return t.charAt(0).toUpperCase()+t.slice(1)},rN={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`},iN=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},aN=(0,v.createContext)({}),oN=()=>(0,v.useContext)(aN),sN=(0,v.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=oN()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,v.createElement)(`svg`,{ref:c,...rN,width:t??l??rN.width,height:t??l??rN.height,stroke:e??f,strokeWidth:m,className:$M(`lucide`,p,i),...!a&&!iN(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,v.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),cN=(e,t)=>{let n=(0,v.forwardRef)(({className:n,...r},i)=>(0,v.createElement)(sN,{ref:i,iconNode:t,className:$M(`lucide-${eN(nN(e))}`,`lucide-${e}`,n),...r}));return n.displayName=nN(e),n},lN=cN(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),uN=cN(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),dN=cN(`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`}]]),fN=cN(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),pN=cN(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),mN=cN(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),hN=cN(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),gN=cN(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),_N=cN(`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`}]]),vN=cN(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),yN=cN(`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`}]]),bN=cN(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),xN=cN(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),SN=cN(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),CN=cN(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),wN=cN(`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`}]]),TN=cN(`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`}]]),EN=cN(`file-diff`,[[`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:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),DN=cN(`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`}]]),ON=cN(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),kN=cN(`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`}]]),AN=cN(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),jN=cN(`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`}]]),MN=cN(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),NN=cN(`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`}]]),PN=cN(`message-circle-question-mark`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),FN=cN(`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`}]]),IN=cN(`message-square-text`,[[`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:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),LN=cN(`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`}]]),RN=cN(`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`}]]),zN=cN(`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`}]]),BN=cN(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),VN=cN(`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`}]]),HN=cN(`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`}]]),UN=cN(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),WN=cN(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),GN=cN(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),KN=cN(`refresh-ccw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),qN=cN(`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`}]]),JN=cN(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),YN=cN(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),XN=cN(`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`}]]),ZN=cN(`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`}]]),QN=cN(`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`}]]),$N=cN(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),eP=cN(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),tP=cN(`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`}]]),nP=cN(`thumbs-down`,[[`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`,key:`m61m77`}],[`path`,{d:`M17 14V2`,key:`8ymqnk`}]]),rP=cN(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),iP=cN(`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`}]]),aP=cN(`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`}]]),oP=cN(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),sP=cN(`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`}]]),cP=cN(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),lP=cN(`zap-off`,[[`path`,{d:`M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317`,key:`193nxd`}],[`path`,{d:`M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773`,key:`27a7lr`}],[`path`,{d:`M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643`,key:`1e0qe9`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),uP=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},dP=(e,t)=>({classGroupId:e,validator:t}),fP=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),pP=`-`,mP=[],hP=`arbitrary..`,gP=e=>{let t=yP(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return vP(e);let n=e.split(pP);return _P(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?uP(i,t):t:i||mP}return n[e]||mP}}},_P=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=_P(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(pP):e.slice(t).join(pP),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},vP=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?hP+r:void 0})(),yP=e=>{let{theme:t,classGroups:n}=e;return bP(n,t)},bP=(e,t)=>{let n=fP();for(let r in e){let i=e[r];xP(i,n,r,t)}return n},xP=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];SP(i,t,n,r)}},SP=(e,t,n,r)=>{if(typeof e==`string`){CP(e,t,n);return}if(typeof e==`function`){wP(e,t,n,r);return}TP(e,t,n,r)},CP=(e,t,n)=>{let r=e===``?t:EP(t,e);r.classGroupId=n},wP=(e,t,n,r)=>{if(DP(e)){xP(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(dP(n,e))},TP=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];xP(o,EP(t,a),n,r)}},EP=(e,t)=>{let n=e,r=t.split(pP),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=fP(),n.nextPart.set(t,i)),n=i}return n},DP=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,OP=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},kP=`!`,AP=`:`,jP=[],MP=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),NP=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===AP){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(kP)?(c=s.slice(0,-1),l=!0):s.startsWith(kP)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return MP(t,l,c,u)};if(t){let e=t+AP,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):MP(jP,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},PP=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},FP=e=>({cache:OP(e.cacheSize),parseClassName:NP(e),sortModifiers:PP(e),...gP(e)}),IP=/\s+/,LP=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(IP),c=``;for(let e=s.length-1;e>=0;--e){let t=s[e],{isExternal:l,modifiers:u,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:p}=n(t);if(l){c=t+(c.length>0?` `+c:c);continue}let m=!!p,h=r(m?f.substring(0,p):f);if(!h){if(!m){c=t+(c.length>0?` `+c:c);continue}if(h=r(f),!h){c=t+(c.length>0?` `+c:c);continue}m=!1}let g=u.length===0?``:u.length===1?u[0]:a(u).join(`:`),_=d?g+kP:g,v=_+h;if(o.indexOf(v)>-1)continue;o.push(v);let y=i(h,m);for(let e=0;e<y.length;++e){let t=y[e];o.push(_+t)}c=t+(c.length>0?` `+c:c)}return c},RP=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=zP(n))&&(i&&(i+=` `),i+=r);return i},zP=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=zP(e[r]))&&(n&&(n+=` `),n+=t);return n},BP=(e,...t)=>{let n,r,i,a,o=o=>(n=FP(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=LP(e,n);return i(e,a),a};return a=o,(...e)=>a(RP(...e))},VP=[],HP=e=>{let t=t=>t[e]||VP;return t.isThemeGetter=!0,t},UP=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,WP=/^\((?:(\w[\w-]*):)?(.+)\)$/i,GP=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,KP=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,qP=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,JP=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,YP=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,XP=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ZP=e=>GP.test(e),QP=e=>!!e&&!Number.isNaN(Number(e)),$P=e=>!!e&&Number.isInteger(Number(e)),eF=e=>e.endsWith(`%`)&&QP(e.slice(0,-1)),tF=e=>KP.test(e),nF=()=>!0,rF=e=>qP.test(e)&&!JP.test(e),iF=()=>!1,aF=e=>YP.test(e),oF=e=>XP.test(e),sF=e=>!lF(e)&&!_F(e),cF=e=>TF(e,kF,iF),lF=e=>UP.test(e),uF=e=>TF(e,AF,rF),dF=e=>TF(e,jF,QP),fF=e=>TF(e,NF,nF),pF=e=>TF(e,MF,iF),mF=e=>TF(e,DF,iF),hF=e=>TF(e,OF,oF),gF=e=>TF(e,PF,aF),_F=e=>WP.test(e),vF=e=>EF(e,AF),yF=e=>EF(e,MF),bF=e=>EF(e,DF),xF=e=>EF(e,kF),SF=e=>EF(e,OF),CF=e=>EF(e,PF,!0),wF=e=>EF(e,NF,!0),TF=(e,t,n)=>{let r=UP.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},EF=(e,t,n=!1)=>{let r=WP.exec(e);return r?r[1]?t(r[1]):n:!1},DF=e=>e===`position`||e===`percentage`,OF=e=>e===`image`||e===`url`,kF=e=>e===`length`||e===`size`||e===`bg-size`,AF=e=>e===`length`,jF=e=>e===`number`,MF=e=>e===`family-name`,NF=e=>e===`number`||e===`weight`,PF=e=>e===`shadow`,FF=BP(()=>{let e=HP(`color`),t=HP(`font`),n=HP(`text`),r=HP(`font-weight`),i=HP(`tracking`),a=HP(`leading`),o=HP(`breakpoint`),s=HP(`container`),c=HP(`spacing`),l=HP(`radius`),u=HP(`shadow`),d=HP(`inset-shadow`),f=HP(`text-shadow`),p=HP(`drop-shadow`),m=HP(`blur`),h=HP(`perspective`),g=HP(`aspect`),_=HP(`ease`),v=HP(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),_F,lF],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],ee=()=>[`auto`,`contain`,`none`],C=()=>[_F,lF,c],w=()=>[ZP,`full`,`auto`,...C()],te=()=>[$P,`none`,`subgrid`,_F,lF],ne=()=>[`auto`,{span:[`full`,$P,_F,lF]},$P,_F,lF],T=()=>[$P,`auto`,_F,lF],re=()=>[`auto`,`min`,`max`,`fr`,_F,lF],ie=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],ae=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],oe=()=>[`auto`,...C()],se=()=>[ZP,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...C()],ce=()=>[ZP,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...C()],le=()=>[ZP,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...C()],E=()=>[e,_F,lF],D=()=>[...b(),bF,mF,{position:[_F,lF]}],ue=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],de=()=>[`auto`,`cover`,`contain`,xF,cF,{size:[_F,lF]}],fe=()=>[eF,vF,uF],pe=()=>[``,`none`,`full`,l,_F,lF],me=()=>[``,QP,vF,uF],O=()=>[`solid`,`dashed`,`dotted`,`double`],he=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],ge=()=>[QP,eF,bF,mF],_e=()=>[``,`none`,m,_F,lF],ve=()=>[`none`,QP,_F,lF],ye=()=>[`none`,QP,_F,lF],be=()=>[QP,_F,lF],xe=()=>[ZP,`full`,...C()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[tF],breakpoint:[tF],color:[nF],container:[tF],"drop-shadow":[tF],ease:[`in`,`out`,`in-out`],font:[sF],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[tF],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[tF],shadow:[tF],spacing:[`px`,QP],text:[tF],"text-shadow":[tF],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,ZP,lF,_F,g]}],container:[`container`],columns:[{columns:[QP,lF,_F,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:ee()}],"overscroll-x":[{"overscroll-x":ee()}],"overscroll-y":[{"overscroll-y":ee()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:w()}],"inset-x":[{"inset-x":w()}],"inset-y":[{"inset-y":w()}],start:[{"inset-s":w(),start:w()}],end:[{"inset-e":w(),end:w()}],"inset-bs":[{"inset-bs":w()}],"inset-be":[{"inset-be":w()}],top:[{top:w()}],right:[{right:w()}],bottom:[{bottom:w()}],left:[{left:w()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[$P,`auto`,_F,lF]}],basis:[{basis:[ZP,`full`,`auto`,s,...C()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[QP,ZP,`auto`,`initial`,`none`,lF]}],grow:[{grow:[``,QP,_F,lF]}],shrink:[{shrink:[``,QP,_F,lF]}],order:[{order:[$P,`first`,`last`,`none`,_F,lF]}],"grid-cols":[{"grid-cols":te()}],"col-start-end":[{col:ne()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":te()}],"row-start-end":[{row:ne()}],"row-start":[{"row-start":T()}],"row-end":[{"row-end":T()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":re()}],"auto-rows":[{"auto-rows":re()}],gap:[{gap:C()}],"gap-x":[{"gap-x":C()}],"gap-y":[{"gap-y":C()}],"justify-content":[{justify:[...ie(),`normal`]}],"justify-items":[{"justify-items":[...ae(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...ae()]}],"align-content":[{content:[`normal`,...ie()]}],"align-items":[{items:[...ae(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...ae(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":ie()}],"place-items":[{"place-items":[...ae(),`baseline`]}],"place-self":[{"place-self":[`auto`,...ae()]}],p:[{p:C()}],px:[{px:C()}],py:[{py:C()}],ps:[{ps:C()}],pe:[{pe:C()}],pbs:[{pbs:C()}],pbe:[{pbe:C()}],pt:[{pt:C()}],pr:[{pr:C()}],pb:[{pb:C()}],pl:[{pl:C()}],m:[{m:oe()}],mx:[{mx:oe()}],my:[{my:oe()}],ms:[{ms:oe()}],me:[{me:oe()}],mbs:[{mbs:oe()}],mbe:[{mbe:oe()}],mt:[{mt:oe()}],mr:[{mr:oe()}],mb:[{mb:oe()}],ml:[{ml:oe()}],"space-x":[{"space-x":C()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":C()}],"space-y-reverse":[`space-y-reverse`],size:[{size:se()}],"inline-size":[{inline:[`auto`,...ce()]}],"min-inline-size":[{"min-inline":[`auto`,...ce()]}],"max-inline-size":[{"max-inline":[`none`,...ce()]}],"block-size":[{block:[`auto`,...le()]}],"min-block-size":[{"min-block":[`auto`,...le()]}],"max-block-size":[{"max-block":[`none`,...le()]}],w:[{w:[s,`screen`,...se()]}],"min-w":[{"min-w":[s,`screen`,`none`,...se()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...se()]}],h:[{h:[`screen`,`lh`,...se()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...se()]}],"max-h":[{"max-h":[`screen`,`lh`,...se()]}],"font-size":[{text:[`base`,n,vF,uF]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,wF,fF]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,eF,lF]}],"font-family":[{font:[yF,pF,t]}],"font-features":[{"font-features":[lF]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,_F,lF]}],"line-clamp":[{"line-clamp":[QP,`none`,_F,dF]}],leading:[{leading:[a,...C()]}],"list-image":[{"list-image":[`none`,_F,lF]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,_F,lF]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:E()}],"text-color":[{text:E()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...O(),`wavy`]}],"text-decoration-thickness":[{decoration:[QP,`from-font`,`auto`,_F,uF]}],"text-decoration-color":[{decoration:E()}],"underline-offset":[{"underline-offset":[QP,`auto`,_F,lF]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:C()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,_F,lF]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,_F,lF]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:D()}],"bg-repeat":[{bg:ue()}],"bg-size":[{bg:de()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},$P,_F,lF],radial:[``,_F,lF],conic:[$P,_F,lF]},SF,hF]}],"bg-color":[{bg:E()}],"gradient-from-pos":[{from:fe()}],"gradient-via-pos":[{via:fe()}],"gradient-to-pos":[{to:fe()}],"gradient-from":[{from:E()}],"gradient-via":[{via:E()}],"gradient-to":[{to:E()}],rounded:[{rounded:pe()}],"rounded-s":[{"rounded-s":pe()}],"rounded-e":[{"rounded-e":pe()}],"rounded-t":[{"rounded-t":pe()}],"rounded-r":[{"rounded-r":pe()}],"rounded-b":[{"rounded-b":pe()}],"rounded-l":[{"rounded-l":pe()}],"rounded-ss":[{"rounded-ss":pe()}],"rounded-se":[{"rounded-se":pe()}],"rounded-ee":[{"rounded-ee":pe()}],"rounded-es":[{"rounded-es":pe()}],"rounded-tl":[{"rounded-tl":pe()}],"rounded-tr":[{"rounded-tr":pe()}],"rounded-br":[{"rounded-br":pe()}],"rounded-bl":[{"rounded-bl":pe()}],"border-w":[{border:me()}],"border-w-x":[{"border-x":me()}],"border-w-y":[{"border-y":me()}],"border-w-s":[{"border-s":me()}],"border-w-e":[{"border-e":me()}],"border-w-bs":[{"border-bs":me()}],"border-w-be":[{"border-be":me()}],"border-w-t":[{"border-t":me()}],"border-w-r":[{"border-r":me()}],"border-w-b":[{"border-b":me()}],"border-w-l":[{"border-l":me()}],"divide-x":[{"divide-x":me()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":me()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...O(),`hidden`,`none`]}],"divide-style":[{divide:[...O(),`hidden`,`none`]}],"border-color":[{border:E()}],"border-color-x":[{"border-x":E()}],"border-color-y":[{"border-y":E()}],"border-color-s":[{"border-s":E()}],"border-color-e":[{"border-e":E()}],"border-color-bs":[{"border-bs":E()}],"border-color-be":[{"border-be":E()}],"border-color-t":[{"border-t":E()}],"border-color-r":[{"border-r":E()}],"border-color-b":[{"border-b":E()}],"border-color-l":[{"border-l":E()}],"divide-color":[{divide:E()}],"outline-style":[{outline:[...O(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[QP,_F,lF]}],"outline-w":[{outline:[``,QP,vF,uF]}],"outline-color":[{outline:E()}],shadow:[{shadow:[``,`none`,u,CF,gF]}],"shadow-color":[{shadow:E()}],"inset-shadow":[{"inset-shadow":[`none`,d,CF,gF]}],"inset-shadow-color":[{"inset-shadow":E()}],"ring-w":[{ring:me()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:E()}],"ring-offset-w":[{"ring-offset":[QP,uF]}],"ring-offset-color":[{"ring-offset":E()}],"inset-ring-w":[{"inset-ring":me()}],"inset-ring-color":[{"inset-ring":E()}],"text-shadow":[{"text-shadow":[`none`,f,CF,gF]}],"text-shadow-color":[{"text-shadow":E()}],opacity:[{opacity:[QP,_F,lF]}],"mix-blend":[{"mix-blend":[...he(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":he()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[QP]}],"mask-image-linear-from-pos":[{"mask-linear-from":ge()}],"mask-image-linear-to-pos":[{"mask-linear-to":ge()}],"mask-image-linear-from-color":[{"mask-linear-from":E()}],"mask-image-linear-to-color":[{"mask-linear-to":E()}],"mask-image-t-from-pos":[{"mask-t-from":ge()}],"mask-image-t-to-pos":[{"mask-t-to":ge()}],"mask-image-t-from-color":[{"mask-t-from":E()}],"mask-image-t-to-color":[{"mask-t-to":E()}],"mask-image-r-from-pos":[{"mask-r-from":ge()}],"mask-image-r-to-pos":[{"mask-r-to":ge()}],"mask-image-r-from-color":[{"mask-r-from":E()}],"mask-image-r-to-color":[{"mask-r-to":E()}],"mask-image-b-from-pos":[{"mask-b-from":ge()}],"mask-image-b-to-pos":[{"mask-b-to":ge()}],"mask-image-b-from-color":[{"mask-b-from":E()}],"mask-image-b-to-color":[{"mask-b-to":E()}],"mask-image-l-from-pos":[{"mask-l-from":ge()}],"mask-image-l-to-pos":[{"mask-l-to":ge()}],"mask-image-l-from-color":[{"mask-l-from":E()}],"mask-image-l-to-color":[{"mask-l-to":E()}],"mask-image-x-from-pos":[{"mask-x-from":ge()}],"mask-image-x-to-pos":[{"mask-x-to":ge()}],"mask-image-x-from-color":[{"mask-x-from":E()}],"mask-image-x-to-color":[{"mask-x-to":E()}],"mask-image-y-from-pos":[{"mask-y-from":ge()}],"mask-image-y-to-pos":[{"mask-y-to":ge()}],"mask-image-y-from-color":[{"mask-y-from":E()}],"mask-image-y-to-color":[{"mask-y-to":E()}],"mask-image-radial":[{"mask-radial":[_F,lF]}],"mask-image-radial-from-pos":[{"mask-radial-from":ge()}],"mask-image-radial-to-pos":[{"mask-radial-to":ge()}],"mask-image-radial-from-color":[{"mask-radial-from":E()}],"mask-image-radial-to-color":[{"mask-radial-to":E()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[QP]}],"mask-image-conic-from-pos":[{"mask-conic-from":ge()}],"mask-image-conic-to-pos":[{"mask-conic-to":ge()}],"mask-image-conic-from-color":[{"mask-conic-from":E()}],"mask-image-conic-to-color":[{"mask-conic-to":E()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:D()}],"mask-repeat":[{mask:ue()}],"mask-size":[{mask:de()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,_F,lF]}],filter:[{filter:[``,`none`,_F,lF]}],blur:[{blur:_e()}],brightness:[{brightness:[QP,_F,lF]}],contrast:[{contrast:[QP,_F,lF]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,CF,gF]}],"drop-shadow-color":[{"drop-shadow":E()}],grayscale:[{grayscale:[``,QP,_F,lF]}],"hue-rotate":[{"hue-rotate":[QP,_F,lF]}],invert:[{invert:[``,QP,_F,lF]}],saturate:[{saturate:[QP,_F,lF]}],sepia:[{sepia:[``,QP,_F,lF]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,_F,lF]}],"backdrop-blur":[{"backdrop-blur":_e()}],"backdrop-brightness":[{"backdrop-brightness":[QP,_F,lF]}],"backdrop-contrast":[{"backdrop-contrast":[QP,_F,lF]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,QP,_F,lF]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[QP,_F,lF]}],"backdrop-invert":[{"backdrop-invert":[``,QP,_F,lF]}],"backdrop-opacity":[{"backdrop-opacity":[QP,_F,lF]}],"backdrop-saturate":[{"backdrop-saturate":[QP,_F,lF]}],"backdrop-sepia":[{"backdrop-sepia":[``,QP,_F,lF]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":C()}],"border-spacing-x":[{"border-spacing-x":C()}],"border-spacing-y":[{"border-spacing-y":C()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,_F,lF]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[QP,`initial`,_F,lF]}],ease:[{ease:[`linear`,`initial`,_,_F,lF]}],delay:[{delay:[QP,_F,lF]}],animate:[{animate:[`none`,v,_F,lF]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,_F,lF]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:ve()}],"rotate-x":[{"rotate-x":ve()}],"rotate-y":[{"rotate-y":ve()}],"rotate-z":[{"rotate-z":ve()}],scale:[{scale:ye()}],"scale-x":[{"scale-x":ye()}],"scale-y":[{"scale-y":ye()}],"scale-z":[{"scale-z":ye()}],"scale-3d":[`scale-3d`],skew:[{skew:be()}],"skew-x":[{"skew-x":be()}],"skew-y":[{"skew-y":be()}],transform:[{transform:[_F,lF,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:xe()}],"translate-x":[{"translate-x":xe()}],"translate-y":[{"translate-y":xe()}],"translate-z":[{"translate-z":xe()}],"translate-none":[`translate-none`],accent:[{accent:E()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:E()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,_F,lF]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mbs":[{"scroll-mbs":C()}],"scroll-mbe":[{"scroll-mbe":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pbs":[{"scroll-pbs":C()}],"scroll-pbe":[{"scroll-pbe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,_F,lF]}],fill:[{fill:[`none`,...E()]}],"stroke-w":[{stroke:[QP,vF,uF,dF]}],stroke:[{stroke:[`none`,...E()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function K(...e){return FF(PO(e))}var IF=new Set([`in_progress`,`running`,`resuming`,`starting`,`streaming`,`queued`,`pending`,`accepted`]),LF=new Set([`failed`,`error`,`resume_failed`,`interrupted`,`cancelled`,`canceled`,`aborted`,`expired`]),RF=300*1e3;function zF(e){let t=e?.UpdatedAt??e?.updated_at;if(typeof t==`string`){let e=Date.parse(t);return Number.isNaN(e)?0:e}return typeof t==`number`&&Number.isFinite(t)?t>1e11?t:t*1e3:0}function BF(e){return String(e||``).trim().toLowerCase()}function VF(e){if(!e)return``;let t=typeof e==`number`?new Date(e>1e11?e:e*1e3):new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(`zh-CN`,{timeZone:`Asia/Shanghai`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1})}function HF(e){return[e?.Title,e?.Summary,e?.FirstPrompt,e?.LastPrompt,e?.SessionId,e?.Model?.display_name,e?.Model?.id].map(BF).join(` `)}function UF(e,t={}){if(!IF.has(BF(e?.ActiveRunStatus)))return!1;let n=zF(e);if(!n)return!0;let r=Number.isFinite(Number(t.now))?Number(t.now):Date.now(),i=Number.isFinite(Number(t.activeStaleAfterMs))?Number(t.activeStaleAfterMs):RF;return r-n<=i}function WF(e=[],t=``,n={}){let r=BF(t),i=new Set(Array.isArray(n.pinnedSessionIds)?n.pinnedSessionIds:[]);return(Array.isArray(e)?e:[]).filter(e=>e?.SessionId).filter(e=>!r||HF(e).includes(r)).slice().sort((e,t)=>{let r=+!!i.has(e.SessionId),a=+!!i.has(t.SessionId);if(r!==a)return a-r;let o=+!!UF(e,n),s=+!!UF(t,n);return o===s?zF(t)-zF(e):s-o})}function GF(e,t={}){let n=UF(e,t),r=LF.has(BF(e?.ActiveRunStatus));return{running:n,failed:r,label:n||r?``:VF(e?.UpdatedAt??e?.updated_at)}}function KF({sessions:e,currentSessionId:t,onCreateNewSession:n,onSelectSession:r,onDeleteSession:i,onTogglePinSession:a,onLoadMoreSessions:o,sessionTitle:s,pinnedSessionIds:c=[],hasMoreSessions:l=!1,isLoadingSessions:u=!1,className:d}){let[f,p]=(0,v.useState)(``),m=(0,v.useMemo)(()=>WF(e,f,{pinnedSessionIds:c}),[e,c,f]),h=(0,v.useMemo)(()=>new Set(c),[c]);return(0,O.jsxs)(`div`,{className:K(`flex h-full min-h-0 flex-col bg-sidebar`,d),children:[(0,O.jsxs)(`div`,{className:`flex flex-shrink-0 flex-col gap-2 border-b border-black/[0.06] px-3 py-3 dark:border-white/[0.08]`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:n,className:`flex h-[34px] w-full items-center justify-between rounded-[10px] px-2.5 text-sm font-medium text-sidebar-text-secondary transition-colors hover:bg-sidebar-hover hover:text-sidebar-text`,children:[(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(FN,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{children:`新对话`})]}),(0,O.jsx)(`span`,{className:`rounded border border-black/[0.08] px-1.5 py-0.5 text-[11px] text-sidebar-text-muted dark:border-white/[0.1]`,children:`⌘ N`})]}),(0,O.jsxs)(`label`,{className:`flex h-9 items-center gap-2 rounded-[10px] border border-black/[0.06] bg-background px-2.5 text-xs text-sidebar-text-muted focus-within:border-primary/40 dark:border-white/[0.08]`,children:[(0,O.jsx)(YN,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,O.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),className:`min-w-0 flex-1 bg-transparent text-sm text-sidebar-text outline-none placeholder:text-sidebar-text-muted`,placeholder:`搜索会话、模型或摘要`})]})]}),(0,O.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-4 pt-2 custom-scrollbar`,onScroll:e=>{if(!o||u||!l||f.trim())return;let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<200&&o()},children:[(0,O.jsxs)(`div`,{className:`px-2.5 py-2 text-xs font-medium text-sidebar-text-muted opacity-75`,children:[`历史记录`,f.trim()?` · ${m.length}`:``]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[m.length>0?m.map(e=>{let n=GF(e),o=h.has(e.SessionId),c=t===e.SessionId;return(0,O.jsxs)(`div`,{className:K(`group relative flex h-[30px] items-center gap-1 rounded-[10px] border-l-2 border-transparent px-2 text-sm leading-5 transition-colors`,c?`border-l-2 border-primary bg-primary/10 font-medium text-sidebar-text`:n.running?`cursor-pointer bg-primary/[0.035] text-sidebar-text`:`cursor-pointer text-sidebar-text-secondary hover:bg-sidebar-hover hover:text-sidebar-text`),children:[(0,O.jsxs)(`button`,{type:`button`,"aria-current":c?`page`:void 0,className:`flex min-w-0 flex-1 items-center gap-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-primary/60`,onClick:()=>r(e.SessionId),children:[(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:s(e)}),n.running?(0,O.jsx)(`span`,{"aria-label":`运行中`,className:`h-1.5 w-1.5 flex-shrink-0 animate-spin rounded-full border border-primary border-t-transparent`}):n.failed?(0,O.jsx)(`span`,{"aria-label":`运行失败`,title:`运行失败`,className:`h-1.5 w-1.5 flex-shrink-0 rounded-full bg-rose-500/75`}):n.label?(0,O.jsx)(`span`,{className:`flex-shrink-0 text-[11px] leading-none text-sidebar-text-muted group-hover:hidden`,children:n.label}):null]}),(0,O.jsxs)(`div`,{className:`absolute right-1 top-1/2 flex -translate-y-1/2 items-center justify-end gap-0.5 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:t=>a(e.SessionId,t),className:K(`flex h-6 w-6 items-center justify-center rounded-md text-sidebar-text-muted hover:bg-sidebar-active hover:text-sidebar-text`,o&&`text-primary opacity-100`),title:o?`取消置顶`:`置顶会话`,"aria-label":o?`取消置顶会话`:`置顶会话`,children:o?(0,O.jsx)(UN,{className:`h-3.5 w-3.5`}):(0,O.jsx)(WN,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:t=>i(e.SessionId,t),className:`flex h-6 w-6 items-center justify-center rounded-md text-sidebar-text-muted hover:bg-sidebar-active hover:text-rose-500`,title:`删除会话`,children:(0,O.jsx)(iP,{className:`h-3.5 w-3.5`})})]})]},e.SessionId)}):(0,O.jsx)(`div`,{className:`rounded-xl border border-dashed border-black/[0.08] px-3 py-8 text-center text-xs text-sidebar-text-muted dark:border-white/[0.1]`,children:`没有匹配的会话`}),u?(0,O.jsxs)(`div`,{className:`flex items-center justify-center gap-2 px-3 py-3 text-xs text-sidebar-text-muted`,children:[(0,O.jsx)(MN,{className:`h-3.5 w-3.5 animate-spin`}),(0,O.jsx)(`span`,{children:`加载中`})]}):null]})]}),(0,O.jsxs)(`div`,{className:`border-t border-black/[0.06] px-4 py-3 text-center dark:border-white/[0.08]`,children:[(0,O.jsx)(`div`,{className:`text-[10px] font-medium tracking-[0.14em] text-sidebar-text-muted`,children:`POWERED BY`}),(0,O.jsx)(`div`,{className:`mt-1 bg-gradient-to-r from-blue-600 to-indigo-500 bg-clip-text text-xs font-bold text-transparent dark:from-blue-400 dark:to-indigo-300`,children:`Ksyun AgentEngine`}),(0,O.jsx)(`div`,{className:`mx-auto mt-2 max-w-[13rem] text-[10px] leading-4 text-sidebar-text-muted`,children:`Agent 可能产生不准确的信息,请独立验证。`})]})]})}typeof window<`u`&&window.document&&window.document.createElement;function qF(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function JF(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function YF(...e){return t=>{let n=!1,r=e.map(e=>{let r=JF(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():JF(e[t],null)}}}}function XF(...e){return v.useCallback(YF(...e),e)}function ZF(e,t){let n=v.createContext(t),r=e=>{let{children:t,...r}=e,i=v.useMemo(()=>r,Object.values(r));return(0,O.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=v.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function QF(e,t=[]){let n=[];function r(t,r){let i=v.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=v.useMemo(()=>o,Object.values(o));return(0,O.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=v.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>v.createContext(e));return function(n){let r=n?.[e]||t;return v.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,$F(i,...t)]}function $F(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var eI=globalThis?.document?v.useLayoutEffect:()=>{},tI=v.useId||(()=>void 0),nI=0;function rI(e){let[t,n]=v.useState(tI());return eI(()=>{e||n(e=>e??String(nI++))},[e]),e||(t?`radix-${t}`:``)}var iI=v.useInsertionEffect||eI;function aI({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=oI({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=v.useRef(e!==void 0);v.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,v.useCallback(t=>{if(s){let n=sI(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function oI({defaultProp:e,onChange:t}){let[n,r]=v.useState(e),i=v.useRef(n),a=v.useRef(t);return iI(()=>{a.current=t},[t]),v.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function sI(e){return typeof e==`function`}function cI(e){let t=lI(e),n=v.forwardRef((e,n)=>{let{children:r,...i}=e,a=v.Children.toArray(r),o=a.find(dI);if(o){let e=o.props.children,r=a.map(t=>t===o?v.Children.count(e)>1?v.Children.only(null):v.isValidElement(e)?e.props.children:null:t);return(0,O.jsx)(t,{...i,ref:n,children:v.isValidElement(e)?v.cloneElement(e,void 0,r):null})}return(0,O.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function lI(e){let t=v.forwardRef((e,t)=>{let{children:n,...r}=e;if(v.isValidElement(n)){let e=pI(n),i=fI(r,n.props);return n.type!==v.Fragment&&(i.ref=t?YF(t,e):e),v.cloneElement(n,i)}return v.Children.count(n)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var uI=Symbol(`radix.slottable`);function dI(e){return v.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===uI}function fI(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}}function pI(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)}var mI=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=cI(`Primitive.${t}`),r=v.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,O.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function hI(e,t){e&&Cl.flushSync(()=>e.dispatchEvent(t))}function gI(e){let t=v.useRef(e);return v.useEffect(()=>{t.current=e}),v.useMemo(()=>(...e)=>t.current?.(...e),[])}function _I(e,t=globalThis?.document){let n=gI(e);v.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var vI=`DismissableLayer`,yI=`dismissableLayer.update`,bI=`dismissableLayer.pointerDownOutside`,xI=`dismissableLayer.focusOutside`,SI,CI=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),wI=v.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=v.useContext(CI),[u,d]=v.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=v.useState({}),m=XF(t,e=>d(e)),h=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),_=h.indexOf(g),y=u?h.indexOf(u):-1,b=l.layersWithOutsidePointerEventsDisabled.size>0,x=y>=_,S=EI(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!x||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),ee=DI(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return _I(e=>{y===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),v.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(SI=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),OI(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=SI)}},[u,f,n,l]),v.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),OI())},[u,l]),v.useEffect(()=>{let e=()=>p({});return document.addEventListener(yI,e),()=>document.removeEventListener(yI,e)},[]),(0,O.jsx)(mI.div,{...c,ref:m,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:qF(e.onFocusCapture,ee.onFocusCapture),onBlurCapture:qF(e.onBlurCapture,ee.onBlurCapture),onPointerDownCapture:qF(e.onPointerDownCapture,S.onPointerDownCapture)})});wI.displayName=vI;var vne=`DismissableLayerBranch`,TI=v.forwardRef((e,t)=>{let n=v.useContext(CI),r=v.useRef(null),i=XF(t,r);return v.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,O.jsx)(mI.div,{...e,ref:i})});TI.displayName=vne;function EI(e,t=globalThis?.document){let n=gI(e),r=v.useRef(!1),i=v.useRef(()=>{});return v.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){kI(bI,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function DI(e,t=globalThis?.document){let n=gI(e),r=v.useRef(!1);return v.useEffect(()=>{let e=e=>{e.target&&!r.current&&kI(xI,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function OI(){let e=new CustomEvent(yI);document.dispatchEvent(e)}function kI(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?hI(i,a):i.dispatchEvent(a)}var AI=`focusScope.autoFocusOnMount`,jI=`focusScope.autoFocusOnUnmount`,MI={bubbles:!1,cancelable:!0},NI=`FocusScope`,PI=v.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=v.useState(null),l=gI(i),u=gI(a),d=v.useRef(null),f=XF(t,e=>c(e)),p=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:VI(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||VI(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&VI(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),v.useEffect(()=>{if(s){HI.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(AI,MI);s.addEventListener(AI,l),s.dispatchEvent(t),t.defaultPrevented||(FI(GI(LI(s)),{select:!0}),document.activeElement===e&&VI(s))}return()=>{s.removeEventListener(AI,l),setTimeout(()=>{let t=new CustomEvent(jI,MI);s.addEventListener(jI,u),s.dispatchEvent(t),t.defaultPrevented||VI(e??document.body,{select:!0}),s.removeEventListener(jI,u),HI.remove(p)},0)}}},[s,l,u,p]);let m=v.useCallback(e=>{if(!n&&!r||p.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]=II(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&VI(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&VI(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,O.jsx)(mI.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});PI.displayName=NI;function FI(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(VI(r,{select:t}),document.activeElement!==n)return}function II(e){let t=LI(e);return[RI(t,e),RI(t.reverse(),e)]}function LI(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode: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}});for(;n.nextNode();)t.push(n.currentNode);return t}function RI(e,t){for(let n of e)if(!zI(n,{upTo:t}))return n}function zI(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}function BI(e){return e instanceof HTMLInputElement&&`select`in e}function VI(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&BI(e)&&t&&e.select()}}var HI=UI();function UI(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=WI(e,t),e.unshift(t)},remove(t){e=WI(e,t),e[0]?.resume()}}}function WI(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function GI(e){return e.filter(e=>e.tagName!==`A`)}var KI=`Portal`,qI=v.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=v.useState(!1);eI(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Cl.createPortal((0,O.jsx)(mI.div,{...r,ref:t}),o):null});qI.displayName=KI;function JI(e,t){return v.useReducer((e,n)=>t[e][n]??e,e)}var YI=e=>{let{present:t,children:n}=e,r=XI(t),i=typeof n==`function`?n({present:r.isPresent}):v.Children.only(n),a=XF(r.ref,QI(i));return typeof n==`function`||r.isPresent?v.cloneElement(i,{ref:a}):null};YI.displayName=`Presence`;function XI(e){let[t,n]=v.useState(),r=v.useRef(null),i=v.useRef(e),a=v.useRef(`none`),[o,s]=JI(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return v.useEffect(()=>{let e=ZI(r.current);a.current=o===`mounted`?e:`none`},[o]),eI(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=ZI(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),eI(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=ZI(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=ZI(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:v.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function ZI(e){return e?.animationName||`none`}function QI(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)}var $I=0;function eL(){v.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??tL()),document.body.insertAdjacentElement(`beforeend`,e[1]??tL()),$I++,()=>{$I===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),$I--}},[])}function tL(){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}var nL=`right-scroll-bar-position`,rL=`width-before-scroll-bar`,iL=`with-scroll-bars-hidden`,aL=`--removed-body-scroll-bar-size`;function oL(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function sL(e,t){var n=(0,v.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 cL=typeof window<`u`?v.useLayoutEffect:v.useEffect,lL=new WeakMap;function uL(e,t){var n=sL(t||null,function(t){return e.forEach(function(e){return oL(e,t)})});return cL(function(){var t=lL.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||oL(e,null)}),i.forEach(function(e){r.has(e)||oL(e,a)})}lL.set(n,e)},[e]),n}function dL(e){return e}function fL(e,t){t===void 0&&(t=dL);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 pL(e){e===void 0&&(e={});var t=fL(null);return t.options=zp({async:!0,ssr:!1},e),t}var mL=function(e){var t=e.sideCar,n=Bp(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 v.createElement(r,zp({},n))};mL.isSideCarExport=!0;function hL(e,t){return e.useMedium(t),mL}var gL=pL(),_L=function(){},vL=v.forwardRef(function(e,t){var n=v.useRef(null),r=v.useState({onScrollCapture:_L,onWheelCapture:_L,onTouchMoveCapture:_L}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,y=_===void 0?`div`:_,b=e.gapMode,x=Bp(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=f,ee=uL([n,t]),C=zp(zp({},x),i);return v.createElement(v.Fragment,null,u&&v.createElement(S,{sideCar:gL,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:b}),o?v.cloneElement(v.Children.only(s),zp(zp({},C),{ref:ee})):v.createElement(y,zp({},C,{className:c,ref:ee}),s))});vL.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},vL.classNames={fullWidth:rL,zeroRight:nL};var yL,bL=function(){if(yL)return yL;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function xL(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=bL();return t&&e.setAttribute(`nonce`,t),e}function SL(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function CL(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var wL=function(){var e=0,t=null;return{add:function(n){e==0&&(t=xL())&&(SL(t,n),CL(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},TL=function(){var e=wL();return function(t,n){v.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},EL=function(){var e=TL();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},DL={left:0,top:0,right:0,gap:0},OL=function(e){return parseInt(e||``,10)||0},kL=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[OL(n),OL(r),OL(i)]},AL=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return DL;var t=kL(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])}},jL=EL(),ML=`data-scroll-locked`,NL=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
97
|
+
.${iL} {
|
|
98
|
+
overflow: hidden ${r};
|
|
99
|
+
padding-right: ${s}px ${r};
|
|
100
|
+
}
|
|
101
|
+
body[${ML}] {
|
|
102
|
+
overflow: hidden ${r};
|
|
103
|
+
overscroll-behavior: contain;
|
|
104
|
+
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
105
|
+
padding-left: ${i}px;
|
|
106
|
+
padding-top: ${a}px;
|
|
107
|
+
padding-right: ${o}px;
|
|
108
|
+
margin-left:0;
|
|
109
|
+
margin-top:0;
|
|
110
|
+
margin-right: ${s}px ${r};
|
|
111
|
+
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.${nL} {
|
|
115
|
+
right: ${s}px ${r};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.${rL} {
|
|
119
|
+
margin-right: ${s}px ${r};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.${nL} .${nL} {
|
|
123
|
+
right: 0 ${r};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.${rL} .${rL} {
|
|
127
|
+
margin-right: 0 ${r};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
body[${ML}] {
|
|
131
|
+
${aL}: ${s}px;
|
|
132
|
+
}
|
|
133
|
+
`},PL=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},FL=function(){v.useEffect(function(){return document.body.setAttribute(ML,(PL()+1).toString()),function(){var e=PL()-1;e<=0?document.body.removeAttribute(ML):document.body.setAttribute(ML,e.toString())}},[])},IL=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;FL();var a=v.useMemo(function(){return AL(i)},[i]);return v.createElement(jL,{styles:NL(a,!t,i,n?``:`!important`)})},LL=!1;if(typeof window<`u`)try{var RL=Object.defineProperty({},"passive",{get:function(){return LL=!0,!0}});window.addEventListener(`test`,RL,RL),window.removeEventListener(`test`,RL,RL)}catch{LL=!1}var zL=LL?{passive:!1}:!1,BL=function(e){return e.tagName===`TEXTAREA`},VL=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!BL(e)&&n[t]===`visible`)},HL=function(e){return VL(e,`overflowY`)},UL=function(e){return VL(e,`overflowX`)},WL=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),qL(e,r)){var i=JL(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},GL=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},KL=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},qL=function(e,t){return e===`v`?HL(t):UL(t)},JL=function(e,t){return e===`v`?GL(t):KL(t)},YL=function(e,t){return e===`h`&&t===`rtl`?-1:1},XL=function(e,t,n,r,i){var a=YL(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=JL(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&qL(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},ZL=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},QL=function(e){return[e.deltaX,e.deltaY]},$L=function(e){return e&&`current`in e?e.current:e},eR=function(e,t){return e[0]===t[0]&&e[1]===t[1]},tR=function(e){return`
|
|
134
|
+
.block-interactivity-${e} {pointer-events: none;}
|
|
135
|
+
.allow-interactivity-${e} {pointer-events: all;}
|
|
136
|
+
`},nR=0,rR=[];function iR(e){var t=v.useRef([]),n=v.useRef([0,0]),r=v.useRef(),i=v.useState(nR++)[0],a=v.useState(EL)[0],o=v.useRef(e);v.useEffect(function(){o.current=e},[e]),v.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Gp([e.lockRef.current],(e.shards||[]).map($L),!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 s=v.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=ZL(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=WL(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=WL(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 XL(h,t,e,h===`h`?s:c,!0)},[]),c=v.useCallback(function(e){var n=e;if(!(!rR.length||rR[rR.length-1]!==a)){var r=`deltaY`in n?QL(n):ZL(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&eR(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map($L).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=v.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:aR(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=v.useCallback(function(e){n.current=ZL(e),r.current=void 0},[]),d=v.useCallback(function(t){l(t.type,QL(t),t.target,s(t,e.lockRef.current))},[]),f=v.useCallback(function(t){l(t.type,ZL(t),t.target,s(t,e.lockRef.current))},[]);v.useEffect(function(){return rR.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,zL),document.addEventListener(`touchmove`,c,zL),document.addEventListener(`touchstart`,u,zL),function(){rR=rR.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,zL),document.removeEventListener(`touchmove`,c,zL),document.removeEventListener(`touchstart`,u,zL)}},[]);var p=e.removeScrollBar,m=e.inert;return v.createElement(v.Fragment,null,m?v.createElement(a,{styles:tR(i)}):null,p?v.createElement(IL,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function aR(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var oR=hL(gL,iR),sR=v.forwardRef(function(e,t){return v.createElement(vL,zp({},e,{ref:t,sideCar:oR}))});sR.classNames=vL.classNames;var cR=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},lR=new WeakMap,uR=new WeakMap,dR={},fR=0,pR=function(e){return e&&(e.host||pR(e.parentNode))},mR=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=pR(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})},hR=function(e,t,n,r){var i=mR(t,Array.isArray(e)?e:[e]);dR[n]||(dR[n]=new WeakMap);var a=dR[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=(lR.get(e)||0)+1,l=(a.get(e)||0)+1;lR.set(e,c),a.set(e,l),o.push(e),c===1&&i&&uR.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(),fR++,function(){o.forEach(function(e){var t=lR.get(e)-1,i=a.get(e)-1;lR.set(e,t),a.set(e,i),t||(uR.has(e)||e.removeAttribute(r),uR.delete(e)),i||e.removeAttribute(n)}),fR--,fR||(lR=new WeakMap,lR=new WeakMap,uR=new WeakMap,dR={})}},yne=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||cR(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),hR(r,i,n,`aria-hidden`)):function(){return null}};function bne(e){let t=xne(e),n=v.forwardRef((e,n)=>{let{children:r,...i}=e,a=v.Children.toArray(r),o=a.find(Cne);if(o){let e=o.props.children,r=a.map(t=>t===o?v.Children.count(e)>1?v.Children.only(null):v.isValidElement(e)?e.props.children:null:t);return(0,O.jsx)(t,{...i,ref:n,children:v.isValidElement(e)?v.cloneElement(e,void 0,r):null})}return(0,O.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function xne(e){let t=v.forwardRef((e,t)=>{let{children:n,...r}=e;if(v.isValidElement(n)){let e=Tne(n),i=wne(r,n.props);return n.type!==v.Fragment&&(i.ref=t?YF(t,e):e),v.cloneElement(n,i)}return v.Children.count(n)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Sne=Symbol(`radix.slottable`);function Cne(e){return v.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Sne}function wne(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}}function Tne(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)}var gR=`Dialog`,[_R,Ene]=QF(gR),[Dne,vR]=_R(gR),yR=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=v.useRef(null),c=v.useRef(null),[l,u]=aI({prop:r,defaultProp:i??!1,onChange:a,caller:gR});return(0,O.jsx)(Dne,{scope:t,triggerRef:s,contentRef:c,contentId:rI(),titleId:rI(),descriptionId:rI(),open:l,onOpenChange:u,onOpenToggle:v.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};yR.displayName=gR;var bR=`DialogTrigger`,One=v.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=vR(bR,n),a=XF(t,i.triggerRef);return(0,O.jsx)(mI.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":FR(i.open),...r,ref:a,onClick:qF(e.onClick,i.onOpenToggle)})});One.displayName=bR;var xR=`DialogPortal`,[kne,SR]=_R(xR,{forceMount:void 0}),CR=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=vR(xR,t);return(0,O.jsx)(kne,{scope:t,forceMount:n,children:v.Children.map(r,e=>(0,O.jsx)(YI,{present:n||a.open,children:(0,O.jsx)(qI,{asChild:!0,container:i,children:e})}))})};CR.displayName=xR;var wR=`DialogOverlay`,TR=v.forwardRef((e,t)=>{let n=SR(wR,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=vR(wR,e.__scopeDialog);return a.modal?(0,O.jsx)(YI,{present:r||a.open,children:(0,O.jsx)(jne,{...i,ref:t})}):null});TR.displayName=wR;var Ane=bne(`DialogOverlay.RemoveScroll`),jne=v.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=vR(wR,n);return(0,O.jsx)(sR,{as:Ane,allowPinchZoom:!0,shards:[i.contentRef],children:(0,O.jsx)(mI.div,{"data-state":FR(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),ER=`DialogContent`,DR=v.forwardRef((e,t)=>{let n=SR(ER,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=vR(ER,e.__scopeDialog);return(0,O.jsx)(YI,{present:r||a.open,children:a.modal?(0,O.jsx)(Mne,{...i,ref:t}):(0,O.jsx)(Nne,{...i,ref:t})})});DR.displayName=ER;var Mne=v.forwardRef((e,t)=>{let n=vR(ER,e.__scopeDialog),r=v.useRef(null),i=XF(t,n.contentRef,r);return v.useEffect(()=>{let e=r.current;if(e)return yne(e)},[]),(0,O.jsx)(OR,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:qF(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:qF(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:qF(e.onFocusOutside,e=>e.preventDefault())})}),Nne=v.forwardRef((e,t)=>{let n=vR(ER,e.__scopeDialog),r=v.useRef(!1),i=v.useRef(!1);return(0,O.jsx)(OR,{...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()}})}),OR=v.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=vR(ER,n),c=v.useRef(null),l=XF(t,c);return eL(),(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(PI,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,O.jsx)(wI,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":FR(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(Fne,{titleId:s.titleId}),(0,O.jsx)(Lne,{contentRef:c,descriptionId:s.descriptionId})]})]})}),kR=`DialogTitle`,AR=v.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=vR(kR,n);return(0,O.jsx)(mI.h2,{id:i.titleId,...r,ref:t})});AR.displayName=kR;var jR=`DialogDescription`,MR=v.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=vR(jR,n);return(0,O.jsx)(mI.p,{id:i.descriptionId,...r,ref:t})});MR.displayName=jR;var NR=`DialogClose`,PR=v.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=vR(NR,n);return(0,O.jsx)(mI.button,{type:`button`,...r,ref:t,onClick:qF(e.onClick,()=>i.onOpenChange(!1))})});PR.displayName=NR;function FR(e){return e?`open`:`closed`}var IR=`DialogTitleWarning`,[Pne,LR]=ZF(IR,{contentName:ER,titleName:kR,docsSlug:`dialog`}),Fne=({titleId:e})=>{let t=LR(IR),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
137
|
+
|
|
138
|
+
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
139
|
+
|
|
140
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return v.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Ine=`DialogDescriptionWarning`,Lne=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${LR(Ine).contentName}}.`;return v.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},RR=yR,zR=CR,BR=TR,VR=DR,HR=AR,UR=MR,WR=PR,GR=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,KR=PO,Rne=(e,t)=>n=>{if(t?.variants==null)return KR(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=GR(t)||GR(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return KR(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},qR=RR,zne=zR,JR=v.forwardRef(({className:e,...t},n)=>(0,O.jsx)(BR,{className:K(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t,ref:n}));JR.displayName=BR.displayName;var Bne=Rne(`fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500`,{variants:{side:{top:`inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top`,bottom:`inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom`,left:`inset-y-0 left-0 h-full border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left`,right:`inset-y-0 right-0 h-full border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right`}},defaultVariants:{side:`right`}}),YR=v.forwardRef(({side:e=`right`,className:t,children:n,showOverlay:r=!0,showCloseButton:i=!0,...a},o)=>(0,O.jsxs)(zne,{children:[r?(0,O.jsx)(JR,{}):null,(0,O.jsxs)(VR,{ref:o,className:K(Bne({side:e}),t),...a,children:[n,i?(0,O.jsxs)(WR,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,O.jsx)(cP,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`sr-only`,children:`Close`})]}):null]})]}));YR.displayName=VR.displayName;var XR=({className:e,...t})=>(0,O.jsx)(`div`,{className:K(`flex flex-col space-y-2 text-center sm:text-left`,e),...t});XR.displayName=`SheetHeader`;var Vne=({className:e,...t})=>(0,O.jsx)(`div`,{className:K(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});Vne.displayName=`SheetFooter`;var ZR=v.forwardRef(({className:e,...t},n)=>(0,O.jsx)(HR,{ref:n,className:K(`text-lg font-semibold text-foreground`,e),...t}));ZR.displayName=HR.displayName;var QR=v.forwardRef(({className:e,...t},n)=>(0,O.jsx)(UR,{ref:n,className:K(`text-sm text-muted-foreground`,e),...t}));QR.displayName=UR.displayName;function $R(e){return String(e.Title||``).trim()||String(e.FirstPrompt||``).trim()||String(e.LastPrompt||``).trim()||String(e.Summary||``).trim()||`新对话`}function Hne({uiCapabilities:e,createNewSession:t,deleteSession:n,loadSession:r,loadMoreSessions:i}){let a=E(e=>e.sessions),o=E(e=>e.currentSessionId),s=E(e=>e.pinnedSessionIds),c=E(e=>e.isLoadingSessions),l=E(e=>e.hasMoreSessions),u=ve(e=>e.sidebarOpen),d=ve(e=>e.mobileSidebarOpen),{isMobile:f}=qt(),p=Be(e),{desktopSidebarVisible:m}=ot({isMobile:f,desktopSidebarOpen:u,mobileSidebarOpen:d});return p?f?(0,O.jsx)(qR,{open:d,onOpenChange:e=>ve.getState().setMobileSidebarOpen(e),children:(0,O.jsxs)(YR,{side:`left`,className:`w-[88vw] max-w-sm border-slate-200 bg-slate-50 p-0 dark:border-slate-800 dark:bg-slate-950`,children:[(0,O.jsx)(ZR,{className:`sr-only`,children:`历史记录`}),(0,O.jsx)(QR,{className:`sr-only`,children:`查看和切换历史对话。`}),(0,O.jsx)(KF,{sessions:a,currentSessionId:o,onCreateNewSession:t,onSelectSession:r,onDeleteSession:(e,t)=>{t.stopPropagation(),n(e)},onTogglePinSession:(e,t)=>{t.stopPropagation(),E.getState().togglePinnedSession(e)},onLoadMoreSessions:i,sessionTitle:$R,pinnedSessionIds:s,hasMoreSessions:l,isLoadingSessions:c})]})}):(0,O.jsx)(`aside`,{className:K(`flex-shrink-0 overflow-hidden border-r border-slate-200 transition-[width] duration-300 ease-in-out dark:border-slate-800`,m?`w-[280px]`:`w-0 border-r-0`),children:(0,O.jsx)(KF,{sessions:a,currentSessionId:o,onCreateNewSession:t,onSelectSession:r,onDeleteSession:(e,t)=>{t.stopPropagation(),n(e)},onTogglePinSession:(e,t)=>{t.stopPropagation(),E.getState().togglePinnedSession(e)},onLoadMoreSessions:i,sessionTitle:$R,pinnedSessionIds:s,hasMoreSessions:l,isLoadingSessions:c})}):null}function Une(){}function Wne(e){let t=[],n=String(e||``),r=n.indexOf(`,`),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);let e=n.slice(i,r).trim();(e||!a)&&t.push(e),i=r+1,r=n.indexOf(`,`,i)}return t}function Gne(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var Kne=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,qne=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Jne={};function ez(e,t){return((t||Jne).jsx?qne:Kne).test(e)}var Yne=/[ \t\n\f\r]/g;function Xne(e){return typeof e==`object`?e.type===`text`?tz(e.value):!1:tz(e)}function tz(e){return e.replace(Yne,``)===``}var nz=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};nz.prototype.normal={},nz.prototype.property={},nz.prototype.space=void 0;function rz(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new nz(n,r,t)}function iz(e){return e.toLowerCase()}var az=class{constructor(e,t){this.attribute=t,this.property=e}};az.prototype.attribute=``,az.prototype.booleanish=!1,az.prototype.boolean=!1,az.prototype.commaOrSpaceSeparated=!1,az.prototype.commaSeparated=!1,az.prototype.defined=!1,az.prototype.mustUseProperty=!1,az.prototype.number=!1,az.prototype.overloadedBoolean=!1,az.prototype.property=``,az.prototype.spaceSeparated=!1,az.prototype.space=void 0;var oz=s({boolean:()=>sz,booleanish:()=>cz,commaOrSpaceSeparated:()=>fz,commaSeparated:()=>dz,number:()=>q,overloadedBoolean:()=>lz,spaceSeparated:()=>uz}),Zne=0,sz=pz(),cz=pz(),lz=pz(),q=pz(),uz=pz(),dz=pz(),fz=pz();function pz(){return 2**++Zne}var mz=Object.keys(oz),hz=class extends az{constructor(e,t,n,r){let i=-1;if(super(e,t),gz(this,`space`,r),typeof n==`number`)for(;++i<mz.length;){let e=mz[i];gz(this,mz[i],(n&oz[e])===oz[e])}}};hz.prototype.defined=!0;function gz(e,t,n){n&&(e[t]=n)}function _z(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new hz(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[iz(r)]=r,n[iz(a.attribute)]=r}return new nz(t,n,e.space)}var vz=_z({properties:{ariaActiveDescendant:null,ariaAtomic:cz,ariaAutoComplete:null,ariaBusy:cz,ariaChecked:cz,ariaColCount:q,ariaColIndex:q,ariaColSpan:q,ariaControls:uz,ariaCurrent:null,ariaDescribedBy:uz,ariaDetails:null,ariaDisabled:cz,ariaDropEffect:uz,ariaErrorMessage:null,ariaExpanded:cz,ariaFlowTo:uz,ariaGrabbed:cz,ariaHasPopup:null,ariaHidden:cz,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:uz,ariaLevel:q,ariaLive:null,ariaModal:cz,ariaMultiLine:cz,ariaMultiSelectable:cz,ariaOrientation:null,ariaOwns:uz,ariaPlaceholder:null,ariaPosInSet:q,ariaPressed:cz,ariaReadOnly:cz,ariaRelevant:null,ariaRequired:cz,ariaRoleDescription:uz,ariaRowCount:q,ariaRowIndex:q,ariaRowSpan:q,ariaSelected:cz,ariaSetSize:q,ariaSort:null,ariaValueMax:q,ariaValueMin:q,ariaValueNow:q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function yz(e,t){return t in e?e[t]:t}function bz(e,t){return yz(e,t.toLowerCase())}var Qne=_z({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:dz,acceptCharset:uz,accessKey:uz,action:null,allow:null,allowFullScreen:sz,allowPaymentRequest:sz,allowUserMedia:sz,alt:null,as:null,async:sz,autoCapitalize:null,autoComplete:uz,autoFocus:sz,autoPlay:sz,blocking:uz,capture:null,charSet:null,checked:sz,cite:null,className:uz,cols:q,colSpan:null,content:null,contentEditable:cz,controls:sz,controlsList:uz,coords:q|dz,crossOrigin:null,data:null,dateTime:null,decoding:null,default:sz,defer:sz,dir:null,dirName:null,disabled:sz,download:lz,draggable:cz,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:sz,formTarget:null,headers:uz,height:q,hidden:lz,high:q,href:null,hrefLang:null,htmlFor:uz,httpEquiv:uz,id:null,imageSizes:null,imageSrcSet:null,inert:sz,inputMode:null,integrity:null,is:null,isMap:sz,itemId:null,itemProp:uz,itemRef:uz,itemScope:sz,itemType:uz,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:sz,low:q,manifest:null,max:null,maxLength:q,media:null,method:null,min:null,minLength:q,multiple:sz,muted:sz,name:null,nonce:null,noModule:sz,noValidate:sz,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:sz,optimum:q,pattern:null,ping:uz,placeholder:null,playsInline:sz,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:sz,referrerPolicy:null,rel:uz,required:sz,reversed:sz,rows:q,rowSpan:q,sandbox:uz,scope:null,scoped:sz,seamless:sz,selected:sz,shadowRootClonable:sz,shadowRootDelegatesFocus:sz,shadowRootMode:null,shape:null,size:q,sizes:null,slot:null,span:q,spellCheck:cz,src:null,srcDoc:null,srcLang:null,srcSet:null,start:q,step:null,style:null,tabIndex:q,target:null,title:null,translate:null,type:null,typeMustMatch:sz,useMap:null,value:cz,width:q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:uz,axis:null,background:null,bgColor:null,border:q,borderColor:null,bottomMargin:q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:sz,declare:sz,event:null,face:null,frame:null,frameBorder:null,hSpace:q,leftMargin:q,link:null,longDesc:null,lowSrc:null,marginHeight:q,marginWidth:q,noResize:sz,noHref:sz,noShade:sz,noWrap:sz,object:null,profile:null,prompt:null,rev:null,rightMargin:q,rules:null,scheme:null,scrolling:cz,standby:null,summary:null,text:null,topMargin:q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:sz,disableRemotePlayback:sz,prefix:null,property:null,results:q,security:null,unselectable:null},space:`html`,transform:bz}),$ne=_z({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`,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:fz,accentHeight:q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:q,amplitude:q,arabicForm:null,ascent:q,attributeName:null,attributeType:null,azimuth:q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:q,by:null,calcMode:null,capHeight:q,className:uz,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:q,diffuseConstant:q,direction:null,display:null,dur:null,divisor:q,dominantBaseline:null,download:sz,dx:null,dy:null,edgeMode:null,editable:null,elevation:q,enableBackground:null,end:null,event:null,exponent:q,externalResourcesRequired:null,fill:null,fillOpacity:q,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:dz,g2:dz,glyphName:dz,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:q,horizOriginX:q,horizOriginY:q,id:null,ideographic:q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:q,k:q,k1:q,k2:q,k3:q,k4:q,kernelMatrix:fz,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:q,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:q,overlineThickness:q,paintOrder:null,panose1:null,path:null,pathLength:q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:uz,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:q,pointsAtY:q,pointsAtZ:q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:fz,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:fz,rev:fz,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:fz,requiredFeatures:fz,requiredFonts:fz,requiredFormats:fz,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:q,specularExponent:q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:q,strikethroughThickness:q,string:null,stroke:null,strokeDashArray:fz,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:q,strokeOpacity:q,strokeWidth:null,style:null,surfaceScale:q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:fz,tabIndex:q,tableValues:null,target:null,targetX:q,targetY:q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:fz,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:q,underlineThickness:q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:q,values:null,vAlphabetic:q,vMathematical:q,vectorEffect:null,vHanging:q,vIdeographic:q,version:null,vertAdvY:q,vertOriginX:q,vertOriginY:q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:yz}),xz=_z({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()}}),Sz=_z({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:bz}),Cz=_z({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),ere={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`},tre=/[A-Z]/g,wz=/-[a-z]/g,nre=/^data[-\w.:]+$/i;function Tz(e,t){let n=iz(t),r=t,i=az;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&nre.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(wz,ire);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!wz.test(e)){let n=e.replace(tre,rre);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=hz}return new i(r,t)}function rre(e){return`-`+e.toLowerCase()}function ire(e){return e.charAt(1).toUpperCase()}var Ez=rz([vz,Qne,xz,Sz,Cz],`html`),Dz=rz([vz,$ne,xz,Sz,Cz],`svg`);function are(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function ore(e){return e.join(` `).trim()}var sre=o(((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,u=`
|
|
141
|
+
`,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),ee(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function ee(){S(i)}function C(e){var t;for(e||=[];t=w();)t!==!1&&e.push(t);return e}function w(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function te(){var e=y(),t=S(a);if(t){if(w(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function ne(){var e=[];C(e);for(var t;t=te();)t!==!1&&(e.push(t),C(e));return e}return ee(),ne()}function _(e){return e?e.replace(l,p):p}t.exports=g})),cre=o((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(sre());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}})),lre=o((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))}})),ure=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(cre()),r=lre();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})),Oz=Az(`end`),kz=Az(`start`);function Az(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 dre(e){let t=kz(e),n=Oz(e);if(t&&n)return{start:t,end:n}}function jz(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Nz(e.position):`start`in e||`end`in e?Nz(e):`line`in e||`column`in e?Mz(e):``}function Mz(e){return Pz(e&&e.line)+`:`+Pz(e&&e.column)}function Nz(e){return Mz(e&&e.start)+`-`+Mz(e&&e.end)}function Pz(e){return e&&typeof e==`number`?e:1}var Fz=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=jz(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}};Fz.prototype.file=``,Fz.prototype.name=``,Fz.prototype.reason=``,Fz.prototype.message=``,Fz.prototype.stack=``,Fz.prototype.column=void 0,Fz.prototype.line=void 0,Fz.prototype.ancestors=void 0,Fz.prototype.cause=void 0,Fz.prototype.fatal=void 0,Fz.prototype.place=void 0,Fz.prototype.ruleId=void 0,Fz.prototype.source=void 0;var fre=l(ure(),1),Iz={}.hasOwnProperty,pre=new Map,mre=/[A-Z]/g,hre=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),gre=new Set([`td`,`th`]);function _re(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=Tre(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=wre(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`?Dz:Ez,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Lz(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Lz(e,t,n){if(t.type===`element`)return vre(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return yre(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return xre(e,t,n);if(t.type===`mdxjsEsm`)return bre(e,t);if(t.type===`root`)return Sre(e,t,n);if(t.type===`text`)return Cre(e,t)}function vre(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Dz,e.schema=i),e.ancestors.push(t);let a=Vz(e,t.tagName,!1),o=Ere(e,t),s=Bz(e,t);return hre.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!Xne(e):!0})),Rz(e,o,a,t),zz(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function yre(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)}Hz(e,t.position)}function bre(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Hz(e,t.position)}function xre(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Dz,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:Vz(e,t.name,!0),o=Dre(e,t),s=Bz(e,t);return Rz(e,o,a,t),zz(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Sre(e,t,n){let r={};return zz(r,Bz(e,t)),e.create(t,e.Fragment,r,n)}function Cre(e,t){return t.value}function Rz(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function zz(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function wre(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 Tre(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=kz(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 Ere(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Iz.call(t.properties,i)){let a=Ore(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&gre.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 Dre(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 Hz(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 Hz(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function Bz(e,t){let n=[],r=-1,i=e.passKeys?new Map:pre;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=Lz(e,a,o);s!==void 0&&n.push(s)}return n}function Ore(e,t,n){let r=Tz(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Gne(n):ore(n)),r.property===`style`){let t=typeof n==`object`?n:kre(e,String(n));return e.stylePropertyNameCase===`css`&&(t=Are(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?ere[r.property]||r.property:r.attribute,n]}}function kre(e,t){try{return(0,fre.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new Fz("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 Vz(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=ez(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=ez(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Iz.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Hz(e)}function Hz(e,t){let n=new Fz("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 Are(e){let t={},n;for(n in e)Iz.call(e,n)&&(t[jre(n)]=e[n]);return t}function jre(e){let t=e.replace(mre,Mre);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function Mre(e){return`-`+e.toLowerCase()}var Uz={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`]},Nre={};function Wz(e,t){let n=t||Nre;return Gz(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function Gz(e,t,n){if(Pre(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 Kz(e.children,t,n)}return Array.isArray(e)?Kz(e,t,n):``}function Kz(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=Gz(e[i],t,n);return r.join(``)}function Pre(e){return!!(e&&typeof e==`object`)}var qz=document.createElement(`i`);function Jz(e){let t=`&`+e+`;`;qz.innerHTML=t;let n=qz.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function Yz(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 Xz(e,t){return e.length>0?(Yz(e,e.length,0,t),e):t}var Zz={}.hasOwnProperty;function Qz(e){let t={},n=-1;for(;++n<e.length;)Fre(t,e[n]);return t}function Fre(e,t){let n;for(n in t){let r=(Zz.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){Zz.call(r,a)||(r[a]=[]);let e=i[a];Ire(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Ire(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);Yz(e,0,0,r)}function $z(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 eB(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var tB=uB(/[A-Za-z]/),nB=uB(/[\dA-Za-z]/),Lre=uB(/[#-'*+\--9=?A-Z^-~]/);function rB(e){return e!==null&&(e<32||e===127)}var iB=uB(/\d/),Rre=uB(/[\dA-Fa-f]/),zre=uB(/[!-/:-@[-`{-~]/);function aB(e){return e!==null&&e<-2}function oB(e){return e!==null&&(e<0||e===32)}function sB(e){return e===-2||e===-1||e===32}var cB=uB(/\p{P}|\p{S}/u),lB=uB(/\s/);function uB(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function dB(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&nB(e.charCodeAt(n+1))&&nB(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 fB(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return sB(r)?(e.enter(n),s(r)):t(r)}function s(r){return sB(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Bre={tokenize:Vre};function Vre(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`),fB(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 aB(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Hre={tokenize:Ure},pB={tokenize:Wre};function Ure(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 Yz(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(pB,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(pB,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 aB(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++;Yz(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 Wre(e,t,n){return fB(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function mB(e){if(e===null||oB(e)||lB(e))return 1;if(cB(e))return 2}function hB(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 gB={name:`attention`,resolveAll:Gre,tokenize:Kre};function Gre(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};_B(d,-c),_B(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=Xz(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=Xz(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=Xz(l,hB(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=Xz(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=Xz(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,Yz(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 Kre(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=mB(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=mB(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 _B(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var qre={name:`autolink`,tokenize:Jre};function Jre(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 tB(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||nB(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||nB(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||rB(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):Lre(t)?(e.consume(t),l):n(t)}function u(e){return nB(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||nB(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var vB={partial:!0,tokenize:Yre};function Yre(e,t,n){return r;function r(t){return sB(t)?fB(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||aB(e)?t(e):n(e)}}var yB={continuation:{tokenize:Zre},exit:Qre,name:`blockQuote`,tokenize:Xre};function Xre(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 sB(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Zre(e,t,n){let r=this;return i;function i(t){return sB(t)?fB(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(yB,t,n)(r)}}function Qre(e){e.exit(`blockQuote`)}var bB={name:`characterEscape`,tokenize:$re};function $re(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 zre(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var xB={name:`characterReference`,tokenize:eie};function eie(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=nB,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=Rre,u):(e.enter(`characterReferenceValue`),a=7,o=iB,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===nB&&!Jz(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 SB={partial:!0,tokenize:nie},CB={concrete:!0,name:`codeFenced`,tokenize:tie};function tie(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`),sB(t)?fB(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||aB(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(SB,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||aB(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):sB(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),fB(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||aB(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||aB(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&&sB(t)?fB(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||aB(t)?e.check(SB,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||aB(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`),sB(t)?fB(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`),sB(t)?fB(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||aB(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function nie(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 wB={name:`codeIndented`,tokenize:iie},rie={partial:!0,tokenize:aie};function iie(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),fB(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):aB(t)?e.attempt(rie,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||aB(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function aie(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):aB(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):fB(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):aB(e)?i(e):n(e)}}var oie={name:`codeText`,previous:cie,resolve:sie,tokenize:lie};function sie(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 cie(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function lie(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)):aB(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||aB(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 uie=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&&TB(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),TB(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),TB(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);TB(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);TB(this.left,t.reverse())}}};function TB(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 EB(e){let t={},n=-1,r,i,a,o,s,c,l,u=new uie(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,die(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 Yz(e,0,1/0,u.slice(0)),!l}function die(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 fie={resolve:mie,tokenize:hie},pie={partial:!0,tokenize:gie};function mie(e){return EB(e),e}function hie(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):aB(t)?e.check(pie,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 gie(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),fB(e,a,`linePrefix`)}function a(i){if(i===null||aB(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 DB(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||rB(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||aB(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||oB(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||rB(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 OB(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):aB(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||aB(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!sB(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function kB(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):aB(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),fB(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||aB(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 AB(e,t){let n;return r;function r(i){return aB(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):sB(i)?fB(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var _ie={name:`definition`,tokenize:yie},vie={partial:!0,tokenize:bie};function yie(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return OB.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=eB(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 oB(t)?AB(e,l)(t):l(t)}function l(t){return DB(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(vie,d,d)(t)}function d(t){return sB(t)?fB(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||aB(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function bie(e,t,n){return r;function r(t){return oB(t)?AB(e,i)(t):n(t)}function i(t){return kB(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return sB(t)?fB(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||aB(e)?t(e):n(e)}}var xie={name:`hardBreakEscape`,tokenize:Sie};function Sie(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return aB(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Cie={name:`headingAtx`,resolve:wie,tokenize:Tie};function wie(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`},Yz(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Tie(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||oB(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||aB(n)?(e.exit(`atxHeading`),t(n)):sB(n)?fB(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||oB(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Eie=`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(`.`),jB=[`pre`,`script`,`style`,`textarea`],Die={concrete:!0,name:`htmlFlow`,resolveTo:Aie,tokenize:jie},Oie={partial:!0,tokenize:Nie},kie={partial:!0,tokenize:Mie};function Aie(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 jie(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:E):tB(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):tB(a)?(e.consume(a),i=4,r.interrupt?t:E):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:E):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:T:m):n(i)}function h(t){return tB(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||oB(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&jB.includes(l)?(i=1,r.interrupt?t(s):T(s)):Eie.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):T(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||nB(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:T):n(i)}function v(t){return sB(t)?(e.consume(t),v):te(t)}function y(t){return t===47?(e.consume(t),te):t===58||t===95||tB(t)?(e.consume(t),b):sB(t)?(e.consume(t),y):te(t)}function b(t){return t===45||t===46||t===58||t===95||nB(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):sB(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,ee):sB(t)?(e.consume(t),S):C(t)}function ee(t){return t===c?(e.consume(t),c=null,w):t===null||aB(t)?n(t):(e.consume(t),ee)}function C(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||oB(t)?x(t):(e.consume(t),C)}function w(e){return e===47||e===62||sB(e)?y(e):n(e)}function te(t){return t===62?(e.consume(t),ne):n(t)}function ne(t){return t===null||aB(t)?T(t):sB(t)?(e.consume(t),ne):n(t)}function T(t){return t===45&&i===2?(e.consume(t),oe):t===60&&i===1?(e.consume(t),se):t===62&&i===4?(e.consume(t),D):t===63&&i===3?(e.consume(t),E):t===93&&i===5?(e.consume(t),le):aB(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Oie,ue,re)(t)):t===null||aB(t)?(e.exit(`htmlFlowData`),re(t)):(e.consume(t),T)}function re(t){return e.check(kie,ie,ue)(t)}function ie(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ae}function ae(t){return t===null||aB(t)?re(t):(e.enter(`htmlFlowData`),T(t))}function oe(t){return t===45?(e.consume(t),E):T(t)}function se(t){return t===47?(e.consume(t),o=``,ce):T(t)}function ce(t){if(t===62){let n=o.toLowerCase();return jB.includes(n)?(e.consume(t),D):T(t)}return tB(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ce):T(t)}function le(t){return t===93?(e.consume(t),E):T(t)}function E(t){return t===62?(e.consume(t),D):t===45&&i===2?(e.consume(t),E):T(t)}function D(t){return t===null||aB(t)?(e.exit(`htmlFlowData`),ue(t)):(e.consume(t),D)}function ue(n){return e.exit(`htmlFlow`),t(n)}}function Mie(e,t,n){let r=this;return i;function i(t){return aB(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 Nie(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(vB,t,n)}}var Pie={name:`htmlText`,tokenize:Fie};function Fie(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):tB(t)?(e.consume(t),C):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):tB(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):aB(t)?(o=d,se(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?oe(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):aB(t)?(o=h,se(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?oe(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?oe(t):aB(t)?(o=v,se(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):aB(t)?(o=y,se(t)):(e.consume(t),y)}function b(e){return e===62?oe(e):y(e)}function x(t){return tB(t)?(e.consume(t),S):n(t)}function S(t){return t===45||nB(t)?(e.consume(t),S):ee(t)}function ee(t){return aB(t)?(o=ee,se(t)):sB(t)?(e.consume(t),ee):oe(t)}function C(t){return t===45||nB(t)?(e.consume(t),C):t===47||t===62||oB(t)?w(t):n(t)}function w(t){return t===47?(e.consume(t),oe):t===58||t===95||tB(t)?(e.consume(t),te):aB(t)?(o=w,se(t)):sB(t)?(e.consume(t),w):oe(t)}function te(t){return t===45||t===46||t===58||t===95||nB(t)?(e.consume(t),te):ne(t)}function ne(t){return t===61?(e.consume(t),T):aB(t)?(o=ne,se(t)):sB(t)?(e.consume(t),ne):w(t)}function T(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,re):aB(t)?(o=T,se(t)):sB(t)?(e.consume(t),T):(e.consume(t),ie)}function re(t){return t===i?(e.consume(t),i=void 0,ae):t===null?n(t):aB(t)?(o=re,se(t)):(e.consume(t),re)}function ie(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||oB(t)?w(t):(e.consume(t),ie)}function ae(e){return e===47||e===62||oB(e)?w(e):n(e)}function oe(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function se(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ce}function ce(t){return sB(t)?fB(e,le,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):le(t)}function le(t){return e.enter(`htmlTextData`),o(t)}}var MB={name:`labelEnd`,resolveAll:IB,resolveTo:LB,tokenize:RB},NB={tokenize:zB},PB={tokenize:BB},FB={tokenize:VB};function IB(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&&Yz(e,0,e.length,n),e}function LB(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=Xz(s,e.slice(a+1,a+r+3)),s=Xz(s,[[`enter`,u,t]]),s=Xz(s,hB(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=Xz(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=Xz(s,e.slice(o+1)),s=Xz(s,[[`exit`,c,t]]),Yz(e,a,e.length,s),e}function RB(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(eB(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(NB,u,o?u:d)(t):t===91?e.attempt(PB,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(FB,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function zB(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 oB(t)?AB(e,a)(t):a(t)}function a(t){return t===41?u(t):DB(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return oB(t)?AB(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?kB(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return oB(t)?AB(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 BB(e,t,n){let r=this;return i;function i(t){return OB.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(eB(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function VB(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 HB={name:`labelStartImage`,resolveAll:MB.resolveAll,tokenize:UB};function UB(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 WB={name:`labelStartLink`,resolveAll:MB.resolveAll,tokenize:GB};function GB(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 KB={name:`lineEnding`,tokenize:qB};function qB(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),fB(e,t,`linePrefix`)}}var JB={name:`thematicBreak`,tokenize:YB};function YB(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||aB(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),sB(t)?fB(e,s,`whitespace`)(t):s(t))}}var XB={continuation:{tokenize:eV},exit:nV,name:`list`,tokenize:$B},ZB={partial:!0,tokenize:rV},QB={partial:!0,tokenize:tV};function $B(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:iB(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(JB,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 iB(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(vB,r.interrupt?n:u,e.attempt(ZB,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return sB(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 eV(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(vB,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,fB(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!sB(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(QB,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,fB(e,e.attempt(XB,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function tV(e,t,n){let r=this;return fB(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 nV(e){e.exit(this.containerState.type)}function rV(e,t,n){let r=this;return fB(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!sB(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var iV={name:`setextUnderline`,resolveTo:aV,tokenize:oV};function aV(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 oV(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`),sB(t)?fB(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||aB(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var sV={tokenize:cV};function cV(e){let t=this,n=e.attempt(vB,r,e.attempt(this.parser.constructs.flowInitial,i,fB(e,e.attempt(this.parser.constructs.flow,i,e.attempt(fie,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 lV={resolveAll:pV()},uV=fV(`string`),dV=fV(`text`);function fV(e){return{resolveAll:pV(e===`text`?mV: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 pV(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 mV(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 hV=s({attentionMarkers:()=>CV,contentInitial:()=>_V,disable:()=>wV,document:()=>gV,flow:()=>yV,flowInitial:()=>vV,insideSpan:()=>SV,string:()=>bV,text:()=>xV}),gV={42:XB,43:XB,45:XB,48:XB,49:XB,50:XB,51:XB,52:XB,53:XB,54:XB,55:XB,56:XB,57:XB,62:yB},_V={91:_ie},vV={[-2]:wB,[-1]:wB,32:wB},yV={35:Cie,42:JB,45:[iV,JB],60:Die,61:iV,95:JB,96:CB,126:CB},bV={38:xB,92:bB},xV={[-5]:KB,[-4]:KB,[-3]:KB,33:HB,38:xB,42:gB,60:[qre,Pie],91:WB,92:[xie,bB],93:MB,95:gB,96:oie},SV={null:[gB,lV]},CV={null:[42,95]},wV={null:[]};function TV(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:ee(x),check:ee(S),consume:v,enter:y,exit:b,interrupt:ee(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=Xz(o,e),g(),o[o.length-1]===null?(C(t,0),l.events=hB(a,l.events,l),l.events):[]}function f(e,t){return DV(p(e),t)}function p(e){return EV(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,te()}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){aB(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,te()):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){C(e,t.from)}function S(e,t){t.restore()}function ee(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=w(),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 C(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&Yz(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function w(){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,te()}}function te(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function EV(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 DV(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=`
|
|
142
|
+
`;break;case-3:o=`\r
|
|
143
|
+
`;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 OV(e){let t={constructs:Qz([hV,...(e||{}).extensions||[]]),content:n(Bre),defined:[],document:n(Hre),flow:n(sV),lazy:{},string:n(uV),text:n(dV)};return t;function n(e){return n;function n(n){return TV(t,e,n)}}}function kV(e){for(;!EB(e););return e}var AV=/[\0\t\n\r]/g;function jV(){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(AV.lastIndex=u,c=AV.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 MV=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function NV(e){return e.replace(MV,PV)}function PV(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return $z(n.slice(t?2:1),t?16:10)}return Jz(n)||e}var FV={}.hasOwnProperty;function IV(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),LV(n)(kV(OV(n).document().write(jV()(e,t,!0))))}function LV(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(Ee),autolinkProtocol:w,autolinkEmail:w,atxHeading:a(Se),blockQuote:a(_e),characterEscape:w,characterReference:w,codeFenced:a(ve),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(ve,o),codeText:a(ye,o),codeTextData:w,data:w,codeFlowValue:w,definition:a(be),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(xe),hardBreakEscape:a(Ce),hardBreakTrailing:a(Ce),htmlFlow:a(we,o),htmlFlowData:w,htmlText:a(we,o),htmlTextData:w,image:a(Te),label:o,link:a(Ee),listItem:a(Oe),listItemValue:f,listOrdered:a(De,d),listUnordered:a(De),paragraph:a(ke),reference:de,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(Se),strong:a(Ae),thematicBreak:a(Me)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:ge,autolinkProtocol:he,blockQuote:c(),characterEscapeValue:te,characterReferenceMarkerHexadecimal:pe,characterReferenceMarkerNumeric:pe,characterReferenceValue:me,characterReference:O,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:te,codeIndented:c(_),codeText:c(ae),codeTextData:te,data:te,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(T),hardBreakTrailing:c(T),htmlFlow:c(re),htmlFlowData:te,htmlText:c(ie),htmlTextData:te,image:c(se),label:le,labelText:ce,lineEnding:ne,link:c(oe),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:fe,resourceDestinationString:E,resourceTitleString:D,resource:ue,setextHeading:c(C),setextHeadingLineSequence:ee,setextHeadingText:S,strong:c(),thematicBreak:c()}};zV(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]];FV.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]||VV).call(a,void 0,e[0])}for(r.position={start:RV(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:RV(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:RV(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]||VV).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+jz({start:e.start,end:e.end})+`): it’s not open`);n.position.end=RV(e.end)}function u(){return Wz(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=eB(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 ee(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function C(){this.data.setextHeadingSlurpLineEnding=void 0}function w(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=je(),n.position={start:RV(e.start),end:void 0},t.push(n)),this.stack.push(n)}function te(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=RV(e.end)}function ne(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=RV(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(w.call(this,e),te.call(this,e))}function T(){this.data.atHardBreak=!0}function re(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ie(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ae(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function oe(){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 se(){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 ce(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=NV(t),n.identifier=eB(t).toLowerCase()}function le(){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 E(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function D(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ue(){this.data.inReference=void 0}function de(){this.data.referenceType=`collapsed`}function fe(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=eB(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function pe(e){this.data.characterReferenceType=e.type}function me(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=$z(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=Jz(t);let i=this.stack[this.stack.length-1];i.value+=r}function O(e){let t=this.stack.pop();t.position.end=RV(e.end)}function he(e){te.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ge(e){te.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function _e(){return{type:`blockquote`,children:[]}}function ve(){return{type:`code`,lang:null,meta:null,value:``}}function ye(){return{type:`inlineCode`,value:``}}function be(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function xe(){return{type:`emphasis`,children:[]}}function Se(){return{type:`heading`,depth:0,children:[]}}function Ce(){return{type:`break`}}function we(){return{type:`html`,value:``}}function Te(){return{type:`image`,title:null,url:``,alt:null}}function Ee(){return{type:`link`,title:null,url:``,children:[]}}function De(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function Oe(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function ke(){return{type:`paragraph`,children:[]}}function Ae(){return{type:`strong`,children:[]}}function je(){return{type:`text`,value:``}}function Me(){return{type:`thematicBreak`}}}function RV(e){return{line:e.line,column:e.column,offset:e.offset}}function zV(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?zV(e,r):BV(e,r)}}function BV(e,t){let n;for(n in t)if(FV.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 VV(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+jz({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+jz({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+jz({start:t.start,end:t.end})+`) is still open`)}function HV(e){let t=this;t.parser=n;function n(n){return IV(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function UV(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 WV(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
144
|
+
`}]}function GV(e,t){let n=t.value?t.value+`
|
|
145
|
+
`:``,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 KV(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function qV(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function JV(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=dB(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 YV(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 XV(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function ZV(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 QV(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ZV(e,t);let i={src:dB(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 $V(e,t){let n={src:dB(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 eH(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 tH(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ZV(e,t);let i={href:dB(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 nH(e,t){let n={href:dB(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 rH(e,t,n){let r=e.all(t),i=n?iH(n):aH(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:`
|
|
146
|
+
`}),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:`
|
|
147
|
+
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function iH(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=aH(n[r])}return t}function aH(e){return e.spread??e.children.length>1}function oH(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 sH(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function cH(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function lH(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function uH(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=kz(t.children[1]),o=Oz(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 dH(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 fH(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var pH=9,mH=32;function hH(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(gH(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(gH(t.slice(i),i>0,!1)),a.join(``)}function gH(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===pH||t===mH;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===pH||t===mH;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function _H(e,t){let n={type:`text`,value:hH(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function vH(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var yH={blockquote:UV,break:WV,code:GV,delete:KV,emphasis:qV,footnoteReference:JV,heading:YV,html:XV,imageReference:QV,image:$V,inlineCode:eH,linkReference:tH,link:nH,listItem:rH,list:oH,paragraph:sH,root:cH,strong:lH,table:uH,tableCell:fH,tableRow:dH,text:_H,thematicBreak:vH,toml:bH,yaml:bH,definition:bH,footnoteDefinition:bH};function bH(){}var xH=typeof self==`object`?self:globalThis,SH=(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(new xH[e](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(new xH[a](o),i)};return r},CH=e=>SH(new Map,e)(0),wH=``,{toString:TH}={},{keys:EH}=Object,DH=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=TH.call(e).slice(8,-1);switch(n){case`Array`:return[1,wH];case`Object`:return[2,wH];case`Date`:return[3,wH];case`RegExp`:return[4,wH];case`Map`:return[5,wH];case`Set`:return[6,wH];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},OH=([e,t])=>e===0&&(t===`function`||t===`symbol`),kH=(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]=DH(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 EH(r))(e||!OH(DH(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,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||!(OH(DH(n))||OH(DH(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!OH(DH(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},AH=(e,{json:t,lossy:n}={})=>{let r=[];return kH(!(t||n),!!t,new Map,r)(e),r},jH=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?CH(AH(e,t)):structuredClone(e):(e,t)=>CH(AH(e,t));function MH(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 NH(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function PH(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||MH,r=e.options.footnoteBackLabel||NH,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=dB(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:{...jH(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
148
|
+
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
149
|
+
`}]}}var FH=(function(e){if(e==null)return BH;if(typeof e==`function`)return zH(e);if(typeof e==`object`)return Array.isArray(e)?IH(e):LH(e);if(typeof e==`string`)return RH(e);throw Error(`Expected function, string, or object as test`)});function IH(e){let t=[],n=-1;for(;++n<e.length;)t[n]=FH(e[n]);return zH(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function LH(e){let t=e;return zH(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function RH(e){return zH(t);function t(t){return t&&t.type===e}}function zH(e){return t;function t(t,n,r){return!!(VH(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function BH(){return!0}function VH(e){return typeof e==`object`&&!!e&&`type`in e}function HH(e){return e}var UH=[],WH=`skip`;function GH(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=FH(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 (`+HH(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=UH,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=KH(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 KH(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?UH:[e]}function qH(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),GH(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 JH={}.hasOwnProperty,YH={};function XH(e,t){let n=t||YH,r=new Map,i=new Map,a={all:s,applyData:QH,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...yH,...n.handlers},one:o,options:n,patch:ZH,wrap:eU};return qH(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(JH.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=jH(n);return r.children=a.all(e),r}return jH(e)}return(a.options.unknownHandler||$H)(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=tU(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=tU(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function ZH(e,t){e.position&&(t.position=dre(e))}function QH(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,jH(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function $H(e,t){let n=t.data||{},r=`value`in t&&!(JH.call(n,`hProperties`)||JH.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 eU(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
150
|
+
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
151
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
152
|
+
`}),n}function tU(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function nU(e,t){let n=XH(e,t),r=n.one(e,void 0),i=PH(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
153
|
+
`},i)),a}function rU(e,t){return e&&`run`in e?async function(n,r){let i=nU(n,{file:r,...t});await e.run(i,r)}:function(n,r){return nU(n,{file:r,...e||t})}}function iU(e){if(e)throw e}var aU=o(((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 oU(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 sU(){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?cU(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 cU(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 lU={basename:uU,dirname:dU,extname:fU,join:pU,sep:`/`};function uU(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);gU(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 dU(e){if(gU(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 fU(e){gU(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 pU(...e){let t=-1,n;for(;++t<e.length;)gU(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:mU(n)}function mU(e){gU(e);let t=e.codePointAt(0)===47,n=hU(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function hU(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 gU(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var _U={cwd:vU};function vU(){return`/`}function yU(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function bU(e){if(typeof e==`string`)e=new URL(e);else if(!yU(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 xU(e)}function xU(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 SU=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],CU=class{constructor(e){let t;t=e?yU(e)?{path:e}:typeof e==`string`||DU(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:_U.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<SU.length;){let e=SU[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)SU.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?lU.basename(this.path):void 0}set basename(e){TU(e,`basename`),wU(e,`basename`),this.path=lU.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?lU.dirname(this.path):void 0}set dirname(e){EU(this.basename,`dirname`),this.path=lU.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?lU.extname(this.path):void 0}set extname(e){if(wU(e,`extname`),EU(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=lU.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){yU(e)&&(e=bU(e)),TU(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?lU.basename(this.path,this.extname):void 0}set stem(e){TU(e,`stem`),wU(e,`stem`),this.path=lU.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 Fz(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 wU(e,t){if(e&&e.includes(lU.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+lU.sep+"`")}function TU(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function EU(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function DU(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var OU=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),kU=l(aU(),1),AU={}.hasOwnProperty,jU=new class e extends OU{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=sU()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,kU.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(PU(`data`,this.frozen),this.namespace[e]=t,this):AU.call(this.namespace,e)&&this.namespace[e]||void 0:e?(PU(`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=LU(e),n=this.parser||this.Parser;return MU(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),MU(`process`,this.parser||this.Parser),NU(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=LU(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);zU(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(),MU(`processSync`,this.parser||this.Parser),NU(`processSync`,this.compiler||this.Compiler),this.process(e,r),IU(`processSync`,`process`,t),n;function r(e,r){t=!0,iU(e),n=r}}run(e,t,n){FU(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=LU(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),IU(`runSync`,`run`,n),r;function i(e,t){iU(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=LU(t),r=this.compiler||this.Compiler;return NU(`stringify`,r),FU(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(PU(`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,kU.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];oU(o)&&oU(r)&&(r=(0,kU.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function MU(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function NU(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function PU(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 FU(e){if(!oU(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function IU(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function LU(e){return RU(e)?e:new CU(e)}function RU(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function zU(e){return typeof e==`string`||BU(e)}function BU(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var VU=[],HU={allowDangerousHtml:!0},UU=/^(https?|ircs?|mailto|xmpp)$/i,WU=[{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 GU(e){let t=KU(e),n=qU(e);return JU(t.runSync(t.parse(n),n),e)}function KU(e){let t=e.rehypePlugins||VU,n=e.remarkPlugins||VU,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...HU}:HU;return jU().use(HV).use(n).use(rU,r).use(t)}function qU(e){let t=e.children||``,n=new CU;return typeof t==`string`?n.value=t:``+t,n}function JU(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||YU;for(let e of WU)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return qH(e,l),_re(e,{Fragment:O.Fragment,components:i,ignoreInvalidStyle:!0,jsx:O.jsx,jsxs:O.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 Uz)if(Object.hasOwn(Uz,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Uz[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 YU(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||UU.test(e.slice(0,t))?e:``}function XU(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 ZU(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function QU(e,t,n){let r=FH((n||{}).ignore||[]),i=$U(t),a=-1;for(;++a<i.length;)GH(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 $U(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([eW(e[0]),tW(e[1])])}return t}function eW(e){return typeof e==`string`?new RegExp(ZU(e),`g`):e}function tW(e){return typeof e==`function`?e:function(){return e}}var nW=`phrasing`,rW=[`autolink`,`link`,`image`,`label`];function iW(){return{transforms:[fW],enter:{literalAutolink:oW,literalAutolinkEmail:sW,literalAutolinkHttp:sW,literalAutolinkWww:sW},exit:{literalAutolink:dW,literalAutolinkEmail:uW,literalAutolinkHttp:cW,literalAutolinkWww:lW}}}function aW(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:nW,notInConstruct:rW},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:nW,notInConstruct:rW},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:nW,notInConstruct:rW}]}}function oW(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function sW(e){this.config.enter.autolinkProtocol.call(this,e)}function cW(e){this.config.exit.autolinkProtocol.call(this,e)}function lW(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 uW(e){this.config.exit.autolinkEmail.call(this,e)}function dW(e){this.exit(e)}function fW(e){QU(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,pW],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,mW]],{ignore:[`link`,`linkReference`]})}function pW(e,t,n,r,i){let a=``;if(!_W(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!hW(n)))return!1;let o=gW(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 mW(e,t,n,r){return!_W(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function hW(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 gW(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=XU(e,`(`),a=XU(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 _W(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||lB(n)||cB(n))&&(!t||n!==47)}DW.peek=EW;function vW(){this.buffer()}function yW(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function bW(){this.buffer()}function xW(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function SW(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=eB(this.sliceSerialize(e)).toLowerCase(),n.label=t}function CW(e){this.exit(e)}function wW(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=eB(this.sliceSerialize(e)).toLowerCase(),n.label=t}function TW(e){this.exit(e)}function EW(){return`[`}function DW(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 OW(){return{enter:{gfmFootnoteCallString:vW,gfmFootnoteCall:yW,gfmFootnoteDefinitionLabelString:bW,gfmFootnoteDefinition:xW},exit:{gfmFootnoteCallString:SW,gfmFootnoteCall:CW,gfmFootnoteDefinitionLabelString:wW,gfmFootnoteDefinition:TW}}}function kW(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:DW},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?`
|
|
154
|
+
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?jW:AW))),s(),o}}function AW(e,t,n){return t===0?e:jW(e,t,n)}function jW(e,t,n){return(n?``:` `)+e}var MW=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];LW.peek=RW;function NW(){return{canContainEols:[`delete`],enter:{strikethrough:FW},exit:{strikethrough:IW}}}function PW(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:MW}],handlers:{delete:LW}}}function FW(e){this.enter({type:`delete`,children:[]},e)}function IW(e){this.exit(e)}function LW(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 RW(){return`~`}function zW(e){return e.length}function BW(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||zW,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=VW(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]=HW(r[d]);else{let e=HW(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(`
|
|
155
|
+
`)}function VW(e){return e==null?``:String(e)}function HW(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 UW(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()),WW);return i(),o}function WW(e,t,n){return`>`+(n?``:` `)+e}function GW(e,t){return KW(e,t.inConstruct,!0)&&!KW(e,t.notInConstruct,!1)}function KW(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 qW(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
156
|
+
`&&GW(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
|
|
157
|
+
`}function JW(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 YW(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 XW(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function ZW(e,t,n,r){let i=XW(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(YW(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,QW);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(JW(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:`
|
|
158
|
+
`,encode:["`"],...s.current()})),t()}return u+=s.move(`
|
|
159
|
+
`),a&&(u+=s.move(a+`
|
|
160
|
+
`)),u+=s.move(c),l(),u}function QW(e,t,n){return(n?``:` `)+e}function $W(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function eG(e,t,n,r){let i=$W(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?` `:`
|
|
161
|
+
`,...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 tG(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function nG(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function rG(e,t,n){let r=mB(e),i=mB(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}}iG.peek=aG;function iG(e,t,n,r){let i=tG(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=rG(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=nG(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=rG(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+nG(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function aG(e,t,n){return n.options.emphasis||`*`}function oG(e,t){let n=!1;return qH(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)&&Wz(e)&&(t.options.setext||n))}function sG(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(oG(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
162
|
+
`,after:`
|
|
163
|
+
`});return r(),t(),o+`
|
|
164
|
+
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
165
|
+
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
166
|
+
`,...a.current()});return/^[\t ]/.test(l)&&(l=nG(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}cG.peek=lG;function cG(e){return e.value||``}function lG(){return`<`}uG.peek=dG;function uG(e,t,n,r){let i=$W(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 dG(){return`!`}fG.peek=pG;function fG(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 pG(){return`!`}mG.peek=hG;function mG(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 hG(){return"`"}function gG(e,t){let n=Wz(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))}_G.peek=vG;function _G(e,t,n,r){let i=$W(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(gG(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 vG(e,t,n){return gG(e,n)?`<`:`[`}yG.peek=bG;function yG(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 bG(){return`[`}function xG(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 SG(e){let t=xG(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 CG(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function wG(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 TG(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?CG(n):xG(n),s=e.ordered?o===`.`?`)`:`.`:SG(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),wG(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 EG(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 DG(e,t,n,r){let i=EG(n),a=n.bulletCurrent||xG(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 OG(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var kG=FH([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function AG(e,t,n,r){return(e.children.some(function(e){return kG(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function jG(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}MG.peek=NG;function MG(e,t,n,r){let i=jG(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=rG(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=nG(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=rG(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+nG(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function NG(e,t,n){return n.options.strong||`*`}function PG(e,t,n,r){return n.safe(e.value,r)}function FG(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 IG(e,t,n){let r=(wG(n)+(n.options.ruleSpaces?` `:``)).repeat(FG(n));return n.options.ruleSpaces?r.slice(0,-1):r}var LG={blockquote:UW,break:qW,code:ZW,definition:eG,emphasis:iG,hardBreak:qW,heading:sG,html:cG,image:uG,imageReference:fG,inlineCode:mG,link:_G,linkReference:yG,list:TG,listItem:DG,paragraph:OG,root:AG,strong:MG,text:PG,thematicBreak:IG};function RG(){return{enter:{table:zG,tableData:UG,tableHeader:UG,tableRow:VG},exit:{codeText:WG,table:BG,tableData:HG,tableHeader:HG,tableRow:HG}}}function zG(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 BG(e){this.exit(e),this.data.inTable=void 0}function VG(e){this.enter({type:`tableRow`,children:[]},e)}function HG(e){this.exit(e)}function UG(e){this.enter({type:`tableCell`,children:[]},e)}function WG(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,GG));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function GG(e,t){return t===`|`?t:e}function KG(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
167
|
+
`,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(`
|
|
168
|
+
`))}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 BW(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=LG.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function qG(){return{exit:{taskListCheckValueChecked:YG,taskListCheckValueUnchecked:YG,paragraph:XG}}}function JG(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:ZG}}}function YG(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function XG(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 ZG(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=LG.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 QG(){return[iW(),OW(),NW(),RG(),qG()]}function $G(e){return{extensions:[aW(),kW(e),PW(),KG(e),JG()]}}var eK={tokenize:mK,partial:!0},tK={tokenize:hK,partial:!0},nK={tokenize:gK,partial:!0},rK={tokenize:_K,partial:!0},iK={tokenize:vK,partial:!0},aK={name:`wwwAutolink`,tokenize:fK,previous:yK},oK={name:`protocolAutolink`,tokenize:pK,previous:bK},sK={name:`emailAutolink`,tokenize:dK,previous:xK},cK={};function lK(){return{text:cK}}for(var uK=48;uK<123;)cK[uK]=sK,uK++,uK===58?uK=65:uK===91&&(uK=97);cK[43]=sK,cK[45]=sK,cK[46]=sK,cK[95]=sK,cK[72]=[sK,oK],cK[104]=[sK,oK],cK[87]=[sK,aK],cK[119]=[sK,aK];function dK(e,t,n){let r=this,i,a;return o;function o(t){return!SK(t)||!xK.call(r,r.previous)||CK(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return SK(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(iK,u,l)(t):t===45||t===95||nB(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&&tB(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function fK(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!yK.call(r,r.previous)||CK(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(eK,e.attempt(tK,e.attempt(nK,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function pK(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&bK.call(r,r.previous)&&!CK(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(tB(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||rB(t)||oB(t)||lB(t)||cB(t)?n(t):e.attempt(tK,e.attempt(nK,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function mK(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 hK(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(rK,c,s)(t):t===null||oB(t)||lB(t)||t!==45&&cB(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 gK(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(rK,t,a)(o):o===null||oB(o)||lB(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function _K(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||oB(o)||lB(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||oB(e)||lB(e)?t(e):r(e)}function a(e){return tB(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):tB(t)?(e.consume(t),o):n(t)}}function vK(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return nB(e)?n(e):t(e)}}function yK(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||oB(e)}function bK(e){return!tB(e)}function xK(e){return!(e===47||SK(e))}function SK(e){return e===43||e===45||e===46||e===95||nB(e)}function CK(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 wK={tokenize:MK,partial:!0};function TK(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:kK,continuation:{tokenize:AK},exit:jK}},text:{91:{name:`gfmFootnoteCall`,tokenize:OK},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:EK,resolveTo:DK}}}}function EK(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=eB(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 DK(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 OK(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||oB(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(eB(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return oB(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 kK(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||oB(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=eB(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return oB(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),fB(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function AK(e,t,n){return e.check(vB,t,e.attempt(wK,t,n))}function jK(e){e.exit(`gfmFootnoteDefinition`)}function MK(e,t,n){let r=this;return fB(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 NK(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&&Yz(o,o.length,0,hB(s,e.slice(r+1,n),t)),Yz(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Yz(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=mB(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=mB(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var PK=class{constructor(){this.map=[]}add(e,t,n){FK(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 FK(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 IK(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 LK(){return{flow:{null:{name:`table`,tokenize:RK,resolveAll:zK}}}}function RK(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):aB(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):sB(t)?fB(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||oB(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,sB(t)?fB(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 sB(t)?fB(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||aB(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 sB(t)?fB(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||aB(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`),ee(t)}function ee(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),ee):n===null||aB(n)?(e.exit(`tableRow`),t(n)):sB(n)?fB(e,ee,`whitespace`)(n):(e.enter(`data`),C(n))}function C(t){return t===null||t===124||oB(t)?(e.exit(`data`),ee(t)):(e.consume(t),t===92?w:C)}function w(t){return t===92||t===124?(e.consume(t),C):C(t)}}function zK(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 PK;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(VK(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=BK(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=BK(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=BK(f,t,o,i,n,d)):(o[0]=o[1],d=BK(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&VK(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=IK(t.events,n))}return e}function BK(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},HK(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=HK(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=HK(t.events,n[2]),a=HK(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({},HK(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function VK(e,t,n,r,i){let a=[],o=HK(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 HK(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var UK={name:`tasklistCheck`,tokenize:GK};function WK(){return{text:{91:UK}}}function GK(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 oB(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 aB(r)?t(r):sB(r)?e.check({tokenize:KK},t,n)(r):n(r)}}function KK(e,t,n){return fB(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function qK(e){return Qz([lK(),TK(),NK(e),LK(),WK()])}var JK={};function YK(e){let t=this,n=e||JK,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(qK(n)),a.push(QG()),o.push($G(n))}function XK(e){QU(e,[/\r?\n|\r/g,ZK])}function ZK(){return{type:`break`}}function QK(){return function(e){XK(e)}}function $K(e){return e.replace(/<think>([\s\S]*?)(?:<\/think>|$)/gi,(e,t)=>`\n> 💭 **思考过程**\n>\n${String(t||``).trim().split(`
|
|
169
|
+
`).filter(Boolean).map(e=>`> ${e}`).join(`
|
|
170
|
+
`)}\n\n`)}function eq(e){return/^\s*\|(?:\s*[:\-]+\s*\|){2,}\s*$/.test(e)}function tq(e){let t=e.trim();return t.startsWith(`|`)?t.split(`|`).length>=4:!1}function nq(e){let t=e.trim();return t.startsWith(`|`)?t.replace(/^\|/,``).replace(/\|\s*$/,``).split(`|`).map(e=>e.trim()):[]}function rq(e,t=``){return`${t}| ${e.join(` | `)} |`}function iq(e){let t=e.split(`
|
|
171
|
+
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(tq(e)&&r+1<t.length&&eq(t[r+1])){let i=e.match(/^(\s*)/)?.[1]||``,a=nq(e),o=nq(t[r+1]),s=[],c=r+2,l=Math.max(a.length,o.length);for(;c<t.length&&tq(t[c]);){let e=nq(t[c]);l=Math.max(l,e.length),s.push(e),c+=1}let u=e=>{let t=[...e];for(;t.length<l;)t.push(``);return t};n.push(rq(u(a),i)),n.push(rq((e=>{let t=[...e];for(;t.length<l;)t.push(`---`);return t})(o),i));for(let e of s)n.push(rq(u(e),i));r=c}else n.push(e),r+=1}return n.join(`
|
|
172
|
+
`)}function aq(e){return eq(e)||/\|\|/.test(e)||/\|(?:\s*[:\-]+\s*\|){2,}/.test(e)&&/\|(?:[^|\n]*\|){2,}/.test(e)}function oq(e){return aq(e)?e.replace(/\|\s*\|/g,`|
|
|
173
|
+
|`).split(`
|
|
174
|
+
`).map(e=>e.trimEnd()).filter(e=>e.trim().length>0):[e]}function sq(e){return tq(e)?e.replace(/\|\s*(?:\*{1,2}|_{1,2})\s*$/u,`|`):e}function cq(e){let t=e.trim();return tq(t)?t.split(`|`).slice(1,-1).length:0}function lq(e){let t=e.match(/^(\s*)/)?.[1]||``,n=cq(e);return n<2?``:`${t}| ${Array.from({length:n},()=>`---`).join(` | `)} |`}function uq(e){let t=[];for(let n of e.split(`
|
|
175
|
+
`)){if(/^\s*\|\s*$/.test(n))continue;let e=n.match(/^(\s*)\|\s*([^|]+)$/);if(e){t.push(`${e[1]}${e[2].trim()}`);continue}t.push(...oq(n).map(sq))}let n=[];for(let e=0;e<t.length;e+=1){let r=t[e];r.trim().length===0&&tq(n[n.length-1]||``)&&eq(t[e+1]||``)||n.push(r)}let r=[];for(let e=0;e<n.length;e+=1){let t=n[e],i=n[e+1]||``;if(r.push(t),tq(t)&&tq(i)&&!eq(i)&&cq(t)===cq(i)){let i=tq(n[e-1]||``),a=t.match(/^(\s*)/)?.[1]||``;if(!i&&a.length===0){let e=lq(t);e&&r.push(e)}}}let i=[];for(let e=0;e<r.length;e+=1){let t=r[e],n=r[e+1]||``,a=i[i.length-1]||``,o=tq(t)&&(a.trim().length===0||!tq(a)),s=tq(t)&&(n.trim().length===0||!tq(n)),c=t.match(/^(\s*)/)?.[1]||``;o&&c.length===0&&a.trim().length>0&&i.push(``),i.push(t),s&&c.length===0&&n.trim().length>0&&i.push(``)}return i.join(`
|
|
176
|
+
`)}function dq(e){let t=e.replace(/^[\u200B-\u200D\uFEFF]+/u,``),n=t.match(/^([ \t\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)([##]{1,6})([ \t\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)(\S.*)?$/u);if(!n)return t;let[,r,i,,a=``]=n,o=r.replace(/[^\t ]/gu,` `),s=i.replace(/#/gu,`#`);return a?`${o}${s} ${a}`:`${o}${s}`}function fq(e){let t=e;return t=t.split(`
|
|
177
|
+
`).map(e=>dq(e)).join(`
|
|
178
|
+
`),t=t.replace(/^[ \t]+(#{1,6}\s*)/gm,`$1`),t=t.replace(/([^\n#])\s*(#{1,6}\s*[^\s|])/g,`$1
|
|
179
|
+
|
|
180
|
+
$2`),t=t.replace(/^(#{1,6}\s*[^\n]+)\n(?!\n)/gm,`$1
|
|
181
|
+
|
|
182
|
+
`),t=t.replace(/^(#{1,6}[^\n|]+?)\s*(\|)/gm,`$1
|
|
183
|
+
$2`),t=t.replace(/([。;;::])\s*(\d+\.\s*)/g,`$1
|
|
184
|
+
$2`),t=t.replace(/([^\n\s])(\d+\.\s+)/g,`$1
|
|
185
|
+
$2`),t=t.replace(/([。;;::\.])\s*-(?!-)\s*/g,`$1
|
|
186
|
+
- `),t=t.replace(/([^\n\s-])-\s+/g,`$1
|
|
187
|
+
- `),t=t.replace(/^-(?!-)(\S)/gm,`- $1`),t=uq(t),t=t.replace(/\n{3,}/g,`
|
|
188
|
+
|
|
189
|
+
`),t.trim()}function pq(e){return e.map((t,n)=>{if(n%2==1)return t;let r=fq(t),i=n>0,a=n<e.length-1;return r?(i&&!r.startsWith(`
|
|
190
|
+
`)&&(r=`\n${r}`),a&&!r.endsWith(`
|
|
191
|
+
`)&&(r=`${r}\n`),r):i&&a?`
|
|
192
|
+
|
|
193
|
+
`:i||a?`
|
|
194
|
+
`:r})}function mq(e){if(!e)return e;let t=String(e).replace(/\r\n/g,`
|
|
195
|
+
`).replace(/\r/g,`
|
|
196
|
+
`).trim();return t=$K(t),t=iq(t),(t.match(/```/g)||[]).length%2==1&&(t=`${t}\n\`\`\``),pq(t.split("```")).join("```").trim()}var hq=`modulepreload`,gq=function(e,t){return new URL(e,t).href},_q={},J=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}))))}r=o(t.map(t=>{if(t=gq(t,n),t in _q)return;_q[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:hq,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.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)})},vq=v.lazy(()=>J(()=>import(`./CodeBlock-b4C7upmO.js`).then(e=>({default:e.CodeBlock})),[],import.meta.url)),yq=v.lazy(()=>J(()=>import(`./MermaidBlock-BEBN4Ksz.js`).then(e=>({default:e.MermaidBlock})),[],import.meta.url)),bq=v.lazy(()=>J(()=>import(`./MathMessageMarkdown-DbdW5A4_.js`).then(e=>({default:e.MathMessageMarkdown})),__vite__mapDeps([0,1,2,3,4]),import.meta.url));function xq(e){return/\$[^$]+\$|\$\$[^$]+\$\$/.test(e)}var Sq={h1({children:e}){return(0,O.jsx)(`h1`,{className:`mb-3.5 mt-5 text-[17px] font-semibold text-foreground`,children:e})},h2({children:e}){return(0,O.jsx)(`h2`,{className:`mb-2.5 mt-4.5 text-[15px] font-semibold text-foreground`,children:e})},h3({children:e}){return(0,O.jsx)(`h3`,{className:`mb-2 mt-3.5 text-[14px] font-semibold text-foreground`,children:e})},p({children:e}){return(0,O.jsx)(`p`,{className:`mb-2.5 min-w-0 break-words leading-[1.65] text-foreground`,children:e})},ul({children:e}){return(0,O.jsx)(`ul`,{className:`mb-3 list-disc space-y-1.5 pl-5 text-foreground`,children:e})},ol({children:e}){return(0,O.jsx)(`ol`,{className:`mb-3 list-decimal space-y-1.5 pl-8 text-foreground`,children:e})},li({children:e}){return(0,O.jsx)(`li`,{className:`min-w-0 break-words pl-1 leading-6 text-foreground`,children:e})},strong({children:e}){return(0,O.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e})},blockquote({children:e}){return(0,O.jsx)(`blockquote`,{className:`mb-3 border-l-2 border-border pl-4 text-text-secondary`,children:e})},code({className:e,children:t,...n}){let r=/language-(\w+)/.exec(e||``),i=String(t??``);if(!r&&!i.includes(`
|
|
197
|
+
`))return(0,O.jsx)(`code`,{className:`break-all font-mono text-[0.92em] text-text-primary before:content-none after:content-none`,...n,children:t});let a=r?r[1]:``;return a===`mermaid`?(0,O.jsx)(v.Suspense,{fallback:(0,O.jsx)(`div`,{className:`h-32 animate-pulse rounded bg-muted`}),children:(0,O.jsx)(yq,{chart:i})}):(0,O.jsx)(v.Suspense,{fallback:(0,O.jsx)(`pre`,{className:`p-4 text-sm`,children:i}),children:(0,O.jsx)(vq,{language:a,value:i})})},table({children:e,...t}){return(0,O.jsx)(`div`,{className:`mb-3 max-w-full overflow-x-auto rounded-lg border border-border`,children:(0,O.jsx)(`table`,{className:`w-full min-w-[36rem] table-auto border-collapse text-sm text-foreground`,...t,children:e})})},th({children:e,...t}){return(0,O.jsx)(`th`,{className:`break-words border-b border-border bg-muted/40 px-3 py-2 text-left align-top font-semibold text-foreground`,...t,children:e})},td({children:e,...t}){return(0,O.jsx)(`td`,{className:`break-words border-b border-border px-3 py-2 align-top text-text-secondary`,...t,children:e})},a({children:e,href:t,...n}){return(0,O.jsx)(`a`,{href:t,className:`text-primary hover:underline`,target:`_blank`,rel:`noopener noreferrer`,...n,children:e})}},Cq=v.memo(({content:e})=>{let t=mq(e);return(0,O.jsx)(`div`,{className:`max-w-none break-words text-[14px] leading-[1.65] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,children:(0,O.jsx)(GU,{remarkPlugins:[YK,QK],components:Sq,children:t})})}),wq=v.memo(({content:e})=>xq(e)?(0,O.jsx)(v.Suspense,{fallback:(0,O.jsx)(Cq,{content:e}),children:(0,O.jsx)(bq,{content:e})}):(0,O.jsx)(Cq,{content:e})),Tq=/^diff --git "?a\/(.+?)"? "?b\/(.+?)"?$/;function Eq(e){let t=[],n=new Map,r=null;for(let i of e.split(`
|
|
198
|
+
`)){let e=i.match(Tq);if(e){let a=e[2],o=n.get(a);if(o){o.lines.push(i),r=o;continue}r={oldPath:e[1],path:a,lines:[i]},n.set(a,r),t.push(r);continue}r?.lines.push(i)}return t}function Dq(e){let t=0,n=0;for(let r of e.lines)r.startsWith(`+`)&&!r.startsWith(`+++`)?t+=1:r.startsWith(`-`)&&!r.startsWith(`---`)&&(n+=1);return{added:t,removed:n}}function Oq(e){return/^diff --git /m.test(e)}function kq(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Aq(e){let t=kq(e.properties)||{},n=Array.isArray(e.required)?new Set(e.required.map(String)):new Set,r=[];for(let[e,i]of Object.entries(t)){let t=kq(i),a=String(t?.type||``).toLowerCase(),o=a===`string`||a===`number`||a===`boolean`||a===`array`?a:`unknown`,s=kq(t?.items),c=Array.isArray(t?.[`x-codex-options`])?t[`x-codex-options`].map(kq).map(e=>e?.label).filter(e=>typeof e==`string`):[],l=c.length?c:void 0;r.push({name:e,title:typeof t?.title==`string`?t.title:void 0,description:typeof t?.description==`string`?t.description:void 0,allowOther:t?.[`x-codex-is-other`]===!0,secret:t?.[`x-codex-is-secret`]===!0,type:o,required:n.has(e),enumValues:Array.isArray(t?.enum)?t.enum:Array.isArray(s?.enum)?s.enum:l})}return r}function jq({schema:e,values:t,onChange:n,disabled:r,onSubmit:i,onCancel:a}){let o=Aq(e),[s,c]=(0,v.useState)(``);return(0,O.jsxs)(`form`,{className:`mt-3`,"data-testid":`interaction-schema-form`,onKeyDown:e=>{e.key===`Enter`&&e.nativeEvent.isComposing&&e.preventDefault()},onSubmit:e=>{if(e.preventDefault(),!r){if(!o.every(e=>{let n=t[e.name];return!e.required||(Array.isArray(n)?n.length>0:String(n??``).trim().length>0)})){c(`请回答必填问题后再提交。`);return}c(``),i()}},children:[o.map(e=>(0,O.jsxs)(`div`,{className:`mb-2 block text-xs text-[var(--ksadk-interaction-muted)]`,children:[(0,O.jsxs)(`span`,{className:`mb-1 block font-medium`,children:[e.description||e.title||e.name,e.required?(0,O.jsx)(`span`,{className:`ml-0.5 text-rose-500`,children:`*`}):null]}),e.enumValues&&e.enumValues.length>0?(0,O.jsxs)(`div`,{className:`space-y-1`,"data-testid":`interaction-field-${e.name}`,children:[e.enumValues.map((i,a)=>{let o=e.type===`array`?Array.isArray(t[e.name])&&t[e.name].includes(i):t[e.name]===i;return(0,O.jsxs)(`label`,{className:`flex min-h-10 cursor-pointer items-center gap-2 rounded-xl px-2 text-sm text-[var(--ksadk-interaction-foreground)] hover:bg-[var(--ksadk-interaction-muted-background)]`,children:[(0,O.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-[var(--ksadk-interaction-muted-background)] text-xs text-[var(--ksadk-interaction-muted)]`,children:a+1}),(0,O.jsx)(`input`,{type:e.type===`array`?`checkbox`:`radio`,name:e.name,disabled:r,checked:!!o,onChange:r=>{let a=Array.isArray(t[e.name])?t[e.name]:[],o=e.type===`array`?r.target.checked?[...a,i]:a.filter(e=>e!==i):i;n({...t,[e.name]:o})},className:`h-4 w-4 accent-current`}),(0,O.jsx)(`span`,{children:String(i)})]},String(i))}),e.allowOther?(0,O.jsx)(`input`,{"aria-label":`${e.title||e.name}:自定义回答`,placeholder:`或填写自己的回答`,type:e.secret?`password`:`text`,disabled:r,value:e.type===`array`?(Array.isArray(t[e.name])?t[e.name]:[]).filter(t=>!e.enumValues.includes(t)).join(`
|
|
199
|
+
`):e.enumValues.includes(t[e.name])?``:String(t[e.name]??``),onChange:r=>{let i=r.target.value,a=(Array.isArray(t[e.name])?t[e.name]:[]).filter(t=>e.enumValues.includes(t));n({...t,[e.name]:e.type===`array`?[...a,...i.trim()?[i]:[]]:i})},className:`w-full rounded-lg border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-control-background)] px-3 py-2 text-sm text-[var(--ksadk-interaction-foreground)]`}):null]}):e.type===`boolean`?(0,O.jsx)(`input`,{type:`checkbox`,"data-testid":`interaction-field-${e.name}`,disabled:r,checked:!!t[e.name],onChange:r=>n({...t,[e.name]:r.target.checked}),className:`h-4 w-4`}):e.type===`number`?(0,O.jsx)(`input`,{type:`number`,"data-testid":`interaction-field-${e.name}`,disabled:r,value:t[e.name]===void 0?``:String(t[e.name]),onChange:r=>n({...t,[e.name]:r.target.value===``?void 0:Number(r.target.value)}),className:`w-full rounded-md border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-control-background)] px-2 py-1.5 text-sm text-foreground`}):(0,O.jsx)(`input`,{type:e.secret?`password`:`text`,"data-testid":`interaction-field-${e.name}`,disabled:r,value:String(t[e.name]??``),onChange:r=>n({...t,[e.name]:r.target.value}),className:`w-full rounded-md border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-control-background)] px-2 py-1.5 text-sm text-foreground`})]},e.name)),s?(0,O.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-rose-600`,children:s}):null,(0,O.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,O.jsx)(`button`,{type:`submit`,"data-testid":`interaction-submit`,disabled:r,className:`inline-flex min-h-8 items-center rounded-md bg-[var(--ksadk-interaction-primary-background)] px-3 py-1.5 text-xs font-semibold text-[var(--ksadk-interaction-primary-foreground)] disabled:cursor-not-allowed disabled:opacity-55`,children:`提交`}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`interaction-form-cancel`,disabled:r,onClick:a,className:`inline-flex min-h-8 items-center rounded-md px-3 py-1.5 text-xs font-medium text-slate-500 underline-offset-2 hover:underline disabled:cursor-not-allowed disabled:opacity-55 dark:text-slate-400`,children:`取消本次确认`})]})]})}function Mq({surfaceId:e,serializedMessages:t}){let{processMessages:n}=MO();return(0,v.useEffect)(()=>{n(JSON.parse(t))},[t,n]),(0,O.jsx)(Kte,{surfaceId:e,className:`w-full`,fallback:(0,O.jsx)(`div`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`界面内容暂不可用`}),loadingFallback:(0,O.jsx)(`div`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`正在加载界面`})})}function Nq({surfaceId:e,messages:t,onAction:n}){let r=e.startsWith(`input-`)?$te(t):null;if(r)return(0,O.jsxs)(`details`,{className:`mx-auto mb-3 w-full max-w-3xl px-6 text-sm text-muted-foreground`,"data-testid":`legacy-question-history`,children:[(0,O.jsxs)(`summary`,{className:`cursor-pointer`,children:[`历史提问 · `,r.length,` 个问题`]}),(0,O.jsx)(`ul`,{className:`mt-2 list-disc space-y-1 pl-5`,children:r.map((e,t)=>(0,O.jsx)(`li`,{children:e},t))})]});let i=JSON.stringify(t);return(0,O.jsx)(`div`,{className:`mb-3 w-full overflow-hidden rounded-lg border border-slate-200 bg-white p-3 shadow-sm dark:border-slate-700 dark:bg-slate-900`,children:(0,O.jsx)(Vte,{catalog:FO,onAction:n,children:(0,O.jsx)(Mq,{surfaceId:e,serializedMessages:i})},`${e}:${i}`)})}function Pq({a2ui:e,disabled:t,onSubmit:n,onCancel:r}){return(0,O.jsxs)(`div`,{className:`mt-3`,"data-testid":`interaction-a2ui-surface`,children:[(0,O.jsx)(Nq,{surfaceId:`interaction-${e.wireVersion}`,messages:e.messages,onAction:t?void 0:e=>{let t=e.userAction?.context||{};n(typeof t.payload==`object`&&t.payload!==null?t.payload:{...t})}}),t?null:(0,O.jsx)(`button`,{type:`button`,"data-testid":`interaction-a2ui-cancel`,onClick:r,className:`mt-1 inline-flex min-h-8 items-center rounded-md px-3 py-1.5 text-xs font-medium text-slate-500 underline-offset-2 hover:underline dark:text-slate-400`,children:`取消本次确认`})]})}function Fq(e){for(let t of e?.messages||[]){let e=t.inputSchema??t.input_schema??t.schema;if(typeof e==`object`&&e)return e}return null}function Iq(e){if(!e.expiresAt)return!1;let t=Date.parse(e.expiresAt);return Number.isFinite(t)&&t<=Date.now()}function Lq(e){let t=e.extensions.submit_error;return typeof t==`object`&&t&&`code`in t&&`message`in t?{code:String(t.code),message:String(t.message),retryable:!!(`retryable`in t&&t.retryable)}:null}function Rq(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function zq(e){let t=Rq(e);if(t)return t;if(typeof e!=`string`)return null;try{return Rq(JSON.parse(e))}catch{return null}}function Bq(e){return Array.isArray(e)?e.map(String).join(` `):typeof e==`string`?e:``}function Vq(e){let t=zq(e.extensions.detail),n=zq(e.extensions.arguments),r=t||n||{},i=e.title.replace(/^审批[::]\s*/,``).trim();return{operation:{command_execution:`命令执行`,file_change:`文件修改`,mcp_tool_call:`MCP 工具调用`}[i]||i,command:Bq(r.command??r.cmd),reason:Bq(r.reason??r.justification),cwd:Bq(r.cwd??r.workdir)}}var Hq={approved:`已同意`,rejected:`已拒绝`,submitted:`已提交`,cancelled:`已取消`,expired:`已过期`};function Uq({interactions:e,activeIndex:t,onSelectIndex:n,onRespond:r,localCatalog:i,className:a}){let[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)({}),u=e[Math.min(t,Math.max(e.length-1,0))];if(!u)return null;let d=Iq(u),f=Lq(u),p=Vq(u),m=d||u.status===`resolving`,h=gA(u.presentation?.a2ui,i),g=u.requestSchema??Fq(u.presentation?.a2ui)??null,_=u.kind===`approval`?`basic-controls`:h===`a2ui`?`a2ui`:h===`json-schema-form`&&g||u.requestSchema&&!u.presentation?`json-schema-form`:`basic-controls`,y=_===`json-schema-form`&&g||u.requestSchema,b=(e,t)=>{m||Promise.resolve(r({interactionId:u.interactionId,expectedRevision:u.revision,action:e,response:t,idempotencyKey:Xk(u.interactionId,u.revision)})).catch(()=>{})};return(0,O.jsx)(`div`,{"data-testid":`interaction-tray`,"data-slot":`interaction-tray`,"data-ui":`interaction-tray`,"data-interaction-status":u.status,"data-interaction-count":e.length,className:K(`mx-auto mb-2 w-full max-w-[64rem] px-3 sm:px-4`,a),children:(0,O.jsxs)(`div`,{"data-slot":`interaction-card`,className:`rounded-2xl border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-background)] px-3 py-3 text-[var(--ksadk-interaction-foreground)] shadow-sm`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-[var(--ksadk-interaction-muted)]`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,O.jsx)(PN,{className:`h-3.5 w-3.5 shrink-0`,strokeWidth:1.7,"aria-hidden":`true`}),(0,O.jsx)(`span`,{"data-testid":`interaction-tray-title`,children:u.title}),p.operation?(0,O.jsx)(`span`,{className:`truncate text-[11px] text-[var(--ksadk-interaction-muted)]`,children:p.operation}):null]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.length>1?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,"data-testid":`interaction-tray-prev`,disabled:t<=0,onClick:()=>n(Math.max(t-1,0)),className:`rounded p-1 transition hover:bg-[var(--ksadk-interaction-muted-background)] disabled:opacity-30`,"aria-label":`上一条待确认`,children:(0,O.jsx)(mN,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),(0,O.jsxs)(`span`,{"data-testid":`interaction-tray-count`,className:`min-w-10 text-center`,children:[t+1,` of `,e.length]}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`interaction-tray-next`,disabled:t>=e.length-1,onClick:()=>n(Math.min(t+1,e.length-1)),className:`rounded p-1 transition hover:bg-[var(--ksadk-interaction-muted-background)] disabled:opacity-30`,"aria-label":`下一条待确认`,children:(0,O.jsx)(hN,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]}):null,(0,O.jsx)(`button`,{type:`button`,"data-testid":`interaction-cancel`,disabled:m,onClick:()=>b(`cancel`,{}),className:`rounded p-1 transition hover:bg-[var(--ksadk-interaction-muted-background)] hover:text-[var(--ksadk-interaction-foreground)] disabled:opacity-30`,"aria-label":`取消本次确认`,children:(0,O.jsx)(cP,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]})]}),u.message===p.command?null:(0,O.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm font-medium leading-5 text-[var(--ksadk-interaction-foreground)]`,"data-testid":`interaction-tray-message`,children:u.message}),p.command||p.reason||p.cwd?(0,O.jsxs)(`div`,{"data-slot":`interaction-summary`,className:`mt-1.5 space-y-1 rounded-xl bg-[var(--ksadk-interaction-muted-background)] px-2.5 py-2 text-xs leading-5`,children:[p.command?(0,O.jsx)(`code`,{className:`block max-h-12 overflow-auto whitespace-pre-wrap break-all font-mono text-[var(--ksadk-interaction-foreground)]`,children:p.command}):null,p.reason?(0,O.jsx)(`p`,{className:`text-[var(--ksadk-interaction-muted)]`,children:p.reason}):null,p.cwd?(0,O.jsx)(`p`,{className:`truncate font-mono text-[11px] text-[var(--ksadk-interaction-muted)]`,title:p.cwd,children:p.cwd}):null]}):null,d?(0,O.jsxs)(`p`,{className:`mt-2 text-xs font-medium text-rose-600 dark:text-rose-400`,"data-testid":`interaction-tray-expired`,children:[`该确认已过期(`,Hq.expired,`),等待运行时继续处理。`]}):null,f?(0,O.jsxs)(`p`,{className:`mt-2 text-xs font-medium text-rose-600 dark:text-rose-400`,"data-testid":`interaction-tray-error`,children:[`提交失败(`,f.code,`):`,f.message,f.retryable?`,可重试。`:``]}):null,_===`a2ui`&&u.presentation?.a2ui?(0,O.jsx)(Pq,{a2ui:u.presentation.a2ui,disabled:m,onSubmit:e=>b(`submit`,e),onCancel:()=>b(`cancel`,{})}):_===`json-schema-form`&&y?(0,O.jsx)(jq,{schema:y,values:c,onChange:l,disabled:m,onSubmit:()=>b(`submit`,c),onCancel:()=>b(`cancel`,{})}):u.kind===`approval`?(0,O.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1`,"data-testid":`interaction-tray-basic`,children:[(0,O.jsxs)(`button`,{type:`button`,"data-testid":`interaction-approve`,disabled:m,onClick:()=>b(`approve`,{decision:`approve`}),className:`group flex min-h-9 w-full items-center gap-2.5 rounded-xl px-2.5 py-1.5 text-left text-sm font-medium text-[var(--ksadk-interaction-foreground)] transition hover:bg-[var(--ksadk-interaction-muted-background)] disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,O.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-[var(--ksadk-interaction-muted-background)] text-xs text-[var(--ksadk-interaction-muted)]`,children:`1`}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1`,children:`批准并继续`}),(0,O.jsx)(lN,{className:`h-3.5 w-3.5 text-[var(--ksadk-interaction-muted)] opacity-0 transition group-hover:opacity-100`,"aria-hidden":`true`})]}),(0,O.jsxs)(`button`,{type:`button`,"data-testid":`interaction-reject`,disabled:m,onClick:()=>b(`reject`,{decision:`reject`}),className:`group flex min-h-9 w-full items-center gap-2.5 rounded-xl px-2.5 py-1.5 text-left text-sm font-medium text-[var(--ksadk-interaction-foreground)] transition hover:bg-[var(--ksadk-interaction-muted-background)] disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,O.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-[var(--ksadk-interaction-muted-background)] text-xs text-[var(--ksadk-interaction-muted)]`,children:`2`}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1`,children:`拒绝`}),(0,O.jsx)(lN,{className:`h-3.5 w-3.5 text-[var(--ksadk-interaction-muted)] opacity-0 transition group-hover:opacity-100`,"aria-hidden":`true`})]}),(0,O.jsxs)(`label`,{className:`mt-0.5 flex min-w-0 items-center gap-2.5 rounded-xl bg-[var(--ksadk-interaction-muted-background)]/60 px-2.5 py-1.5`,children:[(0,O.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-control-background)] text-[var(--ksadk-interaction-muted)]`,children:(0,O.jsx)(HN,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),(0,O.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.nativeEvent.isComposing||!o.trim()||(e.preventDefault(),b(`cancel`,{feedback:o.trim()}))},placeholder:`告诉 Agent 要如何修改`,disabled:m,"data-testid":`interaction-tray-comment`,className:`h-8 min-w-0 flex-1 border-0 bg-transparent px-0 text-sm font-medium text-[var(--ksadk-interaction-foreground)] outline-none placeholder:text-[var(--ksadk-interaction-muted)] disabled:cursor-not-allowed disabled:opacity-55`}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`interaction-feedback-submit`,"aria-label":`提交修改意见`,disabled:m||!o.trim(),onClick:()=>b(`cancel`,{feedback:o.trim()}),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-[var(--ksadk-interaction-muted)] transition hover:bg-[var(--ksadk-interaction-control-background)] hover:text-[var(--ksadk-interaction-foreground)] disabled:opacity-30`,children:(0,O.jsx)(lN,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]})]}):(0,O.jsxs)(`div`,{className:`mt-2.5`,"data-testid":`interaction-tray-basic`,children:[(0,O.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.nativeEvent.isComposing||!o.trim()||(e.preventDefault(),b(`submit`,{value:o.trim()}))},placeholder:`输入回复`,disabled:m,"data-testid":`interaction-tray-comment`,className:`mb-2 h-8 w-full rounded-lg border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-control-background)] px-2.5 text-sm text-[var(--ksadk-interaction-foreground)] outline-none placeholder:text-[var(--ksadk-interaction-muted)] focus:ring-1 focus:ring-[var(--ksadk-interaction-focus-ring)]`}),(0,O.jsx)(`div`,{className:`flex justify-end gap-2`,children:(0,O.jsx)(`button`,{type:`button`,"data-testid":`interaction-submit`,disabled:m,onClick:()=>b(`submit`,{value:o}),className:`inline-flex h-8 items-center gap-1.5 rounded-lg bg-[var(--ksadk-interaction-primary-background)] px-3 text-xs font-medium text-[var(--ksadk-interaction-primary-foreground)] shadow-sm transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-55`,children:`提交`})})]}),u.status===`resolving`?(0,O.jsx)(`p`,{className:`mt-2 text-xs text-[var(--ksadk-interaction-muted)]`,children:`正在提交,请稍候…`}):null]})})}function Wq({outcome:e}){return(0,O.jsx)(`span`,{className:K(`rounded border px-1.5 py-0.5 text-xs font-medium`,e===`approved`?`border-emerald-300 text-emerald-700 dark:border-emerald-900 dark:text-emerald-300`:e===`rejected`?`border-rose-300 text-rose-700 dark:border-rose-900 dark:text-rose-300`:`border-slate-300 text-slate-600 dark:border-slate-700 dark:text-slate-300`),children:Hq[e]||e})}function Gq(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function Kq(e){let t=e?.properties;return typeof t!=`object`||!t?[]:Object.keys(t)}function qq({interaction:e}){if(e.outcome===`cancelled`||e.status===`cancelled`)return null;let t=e.status===`resolved`||e.status===`expired`,n=Kq(e.requestSchema);return(0,O.jsxs)(`div`,{"data-testid":`interaction-history-anchor`,"data-interaction-id":e.interactionId,"data-interaction-status":e.status,className:`mt-2 rounded-lg border border-border bg-muted/55 px-3 py-2 text-xs text-text-secondary`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.title}),(0,O.jsx)(Wq,{outcome:e.outcome||e.status})]}),t?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`mt-1 leading-relaxed`,children:[e.actor?(0,O.jsxs)(`span`,{children:[`操作人:`,e.actor,` · `]}):null,e.resolvedAt?(0,O.jsxs)(`span`,{children:[`决定时间:`,Gq(e.resolvedAt),` · `]}):null,(0,O.jsx)(`span`,{"data-testid":`interaction-history-response-summary`,children:e.responseSummary||`响应内容已脱敏`})]}),(0,O.jsxs)(`details`,{"data-testid":`interaction-history-detail`,className:`mt-1`,children:[(0,O.jsx)(`summary`,{className:`cursor-pointer select-none text-text-muted hover:text-text-primary`,children:`查看确认快照`}),(0,O.jsxs)(`div`,{"data-testid":`interaction-history-snapshot`,className:`mt-1 rounded border border-border bg-card px-2 py-1.5 leading-relaxed text-card-foreground`,children:[(0,O.jsxs)(`div`,{children:[`操作者:`,(0,O.jsx)(`span`,{"data-testid":`interaction-history-actor-ref`,children:e.actor||`—`})]}),(0,O.jsxs)(`div`,{children:[`决定时间:`,Gq(e.resolvedAt)||`—`]}),(0,O.jsxs)(`div`,{children:[`关键参数:`,n.length>0?(0,O.jsx)(`span`,{"data-testid":`interaction-history-schema-keys`,children:n.join(`、`)}):(0,O.jsx)(`span`,{children:`无结构化参数`})]})]})]})]}):(0,O.jsxs)(`div`,{className:`mt-1`,children:[`状态:`,e.status===`pending`?`待处理(见输入区确认面板)`:`处理中…`]})]})}function Jq({summary:e,children:t,defaultOpen:n=!1,streaming:r=!1}){let[i,a]=(0,v.useState)(n);return(0,O.jsxs)(`div`,{className:`mb-1.5`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-1.5 rounded px-1 py-1 text-left text-[13px] text-slate-500 transition-colors hover:bg-slate-100/70 dark:text-slate-400 dark:hover:bg-slate-800/40`,children:[r?(0,O.jsx)(MN,{className:`h-3.5 w-3.5 animate-spin text-slate-400`}):(0,O.jsx)(pN,{className:K(`h-3.5 w-3.5 text-slate-400 transition-transform`,i&&`rotate-90`)}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})]}),i&&(0,O.jsx)(`div`,{className:`mt-1.5 border-l border-slate-200 pl-3.5 dark:border-slate-700/60`,children:t})]})}function Yq({block:e}){let[t,n]=(0,v.useState)(!1),r=e.status===`streaming`,i=e.content.length,a=`${e.id}-thinking-detail`;return(0,O.jsxs)(`div`,{className:`mb-1.5 min-w-0`,children:[(0,O.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":a,onClick:()=>n(e=>!e),className:`inline-flex max-w-full items-center gap-1.5 rounded px-1 py-1 text-left text-[13px] leading-5 text-slate-400 transition-colors hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300`,children:[!r&&(0,O.jsx)(QN,{className:`h-3.5 w-3.5 shrink-0`}),(0,O.jsx)(`span`,{className:K(`min-w-0 truncate`,r&&`waiting-thinking-text`),"data-testid":r?`thinking-indicator`:void 0,role:r?`status`:void 0,children:r?`正在思考…`:`已思考`}),!r&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`span`,{className:`text-slate-300 dark:text-slate-600`,children:`·`}),(0,O.jsxs)(`span`,{className:`font-mono text-xs text-slate-400 dark:text-slate-500`,children:[i,` 字`]})]}),(0,O.jsx)(pN,{className:K(`h-3.5 w-3.5 shrink-0 transition-transform`,t&&`rotate-180`)})]}),t&&e.content&&(0,O.jsx)(`div`,{id:a,className:`custom-scrollbar mt-1.5 max-h-[min(46vh,28rem)] overflow-y-auto border-l border-slate-200/80 pl-3.5 text-[12px] leading-5 text-slate-500 dark:border-slate-700/60 dark:text-slate-400 [&_h1]:!mb-2 [&_h1]:!mt-3 [&_h1]:!text-[13px] [&_h2]:!mb-1.5 [&_h2]:!mt-3 [&_h2]:!text-[12px] [&_h3]:!mb-1 [&_h3]:!mt-2.5 [&_h3]:!text-[12px] [&_li]:!text-[12px] [&_li]:!leading-5 [&_p]:!my-1.5 [&_p]:!text-[12px] [&_p]:!leading-5 [&_p]:!text-slate-500 dark:[&_p]:!text-slate-400 [&_pre]:!my-1.5`,children:(0,O.jsx)(wq,{content:e.content})})]})}function Xq({block:e,tool:t,isStreaming:n,interactionRecord:r,onRespondToApproval:i,onRespondToAguiApproval:a}){let o=t?.status??e.status,s=t?.args??e.args,c=t?.output??e.output,l=e.extra||{},u=(r?.outcome===`cancelled`||r?.outcome===`expired`||r?.status===`cancelled`||r?.status===`expired`?`cancelled`:r?.outcome===`rejected`?`rejected`:r?.outcome===`approved`?`approved`:void 0)||l.approvalStatus||t?.approvalStatus,d=l.approvalRequestId||t?.approvalRequestId,f=l.approvalMessage||t?.approvalMessage,p=l.approvalProtocol||t?.approvalProtocol,m=l.previousResponseId||t?.previousResponseId,h=o===`running`,g=u===`cancelled`||u===`rejected`,_=o===`error`&&!g,v=o===`paused`,y=_?`执行失败`:u===`pending`?`等待确认`:u===`rejected`?`已拒绝`:u===`cancelled`?`已取消`:h?u===`approved`?`已授权 · 执行中`:`正在运行`:u===`approved`?`已授权`:v?`已暂停`:`已完成`,b=_?`text-rose-500 dark:text-rose-400`:v?`text-amber-500 dark:text-amber-400`:h?`text-slate-500 dark:text-slate-400`:`text-slate-400 dark:text-slate-500`;return(0,O.jsx)(Jq,{streaming:h&&!s,defaultOpen:u===`pending`||v,summary:(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(sP,{className:K(`h-3.5 w-3.5 shrink-0`,b)}),(0,O.jsx)(`span`,{className:b,children:y}),(0,O.jsx)(`span`,{className:`truncate font-medium text-slate-600 dark:text-slate-300`,children:e.toolName}),h&&s&&(0,O.jsx)(`span`,{className:`ml-0.5 animate-pulse text-slate-400`,children:`…`})]}),children:(0,O.jsxs)(`div`,{className:`flex flex-col gap-2.5 py-1 text-[13px]`,children:[d&&u===`pending`&&!r&&(0,O.jsxs)(`section`,{"data-slot":`tool-approval-card`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-[var(--ksadk-approval-border)] bg-[var(--ksadk-approval-background)] px-2.5 py-2 font-sans text-[12px] text-[var(--ksadk-approval-foreground)] shadow-[0_1px_2px_rgba(15,23,42,0.03)]`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--ksadk-approval-foreground)]`,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`shrink-0 font-medium`,children:`需要确认`}),(0,O.jsx)(`span`,{className:`min-w-0 truncate opacity-75`,children:f||`允许后将执行此工具调用。`})]}),(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,O.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>p===`ag-ui`?a?.({interruptId:d||``,approve:!0}):i?.({approvalRequestId:d||``,approve:!0,previousResponseId:m}),className:`inline-flex h-7 items-center rounded-md bg-primary px-2.5 text-[12px] font-medium text-primary-foreground transition hover:bg-primary/90 disabled:opacity-55`,children:`允许执行`}),(0,O.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>p===`ag-ui`?a?.({interruptId:d||``,approve:!1}):i?.({approvalRequestId:d||``,approve:!1,previousResponseId:m}),className:`inline-flex h-7 items-center rounded-md px-2 text-[12px] font-medium text-slate-500 transition hover:bg-slate-100 hover:text-rose-600 disabled:opacity-55 dark:text-slate-400 dark:hover:bg-slate-800`,children:`拒绝`})]})]}),d&&u===`pending`&&r?(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5 font-sans text-xs text-slate-500 dark:text-slate-400`,children:[(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400`,"aria-hidden":`true`}),`请在输入区确认面板中操作。`]}):null,d&&u&&u!==`pending`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5 font-sans text-xs text-slate-500 dark:text-slate-400`,children:[(0,O.jsx)(`span`,{children:u===`approved`?`已授权`:u===`cancelled`?`已取消`:`已拒绝`}),u===`approved`&&h?(0,O.jsx)(`span`,{children:`· 工具执行中`}):null,u===`approved`&&_?(0,O.jsx)(`span`,{children:`· 工具执行失败`}):null]}),s?(0,O.jsx)(tJ,{label:`入参`,value:s,tone:`input`}):null,c&&!g?Zq(e.toolName,c,_):null]})})}function Zq(e,t,n){if(Oq(t))return(0,O.jsx)(Qq,{output:t});let r=e.toLowerCase();if(r.includes(`web_search`)||r.includes(`search`)){let e=$q(t);if(e.length>0)return(0,O.jsx)(eJ,{sources:e})}return(0,O.jsx)(tJ,{label:`输出`,value:t,tone:n?`error`:`output`})}function Qq({output:e}){let t=Eq(e),[n,r]=(0,v.useState)(!1),i=n?t:t.slice(0,3);return(0,O.jsxs)(`div`,{className:`my-2 overflow-hidden rounded-xl border border-border bg-background`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs font-medium text-text-secondary`,children:[(0,O.jsx)(EN,{className:`h-3.5 w-3.5 text-primary`}),(0,O.jsxs)(`span`,{children:[`改动 `,t.length,` 个文件`]})]}),(0,O.jsx)(`div`,{className:`flex flex-col`,children:i.map(e=>{let{added:t,removed:n}=Dq(e);return(0,O.jsxs)(`div`,{className:`group/file-change-row flex min-w-0 items-center gap-2 px-3 py-2 text-sm transition-colors hover:bg-muted`,children:[(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[13px] text-text-primary`,children:e.path}),(0,O.jsxs)(`span`,{className:`flex-shrink-0 text-[11px] font-mono`,children:[(0,O.jsxs)(`span`,{className:`text-emerald-600`,children:[`+`,t]}),` `,(0,O.jsxs)(`span`,{className:`text-rose-500`,children:[`−`,n]})]})]},e.path)})}),t.length>3?(0,O.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full items-center justify-center gap-1 border-t border-border py-1.5 text-xs text-text-muted transition hover:bg-muted hover:text-text-primary`,children:n?`收起`:`展开剩余 ${t.length-3} 个文件`}):null]})}function $q(e){try{let t=JSON.parse(e),n=Array.isArray(t)?t:t?.results??t?.sources??[];return Array.isArray(n)?n.map(e=>{let t=e,n=String(t?.url??t?.link??t?.href??``),r=String(t?.title??t?.name??n);return n?{url:n,title:r}:null}).filter(e=>e!==null):[]}catch{return[]}}function eJ({sources:e}){return(0,O.jsx)(`div`,{className:`mt-2 flex min-w-0`,children:(0,O.jsxs)(`span`,{className:`group/web-search-sources relative inline-flex min-w-0`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md border border-border bg-surface px-2 text-xs text-text-secondary transition-colors hover:bg-muted hover:text-text-primary`,children:[(0,O.jsx)(xN,{className:`h-3.5 w-3.5 shrink-0`,strokeWidth:1.7}),(0,O.jsxs)(`span`,{children:[`来源 · `,e.length]})]}),(0,O.jsx)(`span`,{className:`absolute bottom-full left-0 z-30 hidden max-w-[calc(100vw-3rem)] pb-1 group-hover/web-search-sources:block`,children:(0,O.jsx)(`span`,{className:`block w-[min(26rem,calc(100vw-3rem))] rounded-xl border border-border bg-popover p-2 text-left text-text-primary shadow-2xl`,children:(0,O.jsx)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:e.map((e,t)=>(0,O.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 text-sm leading-5 text-text-secondary transition-colors hover:bg-muted hover:text-text-primary`,children:[(0,O.jsx)(xN,{className:`h-3.5 w-3.5 shrink-0`,strokeWidth:1.7}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title})]},`${e.url}-${t}`))})})})]})})}function tJ({label:e,tone:t,value:n}){return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-wide text-slate-400`,children:e}),(0,O.jsx)(`pre`,{className:K(`custom-scrollbar max-h-60 overflow-auto rounded-lg px-3 py-2 text-[12.5px] leading-relaxed whitespace-pre-wrap break-all`,t===`error`?`bg-rose-50/60 text-rose-700 dark:bg-rose-950/20 dark:text-rose-200`:t===`output`?`bg-emerald-50/40 text-emerald-800 dark:bg-emerald-950/20 dark:text-emerald-200`:`bg-slate-50 text-slate-700 dark:bg-slate-900/40 dark:text-slate-200`),children:n})]})}function nJ({block:e}){return e.content?(0,O.jsx)(`div`,{className:`w-full break-words py-0.5 text-[14px] leading-[1.65]`,children:(0,O.jsx)(wq,{content:e.content})}):null}function rJ({message:e,isStreaming:t,onRespondToApproval:n,onRespondToAguiApproval:r,interactionRecords:i,className:a}){let o=e.blocks??[];return(0,O.jsx)(`div`,{className:K(`mb-3 min-w-0`,a),"data-slot":`processing-blocks`,children:o.map(a=>{if(a.type===`thinking`)return(0,O.jsx)(Yq,{block:a},a.id);if(a.type===`tool`){let o=a.extra||{},s=String(o.approvalRequestId||e.tools?.[a.toolName]?.approvalRequestId||``),c=String(o.callId||o.call_id||``),l=s?i?.find(e=>e.interactionId===s):c?i?.find(e=>String(e.extensions.call_id||``)===c):void 0;return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(Xq,{block:a,tool:e.tools?.[a.toolName],isStreaming:t,interactionRecord:l,onRespondToApproval:n,onRespondToAguiApproval:r}),l?(0,O.jsx)(qq,{interaction:l}):null]},a.id)}return(0,O.jsx)(nJ,{block:a},a.id)})})}function iJ({onRetry:e}){let t=k(e=>e.banner);if(!t)return null;let n=t.kind===`rate_limited`?(0,O.jsx)(aJ,{message:t.message,retryAfterSec:t.retryAfterSec},t.createdAt||`${t.sessionId||``}:${t.retryAfterSec||0}`):null,r={rate_limited:{icon:(0,O.jsx)(lP,{className:`h-4 w-4 text-neutral-500`}),bg:`border-neutral-200/70 bg-neutral-50/70 dark:border-neutral-900/40 dark:bg-neutral-950/20`,text:`text-neutral-700 dark:text-neutral-200`,label:n},network:{icon:(0,O.jsx)(MN,{className:`h-4 w-4 animate-spin text-text-secondary`}),bg:`border-border/70 bg-muted/60`,text:`text-text-secondary`,label:t.message||`网络异常,正在重连…`},error:{icon:(0,O.jsx)(oP,{className:`h-4 w-4 text-rose-500`}),bg:`border-rose-200/70 bg-rose-50/70 dark:border-rose-900/40 dark:bg-rose-950/20`,text:`text-rose-600 dark:text-rose-300`,label:t.message||`运行失败,请重试`}}[t.kind];return(0,O.jsxs)(`div`,{className:K(`mx-auto mb-3 flex w-full max-w-3xl items-center gap-2.5 rounded-xl border px-3.5 py-2.5 text-sm shadow-sm`,r.bg,r.text),role:`status`,children:[r.icon,(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.label}),t.kind===`error`&&e?(0,O.jsxs)(`button`,{type:`button`,onClick:e,className:`flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium text-rose-600 transition hover:bg-rose-100 dark:text-rose-300 dark:hover:bg-rose-950/40`,children:[(0,O.jsx)(qN,{className:`h-3 w-3`}),`重试`]}):null]})}function aJ({message:e,retryAfterSec:t}){let[n,r]=(0,v.useState)(t||0);return(0,v.useEffect)(()=>{if(!t)return;let e=setInterval(()=>{r(e=>e>0?e-1:0)},1e3);return()=>clearInterval(e)},[t]),n>0?`${e}(${n}s 后可重试)`:e}async function oJ(e,t=globalThis){let n=String(e??``),r=t?.navigator;if(r?.clipboard?.writeText)try{return await r.clipboard.writeText(n),!0}catch{}let i=t?.document,a=i?.body;if(!i?.createElement||!a?.appendChild||!a?.removeChild)return!1;let o=i.createElement(`textarea`);o.value=n,o.setAttribute?.(`readonly`,``),o.style&&(o.style.position=`fixed`,o.style.top=`0`,o.style.left=`-9999px`,o.style.opacity=`0`,o.style.pointerEvents=`none`);let s=i.activeElement;a.appendChild(o),o.focus?.(),o.select?.(),o.setSelectionRange?.(0,n.length);try{return typeof i.execCommand==`function`?!!i.execCommand(`copy`):!1}finally{a.removeChild(o),s?.focus?.()}}function sJ(e,t,n){return Math.max(t,Math.min(n,e))}function cJ({items:e=[],scrollTop:t=0,viewportHeight:n=0,overscan:r=4,defaultItemHeight:i=120,measuredHeights:a=new Map,getItemKey:o=(e,t)=>e?.id||String(t)}={}){let s=Math.max(0,Number(n)||0),c=Math.max(0,Number(t)||0),l=Math.max(0,Number(r)||0),u=Math.max(1,Number(i)||120);if(!e.length)return{startIndex:0,endIndex:0,offsetTop:0,totalHeight:0,visibleItems:[]};let d=e.map((e,t)=>{let n=o(e,t),r=Number(a.get(n));return Number.isFinite(r)&&r>0?r:u}),f=Array(e.length),p=0;for(let t=0;t<e.length;t+=1)f[t]=p,p+=d[t];let m=p,h=c+s,g=0;for(;g<e.length&&f[g]+d[g]<=c;)g+=1;let _=g;for(;_<e.length&&f[_]<h;)_+=1;return g=sJ(g-l,0,e.length),_=sJ(Math.max(g+1,_+l),0,e.length),{startIndex:g,endIndex:_,offsetTop:f[g]||0,totalHeight:m,visibleItems:e.slice(g,_).map((e,t)=>{let n=g+t;return{index:n,item:e,top:f[n]||0,height:d[n]||u}})}}function lJ({scrollHeight:e,scrollTop:t,clientHeight:n}){return Math.max(0,e-t-n)}function uJ(e){return e.scrollHeight>e.clientHeight+1&&lJ(e)>96}function dJ(e){return String(e?.runId||e?.invocationId||``).trim()}function fJ(e,t){if(e?.role!==`model`||t.role!==`model`)return!1;let n=dJ(e);return!!(n&&n===dJ(t))}var pJ=140,mJ=4;function hJ(e){let t=String(e||``).trim().toLowerCase();return t===`elevated`?`高风险`:t===`always`?`始终确认`:t===`confirm`?`需确认`:e||``}function gJ(e){return String(e||``).trim().toLowerCase()===`elevated`?`border-[var(--ksadk-approval-elevated-border)] bg-[var(--ksadk-approval-elevated-background)] text-[var(--ksadk-approval-elevated-foreground)]`:`border-[var(--ksadk-approval-border)] bg-[var(--ksadk-approval-background)] text-[var(--ksadk-approval-foreground)]`}function _J({messageId:e,top:t,onMeasure:n,children:r}){let i=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{let r=i.current;if(!r)return;let a=()=>n(e,r.offsetHeight,t);if(a(),typeof ResizeObserver>`u`)return;let o=new ResizeObserver(a);return o.observe(r),()=>o.disconnect()},[e,n,t]),(0,O.jsx)(`div`,{ref:i,style:{position:`absolute`,top:t,left:0,right:0},children:r})}function vJ({agentName:e}){return(0,O.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[50vh] px-4`,children:[(0,O.jsx)(`div`,{className:`mb-6 h-16 w-16 rounded-2xl bg-gradient-to-br from-blue-500 to-indigo-600
|
|
200
|
+
flex items-center justify-center shadow-lg shadow-blue-500/20`,children:(0,O.jsx)(dN,{className:`h-8 w-8 text-white`})}),(0,O.jsx)(`h2`,{className:`text-xl font-semibold text-slate-900 dark:text-slate-50`,children:`有什么我可以帮您的吗?`}),(0,O.jsxs)(`p`,{className:`mt-2 text-sm text-slate-500`,children:[`我是 `,e,`,由 Ksyun AgentEngine 驱动`]})]})}function yJ(){return(0,O.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[44rem] flex-col gap-5 px-2 py-8`,"aria-label":`正在加载会话历史`,children:[(0,O.jsx)(`div`,{className:`h-4 w-28 animate-pulse rounded bg-slate-200/80 dark:bg-slate-800`}),(0,O.jsx)(`div`,{className:`h-20 w-4/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,O.jsx)(`div`,{className:`ml-auto h-12 w-3/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,O.jsx)(`div`,{className:`h-16 w-11/12 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`})]})}function bJ({attachments:e,isMobile:t,onOpenAttachmentPreview:n}){return(0,O.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-3`,children:e.map((e,r)=>e.type.startsWith(`image/`)?e.url?(0,O.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:K(`group relative overflow-hidden rounded-xl border border-slate-200 shadow-sm dark:border-slate-700`,t?`w-full max-w-full`:`max-w-[200px]`),children:(0,O.jsx)(`img`,{src:e.url,alt:e.name,className:K(`object-cover transition group-hover:scale-[1.02]`,t?`max-h-[16rem] w-full max-w-full`:`max-h-[200px] max-w-[200px]`)})},`${e.name}-${r}`):(0,O.jsx)(`div`,{className:K(`flex items-center justify-center rounded-xl border border-dashed border-slate-300 bg-slate-50 px-4 text-sm text-slate-500 dark:border-slate-700 dark:bg-slate-900/40 dark:text-slate-400`,t?`h-28 w-full`:`h-[120px] w-[200px]`),children:e.name},`${e.name}-${r}`):(0,O.jsxs)(`div`,{className:K(`flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-100 px-3 py-2 shadow-sm dark:border-slate-700 dark:bg-slate-800`,t?`w-full max-w-full`:`w-max max-w-full`),children:[(0,O.jsx)(VN,{className:`h-4 w-4 flex-shrink-0 text-blue-500`}),e.url?(0,O.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`truncate text-sm text-slate-700 hover:underline dark:text-slate-300`,title:e.name,children:e.name}):(0,O.jsx)(`span`,{className:`truncate text-sm text-slate-700 dark:text-slate-300`,title:e.name,children:e.name})]},`${e.name}-${r}`))})}function xJ({message:e}){return(0,O.jsx)(`div`,{className:`w-full px-0 py-2 sm:px-4`,children:(0,O.jsxs)(`div`,{className:`mx-auto max-w-3xl rounded-xl border border-neutral-200/70 bg-neutral-50/60 px-4 py-3 text-sm text-neutral-600 dark:border-neutral-800 dark:bg-neutral-900/40 dark:text-neutral-300`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.status===`running`?(0,O.jsx)(KN,{className:`h-4 w-4 animate-spin text-neutral-600 dark:text-neutral-300`}):e.status===`failed`?(0,O.jsx)(gN,{className:`h-4 w-4 text-rose-600 dark:text-rose-400`}):(0,O.jsx)(fN,{className:`h-4 w-4 text-emerald-600 dark:text-emerald-400`}),(0,O.jsx)(`span`,{children:e.content})]}),e.compactedUntilSeqId?(0,O.jsxs)(`div`,{className:`mt-1 text-xs text-neutral-700/80 dark:text-neutral-200/80`,children:[`已折叠到会话事件 #`,e.compactedUntilSeqId]}):null,e.summary?(0,O.jsxs)(`details`,{className:`mt-3 rounded-xl border border-neutral-200/80 bg-white/70 px-3 py-2 dark:border-neutral-900/60 dark:bg-slate-950/40`,children:[(0,O.jsx)(`summary`,{className:`cursor-pointer select-none text-xs font-medium text-neutral-800 dark:text-neutral-200`,children:`查看压缩摘要`}),(0,O.jsx)(`div`,{className:`mt-2 text-[13px] leading-relaxed text-slate-700 dark:text-slate-200`,children:(0,O.jsx)(wq,{content:e.summary})})]}):null]})})}function SJ({label:e,tone:t,value:n}){let[r,i]=(0,v.useState)(`idle`),a=kA(n);(0,v.useEffect)(()=>{if(r===`idle`)return;let e=window.setTimeout(()=>i(`idle`),1600);return()=>window.clearTimeout(e)},[r]);let o=async()=>{i(await oJ(a)?`copied`:`failed`)};return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,O.jsx)(`div`,{className:K(`text-xs font-semibold uppercase`,t===`input`?`text-blue-500`:t===`error`?`text-rose-500`:`text-emerald-500`),children:e}),(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{o()},className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[11px] font-medium text-slate-500 transition hover:bg-white hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,children:[r===`copied`?(0,O.jsx)(fN,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,O.jsx)(yN,{className:`h-3.5 w-3.5`}),r===`copied`?`已复制`:r===`failed`?`复制失败`:`复制`]})]}),(0,O.jsx)(`div`,{className:`custom-scrollbar max-h-[220px] overflow-y-auto whitespace-pre-wrap break-words rounded-xl border border-slate-200/30 bg-white/70 p-3 text-slate-600 shadow-sm dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 sm:max-h-[300px]`,children:a})]})}function CJ({isLastMessage:e,isStreaming:t,message:n,onDeleteFeedback:r,onSubmitFeedback:i,alwaysVisible:a=!1}){let[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(n.feedback?.comment||``),u=sM(n,t,e),d=!!n.feedback?.pending,f=n.feedback?.rating,p=async()=>{let e=n.content||``;e&&oJ(e)};return u?(0,O.jsxs)(`div`,{className:K(`mt-2 flex flex-col gap-2 transition-opacity duration-150 focus-within:opacity-100`,a?`opacity-100`:`opacity-0 group-hover:opacity-100`),children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-text-muted`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>{p()},className:`inline-flex items-center gap-1 rounded-full px-2 py-1 font-medium text-text-secondary transition hover:bg-muted hover:text-text-primary`,title:`复制`,children:(0,O.jsx)(yN,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`span`,{className:`text-text-muted/60`,children:`·`}),(0,O.jsx)(`span`,{className:`font-medium`,children:`本次回复有帮助吗?`}),(0,O.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>i({message:n,rating:`up`,comment:``}),className:K(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,f===`up`?`border-primary/30 bg-primary/10 text-primary`:`border-border bg-background text-text-secondary hover:border-primary/30 hover:text-primary`),children:[(0,O.jsx)(rP,{className:`h-3.5 w-3.5`}),`有帮助`]}),(0,O.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>{l(n.feedback?.comment||``),s(e=>!e)},className:K(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,f===`down`?`border-rose-300 bg-rose-50 text-rose-600 dark:border-rose-900/70 dark:bg-rose-950/30 dark:text-rose-300`:`border-border bg-background text-text-secondary hover:border-rose-300 hover:text-rose-600`),children:[(0,O.jsx)(nP,{className:`h-3.5 w-3.5`}),`需改进`]}),n.feedback?(0,O.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>r(n),className:`inline-flex items-center gap-1 rounded-full border border-transparent px-2 py-1 font-medium text-slate-400 transition hover:border-slate-200 hover:text-slate-700 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:border-slate-800 dark:hover:text-slate-200`,children:[(0,O.jsx)(iP,{className:`h-3.5 w-3.5`}),`删除反馈`]}):null,d?(0,O.jsx)(`span`,{className:`text-slate-400`,children:`提交中…`}):null]}),o?(0,O.jsxs)(`div`,{className:`max-w-xl rounded-2xl border border-rose-100 bg-rose-50/60 p-3 shadow-sm dark:border-rose-900/60 dark:bg-rose-950/20`,children:[(0,O.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),placeholder:`可以补充哪里不准确、缺失或不符合预期。`,className:`min-h-[84px] w-full resize-y rounded-xl border border-rose-100 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition placeholder:text-slate-400 focus:border-rose-300 focus:ring-2 focus:ring-rose-100 dark:border-rose-900/70 dark:bg-slate-950 dark:text-slate-100 dark:focus:border-rose-700 dark:focus:ring-rose-950`}),(0,O.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded-xl px-3 py-1.5 text-xs font-semibold text-slate-500 transition hover:bg-white hover:text-slate-800 dark:text-slate-400 dark:hover:bg-slate-950 dark:hover:text-slate-100`,children:`取消`}),(0,O.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>{i({message:n,rating:`down`,comment:c}),s(!1)},className:`rounded-xl bg-rose-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-rose-500 disabled:cursor-not-allowed disabled:opacity-60`,children:`提交点踩`})]})]}):f===`down`&&n.feedback?.comment?(0,O.jsxs)(`div`,{className:`max-w-xl rounded-xl border border-rose-100 bg-rose-50/50 px-3 py-2 text-xs text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/20 dark:text-rose-200`,children:[`反馈:`,n.feedback.comment]}):null,n.feedback?.error?(0,O.jsx)(`div`,{className:`text-xs text-rose-600 dark:text-rose-300`,children:n.feedback.error}):null]}):null}function wJ({agentName:e,isMobile:t,isStreaming:n,isLastMessage:r,showAgentHeader:i,message:a,onDeleteFeedback:o,onOpenAttachmentPreview:s,onRespondToApproval:c,onRespondToAguiApproval:l,onSubmitFeedback:u,onSubmitAguiAction:d,interactionRecords:f}){if(a.role===`user`)return(0,O.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,O.jsxs)(`div`,{className:`max-w-[80%] rounded-2xl bg-muted px-3 py-2 text-[14px] leading-relaxed text-foreground`,children:[a.attachments?.length?(0,O.jsx)(bJ,{attachments:a.attachments,isMobile:t,onOpenAttachmentPreview:s}):null,a.content]})});if(a.role===`a2ui`&&a.aguiActivity)return(0,O.jsx)(Nq,{surfaceId:a.aguiActivity.surfaceId,messages:a.aguiActivity.messages,onAction:d});let p=n&&r&&!a.content;return(0,O.jsxs)(`div`,{className:`group mx-auto mb-3 w-full max-w-[60rem] px-2 sm:px-4`,children:[i?(0,O.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs text-text-muted`,children:[(0,O.jsx)(dN,{className:`w-3.5 h-3.5`}),(0,O.jsx)(`span`,{children:e})]}):null,a.attachments?.length?(0,O.jsx)(bJ,{attachments:a.attachments,isMobile:t,onOpenAttachmentPreview:s}):null,a.blocks?.length?(0,O.jsx)(rJ,{message:a,isStreaming:n,onRespondToApproval:c,interactionRecords:f,onRespondToAguiApproval:l}):(0,O.jsxs)(O.Fragment,{children:[a.reasoning?(0,O.jsxs)(`details`,{className:`group/details mb-3 overflow-hidden rounded-md border border-slate-200/80 bg-slate-50/60 text-sm text-slate-600 transition-colors open:bg-white dark:border-slate-700/80 dark:bg-slate-900/40 dark:text-slate-300 dark:open:bg-slate-950/30`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 font-medium outline-none marker:hidden`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[p?null:(0,O.jsx)(fN,{className:`h-4 w-4 text-slate-400`}),(0,O.jsx)(`span`,{className:K(`truncate`,p&&`waiting-thinking-text`),"data-testid":p?`legacy-thinking-indicator`:void 0,role:p?`status`:void 0,children:p?`正在思考…`:`思考过程`}),p?null:(0,O.jsx)(`span`,{className:`rounded-full bg-slate-200/70 px-2 py-0.5 text-[11px] font-medium text-slate-600 dark:bg-slate-800 dark:text-slate-300`,children:`已完成`})]}),(0,O.jsx)(pN,{className:`h-4 w-4 flex-shrink-0 text-slate-400 transition-transform group-open/details:rotate-180`})]}),(0,O.jsx)(`div`,{className:`border-t border-slate-200/70 bg-white/70 dark:border-slate-800 dark:bg-slate-950/20`,children:(0,O.jsx)(`div`,{className:`custom-scrollbar max-h-[min(46vh,28rem)] overflow-y-auto px-4 py-3 text-[14px] leading-7 text-slate-600 dark:text-slate-300 [&_p]:my-2 [&_pre]:my-2`,children:(0,O.jsx)(wq,{content:a.reasoning})})})]}):null,a.tools?Object.values(a.tools).map((e,t)=>(0,O.jsxs)(`details`,{open:e.approvalStatus===`pending`||e.status===`paused`?!0:void 0,className:K(`group/details mb-2 overflow-hidden rounded-md border text-sm transition-colors`,e.status===`paused`?`border-neutral-200/80 bg-neutral-50/25 text-slate-700 dark:border-neutral-900/60 dark:bg-neutral-950/10 dark:text-slate-200`:e.status===`error`?`border-rose-200/80 bg-rose-50/25 text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/10 dark:text-rose-200`:`border-slate-200/80 bg-slate-50/40 text-slate-600 dark:border-slate-700/80 dark:bg-slate-900/30 dark:text-slate-300`),children:[(0,O.jsx)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-3 py-2 font-medium`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.status===`running`?(0,O.jsx)(KN,{className:`h-4 w-4 animate-spin text-slate-500`}):e.status===`paused`?(0,O.jsx)(ZN,{className:`h-4 w-4 text-neutral-500`}):e.status===`error`?(0,O.jsx)(_N,{className:`h-4 w-4 text-rose-500`}):(0,O.jsx)(fN,{className:`h-4 w-4 text-slate-400`}),(0,O.jsxs)(`span`,{children:[e.approvalStatus===`pending`?`等待审批:`:e.approvalStatus===`approved`?`已批准:`:e.approvalStatus===`rejected`?`已拒绝:`:e.approvalStatus===`cancelled`?`已取消:`:e.status===`error`?`工具调用失败:`:`工具调用:`,e.name]})]})}),(0,O.jsxs)(`div`,{className:K(`flex flex-col gap-3 border-t px-3 py-3 font-mono text-[13px] leading-relaxed`,e.status===`paused`?`border-neutral-200/70 dark:border-neutral-900/60`:e.status===`error`?`border-rose-200/70 dark:border-rose-900/60`:`border-slate-200/70 dark:border-slate-800`),children:[e.approvalRequestId?(0,O.jsxs)(`div`,{className:`font-sans text-sm text-slate-700 dark:text-slate-200`,children:[(0,O.jsx)(`div`,{className:`font-medium`,children:e.approvalStatus===`approved`?`已批准该工具调用。`:e.approvalStatus===`rejected`?`已拒绝该工具调用。`:e.approvalStatus===`cancelled`?`已取消该工具调用。`:e.approvalMessage||`该工具调用需要人工确认后继续。`}),e.approvalLevel?(0,O.jsxs)(`div`,{className:K(`mt-2 inline-flex items-center rounded border px-1.5 py-0.5 text-xs font-medium`,gJ(e.approvalLevel)),children:[`审批级别:`,hJ(e.approvalLevel)]}):null,e.serverLabel?(0,O.jsxs)(`div`,{className:`mt-1 text-xs text-neutral-700/80 dark:text-neutral-200/80`,children:[`MCP Server: `,e.serverLabel]}):null,e.approvalStatus===`pending`?(0,O.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,O.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?l?.({interruptId:e.approvalRequestId||``,approve:!0}):c({approvalRequestId:e.approvalRequestId||``,approve:!0,previousResponseId:e.previousResponseId}),className:`inline-flex min-h-8 items-center gap-1.5 rounded-md bg-emerald-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,O.jsx)(fN,{className:`h-3.5 w-3.5`}),`批准并继续`]}),(0,O.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?l?.({interruptId:e.approvalRequestId||``,approve:!1}):c({approvalRequestId:e.approvalRequestId||``,approve:!1,previousResponseId:e.previousResponseId}),className:`inline-flex min-h-8 items-center gap-1.5 rounded-md border border-slate-300 bg-white px-3 py-1.5 text-xs font-semibold text-slate-600 transition hover:border-rose-300 hover:bg-rose-50 hover:text-rose-600 disabled:cursor-not-allowed disabled:opacity-55 dark:border-slate-700 dark:bg-slate-950 dark:text-slate-300 dark:hover:border-rose-800 dark:hover:bg-rose-950/30 dark:hover:text-rose-300`,children:[(0,O.jsx)(_N,{className:`h-3.5 w-3.5`}),`拒绝`]})]}):(0,O.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 text-xs font-medium text-slate-500 dark:text-slate-400`,children:[e.approvalStatus===`approved`?(0,O.jsx)(fN,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,O.jsx)(_N,{className:`h-3.5 w-3.5 text-rose-500`}),e.approvalStatus===`approved`?`已批准`:e.approvalStatus===`cancelled`?`已取消`:`已拒绝`]})]}):null,e.args?(0,O.jsx)(SJ,{label:`入参 (Args)`,tone:`input`,value:e.args}):null,e.output?(0,O.jsx)(SJ,{label:`输出 (Output)`,tone:e.status===`error`?`error`:`output`,value:e.output}):null]})]},`${e.name}-${t}`)):null,a.tools?Object.values(a.tools).filter(e=>f?.some(t=>t.interactionId===e.approvalRequestId)).map(e=>(0,O.jsx)(qq,{interaction:f.find(t=>t.interactionId===e.approvalRequestId)},`anchor-${e.approvalRequestId}`)):null,(0,O.jsx)(`div`,{className:`w-full break-words`,children:a.content?(0,O.jsx)(wq,{content:a.content}):n&&r&&!a.reasoning&&!a.tools||a.eventType===`optimistic_assistant_placeholder`?(0,O.jsx)(`span`,{className:`relative mt-1 inline-flex h-4 w-4 items-center justify-center`,role:`status`,"aria-label":`正在生成`,children:(0,O.jsx)(`span`,{className:`waiting-generation-breathe h-2.5 w-2.5 rounded-full`})}):null})]}),a.aguiActivities?.map(e=>(0,O.jsx)(Nq,{surfaceId:e.surfaceId,messages:e.messages,onAction:d},e.surfaceId)),(0,O.jsx)(CJ,{isLastMessage:r,isStreaming:n,message:a,onDeleteFeedback:o,onSubmitFeedback:u})]})}function TJ({agentName:e,emptyState:t,isMobile:n,isStreaming:r,activity:i,contextIndicator:a,messages:o,isLoadingInitialHistory:s=!1,onDeleteFeedback:c,onOpenAttachmentPreview:l,onRespondToApproval:u,onRespondToAguiApproval:d,onSubmitFeedback:f,onSubmitAguiAction:p,onStopGeneration:m,onCancelRemote:h,onScrollToBottom:g,checkpoints:_=[],onResumeCheckpoint:y,interactionRecords:b,scrollRef:x,className:S}){let[ee,C]=(0,v.useState)(0),[w,te]=(0,v.useState)(0),[ne,T]=(0,v.useState)(0),[re,ie]=(0,v.useState)(new Map),ae=(0,v.useRef)(re);(0,v.useLayoutEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{C(e.scrollTop),te(e.clientHeight),T(e.scrollHeight)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>t());return n.observe(e),e.firstElementChild instanceof HTMLElement&&n.observe(e.firstElementChild),()=>n.disconnect()},[x]);let oe=(0,v.useMemo)(()=>cJ({items:o,scrollTop:ee,viewportHeight:w,overscan:mJ,defaultItemHeight:pJ,measuredHeights:re,getItemKey:(e,t)=>e?.id||String(t)}),[re,o,ee,w]),se=oe.visibleItems,ce=(0,v.useCallback)((e,t,n)=>{if(!e||!Number.isFinite(t)||t<=0)return;let r=ae.current,i=r.get(e)??pJ;if(i===t)return;let a=new Map(r);a.set(e,t),ae.current=a,ie(a);let o=x.current;o&&n<o.scrollTop&&(o.scrollTop+=t-i,C(o.scrollTop),T(o.scrollHeight))},[x]),le=lJ({scrollHeight:ne,scrollTop:ee,clientHeight:w}),E=uJ({scrollHeight:ne,scrollTop:ee,clientHeight:w});return(0,O.jsxs)(`div`,{ref:x,onScroll:e=>{C(e.currentTarget.scrollTop),te(e.currentTarget.clientHeight),T(e.currentTarget.scrollHeight)},className:K(`custom-scrollbar relative min-h-0 flex-1 overflow-y-auto scroll-smooth`,n?`px-3 py-3`:`px-4 py-5`,S),"data-slot":`message-list`,children:[(0,O.jsx)(`div`,{className:`mx-auto flex w-full max-w-[64rem] flex-col pb-6 sm:pb-8`,children:o.length===0&&s?(0,O.jsx)(yJ,{}):o.length===0?t===void 0?(0,O.jsx)(vJ,{agentName:e}):t:(0,O.jsx)(`div`,{style:{height:oe.totalHeight},className:`relative`,children:se.map(t=>(0,O.jsx)(_J,{messageId:t.item.id||String(t.index),top:t.top,onMeasure:ce,children:t.item.role===`system`?(0,O.jsx)(xJ,{message:t.item}):(0,O.jsx)(wJ,{agentName:e,isMobile:n,isStreaming:r,isLastMessage:t.index===o.length-1,showAgentHeader:!fJ(o[t.index-1],t.item),message:t.item,onDeleteFeedback:c,onOpenAttachmentPreview:l,onRespondToApproval:u,interactionRecords:b,onRespondToAguiApproval:d,onSubmitFeedback:f,onSubmitAguiAction:p})},t.item.id||t.index))})}),(0,O.jsx)(iJ,{}),E?(0,O.jsx)(`button`,{type:`button`,"aria-label":`回到底部`,"data-distance-from-bottom":Math.round(le),onClick:()=>{if(g){g();return}let e=x.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`auto`})},className:`sticky bottom-4 left-1/2 z-20 mx-auto flex h-9 w-9 -translate-x-1/2 items-center justify-center rounded-full border border-border bg-surface text-text-secondary shadow-[0_8px_24px_rgba(15,23,42,0.12)] transition hover:text-text-primary`,title:`回到底部`,children:r?(0,O.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center gap-0.5`,"data-scroll-indicator":`streaming`,children:[0,1,2].map(e=>(0,O.jsx)(`span`,{className:`h-1 w-1 animate-bounce rounded-full bg-current motion-reduce:animate-none`,style:{animationDelay:`${e*120}ms`}},e))}):(0,O.jsx)(pN,{"aria-hidden":`true`,className:`h-5 w-5`,"data-scroll-indicator":`idle`})}):null]})}var EJ=RR,DJ=zR,OJ=v.forwardRef(({className:e,...t},n)=>(0,O.jsx)(BR,{ref:n,className:K(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));OJ.displayName=BR.displayName;var kJ=v.forwardRef(({className:e,children:t,...n},r)=>(0,O.jsxs)(DJ,{children:[(0,O.jsx)(OJ,{}),(0,O.jsxs)(VR,{ref:r,className:K(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...n,children:[t,(0,O.jsxs)(WR,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground`,children:[(0,O.jsx)(cP,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));kJ.displayName=VR.displayName;var AJ=({className:e,...t})=>(0,O.jsx)(`div`,{className:K(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});AJ.displayName=`DialogHeader`;var jJ=({className:e,...t})=>(0,O.jsx)(`div`,{className:K(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});jJ.displayName=`DialogFooter`;var MJ=v.forwardRef(({className:e,...t},n)=>(0,O.jsx)(HR,{ref:n,className:K(`text-lg font-semibold leading-none tracking-tight`,e),...t}));MJ.displayName=HR.displayName;var NJ=v.forwardRef(({className:e,...t},n)=>(0,O.jsx)(UR,{ref:n,className:K(`text-sm text-muted-foreground`,e),...t}));NJ.displayName=UR.displayName;function PJ(e,t){if(!(!t||e))return{width:`min(${t.width}px, calc(100vw - 5rem))`,height:`min(${t.height}px, calc(100vh - 9rem))`}}function FJ(e,t){if(!(!t||e))return{width:`min(${t.width+32}px, calc(100vw - 3rem))`}}function IJ({attachment:e,isMobile:t,previewImageSize:n,onClose:r,onImageLoad:i}){return(0,O.jsx)(EJ,{open:!!e?.url,onOpenChange:e=>!e&&r(),children:(0,O.jsxs)(kJ,{className:K(`gap-0 overflow-hidden border-slate-700 bg-slate-950 p-0 text-slate-100 shadow-2xl [&>button]:right-3 [&>button]:top-3 [&>button]:rounded-md [&>button]:border [&>button]:border-slate-700 [&>button]:bg-slate-900/70 [&>button]:p-1.5 [&>button]:text-slate-200 [&>button]:opacity-100`,t?`left-0 top-0 h-[var(--app-height)] max-h-[var(--app-height)] w-screen max-w-none translate-x-0 translate-y-0 rounded-none border-0`:`max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] rounded-2xl`),style:FJ(t,n),children:[(0,O.jsx)(`div`,{className:`flex items-center gap-3 border-b border-slate-800 px-4 py-3 pr-16`,children:(0,O.jsx)(MJ,{className:`truncate text-sm font-medium`,children:e?.name||`附件预览`})}),(0,O.jsx)(`div`,{className:K(`flex items-center justify-center overflow-auto bg-slate-950`,t?`h-full p-4 pb-[calc(var(--safe-area-bottom)+1rem)]`:`max-h-[calc(100vh-7rem)] p-4`),children:e?e.type.startsWith(`image/`)?(0,O.jsx)(`img`,{src:e.url,alt:e.name,className:K(`object-contain`,t?`h-auto max-h-full w-full max-w-full`:`h-auto w-auto max-h-[calc(100vh-9rem)] max-w-[calc(100vw-5rem)]`),style:PJ(t,n),onLoad:e=>{let t=e.currentTarget;i({width:t.naturalWidth,height:t.naturalHeight})}}):(0,O.jsx)(`iframe`,{src:e.url,title:e.name,className:`h-full min-h-[24rem] w-full rounded-xl border border-slate-800 bg-white`}):null})]})})}function LJ(e){if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>0)return t}return null}function RJ(e){return e?LJ(e.context_window_tokens)??LJ(e?.limits?.context_window_tokens):null}function zJ(e){return e?LJ(e.auto_compact_threshold_percentage)??84:84}function BJ({selectedModel:e,contextUsage:t}){let n=t&&(!t.model||t.model===e?.id)?t:null,r=LJ(n?.used_tokens),i=LJ(n?.context_window_tokens),a=i??RJ(e),o={contextWindowTokens:a??void 0,contextWindowSource:a?i?`runtime`:`model`:void 0},s=n?.source===`last_request`?`上次请求输入`:`上下文占用`;if(!r)return{label:`上下文用量暂不可用`,phase:`default`,...o};let c=a?Math.round(r/a*100):void 0;return{label:s,phase:c!==void 0&&c>=zJ(e)?`warning`:`normal`,percent:c,usedTokens:r,...o}}function VJ(e){return e.requestedSessionId===e.activeSessionId&&e.requestToken===e.activeRequestToken}function HJ({agentName:e,emptyState:t,isMobile:n,onDeleteFeedback:r,onSubmitFeedback:i,onRespondToApproval:a,onRespondToAguiApproval:o,onSubmitAguiAction:s,onStopGeneration:c,onCancelRemote:l,checkpointResumeEnabled:u=!1,onResumeCheckpoint:d,onLoadOlderSessionMessages:f,interactionRecords:p,className:m}){let h=Qc(e=>e.messages),g=E(e=>e.currentSessionId),_=E(e=>e.isLoadingSessions),y=k(e=>!!(e.getSessionActivity(g)&&e.isSessionStreaming(g))),b=k(e=>e.getSessionActivity(g)),x=kj(e=>e.getSessionCheckpoints(g)),S=E(e=>g?e.messageHistory[g]:null),ee=_||!!S?.isLoadingInitial,C=ve(e=>e.input),w=We(e=>e.availableModels),te=We(e=>e.selectedModel),ne=ve(e=>e.previewAttachment),T=ve(e=>e.previewImageSize),re=(0,v.useRef)(null),ie=(0,v.useRef)(!0),ae=(0,v.useRef)(!1),oe=(0,v.useRef)(0),se=(0,v.useRef)(y),ce=(0,v.useRef)(!1),le=(0,v.useRef)(null),D=(0,v.useRef)(!0),ue=(0,v.useRef)(``),de=(0,v.useMemo)(()=>w.find(e=>e.id===te)||null,[w,te]),fe=(0,v.useMemo)(()=>BJ({messages:h,draftInput:C,selectedModel:de}),[C,h,de]),pe=(0,v.useCallback)(()=>{let e=re.current;if(!e)return;ie.current=!0,ae.current=!1;let t=e.style.scrollBehavior;e.style.scrollBehavior=`auto`;let n=0,r=0,i=-1,a=()=>{if(re.current===e){if(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)),r=e.scrollHeight===i?r+1:0,i=e.scrollHeight,n+=1,r>=3||n>=12){e.style.scrollBehavior=t;return}requestAnimationFrame(a)}};a()},[]);return(0,v.useEffect)(()=>{se.current=y},[y]),(0,v.useEffect)(()=>{D.current=!0,ie.current=!0,ae.current=!1,oe.current=0,ce.current=!1,le.current=null,ue.current=``},[g]),(0,v.useEffect)(()=>{let e=h.at(-1),t=ue.current;ue.current=String(e?.id||``),e?.role===`user`&&e.id!==t&&!D.current&&pe()},[h,pe]),(0,v.useEffect)(()=>{let e=re.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight,n=e.scrollTop<oe.current-2;if(oe.current=e.scrollTop,!D.current&&n&&e.scrollTop<200&&g&&S?.hasMore&&!S.isLoadingOlder&&!ce.current&&f){let t=e.scrollHeight,n=g,r=Symbol(n);ce.current=!0,le.current=r,f(n).then(()=>{VJ({requestedSessionId:n,activeSessionId:E.getState().currentSessionId,requestToken:r,activeRequestToken:le.current})&&requestAnimationFrame(()=>{if(!VJ({requestedSessionId:n,activeSessionId:E.getState().currentSessionId,requestToken:r,activeRequestToken:le.current}))return;let e=re.current;if(!e)return;let i=e.scrollHeight-t;e.scrollTop+=i,oe.current=e.scrollTop})}).finally(()=>{le.current===r&&(le.current=null,ce.current=!1)})}if(se.current&&n){ae.current=!0,ie.current=!1;return}if(ae.current){let e=t<=12;ae.current=!e,ie.current=e;return}ie.current=t<96};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[S,g,f]),(0,v.useEffect)(()=>{let e=re.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{!D.current&&!ie.current||(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)))});return t.observe(e),e.firstElementChild instanceof HTMLElement&&t.observe(e.firstElementChild),()=>t.disconnect()},[g]),(0,v.useEffect)(()=>{let e=re.current;if(e){if(h.length>0&&D.current){let e=E.getState().currentSessionId,t=re.current,n=t?t.style.scrollBehavior:``;t&&(t.style.scrollBehavior=`auto`,t.scrollTop=t.scrollHeight,oe.current=t.scrollTop);let r=0,i=t?.scrollHeight??-1,a=!1,o=0,s=()=>{let e=re.current;e&&(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)))},c=()=>{a||(a=!0,s(),t&&(t.style.scrollBehavior=n),ie.current=!0,ae.current=!1,D.current=!1)},l=()=>{if(a)return;if(E.getState().currentSessionId!==e){a=!0;return}let t=re.current;if(t){if(t.scrollHeight!==i)i=t.scrollHeight,s(),r=0;else if(r+=1,r>=3){c();return}o=requestAnimationFrame(l)}},u=window.setTimeout(c,2e3);return o=requestAnimationFrame(l),()=>{if(cancelAnimationFrame(o),window.clearTimeout(u),E.getState().currentSessionId!==e){c();return}t&&(t.style.scrollBehavior=n)}}ie.current&&(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop)}},[h,y]),(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(TJ,{emptyState:t,agentName:e,isMobile:n,isStreaming:y,activity:b,contextIndicator:fe,messages:h,isLoadingInitialHistory:ee,onDeleteFeedback:r,onOpenAttachmentPreview:e=>{ve.getState().setPreviewAttachment(e),ve.getState().setPreviewImageSize(null)},onRespondToApproval:a,onRespondToAguiApproval:o,interactionRecords:p,onScrollToBottom:pe,onSubmitFeedback:i,onSubmitAguiAction:s,onStopGeneration:c,onCancelRemote:l,checkpoints:u?x:[],onResumeCheckpoint:d,scrollRef:re,className:m}),(0,O.jsx)(IJ,{attachment:ne,isMobile:n,previewImageSize:T,onClose:()=>{ve.getState().setPreviewAttachment(null),ve.getState().setPreviewImageSize(null)},onImageLoad:e=>ve.getState().setPreviewImageSize(e)})]})}function UJ({indicator:e,onCompact:t,disabled:n}){let r=(0,v.useRef)(null),[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!i)return;let e=e=>{e.target instanceof Node&&!r.current?.contains(e.target)&&(o.current=!1,a(!1))},t=e=>{e.key===`Escape`&&(o.current=!1,a(!1),r.current?.querySelector(`button`)?.focus())};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,t)}},[i]);let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(``),d=typeof e.usedTokens==`number`&&Number.isFinite(e.usedTokens)&&e.usedTokens>=0,f=d&&typeof e.percent==`number`&&Number.isFinite(e.percent)?Math.max(0,Math.min(100,e.percent)):void 0,p=async()=>{if(!(!t||s||n)){c(!0),u(``);try{await t(),u(`上下文已压缩`)}catch(e){u(e instanceof Error?e.message:`压缩失败,请重试`)}finally{c(!1)}}};return(0,O.jsxs)(`div`,{ref:r,className:`relative flex h-8 w-8 items-center justify-center`,onPointerEnter:e=>{e.pointerType!==`touch`&&a(!0)},onPointerLeave:()=>{o.current||a(!1)},children:[(0,O.jsx)(`button`,{type:`button`,"aria-label":`上下文用量与压缩`,"aria-expanded":i,onClick:()=>{o.current=!o.current,a(o.current),u(``)},className:K(`flex h-8 w-8 items-center justify-center rounded-full`,e.phase===`warning`?`text-text-primary`:`text-text-muted`),children:(0,O.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,className:s?`animate-pulse`:void 0,style:{display:`block`,flexShrink:0},children:[(0,O.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,fill:`none`,stroke:`var(--ksadk-menu-border, #b8bcb5)`,strokeWidth:`2`}),f!==void 0&&(0,O.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,pathLength:`100`,strokeDasharray:`${f} 100`,transform:`rotate(-90 8 8)`})]})}),(0,O.jsxs)(`div`,{style:{background:`var(--ksadk-menu-background, hsl(var(--popover)))`,borderColor:`var(--ksadk-menu-border, hsl(var(--border)))`,boxShadow:`var(--ksadk-menu-shadow, 0 18px 44px rgba(15, 23, 42, 0.16))`},role:i?`dialog`:void 0,"aria-label":i?`上下文`:void 0,className:K(`absolute bottom-full right-0 z-30 w-60 rounded-xl border border-border bg-background p-4 text-sm text-foreground shadow-lg`,i?`block`:`hidden`),children:[(0,O.jsx)(`p`,{className:K(`font-medium`,s&&`waiting-thinking-text`),children:s?`正在压缩上下文…`:d?e.label:`上下文用量暂不可用`}),d&&(0,O.jsxs)(`p`,{className:`mt-1 text-text-secondary`,children:[`${WJ(e.usedTokens)} tokens`,e.contextWindowTokens?` / ${WJ(e.contextWindowTokens)}`:``]}),e.contextWindowTokens&&(0,O.jsxs)(`p`,{className:`mt-1 text-text-muted`,children:[`模型窗口:`,WJ(e.contextWindowTokens),` tokens`]}),d&&!e.contextWindowTokens&&(0,O.jsx)(`p`,{className:`mt-1 text-text-muted`,children:`模型窗口大小未报告`}),f!==void 0&&(0,O.jsxs)(`p`,{className:`text-text-muted`,children:[f,`% 已使用`]}),i&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>void p(),disabled:!t||s||n,className:`mt-3 w-full rounded-lg border border-border bg-muted px-3 py-2 disabled:opacity-50`,children:s?`正在压缩…`:`压缩上下文`}),(0,O.jsx)(`p`,{className:`mt-2 text-xs text-text-muted`,children:n?`请等待当前运行结束`:t?`压缩模型上下文,保留聊天记录`:`当前会话尚不支持手动压缩`}),l&&(0,O.jsx)(`p`,{role:`status`,className:`mt-2 text-xs`,children:l})]})]})]})}function WJ(e){return new Intl.NumberFormat(`zh-CN`).format(e)}var GJ=[{value:`plan`,label:`计划模式`,description:`先分析并形成可执行计划`,icon:jN},{value:`goal`,label:`设定目标`,description:`朝可验证的停止条件持续推进`,icon:tP}],KJ={plan:`计划模式`,goal:`目标`};function qJ({attachmentsEnabled:e,mode:t,support:n,onSelectMode:r,onUpload:i}){let[a,o]=(0,v.useState)(!1),s=(0,v.useRef)(null),c=GJ.filter(e=>n[e.value]);return(0,v.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]),!e&&c.length===0?null:(0,O.jsxs)(`div`,{ref:s,className:`relative flex min-w-0 items-center gap-1`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-text-secondary transition hover:bg-muted hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,"aria-expanded":a,"aria-haspopup":`menu`,"aria-label":`添加附件或选择执行模式`,title:`添加附件或选择执行模式`,children:(0,O.jsx)(GN,{className:`h-[19px] w-[19px]`})}),t?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:K(`flex h-8 max-w-[8.5rem] items-center gap-1 rounded-xl px-2 text-[12px] transition`,t===`goal`?`bg-neutral-50 text-neutral-700 hover:bg-neutral-100 dark:bg-neutral-950/40 dark:text-neutral-300`:`text-text-secondary hover:bg-muted hover:text-text-primary`),"aria-label":`当前执行模式:${KJ[t]}`,children:[(0,O.jsx)(`span`,{className:`truncate`,children:KJ[t]}),(0,O.jsx)(pN,{className:`h-3.5 w-3.5 shrink-0`})]}):null,a?(0,O.jsxs)(`div`,{role:`menu`,"aria-label":`附件与执行模式`,className:`absolute bottom-[calc(100%+0.6rem)] left-0 z-40 w-[min(18rem,calc(100vw-2rem))] rounded-xl border border-border/80 bg-popover p-1 shadow-[0_10px_24px_rgba(15,23,42,0.12)]`,style:{backgroundColor:`var(--ksadk-popover, #fff)`,borderColor:`var(--ksadk-border, rgba(15, 23, 42, 0.12))`},children:[e?(0,O.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{i(),o(!1)},className:`flex h-10 w-full items-center gap-2 rounded-lg px-2.5 text-left transition hover:bg-muted/70`,children:[(0,O.jsx)(aP,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,O.jsx)(`span`,{className:`shrink-0 text-[13px] font-medium text-text-primary`,children:`上传附件`}),(0,O.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:`添加文件或图片`})]}):null,c.map(e=>{let n=e.icon,i=t===e.value;return(0,O.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":i,onClick:()=>{r(e.value),o(!1)},className:K(`flex h-10 w-full items-center gap-2 rounded-lg px-2.5 text-left transition`,i?`bg-muted`:`hover:bg-muted/70`),children:[(0,O.jsx)(n,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,O.jsx)(`span`,{className:`shrink-0 text-[13px] font-medium text-text-primary`,children:e.label}),(0,O.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:e.description}),i?(0,O.jsx)(fN,{className:`h-4 w-4 shrink-0 text-text-primary`}):null]},e.value)})]}):null]})}var JJ=[{value:`auto`,label:`自动`},{value:`enabled`,label:`开启`},{value:`disabled`,label:`关闭`}],YJ={auto:`自动`,enabled:`开启`,disabled:`关闭`};function XJ({availableModels:e,selectedModel:t,thinkingEnabled:n,thinkingMode:r,onSelectModel:i,onSelectThinkingMode:a}){let[o,s]=(0,v.useState)(!1),c=(0,v.useRef)(null),l=e.find(e=>e.id===t)?.display_name||t||`选择模型`;return(0,v.useEffect)(()=>{if(!o)return;let e=e=>{c.current&&!c.current.contains(e.target)&&s(!1)},t=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[o]),(0,O.jsxs)(`div`,{ref:c,className:`relative`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex h-8 max-w-[15rem] items-center gap-1.5 rounded-xl px-3 text-[13px] text-text-primary transition hover:brightness-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,style:{background:`var(--ksadk-menu-trigger-background, hsl(var(--muted)))`},"aria-expanded":o,"aria-haspopup":`menu`,"aria-label":n?`模型 ${l},推理 ${YJ[r]}`:`模型 ${l}`,title:n?`选择模型与推理设置`:`选择模型`,children:[(0,O.jsx)(`span`,{className:`min-w-0 truncate`,children:l}),n?(0,O.jsx)(`span`,{className:`shrink-0 text-text-muted`,children:YJ[r]}):null,(0,O.jsx)(pN,{className:K(`h-3.5 w-3.5 shrink-0 text-text-muted transition-transform`,o&&`rotate-180`)})]}),o?(0,O.jsxs)(`div`,{role:`menu`,"aria-label":`选择模型`,className:`absolute bottom-[calc(100%+0.65rem)] right-0 z-40 w-[min(17rem,calc(100vw-2rem))] overflow-hidden rounded-2xl border p-1.5`,style:{background:`var(--ksadk-menu-background, hsl(var(--popover)))`,borderColor:`var(--ksadk-menu-border, hsl(var(--border)))`,boxShadow:`var(--ksadk-menu-shadow, 0 18px 44px rgba(15, 23, 42, 0.16))`},children:[(0,O.jsx)(`div`,{className:`px-2.5 pb-1.5 pt-1 text-[11px] font-medium text-text-muted`,children:`模型`}),(0,O.jsx)(`div`,{className:`max-h-[min(45vh,18rem)] overflow-y-auto`,children:e.map(e=>{let n=e.id===t;return(0,O.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":n,onClick:()=>{i(e.id),s(!1)},className:K(`flex w-full items-center gap-2 rounded-xl px-2.5 py-2 text-left text-[13px] transition-colors`,n?`bg-muted text-text-primary`:`text-text-secondary hover:bg-muted hover:text-text-primary`),children:[(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.display_name||e.id}),n?(0,O.jsx)(fN,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}):null]},e.id)})}),n?(0,O.jsx)(`div`,{className:`mt-1 border-t border-border px-1 pt-1.5`,children:(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1.5 pb-1`,children:[(0,O.jsx)(`span`,{className:`text-[11px] font-medium text-text-muted`,children:`推理`}),(0,O.jsx)(`div`,{className:`flex rounded-lg bg-muted p-0.5`,children:JJ.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>a(e.value),className:K(`rounded-md px-2 py-1 text-[11px] transition-colors`,e.value===r?`bg-card text-text-primary shadow-sm`:`text-text-muted hover:text-text-primary`),children:e.label},e.value))})]})}):null]}):null]})}var ZJ=[{value:`ask`,label:`请求批准`,description:`Agent 请求授权时确认`,icon:kN},{value:`risk`,label:`风险操作需确认`,description:`仅副作用操作`,icon:ZN},{value:`full`,label:`完全访问`,description:`不再确认`,icon:XN}],QJ={ask:`请求批准`,risk:`风险确认`,full:`完全访问`};function $J({approvalPolicy:e}){let[t,n]=(0,v.useState)(!1),r=(0,v.useRef)(null),i=fe(e=>e.permissionMode),a=fe(e=>e.setPermissionMode),o=i===`ask`?kN:i===`full`?XN:ZN,s=(0,v.useMemo)(()=>ZJ.filter(t=>!e||e.Modes.includes(t.value)),[e]);return(0,v.useEffect)(()=>{s.some(e=>e.value===i)||a(e?.DefaultMode||s[0]?.value||`risk`)},[e?.DefaultMode,i,a,s]),(0,v.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)}},[t]),(0,O.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:K(`flex h-8 items-center gap-1.5 rounded-xl px-2.5 text-[13px] transition hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,i===`full`?`text-amber-600 dark:text-amber-400`:`text-text-secondary hover:text-text-primary`),"aria-expanded":t,"aria-haspopup":`menu`,title:`设置本次会话的工具审批规则`,children:[(0,O.jsx)(o,{className:`h-3.5 w-3.5`}),(0,O.jsx)(`span`,{children:QJ[i]}),(0,O.jsx)(pN,{className:K(`h-3.5 w-3.5 transition-transform`,t&&`rotate-180`)})]}),t?(0,O.jsx)(`div`,{role:`menu`,"aria-label":`工具权限`,className:`absolute bottom-[calc(100%+0.6rem)] left-0 z-30 w-[18rem] rounded-xl border border-border/80 bg-popover p-1 shadow-[0_10px_24px_rgba(15,23,42,0.12)]`,style:{backgroundColor:`var(--ksadk-popover, #fff)`,borderColor:`var(--ksadk-border, rgba(15, 23, 42, 0.12))`},children:s.map(e=>{let t=e.icon,r=e.value===i;return(0,O.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,onClick:()=>{a(e.value),n(!1)},className:K(`flex h-10 w-full items-center gap-2 rounded-lg px-2.5 text-left transition-colors`,r?`bg-primary/[0.08]`:`hover:bg-muted/75`),children:[(0,O.jsx)(t,{className:K(`h-4 w-4 shrink-0`,r?`text-primary`:`text-text-muted`)}),(0,O.jsx)(`span`,{className:K(`shrink-0 text-[13px] font-medium`,r?`text-text-primary`:`text-text-secondary`),children:e.label}),(0,O.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:e.description}),r?(0,O.jsx)(fN,{className:`h-4 w-4 shrink-0 text-primary`,"aria-hidden":`true`}):null]},e.value)})}):null]})}function eY({onCompactContext:e,attachments:t,composerContextIndicator:n,composerMaxHeight:r,fileInputRef:i,input:a,isMobile:o,isStreaming:s,attachmentsEnabled:c=!0,approvalEnabled:l=!1,approvalPolicy:u,thinkingEnabled:d=!1,executionMode:f,executionModeSupport:p,queuedDrafts:m,onAppendAttachments:h,onInputChange:g,onSelectExecutionMode:_,onPaste:y,onRemoveAttachment:b,onStopGeneration:x,onCancelRemote:S,onSubmit:ee,textareaRef:C,className:w}){let[te,ne]=(0,v.useState)(!1),T=e?async()=>{ne(!0);try{await e()}finally{ne(!1)}}:void 0,re=f===`goal`?`描述需要持续完成的目标…`:f===`plan`?`描述需要先规划的任务…`:o?`发送消息...`:`发送消息…`,ie=S?`保留恢复点并结束本次执行`:`停止生成`,ae=f===`goal`?!!a.trim():!!(a.trim()||t.length>0),oe=We(e=>e.availableModels),se=We(e=>e.selectedModel),ce=We(e=>e.thinkingMode),le=We(e=>e.setSelectedModel),E=We(e=>e.setThinkingMode),D=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`;return(0,O.jsx)(`div`,{className:K(`relative z-10 flex-shrink-0 bg-background/95 px-3 py-3 backdrop-blur sm:px-4 sm:py-3`,w),"data-slot":`composer`,children:(0,O.jsxs)(`div`,{className:`mx-auto w-full max-w-[64rem]`,children:[te&&(0,O.jsxs)(`div`,{role:`status`,className:`mb-3 flex items-center gap-2 px-2 text-sm text-text-muted`,children:[(0,O.jsx)(DN,{size:16,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`waiting-thinking-text`,children:`正在压缩上下文`})]}),m.length>0?(0,O.jsxs)(`div`,{className:`mb-2 rounded-2xl border border-neutral-200/80 bg-neutral-50/80 px-3 py-2 text-xs text-neutral-900 shadow-sm dark:border-neutral-900/60 dark:bg-neutral-950/30 dark:text-neutral-100`,children:[(0,O.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,O.jsxs)(`span`,{className:`font-semibold`,children:[`发送队列 · `,m.length]}),(0,O.jsx)(`span`,{className:`text-neutral-700/75 dark:text-neutral-200/75`,children:`当前回复完成后依次发送`})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[m.slice(0,3).map((e,t)=>{let n=e.text.trim()||(e.attachments.length>0?`仅附件消息`:`空消息`);return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-background/70 px-2 py-1.5`,children:[(0,O.jsx)(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-neutral-100 font-mono text-[10px] text-neutral-700 dark:bg-neutral-900/50 dark:text-neutral-100`,children:t+1}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-text-secondary`,children:n}),e.attachments.length>0?(0,O.jsxs)(`span`,{className:`flex-shrink-0 rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] text-neutral-700 dark:bg-neutral-900/50 dark:text-neutral-100`,children:[e.attachments.length,` 附件`]}):null]},`${t}-${n}-${e.attachments.length}`)}),m.length>3?(0,O.jsxs)(`div`,{className:`px-2 pt-0.5 text-[11px] text-neutral-700/80 dark:text-neutral-200/80`,children:[`还有 `,m.length-3,` 条等待发送`]}):null]})]}):null,(0,O.jsx)(`div`,{className:`relative rounded-[28px] bg-surface shadow-[0_0_0_0.5px_rgba(15,23,42,0.08),0_5px_18px_rgba(15,23,42,0.07)] dark:shadow-[0_0_0_0.5px_rgba(255,255,255,0.06),0_8px_24px_rgba(0,0,0,0.24)]`,children:(0,O.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,O.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),te)return;if(s){S?S():x();return}let n=a.trim();ae&&ee(n,t)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),c&&e.dataTransfer.files&&e.dataTransfer.files.length>0&&h(Array.from(e.dataTransfer.files))},className:`relative flex min-h-[116px] min-w-0 flex-1 flex-col rounded-[28px] border border-border/55 bg-background px-4 pb-3 pt-3 transition-all focus-within:border-primary/40 focus-within:ring-2 focus-within:ring-primary/15 sm:px-5`,children:[t.length>0?(0,O.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-2`,children:t.map((e,t)=>(0,O.jsxs)(`div`,{className:K(`group relative flex items-center gap-2 rounded-xl border border-border bg-background px-3 py-2 text-xs`,o?`max-w-full`:`max-w-[14rem]`),children:[(0,O.jsx)(`span`,{className:`flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-muted text-text-muted`,children:(0,O.jsx)(VN,{className:`h-3.5 w-3.5`})}),(0,O.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`span`,{className:`block truncate font-medium text-text-primary`,children:e.name}),(0,O.jsx)(`span`,{className:`block text-[10px] text-text-muted`,children:D(e.size)})]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>b(t),className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full border border-border bg-background text-text-muted shadow-sm transition hover:text-rose-500`,"aria-label":`移除附件 ${e.name}`,children:(0,O.jsx)(`span`,{className:`text-[11px] leading-none`,children:`×`})})]},`${e.name}-${e.size}-${t}`))}):null,(0,O.jsx)(`textarea`,{ref:C,rows:1,value:a,onChange:g,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},onPaste:y,placeholder:re,className:K(`custom-scrollbar max-h-[176px] min-h-[62px] w-full resize-none overflow-y-auto border-0 bg-transparent px-0 pb-1 pt-1 text-[15px] leading-6 text-text-primary outline-none placeholder:text-text-muted/60`,o?`text-[16px]`:`text-[14px]`),style:{maxHeight:`${r}px`,overflowY:`auto`}}),(0,O.jsxs)(`div`,{className:`mt-auto flex min-h-8 items-center justify-between gap-2 pt-1.5`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,O.jsx)(`input`,{ref:i,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&e.target.files.length>0&&(h(Array.from(e.target.files)),e.target.value=``)}}),(0,O.jsx)(qJ,{attachmentsEnabled:c,mode:f,support:p,onSelectMode:_,onUpload:()=>i.current?.click()}),l?(0,O.jsx)($J,{approvalPolicy:u}):null]}),(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[n?(0,O.jsx)(UJ,{indicator:n,onCompact:T,disabled:s}):null,oe.length>0?(0,O.jsx)(XJ,{availableModels:oe,selectedModel:se,thinkingEnabled:d,thinkingMode:ce,onSelectModel:le,onSelectThinkingMode:E}):null,(0,O.jsx)(`button`,{type:`submit`,disabled:te||!s&&!ae,className:K(`flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,s||ae?`bg-[#1f1f1f] text-white hover:opacity-80`:`bg-muted text-text-muted/45`),title:s?ie:`发送消息`,children:s?(0,O.jsx)(eP,{className:`h-3.5 w-3.5 fill-current`}):(0,O.jsx)(uN,{className:`h-[18px] w-[18px]`})})]})]})]})})})]})})}function tY(e){return[e.name,e.size,e.lastModified,e.type].join(`:`)}function nY(e,t){let n=new Map;for(let t of e)n.set(tY(t),t);for(let e of t)n.set(tY(e),e);return Array.from(n.values())}function rY(e){return Array.from(e.clipboardData.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e)}function iY({onCompactContext:e,composerMaxHeight:t,submitDraft:n,stopGeneration:r,cancelRemote:i,isMobile:a,attachmentsEnabled:o=!0,approvalEnabled:s=!1,approvalPolicy:c,thinkingEnabled:l=!1,runtimeCapabilityMatrix:u,pendingInteractions:d,onRespondInteraction:f,localCatalog:p,className:m}){let[h,g]=(0,v.useState)(0),[_,y]=(0,v.useState)(),b=ve(e=>e.input),x=ve(e=>e.attachments),S=E(e=>e.currentSessionId),ee=k(e=>!!(e.getSessionActivity(S)&&e.isSessionStreaming(S))),C=ve(e=>e.queuedDrafts),w=Qc(e=>e.messages),te=E(e=>e.sessions.find(e=>e.SessionId===S)?.ContextUsage),ne=We(e=>e.availableModels),T=We(e=>e.selectedModel),re=We(e=>e.setThinkingMode),ie=(0,v.useRef)(null),ae=(0,v.useRef)(null),oe=(0,v.useMemo)(()=>ne.find(e=>e.id===T)||null,[ne,T]),se=(0,v.useMemo)(()=>BJ({messages:w,draftInput:b,selectedModel:oe,contextUsage:te}),[b,w,oe,te]),ce=(0,v.useMemo)(()=>({plan:!!u?.plan?.supported,goal:!!u?.goal?.supported}),[u]),le=_&&ce[_]?_:void 0,D=(0,v.useCallback)((e,t)=>{!e&&t.length===0||(ve.getState().setInput(``),ve.getState().setAttachments([]),n(e,t,void 0,void 0,le),le===`goal`&&y(void 0))},[le,n]);(0,v.useEffect)(()=>{ae.current&&(ae.current.style.height=`auto`,ae.current.style.height=`${Math.min(ae.current.scrollHeight,t)}px`)},[b,t]);let ue=e=>{ve.getState().setInput(e.target.value),e.target.style.height=`auto`,e.target.style.height=`${Math.min(e.target.scrollHeight,t)}px`},de=e=>{!o||!e.length||ve.getState().setAttachments(t=>nY(t,e))},fe=e=>{if(!o)return;let t=rY(e);t.length&&(e.preventDefault(),e.stopPropagation(),de(t))},pe=d||[],me=Math.min(h,Math.max(pe.length-1,0));return(0,v.useEffect)(()=>{l||re(`auto`)},[re,l]),(0,O.jsxs)(`div`,{className:`flex w-full flex-col justify-center`,children:[pe.length>0&&f?(0,O.jsx)(Uq,{interactions:pe,activeIndex:me,onSelectIndex:g,onRespond:f,localCatalog:p}):null,(0,O.jsx)(eY,{onCompactContext:S?e:void 0,attachments:x,composerContextIndicator:se,composerMaxHeight:t,fileInputRef:ie,input:b,isMobile:a,isStreaming:ee,attachmentsEnabled:o,approvalEnabled:s,approvalPolicy:c,thinkingEnabled:l,executionMode:le,executionModeSupport:ce,queuedDrafts:C,onAppendAttachments:de,onInputChange:ue,onSelectExecutionMode:y,onPaste:fe,onRemoveAttachment:e=>ve.getState().setAttachments(t=>t.filter((t,n)=>n!==e)),onStopGeneration:r,onCancelRemote:i,onSubmit:D,textareaRef:ae,className:m},S||`new-session`)]})}var aY=(0,v.lazy)(()=>J(()=>import(`./NativeTerminalPanel-zvL-WpAn.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function oY({availableModels:e,selectedModel:t,onSelectModel:n,selectedModelLabel:r,modelCatalogLoaded:i,modelSource:a,thinkingEnabled:o,thinkingMode:s,onSelectThinkingMode:c,compact:l=!1}){let u=K(`rounded-full border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition-colors focus:ring-1 focus:ring-blue-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300`,l?`w-full`:`max-w-[13rem]`),d=e.length>1?(0,O.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),className:u,children:e.map(e=>(0,O.jsx)(`option`,{value:e.id,children:e.display_name||e.id},e.id))}):r?(0,O.jsx)(`span`,{className:K(u,`inline-flex max-w-full items-center`,l?`justify-start`:``),title:a||r,children:(0,O.jsx)(`span`,{className:`truncate`,children:r})}):(0,O.jsx)(`span`,{className:`text-sm text-slate-400`,children:i?`未配置模型`:`Loading models...`}),f=o?(0,O.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:K(u,l?``:`max-w-[9rem]`),title:`控制模型 thinking/reasoning 参数`,children:[(0,O.jsx)(`option`,{value:`auto`,children:`思考自动`}),(0,O.jsx)(`option`,{value:`enabled`,children:`开启思考`}),(0,O.jsx)(`option`,{value:`disabled`,children:`关闭思考`})]}):null;return(0,O.jsxs)(`div`,{className:K(`flex min-w-0 gap-2`,l?`w-full flex-col`:`items-center`),children:[d,f]})}function sY({agentName:e,currentSessionId:t,isMobile:n,sidebarOpen:r,mobileSidebarOpen:i,onToggleSidebar:a,availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,mobileActionsOpen:h,onMobileActionsOpenChange:g,workspaceEnabled:_,onOpenWorkspace:y,nativeManagementLink:b,nativeTerminal:x,nativeLauncherMode:S=!1}){let[ee,C]=(0,v.useState)(!1),w=!!x?.Enabled,te=n?i?(0,O.jsx)(zN,{className:`h-5 w-5`}):(0,O.jsx)(BN,{className:`h-5 w-5`}):r?(0,O.jsx)(zN,{className:`h-5 w-5`}):(0,O.jsx)(BN,{className:`h-5 w-5`});return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`header`,{className:K(`flex flex-shrink-0 items-center justify-between border-b border-black/[0.06] bg-background/95 px-3 py-2 backdrop-blur dark:border-white/[0.08] dark:bg-background/95 sm:px-4`,n?`pt-[calc(var(--safe-area-top)+0.5rem)]`:`h-12`),children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[S?null:(0,O.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800`,"aria-label":n?`打开历史记录`:`切换侧边栏`,children:te}),(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100 sm:text-base`,children:e}),(0,O.jsx)(`div`,{className:`text-[11px] text-slate-400 dark:text-slate-500`,children:S?`原生运行时入口`:`智能体`})]})]}),n?(0,O.jsx)(`button`,{type:`button`,onClick:()=>g(!0),className:`rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800`,"aria-label":`打开会话操作`,children:(0,O.jsx)(SN,{className:`h-5 w-5`})}):(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[b?(0,O.jsxs)(`a`,{href:b.href,target:`_blank`,rel:`noreferrer`,title:b.title,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(CN,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{children:b.label})]}):null,_?(0,O.jsxs)(`button`,{type:`button`,onClick:y,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(ON,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{children:`Workspace`})]}):null,w?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>C(!0),className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm font-medium leading-none text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,O.jsx)($N,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{children:`TUI`})]}):null,!S&&n?(0,O.jsx)(oY,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0}):null,!S&&t?(0,O.jsxs)(`span`,{className:`rounded bg-slate-50 px-2 py-1 text-xs font-mono text-slate-400 dark:bg-slate-800`,children:[`ID: `,t.slice(0,8)]}):null]})]}),n?(0,O.jsx)(qR,{open:h,onOpenChange:g,children:(0,O.jsxs)(YR,{side:`bottom`,className:`rounded-t-[1.75rem] border-slate-200 bg-white px-4 pb-[calc(var(--safe-area-bottom)+1rem)] pt-6 dark:border-slate-800 dark:bg-slate-900`,children:[(0,O.jsxs)(XR,{className:`text-left`,children:[(0,O.jsx)(ZR,{children:`会话设置`}),(0,O.jsx)(QR,{className:`sr-only`,children:`调整当前会话的模型和 Workspace 操作。`})]}),(0,O.jsxs)(`div`,{className:`mt-6 flex flex-col gap-4`,children:[_?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),y()},className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(ON,{className:`h-4 w-4`}),`工作区文件`]}):null,w?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),C(!0)},className:`inline-flex items-center gap-2 rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-3 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,O.jsx)($N,{className:`h-4 w-4`}),`原生 TUI`]}):null,b?(0,O.jsxs)(`a`,{href:b.href,target:`_blank`,rel:`noreferrer`,title:b.title,onClick:()=>g(!1),className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(CN,{className:`h-4 w-4`}),b.label]}):null,S?(0,O.jsx)(`div`,{className:`rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm leading-6 text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,children:`当前运行时对话在原生管理台中进行;这里保留管理入口和 Workspace 文件操作。`}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`模型`}),(0,O.jsx)(oY,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`当前会话`}),(0,O.jsx)(`div`,{className:`rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,children:t?(0,O.jsx)(`span`,{className:`break-all font-mono`,children:t}):`新对话尚未创建会话 ID`})]})]})]})]})}):null,x&&ee?(0,O.jsx)(v.Suspense,{fallback:null,children:(0,O.jsx)(aY,{capability:x,open:ee,sessionId:t,onClose:()=>C(!1)})}):null]})}var cY=(0,v.lazy)(()=>J(()=>import(`./NativeTerminalPanel-zvL-WpAn.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function lY({productLabel:e=`原生运行时`,nativeManagementLink:t,nativeTerminal:n,workspaceEnabled:r,onOpenWorkspace:i}){let a=!!n?.Enabled,[o,s]=(0,v.useState)(!1);return(0,O.jsxs)(`section`,{className:`flex min-h-0 flex-1 overflow-y-auto bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.12),transparent_34%),linear-gradient(135deg,#f8fafc_0%,#ffffff_48%,#f1f5f9_100%)] px-4 py-8 dark:bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.16),transparent_34%),linear-gradient(135deg,#020617_0%,#0f172a_52%,#111827_100%)] sm:px-8`,children:[(0,O.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col justify-center`,children:(0,O.jsxs)(`div`,{className:`overflow-hidden rounded-[2rem] border border-slate-200/80 bg-white/90 shadow-xl shadow-slate-200/60 backdrop-blur dark:border-slate-800 dark:bg-slate-900/85 dark:shadow-black/30`,children:[(0,O.jsxs)(`div`,{className:`border-b border-slate-200/80 bg-slate-50/80 px-6 py-5 dark:border-slate-800 dark:bg-slate-950/40 sm:px-8`,children:[(0,O.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-sky-200 bg-sky-50 px-3 py-1 text-xs font-medium text-sky-700 dark:border-sky-900/60 dark:bg-sky-950/50 dark:text-sky-300`,children:[(0,O.jsx)(ZN,{className:`h-3.5 w-3.5`}),e,` native runtime`]}),(0,O.jsx)(`h1`,{className:`mt-5 text-2xl font-semibold tracking-tight text-slate-950 dark:text-slate-50 sm:text-3xl`,children:`对话请使用原生管理台`}),(0,O.jsx)(`p`,{className:`mt-3 max-w-2xl text-sm leading-6 text-slate-600 dark:text-slate-300 sm:text-base`,children:`当前运行时的对话状态由原生管理台承载。AgentEngine Hosted UI 在这里保留统一入口和 Workspace 文件管理,不重复实现运行时内部已有的复杂对话状态机。`})]}),(0,O.jsxs)(`div`,{className:`grid gap-4 p-6 md:grid-cols-3 sm:p-8`,children:[(0,O.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,O.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-slate-950 text-white dark:bg-slate-100 dark:text-slate-950`,children:(0,O.jsx)(IN,{className:`h-5 w-5`})}),(0,O.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生管理台`}),(0,O.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`使用原生管理台处理对话、工具卡片、思考流、审批、中断和运行时历史,避免跨状态机不一致。`}),t?(0,O.jsxs)(`a`,{href:t.href,target:`_blank`,rel:`noreferrer`,title:t.title,className:`mt-5 inline-flex items-center gap-2 rounded-2xl bg-slate-950 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-950 dark:hover:bg-white`,children:[(0,O.jsx)(CN,{className:`h-4 w-4`}),`打开`,t.label]}):(0,O.jsx)(`div`,{className:`mt-5 rounded-2xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm leading-6 text-neutral-800 dark:border-neutral-900/60 dark:bg-neutral-950/30 dark:text-neutral-200`,children:`当前访问模式不开放原生管理入口。需要完整对话体验时,请使用 owner/private 链接或 CLI。`})]}),(0,O.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,O.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-sky-100 text-sky-700 dark:bg-sky-950 dark:text-sky-300`,children:(0,O.jsx)(ON,{className:`h-5 w-5`})}),(0,O.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`Workspace 文件管理`}),(0,O.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`文件浏览、上传、预览仍由 Hosted UI 提供,和原生管理台组合使用覆盖对话与工作区。`}),r?(0,O.jsxs)(`button`,{type:`button`,onClick:i,className:`mt-5 inline-flex items-center gap-2 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-medium text-slate-800 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100 dark:hover:bg-slate-700`,children:[(0,O.jsx)(ON,{className:`h-4 w-4`}),`打开 Workspace`]}):(0,O.jsx)(`div`,{className:`mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400`,children:`当前链接未开放 Workspace 文件管理。Owner 或 private 链接可使用该能力。`})]}),(0,O.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,O.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300`,children:(0,O.jsx)($N,{className:`h-5 w-5`})}),(0,O.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生 TUI`}),(0,O.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`如果运行时暴露安全的 ks-terminal.v1 通道,可以在这里进入原生终端 UI;share 链接不会开放该入口。`}),a?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-5 inline-flex items-center gap-2 rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-2.5 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,O.jsx)($N,{className:`h-4 w-4`}),`打开 TUI`]}):(0,O.jsx)(`div`,{className:`mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400`,children:`当前运行时未声明可用的浏览器 TUI 能力。`})]})]})]})}),n&&o?(0,O.jsx)(v.Suspense,{fallback:null,children:(0,O.jsx)(cY,{capability:n,open:o,onClose:()=>s(!1)})}):null]})}var uY=[],dY=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?dY:uY).push(n+=e[t])})();function fY(e){if(e<768)return!1;for(let t=0,n=uY.length;;){let r=t+n>>1;if(e<uY[r])n=r;else if(e>=dY[r])t=r+1;else return!0;if(t==n)return!1}}function pY(e){return e>=127462&&e<=127487}var mY=8205;function hY(e,t,n=!0,r=!0){return(n?gY:_Y)(e,t,r)}function gY(e,t,n){if(t==e.length)return t;t&&yY(e.charCodeAt(t))&&bY(e.charCodeAt(t-1))&&t--;let r=vY(e,t);for(t+=xY(r);t<e.length;){let i=vY(e,t);if(r==mY||i==mY||n&&fY(i))t+=xY(i),r=i;else if(pY(i)){let n=0,r=t-2;for(;r>=0&&pY(vY(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function _Y(e,t,n){for(;t>0;){let r=gY(e,t-2,n);if(r<t)return r;t--}return 0}function vY(e,t){let n=e.charCodeAt(t);if(!bY(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return yY(r)?(n-55296<<10)+(r-56320)+65536:n}function yY(e){return e>=56320&&e<57344}function bY(e){return e>=55296&&e<56320}function xY(e){return e<65536?1:2}var SY=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=MY(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),wY.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=MY(this,e,t);let n=[];return this.decompose(e,t,n,0),wY.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new OY(this),i=new OY(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new OY(this,e)}iterRange(e,t=this.length){return new kY(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new AY(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new CY(t):wY.from(CY.split(t,[]))}},CY=class e extends SY{constructor(e,t=TY(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new jY(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(DY(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=EY(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=MY(this,t,n);let i=EY(this.text,EY(r.text,DY(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):wY.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
201
|
+
`){[e,t]=MY(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},wY=class e extends SY{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=MY(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
|
|
202
|
+
`){[e,t]=MY(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new CY(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof CY&&c&&(n=u[u.length-1])instanceof CY&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new CY(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};SY.empty=new CY([``],0);function TY(e){let t=-1;for(let n of e)t+=n.length+1;return t}function EY(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function DY(e,t,n){return EY(e,[``],t,n)}var OY=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof CY?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof CY?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
203
|
+
`,this;e--}else if(r instanceof CY){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof CY?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},kY=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new OY(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},AY=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(SY.prototype[Symbol.iterator]=function(){return this.iter()},OY.prototype[Symbol.iterator]=kY.prototype[Symbol.iterator]=AY.prototype[Symbol.iterator]=function(){return this});var jY=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function MY(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function NY(e,t,n=!0,r=!0){return hY(e,t,n,r)}function PY(e){return e>=56320&&e<57344}function FY(e){return e>=55296&&e<56320}function IY(e,t){let n=e.charCodeAt(t);if(!FY(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return PY(r)?(n-55296<<10)+(r-56320)+65536:n}function LY(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function RY(e){return e<65536?1:2}var zY=/\r\n?|\n/,BY=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(BY||={}),VY=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){GY(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:qY(this,e)}mapDesc(e,t=!1){return e.empty?this:KY(this,e,t)}mapPos(e,t=-1,n=BY.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=BY.Simple&&c>=e&&(n==BY.TrackDel&&r<e&&c>e||n==BY.TrackBefore&&r<e||n==BY.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},HY=class e extends VY{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return GY(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return KY(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(SY.empty);r.push(a?t.slice(i,i+a):SY.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:qY(this,e,!0)}map(e,t=!1){return e.empty?this:KY(this,e,t,!0)}iterChanges(e,t=!1){GY(this,e,t)}get desc(){return VY.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new JY(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);UY(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;UY(n,e,t),t>0&&WY(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);UY(n,e,-1),UY(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:VY.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&UY(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?SY.of(l.split(r||zY)):l:SY.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&UY(i,e-o,-1),UY(i,s-e,d),WY(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(SY.empty);r[e]=SY.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function UY(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function WY(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(SY.empty);e.push(n)}}function GY(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=SY.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function KY(e,t,n,r=!1){let i=[],a=r?[]:null,o=new JY(e),s=new JY(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);UY(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(UY(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(UY(i,0,o.ins),a&&WY(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;UY(i,t,e<o.i?o.ins:0),a&&e<o.i&&WY(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?HY.createSet(i,a):VY.create(i);else throw Error(`Mismatched change set lengths`)}function qY(e,t,n=!1){let r=[],i=n?[]:null,a=new JY(e),o=new JY(t);for(let e=!1;;)if(a.done&&o.done)return i?HY.createSet(r,i):VY.create(r);else if(a.ins==0)UY(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)UY(r,0,o.ins,e),i&&WY(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;UY(r,t,n,e),i&&n&&WY(i,r,o.text)}else o.ins==-1?(UY(r,a.off?0:a.len,t,e),i&&WY(i,r,a.textBit(t))):(UY(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&WY(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var JY=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?SY.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?SY.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},YY=class e{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return Y.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return Y.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return Y.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},Y=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>YY.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return YY.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r,i){let a=(n??16777215)<<6|(r==null?7:Math.min(6,r));return!i&&e!=t&&(i=t<e?1:-1),t<e?YY.create(t,e,48|a):YY.create(e,t,(i?i<0?8:16:0)|a)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function XY(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var ZY=0,QY=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=ZY++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:$Y),!!t.static,t.enables)}of(e){return new eX([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new eX(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new eX(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function $Y(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var eX=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=ZY++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||nX(e,c)){let r=t(e);if(a?!tX(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=hX(o,c);if(this.dependencies.every(t=>t instanceof QY?o.facet(t)===e.facet(t):t instanceof aX?o.field(t,!1)==e.field(t,!1):!0)||(a?tX(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}};function tX(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function nX(e,t){let n=!1;for(let r of t)mX(e,r)&1&&(n=!0);return n}function rX(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=hX(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)mX(e,t);return e.values[o]=s(e),1},update(e,n){if(!nX(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=nX(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&$Y(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var iX=QY.define({static:!0}),aX=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(ZY++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(iX).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(iX),i=n.facet(iX),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,iX.of({field:this,create:e})]}get extension(){return this}},oX={lowest:4,low:3,default:2,high:1,highest:0};function sX(e){return t=>new lX(t,e)}var cX={highest:sX(oX.highest),high:sX(oX.high),default:sX(oX.default),low:sX(oX.low),lowest:sX(oX.lowest)},lX=class{constructor(e,t){this.inner=e,this.prec=t}},uX=class e{of(e){return new dX(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},dX=class{constructor(e,t){this.compartment=e,this.inner=t}},fX=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of pX(t,n,o))e instanceof aX?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0))if(s[n.id]=c.length<<1|1,$Y(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>rX(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function pX(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof dX&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof dX){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof lX)a(e.inner,e.prec);else if(e instanceof aX)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof eX)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,oX.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,oX.default),r.reduce((e,t)=>e.concat(t))}function mX(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function hX(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var gX=QY.define(),_X=QY.define({combine:e=>e.some(e=>e),static:!0}),vX=QY.define({combine:e=>e.length?e[0]:void 0,static:!0}),yX=QY.define(),bX=QY.define(),xX=QY.define(),SX=QY.define({combine:e=>e.length?e[0]:!1}),CX=class{constructor(e,t){this.type=e,this.value=t}static define(){return new wX}},wX=class{of(e){return new CX(this,e)}},TX=class{constructor(e){this.map=e}of(e){return new EX(this,e)}},EX=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new TX(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};EX.reconfigure=EX.define(),EX.appendConfig=EX.define();var DX=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&XY(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};DX.time=CX.define(),DX.userEvent=CX.define(),DX.addToHistory=CX.define(),DX.remote=CX.define();function OX(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function kX(e,t,n){let r,i,a;return n?(r=t.changes,i=HY.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:EX.mapEffects(e.effects,r).concat(EX.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function AX(e,t,n){let r=t.selection,i=FX(t.annotations);return t.userEvent&&(i=i.concat(DX.userEvent.of(t.userEvent))),{changes:t.changes instanceof HY?t.changes:HY.of(t.changes||[],n,e.facet(vX)),selection:r&&(r instanceof Y?r:Y.single(r.anchor,r.head)),effects:FX(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function jX(e,t,n){let r=AX(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=kX(r,AX(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=DX.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return NX(n?MX(i):i)}function MX(e){let t=e.startState,n=!0;for(let r of t.facet(yX)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:OX(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=HY.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=DX.create(t,r,e.selection&&e.selection.map(i),EX.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(bX);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof DX?i:Array.isArray(i)&&i.length==1&&i[0]instanceof DX?i[0]:jX(t,FX(i),!1)}return e}function NX(e){let t=e.startState,n=t.facet(xX),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=kX(r,AX(t,a,e.changes.newLength),!0))}return r==e?e:DX.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var PX=[];function FX(e){return e==null?PX:Array.isArray(e)?e:[e]}var IX=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(IX||={}),LX=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,RX;try{RX=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function zX(e){if(RX)return RX.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||LX.test(n)))return!0}return!1}function BX(e){return t=>{if(!/\S/.test(t))return IX.Space;if(zX(t))return IX.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return IX.Word;return IX.Other}}var VX=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)mX(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return mX(this,n),hX(this,n)}update(...e){return jX(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(uX.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(EX.reconfigure)?(n=null,r=e.value):e.is(EX.appendConfig)&&(n=null,r=FX(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=fX.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(_X)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:Y.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=FX(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=EX.mapEffects(a,c).concat(EX.mapEffects(FX(o.effects),l))}return{changes:r,selection:Y.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof HY?t:HY.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return SY.of(t.split(this.facet(e.lineSeparator)||zY))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(mX(this,t),hX(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof aX&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:Y.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=fX.resolve(t.extensions||[],new Map),r=t.doc instanceof SY?t.doc:SY.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||zY)),i=t.selection?t.selection instanceof Y?t.selection:Y.single(t.selection.anchor,t.selection.head):Y.single(0);return XY(i,r.length),n.staticFacet(_X)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
|
|
204
|
+
`}get readOnly(){return this.facet(SX)}phrase(t,...n){for(let n of this.facet(e.phrases))if(Object.prototype.hasOwnProperty.call(n,t)){t=n[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(e,t)=>{if(t==`$`)return`$`;let r=+(t||1);return!r||r>n.length?e:n[r-1]})),t}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(gX))for(let a of i(this,t,n))Object.prototype.hasOwnProperty.call(a,e)&&r.push(a[e]);return r}charCategorizer(e){let t=this.languageDataAt(`wordChars`,e);return BX(t.length?t[0]:``)}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),a=e-n,o=e-n;for(;a>0;){let e=NY(t,a,!1);if(i(t.slice(e,a))!=IX.Word)break;a=e}for(;o<r;){let e=NY(t,o);if(i(t.slice(o,e))!=IX.Word)break;o=e}return a==o?null:Y.range(a+n,o+n)}};VX.allowMultipleSelections=_X,VX.tabSize=QY.define({combine:e=>e.length?e[0]:4}),VX.lineSeparator=vX,VX.readOnly=SX,VX.phrases=QY.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),VX.languageData=gX,VX.changeFilter=yX,VX.transactionFilter=bX,VX.transactionExtender=xX,uX.reconfigure=EX.define();function HX(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],a=r[e];if(a===void 0)r[e]=i;else if(!(a===i||i===void 0))if(Object.hasOwnProperty.call(n,e))r[e]=n[e](a,i);else throw Error(`Config merge conflict for field `+e)}for(let e in t)r[e]===void 0&&(r[e]=t[e]);return r}var UX=class{eq(e){return this==e}range(e,t=e){return GX.create(e,t,this)}};UX.prototype.startSide=UX.prototype.endSide=0,UX.prototype.point=!1,UX.prototype.mapMode=BY.TrackDel;function WX(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var GX=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function KX(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var qX=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let a=r,o=i.length;;){if(a==o)return a;let r=a+o>>1,s=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==a)return s>=0?a:o;s>=0?o=r:a=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),a=this.findIndex(n,1e9,!1,i);i<a;i++)if(r(this.from[i]+e,this.to[i]+e,this.value[i])===!1)return!1}map(t,n){let r=[],i=[],a=[],o=-1,s=-1;for(let e=0;e<this.value.length;e++){let c=this.value[e],l=this.from[e]+t,u=this.to[e]+t,d,f;if(l==u){let e=n.mapPos(l,c.startSide,c.mapMode);if(e==null||(d=f=e,c.startSide!=c.endSide&&(f=n.mapPos(l,c.endSide),f<d)))continue}else if(d=n.mapPos(l,c.startSide),f=n.mapPos(u,c.endSide),d>f||d==f&&c.startSide>0&&c.endSide<=0)continue;(f-d||c.endSide-c.startSide)<0||(o<0&&(o=d),c.point&&(s=Math.max(s,f-d)),r.push(c),i.push(d-o),a.push(f-o))}return{mapped:r.length?new e(i,a,r,s):null,pos:o}}},JX=class e{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(t,n,r,i){return new e(t,n,r,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(t){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:a=this.length}=t,o=t.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(KX)),this.isEmpty)return n.length?e.of(n):this;let s=new QX(this,null,-1).goto(0),c=0,l=[],u=new XX;for(;s.value||c<n.length;)if(c<n.length&&(s.from-n[c].from||s.startSide-n[c].value.startSide)>=0){let e=n[c++];u.addInner(e.from,e.to,e.value)||l.push(e)}else s.rangeIndex==1&&s.chunkIndex<this.chunk.length&&(c==n.length||this.chunkEnd(s.chunkIndex)<n[c].from)&&(!o||i>this.chunkEnd(s.chunkIndex)||a<this.chunkPos[s.chunkIndex])&&u.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||i>s.to||a<s.from||o(s.from,s.to,s.value))&&(u.addInner(s.from,s.to,s.value)||l.push(GX.create(s.from,s.to,s.value))),s.next());return u.finishInner(this.nextLayer.isEmpty&&!l.length?e.empty:this.nextLayer.update({add:l,filter:o,filterFrom:i,filterTo:a}))}map(t){if(t.empty||this.isEmpty)return this;let n=[],r=[],i=-1;for(let e=0;e<this.chunk.length;e++){let a=this.chunkPos[e],o=this.chunk[e],s=t.touchesRange(a,a+o.length);if(s===!1)i=Math.max(i,o.maxPoint),n.push(o),r.push(t.mapPos(a));else if(s===!0){let{mapped:e,pos:s}=o.map(a,t);e&&(i=Math.max(i,e.maxPoint),n.push(e),r.push(s))}}let a=this.nextLayer.map(t);return n.length==0?a:new e(r,n,a||e.empty,i)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],a=this.chunk[r];if(t>=i&&e<=i+a.length&&a.between(i,e-i,t-i,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return $X.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return $X.from(e).goto(t)}static compare(e,t,n,r,i=-1){let a=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=ZX(a,o,n),c=new tZ(a,s,i),l=new tZ(o,s,i);n.iterGaps((e,t,n)=>nZ(c,e,l,t,n,r)),n.empty&&n.length==0&&nZ(c,0,l,0,0,r)}static eq(e,t,n=0,r){r??=999999999;let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),a=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=a.length)return!1;if(!i.length)return!0;let o=ZX(i,a),s=new tZ(i,o,0).goto(n),c=new tZ(a,o,0).goto(n);for(;;){if(s.to!=c.to||!rZ(s.active,c.active)||s.point&&(!c.point||!WX(s.point,c.point)))return!1;if(s.to>r)return!0;s.next(),c.next()}}static spans(e,t,n,r,i=-1){let a=new tZ(e,null,i).goto(t),o=t,s=a.openStart;for(;;){let e=Math.min(a.to,n);if(a.point){let n=a.activeForPoint(a.to),i=a.pointFrom<t?n.length+1:a.point.startSide<0?n.length:Math.min(n.length,s);r.point(o,e,a.point,n,i,a.pointRank),s=Math.min(a.openEnd(e),n.length)}else e>o&&(r.span(o,e,a.active,s),s=a.openEnd(e));if(a.to>n)return s+(a.point&&a.to>n?1:0);o=a.to,a.next()}}static of(e,t=!1){let n=new XX;for(let r of e instanceof GX?[e]:t?YX(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(t){if(!t.length)return e.empty;let n=t[t.length-1];for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=e.empty;i=i.nextLayer)n=new e(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};JX.empty=new JX([],[],null,-1);function YX(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(KX(t,r)>0)return e.slice().sort(KX);t=r}return e}JX.empty.nextLayer=JX.empty;var XX=class e{finishChunk(e){this.chunks.push(new qX(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,n,r){this.addInner(t,n,r)||(this.nextLayer||=new e).add(t,n,r)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(JX.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=JX.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function ZX(e,t,n){let r=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let a=r.get(e.chunk[t]);a!=null&&(n?n.mapPos(a):a)==e.chunkPos[t]&&!n?.touchesRange(a,a+e.chunk[t].length)&&i.add(e.chunk[t])}return i}var QX=class{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},$X=class e{constructor(e){this.heap=e}static from(t,n=null,r=-1){let i=[];for(let e=0;e<t.length;e++)for(let a=t[e];!a.isEmpty;a=a.nextLayer)a.maxPoint>=r&&i.push(new QX(a,n,r,e));return i.length==1?i[0]:new e(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)eZ(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)eZ(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),eZ(this.heap,0)}}};function eZ(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}var tZ=class{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=$X.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){iZ(this.active,e),iZ(this.activeTo,e),iZ(this.activeRank,e),this.minActive=oZ(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;aZ(this.active,t,n),aZ(this.activeTo,t,r),aZ(this.activeRank,t,i),e&&aZ(e,t,this.cursor.from),this.minActive=oZ(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&iZ(n,r)}else if(!this.cursor.value){this.to=this.endSide=1e9;break}else if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let e=this.cursor.value;if(!e.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function nZ(e,t,n,r,i,a){e.goto(t),n.goto(r);let o=r+i,s=r,c=r-t,l=!!a.boundChange;for(let t=!1;;){let r=e.to+c-n.to,i=r||e.endSide-n.endSide,u=i<0?e.to+c:n.to,d=Math.min(u,o);if(e.point||n.point?(e.point&&n.point&&WX(e.point,n.point)&&rZ(e.activeForPoint(e.to),n.activeForPoint(n.to))||a.comparePoint(s,d,e.point,n.point),t=!1):(t&&a.boundChange(s),d>s&&!rZ(e.active,n.active)&&a.compareRange(s,d,e.active,n.active),l&&d<o&&(r||e.openEnd(u)!=n.openEnd(u))&&(t=!0)),u>o)break;s=u,i<=0&&e.next(),i>=0&&n.next()}}function rZ(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!WX(e[n],t[n]))return!1;return!0}function iZ(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function aZ(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function oZ(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function sZ(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)e.charCodeAt(i)==9?(r+=t-r%t,i++):(r++,i=NY(e,i));return r}function cZ(e,t,n,r){for(let r=0,i=0;;){if(i>=t)return r;if(r==e.length)break;i+=e.charCodeAt(r)==9?n-i%n:1,r=NY(e,r)}return r===!0?-1:e.length}for(var lZ=`ͼ`,uZ=typeof Symbol>`u`?`__ͼ`:Symbol.for(lZ),dZ=typeof Symbol>`u`?`__styleSet`+Math.floor(Math.random()*1e8):Symbol(`styleSet`),fZ=typeof globalThis<`u`?globalThis:typeof window<`u`?window:{},pZ=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,a,o){let s=[],c=/^@(\w+)\b/.exec(e[0]),l=c&&c[1]==`keyframes`;if(c&&t==null)return a.push(e[0]+`;`);for(let n in t){let o=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),o,a);else if(o&&typeof o==`object`){if(!c)throw RangeError(`The value of a property (`+n+`) should be a primitive value.`);i(r(n),o,s,l)}else o!=null&&s.push(n.replace(/_.*/,``).replace(/[A-Z]/g,e=>`-`+e.toLowerCase())+`: `+o+`;`)}(s.length||l)&&a.push((n&&!c&&!o?e.map(n):e).join(`, `)+` {`+s.join(` `)+`}`)}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join(`
|
|
205
|
+
`)}static newName(){let e=fZ[uZ]||1;return fZ[uZ]=e+1,lZ+e.toString(36)}static mount(e,t,n){let r=e[dZ],i=n&&n.nonce;r?i&&r.setNonce(i):r=new hZ(e,i),r.mount(Array.isArray(t)?t:[t],e)}},mZ=new Map,hZ=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=mZ.get(n);if(t)return e[dZ]=t;this.sheet=new r.CSSStyleSheet,mZ.set(n,this)}else this.styleTag=n.createElement(`style`),t&&this.styleTag.setAttribute(`nonce`,t);this.modules=[],e[dZ]=this}mount(e,t){let n=this.sheet,r=0,i=0;for(let t=0;t<e.length;t++){let a=e[t],o=this.modules.indexOf(a);if(o<i&&o>-1&&(this.modules.splice(o,1),i--,o=-1),o==-1){if(this.modules.splice(i++,0,a),n)for(let e=0;e<a.rules.length;e++)n.insertRule(a.rules[e],r++)}else{for(;i<o;)r+=this.modules[i++].rules.length;r+=a.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e=``;for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+`
|
|
206
|
+
`;this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute(`nonce`)!=e&&this.styleTag.setAttribute(`nonce`,e)}},gZ={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},_Z={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},vZ=typeof navigator<`u`&&/Mac/.test(navigator.platform),yZ=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),bZ=0;bZ<10;bZ++)gZ[48+bZ]=gZ[96+bZ]=String(bZ);for(var bZ=1;bZ<=24;bZ++)gZ[bZ+111]=`F`+bZ;for(var bZ=65;bZ<=90;bZ++)gZ[bZ]=String.fromCharCode(bZ+32),_Z[bZ]=String.fromCharCode(bZ);for(var xZ in gZ)_Z.hasOwnProperty(xZ)||(_Z[xZ]=gZ[xZ]);function SZ(e){var t=!(vZ&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||yZ&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?_Z:gZ)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}function CZ(){var e=arguments[0];typeof e==`string`&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&typeof n==`object`&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i==`string`?e.setAttribute(r,i):i!=null&&(e[r]=i)}t++}for(;t<arguments.length;t++)wZ(e,arguments[t]);return e}function wZ(e,t){if(typeof t==`string`)e.appendChild(document.createTextNode(t));else if(t!=null)if(t.nodeType!=null)e.appendChild(t);else if(Array.isArray(t))for(var n=0;n<t.length;n++)wZ(e,t[n]);else throw RangeError(`Unsupported child node: `+t)}var TZ=typeof navigator<`u`?navigator:{userAgent:``,vendor:``,platform:``},EZ=typeof document<`u`?document:{documentElement:{style:{}}},DZ=/Edge\/(\d+)/.exec(TZ.userAgent),OZ=/MSIE \d/.test(TZ.userAgent),kZ=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(TZ.userAgent),AZ=!!(OZ||kZ||DZ),jZ=!AZ&&/gecko\/(\d+)/i.test(TZ.userAgent),MZ=!AZ&&/Chrome\/(\d+)/.exec(TZ.userAgent),NZ=`webkitFontSmoothing`in EZ.documentElement.style,PZ=!AZ&&/Apple Computer/.test(TZ.vendor),FZ=PZ&&(/Mobile\/\w+/.test(TZ.userAgent)||TZ.maxTouchPoints>2),IZ={mac:FZ||/Mac/.test(TZ.platform),windows:/Win/.test(TZ.platform),linux:/Linux|X11/.test(TZ.platform),ie:AZ,ie_version:OZ?EZ.documentMode||6:kZ?+kZ[1]:DZ?+DZ[1]:0,gecko:jZ,gecko_version:jZ?+(/Firefox\/(\d+)/.exec(TZ.userAgent)||[0,0])[1]:0,chrome:!!MZ,chrome_version:MZ?+MZ[1]:0,ios:FZ,android:/Android\b/.test(TZ.userAgent),webkit:NZ,webkit_version:NZ?+(/\bAppleWebKit\/(\d+)/.exec(TZ.userAgent)||[0,0])[1]:0,safari:PZ,safari_version:PZ?+(/\bVersion\/(\d+(\.\d+)?)/.exec(TZ.userAgent)||[0,0])[1]:0,tabSize:EZ.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function LZ(e,t){for(let n in e)n==`class`&&t.class?t.class+=` `+e.class:n==`style`&&t.style?t.style+=`;`+e.style:t[n]=e[n];return t}var RZ=Object.create(null);function zZ(e,t,n){if(e==t)return!0;e||=RZ,t||=RZ;let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let a of r)if(a!=n&&(i.indexOf(a)==-1||e[a]!==t[a]))return!1;return!0}function BZ(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]??e.removeAttribute(r)}for(let n in t){let r=t[n];n==`style`?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function VZ(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i==`style`?e.style.cssText=``:e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i==`style`?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function HZ(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}var UZ=class{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},WZ=(function(e){return e[e.Text=0]=`Text`,e[e.WidgetBefore=1]=`WidgetBefore`,e[e.WidgetAfter=2]=`WidgetAfter`,e[e.WidgetRange=3]=`WidgetRange`,e})(WZ||={}),GZ=class extends UX{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new KZ(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new JZ(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:i,end:a}=YZ(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new JZ(e,n,r,t,e.widget||null,!0)}static line(e){return new qZ(e)}static set(e,t=!1){return JX.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};GZ.none=JX.empty;var KZ=class e extends GZ{constructor(e){let{start:t,end:n}=YZ(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?LZ(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||RZ}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&zZ(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};KZ.prototype.point=!1;var qZ=class e extends GZ{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&zZ(this.spec.attributes,t.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError(`Line decoration ranges must be zero-length`);return super.range(e,t)}};qZ.prototype.mapMode=BY.TrackBefore,qZ.prototype.point=!0;var JZ=class e extends GZ{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?BY.TrackBefore:BY.TrackAfter:BY.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?WZ.WidgetBefore:WZ.WidgetAfter:WZ.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&XZ(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError(`Invalid range for replacement decoration`);if(!this.isReplace&&t!=e)throw RangeError(`Widget decorations can only have zero-length ranges`);return super.range(e,t)}};JZ.prototype.point=!0;function YZ(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function XZ(e,t){return e==t||!!(e&&t&&e.compare(t))}function ZZ(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var QZ=class e extends UX{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(t){return t==this||t instanceof e&&this.tagName==t.tagName&&zZ(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||RZ,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(e,t=!1){return JX.of(e,t)}};QZ.prototype.startSide=QZ.prototype.endSide=-1;function $Z(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function eQ(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function tQ(e,t){if(!t.anchorNode)return!1;try{return eQ(e,t.anchorNode)}catch{return!1}}function nQ(e){return e.nodeType==3?_Q(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function rQ(e,t,n,r){return n?oQ(e,t,n,r,-1)||oQ(e,t,n,r,1):!1}function iQ(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function aQ(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function oQ(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:sQ(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||n.nodeType!=1)return!1;t=iQ(e)+(i<0?0:1),e=n}else if(e.nodeType==1){if(e=e.childNodes[t+(i<0?-1:0)],e.nodeType==1&&e.contentEditable==`false`)return!1;t=i<0?sQ(e):0}else return!1}}function sQ(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function cQ(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function lQ(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function uQ(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function dQ(e,t,n,r,i,a,o,s){let c=e.ownerDocument,l=c.defaultView||window;for(let u=e,d=!1;u&&!d;)if(u.nodeType==1){let e,f=u==c.body,p=1,m=1;if(f)e=lQ(l);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let t=u.getBoundingClientRect();({scaleX:p,scaleY:m}=uQ(u,t)),e={left:t.left,right:t.left+u.clientWidth*p,top:t.top,bottom:t.top+u.clientHeight*m}}let h=0,g=0;if(i==`nearest`)t.top<e.top+o?(g=t.top-(e.top+o),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom-o&&(g=t.bottom-e.bottom+o,n<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let r=t.bottom-t.top,a=e.bottom-e.top;g=(i==`center`&&r<=a?t.top+r/2-a/2:i==`start`||i==`center`&&n<0?t.top-o:t.bottom-a+o)-e.top}if(r==`nearest`?t.left<e.left+a?(h=t.left-(e.left+a),n>0&&t.right>e.right+h&&(h=t.right-e.right+a)):t.right>e.right-a&&(h=t.right-e.right+a,n<0&&t.left<e.left+h&&(h=t.left-(e.left+a))):h=(r==`center`?t.left+(t.right-t.left)/2-(e.right-e.left)/2:r==`start`==s?t.left-a:t.right-(e.right-e.left)+a)-e.left,h||g)if(f)l.scrollBy(h,g);else{let e=0,n=0;if(g){let e=u.scrollTop;u.scrollTop+=g/m,n=(u.scrollTop-e)*m}if(h){let t=u.scrollLeft;u.scrollLeft+=h/p,e=(u.scrollLeft-t)*p}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-h)<1&&(r=`nearest`),n&&Math.abs(n-g)<1&&(i=`nearest`)}if(f)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function fQ(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let a=e.parentNode;a&&!(a==n.body||(!t||r)&&i);)if(a.nodeType==1)!i&&a.scrollHeight>a.clientHeight&&(i=a),t&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:i}}var pQ=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?sQ(t):0),n,Math.min(e.focusOffset,n?sQ(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}},mQ=null;IZ.safari&&IZ.safari_version>=26&&(mQ=!1);function hQ(e){if(e.setActive)return e.setActive();if(mQ)return e.focus(mQ);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(mQ==null?{get preventScroll(){return mQ={preventScroll:!0},!0}}:void 0),!mQ){mQ=!1;for(let e=0;e<t.length;){let n=t[e++],r=t[e++],i=t[e++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}}}var gQ;function _Q(e,t,n=t){let r=gQ||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function vQ(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let a=new KeyboardEvent(`keydown`,i);a.synthetic=!0,e.dispatchEvent(a);let o=new KeyboardEvent(`keyup`,i);return o.synthetic=!0,e.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented}function yQ(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function bQ(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,sQ(n));;)if(r){if(n.nodeType!=1)return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=sQ(n))}else if(n==e)return!0;else r=iQ(n),n=n.parentNode}function xQ(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function SQ(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r>0)return{node:n,offset:r};else if(n.nodeType==1&&r>0){if(n.contentEditable==`false`)return null;n=n.childNodes[r-1],r=sQ(n)}else if(n.parentNode&&!aQ(n))r=iQ(n),n=n.parentNode;else return null}function CQ(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r<n.nodeValue.length)return{node:n,offset:r};else if(n.nodeType==1&&r<n.childNodes.length){if(n.contentEditable==`false`)return null;n=n.childNodes[r],r=0}else if(n.parentNode&&!aQ(n))r=iQ(n)+1,n=n.parentNode;else return null}var wQ=class e{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(t,n){return new e(t.parentNode,iQ(t),n)}static after(t,n){return new e(t.parentNode,iQ(t)+1,n)}},TQ=(function(e){return e[e.LTR=0]=`LTR`,e[e.RTL=1]=`RTL`,e})(TQ||={}),EQ=TQ.LTR,DQ=TQ.RTL;function OQ(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<e[n]);return t}var kQ=OQ(`88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008`),AQ=OQ(`4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333`),jQ=Object.create(null),MQ=[];for(let e of[`()`,`[]`,`{}`]){let t=e.charCodeAt(0),n=e.charCodeAt(1);jQ[t]=n,jQ[n]=-t}function NQ(e){return e<=247?kQ[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?AQ[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var PQ=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,FQ=class{get dir(){return this.level%2?DQ:EQ}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let i=-1;for(let a=0;a<e.length;a++){let o=e[a];if(o.from<=t&&o.to>=t){if(o.level==n)return a;(i<0||(r==0?e[i].level>o.level:r<0?o.from<t:o.to>t))&&(i=a)}}if(i<0)throw RangeError(`Index out of range`);return i}};function IQ(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!IQ(r.inner,i.inner))return!1}return!0}var LQ=[];function RQ(e,t,n,r,i){for(let a=0;a<=r.length;a++){let o=a?r[a-1].to:t,s=a<r.length?r[a].from:n,c=a?256:i;for(let t=o,n=c,r=c;t<s;t++){let i=NQ(e.charCodeAt(t));i==512?i=n:i==8&&r==4&&(i=16),LQ[t]=i==4?2:i,i&7&&(r=i),n=i}for(let e=o,t=c,r=c;e<s;e++){let i=LQ[e];if(i==128)e<s-1&&t==LQ[e+1]&&t&24?i=LQ[e]=t:LQ[e]=256;else if(i==64){let i=e+1;for(;i<s&&LQ[i]==64;)i++;let a=e&&t==8||i<n&&LQ[i]==8?r==1?1:8:256;for(let t=e;t<i;t++)LQ[t]=a;e=i-1}else i==8&&r==1&&(LQ[e]=1);t=i,i&7&&(r=i)}}}function zQ(e,t,n,r,i){let a=i==1?2:1;for(let o=0,s=0,c=0;o<=r.length;o++){let l=o?r[o-1].to:t,u=o<r.length?r[o].from:n;for(let t=l,n,r,o;t<u;t++)if(r=jQ[n=e.charCodeAt(t)])if(r<0){for(let e=s-3;e>=0;e-=3)if(MQ[e+1]==-r){let n=MQ[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(LQ[t]=LQ[MQ[e]]=r),s=e;break}}else if(MQ.length==189)break;else MQ[s++]=t,MQ[s++]=n,MQ[s++]=c;else if((o=LQ[t])==2||o==1){let e=o==i;c=+!e;for(let t=s-3;t>=0;t-=3){let n=MQ[t+2];if(n&2)break;if(e)MQ[t+2]|=2;else{if(n&4)break;MQ[t+2]|=4}}}}}function BQ(e,t,n,r){for(let i=0,a=r;i<=n.length;i++){let o=i?n[i-1].to:e,s=i<n.length?n[i].from:t;for(let c=o;c<s;){let o=LQ[c];if(o==256){let o=c+1;for(;;)if(o==s){if(i==n.length)break;o=n[i++].to,s=i<n.length?n[i].from:t}else if(LQ[o]==256)o++;else break;let l=a==1,u=l==((o<t?LQ[o]:r)==1)?l?1:2:r;for(let t=o,r=i,a=r?n[r-1].to:e;t>c;)t==a&&(t=n[--r].from,a=r?n[r-1].to:e),LQ[--t]=u;c=o}else a=o,c++}}}function VQ(e,t,n,r,i,a,o){let s=r%2?2:1;if(r%2==i%2)for(let c=t,l=0;c<n;){let t=!0,u=!1;if(l==a.length||c<a[l].from){let e=LQ[c];e!=s&&(t=!1,u=e==16)}let d=!t&&s==1?[]:null,f=t?r:r+1,p=c;run:for(;;)if(l<a.length&&p==a[l].from){if(u)break run;let m=a[l];if(!t)for(let e=m.to,t=l+1;;){if(e==n)break run;if(t<a.length&&a[t].from==e)e=a[t++].to;else if(LQ[e]==s)break run;else break}l++,d?d.push(m):(m.from>c&&o.push(new FQ(c,m.from,f)),HQ(e,m.direction==EQ==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?LQ[p]!=s:LQ[p]==s))break;else p++;d?VQ(e,c,p,r+1,i,d,o):c<p&&o.push(new FQ(c,p,f)),c=p}else for(let c=n,l=a.length;c>t;){let n=!0,u=!1;if(!l||c>a[l-1].to){let e=LQ[c-1];e!=s&&(n=!1,u=e==16)}let d=!n&&s==1?[]:null,f=n?r:r+1,p=c;run:for(;;)if(l&&p==a[l-1].to){if(u)break run;let m=a[--l];if(!n)for(let e=m.from,n=l;;){if(e==t)break run;if(n&&a[n-1].to==e)e=a[--n].from;else if(LQ[e-1]==s)break run;else break}d?d.push(m):(m.to<c&&o.push(new FQ(m.to,c,f)),HQ(e,m.direction==EQ==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.from),p=m.from}else if(p==t||(n?LQ[p-1]!=s:LQ[p-1]==s))break;else p--;d?VQ(e,p,c,r+1,i,d,o):p<c&&o.push(new FQ(p,c,f)),c=p}}function HQ(e,t,n,r,i,a,o){let s=t%2?2:1;RQ(e,i,a,r,s),zQ(e,i,a,r,s),BQ(i,a,r,s),VQ(e,i,a,t,n,r,o)}function UQ(e,t,n){if(!e)return[new FQ(0,0,+(t==DQ))];if(t==EQ&&!n.length&&!PQ.test(e))return WQ(e.length);if(n.length)for(;e.length>LQ.length;)LQ[LQ.length]=256;let r=[],i=t==EQ?0:1;return HQ(e,i,i,n,0,e.length,r),r}function WQ(e){return[new FQ(0,e,0)]}var GQ=``;function KQ(e,t,n,r,i){let a=r.head-e.from,o=FQ.find(t,a,r.bidiLevel??-1,r.assoc),s=t[o],c=s.side(i,n);if(a==c){let e=o+=i?1:-1;if(e<0||e>=t.length)return null;s=t[o=e],a=s.side(!i,n),c=s.side(i,n)}let l=NY(e.text,a,s.forward(i,n));(l<s.from||l>s.to)&&(l=c),GQ=e.text.slice(Math.min(a,l),Math.max(a,l));let u=o==(i?t.length-1:0)?null:t[o+(i?1:-1)];return u&&l==c&&u.level+ +!i<s.level?Y.cursor(u.side(!i,n)+e.from,u.forward(i,n)?1:-1,u.level):Y.cursor(l+e.from,s.forward(i,n)?-1:1,s.level)}function qQ(e,t,n){for(let r=t;r<n;r++){let t=NQ(e.charCodeAt(r));if(t==1)return EQ;if(t==2||t==4)return DQ}return EQ}var JQ=QY.define(),YQ=QY.define(),XQ=QY.define(),ZQ=QY.define(),QQ=QY.define(),$Q=QY.define(),e$=QY.define(),t$=QY.define(),n$=QY.define(),r$=QY.define({combine:e=>e.some(e=>e)}),i$=QY.define({combine:e=>e.some(e=>e)}),a$=QY.define(),o$=class e{constructor(e,t,n,r,i,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=a}map(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new e(Y.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},s$=EX.define({map:(e,t)=>e.map(t)}),c$=EX.define();function l$(e,t,n){let r=e.facet(ZQ);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+`:`,t):console.error(t))}var u$=QY.define({combine:e=>e.length?e[0]:!0}),d$=0,f$=QY.define({combine(e){return e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})}}),p$=class e{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(f$.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(f$.of({plugin:this,arg:e}))}static define(t,n){let{eventHandlers:r,eventObservers:i,provide:a,decorations:o}=n||{};return new e(d$++,t,r,i,e=>{let t=[];return o&&t.push(_$.of(t=>{let n=t.plugin(e);return n?o(n):GZ.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},m$=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(!this.value){if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){l$(e.state,t,`CodeMirror plugin crashed`),this.deactivate()}}else if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(l$(e.state,t,`CodeMirror plugin crashed`),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}return this}destroy(e){if(this.value?.destroy)try{this.value.destroy()}catch(t){l$(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}},h$=QY.define(),g$=QY.define(),_$=QY.define(),v$=QY.define(),y$=QY.define(),b$=QY.define(),x$=QY.define();function S$(e,t){let n=e.state.facet(x$);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return JX.spans(r,t.from,t.to,{point(){},span(e,n,r,a){let o=e-t.from,s=n-t.from,c=i;for(let e=r.length-1;e>=0;e--,a--){let n=r[e].spec.bidiIsolate,i;if(n??=qQ(t.text,o,s),a>0&&c.length&&(i=c[c.length-1]).to==o&&i.direction==n)i.to=s,c=i.inner;else{let e={from:o,to:s,direction:n,inner:[]};c.push(e),c=e.inner}}}}),i}var C$=QY.define();function w$(e){let t=0,n=0,r=0,i=0;for(let a of e.state.facet(C$)){let o=a(e);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:t,right:n,top:r,bottom:i}}var T$=QY.define(),E$=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(t){return new e(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(t,n){if(n.length==0)return t;let r=[];for(let i=0,a=0,o=0;;){let s=i<t.length?t[i].fromB:1e9,c=a<n.length?n[a]:1e9,l=Math.min(s,c);if(l==1e9)break;let u=l+o,d=l,f=u;for(;;)if(a<n.length&&n[a]<=d){let e=n[a+1];a+=2,d=Math.max(d,e);for(let e=i;e<t.length&&t[e].fromB<=d;e++)o=t[e].toA-t[e].toB;f=Math.max(f,e+o)}else if(i<t.length&&t[i].fromB<=d){let e=t[i++];d=Math.max(d,e.toB),f=Math.max(f,e.toA),o=e.toA-e.toB}else break;r.push(new e(u,f,l,d))}return r}},D$=class e{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=HY.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new E$(e,t,n,i))),this.changedRanges=r}static create(t,n,r){return new e(t,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},O$=[],k$=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return O$}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&BZ(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:``)+(this.breakAfter?`#`:``)}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw RangeError(`Invalid child in posBefore`)}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=iQ(this.dom),r=this.length?e>0:t>0;return new wQ(this.parent.dom,n+ +!!r,e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof M$)return e;return null}static get(e){return e.cmTile}},A$=class extends k${constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,r,i=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=j$(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=j$(r);this.length=a}};function j$(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var M$=class extends A${constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=k$.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let a=n.children[r++];if(a instanceof N$)t.push(r),n=a,r=0;else{let t=i+a.length,n=e(a,i);if(n!==void 0)return n;i=t+a.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,a=-1;if(this.blockTiles((o,s)=>{let c=s+o.length;if(e>=s&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(s<e||e==c&&(t<-1?o.length:o.covers(1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,r=e-s),(c>e||e==s&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,a=e-s)}}),!n&&!i)throw Error(`No tile at position `+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:a}}},N$=class e extends A${constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},P$=class e extends A${constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(t,n,r){let i=new e(n||document.createElement(`div`),t);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,i=-1,a=null,o=-1;function s(e,c){for(let l=0,u=0;l<e.children.length&&u<=c;l++){let d=e.children[l],f=u+d.length;f>=c&&(d.isComposite()?s(d,c-u):(!a||a.isHidden&&(t>0||n&&I$(a,d)))&&(f>c||d.flags&32)?(a=d,o=c-u):(u<c||d.flags&16&&!d.isHidden)&&(r=d,i=c-u)),u=f}}s(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?i:o}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):F$(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new wQ(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,e.flags&16?1:e.flags&32?-1:t);let i=n.tile.parent,a=!1;for(let e of i.children){if(a)return new wQ(e.dom,0);e==n.tile&&(a=!0)}}return new wQ(this.dom,0)}};function F$(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=nQ(t);return n[n.length-1]||null}function I$(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var L$=class e extends A${constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},R$=class e extends k${constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,i=e,a=0;e==0&&t<0||e==n&&t>=0?IZ.chrome||IZ.gecko||(e?(r--,a=1):i<n&&(i++,a=-1)):t<0?r--:i<n&&i++;let o=_Q(this.dom,r,i).getClientRects();if(!o.length)return null;let s=o[(a?a<0:t>=0)?0:o.length-1];return IZ.safari&&!a&&s.width==0&&(s=Array.prototype.find.call(o,e=>e.width)||s),a?cQ(s,a<0):s||null}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},z$=class e extends k${constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return cQ(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?i==0:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return cQ(n,!r)}}get overrideDOMText(){if(!this.length)return SY.empty;let{root:e}=this;if(!e)return SY.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,n,r,i,a){return a||(a=t.toDOM(n),t.editable||(a.contentEditable=`false`)),new e(a,r,t,i)}},B$=class extends k${constructor(e){let t=document.createElement(`img`);t.className=`cm-widgetBuffer`,t.setAttribute(`aria-hidden`,`true`),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return SY.empty}coordsIn(e){return this.dom.getBoundingClientRect()}},V$=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(!r.isComposite())if(i==r.length)a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++;else if(e){let t=Math.min(e,r.length-i);n&&n.skip(r,i,i+t),e-=t,i+=t}else break;else if(a){if(!e)break;n&&n.break(),e--,a=!1}else if(i==r.children.length){if(!e&&!o.length)break;n&&n.leave(r),a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++}else{let s=r.children[i],c=s.breakAfter;(t>0?s.length<=e:s.length<e)&&(!n||n.skip(s,0,s.length)!==!1||!s.isComposite)?(a=!!c,i++,e-=s.length):(o.push({tile:r,index:i}),r=s,i=0,n&&s.isComposite()&&n.enter(s))}return this.tile=r,this.index=i,this.beforeBreak=a,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},H$=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},U$=class{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){this.flushBuffer();let i=this.ensureMarks(t,n),a=i.lastChild;if(a&&a.isText()&&!(a.flags&8)&&a.length+e.length<512){this.cache.reused.set(a,2);let t=i.children[i.children.length-1]=new R$(a.dom,a.text+e);t.parent=i}else i.append(r||R$.of(e,this.cache.find(R$)?.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?$$(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof L$&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM($$(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=k$.get(n.dom);e&&e.setDOM($$(n.dom))}let e=L$.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=k$.get(e.text);i&&this.cache.reused.set(i,2);let a=new R$(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,r.append(a)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){e||=X$;let n=P$.start(e,t||this.cache.find(P$)?.dom,!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){let n=this.curLine;for(let r=e.length-1;r>=0;r--){let i=e[r],a;if(t>0&&(a=n.lastChild)&&a instanceof L$&&a.mark.eq(i))n=a,t--;else{let e=L$.of(i,this.cache.find(L$,e=>e.mark.eq(i))?.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!J$(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!(IZ.ios&&J$(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(t1,0,32)||new z$(t1.toDOM(),0,t1,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,n=new H$(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){this.updateBlockWrappers();let e=this.root;for(let t of this.wrappers){let n=e.lastChild;if(t.from<this.pos&&n instanceof N$&&n.wrapper.eq(t.wrapper))e=n;else{let n=N$.of(t.wrapper,this.cache.find(N$,e=>e.wrapper.eq(t.wrapper))?.dom);e.append(n),e=n}}return e}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(B$,void 0,1);return n&&(n.flags=t),n||new B$(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},W$=class{constructor(e){this.skipCount=0,this.text=``,this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text=``,this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw Error(`Ran out of text content when drawing inline views`);this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},G$=[z$,P$,R$,L$,B$,N$,M$];for(let e=0;e<G$.length;e++)G$[e].bucket=e;var K$=class{constructor(e){this.view=e,this.buckets=G$.map(()=>[]),this.index=G$.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],a=this.index[r];for(let e=i.length-1;e>=0;e--){let o=(e+a)%i.length,s=i[o];if((!t||t(s))&&!this.reused.has(s))return i.splice(o,1),o<a&&this.index[r]--,this.reused.set(s,n),s}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,a=0;;i++){if(i==r.length){if(a)return null;a=1,i=0}let o=r[i];if(!this.reused.has(o)&&(a==0?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(o.flags&497)==n?(this.reused.set(o,1),o):(this.reused.set(o,2),new z$(o.dom,t,e,o.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},q$=class{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new K$(e),this.text=new W$(e.state.doc),this.builder=new U$(this.cache,new M$(e,e.contentDOM),JX.iter(n)),this.cache.reused.set(t,2),this.old=new V$(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,a=0;;){let o=a<e.length?e[a++]:null,s=o?o.fromA:this.old.root.length;if(s>r){let e=s-r;this.preserve(e,!a,!o),r=s,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(i,o.toB)),i=o.toB,r=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=Q$(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let a=n>0||t<e.length?z$.of(e.widget,this.view,n-t,e.flags&496,this.cache.maybeReuse(e)):this.cache.reuse(e);a.flags&256?(a.flags&=-2,this.builder.addBlockWidget(a)):(this.builder.ensureLine(null),this.builder.addInlineWidget(a,r,i),i=r.length)}else if(e.isText())this.builder.ensureLine(null),!t&&n==e.length&&!this.cache.reused.has(e)?this.builder.addText(e.text,r,i,this.cache.reuse(e)):(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof B$)this.cache.add(e);else if(e instanceof L$)this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length;else return!1;this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof L$&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof L$&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=0,a=JX.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof JZ){if(this.disallowBlockEffectsFor[c]){if(a.block)throw RangeError(`Block decorations may not be specified via plugins`);if(t>this.view.state.doc.lineAt(e).to)throw RangeError(`Decorations that replace line breaks may not be specified via plugins`)}if(i=o.length,s>o.length)r.continueWidget(t-e);else{let i=a.widget||(a.block?e1.block:e1.inline),c=Y$(a),l=this.cache.findWidget(i,t-e,c)||z$.of(i,this.view,t-e,c);a.block?(a.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(l)):(r.ensureLine(n),r.addInlineWidget(l,o,s))}n=null}else n=Z$(n,a);t>e&&this.text.skip(t-e)},span:(e,t,i,a)=>{for(let o=e;o<t;){let s=this.text.next(Math.min(512,t-o));s==null?(r.addLineStartIfNotCovered(n),r.addBreak(),o++):(r.ensureLine(n),r.addText(s,i,o==e?a:i.length),o+=s.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=a>i,this.openMarks=a}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=k$.get(r);if(r==this.view.contentDOM)break;e instanceof L$?t.push(e):e?.isLine()?n=e:e instanceof N$||(r.nodeName==`DIV`&&!n&&r!=this.view.contentDOM?n=new P$(r,X$):n||t.push(L$.of(new KZ({tagName:r.nodeName.toLowerCase(),attributes:HZ(r)}),r)))}return{line:n,marks:t}}};function J$(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function Y$(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}var X$={class:`cm-line`};function Z$(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r?e:(e||={class:`cm-line`},n&&LZ(n,e),r&&(e.class+=` `+r),e)}function Q$(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof L$&&t.push(r.mark)}return t}function $$(e){let t=k$.get(e);return t&&t.setDOM(e.cloneNode()),e}var e1=class extends UZ{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};e1.inline=new e1(`span`),e1.block=new e1(`div`);var t1=new class extends UZ{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}},n1=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=GZ.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new M$(e,e.contentDOM),this.updateInner([new E$(0,0,0,e.state.doc.length)],null)}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(this.domChanged?.newSel?n=this.domChanged.newSel.head:!p1(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?o1(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new E$(n,r,e.changes.mapPos(n,-1),e.changes.mapPos(r,1)).addToSet(t.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(IZ.ie||IZ.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,a=this.blockWrappers;this.updateDeco();let o=l1(i,this.decorations,e.changes);o.length&&(t=E$.extendWithRanges(t,o));let s=d1(a,this.blockWrappers,e.changes);return s.length&&(t=E$.extendWithRanges(t,s)),r&&!t.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(t=r.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new q$(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&k$.get(t.text)&&r.cache.reused.set(k$.get(t.text),2),this.tile=r.run(e,t),r1(n,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+`px`,this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+`px`:``;let r=IZ.chrome||IZ.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=``});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof m1&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(c$)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,a=!i&&!(this.view.state.facet(u$)||n.tabIndex>-1)&&tQ(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||a))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,c,l;if(s.empty?l=c=this.inlineDOMNearPos(s.anchor,s.assoc||1):(l=this.inlineDOMNearPos(s.head,s.head==s.from?1:-1),c=this.inlineDOMNearPos(s.anchor,s.anchor==s.from?1:-1)),IZ.gecko&&s.empty&&!this.hasComposition&&i1(c)){let e=document.createTextNode(``);this.view.observer.ignore(()=>c.node.insertBefore(e,c.node.childNodes[c.offset]||null)),c=l=new wQ(e,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!rQ(c.node,c.offset,u.anchorNode,u.anchorOffset)||!rQ(l.node,l.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,s))&&(this.view.observer.ignore(()=>{IZ.android&&IZ.chrome&&n.contains(u.focusNode)&&f1(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=$Z(this.view.root);if(e)if(s.empty){if(IZ.gecko){let e=s1(c.node,c.offset);if(e&&e!=3){let t=(e==1?SQ:CQ)(c.node,c.offset);t&&(c=new wQ(t.node,t.offset))}}e.collapse(c.node,c.offset),s.bidiLevel!=null&&e.caretBidiLevel!==void 0&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(c.node,c.offset);try{e.extend(l.node,l.offset)}catch{}}else{let t=document.createRange();s.anchor>s.head&&([c,l]=[l,c]),t.setEnd(l.node,l.offset),t.setStart(c.node,c.offset),e.removeAllRanges(),e.addRange(t)}a&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,l)),this.impreciseAnchor=c.precise?null:new wQ(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new wQ(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&rQ(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=$Z(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let s=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!s||!c||s.bottom>c.top)return;let l=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(l.node,l.offset),n.modify(`move`,t.assoc<0?`forward`:`backward`,`lineboundary`),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=sQ(e)==0?0:t==0?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;r==0&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!k$.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}else if(n.isText())return e==n.dom?r+t:r+(t?n.length:0);else return r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,i=!1,a,o=-1,s=!1;return this.tile.blockTiles((t,c)=>{if(t.isWidget()){if(t.flags&32&&c>=e)return!0;t.flags&16&&(i=!0)}else{let l=c+t.length;if(c<=e&&(n=t,r=e-c,i=l<e),l>=e&&!a&&(a=t,o=e-c,s=c>e),c>e&&a)return!0}}),!n&&!a?this.domAtPos(e,t):(i&&a?n=null:s&&n&&(a=null),n&&t<0||!a?n.domIn(r,t):a.domIn(o,t))}coordsAt(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof m1?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(e,t){if(e.isComposite())for(let n of e.children){if(n.length>=t){let e=r(n,t);if(e)return e}if(t-=n.length,t<0)break}else if(e.isText()&&t<e.length){let n=NY(e.text,t);if(n==t)return null;let r=_Q(e.dom,t,n).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}return r(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,a=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,s=this.view.textDirection==TQ.LTR,c=0,l=(e,u,d)=>{for(let f=0;f<e.children.length&&!(u>r);f++){let r=e.children[f],p=u+r.length,m=r.dom.getBoundingClientRect(),{height:h}=m;if(d&&!f&&(c+=m.top-d.top),r instanceof N$)p>n&&l(r,u,m);else if(u>=n&&(c>0&&t.push(-c),t.push(h+c),c=0,a)){let e=r.dom.lastChild,t=e?nQ(e):[];if(t.length){let e=t[t.length-1],n=s?e.right-m.left:m.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=p)}}d&&f==e.children.length-1&&(c+=d.bottom-m.bottom),u=p+r.breakAfter}};return l(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction==`rtl`?TQ.RTL:TQ.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=nQ(r.dom);if(e.length!=1)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement(`div`),n,r,i;return t.className=`cm-line`,t.style.width=`99999px`,t.style.position=`absolute`,t.textContent=`abc def ghi jkl mno pqr stu`,this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=nQ(t.firstChild)[0];n=t.getBoundingClientRect().height,r=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],a=i?i.from-1:this.view.state.doc.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(GZ.replace({widget:new m1(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return GZ.set(e)}updateDeco(){let e=1,t=this.view.state.facet(_$).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet(y$).map((e,t)=>{let r=typeof e==`function`;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(JX.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(v$).map(e=>typeof e==`function`?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(a$))try{if(t(this.view,e.range,e))return!0}catch(e){l$(this.view.state,e,`scroll handler`)}let{range:t}=e,n=this.coordsAt(t.head,t.assoc??(t.empty?0:t.head>t.anchor?-1:1)),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let i=w$(this.view),a={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom},{offsetWidth:o,offsetHeight:s}=this.view.scrollDOM;if(dQ(this.view.scrollDOM,a,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,s),-s),this.view.textDirection==TQ.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let e=this.view.docView.lineAt(t.head,1);e&&e.dom.scrollIntoView({block:`nearest`})}}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){r1(this.tile)}};function r1(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)r1(n,t)}}function i1(e){return e.node.nodeType==1&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable==`false`)&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable==`false`)}function a1(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=SQ(n.focusNode,n.focusOffset),i=CQ(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=k$.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=k$.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(a=i)}}if(e.docView.lastCompositionAfterCursor=a!=r,!a)return null;let o=t-a.offset;return{from:o,to:o+a.node.nodeValue.length,node:a.node}}function o1(e,t,n){let r=a1(e,n);if(!r)return null;let{node:i,from:a,to:o}=r,s=i.nodeValue;if(/[\n\r]/.test(s)||e.state.doc.sliceString(r.from,r.to)!=s)return null;let c=t.invertedDesc;return{range:new E$(c.mapPos(a),c.mapPos(o),a,o),text:i}}function s1(e,t){return e.nodeType==1?(t&&e.childNodes[t-1].contentEditable==`false`?1:0)|(t<e.childNodes.length&&e.childNodes[t].contentEditable==`false`?2:0):0}var c1=class{constructor(){this.changes=[]}compareRange(e,t){ZZ(e,t,this.changes)}comparePoint(e,t){ZZ(e,t,this.changes)}boundChange(e){ZZ(e,e,this.changes)}};function l1(e,t,n){let r=new c1;return JX.compare(e,t,n,r),r.changes}var u1=class{constructor(){this.changes=[]}compareRange(e,t){ZZ(e,t,this.changes)}comparePoint(){}boundChange(e){ZZ(e,e,this.changes)}};function d1(e,t,n){let r=new u1;return JX.compare(e,t,n,r),r.changes}function f1(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(n.nodeType==1&&n.contentEditable==`false`)return!0;return!1}function p1(e,t){let n=!1;return t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)}),n}var m1=class extends UZ{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement(`div`);return e.className=`cm-gap`,this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+`px`,!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function h1(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return Y.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=NY(i.text,a,!1):s=NY(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=NY(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;s<i.length;){let e=NY(i.text,s);if(r(i.text.slice(s,e))!=c)break;s=e}return Y.range(o+i.from,s+i.from)}function g1(e,t,n,r,i){let a=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>e.defaultLineHeight*1.5){let t=e.viewState.heightOracle.textHeight,r=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t);a+=r*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+cZ(o,a,e.state.tabSize)}function _1(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;(!e||i.type==WZ.Text&&(e.type!=i.type||(n<0?i.from<t:i.to>t)))&&(e=i)}}return e||r}return r}function v1(e,t,n,r){let i=_1(e,t.head,t.assoc||-1),a=!r||i.type!=WZ.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(a){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),o=e.posAtCoords({x:n==(r==TQ.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o!=null)return Y.cursor(o,n?-1:1)}return Y.cursor(n?i.to:i.from,n?-1:1)}function y1(e,t,n,r){let i=e.state.doc.lineAt(t.head),a=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let s=t,c=null;;){let t=KQ(i,a,o,s,n),l=GQ;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=`
|
|
207
|
+
`,i=e.state.doc.line(i.number+(n?1:-1)),a=e.bidiSpans(i),t=e.visualLineSide(i,!n)}if(!c){if(!r)return t;c=r(l)}else if(!c(l))return s;s=t}}function b1(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==IX.Space&&(i=t),i==t}}function x1(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return Y.cursor(i,t.assoc);let o=t.goalColumn,s,c=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(l)o??=l.left-c.left,s=a<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(i);o??=Math.min(c.right-c.left,e.defaultCharacterWidth*(i-t.from)),s=(a<0?t.top:t.bottom)+u}let d=c.left+o,f=e.viewState.heightOracle.textHeight>>1,p=r??f;for(let t=0;;t+=f){let r=s+(p+t)*a,i=E1(e,{x:d,y:r},!1,a);if(n?r>c.bottom:r<c.top)return Y.cursor(i.pos,i.assoc);let l=e.coordsAtPos(i.pos,i.assoc),u=l?(l.top+l.bottom)/2:0;if(!l||(n?u>s:u<s))return Y.cursor(i.pos,i.assoc,void 0,o)}}function S1(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,a)=>{if(t>e&&t<i){let a=r||n||(t-e<i-t?-1:1);t=a<0?e:i,r=a}});if(!r)return t}}function C1(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],a=null;if(i.empty){let t=S1(e,i.from,0);t!=i.from&&(a=Y.cursor(t,-1))}else{let t=S1(e,i.from,-1),n=S1(e,i.to,1);(t!=i.from||n!=i.to)&&(a=Y.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}a&&(n||=t.ranges.slice(),n[r]=a)}return n?Y.create(n,t.mainIndex):t}function w1(e,t,n){let r=S1(e.state.facet(b$).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:Y.cursor(r,r<n.from?1:-1)}var T1=class{constructor(e,t){this.pos=e,this.assoc=t}};function E1(e,t,n,r){let i=e.contentDOM.getBoundingClientRect(),a=i.top+e.viewState.paddingTop,{x:o,y:s}=t,c=s-a,l;for(;;){if(c<0)return new T1(0,1);if(c>e.viewState.docHeight)return new T1(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==WZ.Text){if(r<0?l.to<e.viewport.from:l.from>e.viewport.to)break;let t=e.docView.coordsAt(r<0?l.from:l.to,r>0?-1:1);if(t&&(r<0?t.top<=c+a:t.bottom>=c+a))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?l.bottom+t:l.top-t}if(e.viewport.from>=l.to||e.viewport.to<=l.from){if(n)return null;if(l.type==WZ.Text){let t=g1(e,i,l,o,s);return new T1(t,t==l.from?1:-1)}}if(l.type!=WZ.Text)return c<(l.top+l.bottom)/2?new T1(l.from,1):new T1(l.to,-1);let u=e.docView.lineAt(l.from,2);return(!u||u.length!=l.length)&&(u=e.docView.lineAt(l.from,-2)),new D1(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var D1=class{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[FQ.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[FQ.find(r,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:r}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from<t)}scan(e,t,n=!1){let r=0,i=e.length-1,a=new Set,o=this.bidiIn(e[0],e[i]),s,c,l=-1,u=1e9,d;search:for(;r<i;){let n=i-r,f=r+i>>1;adjust:if(a.has(f)){let e=r+Math.floor(Math.random()*n);for(let t=0;t<n;t++){if(!a.has(e)){f=e;break adjust}e++,e==i&&(e=r)}break search}a.add(f);let p=t(f);if(p)for(let t=0;t<p.length;t++){let n=p[t],a=0;if(!(n.width==0&&p.length>1)){if(n.bottom<this.y)(!s||s.bottom<n.bottom)&&(s=n),a=1;else if(n.top>this.y)(!c||c.top>n.top)&&(c=n),a=-1;else{let e=n.left>this.x?this.x-n.left:n.right<this.x?this.x-n.right:0,t=Math.abs(e);t<u&&(l=f,u=t,d=n),e&&(a=e<0==(this.baseDir==TQ.LTR)?-1:1)}a==-1&&(!o||this.baseDirAt(e[f],1))?i=f:a==1&&(!o||this.baseDirAt(e[f+1],-1))&&(r=f+1)}}}if(!d){let n=s&&(!c||this.y-s.bottom<c.top-this.y)?s:c;return this.y=(n.top+n.bottom)/2,this.scan(e,t,!0)}if(u&&!n){let{top:n,bottom:r}=d;if(s&&s.bottom>(n+n+r)/3)return this.y=s.bottom-1,this.scan(e,t,!0);if(c&&c.top<(n+r+r)/3)return this.y=c.top+1,this.scan(e,t,!0)}let f=(o?this.dirAt(e[l],1):this.baseDir)==TQ.LTR;return{i:l,after:this.x>(d.left+d.right)/2==f}}scanText(e,t){let n=[];for(let r=0;r<e.length;r=NY(e.text,r))n.push(t+r);n.push(t+e.length);let r=this.scan(n,r=>{let i=n[r]-t,a=n[r+1]-t;return _Q(e.dom,i,a).getClientRects()});return r.after?new T1(n[r.i+1],-1):new T1(n[r.i],1)}scanTile(e,t){if(!e.length)return new T1(t,1);if(e.children.length==1){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let r=0,i=t;r<e.children.length;r++)n.push(i+=e.children[r].length);let r=this.scan(n,t=>{let n=e.children[t];return n.flags&48?null:(n.dom.nodeType==1?n.dom:_Q(n.dom,0,n.length)).getClientRects()}),i=e.children[r.i],a=n[r.i];return i.isText()?this.scanText(i,a):i.isComposite()?this.scanTile(i,a):r.after?new T1(n[r.i+1],-1):new T1(a,1)}},O1=``,k1=class{constructor(e,t){this.points=e,this.view=t,this.text=``,this.lineSeparator=t.state.facet(VX.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=O1}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=k$.get(r),a=r.nextSibling;if(a==t){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let o=k$.get(a);(i&&o?i.breakAfter:(i?i.breakAfter:aQ(r))||aQ(a)&&(r.nodeName!=`BR`||i?.isWidget())&&this.text.length>e)&&!j1(a,t)&&this.lineBreak(),r=a}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,a=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),a=this.lineSeparator.length):(o=r.exec(t))&&(i=o.index,a=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),a>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=a-1);n=i+a}}readNode(e){let t=k$.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName==`BR`?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(A1(e,n.node,n.offset)?t:0))}};function A1(e,t,n){for(;;){if(!t||n<sQ(t))return!1;if(t==e)return!0;n=iQ(t)+1,t=t.parentNode}}function j1(e,t){let n;for(;!(e==t||!e);e=e.nextSibling){let t=k$.get(e);if(!t?.isWidget())return!1;t&&(n||=[]).push(t)}if(n){for(let e of n)if(e.overrideDOMText?.length)return!1}return!0}var M1=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},N1=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text=``,this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=P1(e.docView.tile,t,n,0))){let t=i||a?[]:z1(e),n=new k1(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=B1(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!eQ(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!eQ(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((IZ.ios||IZ.chrome)&&o.main.empty&&n!=r&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),a=s.from-t,o=s.to-i;(a==0||a==1||t==0)&&(o==0||o==-1||i==e.state.doc.length)&&(n=0,r=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(Y.range(r,n));else if(e.lineWrapping&&r==n&&!(o.main.empty&&o.main.head==n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),r=0;t&&(r=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=Y.create([Y.cursor(n,r)])}else this.newSel=Y.single(r,n)}}};function P1(e,t,n,r){if(e.isComposite()){let i=-1,a=-1,o=-1,s=-1;for(let c=0,l=r,u=r;c<e.children.length;c++){let r=e.children[c],d=l+r.length;if(l<t&&d>n)return P1(r,t,n,l);if(d>=t&&i==-1&&(i=c,a=l),l>n&&r.dom.parentNode==e.dom){o=c,s=u;break}u=d,l=d+r.breakAfter}return{from:a,to:s<0?r+e.length:s,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o<e.children.length&&o>=0?e.children[o].dom:null}}else if(e.isText())return{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling};else return null}function F1(e,t){let n,{newSel:r}=t,{state:i}=e,a=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:r}=t.bounds,s=a.from,c=null;(o===8||IZ.android&&t.text.length<r-e)&&(s=a.to,c=`end`);let l=i.doc.sliceString(e,r,O1),u,d;!a.empty&&a.from>=e&&a.to<=r&&(t.typeOver||l!=t.text)&&l.slice(0,a.from-e)==t.text.slice(0,a.from-e)&&l.slice(a.to-e)==t.text.slice(u=t.text.length-(l.length-(a.to-e)))?n={from:a.from,to:a.to,insert:SY.of(t.text.slice(a.from-e,u).split(O1))}:(d=R1(l,t.text,s-e,c))&&(IZ.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==``&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:SY.of(t.text.slice(d.from,d.toB).split(O1))})}else r&&(!e.hasFocus&&i.facet(u$)||V1(r,a))&&(r=null);if(!n&&!r)return!1;if((IZ.mac||IZ.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute(`autocorrect`)==`off`?(r&&n.insert.length==2&&(r=Y.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:SY.of([n.insert.toString().replace(`.`,` `)])}):i.doc.lineAt(a.from).to<a.to&&e.docView.lineHasWidget(a.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:a.from,to:a.to,insert:i.toText(e.inputState.insertingText)}:IZ.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==`
|
|
208
|
+
`&&e.lineWrapping&&(r&&=Y.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:SY.of([` `])}),n)return I1(e,n,r,o);if(r&&!V1(r,a)){let t=!1,n=`select`;return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin==`select`&&(t=!0),n=e.inputState.lastSelectionOrigin,n==`select.pointer`&&(r=C1(i.facet(b$).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}else return!1}function I1(e,t,n,r=-1){if(IZ.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(IZ.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==` `)&&t.insert.length==1&&t.insert.lines==2&&vQ(e.contentDOM,`Enter`,13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.length<t.to-t.from&&t.to>i.head)&&vQ(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&vQ(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=L1(e,t,n);return e.state.facet($Q).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function L1(e,t,n){let r,i=e.state,a=i.selection.main,o=-1;if(t.from==t.to&&t.from<a.from||t.from>a.to){let n=t.from<a.from?-1:1,r=n<0?a.from:a.to,s=S1(i.facet(b$).map(t=>t(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:Y.cursor(t.from+t.insert.length,-1)};else if(t.from>=a.from&&t.to<=a.to&&t.to-t.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=a.from<t.from?i.sliceDoc(a.from,t.from):``,o=a.to>t.to?i.sliceDoc(t.to,a.to):``;r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=i.changes(t),s=n&&n.main.to<=o.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=a.to+10&&t.to>=a.to-10){let c=e.state.sliceDoc(t.from,t.to),l,u=n&&a1(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(a.head);let d=a.to-t.to;r=i.changeByRange(n=>{if(n.from==a.from&&n.to==a.to)return{changes:o,range:s||n.map(o)};let r=n.to-d,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let f=i.changes({from:u,to:r,insert:t.insert}),p=n.to-a.to;return{changes:f,range:s?Y.range(Math.max(0,s.anchor+p),Math.max(0,s.head+p)):n.map(f)}})}else r={changes:o,selection:s&&i.selection.replaceRange(s)}}let s=`input.type`;return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=`.compose`,e.inputState.compositionFirstChange&&(s+=`.start`,e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:s,scrollIntoView:!0})}function R1(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a<i&&e.charCodeAt(a)==t.charCodeAt(a);)a++;if(a==i&&e.length==t.length)return null;let o=e.length,s=t.length;for(;o>0&&s>0&&e.charCodeAt(o-1)==t.charCodeAt(s-1);)o--,s--;if(r==`end`){let e=Math.max(0,a-Math.min(o,s));n-=o+e-a}if(o<a&&e.length<t.length){let e=n<=a&&n>=o?a-n:0;a-=e,s=a+(s-o),o=a}else if(s<a){let e=n<=a&&n>=s?a-n:0;a-=e,o=a+(o-s),s=a}return{from:a,toA:o,toB:s}}function z1(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=e.observer.selectionRange;return n&&(t.push(new M1(n,r)),(i!=n||a!=r)&&t.push(new M1(i,a))),t}function B1(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n>-1&&r>-1?Y.single(n+t,r+t):null}function V1(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var H1=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText=``,this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,IZ.safari&&e.contentDOM.addEventListener(`input`,()=>null),IZ.gecko&&w0(e.contentDOM.ownerDocument)}handleEvent(e){!t0(this.view,e)||this.ignoreDuringComposition(e)||e.type==`keydown`&&this.keydown(e)||(this.view.updateState==0?this.runHandlers(e.type,e):Promise.resolve().then(()=>this.runHandlers(e.type,e)))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=W1(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if(e!=`scroll`){let i=!t[e].handlers.length,a=n[e];a&&i!=!a.handlers.length&&(r.removeEventListener(e,this.handleEvent),a=null),a||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)e!=`scroll`&&!t[e]&&r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&q1.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),IZ.android&&IZ.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return IZ.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=G1.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||K1.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key==`Enter`&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,vQ(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:IZ.safari&&!IZ.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function U1(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){l$(n.state,e)}}}function W1(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(U1(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(U1(t.value,r))}}for(let e in n0)n(e).handlers.push(n0[e]);for(let e in r0)n(e).observers.push(r0[e]);return t}var G1=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],K1=`dthko`,q1=[16,17,18,20,91,92,224,225],J1=6;function Y1(e){return Math.max(0,e)*.7+8}function X1(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var Z1=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=fQ(e.contentDOM),this.atoms=e.state.facet(b$).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener(`mousemove`,this.move=this.move.bind(this)),i.addEventListener(`mouseup`,this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(VX.allowMultipleSelections)&&Q1(e,t),this.dragging=e0(e,t)&&p0(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&X1(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:o}=this.scrollParents.y.getBoundingClientRect());let s=w$(this.view);e.clientX-s.left<=r+J1?t=-Y1(r-e.clientX):e.clientX+s.right>=a-J1&&(t=Y1(e.clientX-a)),e.clientY-s.top<=i+J1?n=-Y1(i-e.clientY):e.clientY+s.bottom>=o-J1&&(n=Y1(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){this.dragging??this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener(`mousemove`,this.move),e.removeEventListener(`mouseup`,this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=C1(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:`select.pointer`}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent(`input.type`))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function Q1(e,t){let n=e.state.facet(JQ);return n.length?n[0](t):IZ.mac?t.metaKey:t.ctrlKey}function $1(e,t){let n=e.state.facet(YQ);return n.length?n[0](t):IZ.mac?!t.altKey:!t.ctrlKey}function e0(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=$Z(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}function t0(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=k$.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var n0=Object.create(null),r0=Object.create(null),i0=IZ.ie&&IZ.ie_version<15||IZ.ios&&IZ.webkit_version<604;function a0(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement(`textarea`));n.style.cssText=`position: fixed; left: -10000px; top: 10px`,n.focus(),setTimeout(()=>{e.focus(),n.remove(),s0(e,n.value)},50)}function o0(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function s0(e,t){t=o0(e.state,t$,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(y0!=null&&n.selection.ranges.every(e=>e.empty)&&y0==a.toString()){let e=-1;r=n.changeByRange(r=>{let s=n.doc.lineAt(r.from);if(s.from==e)return{range:r};e=s.from;let c=n.toText((o?a.line(i++).text:t)+n.lineBreak);return{changes:{from:s.from,insert:c},range:Y.cursor(r.from+c.length)}})}else r=o?n.changeByRange(e=>{let t=a.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:Y.cursor(e.from+t.length)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}r0.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},r0.wheel=r0.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},n0.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),r0.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin(`select.pointer`)},r0.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},n0.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(XQ))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=m0(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new Z1(e,t,n,r)),r&&e.observer.ignore(()=>{hQ(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin(`select.pointer`);return!1};function c0(e,t,n,r){if(r==1)return Y.cursor(t,n);if(r==2)return h1(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:i.from,o=r?r.posAtEnd:i.to;return o<e.state.doc.length&&o==i.to&&o++,Y.range(a,o)}}var l0=IZ.ie&&IZ.ie_version<=11,u0=null,d0=0,f0=0;function p0(e){if(!l0)return e.detail;let t=u0,n=f0;return u0=e,f0=Date.now(),d0=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(d0+1)%3:1}function m0(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=p0(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,a,o){let s=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c,l=c0(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=c0(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i<l.from?Y.range(i,a,l.assoc):Y.range(a,i,l.assoc)}return a?i.replaceRange(i.main.extend(l.from,l.to,l.assoc)):o&&r==1&&i.ranges.length>1&&(c=h0(i,s.pos))?c:o?i.addRange(l):Y.create([l])}}}function h0(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return Y.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-+(e.mainIndex>n))}return null}n0.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=Y.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,o0(e.state,n$,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},n0.dragend=e=>(e.inputState.draggedContent=null,!1);function g0(e,t,n,r){if(n=o0(e.state,t$,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&$1(e,t)?{from:a.from,to:a.to}:null,s={from:i,insert:n},c=e.state.changes(o?[o,s]:s);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:o?`move.drop`:`input.drop`}),e.inputState.draggedContent=null}n0.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,a=()=>{++i==n.length&&g0(e,t,r.filter(e=>e!=null).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=a,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),a()},t.readAsText(n[e])}return!0}else{let n=t.dataTransfer.getData(`Text`);if(n)return g0(e,t,n,!0),!0}return!1},n0.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=i0?null:t.clipboardData;return n?(s0(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(a0(e),!1)};function _0(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement(`textarea`));r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function v0(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let a=e.doc.lineAt(r);a.number>i&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),i=a.number}r=!0}return{text:o0(e,n$,t.join(e.lineBreak)),ranges:n,linewise:r}}var y0=null;n0.copy=n0.cut=(e,t)=>{if(!tQ(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=v0(e.state);if(!n&&!i)return!1;y0=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=i0?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):(_0(e,n),!1)};var b0=CX.define();function x0(e,t){let n=[];for(let r of e.facet(e$)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:b0.of(!0)}):null}function S0(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=x0(e.state,t);n?e.dispatch(n):e.update([])}},10)}r0.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),S0(e)},r0.blur=e=>{e.observer.clearSelectionRange(),S0(e)},r0.compositionstart=r0.compositionupdate=e=>{e.observer.editContext||(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},r0.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,IZ.chrome&&IZ.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},r0.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},n0.beforeinput=(e,t)=>{if((t.inputType==`insertText`||t.inputType==`insertCompositionText`)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType==`insertReplacementText`&&e.observer.editContext){let n=t.dataTransfer?.getData(`text/plain`),r=t.getTargetRanges();if(n&&r.length){let t=r[0];return I1(e,{from:e.posAtDOM(t.startContainer,t.startOffset),to:e.posAtDOM(t.endContainer,t.endOffset),insert:e.state.toText(n)},null),!0}}let n;if(IZ.chrome&&IZ.android&&(n=G1.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),n.key==`Backspace`||n.key==`Delete`)){let t=window.visualViewport?.height||0;setTimeout(()=>{(window.visualViewport?.height||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return IZ.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),IZ.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>r0.compositionend(e,t),20),!1};var C0=new Set;function w0(e){C0.has(e)||(C0.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}var T0=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],E0=!1;function D0(){E0=!1}var O0=class{constructor(e){this.lineWrapping=e,this.doc=SY.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return T0.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,i,a){let o=T0.indexOf(e)>-1,s=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,s){this.heightSamples={};for(let e=0;e<a.length;e++){let t=a[e];t<0?e++:this.heightSamples[Math.floor(t*10)]=!0}}return s}},k0=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},A0=class e{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return typeof this._content==`number`?WZ.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof JZ?this._content.widget:null}get widgetLineBreaks(){return typeof this._content==`number`?this._content:0}join(t){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new e(this.from,this.length+t.length,this.top,this.height+t.height,n)}},j0=(function(e){return e[e.ByPos=0]=`ByPos`,e[e.ByHeight=1]=`ByHeight`,e[e.ByPosNoHeight=2]=`ByPosNoHeight`,e})(j0||={}),M0=.001,N0=class e{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>M0&&(E0=!0),this.height=e)}replace(t,n,r){return e.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,a=n.doc;for(let o=r.length-1;o>=0;o--){let{fromA:s,toA:c,fromB:l,toB:u}=r[o],d=i.lineAt(s,j0.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,j0.ByPosNoHeight,n,0,0);for(u+=f.to-c,c=f.to;o>0&&d.from<=r[o-1].toA;)s=r[o-1].fromA,l=r[o-1].fromB,o--,s<d.from&&(d=i.lineAt(s,j0.ByPosNoHeight,n,0,0));l+=d.from-s,s=d.from;let p=H0.build(n.setDoc(a),e,l,u);i=P0(i,i.replace(s,c,p))}return i.updateHeight(n,0)}static empty(){return new L0(0,0,0)}static of(t){if(t.length==1)return t[0];let n=0,r=t.length,i=0,a=0;for(;;)if(n==r)if(i>a*2){let e=t[n-1];e.break?t.splice(--n,1,e.left,null,e.right):t.splice(--n,1,e.left,e.right),r+=1+e.break,i-=e.size}else if(a>i*2){let e=t[r];e.break?t.splice(r,1,e.left,null,e.right):t.splice(r,1,e.left,e.right),r+=2+e.break,a-=e.size}else break;else if(i<a){let e=t[n++];e&&(i+=e.size)}else{let e=t[--r];e&&(a+=e.size)}let o=0;return t[n-1]==null?(o=1,n--):t[n]??(o=1,r++),new z0(e.of(t.slice(0,n)),o,e.of(t.slice(r)))}};function P0(e,t){return e==t?e:(e.constructor!=t.constructor&&(E0=!0),t)}N0.prototype.size=1;var F0=GZ.replace({}),I0=class extends N0{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new A0(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new A0(r,0,n,this.spaceAbove,F0):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let a=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(a):a}forEachLine(e,t,n,r,i,a){e<=i+this.length&&t>=i&&a(this.lineAt(0,j0.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},L0=class e extends I0{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new A0(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof e||i instanceof R0&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof R0?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):N0.of(r)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:``}${this.widgetHeight?`:`+this.widgetHeight:``})`}},R0=class e extends N0{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,i=r-n+1,a,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);a=t/i,this.length>i+1&&(o=(this.height-t)/(this.length-i-1))}else a=this.height/i;return{firstLine:n,lastLine:r,perLine:a,perChar:o}}blockAt(e,t,n,r){let{firstLine:i,lastLine:a,perLine:o,perChar:s}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),a=t.doc.lineAt(i),c=o+a.length*s,l=Math.max(n,e-c/2);return new A0(a.from,a.length,l,c,0)}else{let r=Math.max(0,Math.min(a-i,Math.floor((e-n)/o))),{from:s,length:c}=t.doc.line(i+r);return new A0(s,c,n+o*r,o,0)}}lineAt(e,t,n,r,i){if(t==j0.ByHeight)return this.blockAt(e,n,r,i);if(t==j0.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new A0(t,r-t,0,0,0)}let{firstLine:a,perLine:o,perChar:s}=this.heightMetrics(n,i),c=n.doc.lineAt(e),l=o+c.length*s,u=c.number-a,d=r+o*u+s*(c.from-i-u);return new A0(c.from,c.length,Math.max(r,Math.min(d,r+this.height-l)),l,0)}forEachLine(e,t,n,r,i,a){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:o,perLine:s,perChar:c}=this.heightMetrics(n,i);for(let l=e,u=r;l<=t;){let t=n.doc.lineAt(l);if(l==e){let n=t.number-o;u+=s*n+c*(e-i-n)}let r=s+c*t.length;a(new A0(t.from,t.length,u,r,0)),u+=r,l=t.to+1}}replace(t,n,r){let i=this.length-n;if(i>0){let t=r[r.length-1];t instanceof e?r[r.length-1]=new e(t.length+i):r.push(null,new e(i-1))}if(t>0){let n=r[0];n instanceof e?r[0]=new e(t+n.length):r.unshift(new e(t-1),null)}return N0.of(r)}decomposeLeft(t,n){n.push(new e(t-1),null)}decomposeRight(t,n){n.push(null,new e(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let a=n+this.length;if(i&&i.from<=n+this.length&&i.more){let r=[],o=Math.max(n,i.from),s=-1;for(i.from>n&&r.push(new e(i.from-n-1).updateHeight(t,n));o<=a&&i.more;){let e=t.doc.lineAt(o).length;r.length&&r.push(null);let n=i.heights[i.index++],a=0;n<0&&(a=-n,n=i.heights[i.index++]),s==-1?s=n:Math.abs(n-s)>=M0&&(s=-2);let c=new L0(e,n,a);c.outdated=!1,r.push(c),o+=e+1}o<=a&&r.push(null,new e(a-o).updateHeight(t,o));let c=N0.of(r);return(s<0||Math.abs(c.height-this.height)>=M0||Math.abs(s-this.heightMetrics(t,n).perLine)>=M0)&&(E0=!0),P0(this,c)}else (r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},z0=class extends N0{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let a=r+this.left.height,o=i+this.left.length+this.break,s=t==j0.ByHeight?e<a:e<o,c=s?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,a,o);if(this.break||(s?c.to<o:c.from>o))return c;let l=t==j0.ByPosNoHeight?j0.ByPosNoHeight:j0.ByPos;return s?c.join(this.right.lineAt(o,l,n,a,o)):this.left.lineAt(o,l,n,r,i).join(c)}forEachLine(e,t,n,r,i,a){let o=r+this.left.height,s=i+this.left.length+this.break;if(this.break)e<s&&this.left.forEachLine(e,t,n,r,i,a),t>=s&&this.right.forEachLine(e,t,n,o,s,a);else{let c=this.lineAt(s,j0.ByPos,n,r,i);e<c.from&&this.left.forEachLine(e,c.from-1,n,r,i,a),c.to>=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(c.to+1,t,n,o,s,a)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let a=i.length;for(let e of n)i.push(e);if(e>0&&B0(i,a-1),t<this.length){let e=i.length;this.decomposeRight(t,i),B0(i,e)}return N0.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?N0.of(this.break?[e,null,t]:[e,t]):(this.left=P0(this.left,e),this.right=P0(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:a}=this,o=t+i.length+this.break,s=null;return r&&r.from<=t+i.length&&r.more?s=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=o+a.length&&r.more?s=a=a.updateHeight(e,o,n,r):a.updateHeight(e,o,n),s?this.balanced(i,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?` `:`-`)+this.right}};function B0(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof R0&&(r=e[t+1])instanceof R0&&e.splice(t-1,3,new R0(n.length+1+r.length))}var V0=5,H0=class e{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof L0?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new L0(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let a=t-e;n.block?this.addBlock(new I0(a,r,n)):(a||i||r>=V0)&&this.addLineDeco(r,i,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new L0(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new R0(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof L0)return e;let t=new L0(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos+=e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos+=n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof L0)&&!this.isCovered?this.nodes.push(new L0(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let e of this.nodes)e instanceof L0&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(t,n,r,i){let a=new e(r,t);return JX.spans(n,r,i,a,0),a.finish(r)}};function U0(e,t,n){let r=new W0;return JX.compare(e,t,n,r,0),r.changes}var W0=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&ZZ(e,t,this.changes,5)}};function G0(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,a=Math.max(0,n.left),o=Math.min(i.innerWidth,n.right),s=Math.max(0,n.top),c=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(t.nodeType==1){let n=t,r=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&r.overflow!=`visible`){let r=n.getBoundingClientRect();a=Math.max(a,r.left),o=Math.min(o,r.right),s=Math.max(s,r.top),c=Math.min(t==e.parentNode?i.innerHeight:c,r.bottom)}t=r.position==`absolute`||r.position==`fixed`?n.offsetParent:n.parentNode}else if(t.nodeType==11)t=t.host;else break;return{left:a-n.left,right:Math.max(a,o)-n.left,top:s-(n.top+t),bottom:Math.max(s,c)-(n.top+t)}}function K0(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}function q0(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var J0=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return GZ.replace({widget:new Y0(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},Y0=class extends UZ{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement(`div`);return this.vertical?e.style.height=this.size+`px`:(e.style.width=this.size+`px`,e.style.height=`2px`,e.style.display=`inline-block`),e}get estimatedHeight(){return this.vertical?this.size:-1}},X0=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=n2,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=TQ.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(g$).some(e=>typeof e!=`function`&&e.class==`cm-lineWrapping`);this.heightOracle=new O0(n),this.stateDeco=r2(t),this.heightMap=N0.empty().applyChanges(this.stateDeco,SY.empty,this.heightOracle.setDoc(t.doc),[new E$(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=GZ.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new Z0(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?n2:new i2(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(a2(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=r2(this.state);let r=e.changedRanges,i=E$.extendWithRanges(r,U0(n,this.stateDeco,e?e.changes:HY.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);D0(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||E0)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let s=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<s.from||t.range.head>s.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,t));let c=s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(i$)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction==`rtl`?TQ.RTL:TQ.LTR;let a=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent===`refresh`,o=t.getBoundingClientRect(),s=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,l=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=uQ(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,c|=16,a=s=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(s=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=fQ(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=xQ(this.scrollParent||e.win);let m=(this.printing?q0:G0)(t,this.paddingTop),h=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(s=!0)),!this.inView&&!this.scrollTarget&&!K0(e.dom))return 0;let v=o.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),s){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(a=!0),a||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:o,textHeight:s}=e.docView.measureTextSize();a=n>0&&r.refresh(i,n,o,s,Math.max(5,v/o),t),a&&(e.docView.minWidth=0,c|=16)}h>0&&g>0?l=Math.max(h,g):h<0&&g<0&&(l=Math.min(h,g)),D0();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?N0.empty().applyChanges(this.stateDeco,SY.empty,this.heightOracle,[new E$(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new k0(n.from,i))}E0&&(c|=2)}let y=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),c|=this.updateForViewport()),(c&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,s=new Z0(r.lineAt(a-n*1e3,j0.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,j0.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<s.from||e>s.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),a=r.lineAt(e,j0.ByPos,i,0,0),o;o=t.y==`center`?(a.top+a.bottom)/2-n/2:t.y==`start`||t.y==`nearest`&&e<s.from?a.top:a.bottom-n,s=new Z0(r.lineAt(o-1e3/2,j0.ByHeight,i,0,0).from,r.lineAt(o+n+1e3/2,j0.ByHeight,i,0,0).to)}}return s}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new Z0(this.heightMap.lineAt(n,j0.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,j0.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,j0.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,j0.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:o}=this;return(e==0||r<=a-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=o+Math.max(10,Math.min(n,250)))&&r>a-2*1e3&&i<o+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new J0(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,a=r<<1;if(this.defaultTextDirection!=TQ.LTR&&!n)return[];let o=[],s=(r,a,c,l)=>{if(a-r<i)return;let u=this.state.selection.main,d=[u.from];u.empty||d.push(u.to);for(let e of d)if(e>r&&e<a){s(r,e-10,c,l),s(e+10,a,c,l);return}let f=t2(e,e=>e.from>=c.from&&e.to<=c.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-a)<i&&!d.some(t=>e.from<t&&e.to>t));if(!f){if(a<c.to&&t&&n&&t.visibleRanges.some(e=>e.from<=a&&e.to>=a)){let e=t.moveToLineBoundary(Y.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new J0(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length<a||t.type!=WZ.Text)return;let i=Q0(t.from,t.to,this.stateDeco);if(i.total<a)return;let o=this.scrollTarget?this.scrollTarget.range.head:null,c,l;if(n){let e=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,n,a;if(o!=null){let r=e2(i,o),s=((this.visibleBottom-this.visibleTop)/2+e)/t.height;n=r-s,a=r+s}else n=(this.visibleTop-t.top-e)/t.height,a=(this.visibleBottom-t.top+e)/t.height;c=$0(i,n),l=$0(i,a)}else{let n=i.total*this.heightOracle.charWidth,a=r*this.heightOracle.charWidth,s=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+s<this.pixelViewport.left&&(s=n.size-n.displaySize);let u=this.pixelViewport.left+s,d=this.pixelViewport.right+s,f,p;if(o!=null){let e=e2(i,o),t=((d-u)/2+a)/n;f=e-t,p=e+t}else f=(u-a)/n,p=(d+a)/n;c=$0(i,f),l=$0(i,p)}c>t.from&&s(t.from,c,t,i),l<t.to&&s(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(c):c(e);return o}gapSize(e,t,n,r){let i=e2(r,n)-e2(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){J0.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=GZ.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];JX.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(r&8);t++){let i=this.visibleRanges[t],a=n[t];(i.from!=a.from||i.to!=a.to)&&(r|=4,e&&e.mapPos(i.from,-1)==a.from&&e.mapPos(i.to,1)==a.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||a2(this.heightMap.lineAt(e,j0.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||a2(this.heightMap.lineAt(this.scaler.fromDOM(e),j0.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return a2(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},Z0=class{constructor(e,t){this.from=e,this.to=t}};function Q0(e,t,n){let r=[],i=e,a=0;return JX.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),a+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),a+=t-i),{total:a,ranges:r}}function $0({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],a=i-n;if(r<=a)return n+r;r-=a}}function e2(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function t2(e,t){for(let n of e)if(t(n))return n}var n2={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function r2(e){let t=e.facet(_$).filter(e=>typeof e!=`function`),n=e.facet(y$).filter(e=>typeof e!=`function`);return n.length&&t.push(JX.join(n)),t}var i2=class e{constructor(e,t,n){let r=0,i=0,a=0;this.viewports=n.map(({from:n,to:i})=>{let a=t.lineAt(n,j0.ByPos,e,0,0).top,o=t.lineAt(i,j0.ByPos,e,0,0).bottom;return r+=o-a,{from:n,to:i,top:a,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=a+(e.top-i)*this.scale,a=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(t){return t instanceof e?this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,n)=>e.from==t.viewports[n].from&&e.to==t.viewports[n].to):!1}};function a2(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new A0(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>a2(e,t)):e._content)}var o2=QY.define({combine:e=>e.join(` `)}),s2=QY.define({combine:e=>e.indexOf(!0)>-1}),c2=pZ.newName(),l2=pZ.newName(),u2=pZ.newName(),d2={"&light":`.`+l2,"&dark":`.`+u2};function f2(e,t,n){return new pZ(t,{finish(t){return/&/.test(t)?t.replace(/&\w*/,t=>{if(t==`&`)return e;if(!n||!n[t])throw RangeError(`Unsupported selector: ${t}`);return n[t]}):e+` `+t}})}var p2=f2(`.`+c2,{"&":{position:`relative !important`,boxSizing:`border-box`,"&.cm-focused":{outline:`1px dotted #212121`},display:`flex !important`,flexDirection:`column`},".cm-scroller":{display:`flex !important`,alignItems:`flex-start !important`,fontFamily:`monospace`,lineHeight:1.4,height:`100%`,overflowX:`auto`,position:`relative`,zIndex:0,overflowAnchor:`none`},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:`block`,whiteSpace:`pre`,wordWrap:`normal`,boxSizing:`border-box`,minHeight:`100%`,padding:`4px 0`,outline:`none`,"&[contenteditable=true]":{WebkitUserModify:`read-write-plaintext-only`}},".cm-lineWrapping":{whiteSpace_fallback:`pre-wrap`,whiteSpace:`break-spaces`,wordBreak:`break-word`,overflowWrap:`anywhere`,flexShrink:1},"&light .cm-content":{caretColor:`black`},"&dark .cm-content":{caretColor:`white`},".cm-line":{display:`block`,padding:`0 2px 0 6px`},".cm-layer":{position:`absolute`,left:0,top:0,contain:`size style`,"& > *":{position:`absolute`}},"&light .cm-selectionBackground":{background:`#d9d9d9`},"&dark .cm-selectionBackground":{background:`#222`},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#d7d4f0`},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#233`},".cm-cursorLayer":{pointerEvents:`none`},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:`steps(1) cm-blink 1.2s infinite`},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:`1.2px solid black`,marginLeft:`-0.6px`,pointerEvents:`none`},".cm-cursor":{display:`none`},"&dark .cm-cursor":{borderLeftColor:`#ddd`},".cm-selectionHandle":{backgroundColor:`currentColor`,width:`1.5px`},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:`""`,backgroundColor:`inherit`,borderRadius:`50%`,width:`8px`,height:`8px`,position:`absolute`,left:`-3.25px`},".cm-selectionHandle-start::before":{top:`-8px`},".cm-selectionHandle-end::before":{bottom:`-8px`},".cm-dropCursor":{position:`absolute`},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:`block`},".cm-iso":{unicodeBidi:`isolate`},".cm-announced":{position:`fixed`,top:`-10000px`},"@media print":{".cm-announced":{display:`none`}},"&light .cm-activeLine":{backgroundColor:`#cceeff44`},"&dark .cm-activeLine":{backgroundColor:`#99eeff33`},"&light .cm-specialChar":{color:`red`},"&dark .cm-specialChar":{color:`#f78`},".cm-gutters":{flexShrink:0,display:`flex`,height:`100%`,boxSizing:`border-box`,zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:`#f5f5f5`,color:`#6c6c6c`,border:`0px solid #ddd`,"&.cm-gutters-before":{borderRightWidth:`1px`},"&.cm-gutters-after":{borderLeftWidth:`1px`}},"&dark .cm-gutters":{backgroundColor:`#333338`,color:`#ccc`},".cm-gutter":{display:`flex !important`,flexDirection:`column`,flexShrink:0,boxSizing:`border-box`,minHeight:`100%`,overflow:`hidden`},".cm-gutterElement":{boxSizing:`border-box`},".cm-lineNumbers .cm-gutterElement":{padding:`0 3px 0 5px`,minWidth:`20px`,textAlign:`right`,whiteSpace:`nowrap`},"&light .cm-activeLineGutter":{backgroundColor:`#e2f2ff`},"&dark .cm-activeLineGutter":{backgroundColor:`#222227`},".cm-panels":{boxSizing:`border-box`,position:`sticky`,left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:`#f5f5f5`,color:`black`},"&light .cm-panels-top":{borderBottom:`1px solid #ddd`},"&light .cm-panels-bottom":{borderTop:`1px solid #ddd`},"&dark .cm-panels":{backgroundColor:`#333338`,color:`white`},".cm-dialog":{padding:`2px 19px 4px 6px`,position:`relative`,"& label":{fontSize:`80%`}},".cm-dialog-close":{position:`absolute`,top:`3px`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,fontSize:`14px`,padding:`0`},".cm-tab":{display:`inline-block`,overflow:`hidden`,verticalAlign:`bottom`},".cm-widgetBuffer":{verticalAlign:`text-top`,height:`1em`,width:0,display:`inline`},".cm-placeholder":{color:`#888`,display:`inline-block`,verticalAlign:`top`,userSelect:`none`},".cm-highlightSpace":{backgroundImage:`radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)`,backgroundPosition:`center`},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:`auto 100%`,backgroundPosition:`right 90%`,backgroundRepeat:`no-repeat`},".cm-trailingSpace":{backgroundColor:`#ff332255`},".cm-button":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,padding:`.2em 1em`,borderRadius:`1px`},"&light .cm-button":{backgroundImage:`linear-gradient(#eff1f5, #d9d9df)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#b4b4b4, #d0d3d6)`}},"&dark .cm-button":{backgroundImage:`linear-gradient(#393939, #111)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#111, #333)`}},".cm-textfield":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,border:`1px solid silver`,padding:`.2em .5em`},"&light .cm-textfield":{backgroundColor:`white`},"&dark .cm-textfield":{border:`1px solid #555`,backgroundColor:`inherit`}},d2),m2={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},h2=IZ.ie&&IZ.ie_version<=11,g2=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new pQ,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(IZ.ie&&IZ.ie_version<=11||IZ.ios&&e.composing)&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&IZ.android&&e.constructor.EDIT_CONTEXT!==!1&&!(IZ.chrome&&IZ.chrome_version<126)&&(this.editContext=new b2(e),e.state.facet(u$)&&(e.contentDOM.editContext=this.editContext.editContext)),h2&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia(`print`)),typeof ResizeObserver==`function`&&(this.resizeScroll=new ResizeObserver(()=>{this.view.docView?.lastUpdate<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver==`function`&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent(`Event`)))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent(`Event`))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers(`scroll`,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type==`change`||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(u$)?n.root.activeElement!=this.dom:!tQ(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(i&&i.isWidget()&&i.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(IZ.ie&&IZ.ie_version<=11||IZ.android&&IZ.chrome)&&!n.state.selection.main.empty&&r.focusNode&&rQ(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=$Z(e.root);if(!t)return!1;let n=IZ.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&y2(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=tQ(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&bQ(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||=this.scrollTargets.slice(0,e),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener(`scroll`,this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||=(this.observer.observe(this.dom,m2),h2&&this.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),h2&&this.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&vQ(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}(!this.delayedAndroidKey||e==`Enter`)&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!this.delayedAndroidKey?.force})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),t==-1?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&tQ(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new N1(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=F1(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!V1(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type==`attributes`),e.type==`childList`){let n=_2(t,e.previousSibling||e.target.previousSibling,-1),r=_2(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else if(e.type==`characterData`)return{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue};else return null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener(`change`,this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener(`beforeprint`,this.onPrint),e.addEventListener(`scroll`,this.onScroll),e.document.addEventListener(`selectionchange`,this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener(`scroll`,this.onScroll),e.removeEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener(`change`,this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener(`beforeprint`,this.onPrint),e.document.removeEventListener(`selectionchange`,this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(u$)!=e.state.facet(u$)&&(e.view.contentDOM.editContext=e.state.facet(u$)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)==null||e.disconnect(),(t=this.gapIntersection)==null||t.disconnect(),(n=this.resizeScroll)==null||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function _2(e,t,n){for(;t;){let r=k$.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i==e.dom?n>0?t.nextSibling:t.previousSibling:i}return null}function v2(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return rQ(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function y2(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return v2(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener(`beforeinput`,r,!0),e.dom.ownerDocument.execCommand(`indent`),e.contentDOM.removeEventListener(`beforeinput`,r,!0),n?v2(e,n):null}var b2=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:a}=r,o=this.toEditorPos(n.updateRangeStart),s=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let c=s-o>n.text.length;o==this.from&&i<this.from?o=i:s==this.to&&i>this.to&&(s=i);let l=R1(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=Y.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));V1(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:SY.of(n.text.slice(l.from,l.toB).split(`
|
|
209
|
+
`))};if((IZ.mac||IZ.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:SY.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);I1(e,u,Y.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t<a;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i<a){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+` `:t==`Dashed`?`dashed `:t==`Squiggle`?`wavy `:``}${/thin/i.test(r)?1:2}px`;n.push(GZ.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:c$.of(GZ.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=$Z(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to)if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}else r=null,this.revertPending(e.state);if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(i<this.to){if(i<this.from||a>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},x2=class e{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement(`div`),this.scrollDOM=document.createElement(`div`),this.scrollDOM.tabIndex=-1,this.scrollDOM.className=`cm-scroller`,this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement(`div`),this.announceDOM.className=`cm-announced`,this.announceDOM.setAttribute(`aria-live`,`polite`),this.dom=document.createElement(`div`),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||yQ(e.parent)||document,this.viewState=new X0(this,e.state||VX.create(e)),e.scrollTo&&e.scrollTo.is(s$)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(f$).map(e=>new m$(e));for(let e of this.plugins)e.update(this);this.observer=new g2(this),this.inputState=new H1(this),this.inputState.ensureHandlers(this.plugins),this.docView=new n1(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof DX?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(b0))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=x0(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(VX.phrases)!=this.state.facet(VX.phrases))return this.setState(a);i=D$.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new o$(t.empty?t:Y.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(s$)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=w2.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(T$)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(o2)!=i.state.facet(o2)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(QQ))try{e(i)}catch(e){l$(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!F1(this,u)&&l.force&&vQ(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw Error(`Calls to EditorView.setState are not allowed while an update is in progress`);if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new X0(this,e),this.plugins=e.facet(f$).map(e=>new m$(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new n1(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(f$),n=e.state.facet(f$);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new m$(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){l$(this.state,e,`doc view update listener`)}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0)if(xQ(n||this.win))i=-1,a=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}this.updateState=1;let o=this.viewState.measure();if(!o&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let s=[];o&4||([this.measureRequests,s]=[s,this.measureRequests]);let c=s.map(e=>{try{return e.read(this)}catch(e){return l$(this.state,e),C2}}),l=D$.create(this,this.state,[]),u=!1;l.flags|=o,t?t.flags|=o:t=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),u=this.docView.update(l),u&&this.docViewUpdate());for(let e=0;e<s.length;e++)if(c[e]!=C2)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){l$(this.state,e)}if(u&&this.docView.updateSelection(!0),!l.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}else{let e=((i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-a)/this.scaleY;if((e>1||e<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(QQ))e(t)}get themeClasses(){return c2+` `+(this.state.facet(s2)?u2:l2)+` `+this.state.facet(o2)}updateAttrs(){let e=T2(this,h$,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(u$)?`true`:`false`,class:`cm-content`,style:`${IZ.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),T2(this,g$,t);let n=this.observer.ignore(()=>{let n=VZ(this.contentDOM,this.contentAttrs,t),r=VZ(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&(this.announceDOM.textContent=``),n=!1;let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(T$);let t=this.state.facet(e.cspNonce);pZ.mount(this.root,this.styleModules.concat(p2).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw Error(`Reading the editor layout isn't allowed during an update`);this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return w1(this,e,y1(this,e,t,n))}moveByGroup(e,t){return w1(this,e,y1(this,e,t,t=>b1(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return Y.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return v1(this,e,t,n)}moveVertically(e,t,n){return w1(this,e,x1(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=E1(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),E1(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),a=i[FQ.find(i,e-r.from,-1,t)];return cQ(n,a.dir==TQ.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(r$)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>S2)return WQ(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||IQ(r.isolates,n=S$(this,e))))return r.order;n||=S$(this,e);let r=UQ(e.text,t,n);return this.bidiCache.push(new w2(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||IZ.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{hQ(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return s$.of(new o$(typeof e==`number`?Y.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return s$.of(new o$(Y.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return p$.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return p$.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=pZ.newName(),r=[o2.of(n),T$.of(f2(`.${n}`,e))];return t&&t.dark&&r.push(s2.of(!0)),r}static baseTheme(e){return cX.lowest(T$.of(f2(`.`+c2,e,d2)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&k$.get(t)||k$.get(e))?.root?.view||null}};x2.styleModule=T$,x2.inputHandler=$Q,x2.clipboardInputFilter=t$,x2.clipboardOutputFilter=n$,x2.scrollHandler=a$,x2.focusChangeEffect=e$,x2.perLineTextDirection=r$,x2.exceptionSink=ZQ,x2.updateListener=QQ,x2.editable=u$,x2.mouseSelectionStyle=XQ,x2.dragMovesSelection=YQ,x2.clickAddsSelectionRange=JQ,x2.decorations=_$,x2.blockWrappers=v$,x2.outerDecorations=y$,x2.atomicRanges=b$,x2.bidiIsolatedRanges=x$,x2.cursorScrollMargin=QY.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),x2.scrollMargins=C$,x2.darkTheme=s2,x2.cspNonce=QY.define({combine:e=>e.length?e[0]:``}),x2.contentAttributes=g$,x2.editorAttributes=h$,x2.lineWrapping=x2.contentAttributes.of({class:`cm-lineWrapping`}),x2.announce=EX.define();var S2=4096,C2={},w2=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:TQ.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new e(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function T2(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&LZ(a,n)}return n}var E2=IZ.mac?`mac`:IZ.windows?`win`:IZ.linux?`linux`:`key`;function D2(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;e<n.length-1;++e){let r=n[e];if(/^(cmd|meta|m)$/i.test(r))s=!0;else if(/^a(lt)?$/i.test(r))i=!0;else if(/^(c|ctrl|control)$/i.test(r))a=!0;else if(/^s(hift)?$/i.test(r))o=!0;else if(/^mod$/i.test(r))t==`mac`?s=!0:a=!0;else throw Error(`Unrecognized modifier name: `+r)}return i&&(r=`Alt-`+r),a&&(r=`Ctrl-`+r),s&&(r=`Meta-`+r),o&&(r=`Shift-`+r),r}function O2(e,t,n){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n!==!1&&t.shiftKey&&(e=`Shift-`+e),e}var k2=cX.default(x2.domEventHandlers({keydown(e,t){return R2(M2(t.state),e,t,`editor`)}})),A2=QY.define({enables:k2}),j2=new WeakMap;function M2(e){let t=e.facet(A2),n=j2.get(t);return n||j2.set(t,n=I2(t.reduce((e,t)=>e.concat(t),[]))),n}function N2(e,t,n){return R2(M2(e.state),t,e,n)}var P2=null,F2=4e3;function I2(e,t=E2){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>D2(e,t));for(let t=1;t<l.length;t++){let n=l.slice(0,t).join(` `);i(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=P2={view:t,prefix:n,scope:e};return setTimeout(()=>{P2==r&&(P2=null)},F2),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,L2))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var L2=null;function R2(e,t,n,r){L2=t;let i=SZ(t),a=RY(IY(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;P2&&P2.view==n&&P2.scope==r&&(o=P2.prefix+` `,q1.indexOf(t.keyCode)<0&&(c=!0,P2=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+O2(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(IZ.windows&&t.ctrlKey&&t.altKey)&&!(IZ.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=gZ[t.keyCode])&&p!=i?(d(f[o+O2(p,t,!0)])||t.shiftKey&&(m=_Z[t.keyCode])!=i&&m!=p&&d(f[o+O2(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+O2(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),L2=null,s}var z2=class e{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement(`div`);return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className?(this.adjust(e),!0):!1}adjust(e){e.style.left=this.left+`px`,e.style.top=this.top+`px`,this.width!=null&&(e.style.width=this.width+`px`),e.style.height=this.height+`px`}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=B2(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return H2(t,n,r)}};function B2(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==TQ.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function V2(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),c=e.posAtCoords({x:a.right-1,y:o});return s==null||c==null?r:{from:Math.max(r.from,Math.min(s,c)),to:Math.min(r.to,Math.max(s,c))}}function H2(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==TQ.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=B2(e),l=o.querySelector(`.cm-line`),u=l&&window.getComputedStyle(l),d=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=s.right-(u?parseInt(u.paddingRight):0),p=_1(e,r,1),m=_1(e,i,-1),h=p.type==WZ.Text?p:null,g=m.type==WZ.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=V2(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=V2(e,i,-1,g)),h&&g&&h.from==g.from&&h.to==g.to)return v(y(n.from,n.to,h));{let t=h?y(n.from,null,h):b(p,!1),r=g?y(null,n.to,g):b(m,!0),i=[];return(h||p).to<(g||m).from-(h&&g?1:0)||p.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<r.top?i.push(_(d,t.bottom,f,r.top)):t.bottom<r.top&&e.elementAtHeight((t.bottom+r.top)/2).type==WZ.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),v(t).concat(i).concat(v(r))}function _(e,n,r,i){return new z2(t,e-c.left,n-c.top,Math.max(0,r-e),i-n)}function v({top:e,bottom:t,horizontal:n}){let r=[];for(let i=0;i<n.length;i+=2)r.push(_(n[i],e,n[i+1],t));return r}function y(t,n,r){let i=1e9,o=-1e9,s=[];function c(t,n,c,l,u){let p=e.coordsAtPos(t,t==r.to?-2:2),m=e.coordsAtPos(c,c==r.from?2:-2);!p||!m||(i=Math.min(p.top,m.top,i),o=Math.max(p.bottom,m.bottom,o),u==TQ.LTR?s.push(a&&n?d:p.left,a&&l?f:m.right):s.push(!a&&l?d:m.left,!a&&n?f:p.right))}let l=t??r.from,u=n??r.to;for(let r of e.visibleRanges)if(r.to>l&&r.from<u)for(let i=Math.max(r.from,l),a=Math.min(r.to,u);;){let r=e.state.doc.lineAt(i);for(let o of e.bidiSpans(r)){let e=o.from+r.from,s=o.to+r.from;if(e>=a)break;s>i&&c(Math.max(e,i),t==null&&e<=l,Math.min(s,a),n==null&&s>=u,o.dir)}if(i=r.to+1,i>=a)break}return s.length==0&&c(l,t==null,u,n==null,e.textDirection),{top:i,bottom:o,horizontal:s}}function b(e,t){let n=s.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}function U2(e,t){return e.constructor==t.constructor&&e.eq(t)}var W2=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement(`div`)),this.dom.classList.add(`cm-layer`),t.above&&this.dom.classList.add(`cm-layer-above`),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute(`aria-hidden`,`true`),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(G2)!=e.state.facet(G2)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(G2);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>!U2(e,this.drawn[t]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,IZ.webkit&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},G2=QY.define();function K2(e){return[p$.define(t=>new W2(t,e)),G2.of(e)]}var q2=QY.define({combine(e){return HX(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function J2(e={}){return[q2.of(e),X2,Q2,$2,i$.of(!0)]}function Y2(e){return e.startState.facet(q2)!=e.state.facet(q2)}var X2=K2({above:!0,markers(e){let{state:t}=e,n=t.facet(q2),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&IZ.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:Y.cursor(i.head,i.assoc);for(let i of z2.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName=t.style.animationName==`cm-blink`?`cm-blink2`:`cm-blink`);let n=Y2(e);return n&&Z2(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){Z2(t.state,e)},class:`cm-cursorLayer`});function Z2(e,t){t.style.animationDuration=e.facet(q2).cursorBlinkRate+`ms`}var Q2=K2({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let n of r)if(!n.empty)for(let r of z2.forRange(e,`cm-selectionBackground`,n))t.push(r);if(IZ.ios&&!n.empty&&e.state.facet(q2).iosSelectionHandles){for(let r of z2.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,Y.cursor(n.from,1)))t.push(r);for(let r of z2.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,Y.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||Y2(e)},class:`cm-selectionLayer`}),$2=cX.highest(x2.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`transparent !important`},caretColor:`transparent !important`},".cm-content":{caretColor:`transparent !important`,"& :focus":{caretColor:`initial !important`,"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}}})),e4=EX.define({map(e,t){return e==null?null:t.mapPos(e)}}),t4=aX.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(e4)?t.value:e,e)}}),n4=p$.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(t4);n==null?this.cursor!=null&&((t=this.cursor)==null||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement(`div`)),this.cursor.className=`cm-dropCursor`),(e.startState.field(t4)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(t4),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+`px`,this.cursor.style.top=e.top/n+`px`,this.cursor.style.height=e.height/n+`px`):this.cursor.style.left=`-100000px`}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(t4)!=e&&this.view.dispatch({effects:e4.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function r4(){return[t4,n4]}/x/.unicode;function i4(){return o4}var a4=GZ.line({class:`cm-activeLine`}),o4=p$.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(a4.range(i.from)),t=i.from)}return GZ.set(n)}},{decorations:e=>e.decorations}),s4=2e3;function c4(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>s4||n.off>s4||t.col<0||n.col<0){let o=Math.min(t.off,n.off),s=Math.max(t.off,n.off);for(let t=r;t<=i;t++){let n=e.doc.line(t);n.length<=s&&a.push(Y.range(n.from+o,n.to+s))}}else{let o=Math.min(t.col,n.col),s=Math.max(t.col,n.col);for(let t=r;t<=i;t++){let n=e.doc.line(t),r=cZ(n.text,o,e.tabSize,!0);if(r<0)a.push(Y.cursor(n.to));else{let t=cZ(n.text,s,e.tabSize);a.push(Y.range(n.from+r,n.from+t))}}}return a}function l4(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function u4(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,a=i>s4?-1:i==r.length?l4(e,t.clientX):sZ(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function d4(e,t){let n=u4(e,t),r=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(t,i,a){let o=u4(e,t);if(!o)return r;let s=c4(e.state,n,o);return s.length?a?Y.create(s.concat(r.ranges)):Y.create(s):r}}:null}function f4(e){let t=e?.eventFilter||(e=>e.altKey&&e.button==0);return x2.mouseSelectionStyle.of((e,n)=>t(n)?d4(e,n):null)}var p4={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},m4={style:`cursor: crosshair`};function h4(e={}){let[t,n]=p4[e.key||`Alt`],r=p$.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){(e.keyCode==t||!n(e))&&this.set(!1)},mousemove(e){this.set(n(e))}}});return[r,x2.contentAttributes.of(e=>e.plugin(r)?.isDown?m4:null)]}var g4=`-10000px`,_4=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],s=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(s=e)}if(s<0)a[n]=this.createTooltipView(r,n?a[n-1]:null),o&&(o[n]=!!r.above);else{let r=a[n]=this.tooltipViews[s];o&&(o[n]=t[s]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)a.indexOf(e)<0&&(this.removeTooltipView(e),(n=e.destroy)==null||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function v4(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var y4=QY.define({combine:e=>({position:IZ.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||v4})}),b4=new WeakMap,x4=p$.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(y4);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new _4(e,T4,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener(`resize`,this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement(`div`),this.container.style.position=`relative`,this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(y4);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=g4,n.dom.style.left=`0px`,this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(IZ.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else ({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=w$(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(y4).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let s=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:l}=c,u=e.pos[o],d=e.size[o];if(!u||s.clip!==!1&&(u.bottom<=Math.max(t.top,n.top)||u.top>=Math.min(t.bottom,n.bottom)||u.right<Math.max(t.left,n.left)-.1||u.left>Math.min(t.right,n.right)+.1)){l.style.top=g4;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=b4.get(c)??d.bottom-d.top,g=c.offset||w4,_=this.view.textDirection==TQ.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.y<n.top:u.bottom+h+p+g.y>n.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let b=(y?u.top-n.top:n.bottom-u.bottom)-p;if(b<h&&c.resize!==!1){if(b<this.view.defaultLineHeight){l.style.top=g4;continue}b4.set(c,h),l.style.height=(h=b)/i+`px`}else l.style.height&&(l.style.height=``);let x=y?u.top-h-p-g.y:u.bottom+p+g.y,S=v+m;if(c.overlap!==!0)for(let e of a)e.left<S&&e.right>v&&e.top<x+h&&e.bottom>x&&(x=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(x-e.parent.top)/i+`px`,S4(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,S4(l,v/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:x,right:S,bottom:x+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=g4}},{eventObservers:{scroll(){this.maybeMeasure()}}});function S4(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var C4=x2.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:`border-box`},"&light .cm-tooltip":{border:`1px solid #bbb`,backgroundColor:`#f5f5f5`},"&light .cm-tooltip-section:not(:first-child)":{borderTop:`1px solid #bbb`},"&dark .cm-tooltip":{backgroundColor:`#333338`,color:`white`},".cm-tooltip-arrow":{height:`7px`,width:`14px`,position:`absolute`,zIndex:-1,overflow:`hidden`,"&:before, &:after":{content:`''`,position:`absolute`,width:0,height:0,borderLeft:`7px solid transparent`,borderRight:`7px solid transparent`},".cm-tooltip-above &":{bottom:`-7px`,"&:before":{borderTop:`7px solid #bbb`},"&:after":{borderTop:`7px solid #f5f5f5`,bottom:`1px`}},".cm-tooltip-below &":{top:`-7px`,"&:before":{borderBottom:`7px solid #bbb`},"&:after":{borderBottom:`7px solid #f5f5f5`,top:`1px`}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:`#333338`,borderBottomColor:`#333338`},"&:after":{borderTopColor:`transparent`,borderBottomColor:`transparent`}}}),w4={x:0,y:0},T4=QY.define({enables:[x4,C4]});function E4(e,t){let n=e.plugin(x4);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var D4=QY.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function O4(e,t){let n=e.plugin(k4),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var k4=p$.fromClass(class{constructor(e){this.input=e.state.facet(M4),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(D4);this.top=new A4(e,!0,t.topContainer),this.bottom=new A4(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(D4);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new A4(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new A4(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(M4);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>x2.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),A4=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes=``,this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&=(this.dom.remove(),void 0);return}if(!this.dom){this.dom=document.createElement(`div`),this.dom.className=this.top?`cm-panels cm-panels-top`:`cm-panels cm-panels-bottom`,this.dom.style[this.top?`top`:`bottom`]=`0`;let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=j4(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=j4(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(` `))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(` `))e&&this.container.classList.add(e)}}};function j4(e){let t=e.nextSibling;return e.remove(),t}var M4=QY.define({enables:k4});function N4(e,t){let n,r=new Promise(e=>n=e),i=e=>L4(e,t,n);e.state.field(P4,!1)?e.dispatch({effects:F4.of(i)}):e.dispatch({effects:EX.appendConfig.of(P4.init(()=>[i]))});let a=I4.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(P4).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}var P4=aX.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(F4)?e=[n.value].concat(e):n.is(I4)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>M4.computeN([e],t=>t.field(e))}),F4=EX.define(),I4=EX.define();function L4(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=CZ(`form`),t.input){let e=CZ(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(CZ(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(CZ(`button`,{class:`cm-button`,type:`submit`},t.submitLabel||`OK`))}let i=r.nodeName==`FORM`?[r]:r.querySelectorAll(`form`);for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener(`keydown`,e=>{e.keyCode==27?(e.preventDefault(),o(null)):e.keyCode==13&&(e.preventDefault(),o(t))}),t.addEventListener(`submit`,e=>{e.preventDefault(),o(t)})}let a=CZ(`div`,r,CZ(`button`,{onclick:()=>o(null),"aria-label":e.state.phrase(`close`),class:`cm-dialog-close`,type:`button`},[`×`]));t.class&&(a.className=t.class),a.classList.add(`cm-dialog`);function o(t){a.contains(a.ownerDocument.activeElement)&&e.focus(),n(t)}return{dom:a,top:t.top,mount:()=>{if(t.focus){let e;e=typeof t.focus==`string`?r.querySelector(t.focus):r.querySelector(`input`)||r.querySelector(`button`),e&&`select`in e?e.select():e&&`focus`in e&&e.focus()}}}}var R4=class extends UX{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};R4.prototype.elementClass=``,R4.prototype.toDOM=void 0,R4.prototype.mapMode=BY.TrackBefore,R4.prototype.startSide=R4.prototype.endSide=-1,R4.prototype.point=!0;var z4=QY.define(),B4=QY.define(),V4={class:``,renderEmptyElements:!1,elementStyle:``,markers:()=>JX.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:`before`},H4=QY.define();function U4(e){return[G4(),H4.of({...V4,...e})]}var W4=QY.define({combine:e=>e.some(e=>e)});function G4(e){let t=[K4];return e&&e.fixed===!1&&t.push(W4.of(!0)),t}var K4=p$.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement(`div`),this.dom.className=`cm-gutters cm-gutters-before`,this.dom.setAttribute(`aria-hidden`,`true`),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.gutters=e.state.facet(H4).map(t=>new X4(e,t)),this.fixed=!e.state.facet(W4);for(let e of this.gutters)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position=`sticky`),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement(`div`),this.domAfter.className=`cm-gutters cm-gutters-after`,this.domAfter.setAttribute(`aria-hidden`,`true`),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.domAfter.style.position=this.fixed?`sticky`:``,this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+`px`;this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(W4)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?`sticky`:``,this.domAfter&&(this.domAfter.style.position=this.fixed?`sticky`:``)),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=JX.iter(this.view.state.facet(z4),this.view.viewport.from),r=[],i=this.gutters.map(e=>new Y4(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let a of e.type)if(a.type==WZ.Text&&t){J4(n,r,a.from);for(let e of i)e.line(this.view,a,r);t=!1}else if(a.widget)for(let e of i)e.widget(this.view,a)}else if(e.type==WZ.Text){J4(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(H4),n=e.state.facet(H4),r=e.docChanged||e.heightChanged||e.viewportChanged||!JX.eq(e.startState.facet(z4),e.state.facet(z4),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new X4(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>x2.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==TQ.LTR?{left:r,right:i}:{right:r,left:i}})});function q4(e){return Array.isArray(e)?e:[e]}function J4(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var Y4=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=JX.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==r.elements.length){let t=new Z4(e,a,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,a,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];J4(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let a=this.gutter;r.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(B4)){let i=n(e,t.widget,t);i&&(r||=[]).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},X4=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement(`div`),this.dom.className=`cm-gutter`+(this.config.class?` `+this.config.class:``);for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i=r.target,a;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let e=i.getBoundingClientRect();a=(e.top+e.bottom)/2}else a=r.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[n](e,o,r)&&r.preventDefault()});this.markers=q4(t.markers(e)),t.initialSpacer&&(this.spacer=new Z4(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+=`visibility: hidden; pointer-events: none`)}update(e){let t=this.markers;if(this.markers=q4(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!JX.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Z4=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement(`div`),this.dom.className=`cm-gutterElement`,this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+`px`),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+`px`:``),Q4(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n=`cm-gutterElement`,r=this.dom.firstChild;for(let i=0,a=0;;){let o=a,s=i<t.length?t[i++]:null,c=!1;if(s){let e=s.elementClass;e&&(n+=` `+e);for(let e=a;e<this.markers.length;e++)if(this.markers[e].compare(s)){o=e,c=!0;break}}else o=this.markers.length;for(;a<o;){let e=this.markers[a++];if(e.toDOM){e.destroy(r);let t=r.nextSibling;r.remove(),r=t}}if(!s)break;s.toDOM&&(c?r=r.nextSibling:this.dom.insertBefore(s.toDOM(e),r)),c&&a++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function Q4(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}var $4=QY.define(),e3=QY.define(),t3=QY.define({combine(e){return HX(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let r=n[e],i=t[e];n[e]=r?(e,t,n)=>r(e,t,n)||i(e,t,n):i}return n}})}}),n3=class extends R4{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function r3(e,t){return e.state.facet(t3).formatNumber(t,e.state)}var i3=H4.compute([t3],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet($4)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new n3(r3(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(e3)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(t3)!=e.state.facet(t3),initialSpacer(e){return new n3(r3(e,o3(e.state.doc.lines)))},updateSpacer(e,t){let n=r3(t.view,o3(t.view.state.doc.lines));return n==e.number?e:new n3(n)},domEventHandlers:e.facet(t3).domEventHandlers,side:`before`}));function a3(e={}){return[t3.of(e),G4(),i3]}function o3(e){let t=9;for(;t<e;)t=t*10+9;return t}var s3=new class extends R4{constructor(){super(...arguments),this.elementClass=`cm-activeLineGutter`}},c3=z4.compute([`selection`],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(s3.range(i)))}return JX.of(t)});function l3(){return c3}var u3=1024,d3=0,f3=class{constructor(e,t){this.from=e,this.to=t}},p3=class{constructor(e={}){this.id=d3++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=g3.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};p3.closedBy=new p3({deserialize:e=>e.split(` `)}),p3.openedBy=new p3({deserialize:e=>e.split(` `)}),p3.group=new p3({deserialize:e=>e.split(` `)}),p3.isolate=new p3({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),p3.contextHash=new p3({perNode:!0}),p3.lookAhead=new p3({perNode:!0}),p3.mounted=new p3({perNode:!0});var m3=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[p3.mounted.id]}},h3=Object.create(null),g3=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):h3,r=!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(p3.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(p3.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};g3.none=new g3(``,Object.create(null),0,8);var _3=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new g3(e.name,r,e.id,e.flags):e)}return new e(n)}},v3=new WeakMap,y3=new WeakMap,b3;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(b3||={});var x3=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=m3.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new F3(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new F3(v3.get(this)||this.topNode);return r.moveTo(e,t),v3.set(this,r._tree),r}get topNode(){return new D3(this,0,0,null)}resolve(e,t=0){let n=T3(v3.get(this)||this.topNode,e,t,!1);return v3.set(this,n),n}resolveInner(e,t=0){let n=T3(y3.get(this)||this.topNode,e,t,!0);return y3.set(this,n),n}resolveStack(e,t=0){return P3(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&b3.IncludeAnonymous)>0;for(let e=this.cursor(a|b3.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:B3(g3.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(g3.none,t,n,r)))}static build(e){return L3(e)}};x3.empty=new x3(g3.none,[],[],0);var S3=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},C3=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return g3.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(w3(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function w3(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function T3(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof D3&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:b3.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof D3&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var E3=class{cursor(e=0){return new F3(this,e)}getChild(e,t=null,n=null){let r=O3(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return O3(this,e,t,n)}resolve(e,t=0){return T3(this,e,t,!1)}resolveInner(e,t=0){return T3(this,e,t,!0)}matchContext(e){return k3(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},D3=class e extends E3{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(!(!(a&b3.EnterBracketed&&l instanceof x3&&(d=m3.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!w3(i,r,u,u+l.length))){if(l instanceof C3){if(a&b3.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new j3(new A3(o,l,t,u),null,e)}else if(a&b3.IncludeAnonymous||!l.type.isAnonymous||I3(l)){let s;if(!(a&b3.IgnoreMounts)&&(s=m3.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&b3.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&b3.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&b3.IgnoreOverlays)&&(i=m3.get(this._tree))&&i.overlay){let a=t-this.from,o=r&b3.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function O3(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function k3(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var A3=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},j3=class e extends E3{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&b3.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new x3(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function M3(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof D3&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new N3(i,n)}var N3=class{constructor(e,t){this.heads=e,this.node=t}get next(){return M3(this.heads)}};function P3(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof D3?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=m3.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new D3(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(T3(o,t,n,!1))}}return i?M3(i):r}var F3=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~b3.EnterBracketed,e instanceof D3)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof D3?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&b3.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&b3.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&b3.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else ({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&b3.IncludeAnonymous||e instanceof C3||!e.type.isAnonymous||I3(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new j3(this.buffer,t,this.stack[e]);return this.bufferNode=new j3(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return k3(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return k3(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function I3(e){return e.children.some(e=>e instanceof C3||!e.type.isAnonymous||I3(e))}function L3(e){let{buffer:t,nodeSet:n,maxBufferLength:r=u3,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new S3(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:S,end:ee,size:C}=o,w=l,te=c;if(C<0)if(o.next(),C==-1){let t=i[x];_.push(t),v.push(S-e);return}else if(C==-3){c=x;return}else if(C==-4){l=x;return}else throw RangeError(`Unrecognized record size: ${C}`);let ne=s[x],T,re,ie=S-e;if(ee-S<=r&&(re=h(o.pos-t,y))){let t=new Uint16Array(re.size-re.skip),r=o.pos-re.size,i=t.length;for(;o.pos>r;)i=g(re.start,t,i);T=new C3(t,ee-re.start,n),ie=re.start-e}else{let e=o.pos-C;o.next();let t=[],n=[],i=x>=a?x:-1,s=0,c=ee;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,S,s,o.end,c,i,w,te),s=t.length,c=o.end),o.next()):b>2500?d(S,e,t,n):u(S,e,t,n,i,b+1);if(i>=0&&s>0&&s<t.length&&p(t,n,S,s,S,c,i,w,te),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(ne,te);T=B3(ne,t,n,0,t.length,0,ee-S,e,e)}else T=m(ne,t,n,ee-S,w-ee,te)}_.push(T),v.push(ie)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new C3(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof x3){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(p3.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[p3.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[p3.lookAhead,i];o=o?[e].concat(o):[e]}return new x3(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0)if(n.size==-3||n.size==-4)d+=4;else break scan;else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new x3(s[e.topID],_.reverse(),v.reverse(),y)}var R3=new WeakMap;function z3(e,t){if(!e.isAnonymous||t instanceof C3||t.type!=e)return 1;let n=R3.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof x3)){n=1;break}n+=z3(e,r)}R3.set(t,n)}return n}function B3(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=z3(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=z3(e,t[s]);for(s++;s<i;s++){let n=z3(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(B3(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var V3=class{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof j3?this.setBuffer(e.context.buffer,e.index,t):e instanceof D3&&this.map.set(e.tree,t)}get(e){return e instanceof j3?this.getBuffer(e.context.buffer,e.index):e instanceof D3?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},H3=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},U3=class{startParse(e,t,n){return typeof e==`string`&&(e=new W3(e)),n=n?n.length?n.map(e=>new f3(e.from,e.to)):[new f3(0,0)]:[new f3(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},W3=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};function G3(e){return(t,n,r,i)=>new X3(t,e,n,r,i)}var K3=class{constructor(e,t,n,r,i,a){this.parser=e,this.parse=t,this.overlay=n,this.bracketed=r,this.target=i,this.from=a}};function q3(e){if(!e.length||e.some(e=>e.from>=e.to))throw RangeError(`Invalid inner parse ranges given: `+JSON.stringify(e))}var J3=class{constructor(e,t,n,r,i,a,o,s){this.parser=e,this.predicate=t,this.mounts=n,this.index=r,this.start=i,this.bracketed=a,this.target=o,this.prev=s,this.depth=0,this.ranges=[]}},Y3=new p3({perNode:!0}),X3=class{constructor(e,t,n,r,i){this.nest=t,this.input=n,this.fragments=r,this.ranges=i,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;if(this.baseParse=null,this.baseTree=e,this.startInner(),this.stoppedAt!=null)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;return this.stoppedAt!=null&&(e=new x3(e.type,e.children,e.positions,e.length,e.propValues.concat([[Y3,this.stoppedAt]]))),e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[p3.mounted.id]=new m3(t,e.overlay,e.parser,e.bracketed),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new t6(this.fragments),t=null,n=null,r=new F3(new D3(this.baseTree,this.ranges[0].from,0,null),b3.IncludeAnonymous|b3.IgnoreMounts);scan:for(let i,a;;){let o=!0,s;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)o=!1;else if(e.hasNode(r)){if(t){let e=t.mounts.find(e=>e.frag.from<=r.from&&e.frag.to>=r.to&&e.mount.overlay);if(e)for(let n of e.mount.overlay){let i=n.from+e.pos,a=n.to+e.pos;i>=r.from&&a<=r.to&&!t.ranges.some(e=>e.from<a&&e.to>i)&&t.ranges.push({from:i,to:a})}}o=!1}else if(n&&(a=Z3(n.ranges,r.from,r.to)))o=a!=2;else if(!r.type.isAnonymous&&(i=this.nest(r,this.input))&&(r.from<r.to||!i.overlay)){r.tree||($3(r),t&&t.depth++,n&&n.depth++);let a=e.findMounts(r.from,i.parser);if(typeof i.overlay==`function`)t=new J3(i.parser,i.overlay,a,this.inner.length,r.from,!!i.bracketed,r.tree,t);else{let e=n6(this.ranges,i.overlay||(r.from<r.to?[new f3(r.from,r.to)]:[]));e.length&&q3(e),(e.length||!i.overlay)&&this.inner.push(new K3(i.parser,e.length?i.parser.startParse(this.input,i6(a,e),e):i.parser.startParse(``),i.overlay?i.overlay.map(e=>new f3(e.from-r.from,e.to-r.from)):null,!!i.bracketed,r.tree,e.length?e[0].from:r.from)),i.overlay?e.length&&(n={ranges:e,depth:0,prev:n}):o=!1}}else if(t&&(s=t.predicate(r))&&(s===!0&&(s=new f3(r.from,r.to)),s.from<s.to)){let e=t.ranges.length-1;e>=0&&t.ranges[e].to==s.from?t.ranges[e]={from:t.ranges[e].from,to:s.to}:t.ranges.push(s)}if(o&&r.firstChild())t&&t.depth++,n&&n.depth++;else for(;!r.nextSibling();){if(!r.parent())break scan;if(t&&!--t.depth){let e=n6(this.ranges,t.ranges);e.length&&(q3(e),this.inner.splice(t.index,0,new K3(t.parser,t.parser.startParse(this.input,i6(t.mounts,e),e),t.ranges.map(e=>new f3(e.from-t.start,e.to-t.start)),t.bracketed,t.target,e[0].from))),t=t.prev}n&&!--n.depth&&(n=n.prev)}}}};function Z3(e,t,n){for(let r of e){if(r.from>=n)break;if(r.to>t)return r.from<=t&&r.to>=n?2:1}return 0}function Q3(e,t,n,r,i,a){if(t<n){let o=e.buffer[t+1];r.push(e.slice(t,n,o)),i.push(o-a)}}function $3(e){let{node:t}=e,n=[],r=t.context.buffer;do n.push(e.index),e.parent();while(!e.tree);let i=e.tree,a=i.children.indexOf(r),o=i.children[a],s=o.buffer,c=[a];function l(e,r,i,a,u,d){let f=n[d],p=[],m=[];Q3(o,e,f,p,m,a);let h=s[f+1],g=s[f+2];c.push(p.length);let _=d?l(f+4,s[f+3],o.set.types[s[f]],h,g-h,d-1):t.toTree();return p.push(_),m.push(h-a),Q3(o,s[f+3],r,p,m,a),new x3(i,p,m,u)}i.children[a]=l(0,s.length,g3.none,0,o.length,n.length-1);for(let t of c){let n=e.tree.children[t],r=e.tree.positions[t];e.yield(new D3(n,r+e.from,t,e._tree))}}var e6=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(b3.IncludeAnonymous|b3.IgnoreMounts)}moveTo(e){let{cursor:t}=this,n=e-this.offset;for(;!this.done&&t.from<n;)if(!(t.to>=e&&t.enter(n,1,b3.IgnoreOverlays|b3.ExcludeBuffers)))if(t.to<=e)t.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof x3)t=t.children[0];else break}return!1}},t6=class{constructor(e){if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let t=this.curFrag=e[0];this.curTo=t.tree.prop(Y3)??t.to,this.inner=new e6(t.tree,-t.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=e.tree.prop(Y3)??e.to,this.inner=new e6(e.tree,-e.offset)}}findMounts(e,t){let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let r=e.tree?.prop(p3.mounted);if(r&&r.parser==t)for(let t=this.fragI;t<this.fragments.length;t++){let i=this.fragments[t];if(i.from>=e.to)break;i.tree==this.curFrag.tree&&n.push({frag:i,pos:e.from-i.offset,mount:r})}}}return n}};function n6(e,t){let n=null,r=t;for(let i=1,a=0;i<e.length;i++){let o=e[i-1].to,s=e[i].from;for(;a<r.length;a++){let e=r[a];if(e.from>=s)break;e.to<=o||(n||(r=n=t.slice()),e.from<o?(n[a]=new f3(e.from,o),e.to>s&&n.splice(a+1,0,new f3(s,e.to))):e.to>s?n[a--]=new f3(s,e.to):n.splice(a--,1))}}return r}function r6(e,t,n,r){let i=0,a=0,o=!1,s=!1,c=-1e9,l=[];for(;;){let u=i==e.length?1e9:o?e[i].to:e[i].from,d=a==t.length?1e9:s?t[a].to:t[a].from;if(o!=s){let e=Math.max(c,n),t=Math.min(u,d,r);e<t&&l.push(new f3(e,t))}if(c=Math.min(u,d),c==1e9)break;u==c&&(o?(o=!1,i++):o=!0),d==c&&(s?(s=!1,a++):s=!0)}return l}function i6(e,t){let n=[];for(let{pos:r,mount:i,frag:a}of e){let e=r+(i.overlay?i.overlay[0].from:0),o=e+i.tree.length,s=Math.max(a.from,e),c=Math.min(a.to,o);if(i.overlay){let o=r6(t,i.overlay.map(e=>new f3(e.from+r,e.to+r)),s,c);for(let t=0,r=s;;t++){let s=t==o.length,l=s?c:o[t].from;if(l>r&&n.push(new H3(r,l,i.tree,-e,a.from>=r||a.openStart,a.to<=l||a.openEnd)),s)break;r=o[t].to}}else n.push(new H3(s,c,i.tree,-e,a.from>=e||a.openStart,a.to<=o||a.openEnd))}return n}var a6=0,o6=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=a6++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new c6(e);return e=>e.modified.indexOf(t)>-1?e:c6.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},s6=0,c6=class e{constructor(e){this.name=e,this.instances=[],this.id=s6++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&l6(n,e.modified));if(r)return r;let i=[],a=new o6(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=u6(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function l6(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function u6(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function d6(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new p6(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return f6.add(t)}var f6=new p3({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new p6(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),p6=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};p6.empty=new p6([],2,null);function m6(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function h6(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function g6(e,t,n,r=0,i=e.length){let a=new _6(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var _6=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=v6(e)||p6.empty,u=h6(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(p3.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do{if(e.to<=t)continue;if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function v6(e){let t=e.type.prop(f6);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var X=o6.define,y6=X(),b6=X(),x6=X(b6),S6=X(b6),C6=X(),w6=X(C6),T6=X(C6),E6=X(),D6=X(E6),O6=X(),k6=X(),A6=X(),j6=X(A6),M6=X(),Z={comment:y6,lineComment:X(y6),blockComment:X(y6),docComment:X(y6),name:b6,variableName:X(b6),typeName:x6,tagName:X(x6),propertyName:S6,attributeName:X(S6),className:X(b6),labelName:X(b6),namespace:X(b6),macroName:X(b6),literal:C6,string:w6,docString:X(w6),character:X(w6),attributeValue:X(w6),number:T6,integer:X(T6),float:X(T6),bool:X(C6),regexp:X(C6),escape:X(C6),color:X(C6),url:X(C6),keyword:O6,self:X(O6),null:X(O6),atom:X(O6),unit:X(O6),modifier:X(O6),operatorKeyword:X(O6),controlKeyword:X(O6),definitionKeyword:X(O6),moduleKeyword:X(O6),operator:k6,derefOperator:X(k6),arithmeticOperator:X(k6),logicOperator:X(k6),bitwiseOperator:X(k6),compareOperator:X(k6),updateOperator:X(k6),definitionOperator:X(k6),typeOperator:X(k6),controlOperator:X(k6),punctuation:A6,separator:X(A6),bracket:j6,angleBracket:X(j6),squareBracket:X(j6),paren:X(j6),brace:X(j6),content:E6,heading:D6,heading1:X(D6),heading2:X(D6),heading3:X(D6),heading4:X(D6),heading5:X(D6),heading6:X(D6),contentSeparator:X(E6),list:X(E6),quote:X(E6),emphasis:X(E6),strong:X(E6),link:X(E6),monospace:X(E6),strikethrough:X(E6),inserted:X(),deleted:X(),changed:X(),invalid:X(),meta:M6,documentMeta:X(M6),annotation:X(M6),processingInstruction:X(M6),definition:o6.defineModifier(`definition`),constant:o6.defineModifier(`constant`),function:o6.defineModifier(`function`),standard:o6.defineModifier(`standard`),local:o6.defineModifier(`local`),special:o6.defineModifier(`special`)};for(let e in Z){let t=Z[e];t instanceof o6&&(t.name=e)}m6([{tag:Z.link,class:`tok-link`},{tag:Z.heading,class:`tok-heading`},{tag:Z.emphasis,class:`tok-emphasis`},{tag:Z.strong,class:`tok-strong`},{tag:Z.keyword,class:`tok-keyword`},{tag:Z.atom,class:`tok-atom`},{tag:Z.bool,class:`tok-bool`},{tag:Z.url,class:`tok-url`},{tag:Z.labelName,class:`tok-labelName`},{tag:Z.inserted,class:`tok-inserted`},{tag:Z.deleted,class:`tok-deleted`},{tag:Z.literal,class:`tok-literal`},{tag:Z.string,class:`tok-string`},{tag:Z.number,class:`tok-number`},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],class:`tok-string2`},{tag:Z.variableName,class:`tok-variableName`},{tag:Z.local(Z.variableName),class:`tok-variableName tok-local`},{tag:Z.definition(Z.variableName),class:`tok-variableName tok-definition`},{tag:Z.special(Z.variableName),class:`tok-variableName2`},{tag:Z.definition(Z.propertyName),class:`tok-propertyName tok-definition`},{tag:Z.typeName,class:`tok-typeName`},{tag:Z.namespace,class:`tok-namespace`},{tag:Z.className,class:`tok-className`},{tag:Z.macroName,class:`tok-macroName`},{tag:Z.propertyName,class:`tok-propertyName`},{tag:Z.operator,class:`tok-operator`},{tag:Z.comment,class:`tok-comment`},{tag:Z.meta,class:`tok-meta`},{tag:Z.invalid,class:`tok-invalid`},{tag:Z.punctuation,class:`tok-punctuation`}]);var N6=new p3;function P6(e){return QY.define({combine:e?t=>t.concat(e):void 0})}var F6=new p3,I6=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,VX.prototype.hasOwnProperty(`tree`)||Object.defineProperty(VX.prototype,"tree",{get(){return R6(this)}}),this.parser=t,this.extension=[G6.of(this),VX.languageData.of((e,t,n)=>{let r=L6(e,t,n),i=r.type.prop(N6);if(!i)return[];let a=e.facet(i),o=r.type.prop(F6);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return L6(e,t,n).type.prop(N6)==this.data}findRegions(e){let t=e.facet(G6);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(N6)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(p3.mounted);if(i){if(i.tree.prop(N6)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}else if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof x3&&r(i,e.positions[n]+t)}};return r(R6(e),0),n}get allowsNesting(){return!0}};I6.setState=EX.define();function L6(e,t,n){let r=e.facet(G6),i=R6(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,b3.ExcludeBuffers|b3.EnterBracketed))e.type.isTop&&(i=e);return i}var Iie=class e extends I6{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=P6(t.languageData);return new e(n,t.parser.configure({props:[N6.add(e=>e.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function R6(e){let t=e.field(I6.state,!1);return t?t.tree:x3.empty}var Lie=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},z6=null,B6=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],x3.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Lie(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=x3.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(H3.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(H3.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=z6;z6=this;try{return e()}finally{z6=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=V6(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=H3.applyChanges(r,e),i=x3.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=V6(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends U3{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=z6;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new x3(g3.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return z6}};function V6(e,t,n){return H3.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var H6=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=B6.create(t.facet(G6).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};I6.state=aX.define({create:H6.init,update(e,t){for(let e of t.effects)if(e.is(I6.setState))return e.value;return t.startState.facet(G6)==t.state.facet(G6)?e.apply(t):H6.init(t.state)}});var U6=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(U6=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var W6=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,Rie=p$.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(I6.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(I6.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=U6(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(I6.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!W6?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>W6&&W6()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:I6.setState.of(new H6(i.context))})),this.chunkBudget>0&&!(s&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>l$(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),G6=QY.define({combine(e){return e.length?e[0]:null},enables:e=>[I6.state,Rie,x2.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),K6=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},Q=class e{constructor(e,t,n,r,i,a=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=r,this.loadFunc=i,this.support=a,this.loading=null}load(){return this.loading||=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e})}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw RangeError(`Must pass either 'load' or 'support' to LanguageDescription.of`);n=()=>Promise.resolve(r)}return new e(t.name,(t.alias||[]).concat(t.name).map(e=>e.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(e,t){for(let n of e)if(n.filename&&n.filename.test(t))return n;let n=/\.([^.]+)$/.exec(t);if(n){for(let t of e)if(t.extensions.indexOf(n[1])>-1)return t}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let n of e)if(n.alias.some(e=>e==t))return n;if(n)for(let n of e)for(let e of n.alias){let r=t.indexOf(e);if(r>-1&&(e.length>2||!/\w/.test(t[r-1])&&!/\w/.test(t[r+e.length])))return n}return null}},zie=QY.define(),q6=QY.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function J6(e){let t=e.facet(q6);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Y6(e,t){let n=``,r=e.tabSize,i=e.facet(q6)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function X6(e,t){e instanceof VX&&(e=new Z6(e));for(let n of e.state.facet(zie)){let r=n(e,t);if(r!==void 0)return r}let n=R6(e.state);return n.length>=t?Bie(e,n,t):null}var Z6=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=J6(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return sZ(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Q6=new p3;function Bie(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return $6(r,e,n)}function $6(e,t,n){for(let r=e;r;r=r.next){let e=Hie(r.node);if(e)return e(Wie.create(t,n,r))}return 0}function Vie(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Hie(e){let t=e.type.prop(Q6);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(p3.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>e8(e,!0,1,void 0,n&&!Vie(e)?t.from:void 0)}return e.parent==null?Uie:null}function Uie(){return 0}var Wie=class e extends Z6{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(Gie(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return $6(this.context.next,this.base,this.pos)}};function Gie(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Kie(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function qie({closing:e,align:t=!0,units:n=1}){return r=>e8(r,t,n,e)}function e8(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?Kie(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var Jie=e=>e.baseIndent;function Yie({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var Xie=200;function Zie(){return VX.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent(`input.type`)&&!e.isUserEvent(`input.complete`))return e;let t=e.startState.languageDataAt(`indentOnInput`,e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+Xie)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=X6(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=Y6(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var t8=QY.define(),n8=new p3;function Qie(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}function $ie(e,t,n){let r=R6(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let i=o.node;if(i.to<=n||i.from>n)continue;if(a&&i.from<t)break;let s=i.type.prop(n8);if(s&&(i.to<r.length-50||r.length==e.doc.length||!eae(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function eae(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function r8(e,t,n){for(let r of e.facet(t8)){let i=r(e,t,n);if(i)return i}return $ie(e,t,n)}function i8(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}var a8=EX.define({map:i8}),o8=EX.define({map:i8});function s8(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}var c8=aX.define({create(){return GZ.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=l8(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(a8)&&!tae(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(p8),i=r?GZ.replace({widget:new oae(r(t.state,n.value))}):g8;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(o8)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=l8(e,t.selection.main.head)),e},provide:e=>x2.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError(`Invalid JSON for fold state`);let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid JSON for fold state`);t.push(g8.range(r,i))}return GZ.set(t,!0)}});function l8(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function u8(e,t,n){var r;let i=null;return(r=e.field(c8,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function tae(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function d8(e,t){return e.field(c8,!1)?t:t.concat(EX.appendConfig.of(m8()))}var nae=e=>{for(let t of s8(e)){let n=r8(e.state,t.from,t.to);if(n)return e.dispatch({effects:d8(e.state,[a8.of(n),f8(e,n)])}),!0}return!1},rae=e=>{if(!e.state.field(c8,!1))return!1;let t=[];for(let n of s8(e)){let r=u8(e.state,n.from,n.to);r&&t.push(o8.of(r),f8(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function f8(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return x2.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var iae=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:nae},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:rae},{key:`Ctrl-Alt-[`,run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=r8(t,i.from,i.to);a&&n.push(a8.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:d8(e.state,n)}),!!n.length}},{key:`Ctrl-Alt-]`,run:e=>{let t=e.state.field(c8,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(o8.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],aae={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},p8=QY.define({combine(e){return HX(e,aae)}});function m8(e){let t=[c8,lae];return e&&t.push(p8.of(e)),t}function h8(e,t){let{state:n}=e,r=n.facet(p8),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=u8(e.state,n.from,n.to);r&&e.dispatch({effects:o8.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement(`span`);return a.textContent=r.placeholderText,a.setAttribute(`aria-label`,n.phrase(`folded code`)),a.title=n.phrase(`unfold`),a.className=`cm-foldPlaceholder`,a.onclick=i,a}var g8=GZ.replace({widget:new class extends UZ{toDOM(e){return h8(e,null)}}}),oae=class extends UZ{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return h8(e,this.value)}},sae={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},_8=class extends R4{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement(`span`);return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?`Fold line`:`Unfold line`),t}};function cae(e={}){let t={...sae,...e},n=new _8(t,!0),r=new _8(t,!1),i=p$.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(G6)!=e.state.facet(G6)||e.startState.field(c8,!1)!=e.state.field(c8,!1)||R6(e.startState)!=R6(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new XX;for(let i of e.viewportLineBlocks){let a=u8(e.state,i.from,i.to)?r:r8(e.state,i.from,i.to)?n:null;a&&t.add(i.from,i.from,a)}return t.finish()}}),{domEventHandlers:a}=t;return[i,U4({class:`cm-foldGutter`,markers(e){return e.plugin(i)?.markers||JX.empty},initialSpacer(){return new _8(t,!1)},domEventHandlers:{...a,click:(e,t,n)=>{if(a.click&&a.click(e,t,n))return!0;let r=u8(e.state,t.from,t.to);if(r)return e.dispatch({effects:o8.of(r)}),!0;let i=r8(e.state,t.from,t.to);return i?(e.dispatch({effects:a8.of(i)}),!0):!1}}}),m8()]}var lae=x2.baseTheme({".cm-foldPlaceholder":{backgroundColor:`#eee`,border:`1px solid #ddd`,color:`#888`,borderRadius:`.2em`,margin:`0 1px`,padding:`0 1px`,cursor:`pointer`},".cm-foldGutter span":{padding:`0 1px`,cursor:`pointer`}}),v8=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=pZ.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof I6?e=>e.prop(N6)==a.data:a?e=>e==a:void 0,this.style=m6(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new pZ(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},y8=QY.define(),b8=QY.define({combine(e){return e.length?[e[0]]:null}});function x8(e){let t=e.facet(y8);return t.length?t:e.facet(b8)}function S8(e,t){let n=[dae],r;return e instanceof v8&&(e.module&&n.push(x2.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(b8.of(e)):r?n.push(y8.computeN([x2.darkTheme],t=>t.facet(x2.darkTheme)==(r==`dark`)?[e]:[])):n.push(y8.of(e)),n}var uae=class{constructor(e){this.markCache=Object.create(null),this.tree=R6(e.state),this.decorations=this.buildDeco(e,x8(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=R6(e.state),n=x8(e.state),r=n!=x8(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&a>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return GZ.none;let n=new XX;for(let{from:r,to:i}of e.visibleRanges)g6(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=GZ.mark({class:r})))},r,i);return n.finish()}},dae=cX.high(p$.fromClass(uae,{decorations:e=>e.decorations})),fae=v8.define([{tag:Z.meta,color:`#404740`},{tag:Z.link,textDecoration:`underline`},{tag:Z.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:Z.emphasis,fontStyle:`italic`},{tag:Z.strong,fontWeight:`bold`},{tag:Z.strikethrough,textDecoration:`line-through`},{tag:Z.keyword,color:`#708`},{tag:[Z.atom,Z.bool,Z.url,Z.contentSeparator,Z.labelName],color:`#219`},{tag:[Z.literal,Z.inserted],color:`#164`},{tag:[Z.string,Z.deleted],color:`#a11`},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],color:`#e40`},{tag:Z.definition(Z.variableName),color:`#00f`},{tag:Z.local(Z.variableName),color:`#30a`},{tag:[Z.typeName,Z.namespace],color:`#085`},{tag:Z.className,color:`#167`},{tag:[Z.special(Z.variableName),Z.macroName],color:`#256`},{tag:Z.definition(Z.propertyName),color:`#00c`},{tag:Z.comment,color:`#940`},{tag:Z.invalid,color:`#f00`}]),pae=x2.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),C8=1e4,w8=`()[]{}`,T8=QY.define({combine(e){return HX(e,{afterCursor:!0,brackets:w8,maxScanDistance:C8,renderMatch:gae})}}),mae=GZ.mark({class:`cm-matchingBracket`}),hae=GZ.mark({class:`cm-nonmatchingBracket`});function gae(e){let t=[],n=e.matched?mae:hae;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function E8(e){let t=[],n=e.facet(T8);for(let r of e.selection.ranges){if(!r.empty)continue;let i=A8(e,r.head,-1,n)||r.head>0&&A8(e,r.head-1,1,n)||n.afterCursor&&(A8(e,r.head,1,n)||r.head<e.doc.length&&A8(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return GZ.set(t,!0)}var _ae=[p$.fromClass(class{constructor(e){this.paused=!1,this.decorations=E8(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=E8(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),pae];function vae(e={}){return[T8.of(e),_ae]}var D8=new p3;function O8(e,t,n){let r=e.prop(t<0?p3.openedBy:p3.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function k8(e){let t=e.type.prop(D8);return t?t(e.node):e}function A8(e,t,n,r={}){let i=r.maxScanDistance||C8,a=r.brackets||w8,o=R6(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=O8(r.type,n,a);if(i&&r.from<r.to){let o=k8(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return yae(e,t,n,r,o,i,a)}}return bae(e,t,n,o,s.type,i,a)}function yae(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=k8(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(O8(u.type,n,o))l++;else if(O8(u.type,-n,o)){if(l==0){let e=k8(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function bae(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i))if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}function j8(e,t,n,r=0,i=0){t??(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let i=r;i<t;i++)e.charCodeAt(i)==9?a+=n-a%n:a++;return a}var M8=class{constructor(e,t,n,r){this.string=e,this.tabSize=t,this.indentUnit=n,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),n;if(n=typeof e==`string`?t==e:t&&(e instanceof RegExp?e.test(t):e(t)),n)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=j8(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){return this.overrideIndent??j8(this.string,null,this.tabSize)}match(e,t,n){if(typeof e==`string`){let r=e=>n?e.toLowerCase():e;return r(this.string.substr(this.pos,e.length))==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}};function xae(e){return{name:e.name||``,token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||Sae,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||L8,mergeTokens:e.mergeTokens!==!1}}function Sae(e){if(typeof e!=`object`)return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}var N8=new WeakMap,Cae=class e extends I6{constructor(e){let t=P6(e.languageData),n=xae(e),r,i=new class extends U3{createParse(e,t,n){return new Tae(r,e,t,n)}};super(t,i,[],e.name),this.topNode=Oae(t,this),r=this,this.streamParser=n,this.stateAfter=new p3({perNode:!0}),this.tokenTable=e.tokenTable?new H8(n.tokenTable):Dae}static define(t){return new e(t)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=N8.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let r=P8(this,e.node.tree,e.node.from,e.node.from,t??e.pos),i,a;if(r?(a=r.state,i=r.pos+1):(a=this.streamParser.startState(e.unit),i=e.node.from),e.pos-i>1e4)return null;for(;i<e.pos;){let t=e.state.doc.lineAt(i),r=Math.min(e.pos,t.to);if(t.length){let i=n?n(t.from):-1,o=new M8(t.text,e.state.tabSize,e.unit,i<0?void 0:i);for(;o.pos<r-t.from;)I8(this.streamParser.token,o,a)}else this.streamParser.blankLine(a,e.unit);if(r==e.pos)break;i=t.to+1}let o=e.lineAt(e.pos);return n&&t==null&&N8.set(e.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],e)}get allowsNesting(){return!1}};function P8(e,t,n,r,i){let a=n>=r&&n+t.length<=i&&t.prop(e.stateAfter);if(a)return{state:e.streamParser.copyState(a),pos:n+t.length};for(let a=t.children.length-1;a>=0;a--){let o=t.children[a],s=n+t.positions[a],c=o instanceof x3&&s<i&&P8(e,o,s,r,i);if(c)return c}return null}function F8(e,t,n,r,i){if(i&&n<=0&&r>=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let a=t.children.length-1;a>=0;a--){let o=t.positions[a],s=t.children[a],c;if(o<r&&s instanceof x3){if(!(c=F8(e,s,n-o,r-o,i)))break;return i?new x3(t.type,t.children.slice(0,a).concat(c),t.positions.slice(0,a+1),o+c.length):c}}return null}function wae(e,t,n,r,i){for(let i of t){let t=i.from+(i.openStart?25:0),a=i.to-(i.openEnd?25:0),o=t<=n&&a>n&&P8(e,i.tree,0-i.offset,n,a),s;if(o&&o.pos<=r&&(s=F8(e,i.tree,n+i.offset,o.pos+i.offset,!1)))return{state:o.state,tree:s}}return{state:e.streamParser.startState(i?J6(i):4),tree:x3.empty}}var Tae=class{constructor(e,t,n,r){this.lang=e,this.input=t,this.fragments=n,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let i=B6.get(),a=r[0].from,{state:o,tree:s}=wae(e,n,a,this.to,i?.state);this.state=o,this.parsedPos=this.chunkStart=a+s.length;for(let e=0;e<s.children.length;e++)this.chunks.push(s.children[e]),this.chunkPos.push(s.positions[e]);i&&this.parsedPos<i.viewport.from-1e5&&r.some(e=>e.from<=i.viewport.from&&e.to>=i.viewport.from)&&(this.state=this.lang.streamParser.startState(J6(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let e=B6.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(t,this.chunkStart+512);for(e&&(n=Math.min(n,e.viewport.to));this.parsedPos<n;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
|
|
210
|
+
`&&(t=``);else{let e=t.indexOf(`
|
|
211
|
+
`);e>-1&&(t=t.slice(0,e))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),n=e+t.length;for(let e=this.rangeIndex;;){let r=this.ranges[e].to;if(r>=n||(t=t.slice(0,r-(n-t.length)),e++,e==this.ranges.length))break;let i=this.ranges[e].from,a=this.lineAfter(i);t+=a,n=i+a.length}return{line:t,end:n}}skipGapsTo(e,t,n){for(;;){let r=this.ranges[this.rangeIndex].to,i=e+t;if(n>0?r>i:r>=i)break;let a=this.ranges[++this.rangeIndex].from;t+=a-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,n,r){let i=4;if(this.ranges.length>1){r=this.skipGapsTo(t,r,1),t+=r;let e=this.chunk.length;r=this.skipGapsTo(n,r,-1),n+=r,i+=this.chunk.length-e}let a=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&i==4&&a>=0&&this.chunk[a]==e&&this.chunk[a+2]==t?this.chunk[a+2]=n:this.chunk.push(e,t,n,i),r}parseLine(e){let{line:t,end:n}=this.nextLine(),r=0,{streamParser:i}=this.lang,a=new M8(t,e?e.state.tabSize:4,e?J6(e.state):2);if(a.eol())i.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let e=I8(i.token,a,this.state);if(e&&(r=this.emitToken(this.lang.tokenTable.resolve(e),this.parsedPos+a.start,this.parsedPos+a.pos,r)),a.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=x3.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Eae,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new x3(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new x3(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function I8(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let r=e(t,n);if(t.pos>t.start)return r}throw Error(`Stream parser failed to advance stream.`)}var L8=Object.create(null),R8=[g3.none],Eae=new _3(R8),z8=[],B8=Object.create(null),V8=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])V8[e]=W8(L8,t);var H8=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),V8)}resolve(e){return e?this.table[e]||(this.table[e]=W8(this.extra,e)):0}},Dae=new H8(L8);function U8(e,t){z8.indexOf(e)>-1||(z8.push(e),console.warn(t))}function W8(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||Z[n];r?typeof r==`function`?t.length?t=t.map(r):U8(n,`Modifier ${n} used at start of tag`):t.length?U8(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:U8(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=B8[i];if(a)return a.id;let o=B8[i]=g3.define({id:R8.length,name:r,props:[d6({[r]:n})]});return R8.push(o),o.id}function Oae(e,t){let n=g3.define({id:R8.length,name:`Document`,props:[N6.add(()=>e),Q6.add(()=>e=>t.getIndent(e))],top:!0});return R8.push(n),n}TQ.RTL,TQ.LTR;var kae=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=K8(e.state,n.from);return r.line?Aae(e):r.block?Mae(e):!1};function G8(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var Aae=G8(Fae,0),jae=G8(J8,0),Mae=G8((e,t)=>J8(e,t,Pae(t)),0);function K8(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var q8=50;function Nae(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-q8,r),o=e.sliceDoc(i,i+q8),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*q8?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+q8),d=e.sliceDoc(i-q8,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function Pae(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function J8(e,t,n=t.selection.ranges){let r=n.map(e=>K8(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Nae(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function Fae(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=K8(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var Y8=CX.define(),Iae=CX.define(),Lae=QY.define(),X8=QY.define({combine(e){return HX(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),Z8=aX.define({create(){return s5.empty},update(e,t){let n=t.state.facet(X8),r=t.annotation(Y8);if(r){let i=t5.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?n5(o,o.length,n.minDepth,i):a5(o,t.startState.selection),new s5(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(Iae);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(DX.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=t5.fromTransaction(t),o=t.annotation(DX.time),s=t.annotation(DX.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new s5(e.done.map(t5.fromJSON),e.undone.map(t5.fromJSON))}});function Rae(e={}){return[Z8,X8.of(e),x2.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?$8:e.inputType==`historyRedo`?e5:null;return n?(e.preventDefault(),n(t)):!1}})]}function Q8(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(Z8,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var $8=Q8(0,!1),e5=Q8(1,!1),zae=Q8(0,!0),Bae=Q8(1,!0),t5=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&HY.fromJSON(t.changes),[],t.mapped&&VY.fromJSON(t.mapped),t.startSelection&&Y.fromJSON(t.startSelection),t.selectionsAfter.map(Y.fromJSON))}static fromTransaction(t,n){let r=i5;for(let e of t.startState.facet(Lae)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,i5)}static selection(t){return new e(void 0,i5,void 0,void 0,t)}};function n5(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function Vae(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function Hae(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function r5(e,t){return e.length?t.length?e.concat(t):e:t}var i5=[],Uae=200;function a5(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Uae));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),n5(e,e.length-1,1e9,n.setSelAfter(r)))}else return[t5.selection([t])]}function Wae(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function o5(e,t){if(!e.length)return e;let n=e.length,r=i5;for(;n;){let i=Gae(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[t5.selection(r)]:i5}function Gae(e,t,n){let r=r5(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):i5,n);if(!e.changes)return t5.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new t5(i,EX.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Kae=/^(input\.type|delete)($|\.)/,s5=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Kae.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Vae(s.changes,t.changes))||r==`input.type.compose`)?n5(o,o.length-1,i.minDepth,new t5(t.changes.compose(s.changes),r5(EX.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,i5)):n5(o,o.length,i.minDepth,t),new e(o,i5,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:i5;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Hae(a[a.length-1],t)?this:new e(a5(this.done,t),this.undone,n,r)}addMapping(t){return new e(o5(this.done,t),o5(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Y8.of({side:e,rest:Wae(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?i5:r.slice(0,r.length-1);return i.mapped&&(n=o5(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Y8.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};s5.empty=new s5(i5,i5);var qae=[{key:`Mod-z`,run:$8,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:e5,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:e5,preventDefault:!0},{key:`Mod-u`,run:zae,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Bae,preventDefault:!0}];function c5(e,t){return Y.create(e.ranges.map(t),e.mainIndex)}function l5(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function u5({state:e,dispatch:t},n){let r=c5(e.selection,n);return r.eq(e.selection,!0)?!1:(t(l5(e,r)),!0)}function d5(e,t){return Y.cursor(t?e.to:e.from)}function f5(e,t){return u5(e,n=>n.empty?e.moveByChar(n,t):d5(n,t))}function p5(e){return e.textDirectionAt(e.state.selection.main.head)==TQ.LTR}var m5=e=>f5(e,!p5(e)),h5=e=>f5(e,p5(e));function g5(e,t){return u5(e,n=>n.empty?e.moveByGroup(n,t):d5(n,t))}var Jae=e=>g5(e,!p5(e)),Yae=e=>g5(e,p5(e));typeof Intl<`u`&&Intl.Segmenter;function Xae(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function _5(e,t,n){let r=R6(e).resolveInner(t.head),i=n?p3.closedBy:p3.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Xae(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?A8(e,r.from,1):A8(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,Y.cursor(s,n?-1:1)}var Zae=e=>u5(e,t=>_5(e.state,t,!p5(e))),Qae=e=>u5(e,t=>_5(e.state,t,p5(e)));function v5(e,t){return u5(e,n=>{if(!n.empty)return d5(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var y5=e=>v5(e,!1),b5=e=>v5(e,!0);function x5(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(x2.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function S5(e,t){let n=x5(e),{state:r}=e,i=c5(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):d5(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=x2.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(l5(r,i),{effects:a}),!0}var C5=e=>S5(e,!1),w5=e=>S5(e,!0);function T5(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=Y.cursor(r.from+n))}return i}var $ae=e=>u5(e,t=>T5(e,t,!0)),eoe=e=>u5(e,t=>T5(e,t,!1)),toe=e=>u5(e,t=>T5(e,t,!p5(e))),noe=e=>u5(e,t=>T5(e,t,p5(e))),roe=e=>u5(e,t=>Y.cursor(e.lineBlockAt(t.head).from,1)),ioe=e=>u5(e,t=>Y.cursor(e.lineBlockAt(t.head).to,-1));function aoe(e,t,n){let r=!1,i=c5(e.selection,t=>{let i=A8(e,t.head,-1)||A8(e,t.head,1)||t.head>0&&A8(e,t.head-1,1)||t.head<e.doc.length&&A8(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?Y.range(t.anchor,a):Y.cursor(a)});return r?(t(l5(e,i)),!0):!1}var ooe=({state:e,dispatch:t})=>aoe(e,t,!1);function E5(e,t){let n=c5(e.state.selection,e=>{let n=t(e);return Y.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(l5(e.state,n)),!0)}function D5(e,t){return E5(e,n=>e.moveByChar(n,t))}var O5=e=>D5(e,!p5(e)),k5=e=>D5(e,p5(e));function A5(e,t){return E5(e,n=>e.moveByGroup(n,t))}var soe=e=>A5(e,!p5(e)),coe=e=>A5(e,p5(e)),loe=e=>E5(e,t=>_5(e.state,t,!p5(e))),uoe=e=>E5(e,t=>_5(e.state,t,p5(e)));function j5(e,t){return E5(e,n=>e.moveVertically(n,t))}var M5=e=>j5(e,!1),N5=e=>j5(e,!0);function P5(e,t){return E5(e,n=>e.moveVertically(n,t,x5(e).height))}var F5=e=>P5(e,!1),I5=e=>P5(e,!0),doe=e=>E5(e,t=>T5(e,t,!0)),foe=e=>E5(e,t=>T5(e,t,!1)),poe=e=>E5(e,t=>T5(e,t,!p5(e))),moe=e=>E5(e,t=>T5(e,t,p5(e))),hoe=e=>E5(e,t=>Y.cursor(e.lineBlockAt(t.head).from)),goe=e=>E5(e,t=>Y.cursor(e.lineBlockAt(t.head).to)),L5=({state:e,dispatch:t})=>(t(l5(e,{anchor:0})),!0),R5=({state:e,dispatch:t})=>(t(l5(e,{anchor:e.doc.length})),!0),z5=({state:e,dispatch:t})=>(t(l5(e,{anchor:e.selection.main.anchor,head:0})),!0),B5=({state:e,dispatch:t})=>(t(l5(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),_oe=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),voe=({state:e,dispatch:t})=>{let n=Y5(e).map(({from:t,to:n})=>Y.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:Y.create(n),userEvent:`select`})),!0},yoe=({state:e,dispatch:t})=>{let n=c5(e.selection,t=>{let n=R6(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return Y.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(l5(e,n)),!0)};function V5(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(l5(n,Y.create(i,i.length-1))),!0)}var boe=e=>V5(e,!1),xoe=e=>V5(e,!0),Soe=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=Y.create([n.main]):n.main.empty||(r=Y.create([Y.cursor(n.main.head)])),r?(t(l5(e,r)),!0):!1};function H5(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=U5(e,o,!1)):o>i&&(n=`delete.forward`,o=U5(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=U5(e,i,!1),a=U5(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:Y.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?x2.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function U5(e,t,n){if(e instanceof x2)for(let r of e.state.facet(x2.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var W5=(e,t,n)=>H5(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=sZ(s,a.tabSize)%J6(a)||J6(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=NY(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=NY(o.text,c-o.from,!1,!1)+o.from);return c}),G5=e=>W5(e,!1,!0),K5=e=>W5(e,!0,!1),q5=(e,t)=>H5(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=NY(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),J5=e=>q5(e,!1),Coe=e=>q5(e,!0),woe=e=>H5(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Toe=e=>H5(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Eoe=e=>H5(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Doe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:SY.of([``,``])},range:Y.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Ooe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:NY(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:NY(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:Y.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Y5(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function X5(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Y5(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(Y.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(Y.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:Y.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var koe=({state:e,dispatch:t})=>X5(e,t,!1),Aoe=({state:e,dispatch:t})=>X5(e,t,!0);function Z5(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Y5(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var joe=({state:e,dispatch:t})=>Z5(e,t,!1),Moe=({state:e,dispatch:t})=>Z5(e,t,!0),Noe=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Y5(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=c5(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function Poe(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=R6(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(p3.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var Q5=$5(!1),Foe=$5(!0);function $5(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&Poe(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Z6(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=X6(s,r);for(c??=sZ(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,Y6(t,c)];return o&&l.push(Y6(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:SY.of(l)},range:Y.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function e7(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:Y.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var Ioe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Z6(e,{overrideIndentation:e=>n[e]??-1}),i=e7(e,(t,i,a)=>{let o=X6(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=Y6(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},t7=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(e7(e,(t,n)=>{n.push({from:t.from,insert:e.facet(q6)})}),{userEvent:`input.indent`})),!0),n7=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(e7(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=sZ(r,e.tabSize),a=0,o=Y6(e,Math.max(0,i-J6(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),Loe=e=>(e.setTabFocusMode(),!0),Roe=[{key:`Ctrl-b`,run:m5,shift:O5,preventDefault:!0},{key:`Ctrl-f`,run:h5,shift:k5},{key:`Ctrl-p`,run:y5,shift:M5},{key:`Ctrl-n`,run:b5,shift:N5},{key:`Ctrl-a`,run:roe,shift:hoe},{key:`Ctrl-e`,run:ioe,shift:goe},{key:`Ctrl-d`,run:K5},{key:`Ctrl-h`,run:G5},{key:`Ctrl-k`,run:woe},{key:`Ctrl-Alt-h`,run:J5},{key:`Ctrl-o`,run:Doe},{key:`Ctrl-t`,run:Ooe},{key:`Ctrl-v`,run:w5}],zoe=[{key:`ArrowLeft`,run:m5,shift:O5,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Jae,shift:soe,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:toe,shift:poe,preventDefault:!0},{key:`ArrowRight`,run:h5,shift:k5,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Yae,shift:coe,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:noe,shift:moe,preventDefault:!0},{key:`ArrowUp`,run:y5,shift:M5,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:L5,shift:z5},{mac:`Ctrl-ArrowUp`,run:C5,shift:F5},{key:`ArrowDown`,run:b5,shift:N5,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:R5,shift:B5},{mac:`Ctrl-ArrowDown`,run:w5,shift:I5},{key:`PageUp`,run:C5,shift:F5},{key:`PageDown`,run:w5,shift:I5},{key:`Home`,run:eoe,shift:foe,preventDefault:!0},{key:`Mod-Home`,run:L5,shift:z5},{key:`End`,run:$ae,shift:doe,preventDefault:!0},{key:`Mod-End`,run:R5,shift:B5},{key:`Enter`,run:Q5,shift:Q5},{key:`Mod-a`,run:_oe},{key:`Backspace`,run:G5,shift:G5,preventDefault:!0},{key:`Delete`,run:K5,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:J5,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:Coe,preventDefault:!0},{mac:`Mod-Backspace`,run:Toe,preventDefault:!0},{mac:`Mod-Delete`,run:Eoe,preventDefault:!0}].concat(Roe.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Boe=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Zae,shift:loe},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Qae,shift:uoe},{key:`Alt-ArrowUp`,run:koe},{key:`Shift-Alt-ArrowUp`,run:joe},{key:`Alt-ArrowDown`,run:Aoe},{key:`Shift-Alt-ArrowDown`,run:Moe},{key:`Mod-Alt-ArrowUp`,run:boe},{key:`Mod-Alt-ArrowDown`,run:xoe},{key:`Escape`,run:Soe},{key:`Mod-Enter`,run:Foe},{key:`Alt-l`,mac:`Ctrl-l`,run:voe},{key:`Mod-i`,run:yoe,preventDefault:!0},{key:`Mod-[`,run:n7},{key:`Mod-]`,run:t7},{key:`Mod-Alt-\\`,run:Ioe},{key:`Shift-Mod-k`,run:Noe},{key:`Shift-Mod-\\`,run:ooe},{key:`Mod-/`,run:kae},{key:`Alt-A`,run:jae},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Loe}].concat(zoe),Voe={key:`Tab`,run:t7,shift:n7},Hoe=`#e5c07b`,r7=`#e06c75`,Uoe=`#56b6c2`,Woe=`#ffffff`,i7=`#abb2bf`,a7=`#7d8799`,Goe=`#61afef`,Koe=`#98c379`,o7=`#d19a66`,qoe=`#c678dd`,Joe=`#21252b`,s7=`#2c313a`,c7=`#282c34`,l7=`#353a42`,Yoe=`#3E4451`,u7=`#528bff`,d7=[x2.theme({"&":{color:i7,backgroundColor:c7},".cm-content":{caretColor:u7},".cm-cursor, .cm-dropCursor":{borderLeftColor:u7},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Yoe},".cm-panels":{backgroundColor:Joe,color:i7},".cm-panels.cm-panels-top":{borderBottom:`2px solid black`},".cm-panels.cm-panels-bottom":{borderTop:`2px solid black`},".cm-searchMatch":{backgroundColor:`#72a1ff59`,outline:`1px solid #457dff`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:`#6199ff2f`},".cm-activeLine":{backgroundColor:`#6699ff0b`},".cm-selectionMatch":{backgroundColor:`#aafe661a`},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bad0f847`},".cm-gutters":{backgroundColor:c7,color:a7,border:`none`},".cm-activeLineGutter":{backgroundColor:s7},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:l7},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:l7,borderBottomColor:l7},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:s7,color:i7}}},{dark:!0}),S8(v8.define([{tag:Z.keyword,color:qoe},{tag:[Z.name,Z.deleted,Z.character,Z.propertyName,Z.macroName],color:r7},{tag:[Z.function(Z.variableName),Z.labelName],color:Goe},{tag:[Z.color,Z.constant(Z.name),Z.standard(Z.name)],color:o7},{tag:[Z.definition(Z.name),Z.separator],color:i7},{tag:[Z.typeName,Z.className,Z.number,Z.changed,Z.annotation,Z.modifier,Z.self,Z.namespace],color:Hoe},{tag:[Z.operator,Z.operatorKeyword,Z.url,Z.escape,Z.regexp,Z.link,Z.special(Z.string)],color:Uoe},{tag:[Z.meta,Z.comment],color:a7},{tag:Z.strong,fontWeight:`bold`},{tag:Z.emphasis,fontStyle:`italic`},{tag:Z.strikethrough,textDecoration:`line-through`},{tag:Z.link,color:a7,textDecoration:`underline`},{tag:Z.heading,fontWeight:`bold`,color:r7},{tag:[Z.atom,Z.bool,Z.special(Z.variableName)],color:o7},{tag:[Z.processingInstruction,Z.string,Z.inserted],color:Koe},{tag:Z.invalid,color:Woe}]))],f7=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,p7=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(f7(e)):f7,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return IY(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=LY(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=RY(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(p7.prototype[Symbol.iterator]=function(){return this});var m7={from:-1,to:-1,match:/.*/.exec(``),precise:!0},h7=`gm`+(/x/.unicode==null?``:`u`),g7=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=m7,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new y7(e,t,n,r,i);this.re=new RegExp(t,h7+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=b7(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=b7(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},_7=new WeakMap,v7=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=_7.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return _7.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),_7.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},y7=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=m7,this.matchPos=b7(e,r),this.re=new RegExp(t,h7+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=v7.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=b7(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=v7.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(g7.prototype[Symbol.iterator]=y7.prototype[Symbol.iterator]=function(){return this});function Xoe(e){try{return new RegExp(e,h7),!0}catch{return!1}}function b7(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var Zoe=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=N4(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=Y.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,x2.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},Qoe={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},x7=QY.define({combine(e){return HX(e,Qoe,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function $oe(e){let t=[ise,rse];return e&&t.push(x7.of(e)),t}var ese=GZ.mark({class:`cm-selectionMatch`}),tse=GZ.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function S7(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=IX.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=IX.Word)}function nse(e,t,n,r){return e(t.sliceDoc(n,n+1))==IX.Word&&e(t.sliceDoc(r-1,r))==IX.Word}var rse=p$.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(x7),{state:n}=e,r=n.selection;if(r.ranges.length>1)return GZ.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return GZ.none;let e=n.wordAt(i.head);if(!e)return GZ.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return GZ.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(S7(o,n,i.from,i.to)&&nse(o,n,i.from,i.to)))return GZ.none}else if(a=n.sliceDoc(i.from,i.to),!a)return GZ.none}let s=[];for(let r of e.visibleRanges){let e=new p7(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||S7(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(tse.range(r,a)):(r>=i.to||a<=i.from)&&s.push(ese.range(r,a)),s.length>t.maxMatches))return GZ.none}}return GZ.set(s)}},{decorations:e=>e.decorations}),ise=x2.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),ase=({state:e,dispatch:t})=>{let{selection:n}=e,r=Y.create(n.ranges.map(t=>e.wordAt(t.head)||Y.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function ose(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new p7(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new p7(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var sse=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return ase({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=ose(e,r);return i?(t(e.update({selection:e.selection.addRange(Y.range(i.from,i.to),!1),effects:x2.scrollIntoView(i.to)})),!0):!1},C7=QY.define({combine(e){return HX(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new xse(e),scrollToMatch:e=>x2.scrollIntoView(e)})}}),w7=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Xoe(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
212
|
+
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new pse(this):new use(this)}getCursor(e,t=0,n){let r=e.doc?e:VX.create({doc:e});return n??=r.doc.length,this.regexp?D7(this,r,t,n):E7(this,r,t,n)}},T7=class{constructor(e){this.spec=e}};function cse(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function E7(e,t,n,r){let i;return e.wholeWord&&(i=lse(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=cse(e.test,t,i)),new p7(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function lse(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(O7(i,n-a))!=IX.Word||t(k7(i,n-a))!=IX.Word)&&(t(k7(i,r-a))!=IX.Word||t(O7(i,r-a))!=IX.Word))}var use=class extends T7{constructor(e){super(e)}nextMatch(e,t,n){let r=E7(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=E7(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=E7(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=E7(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=E7(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function dse(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function D7(e,t,n,r){let i;return e.wholeWord&&(i=fse(t.charCategorizer(t.selection.main.head))),e.test&&(i=dse(e.test,t,i)),new g7(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function O7(e,t){return e.slice(NY(e,t,!1),t)}function k7(e,t){return e.slice(t,NY(e,t))}function fse(e){return(t,n,r)=>!r[0].length||(e(O7(r.input,r.index))!=IX.Word||e(k7(r.input,r.index))!=IX.Word)&&(e(k7(r.input,r.index+r[0].length))!=IX.Word||e(O7(r.input,r.index+r[0].length))!=IX.Word)}var pse=class extends T7{nextMatch(e,t,n){let r=D7(this.spec,e,n,e.doc.length).next();return r.done&&(r=D7(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=D7(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=D7(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=D7(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},A7=EX.define(),j7=EX.define(),M7=aX.define({create(e){return new N7(z7(e).create(),null)},update(e,t){for(let n of t.effects)n.is(A7)?e=new N7(n.value.create(),e.panel):n.is(j7)&&(e=new N7(e.query,n.value?R7:null));return e},provide:e=>M4.from(e,e=>e.panel)}),N7=class{constructor(e,t){this.query=e,this.panel=t}},mse=GZ.mark({class:`cm-searchMatch`}),hse=GZ.mark({class:`cm-searchMatch cm-searchMatch-selected`}),gse=p$.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(M7))}update(e){let t=e.state.field(M7);(t!=e.startState.field(M7)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return GZ.none;let{view:n}=this,r=new XX;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?hse:mse)})}return r.finish()}},{decorations:e=>e.decorations});function P7(e){return t=>{let n=t.state.field(M7,!1);return n&&n.query.spec.valid?e(t,n):H7(t)}}var F7=P7((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=Y.single(r.from,r.to),a=e.state.facet(C7);return e.dispatch({selection:i,effects:[q7(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),V7(e),!0}),I7=P7((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=Y.single(i.from,i.to),o=e.state.facet(C7);return e.dispatch({selection:a,effects:[q7(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),V7(e),!0}),_se=P7((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:Y.create(n.map(e=>Y.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),vse=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new p7(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(Y.range(t.value.from,t.value.to))}return t(e.update({selection:Y.create(a,o),userEvent:`select.search.matches`})),!0},L7=P7((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),u.push(x2.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=Y.single(o.from,o.to).map(d),u.push(q7(e,o)),u.push(n.facet(C7).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),yse=P7((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:x2.announce.of(r),userEvent:`input.replace.all`}),!0});function R7(e){return e.state.facet(C7).createPanel(e)}function z7(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(C7);return new w7({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function B7(e){let t=O4(e,R7);return t&&t.dom.querySelector(`[main-field]`)}function V7(e){let t=B7(e);t&&t==e.root.activeElement&&t.select()}var H7=e=>{let t=e.state.field(M7,!1);if(t&&t.panel){let n=B7(e);if(n&&n!=e.root.activeElement){let r=z7(e.state,t.query.spec);r.valid&&e.dispatch({effects:A7.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[j7.of(!0),t?A7.of(z7(e.state,t.query.spec)):EX.appendConfig.of(Cse)]});return!0},U7=e=>{let t=e.state.field(M7,!1);if(!t||!t.panel)return!1;let n=O4(e,R7);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:j7.of(!1)}),!0},bse=[{key:`Mod-f`,run:H7,scope:`editor search-panel`},{key:`F3`,run:F7,shift:I7,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:F7,shift:I7,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:U7,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:vse},{key:`Mod-Alt-g`,run:Zoe},{key:`Mod-d`,run:sse,preventDefault:!0}],xse=class{constructor(e){this.view=e;let t=this.query=e.state.field(M7).query.spec;this.commit=this.commit.bind(this),this.searchField=CZ(`input`,{value:t.search,placeholder:W7(e,`Find`),"aria-label":W7(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=CZ(`input`,{value:t.replace,placeholder:W7(e,`Replace`),"aria-label":W7(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=CZ(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=CZ(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=CZ(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return CZ(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=CZ(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>F7(e),[W7(e,`next`)]),n(`prev`,()=>I7(e),[W7(e,`previous`)]),n(`select`,()=>_se(e),[W7(e,`all`)]),CZ(`label`,null,[this.caseField,W7(e,`match case`)]),CZ(`label`,null,[this.reField,W7(e,`regexp`)]),CZ(`label`,null,[this.wordField,W7(e,`by word`)]),...e.state.readOnly?[]:[CZ(`br`),this.replaceField,n(`replace`,()=>L7(e),[W7(e,`replace`)]),n(`replaceAll`,()=>yse(e),[W7(e,`replace all`)])],CZ(`button`,{name:`close`,onclick:()=>U7(e),"aria-label":W7(e,`close`),type:`button`},[`×`])])}commit(){let e=new w7({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:A7.of(e)}))}keydown(e){N2(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?I7:F7)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),L7(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(A7)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(C7).top}};function W7(e,t){return e.state.phrase(t)}var G7=30,K7=/[\s\.,:;?!]/;function q7(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-G7),o=Math.min(i,n+G7),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<G7;e++)if(!K7.test(s[e+1])&&K7.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-G7;e--)if(!K7.test(s[e-1])&&K7.test(s[e])){s=s.slice(0,e);break}}return x2.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var Sse=x2.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),Cse=[M7,cX.low(gse),Sse],J7=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=R6(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search($7(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function Y7(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function wse(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=Y7(t)+Y7(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function X7(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:wse(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function Tse(e,t){return n=>{for(let t=R6(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var Z7=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function Q7(e){return e.selection.main.from}function $7(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var e9=CX.define();function Ese(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:Y.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var t9=new WeakMap;function Dse(e){if(!Array.isArray(e))return e;let t=t9.get(e);return t||t9.set(e,t=X7(e)),t}var n9=EX.define(),r9=EX.define(),Ose=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=IY(e,t),r=RY(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(IY(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=IY(e,0),i=RY(r),a=i==e.length?0:-100;if(r!=t[0])if(r==n[0])a+=-200;else return null;return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=IY(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=RY(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=IY(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=LY(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=RY(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?RY(IY(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},kse=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},i9=QY.define({combine(e){return HX(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Ase,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>a9(e(n),t(n)),optionClass:(e,t)=>n=>a9(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function a9(e,t){return e?t?e+` `+t:e:t}function Ase(e,t,n,r,i,a){let o=e.textDirection==TQ.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var o9=EX.define();function jse(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function s9(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var Mse=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(i9);this.optionContent=jse(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=s9(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:o9.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(i9).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:r9.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=s9(r.length,i,e.state.facet(i9).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=s9(t.options.length,t.selected,this.view.state.facet(i9).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>l$(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&Pse(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(i9).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function Nse(e,t){return n=>new Mse(n,e,t)}function Pse(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function c9(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function Fse(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(i9);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new Z7(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new kse(n):new Ose(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new Z7(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):c9(e.completion)>c9(c)&&(s[s.length-1]=e),c=e.completion}return s}var Ise=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,l9(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=Fse(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(i9).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,l9(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:Use,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},Lse=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(Vse,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(i9),i=(r.override||n.languageDataAt(`autocomplete`,Q7(n)).map(Dse)).map(e=>(this.active.find(t=>t.source==e)||new d9(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(p9));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!Rse(i,this.active)||o?a=Ise.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new d9(e.source,0):e));for(let e of t.effects)e.is(o9)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?zse:Bse}};function Rse(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var zse={"aria-autocomplete":`list`},Bse={};function l9(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var Vse=[];function u9(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(e9);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var d9=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=u9(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(n9))i=new e(i.source,1,n.value);else if(n.is(r9))i=new e(i.source,0);else if(n.is(p9))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Q7(e.state))}},f9=class e extends d9{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=Q7(t.state);if(o>a||!r||n&2&&(Q7(t.startState)==this.from||o<this.limit))return new d9(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return Hse(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new J7(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??Q7(t.state)):new d9(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new d9(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function Hse(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):$7(e,!0).test(i)}var p9=EX.define({map(e,t){return e.map(e=>e.map(t))}}),m9=aX.define({create(){return Lse.start()},update(e,t){return e.update(t)},provide:e=>[T4.from(e,e=>e.tooltip),x2.contentAttributes.from(e,e=>e.attrs)]});function h9(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(m9).active.find(e=>e.source==t.source);return r instanceof f9?(typeof n==`string`?e.dispatch({...Ese(e.state,n,r.from,r.to),annotations:e9.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var Use=Nse(m9,h9);function g9(e,t=`option`){return n=>{let r=n.state.field(m9,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(i9).interactionDelay)return!1;let i=1,a;t==`page`&&(a=E4(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:o9.of(s)}),!0}}var Wse=e=>{let t=e.state.field(m9,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(i9).interactionDelay?!1:h9(e,t.open.options[t.open.selected])},_9=e=>e.state.field(m9,!1)?(e.dispatch({effects:n9.of(!0)}),!0):!1,Gse=e=>{let t=e.state.field(m9,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:r9.of(null)}),!0)},Kse=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},qse=50,Jse=1e3,Yse=p$.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(m9).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(m9),n=e.state.facet(i9);if(!e.selectionSet&&!e.docChanged&&e.startState.field(m9)==t)return;let r=e.transactions.some(e=>{let t=u9(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>qse&&Date.now()-n.time>Jse){for(let e of n.context.abortListeners)try{e()}catch(e){l$(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(n9)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(m9);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(i9).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new J7(t,Q7(t),e.explicit,this.view),r=new Kse(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:r9.of(null)}),l$(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(i9).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(i9),n=this.view.state.field(m9);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=Q7(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new f9(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new d9(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:p9.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(m9,!1);if(t&&t.tooltip&&this.view.state.facet(i9).closeOnBlur){let n=t.open&&E4(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:r9.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:n9.of(!1)}),20),this.composing=0}}}),Xse=typeof navigator==`object`&&/Win/.test(navigator.platform),Zse=cX.highest(x2.domEventHandlers({keydown(e,t){let n=t.state.field(m9,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Xse&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&h9(t,r),!1}})),v9=x2.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),Qse=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},$se=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,BY.TrackDel),r=t.mapPos(this.to,1,BY.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},ece=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(q6);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new $se(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1,c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new Qse(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},tce=GZ.widget({widget:new class extends UZ{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),nce=GZ.mark({class:`cm-snippetField`}),y9=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=GZ.set(e.map(e=>(e.from==e.to?tce:nce).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},b9=EX.define({map(e,t){return e&&e.map(t)}}),rce=EX.define(),x9=aX.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(b9))return n.value;if(n.is(rce)&&e)return new y9(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>x2.decorations.from(e,e=>e?e.deco:GZ.none)});function S9(e,t){return Y.create(e.filter(e=>e.field==t).map(e=>Y.range(e.from,e.to)))}function ice(e){let t=ece.parse(e);return(e,n,r,i)=>{let{text:a,ranges:o}=t.instantiate(e.state,r),{main:s}=e.state.selection,c={changes:{from:r,to:i==s.from?s.to:i,insert:SY.of(a)},scrollIntoView:!0,annotations:n?[e9.of(n),DX.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=S9(o,0)),o.some(e=>e.field>0)){let t=new y9(o,0),n=c.effects=[b9.of(t)];e.state.field(x9,!1)===void 0&&n.push(EX.appendConfig.of([x9,oce,cce,v9]))}e.dispatch(e.state.update(c))}}function C9(e){return({state:t,dispatch:n})=>{let r=t.field(x9,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:S9(r.ranges,i),effects:b9.of(a?null:new y9(r.ranges,i)),scrollIntoView:!0})),!0}}var ace=[{key:`Tab`,run:C9(1),shift:C9(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(x9,!1)?(t(e.update({effects:b9.of(null)})),!0):!1}],w9=QY.define({combine(e){return e.length?e[0]:ace}}),oce=cX.highest(A2.compute([w9],e=>e.facet(w9)));function sce(e,t){return{...t,apply:ice(e)}}var cce=x2.domEventHandlers({mousedown(e,t){let n=t.state.field(x9,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:S9(n.ranges,i.field),effects:b9.of(n.ranges.some(e=>e.field>i.field)?new y9(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),T9={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},E9=EX.define({map(e,t){return t.mapPos(e,-1,BY.TrackAfter)??void 0}}),D9=new class extends UX{};D9.startSide=1,D9.endSide=-1;var O9=aX.define({create(){return JX.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(E9)&&(e=e.update({add:[D9.range(n.value,n.value+1)]}));return e}});function lce(){return[dce,O9]}var k9=`()[]{}<>«»»«[]{}`;function A9(e){for(let t=0;t<16;t+=2)if(k9.charCodeAt(t)==e)return k9.charAt(t+1);return LY(e<128?e:e+1)}function j9(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||T9}var uce=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),dce=x2.inputHandler.of((e,t,n,r)=>{if((uce?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&RY(IY(r,0))==1||t!=i.from||n!=i.to)return!1;let a=pce(e.state,r);return a?(e.dispatch(a),!0):!1}),fce=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=j9(e,e.selection.main.head).brackets||T9.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=mce(e.doc,t.head);for(let i of n)if(i==r&&N9(e.doc,t.head)==A9(IY(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:Y.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function pce(e,t){let n=j9(e,e.selection.main.head),r=n.brackets||T9.brackets;for(let i of r){let a=A9(IY(i,0));if(t==i)return a==i?_ce(e,i,r.indexOf(i+i+i)>-1,n):hce(e,i,a,n.before||T9.before);if(t==a&&M9(e,e.selection.main.from))return gce(e,i,a)}return null}function M9(e,t){let n=!1;return e.field(O9).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function N9(e,t){let n=e.sliceString(t,t+2);return n.slice(0,RY(IY(n,0)))}function mce(e,t){let n=e.sliceString(t-2,t);return RY(IY(n,0))==n.length?n:n.slice(1)}function hce(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:E9.of(a.to+t.length),range:Y.range(a.anchor+t.length,a.head+t.length)};let o=N9(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:E9.of(a.head+t.length),range:Y.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function gce(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&N9(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:Y.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function _ce(e,t,n,r){let i=r.stringPrefixes||T9.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:E9.of(r.to+t.length),range:Y.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=N9(e.doc,o),c;if(s==t){if(P9(e,o))return{changes:{insert:t+t,from:o},effects:E9.of(o+t.length),range:Y.cursor(o+t.length)};if(M9(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:Y.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=F9(e,o-2*t.length,i))>-1&&P9(e,c))return{changes:{insert:t+t+t+t,from:o},effects:E9.of(o+t.length),range:Y.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=IX.Word&&F9(e,o,i)>-1&&!vce(e,o,t,i))return{changes:{insert:t+t,from:o},effects:E9.of(o+t.length),range:Y.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function P9(e,t){let n=R6(e).resolveInner(t+1);return n.parent&&n.from==t}function vce(e,t,n,r){let i=R6(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function F9(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=IX.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=IX.Word)return n}return-1}function yce(e={}){return[Zse,m9,i9.of(e),Yse,L9,v9]}var I9=[{key:`Ctrl-Space`,run:_9},{mac:"Alt-`",run:_9},{mac:`Alt-i`,run:_9},{key:`Escape`,run:Gse},{key:`ArrowDown`,run:g9(!0)},{key:`ArrowUp`,run:g9(!1)},{key:`PageDown`,run:g9(!0,`page`)},{key:`PageUp`,run:g9(!1,`page`)},{key:`Enter`,run:Wse}],L9=cX.highest(A2.computeN([i9],e=>e.facet(i9).defaultKeymap?[I9]:[]));function $(e){return new K6(Cae.define(e))}function R9(e){return J(()=>import(`./dist-ClYUxfeK.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([7,8]),import.meta.url)}var bce=[Q.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return J(()=>import(`./dist-fBO2v5Kt.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return J(()=>import(`./dist-fBO2v5Kt.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return R9(`Cassandra`)}}),Q.of({name:`CSS`,extensions:[`css`],load(){return J(()=>import(`./dist-B2_CVgKv.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([10,8]),import.meta.url)}}),Q.of({name:`Go`,extensions:[`go`],load(){return J(()=>import(`./dist-B3FR1SKK.js`).then(e=>e.go()),__vite__mapDeps([11,8]),import.meta.url)}}),Q.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return J(()=>import(`./dist-DoVSwoDb.js`).then(e=>e.html()),__vite__mapDeps([12,10,8,13]),import.meta.url)}}),Q.of({name:`Java`,extensions:[`java`],load(){return J(()=>import(`./dist-QfkEHOlb.js`).then(e=>e.java()),__vite__mapDeps([14,8]),import.meta.url)}}),Q.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return J(()=>import(`./dist-ufY3F5p6.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return J(()=>import(`./dist-DVCOWtha.js`).then(e=>e.jinja()),__vite__mapDeps([15,12,10,8,13]),import.meta.url)}}),Q.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return J(()=>import(`./dist-CB9iJrvg.js`).then(e=>e.json()),__vite__mapDeps([16,8]),import.meta.url)}}),Q.of({name:`JSX`,extensions:[`jsx`],load(){return J(()=>import(`./dist-ufY3F5p6.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`LESS`,extensions:[`less`],load(){return J(()=>import(`./dist-DFD6Qa6T.js`).then(e=>e.less()),__vite__mapDeps([17,10,8]),import.meta.url)}}),Q.of({name:`Liquid`,extensions:[`liquid`],load(){return J(()=>import(`./dist-Cf125P_m.js`).then(e=>e.liquid()),__vite__mapDeps([18,12,10,8,13]),import.meta.url)}}),Q.of({name:`MariaDB SQL`,load(){return R9(`MariaSQL`)}}),Q.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return J(()=>import(`./dist-btbmmX5O.js`).then(e=>e.markdown()),__vite__mapDeps([19,12,10,8,13]),import.meta.url)}}),Q.of({name:`MS SQL`,load(){return R9(`MSSQL`)}}),Q.of({name:`MySQL`,load(){return R9(`MySQL`)}}),Q.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return J(()=>import(`./dist-C1NMAY5a.js`).then(e=>e.php()),__vite__mapDeps([20,12,10,8,13]),import.meta.url)}}),Q.of({name:`PLSQL`,extensions:[`pls`],load(){return R9(`PLSQL`)}}),Q.of({name:`PostgreSQL`,load(){return R9(`PostgreSQL`)}}),Q.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return J(()=>import(`./dist-C5_ZAZsG.js`).then(e=>e.python()),__vite__mapDeps([21,8]),import.meta.url)}}),Q.of({name:`Rust`,extensions:[`rs`],load(){return J(()=>import(`./dist-BIr4DSRq.js`).then(e=>e.rust()),__vite__mapDeps([22,8]),import.meta.url)}}),Q.of({name:`Sass`,extensions:[`sass`],load(){return J(()=>import(`./dist-D_ctSS2i.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SCSS`,extensions:[`scss`],load(){return J(()=>import(`./dist-D_ctSS2i.js`).then(e=>e.sass()),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SQL`,extensions:[`sql`],load(){return R9(`StandardSQL`)}}),Q.of({name:`SQLite`,load(){return R9(`SQLite`)}}),Q.of({name:`TSX`,extensions:[`tsx`],load(){return J(()=>import(`./dist-ufY3F5p6.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return J(()=>import(`./dist-ufY3F5p6.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return J(()=>import(`./dist-DiixqL0J.js`).then(e=>e.wast()),__vite__mapDeps([24,8]),import.meta.url)}}),Q.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return J(()=>import(`./dist-CFzsn6BG.js`).then(e=>e.xml()),__vite__mapDeps([25,8]),import.meta.url)}}),Q.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return J(()=>import(`./dist-Bj730Ib4.js`).then(e=>e.yaml()),__vite__mapDeps([26,8]),import.meta.url)}}),Q.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return J(()=>import(`./apl-CnwPGSsG.js`).then(e=>$(e.apl)),[],import.meta.url)}}),Q.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return J(()=>import(`./asciiarmor-qTkVPQu6.js`).then(e=>$(e.asciiArmor)),[],import.meta.url)}}),Q.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return J(()=>import(`./asn1-Dr8qZg38.js`).then(e=>$(e.asn1({}))),[],import.meta.url)}}),Q.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return J(()=>import(`./asterisk-Bja0s6e1.js`).then(e=>$(e.asterisk)),[],import.meta.url)}}),Q.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return J(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>$(e.brainfuck)),[],import.meta.url)}}),Q.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return J(()=>import(`./cobol-B_OZ4V-R.js`).then(e=>$(e.cobol)),[],import.meta.url)}}),Q.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.csharp)),[],import.meta.url)}}),Q.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`ClojureScript`,extensions:[`cljs`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return J(()=>import(`./css-CYpP4FRV.js`).then(e=>$(e.gss)),[],import.meta.url)}}),Q.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return J(()=>import(`./cmake-CyVbuzPu.js`).then(e=>$(e.cmake)),[],import.meta.url)}}),Q.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return J(()=>import(`./coffeescript-B2pKbFk8.js`).then(e=>$(e.coffeeScript)),[],import.meta.url)}}),Q.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return J(()=>import(`./commonlisp-CcllspGY.js`).then(e=>$(e.commonLisp)),[],import.meta.url)}}),Q.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return J(()=>import(`./cypher-p9eYesGn.js`).then(e=>$(e.cypher)),[],import.meta.url)}}),Q.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return J(()=>import(`./python-BqYw9LYJ.js`).then(e=>$(e.cython)),[],import.meta.url)}}),Q.of({name:`Crystal`,extensions:[`cr`],load(){return J(()=>import(`./crystal-M5-qzICs.js`).then(e=>$(e.crystal)),[],import.meta.url)}}),Q.of({name:`D`,extensions:[`d`],load(){return J(()=>import(`./d-BhMjBjQP.js`).then(e=>$(e.d)),[],import.meta.url)}}),Q.of({name:`Dart`,extensions:[`dart`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.dart)),[],import.meta.url)}}),Q.of({name:`diff`,extensions:[`diff`,`patch`],load(){return J(()=>import(`./diff-ChtP43wD.js`).then(e=>$(e.diff)),[],import.meta.url)}}),Q.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return J(()=>import(`./dockerfile-BLkNEvjs.js`).then(e=>$(e.dockerFile)),__vite__mapDeps([27,28]),import.meta.url)}}),Q.of({name:`DTD`,extensions:[`dtd`],load(){return J(()=>import(`./dtd-DTF72YNO.js`).then(e=>$(e.dtd)),[],import.meta.url)}}),Q.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return J(()=>import(`./dylan-C6jEEEk-.js`).then(e=>$(e.dylan)),[],import.meta.url)}}),Q.of({name:`EBNF`,load(){return J(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>$(e.ebnf)),[],import.meta.url)}}),Q.of({name:`ECL`,extensions:[`ecl`],load(){return J(()=>import(`./ecl-BSZaIHnp.js`).then(e=>$(e.ecl)),[],import.meta.url)}}),Q.of({name:`edn`,extensions:[`edn`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Eiffel`,extensions:[`e`],load(){return J(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>$(e.eiffel)),[],import.meta.url)}}),Q.of({name:`Elm`,extensions:[`elm`],load(){return J(()=>import(`./elm-Cshzl8qu.js`).then(e=>$(e.elm)),[],import.meta.url)}}),Q.of({name:`Erlang`,extensions:[`erl`],load(){return J(()=>import(`./erlang-DaB2Rkuy.js`).then(e=>$(e.erlang)),[],import.meta.url)}}),Q.of({name:`Esper`,load(){return J(()=>import(`./sql-DcCJ9jop.js`).then(e=>$(e.esper)),[],import.meta.url)}}),Q.of({name:`Factor`,extensions:[`factor`],load(){return J(()=>import(`./factor-D7LVTn2l.js`).then(e=>$(e.factor)),__vite__mapDeps([29,28]),import.meta.url)}}),Q.of({name:`FCL`,load(){return J(()=>import(`./fcl-ClOhbFR7.js`).then(e=>$(e.fcl)),[],import.meta.url)}}),Q.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return J(()=>import(`./forth-Cezjo90N.js`).then(e=>$(e.forth)),[],import.meta.url)}}),Q.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return J(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>$(e.fortran)),[],import.meta.url)}}),Q.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.fSharp)),[],import.meta.url)}}),Q.of({name:`Gas`,extensions:[`s`],load(){return J(()=>import(`./gas-BHEdbvp9.js`).then(e=>$(e.gas)),[],import.meta.url)}}),Q.of({name:`Gherkin`,extensions:[`feature`],load(){return J(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>$(e.gherkin)),[],import.meta.url)}}),Q.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return J(()=>import(`./groovy-BC3IOsC8.js`).then(e=>$(e.groovy)),[],import.meta.url)}}),Q.of({name:`Haskell`,extensions:[`hs`],load(){return J(()=>import(`./haskell-BRsoo5mP.js`).then(e=>$(e.haskell)),[],import.meta.url)}}),Q.of({name:`Haxe`,extensions:[`hx`],load(){return J(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.haxe)),[],import.meta.url)}}),Q.of({name:`HXML`,extensions:[`hxml`],load(){return J(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.hxml)),[],import.meta.url)}}),Q.of({name:`HTTP`,load(){return J(()=>import(`./http-CLVgA2GD.js`).then(e=>$(e.http)),[],import.meta.url)}}),Q.of({name:`IDL`,extensions:[`pro`],load(){return J(()=>import(`./idl-BUZw3wgd.js`).then(e=>$(e.idl)),[],import.meta.url)}}),Q.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return J(()=>import(`./javascript-9Tg8ixDm.js`).then(e=>$(e.jsonld)),[],import.meta.url)}}),Q.of({name:`Julia`,extensions:[`jl`],load(){return J(()=>import(`./julia-CQfgDRfP.js`).then(e=>$(e.julia)),[],import.meta.url)}}),Q.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.kotlin)),[],import.meta.url)}}),Q.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return J(()=>import(`./livescript-BXxG0Yva.js`).then(e=>$(e.liveScript)),[],import.meta.url)}}),Q.of({name:`Lua`,extensions:[`lua`],load(){return J(()=>import(`./lua-CiA1ziua.js`).then(e=>$(e.lua)),[],import.meta.url)}}),Q.of({name:`mIRC`,extensions:[`mrc`],load(){return J(()=>import(`./mirc-C9zpzAZU.js`).then(e=>$(e.mirc)),[],import.meta.url)}}),Q.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return J(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>$(e.mathematica)),[],import.meta.url)}}),Q.of({name:`Modelica`,extensions:[`mo`],load(){return J(()=>import(`./modelica-CqHI_q-D.js`).then(e=>$(e.modelica)),[],import.meta.url)}}),Q.of({name:`MUMPS`,extensions:[`mps`],load(){return J(()=>import(`./mumps-CW_TBmxz.js`).then(e=>$(e.mumps)),[],import.meta.url)}}),Q.of({name:`Mbox`,extensions:[`mbox`],load(){return J(()=>import(`./mbox-BEMVcqjs.js`).then(e=>$(e.mbox)),[],import.meta.url)}}),Q.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return J(()=>import(`./nginx-BMaDbqW3.js`).then(e=>$(e.nginx)),[],import.meta.url)}}),Q.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return J(()=>import(`./nsis-AQ_alPln.js`).then(e=>$(e.nsis)),__vite__mapDeps([30,28]),import.meta.url)}}),Q.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return J(()=>import(`./ntriples-d28e9m0E.js`).then(e=>$(e.ntriples)),[],import.meta.url)}}),Q.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveC)),[],import.meta.url)}}),Q.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveCpp)),[],import.meta.url)}}),Q.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.oCaml)),[],import.meta.url)}}),Q.of({name:`Octave`,extensions:[`m`],load(){return J(()=>import(`./octave-D2Q8cUp1.js`).then(e=>$(e.octave)),[],import.meta.url)}}),Q.of({name:`Oz`,extensions:[`oz`],load(){return J(()=>import(`./oz-BwTct_5T.js`).then(e=>$(e.oz)),[],import.meta.url)}}),Q.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return J(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>$(e.pascal)),[],import.meta.url)}}),Q.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return J(()=>import(`./perl-CdEHsPfU.js`).then(e=>$(e.perl)),[],import.meta.url)}}),Q.of({name:`Pig`,extensions:[`pig`],load(){return J(()=>import(`./pig-AF4Hwhju.js`).then(e=>$(e.pig)),[],import.meta.url)}}),Q.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return J(()=>import(`./powershell-CzG71I4L.js`).then(e=>$(e.powerShell)),[],import.meta.url)}}),Q.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return J(()=>import(`./properties-C357ku5U.js`).then(e=>$(e.properties)),[],import.meta.url)}}),Q.of({name:`ProtoBuf`,extensions:[`proto`],load(){return J(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>$(e.protobuf)),[],import.meta.url)}}),Q.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return J(()=>import(`./pug-Bugr-47h.js`).then(e=>$(e.pug)),__vite__mapDeps([31,32]),import.meta.url)}}),Q.of({name:`Puppet`,extensions:[`pp`],load(){return J(()=>import(`./puppet-B4hC2X4m.js`).then(e=>$(e.puppet)),[],import.meta.url)}}),Q.of({name:`Q`,extensions:[`q`],load(){return J(()=>import(`./q-B9NhS7L_.js`).then(e=>$(e.q)),[],import.meta.url)}}),Q.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return J(()=>import(`./r-DADKenSm.js`).then(e=>$(e.r)),[],import.meta.url)}}),Q.of({name:`RPM Changes`,load(){return J(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmChanges)),[],import.meta.url)}}),Q.of({name:`RPM Spec`,extensions:[`spec`],load(){return J(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmSpec)),[],import.meta.url)}}),Q.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return J(()=>import(`./ruby-DsYpTuWg.js`).then(e=>$(e.ruby)),[],import.meta.url)}}),Q.of({name:`SAS`,extensions:[`sas`],load(){return J(()=>import(`./sas-C2OyD2Y6.js`).then(e=>$(e.sas)),[],import.meta.url)}}),Q.of({name:`Scala`,extensions:[`scala`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.scala)),[],import.meta.url)}}),Q.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return J(()=>import(`./scheme-CyDdOh7e.js`).then(e=>$(e.scheme)),[],import.meta.url)}}),Q.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return J(()=>import(`./shell-Du5Qg9im.js`).then(e=>$(e.shell)),[],import.meta.url)}}),Q.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return J(()=>import(`./sieve-BAxa3IjF.js`).then(e=>$(e.sieve)),[],import.meta.url)}}),Q.of({name:`Smalltalk`,extensions:[`st`],load(){return J(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>$(e.smalltalk)),[],import.meta.url)}}),Q.of({name:`Solr`,load(){return J(()=>import(`./solr-BBopId9w.js`).then(e=>$(e.solr)),[],import.meta.url)}}),Q.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.sml)),[],import.meta.url)}}),Q.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return J(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>$(e.sparql)),[],import.meta.url)}}),Q.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return J(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>$(e.spreadsheet)),[],import.meta.url)}}),Q.of({name:`Squirrel`,extensions:[`nut`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.squirrel)),[],import.meta.url)}}),Q.of({name:`Stylus`,extensions:[`styl`],load(){return J(()=>import(`./stylus-DLLZ8dgm.js`).then(e=>$(e.stylus)),[],import.meta.url)}}),Q.of({name:`Swift`,extensions:[`swift`],load(){return J(()=>import(`./swift-DKB6_1j6.js`).then(e=>$(e.swift)),[],import.meta.url)}}),Q.of({name:`sTeX`,load(){return J(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return J(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return J(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`Tcl`,extensions:[`tcl`],load(){return J(()=>import(`./tcl-BGfruO1u.js`).then(e=>$(e.tcl)),[],import.meta.url)}}),Q.of({name:`Textile`,extensions:[`textile`],load(){return J(()=>import(`./textile-DWBqthVk.js`).then(e=>$(e.textile)),[],import.meta.url)}}),Q.of({name:`TiddlyWiki`,load(){return J(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>$(e.tiddlyWiki)),[],import.meta.url)}}),Q.of({name:`Tiki wiki`,load(){return J(()=>import(`./tiki-CxVlf5KZ.js`).then(e=>$(e.tiki)),[],import.meta.url)}}),Q.of({name:`TOML`,extensions:[`toml`],load(){return J(()=>import(`./toml-LvoKBwCs.js`).then(e=>$(e.toml)),[],import.meta.url)}}),Q.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return J(()=>import(`./troff-C2dAgh7P.js`).then(e=>$(e.troff)),[],import.meta.url)}}),Q.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return J(()=>import(`./ttcn-BePYh-hG.js`).then(e=>$(e.ttcn)),[],import.meta.url)}}),Q.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return J(()=>import(`./ttcn-cfg-CY0aot7Q.js`).then(e=>$(e.ttcnCfg)),[],import.meta.url)}}),Q.of({name:`Turtle`,extensions:[`ttl`],load(){return J(()=>import(`./turtle-BDLWE2cD.js`).then(e=>$(e.turtle)),[],import.meta.url)}}),Q.of({name:`Web IDL`,extensions:[`webidl`],load(){return J(()=>import(`./webidl-D5jiJvOU.js`).then(e=>$(e.webIDL)),[],import.meta.url)}}),Q.of({name:`VB.NET`,extensions:[`vb`],load(){return J(()=>import(`./vb-BthdM_4N.js`).then(e=>$(e.vb)),[],import.meta.url)}}),Q.of({name:`VBScript`,extensions:[`vbs`],load(){return J(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>$(e.vbScript)),[],import.meta.url)}}),Q.of({name:`Velocity`,extensions:[`vtl`],load(){return J(()=>import(`./velocity-CqftRsjg.js`).then(e=>$(e.velocity)),[],import.meta.url)}}),Q.of({name:`Verilog`,extensions:[`v`],load(){return J(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return J(()=>import(`./vhdl-CMrOq2q1.js`).then(e=>$(e.vhdl)),[],import.meta.url)}}),Q.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return J(()=>import(`./xquery-fj_R-kMw.js`).then(e=>$(e.xQuery)),[],import.meta.url)}}),Q.of({name:`Yacas`,extensions:[`ys`],load(){return J(()=>import(`./yacas-CXXgtw0p.js`).then(e=>$(e.yacas)),[],import.meta.url)}}),Q.of({name:`Z80`,extensions:[`z80`],load(){return J(()=>import(`./z80-CL1naaMV.js`).then(e=>$(e.z80)),[],import.meta.url)}}),Q.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.mscgen)),[],import.meta.url)}}),Q.of({name:`Xù`,extensions:[`xu`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.xu)),[],import.meta.url)}}),Q.of({name:`MsGenny`,extensions:[`msgenny`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.msgenny)),[],import.meta.url)}}),Q.of({name:`Vue`,extensions:[`vue`],load(){return J(()=>import(`./dist-DvFK7p5S.js`).then(e=>e.vue()),__vite__mapDeps([33,12,10,8,13]),import.meta.url)}}),Q.of({name:`Angular Template`,load(){return J(()=>import(`./dist-BnaTiyzN.js`).then(e=>e.angular()),__vite__mapDeps([34,12,10,8,13]),import.meta.url)}})];function z9(e){let t=String(e||``).split(`/`).pop()||``,n=t.lastIndexOf(`.`);return n>=0?t.slice(n):``}function B9(e){return Q.matchFilename(bce,`file${e}`)}function V9({content:e,path:t,readOnly:n=!1,onSave:r,onDirtyChange:i,onContentChange:a,getContentRef:o}){let s=(0,v.useRef)(null),c=(0,v.useRef)(null),l=(0,v.useRef)(new uX),u=(0,v.useRef)(new uX),d=(0,v.useRef)(new uX),f=(0,v.useRef)(!1),p=(0,v.useRef)(r),m=(0,v.useRef)(i),h=(0,v.useRef)(a);(0,v.useEffect)(()=>{p.current=r,m.current=i,h.current=a},[r,i,a]);let g=(0,v.useCallback)(e=>{f.current!==e&&(f.current=e,m.current?.(e))},[]);return(0,v.useEffect)(()=>{if(!s.current)return;let r=document.documentElement.classList.contains(`dark`),i=A2.of([{key:`Mod-s`,run:e=>{let t=e.state.doc.toString();return p.current?.(t),g(!1),!0},preventDefault:!0}]),a=new x2({state:VX.create({doc:e,extensions:[a3(),l3(),Rae(),cae(),J2(),r4(),VX.allowMultipleSelections.of(!0),Zie(),S8(fae,{fallback:!0}),vae(),lce(),yce(),f4(),h4(),i4(),$oe(),A2.of([...fce,...Boe,...bse,...qae,...iae,...I9,Voe]),i,x2.updateListener.of(e=>{e.docChanged&&(g(!0),h.current?.(e.state.doc.toString()))}),d.current.of(VX.readOnly.of(n)),l.current.of([]),u.current.of(r?d7:[]),x2.theme({"&":{height:`100%`},".cm-scroller":{overflow:`auto`}})]}),parent:s.current});c.current=a,o&&(o.current=()=>a.state.doc.toString());let f=B9(z9(t));return f&&f.load().then(e=>{c.current&&c.current.dispatch({effects:l.current.reconfigure(e)})}).catch(()=>{}),()=>{a.destroy(),c.current=null,o&&(o.current=null)}},[]),(0,v.useEffect)(()=>{let t=c.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),g(!1))},[e,g]),(0,v.useEffect)(()=>{let e=c.current;if(!e)return;let n=B9(z9(t));n?n.load().then(e=>{c.current&&c.current.dispatch({effects:l.current.reconfigure(e)})}).catch(()=>{}):e.dispatch({effects:l.current.reconfigure([])})},[t]),(0,v.useEffect)(()=>{let e=c.current;e&&e.dispatch({effects:d.current.reconfigure(VX.readOnly.of(n))})},[n]),(0,v.useEffect)(()=>{let e=new MutationObserver(()=>{let e=c.current;if(!e)return;let t=document.documentElement.classList.contains(`dark`);e.dispatch({effects:u.current.reconfigure(t?d7:[])})});return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>e.disconnect()},[]),(0,O.jsx)(`div`,{ref:s,className:`h-full w-full overflow-hidden [&_.cm-editor]:h-full [&_.cm-scroller]:auto`})}function H9({content:e,objectUrl:t,kind:n,filename:r,path:i}){return n===`markdown`?(0,O.jsx)(wq,{content:e||``}):n===`image`&&t?(0,O.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,O.jsx)(`img`,{src:t,alt:r,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n===`pdf`&&t?(0,O.jsx)(`iframe`,{src:t,title:r,className:`h-full w-full border-0`}):(n===`text`||n===`code`)&&e!==null?(0,O.jsx)(V9,{content:e,path:i||r,readOnly:!0,onSave:()=>{},onDirtyChange:()=>{},getContentRef:{current:()=>e||``}}):(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,O.jsx)(`div`,{className:`w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400`,children:`该文件类型暂不支持在线预览,请直接下载查看。`})})}function U9(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function xce(e){let t=e.endsWith(`/`)?e:`${e}/`;if(typeof window>`u`)return`'self'`;try{return new URL(t,window.location.origin).toString()}catch{return`'self'`}}function W9(...e){return Array.from(new Set(e.filter(e=>!!e))).join(` `)}function Sce(e){let t=e?xce(e):void 0,n=W9(`'unsafe-inline'`,`'unsafe-eval'`,`'self'`,`https:`,t),r=W9(`'self'`,`https:`,t);return[`default-src 'none'`,`script-src ${n}`,`style-src 'unsafe-inline' data: ${r}`,`img-src data: blob: ${r}`,`font-src data: ${r}`,`media-src data: blob: ${r}`,`worker-src blob:`,`connect-src 'none'`,`form-action 'none'`,`base-uri 'self'`].join(`; `)}function Cce(e){try{let t=new URL(e,window.location.href);return[`http:`,`https:`,`mailto:`].includes(t.protocol)}catch{return!1}}function G9(e,t={}){let{channelId:n,basePath:r}=typeof t==`string`?{channelId:t}:t,i=Sce(r),a=`<script>
|
|
213
|
+
function ksadkScrollToHash(rawHref) {
|
|
214
|
+
if (!rawHref || rawHref === '#') return;
|
|
215
|
+
var rawId = rawHref.slice(1);
|
|
216
|
+
var id = rawId;
|
|
217
|
+
try {
|
|
218
|
+
id = decodeURIComponent(rawId);
|
|
219
|
+
} catch (_) {}
|
|
220
|
+
var target = document.getElementById(id) || document.getElementsByName(id)[0];
|
|
221
|
+
if (target) {
|
|
222
|
+
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
document.addEventListener('click', function(event) {
|
|
226
|
+
var target = event.target && event.target.closest ? event.target.closest('a') : null;
|
|
227
|
+
if (!target) return;
|
|
228
|
+
var rawHref = target.getAttribute('href') || '';
|
|
229
|
+
if (rawHref.charAt(0) === '#') {
|
|
230
|
+
event.preventDefault();
|
|
231
|
+
ksadkScrollToHash(rawHref);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (target.href) {
|
|
235
|
+
event.preventDefault();
|
|
236
|
+
window.parent.postMessage({
|
|
237
|
+
type: 'ksadk:linkClick',
|
|
238
|
+
channelId: ${JSON.stringify(n||``)},
|
|
239
|
+
href: target.href,
|
|
240
|
+
target: target.target || '_self'
|
|
241
|
+
}, '*');
|
|
242
|
+
}
|
|
243
|
+
}, true);
|
|
244
|
+
<\/script>`,o=`${`<meta http-equiv="Content-Security-Policy" content="${U9(i)}">`}${r?`<base href="${U9(r)}">`:``}${a}`;return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,`$&${o}`):`${o}${e}`}function K9(e,t){let n=(0,v.useRef)(null);(0,v.useEffect)(()=>(n.current=n=>{if(n.source!==e.current?.contentWindow||n.data?.type!==`ksadk:linkClick`||t&&n.data?.channelId!==t)return;let r=n.data?.href;typeof r==`string`&&r&&Cce(r)&&window.open(r,`_blank`,`noopener,noreferrer`)},window.addEventListener(`message`,n.current),()=>{n.current&&window.removeEventListener(`message`,n.current)}),[e,t])}function wce({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let o=(0,v.useRef)(null),s=(0,v.useId)(),[c,l]=(0,v.useState)(`preview`),u=_t(t),d=gt(t),f=(0,v.useCallback)(()=>G9(e,{basePath:u,channelId:s}),[e,u,s]),[p,m]=(0,v.useState)(f());(0,v.useEffect)(()=>{let e=setTimeout(()=>{m(f())},300);return()=>clearTimeout(e)},[f]),K9(o,s);let h=(0,v.useCallback)(()=>{let e=new Blob([p],{type:`text/html;charset=utf-8`}),t=URL.createObjectURL(e),n=window.open(t,`_blank`,`noopener,noreferrer`);window.setTimeout(()=>URL.revokeObjectURL(t),3e4),n||window.open(d,`_blank`,`noopener,noreferrer`)},[d,p]);return a?(0,O.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-slate-700`,children:[(0,O.jsxs)(`button`,{onClick:()=>l(`editor`),className:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,O.jsx)(vN,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,O.jsxs)(`button`,{onClick:()=>l(`preview`),className:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,O.jsx)(wN,{className:`h-3.5 w-3.5`}),`预览`]})]}),c===`editor`?(0,O.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,O.jsx)(`iframe`,{ref:o,srcDoc:p,sandbox:`allow-scripts allow-downloads allow-same-origin`,title:`HTML 预览`,className:`h-full w-full border-0 bg-white`})]}):c===`editor`?(0,O.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,O.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,O.jsxs)(`button`,{onClick:()=>l(`preview`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(wN,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,O.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,O.jsx)(`iframe`,{ref:o,srcDoc:p,sandbox:`allow-scripts allow-downloads allow-same-origin`,title:`HTML 预览`,className:`h-full w-full border-0 bg-white`}),(0,O.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex gap-1.5`,children:[(0,O.jsxs)(`button`,{onClick:h,className:`inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,title:`在新窗口中打开当前预览`,children:[(0,O.jsx)(CN,{className:`h-3.5 w-3.5`}),`新窗口`]}),(0,O.jsxs)(`button`,{onClick:()=>l(`editor`),className:`inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(vN,{className:`h-3.5 w-3.5`}),`编辑`]})]})]})}function q9(e){e.current&&clearTimeout(e.current)}function Tce({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let[o,s]=(0,v.useState)(`editor`),[c,l]=(0,v.useState)(e),u=(0,v.useRef)(null);return(0,v.useEffect)(()=>(q9(u),u.current=setTimeout(()=>l(e),300),()=>q9(u)),[e]),a?(0,O.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200/30 px-2 py-1.5 dark:border-slate-700/30`,children:[(0,O.jsxs)(`button`,{onClick:()=>s(`editor`),className:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,O.jsx)(vN,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,O.jsxs)(`button`,{onClick:()=>s(`preview`),className:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,O.jsx)(wN,{className:`h-3.5 w-3.5`}),`预览`]})]}),o===`editor`?(0,O.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,O.jsx)(wq,{content:c})})]}):o===`editor`?(0,O.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,O.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,O.jsxs)(`button`,{onClick:()=>s(`preview`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(wN,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,O.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,O.jsx)(wq,{content:c})}),(0,O.jsxs)(`button`,{onClick:()=>s(`editor`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(vN,{className:`h-3.5 w-3.5`}),`编辑`]})]})}var Ece=`/agentengine/api/v1/GetWorkspaceFileContent`,Dce=4e3;function J9(e){let t=mt(e);if(!t||t===`.`)return`.`;let n=t.split(`/`).filter(Boolean);return n.length<=1?`.`:n.slice(0,-1).join(`/`)}function Oce(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function Y9(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`0 B`:t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}var kce=[{label:`Markdown`,detail:`.md .markdown .mdx`},{label:`代码/文本`,detail:`.py .js .ts .tsx .json .yaml .log .txt`},{label:`图片`,detail:`PNG JPG GIF WebP SVG`},{label:`PDF`,detail:`.pdf`},{label:`表格文本`,detail:`CSV TSV`}];function Ace(e){return gt(e)}function X9({label:e,showSupportedTypes:t=!1}){return(0,O.jsx)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center px-6 text-center`,children:(0,O.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400`,children:[(0,O.jsx)(`div`,{children:e}),t?(0,O.jsxs)(`div`,{className:`mt-4 text-left`,children:[(0,O.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.12em] text-slate-400`,children:`支持在线预览`}),(0,O.jsx)(`div`,{className:`mt-2 grid gap-2`,children:kce.map(e=>(0,O.jsxs)(`div`,{className:`rounded-xl border border-slate-200 bg-white px-3 py-2 dark:border-slate-800 dark:bg-slate-950`,children:[(0,O.jsx)(`div`,{className:`text-sm font-medium text-slate-700 dark:text-slate-200`,children:e.label}),(0,O.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-slate-400`,children:e.detail})]},e.label))}),(0,O.jsx)(`div`,{className:`mt-3 text-xs leading-5 text-slate-400`,children:`Word、Excel、PPT 当前不支持在线预览,可下载后查看。`})]}):null]})})}function Z9({agentId:e,capability:t,open:n,onClose:r,isFullscreen:i=!1,onToggleFullscreen:a,isMobile:o=!1,api:s}){let c=(0,v.useRef)(null),l=(0,v.useRef)(null),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(`.`),[m,h]=(0,v.useState)([]),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(!1),[ee,C]=(0,v.useState)(``),[w,te]=(0,v.useState)(null),[ne,T]=(0,v.useState)(null),[re,ie]=(0,v.useState)(!1),[ae,oe]=(0,v.useState)(!1),se=(0,v.useRef)(null),ce=(0,v.useRef)(null),le=(0,v.useRef)(`selection`),E=(0,v.useRef)(Dt()),D=(0,v.useMemo)(()=>m.find(e=>e.Path===w)??null,[m,w]),ue=(0,v.useMemo)(()=>D?Tt({path:D.Path,mimeType:D.MimeType}):null,[D]),de=(0,v.useCallback)(()=>re?window.confirm(`当前文件有未保存的更改,确定要离开吗?`):!0,[re]),fe=t.ContentPath||Ece,pe=t.RootLabel||`Workspace`,me=pe?`${pe.charAt(0).toUpperCase()}${pe.slice(1)}`:`Workspace`,he=yt(f),ge=(0,v.useCallback)(()=>{l.current&&=(URL.revokeObjectURL(l.current),null)},[]);(0,v.useEffect)(()=>()=>ge(),[ge]);let _e=(0,v.useCallback)(async(t,n={})=>{let r=!!n.background;r?b(!0):_(!0),r||C(``);try{let n=await s.listWorkspaceFiles(e,t,!1),i=mt(String(n?.Path||t||`.`)),a=Array.isArray(n?.Entries)?n.Entries:[];p(i),h(a),le.current=r?`background-refresh`:`selection`,te(e=>{if(e){let t=a.find(t=>t.Path===e);if(t&&t.Type===`file`)return e}return a.find(e=>e.Type===`file`)?.Path??null})}catch(e){console.error(`Failed to load workspace entries:`,e),r||C(e instanceof Error?e.message:String(e))}finally{r?b(!1):_(!1)}},[e,s]);(0,v.useEffect)(()=>{!n||u||(d(!0),_e(`.`))},[u,_e,n]),(0,v.useEffect)(()=>{if(!n||re||!u)return;let e=window.setInterval(()=>{_e(f,{background:!0})},Dce);return()=>window.clearInterval(e)},[f,re,u,_e,n]);let ve=(0,v.useCallback)(async t=>{let n=E.current.next(t.Path),r=Ct({path:t.Path,mimeType:t.MimeType});if(ce.current=t.Path,r===`unsupported`){ge(),T({path:t.Path,kind:r,status:`ready`,mimeType:t.MimeType??void 0});return}ge(),T({path:t.Path,kind:r,status:`loading`,mimeType:t.MimeType??void 0});try{let r=await s.getWorkspaceFileContent(e,t.Path,{asText:!1});if(!E.current.isCurrent(n))return;if(r instanceof Blob){let e=t.MimeType||``,i=Ct({path:t.Path,mimeType:e});if(i===`image`||i===`pdf`){let n=URL.createObjectURL(r);l.current=n,T({path:t.Path,kind:i,status:`ready`,mimeType:e,objectUrl:n});return}let a=await r.text();if(!E.current.isCurrent(n))return;let o=Ct({path:t.Path,mimeType:e});T({path:t.Path,kind:o,status:`ready`,mimeType:e,content:a})}else{let e=t.MimeType||``,n=Ct({path:t.Path,mimeType:e});T({path:t.Path,kind:n,status:`ready`,mimeType:e,content:r})}}catch(e){if(!E.current.isCurrent(n))return;console.error(`Failed to preview workspace file:`,e),T({path:t.Path,kind:r,status:`error`,mimeType:t.MimeType??void 0,error:e instanceof Error?e.message:String(e)})}},[e,s,ge]);(0,v.useEffect)(()=>{if(!D||D.Type!==`file`){ge(),T(null),ie(!1),ce.current=null;return}if(le.current===`background-refresh`&&ce.current===D.Path){le.current=`selection`;return}le.current=`selection`,ve(D)},[ge,ve,D]);let ye=async n=>{if(!(!n||n.length===0)){S(!0),C(``);try{for(let r of Array.from(n)){if(r.size>t.MaxUploadBytes)throw Error(`文件 ${r.name} 超过上传上限`);let n=vt(f)?r.name:`${f}/${r.name}`,i=new FormData;i.append(`file`,r),i.append(`AgentId`,e),i.append(`Path`,n),await s.addWorkspaceFile(i)}await _e(f)}catch(e){console.error(`Failed to upload workspace files:`,e),C(e instanceof Error?e.message:String(e))}finally{c.current&&(c.current.value=``),S(!1)}}},be=async n=>{if(!t.SupportsDelete)return;let r=mt(n.Path);if(window.confirm(`删除 ${r} ?`)){C(``);try{await s.deleteWorkspaceFile(e,r),w&&mt(w)===r&&(te(null),ie(!1)),await _e(n.Type===`directory`&&(mt(f)===r||mt(f).startsWith(`${r}/`))?J9(r):f)}catch(e){console.error(`Failed to delete workspace file:`,e),C(e instanceof Error?e.message:String(e))}}},xe=()=>!D||D.Type!==`file`?(0,O.jsx)(X9,{label:`从左侧选择文件后在这里查看内容预览。`,showSupportedTypes:!0}):!ne||ne.path!==D.Path||ne.status===`loading`?(0,O.jsx)(`div`,{className:`flex h-full min-h-[16rem] items-center justify-center`,children:(0,O.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-2 text-sm text-slate-500 shadow-sm dark:border-slate-800 dark:bg-slate-900 dark:text-slate-400`,children:[(0,O.jsx)(MN,{className:`h-4 w-4 animate-spin`}),`正在加载预览...`]})}):ne.status===`error`?(0,O.jsx)(X9,{label:ne.error||`文件预览加载失败。`}):ne.kind===`markdown`?(0,O.jsx)(Tce,{content:ne.content||``,path:D.Path,onSave:Se,onDirtyChange:ie,getContentRef:se,isMobile:o}):ne.kind===`image`&&ne.objectUrl?(0,O.jsx)(H9,{content:null,objectUrl:ne.objectUrl,kind:`image`,filename:D.Name,mimeType:ne.mimeType||``}):ne.kind===`pdf`&&ne.objectUrl?(0,O.jsx)(H9,{content:null,objectUrl:ne.objectUrl,kind:`pdf`,filename:D.Name,mimeType:ne.mimeType||``}):ne.kind===`html`?(0,O.jsx)(wce,{content:ne.content||``,path:D.Path,onSave:Se,onDirtyChange:ie,getContentRef:se,isMobile:o,agentId:e,contentPath:fe}):ne.kind===`text`||ne.kind===`code`?(0,O.jsx)(V9,{content:ne.content||``,path:D.Path,onSave:Se,onDirtyChange:ie,getContentRef:se}):(0,O.jsx)(H9,{content:null,kind:`unsupported`,filename:D.Name,mimeType:ne.mimeType||``}),Se=async t=>{if(D){oe(!0),C(``);try{let n=new Blob([t],{type:D.MimeType||`text/plain`}),r=new FormData;r.append(`file`,n,D.Name),r.append(`AgentId`,e),r.append(`Path`,D.Path),await s.addWorkspaceFile(r),E.current.invalidate(),ie(!1),T(e=>e&&e.path===D.Path?{...e,content:t}:e),ce.current=D.Path,await _e(f,{background:!0})}catch(e){console.error(`Failed to save workspace file:`,e),C(e instanceof Error?e.message:String(e))}finally{oe(!1)}}},Ce=D?.Type===`file`&&ne?.path===D.Path&&ne.status===`ready`&&(ne.kind===`text`||ne.kind===`code`||ne.kind===`html`||ne.kind===`markdown`),we=D?.Type===`file`&&ne?.path===D.Path&&ne.status===`ready`&&ne.kind===`pdf`;return(0,O.jsxs)(`div`,{className:`flex h-full min-h-[22rem] w-full min-w-0 flex-col bg-white text-slate-800 dark:bg-slate-950 dark:text-slate-200`,children:[(0,O.jsxs)(`div`,{className:`flex h-14 flex-shrink-0 items-center gap-3 border-b border-slate-200/30 px-4 dark:border-slate-800/40`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,O.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:me}),(0,O.jsx)(`div`,{className:`hidden h-4 w-px bg-slate-200/70 dark:bg-slate-800 sm:block`}),(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`flex-shrink-0 text-xs text-slate-400`,children:`当前目录`}),(0,O.jsx)(`div`,{className:`custom-scrollbar max-w-[min(42vw,34rem)] overflow-x-auto whitespace-nowrap rounded-md bg-slate-50 px-2 py-1 font-mono text-[11px] text-slate-600 dark:bg-slate-900 dark:text-slate-300`,title:`${he},来自 ListWorkspaceFiles 返回的 Data.Path 字段`,children:he})]}),(0,O.jsx)(`div`,{className:`hidden truncate text-[11px] text-slate-400 xl:block`,children:`工作区内相对路径,不是宿主机绝对路径。`})]}),(0,O.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-1.5`,children:[(0,O.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void ye(e.target.files)}),(0,O.jsxs)(`button`,{type:`button`,onClick:()=>c.current?.click(),disabled:x,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:text-slate-300 dark:hover:bg-slate-900`,title:`上传文件,上限 ${Math.floor(t.MaxUploadBytes/(1024*1024))}MB`,children:[(0,O.jsx)(aP,{className:`h-3.5 w-3.5`}),x?`上传中`:`上传`]}),(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{let e=new URLSearchParams({Path:f}).toString();window.open(`/agentengine/api/v1/ExportWorkspaceZip?${e}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-900`,title:`导出当前目录为 ZIP`,children:[(0,O.jsx)(RN,{className:`h-3.5 w-3.5`}),`导出`]}),a?(0,O.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,"aria-label":i?`退出全屏`:`全屏查看 Workspace`,title:i?`退出全屏`:`全屏查看`,children:i?(0,O.jsx)(LN,{className:`h-4 w-4`}):(0,O.jsx)(NN,{className:`h-4 w-4`})}):null,r?(0,O.jsx)(`button`,{type:`button`,onClick:()=>{de()&&r?.()},className:`rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,"aria-label":`关闭 Workspace`,title:`关闭`,children:(0,O.jsx)(cP,{className:`h-4 w-4`})}):null]})]}),(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,O.jsxs)(`div`,{className:`flex w-full flex-col border-b border-slate-200/30 dark:border-slate-800/40 md:w-[13.5rem] md:border-b-0 md:border-r`,children:[(0,O.jsxs)(`div`,{className:`flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-3 dark:border-slate-800/40`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-slate-900 dark:text-slate-100`,children:`文件`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-slate-400`,children:[(0,O.jsxs)(`span`,{children:[m.length,` 项`]}),y?(0,O.jsx)(qN,{className:`h-3 w-3 animate-spin`,"aria-label":`正在同步 Workspace 目录`}):null]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>{de()&&_e(J9(f))},disabled:g||vt(f),className:`rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900`,title:`返回上级目录`,children:(0,O.jsx)(uN,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>{de()&&_e(f)},disabled:g,className:`rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900`,title:`刷新目录`,children:(0,O.jsx)(qN,{className:`h-4 w-4 ${g?`animate-spin`:``}`})})]})]}),ee?(0,O.jsx)(`div`,{className:`mt-3 rounded-xl border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-600 dark:border-red-900/60 dark:bg-red-950/40 dark:text-red-300`,children:ee}):null]}),(0,O.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto px-2 py-2`,children:!u&&!n?(0,O.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`打开面板后加载 workspace 文件。`}):g?(0,O.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`正在加载目录...`}):m.length===0?(0,O.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`当前目录为空。`}):(0,O.jsx)(`div`,{className:`space-y-0.5`,children:m.map(e=>{let n=Ct({path:e.Path,mimeType:e.MimeType}),r=w===e.Path,i=e.Type===`file`?Ace(e.Path):``;return(0,O.jsxs)(`div`,{title:e.Path,className:K(`group flex items-center gap-1 rounded-lg px-1.5 py-1 transition`,r?`bg-slate-100 text-slate-950 dark:bg-slate-800 dark:text-slate-50`:`text-slate-700 hover:bg-slate-50 dark:text-slate-300 dark:hover:bg-slate-900`),children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{if(e.Type===`directory`){_e(e.Path);return}w!==e.Path&&!de()||te(e.Path)},className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,O.jsx)(`div`,{className:K(`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md`,r?`text-slate-900 dark:text-slate-50`:`text-slate-400 dark:text-slate-500`),children:e.Type===`directory`?(0,O.jsx)(ON,{className:`h-3.5 w-3.5`}):n===`image`?(0,O.jsx)(AN,{className:`h-3.5 w-3.5`}):n===`markdown`||n===`text`||n===`html`?(0,O.jsx)(TN,{className:`h-3.5 w-3.5`}):(0,O.jsx)(DN,{className:`h-3.5 w-3.5`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`div`,{className:`truncate text-[13px] leading-5`,children:e.Name}),(0,O.jsx)(`div`,{className:K(`truncate text-[11px] leading-4`,r?`text-slate-500 dark:text-slate-400`:`text-slate-400`),children:e.Type===`directory`?`目录`:Y9(e.SizeBytes)})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-0.5 opacity-0 transition group-hover:opacity-100`,children:[e.Type===`file`?(0,O.jsx)(`a`,{href:i,download:e.Name,className:K(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`下载`,children:(0,O.jsx)(bN,{className:`h-3.5 w-3.5`})}):null,t.SupportsDelete?(0,O.jsx)(`button`,{type:`button`,onClick:()=>void be(e),className:K(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`删除`,children:(0,O.jsx)(iP,{className:`h-3.5 w-3.5`})}):null]})]},e.Path)})})})]}),(0,O.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,O.jsx)(`div`,{className:`flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-4 dark:border-slate-800/40`,children:D?(0,O.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:D.Name}),(0,O.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-slate-400`,children:D.Path}),(0,O.jsxs)(`div`,{className:`mt-1 text-[11px] text-slate-400`,children:[Y9(D.SizeBytes),D.MimeType?` · ${D.MimeType}`:``,D.ModifiedAt?` · ${Oce(D.ModifiedAt)}`:``]})]}),ue===`text`||ue===`code`||ue===`html`||ue===`markdown`?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{let e=se.current;e&&Se(e())},disabled:!re||ae,className:K(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition`,re&&!ae?`bg-blue-600 text-white hover:bg-blue-700`:`text-slate-400 dark:text-slate-500 cursor-not-allowed`),children:[(0,O.jsx)(JN,{className:`h-3.5 w-3.5`}),ae?`保存中`:re?`保存`:`已保存`]}):null]}):(0,O.jsxs)(`div`,{className:`w-full`,children:[(0,O.jsx)(`div`,{className:`text-sm font-semibold text-slate-900 dark:text-slate-100`,children:`文件预览`}),(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-slate-500 dark:text-slate-400`,children:`选择左侧文件后可在此查看内容。`})]})}),(0,O.jsx)(`div`,{className:K(`custom-scrollbar min-h-0 flex-1`,we||Ce?`overflow-hidden p-0`:`overflow-y-auto px-4 py-4`),children:xe()})]})]})]})}function jce({agentId:e,capability:t,workspacePanelOpen:n,workspacePanelWidth:r,workspacePanelFullscreen:i,isMobile:a,workspaceEnabled:o,workspaceFiles:s,workspacePanelPresentation:c,closeWorkspacePanel:l,handleWorkspacePanelResizeStart:u,api:d}){let f=c.renderMode===`inline`,p=c.renderMode===`sheet`;return!o||!s?null:(0,O.jsxs)(O.Fragment,{children:[f?(0,O.jsxs)(O.Fragment,{children:[n&&!i?(0,O.jsx)(`div`,{role:`separator`,"aria-label":`调整 Workspace 宽度`,"aria-orientation":`vertical`,onPointerDown:u,className:`hidden h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-blue-200/60 dark:hover:bg-blue-900/50 md:block`}):null,(0,O.jsx)(`aside`,{style:n&&!i?{width:`${r}px`}:void 0,className:K(i?`fixed inset-0 z-40 flex h-[var(--app-height)] w-screen overflow-hidden bg-white dark:bg-slate-950`:`hidden h-full flex-shrink-0 overflow-hidden bg-white transition-[width] duration-200 ease-out dark:bg-slate-950 md:flex`,n?`border-l border-slate-200/30 dark:border-slate-800/40`:`w-0 border-l border-transparent`),children:n?(0,O.jsx)(Z9,{agentId:e,capability:t,open:n,onClose:l,isFullscreen:i,onToggleFullscreen:()=>ve.getState().setWorkspacePanelFullscreen(!i),isMobile:a,api:d}):null})]}):null,p?(0,O.jsx)(qR,{open:n,onOpenChange:e=>{e||ve.getState().setWorkspacePanelFullscreen(!1),ve.getState().setWorkspacePanelOpen(e)},modal:c.modal,children:(0,O.jsxs)(YR,{side:c.side,showOverlay:c.showOverlay,onInteractOutside:e=>{c.preventOutsideClose&&e.preventDefault()},showCloseButton:!1,className:K(`border-slate-200 bg-white p-0 dark:border-slate-800 dark:bg-slate-950`,a?`h-[70vh] rounded-t-[1.75rem]`:`h-[calc(100vh-1.5rem)] w-[min(72rem,calc(100vw-1.5rem))] max-w-[calc(100vw-1.5rem)] rounded-l-[1.5rem] border-l shadow-2xl`),children:[(0,O.jsx)(ZR,{className:`sr-only`,children:`Workspace 文件`}),(0,O.jsx)(QR,{className:`sr-only`,children:`浏览、上传和预览 Workspace 文件。`}),(0,O.jsx)(Z9,{agentId:e,capability:t,open:n,onClose:l,isMobile:a,api:d})]})}):null]})}var Q9=new Kc,Mce=v.lazy(()=>J(()=>import(`./ArtifactsPanel-CGbWlMNh.js`).then(e=>({default:e.ArtifactsPanel})),[],import.meta.url)),Nce=v.lazy(()=>J(()=>import(`./NativeTerminalPanel-zvL-WpAn.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function Pce(e={}){let t=e.apiAdapter||Q9,[n,r]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=new AbortController;return t.getAgentUiBootstrap(void 0,{signal:e.signal}).then(n=>{e.signal.aborted||r({api:t,data:n})}).catch(()=>{e.signal.aborted||r({api:t,data:void 0})}),()=>e.abort()},[t]),!n||n.api!==t)return(0,O.jsx)(he,{});let i=n.data?.AuthorizationScopeKey;return(0,O.jsx)(ge,{authorizationScopeKey:e.authorizationScopeKey??(typeof i==`string`&&i?i:void 0),children:(0,O.jsx)(Fce,{...e,bootstrapData:n.data})})}function Fce({apiAdapter:e,initialSurface:t=`chat`,routeShell:n,bootstrapData:r}){let i=e||Q9,a=He(e=>e.agentId),o=E(e=>e.currentSessionId),s=k(e=>e.isStreaming),c=ve(e=>e.sidebarOpen),l=ve(e=>e.mobileSidebarOpen),u=ve(e=>e.mobileActionsOpen),d=He(e=>e.agentName),f=We(e=>e.selectedModel),p=We(e=>e.availableModels),m=We(e=>e.modelSource),h=We(e=>e.modelCatalogLoaded),g=We(e=>e.thinkingMode),_=fe(e=>e.permissionMode),y=He(e=>e.agentFramework),b=He(e=>e.workspaceFiles),x=He(e=>e.accessMode),S=He(e=>e.status),ee=He(e=>e.errorMessage),C=ve(e=>e.workspacePanelOpen),w=ve(e=>e.workspacePanelWidth),te=ve(e=>e.workspacePanelFullscreen),ne=He(e=>e.apiFormats),T=He(e=>e.capabilities),re=rt(e=>e.visible&&!!e.content),ie=(0,v.useRef)([]),ae=(0,v.useRef)(null),{isMobile:oe,viewportHeight:se}=qt(),ce=st({isMobile:oe,viewportHeight:se}),{fetchSessions:le,loadMoreSessions:D,loadSession:ue,followAcceptedInteraction:de,loadOlderSessionMessages:pe,createNewSession:me,adoptCreatedSession:he,waitForPendingSessionCreation:ge,deleteSession:_e,currentSessionIdRef:ye,agentIdRef:be,runSubscriptionAbortRef:xe}=QM({agentId:a,currentSessionId:o,isMobile:oe,uiCapabilities:T,api:i,resetCompaction:()=>{},disconnectRun:()=>ae.current?.()}),Se=(0,v.useCallback)(e=>{if(!e)return;let t=()=>{E.getState().clearSessionMessageHistory(e),le(be.current,e)};queueMicrotask(t),window.setTimeout(t,1800),window.setTimeout(t,5e3)},[be,le]),Ce=p.find(e=>e.id===f)||null,{submitDraft:we,stopGeneration:Te,disconnectRun:Ee,resumeCheckpoint:De,submitAguiAction:Oe,respondToAguiApproval:ke}=rM({agentId:a,currentSessionId:o,agentFramework:y,apiFormats:ne,selectedModel:f,selectedModelMetadata:Ce,thinkingMode:g,permissionMode:_,uiCapabilities:T,isMobile:oe,api:i,currentSessionIdRef:ye,agentIdRef:be,queuedDraftRef:ie,onRunSettled:Se,onSessionCreated:e=>he(e,!0),waitForPendingSessionCreation:ge});(0,v.useEffect)(()=>{ae.current=Ee},[Ee]);let Ae=(0,v.useCallback)(()=>{let e=ye.current;xe.current?.abort(),k.getState().stopActivity(),k.getState().stopSessionActivity(e),Te()},[ye,xe,Te]),je=(0,v.useCallback)(async()=>{let e=ye.current,t=k.getState(),n=t.getSessionActivity(e)?.runId||t.currentRunId||``;if(e&&n)try{await i.cancelRun(a,e,n),k.getState().stopSessionActivity(e,`取消请求已发送,后台运行会停在最近 checkpoint。`)}catch(t){console.warn(`[App] cancelRun failed:`,t),k.getState().updateActivity({sessionId:e,status:`failed`,phase:`取消请求失败`,detail:t instanceof Error?t.message:String(t),countEvent:!1})}Se(e)},[i,a,ye,Se]),{submitResponseFeedback:Me,deleteResponseFeedback:Ne,respondToApproval:Pe}=mM({agentId:a,currentSessionId:o,isStreaming:s,api:i,submitDraft:we}),Fe=(0,v.useRef)(Pe),Ie=(0,v.useRef)(ke);(0,v.useEffect)(()=>{Fe.current=Pe,Ie.current=ke},[Pe,ke]);let{pending:Le,records:Re,respond:ze,localCatalog:Ve}=hM({agentId:a,getAgentId:()=>be.current,currentSessionId:o,api:i,interactionV1Enabled:!!T.InteractionV1,onAcceptedInteraction:de,legacyResponsesApproval:(e,t)=>{Fe.current({approvalRequestId:e,approve:t})},legacyAguiResume:(e,t,n)=>Ie.current({interruptId:e,approve:t===`resolved`})});Zc({fetchSessions:le},void 0,i,r),(0,v.useEffect)(()=>{be.current=a,Pt(a,o)},[a,o,be]),(0,v.useEffect)(()=>{oe?ve.getState().setWorkspacePanelFullscreen(!1):(ve.getState().setMobileSidebarOpen(!1),ve.getState().setMobileActionsOpen(!1))},[oe]),(0,v.useEffect)(()=>{C||ve.getState().setWorkspacePanelFullscreen(!1)},[C]),(0,v.useEffect)(()=>()=>{xe.current?.abort()},[xe]);let Ue=Be(T),Ge=!!T.Thinking,Ke=Ot({workspaceFiles:b,accessMode:x}),qe=Et({isMobile:oe}),Je=Vt({capability:T.NativeDashboard,agentFramework:y,accessMode:x,origin:window.location.origin}),Ye=!Ue,Xe=y===`openclaw`?`OpenClaw`:y===`hermes`?`Hermes`:`原生运行时`,Ze=Ce?.display_name||f||``,Qe=!oe&&c&&Ue,$e=(0,v.useRef)(!1),[et,tt]=(0,v.useState)(t===`tui`),nt=et&&!!T.NativeTerminal?.Enabled;(0,v.useEffect)(()=>{$e.current||t!==`workspace`||!Ke||($e.current=!0,ve.getState().setWorkspacePanelOpen(!0),ve.getState().setWorkspacePanelFullscreen(!0))},[t,Ke]);let it=()=>{ve.getState().setWorkspacePanelFullscreen(!1),ve.getState().setWorkspacePanelOpen(!1)};if(S!==`ready`){let e=S===`auth-required`,t=(0,O.jsx)(`div`,{className:`ksadk-web`,children:(0,O.jsx)(`div`,{className:`fixed inset-0 flex h-[var(--app-height)] min-h-[var(--app-height)] items-center justify-center bg-slate-50 px-6 font-sans text-slate-800 dark:bg-slate-950 dark:text-slate-100`,children:(0,O.jsxs)(`div`,{className:`w-full max-w-lg rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm dark:border-slate-800 dark:bg-slate-900`,children:[(0,O.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-blue-50 text-xl text-blue-600 dark:bg-blue-950/50`,children:S===`loading`?`…`:`↗`}),(0,O.jsx)(`h1`,{className:`text-xl font-semibold`,children:S===`loading`?`正在连接 Agent`:e?`需要有效的访问链接`:`Agent 暂时无法连接`}),S===`loading`?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`p`,{className:`mt-3 text-sm leading-6 text-slate-500 dark:text-slate-400`,children:[ee,e?` 请从 AgentEngine 控制台重新打开 Dashboard,或使用 agentengine dashboard open 获取临时链接。`:``]}),(0,O.jsx)(`button`,{type:`button`,className:`mt-6 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-blue-500`,onClick:()=>window.location.reload(),children:`重新加载`})]})]})})});return n?(0,O.jsx)(n,{children:t}):t}let at=(0,O.jsx)(`div`,{className:`ksadk-web`,children:(0,O.jsxs)(`div`,{className:`fixed inset-0 flex h-[var(--app-height)] min-h-[var(--app-height)] overflow-hidden bg-white font-sans text-slate-800 dark:bg-slate-900 dark:text-slate-200`,children:[(0,O.jsx)(Hne,{uiCapabilities:T,createNewSession:me,deleteSession:_e,loadSession:ue,loadMoreSessions:D}),(0,O.jsxs)(`main`,{className:`relative flex min-w-0 flex-1 flex-col bg-white dark:bg-slate-900`,children:[(0,O.jsx)(sY,{agentName:d,currentSessionId:o,nativeLauncherMode:Ye,isMobile:oe,sidebarOpen:c,mobileSidebarOpen:l,onToggleSidebar:()=>{oe?ve.getState().toggleMobileSidebar():ve.getState().toggleSidebar()},availableModels:p,selectedModel:f,onSelectModel:e=>{We.getState().setSelectedModel(e),oe&&ve.getState().setMobileActionsOpen(!1)},selectedModelLabel:Ze,modelCatalogLoaded:h,modelSource:m,thinkingEnabled:Ge,thinkingMode:g,onSelectThinkingMode:e=>We.getState().setThinkingMode(Ut(e)),mobileActionsOpen:u,onMobileActionsOpenChange:e=>ve.getState().setMobileActionsOpen(e),workspaceEnabled:Ke,onOpenWorkspace:()=>ve.getState().setWorkspacePanelOpen(!0),nativeManagementLink:Je,nativeTerminal:T.NativeTerminal}),Ye?(0,O.jsx)(lY,{productLabel:Xe,nativeManagementLink:Je,nativeTerminal:T.NativeTerminal,workspaceEnabled:Ke,onOpenWorkspace:()=>ve.getState().setWorkspacePanelOpen(!0)}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(HJ,{agentName:d,isMobile:oe,onDeleteFeedback:Ne,onSubmitFeedback:Me,onRespondToApproval:Pe,onRespondToAguiApproval:ke,onSubmitAguiAction:Oe,onStopGeneration:Ae,onCancelRemote:T.StopRun?je:void 0,checkpointResumeEnabled:T.RunLifecycle.Enabled&&T.RunLifecycle.Checkpoints&&T.RunLifecycle.CheckpointResume,onResumeCheckpoint:De,onLoadOlderSessionMessages:pe,interactionRecords:Re}),(0,O.jsx)(iY,{onCompactContext:T.ContextCompaction&&i.compactSession?async()=>{if(!(!o||!i.compactSession)){if((await i.compactSession(a,o)).Status!==`completed`)throw Error(`运行时尚未确认压缩完成`);await le(a,o)}}:void 0,composerMaxHeight:ce,submitDraft:we,stopGeneration:Ae,cancelRemote:T.StopRun?je:void 0,isMobile:oe,attachmentsEnabled:T.Attachments!==!1,approvalEnabled:!!T.Approval&&T.ApprovalPolicy?.RuntimeOverride!==!1,approvalPolicy:T.ApprovalPolicy,thinkingEnabled:Ge,runtimeCapabilityMatrix:T.RuntimeCapabilityMatrix,pendingInteractions:Le,onRespondInteraction:e=>{ze(e)},localCatalog:Ve})]})]}),(0,O.jsx)(jce,{agentId:a,capability:b,workspacePanelOpen:C,workspacePanelWidth:w,workspacePanelFullscreen:te,isMobile:oe,workspaceEnabled:Ke,workspaceFiles:b,workspacePanelPresentation:qe,closeWorkspacePanel:it,handleWorkspacePanelResizeStart:e=>{if(te||oe)return;e.preventDefault();let t=e.clientX,n=w,r=Ue&&Qe?280:0,i=document.body.style.cursor,a=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let o=e=>{let i=n+t-e.clientX;ve.getState().setWorkspacePanelWidth(El(i,window.innerWidth,r))},s=()=>{document.body.style.cursor=i,document.body.style.userSelect=a,window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},api:i}),re&&(0,O.jsx)(v.Suspense,{fallback:null,children:(0,O.jsx)(Mce,{})}),nt?(0,O.jsx)(v.Suspense,{fallback:null,children:(0,O.jsx)(Nce,{capability:T.NativeTerminal,open:!0,sessionId:o,onClose:()=>tt(!1)})}):null]})});return n?(0,O.jsx)(n,{children:at}):at}function Ice(){return(0,O.jsx)(Pce,{})}function Lce(e){let t=e instanceof Error?e.message:String(e||``);return/loading chunk|chunkloaderror|failed to fetch dynamically imported module|error loading dynamically imported module|importing a module script failed/i.test(t)}var $9=`agentengine-ui:chunk-reload-attempted`,Rce=class extends v.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){if(console.error(`UI 渲染错误:`,e,t),Lce(e))try{window.sessionStorage.getItem($9)||(window.sessionStorage.setItem($9,String(Date.now())),window.location.reload())}catch{window.location.reload()}}handleReload=()=>{try{window.sessionStorage.removeItem($9)}catch{}this.setState({hasError:!1,error:null}),window.location.reload()};render(){return this.state.hasError?(0,O.jsx)(`div`,{className:`flex h-screen w-screen items-center justify-center bg-slate-50 dark:bg-slate-900`,children:(0,O.jsxs)(`div`,{className:`max-w-md rounded-2xl border border-red-200 bg-white p-8 text-center shadow-lg dark:border-red-900 dark:bg-slate-950`,children:[(0,O.jsx)(`div`,{className:`mb-4 text-4xl`,children:`⚠`}),(0,O.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-red-600 dark:text-red-400`,children:`页面渲染出错`}),(0,O.jsx)(`p`,{className:`mb-6 text-sm text-slate-600 dark:text-slate-400`,children:this.state.error?.message||`发生了未知错误,请刷新页面重试。`}),(0,O.jsx)(`button`,{onClick:this.handleReload,className:`rounded-lg bg-blue-600 px-6 py-2.5 text-sm font-medium text-white transition hover:bg-blue-700`,children:`刷新页面`})]})}):this.props.children}};function zce(){let e=ve(e=>e.toasts),t=ve(e=>e.dismissToast);return(0,v.useEffect)(()=>{if(!e.length)return;let n=e[0],r=3e3-(Date.now()-n.createdAt);if(r<=0){t(n.id);return}let i=setTimeout(()=>t(n.id),r);return()=>clearTimeout(i)},[e,t]),e.length?(0,O.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-4 py-3 text-sm shadow-lg transition-all ${e.variant===`error`?`bg-red-600 text-white`:`bg-slate-800 text-white dark:bg-slate-200 dark:text-slate-900`}`,children:[(0,O.jsx)(`span`,{className:`flex-1`,children:e.message}),(0,O.jsx)(`button`,{onClick:()=>t(e.id),className:`shrink-0 rounded p-0.5 opacity-70 hover:opacity-100`,children:(0,O.jsx)(cP,{size:14})})]},e.id))}):null}y.createRoot(document.getElementById(`root`)).render((0,O.jsxs)(Rce,{children:[(0,O.jsx)(Ice,{}),(0,O.jsx)(zce,{})]}));export{fB as $,p3 as A,VX as B,F6 as C,o as Ct,Z as D,d6 as E,x3 as F,mq as G,sZ as H,G3 as I,JW as J,QK as K,x2 as L,g3 as M,V3 as N,u3 as O,U3 as P,FH as Q,A2 as R,N6 as S,p as St,o6 as T,l as Tt,oJ as U,cX as V,J as W,WH as X,GU as Y,GH as Z,Qie as _,yN as _t,Tse as a,Tz as at,Q6 as b,rt as bt,I6 as c,Une as ct,B6 as d,iP as dt,aB as et,D8 as f,$N as ft,Jie as g,bN as gt,qie as h,wN as ht,X7 as i,Dz as it,_3 as j,b3 as k,Q as l,K as lt,P6 as m,GN as mt,K9 as n,are as nt,sce as o,iz as ot,Yie as p,qN as pt,YK as q,J7 as r,Ez as rt,Iie as s,Wne as st,G9 as t,Jz as tt,K6 as u,cP as ut,n8 as v,fN as vt,R6 as w,s as wt,q6 as x,me as xt,t8 as y,cN as yt,Y as z};
|